更新
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
# @dcloudio/types
|
||||
|
||||
uni-app 类型提示
|
||||
|
||||
## 操作流程
|
||||
|
||||
```shell
|
||||
npm run test
|
||||
npm run publish:patch
|
||||
```
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
declare namespace string {
|
||||
/**
|
||||
* @description 元素上的属性
|
||||
* @module dom
|
||||
*/
|
||||
interface AttrString extends String {}
|
||||
|
||||
/**
|
||||
* @description 元素上某个属性的值
|
||||
* @module dom
|
||||
*/
|
||||
interface AttrValueString extends String {}
|
||||
|
||||
/**
|
||||
* @description 元素全局属性`class`的值
|
||||
* @module dom
|
||||
*/
|
||||
interface ClassString extends String {}
|
||||
|
||||
/**
|
||||
* @description 元素全局属性`id`的值
|
||||
* @module dom
|
||||
*/
|
||||
interface IDString extends String {}
|
||||
|
||||
/**
|
||||
* @description 元素上的事件
|
||||
* @module dom
|
||||
*/
|
||||
interface HTMLEventString extends String {}
|
||||
|
||||
/**
|
||||
* @description CSS颜色的值
|
||||
* @module dom
|
||||
*/
|
||||
interface ColorString extends String {}
|
||||
|
||||
/**
|
||||
* @description 提示common模块 以及js文件路径
|
||||
* @module vue
|
||||
*/
|
||||
interface RequireCommonString extends String {}
|
||||
|
||||
/**
|
||||
* @description 国际化翻译的key值
|
||||
* @module vue
|
||||
*/
|
||||
interface VueI18NKeyString extends String {}
|
||||
|
||||
/**
|
||||
* @description vue默认参数data中的属性名称
|
||||
* @module vue
|
||||
*/
|
||||
interface VueDataString extends String {}
|
||||
|
||||
/**
|
||||
* @description vue组件中ref属性的值
|
||||
* @module vue
|
||||
*/
|
||||
interface VueRefString extends String {}
|
||||
|
||||
/**
|
||||
* @description vuex 中 actions 的名称
|
||||
* @module vue
|
||||
*/
|
||||
interface VuexDispatchString extends String {}
|
||||
|
||||
/**
|
||||
* @description vuex 中 mutations 的名称
|
||||
* @module vue
|
||||
*/
|
||||
interface VuexCommitString extends String {}
|
||||
|
||||
/**
|
||||
* @description vue, nvue, uvue页面文件的文件路径(根据项目自动匹配)
|
||||
* @module vue
|
||||
*/
|
||||
interface PageURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description nvue页面文件的文件路径
|
||||
* @module vue
|
||||
*/
|
||||
interface NPageURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description uvue页面文件的文件路径, 仅在uniappx中生效
|
||||
* @module uniappx
|
||||
*/
|
||||
interface UPageURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description video 组件的 id, 仅在uniappx中生效
|
||||
* @module uniappx
|
||||
*/
|
||||
interface VideoIdString extends String {}
|
||||
|
||||
/**
|
||||
* @description web-view 组件的 id, 仅在uniappx中生效
|
||||
* @module uniappx
|
||||
*/
|
||||
interface WebviewIdString extends String {}
|
||||
|
||||
/**
|
||||
* @description uniCloud db schema中parentKey的值
|
||||
* @module uniCloud
|
||||
*/
|
||||
interface ParentFieldString extends String {}
|
||||
|
||||
/**
|
||||
* @description uniCloud db schema中required数组的值
|
||||
* @module uniCloud
|
||||
*/
|
||||
interface SchemaFieldString extends String {}
|
||||
|
||||
/**
|
||||
* @description uniCloud db schema中validateFunction的值
|
||||
* @module uniCloud
|
||||
*/
|
||||
interface ValidateFunctionString extends String {}
|
||||
|
||||
/**
|
||||
* @description uniCloud 云函数名
|
||||
* @module uniCloud
|
||||
*/
|
||||
interface CloudFunctionString extends String {}
|
||||
|
||||
/**
|
||||
* @description uniCloud 云对象名
|
||||
* @module uniCloud
|
||||
*/
|
||||
interface CloudObjectString extends String {}
|
||||
|
||||
/**
|
||||
* @description uniCloud 数据库集合的名称
|
||||
* @module uniCloud
|
||||
*/
|
||||
interface DBCollectionString extends String {}
|
||||
|
||||
/**
|
||||
* @description uniCloud 数据库字段名称
|
||||
* @module uniCloud
|
||||
*/
|
||||
interface DBFieldString extends String {}
|
||||
|
||||
/**
|
||||
* @description uniCloud 数据库要操作的集合, 要查询的字段
|
||||
* @module uniCloud
|
||||
*/
|
||||
interface JQLString extends String {}
|
||||
|
||||
/**
|
||||
* @description CSS属性的名称
|
||||
* @module jQuery
|
||||
*/
|
||||
interface cssPropertyString extends String {}
|
||||
|
||||
/**
|
||||
* @description CSS某个属性的值
|
||||
* @module jQuery
|
||||
*/
|
||||
interface cssPropertyValueString extends String {}
|
||||
|
||||
/**
|
||||
* @description CSS选择器的名称
|
||||
* @module jQuery
|
||||
*/
|
||||
interface cssSelectorString extends String {}
|
||||
|
||||
/**
|
||||
* @description 任意文件的文件路径
|
||||
* @module uri
|
||||
*/
|
||||
interface URIString extends String {}
|
||||
|
||||
/**
|
||||
* @description css文件的文件路径(后缀为`.css`的文件路径)
|
||||
* @module uri
|
||||
*/
|
||||
interface CSSURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description js文件的文件路径(后缀为`.js`的文件路径)
|
||||
* @module uri
|
||||
*/
|
||||
interface JSURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description html文件的文件路径(后缀为`.html`的文件路径)
|
||||
* @module uri
|
||||
*/
|
||||
interface HTMLURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description markdown文件的文件路径(后缀为`.md`的文件路径)
|
||||
* @module uri
|
||||
*/
|
||||
interface MarkdownURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description js, ts, uts引用文件或模块的文件路径(支持vue,nvue,uvue中script标签内容), 例: `import xxx from 'xxx'`
|
||||
* @module uri
|
||||
*/
|
||||
interface ScriptImportURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description css文件可以引用的文件的文件路径, 后缀为`[".css"]`的文件路径 例: `@import url('xxx.css')`
|
||||
* @module uri
|
||||
*/
|
||||
interface CssImportURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description scss文件可以引用的文件的文件路径, 后缀为`[".scss", ".css"]`的文件路径, 例: `@import 'xxx.scss'`
|
||||
* @module uri
|
||||
*/
|
||||
interface ScssImportURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description less文件可以引用的文件的文件路径, 后缀为`[".less", ".css"]`的文件路径, 例: `@import 'xxx.less'`
|
||||
* @module uri
|
||||
*/
|
||||
interface LessImportURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description 字体文件的文件路径
|
||||
* @module uri
|
||||
*/
|
||||
interface FontURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description 图片文件的文件路径
|
||||
* @module uri
|
||||
*/
|
||||
interface ImageURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description 音频文件的文件路径
|
||||
* @module uri
|
||||
*/
|
||||
interface AudioURIString extends String {}
|
||||
|
||||
/**
|
||||
* @description 视频文件的文件路径
|
||||
* @module uri
|
||||
*/
|
||||
interface VideoURIString extends String {}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
/// <reference path="./HBuilderX.d.ts" />
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/// <reference path="../hbuilder-x/index.d.ts" />
|
||||
/// <reference path="./plus.d.ts" />
|
||||
+20746
File diff suppressed because it is too large
Load Diff
+2
@@ -0,0 +1,2 @@
|
||||
/// <reference path="./uni-app/index.d.ts" />
|
||||
/// <reference path="./html5plus/plus.d.ts" />
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "@dcloudio/types",
|
||||
"version": "3.4.32",
|
||||
"description": "uni-app types",
|
||||
"typings": "index.d.ts",
|
||||
"scripts": {
|
||||
"tslint": "tslint --project ./ --fix",
|
||||
"dtslint": "dtslint ./",
|
||||
"test": "dtslint ./",
|
||||
"build:wx": "node ./scripts/build-wx.js",
|
||||
"build": "npm run build:wx && npm run build:promisify",
|
||||
"prepublishOnly": "npm run test",
|
||||
"build:promisify": "node ./scripts/build-promisify.js",
|
||||
"publish:patch": "npm version patch && npm publish",
|
||||
"publish:minor": "npm version minor && npm publish",
|
||||
"publish:major": "npm version major && npm publish",
|
||||
"postpublish": "npx cnpm sync @dcloudio/types"
|
||||
},
|
||||
"author": "fxy060608",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@definitelytyped/dtslint": "^0.0.115",
|
||||
"miniprogram-api-typings": "4.1.2",
|
||||
"ts-morph": "^17.0.1",
|
||||
"tslint": "^5.14.0",
|
||||
"typescript": "5.0.4",
|
||||
"vue": "2.6"
|
||||
},
|
||||
"packageManager": "pnpm@9.5.0+sha512.140036830124618d624a2187b50d04289d5a087f326c9edfc0ccd733d76c4f52c3a313d4fc148794a2a9d81553016004e6742e8cf850670268a7387fc220c903"
|
||||
}
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
declare namespace App {
|
||||
interface ReferrerInfo {
|
||||
/**
|
||||
* 来源小程序或公众号或App的 appId
|
||||
*
|
||||
* 以下场景支持返回 referrerInfo.appId:
|
||||
* - 1020(公众号 profile 页相关小程序列表): appId
|
||||
* - 1035(公众号自定义菜单):来源公众号 appId
|
||||
* - 1036(App 分享消息卡片):来源应用 appId
|
||||
* - 1037(小程序打开小程序):来源小程序 appId
|
||||
* - 1038(从另一个小程序返回):来源小程序 appId
|
||||
* - 1043(公众号模板消息):来源公众号 appId
|
||||
*/
|
||||
appId: string;
|
||||
/**
|
||||
* 来源小程序传过来的数据,scene=1037或1038时支持
|
||||
*/
|
||||
extraData?: any;
|
||||
}
|
||||
|
||||
interface LaunchShowOption {
|
||||
/**
|
||||
* 打开小程序的路径
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* 打开小程序的query
|
||||
*/
|
||||
query: AnyObject;
|
||||
/**
|
||||
* 打开小程序的场景值
|
||||
* - 1001: 发现栏小程序主入口,「最近使用」列表(基础库2.2.4版本起包含「我的小程序」列表)
|
||||
* - 1005: 顶部搜索框的搜索结果页
|
||||
* - 1006: 发现栏小程序主入口搜索框的搜索结果页
|
||||
* - 1007: 单人聊天会话中的小程序消息卡片
|
||||
* - 1008: 群聊会话中的小程序消息卡片
|
||||
* - 1011: 扫描二维码
|
||||
* - 1012: 长按图片识别二维码
|
||||
* - 1013: 手机相册选取二维码
|
||||
* - 1014: 小程序模板消息
|
||||
* - 1017: 前往体验版的入口页
|
||||
* - 1019: 微信钱包
|
||||
* - 1020: 公众号 profile 页相关小程序列表
|
||||
* - 1022: 聊天顶部置顶小程序入口
|
||||
* - 1023: 安卓系统桌面图标
|
||||
* - 1024: 小程序 profile 页
|
||||
* - 1025: 扫描一维码
|
||||
* - 1026: 附近小程序列表
|
||||
* - 1027: 顶部搜索框搜索结果页「使用过的小程序」列表
|
||||
* - 1028: 我的卡包
|
||||
* - 1029: 卡券详情页
|
||||
* - 1030: 自动化测试下打开小程序
|
||||
* - 1031: 长按图片识别一维码
|
||||
* - 1032: 手机相册选取一维码
|
||||
* - 1034: 微信支付完成页
|
||||
* - 1035: 公众号自定义菜单
|
||||
* - 1036: App 分享消息卡片
|
||||
* - 1037: 小程序打开小程序
|
||||
* - 1038: 从另一个小程序返回
|
||||
* - 1039: 摇电视
|
||||
* - 1042: 添加好友搜索框的搜索结果页
|
||||
* - 1043: 公众号模板消息
|
||||
* - 1044: 带 shareTicket 的小程序消息卡片
|
||||
* - 1045: 朋友圈广告
|
||||
* - 1046: 朋友圈广告详情页
|
||||
* - 1047: 扫描小程序码
|
||||
* - 1048: 长按图片识别小程序码
|
||||
* - 1049: 手机相册选取小程序码
|
||||
* - 1052: 卡券的适用门店列表
|
||||
* - 1053: 搜一搜的结果页
|
||||
* - 1054: 顶部搜索框小程序快捷入口
|
||||
* - 1056: 音乐播放器菜单
|
||||
* - 1057: 钱包中的银行卡详情页
|
||||
* - 1058: 公众号文章
|
||||
* - 1059: 体验版小程序绑定邀请页
|
||||
* - 1064: 微信连Wi-Fi状态栏
|
||||
* - 1067: 公众号文章广告
|
||||
* - 1068: 附近小程序列表广告
|
||||
* - 1069: 移动应用
|
||||
* - 1071: 钱包中的银行卡列表页
|
||||
* - 1072: 二维码收款页面
|
||||
* - 1073: 客服消息列表下发的小程序消息卡片
|
||||
* - 1074: 公众号会话下发的小程序消息卡片
|
||||
* - 1077: 摇周边
|
||||
* - 1078: 连Wi-Fi成功页
|
||||
* - 1079: 微信游戏中心
|
||||
* - 1081: 客服消息下发的文字链
|
||||
* - 1082: 公众号会话下发的文字链
|
||||
* - 1084: 朋友圈广告原生页
|
||||
* - 1089: 微信聊天主界面下拉,「最近使用」栏(基础库2.2.4版本起包含「我的小程序」栏)
|
||||
* - 1090: 长按小程序右上角菜单唤出最近使用历史
|
||||
* - 1091: 公众号文章商品卡片
|
||||
* - 1092: 城市服务入口
|
||||
* - 1095: 小程序广告组件
|
||||
* - 1096: 聊天记录
|
||||
* - 1097: 微信支付签约页
|
||||
* - 1099: 页面内嵌插件
|
||||
* - 1102: 公众号 profile 页服务预览
|
||||
* - 1103: 发现栏小程序主入口,「我的小程序」列表(基础库2.2.4版本起废弃)
|
||||
* - 1104: 微信聊天主界面下拉,「我的小程序」栏(基础库2.2.4版本起废弃)
|
||||
*/
|
||||
scene: number;
|
||||
/**
|
||||
* 打开小程序的场景值
|
||||
*/
|
||||
shareTicket: string;
|
||||
/**
|
||||
* 当场景为由从另一个小程序或公众号或App打开时,返回此字段
|
||||
*/
|
||||
referrerInfo?: ReferrerInfo;
|
||||
}
|
||||
|
||||
interface PageNotFoundOption {
|
||||
/**
|
||||
* 不存在页面的路径
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* 打开不存在页面的 query
|
||||
*/
|
||||
query: AnyObject;
|
||||
/**
|
||||
* 是否本次启动的首个页面(例如从分享等入口进来,首个页面是开发者配置的分享页面)
|
||||
*/
|
||||
isEntryPage: boolean;
|
||||
}
|
||||
|
||||
interface AppInstance<T extends AnyObject = {}> {
|
||||
/**
|
||||
* 全局对象
|
||||
* 文档:[https://uniapp.dcloud.io/collocation/App?id=globaldata](https://uniapp.dcloud.io/collocation/App?id=globaldata)
|
||||
*/
|
||||
globalData?: AnyObject;
|
||||
/**
|
||||
* 生命周期回调 监听应用初始化
|
||||
*
|
||||
* 应用初始化完成时触发,全局只触发一次。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/collocation/frame/lifecycle](https://uniapp.dcloud.io/collocation/frame/lifecycle)
|
||||
*/
|
||||
onLaunch?(options?: LaunchShowOption): void;
|
||||
/**
|
||||
* 生命周期回调 监听应用显示
|
||||
*
|
||||
* 应用启动,或从后台进入前台显示时触发
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/collocation/frame/lifecycle](https://uniapp.dcloud.io/collocation/frame/lifecycle)
|
||||
*/
|
||||
onShow?(options?: LaunchShowOption): void;
|
||||
/**
|
||||
* 生命周期回调 监听应用隐藏
|
||||
*
|
||||
* 应用从前台进入后台时触发
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/collocation/frame/lifecycle](https://uniapp.dcloud.io/collocation/frame/lifecycle)
|
||||
*/
|
||||
onHide?(): void;
|
||||
/**
|
||||
* 错误监听函数
|
||||
* 小程序发生脚本错误或 API 调用报错时触发
|
||||
* @param error 错误信息,包含堆栈
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/collocation/frame/lifecycle](https://uniapp.dcloud.io/collocation/frame/lifecycle)
|
||||
*/
|
||||
onError?(error: string): void;
|
||||
/**
|
||||
* 页面不存在监听函数
|
||||
*
|
||||
* 应用要打开的页面不存在时触发,会带上页面信息回调该函数
|
||||
*
|
||||
* **注意:**
|
||||
* 1. 如果开发者没有添加 `onPageNotFound` 监听,当跳转页面不存在时,将推入微信客户端原生的页面不存在提示页面。
|
||||
* 2. 如果 `onPageNotFound` 回调中又重定向到另一个不存在的页面,将推入微信客户端原生的页面不存在提示页面,并且不再回调 `onPageNotFound`。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/collocation/frame/lifecycle](https://uniapp.dcloud.io/collocation/frame/lifecycle)
|
||||
*/
|
||||
onPageNotFound?(options: PageNotFoundOption): void;
|
||||
/**
|
||||
* 未处理的 Promise 拒绝事件监听函数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/collocation/frame/lifecycle](https://uniapp.dcloud.io/collocation/frame/lifecycle)
|
||||
*/
|
||||
onUnhandledRejection?(
|
||||
options: UniNamespace.OnUnhandledRejectionCallbackResult
|
||||
): void;
|
||||
/**
|
||||
* 监听系统主题变化
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/collocation/frame/lifecycle](https://uniapp.dcloud.io/collocation/frame/lifecycle)
|
||||
*/
|
||||
onThemeChange?(options: UniNamespace.OnThemeChangeCallbackResult): void;
|
||||
/**
|
||||
* 监听 nvue 页面消息
|
||||
*
|
||||
* nvue 页面使用 `uni.postMessage` 发送消息时触发
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/collocation/frame/lifecycle](https://uniapp.dcloud.io/collocation/frame/lifecycle)
|
||||
*/
|
||||
onUniNViewMessage?(options: AnyObject): void;
|
||||
}
|
||||
|
||||
type AppConstructor = <T extends AnyObject & AppInstance>(
|
||||
options: AppInstance<T> & T,
|
||||
) => void;
|
||||
|
||||
interface GetAppOption {
|
||||
/**
|
||||
* 在 `App` 未定义时返回默认实现。当App被调用时,默认实现中定义的属性会被覆盖合并到App中。一般用于独立分包
|
||||
*/
|
||||
allowDefault: boolean;
|
||||
}
|
||||
|
||||
type GetApp = <T extends AnyObject>(opts?: GetAppOption) => AppInstance<T> & T;
|
||||
}
|
||||
|
||||
declare const getApp: App.GetApp;
|
||||
|
||||
declare const createApp: any;
|
||||
declare const createPage: any;
|
||||
declare const createComponent: any;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/// <reference path="../hbuilder-x/index.d.ts" />
|
||||
/// <reference path="./uni-cloud-client/index.d.ts" />
|
||||
|
||||
/**
|
||||
* uniCloud 实例变量
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/uniCloud/](https://uniapp.dcloud.net.cn/uniCloud/)
|
||||
*/
|
||||
declare const uniCloud: UniCloudNamespace.UniCloud;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
interface AnyObject {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
type KVInfer<T> = { [K in keyof T]: T[K] };
|
||||
|
||||
type Void<T> = T | undefined | null;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/// <reference path="../hbuilder-x/index.d.ts" />
|
||||
/// <reference path="../html5plus/plus.d.ts" />
|
||||
/// <reference path="./common.d.ts" />
|
||||
/// <reference path="./app.d.ts" />
|
||||
/// <reference path="./page.d.ts" />
|
||||
/// <reference path="./uni/index.d.ts" />
|
||||
/// <reference path="./uni-patches/index.d.ts" />
|
||||
/// <reference path="./cloud.d.ts" />
|
||||
|
||||
import UniApp = UniNamespace;
|
||||
import UniCloud = UniCloudNamespace;
|
||||
+718
@@ -0,0 +1,718 @@
|
||||
declare namespace Page {
|
||||
interface CustomShareContent {
|
||||
/**
|
||||
* 转发标题。默认值:当前应用名称
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* 转发路径,必须是以 / 开头的完整路径。默认值:当前页面 path
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* 自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径。支持PNG及JPG。显示图片长宽比是 5:4,默认值:使用默认截图
|
||||
*/
|
||||
imageUrl?: string;
|
||||
/**
|
||||
* 如果该参数存在,则以 resolve 结果为准,如果三秒内不 resolve,分享会使用上面传入的默认参数
|
||||
*/
|
||||
promise?: Promise<{
|
||||
/**
|
||||
* 转发标题。默认值:当前应用名称
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* 转发路径,必须是以 / 开头的完整路径。默认值:当前页面 path
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* 自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径。支持PNG及JPG。显示图片长宽比是 5:4,默认值:使用默认截图
|
||||
*/
|
||||
imageUrl?: string;
|
||||
}>;
|
||||
/**
|
||||
* 自定义分享描述
|
||||
*/
|
||||
desc?: string;
|
||||
/**
|
||||
* 自定义吱口令文案,最多 28 个字符
|
||||
*/
|
||||
content?: string;
|
||||
/**
|
||||
* 自定义分享预览大图,建议尺寸 750x825,支持:网络图片路径、apFilePath 路径、相对路径,不支持:base64
|
||||
*/
|
||||
bgImgUrl?: string;
|
||||
/**
|
||||
* 自定义社交图片链接,作为分享到支付宝好友时的主体图片。建议尺寸 376x330
|
||||
*/
|
||||
scImgUrl?: string;
|
||||
/**
|
||||
* 生成分享截图的搜索引导,设置该参数后,会在分享图片中增加上支付宝搜“设置关键字”的内容,设置关键字不能超过 5 个字
|
||||
*/
|
||||
searchTip?: string;
|
||||
/**
|
||||
* 分享成功后回调
|
||||
*/
|
||||
success?: () => void;
|
||||
/**
|
||||
* 分享失败后回调
|
||||
*/
|
||||
fail?: () => void;
|
||||
/**
|
||||
* 开发者后台设置的分享素材模板 id
|
||||
*/
|
||||
templateId?: string;
|
||||
/**
|
||||
* PC端打开小程序加载的页面,不支持可传空字符串
|
||||
*/
|
||||
PCPath?: string;
|
||||
/**
|
||||
* PC端打开小程序加载的模式,若需要在PC端打开小程序,则必须传PCMode字段
|
||||
*/
|
||||
PCMode?: string;
|
||||
/**
|
||||
* PCQQ、低版本手机QQ无法执行小程序时打开的H5页面
|
||||
*/
|
||||
generalWebpageUrl?: string;
|
||||
/**
|
||||
* 监听用户点击页面内转发按钮的,只有带上该参数,才支持快速分享
|
||||
*/
|
||||
entryDataHash?: string;
|
||||
/**
|
||||
* 分享模板id,可以使用不同的分享模版,可选模版参考管理端分享模版一栏
|
||||
*/
|
||||
shareTemplateId?: string;
|
||||
/**
|
||||
* 分享模板的数据,不同的模板id需要不同的数据,数据的格式请参考管理端分享模版一栏
|
||||
*/
|
||||
shareTemplateData?: string;
|
||||
/**
|
||||
* 指定分享的类型
|
||||
*/
|
||||
shareType?: string;
|
||||
/**
|
||||
* 转发形式(1 - 京东小程序正式版;2 - 京东小程序体验版;京东App9.0.0开始不填或者其他值都会先判断是否有url参数,如果有打开分享后显示url对应页面,否则默认生成京东小程序官方的一个分享中间页面,点击可跳到京东app里面的对应小程序)
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* 渠道(不写默认微信朋友,微信朋友圈),可用值有:Wxfriends,QQfriends,Wxmoments,QQzone,Sinaweibo
|
||||
*/
|
||||
channel?: string;
|
||||
/**
|
||||
* h5链接地址(h5分享填写,不填默认中间页)
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* 口令分享渠道,可用值有:Wxfriends,QQfriends,Wxmoments,QQzone,Sinaweibo,当需要口令分享时,需要配置此选项
|
||||
*/
|
||||
keyShareChannel?: string;
|
||||
/**
|
||||
* 海报分享,本地图片地址(海报图片由开发者生成后将图片地址传入jdfile开头的格式)
|
||||
*/
|
||||
localImageUrl?: string;
|
||||
/**
|
||||
* 海报分享,网络图片地址(海报图片由开发者生成后将图片地址传入),注意:localImageUrl、onlineImageUrl建议开发者使用时只传一个值 如果传入两个值 优先localImageUrl
|
||||
*/
|
||||
onlineImageUrl?: string;
|
||||
}
|
||||
|
||||
interface PageScrollOption {
|
||||
/**
|
||||
* 页面在垂直方向已滚动的距离(单位 px)
|
||||
*/
|
||||
scrollTop: number;
|
||||
}
|
||||
|
||||
interface ResizeOption {
|
||||
/**
|
||||
* 页面在垂直方向已滚动的距离(单位 px)
|
||||
*/
|
||||
scrollTop: number;
|
||||
/**
|
||||
* 新的显示区域尺寸
|
||||
*/
|
||||
size?: {
|
||||
/**
|
||||
* 新的显示区域宽度
|
||||
*/
|
||||
windowWidth: number;
|
||||
/**
|
||||
* 新的显示区域高度
|
||||
*/
|
||||
windowHeight: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface ShareAppMessageOption {
|
||||
/**
|
||||
* 转发事件来源。
|
||||
* 可选值:
|
||||
* - `button`:页面内转发按钮;
|
||||
* - `menu`:右上角转发菜单。
|
||||
*/
|
||||
from: "button" | "menu";
|
||||
/**
|
||||
* 如果 `from` 值是 `button`,则 `target` 是触发这次转发事件的 `button`,否则为 `undefined`
|
||||
*/
|
||||
target: any;
|
||||
/**
|
||||
* 页面中包含 `<web-view>` 组件时,返回当前 `<web-view>` 的 url
|
||||
*/
|
||||
webViewUrl?: string;
|
||||
}
|
||||
|
||||
interface AddToFavoritesOption {
|
||||
/**
|
||||
* 转发事件来源。
|
||||
* 可选值:
|
||||
* - `button`:页面内转发按钮;
|
||||
* - `menu`:右上角转发菜单。
|
||||
*/
|
||||
from: "button" | "menu";
|
||||
/**
|
||||
* 页面中包含 `<web-view>` 组件时,返回当前 `<web-view>` 的 url
|
||||
*/
|
||||
webviewUrl: string;
|
||||
}
|
||||
|
||||
interface CustomFavoritesContent {
|
||||
/**
|
||||
* 自定义标题,默认值:页面标题或账号名称
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* 自定义 query 字段
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* 自定义图片,显示图片长宽比为 1:1
|
||||
*/
|
||||
imageUrl?: string;
|
||||
}
|
||||
|
||||
interface TabItemTapOption {
|
||||
/**
|
||||
* 被点击 tabItem 的序号,从0开始
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* 被点击 tabItem 的页面路径
|
||||
*/
|
||||
pagePath: string;
|
||||
/**
|
||||
* 被点击 tabItem 的按钮文字
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
|
||||
interface NavigationBarButtonTapOption {
|
||||
/**
|
||||
* 原生标题栏按钮数组的下标
|
||||
*/
|
||||
index: number;
|
||||
}
|
||||
|
||||
interface BackPressOption {
|
||||
/**
|
||||
* - backbutton 顶部导航栏左边的返回按钮或 Android 实体返回键
|
||||
* - navigateBack 返回 API,即 uni.navigateBack()
|
||||
*/
|
||||
from: 'backbutton' | 'navigateBack';
|
||||
}
|
||||
|
||||
interface NavigationBarSearchInputEvent {
|
||||
/**
|
||||
* 搜索输入框输入内容
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
|
||||
interface PageInstanceBaseProps<D extends AnyObject = any> {
|
||||
/**
|
||||
* 到当前页面的路径,类型为 `String`
|
||||
*/
|
||||
route?: string;
|
||||
/**
|
||||
* 获取当前页面的webview对象实例。仅 App 平台支持
|
||||
*/
|
||||
$getAppWebview?: () => PlusWebviewWebviewObject;
|
||||
/**
|
||||
* 当前页面的 Vue 实例
|
||||
*/
|
||||
$vm?: any;
|
||||
}
|
||||
|
||||
interface OnShareTimelineOptions extends OnShareChatOptions {}
|
||||
|
||||
interface ShareTimelineContent extends Omit<ShareChatContent, 'content'> {}
|
||||
|
||||
interface ShareChatContent {
|
||||
/**
|
||||
* 自定义标题,即朋友圈列表页上显示的标题。默认值:当前小程序名称
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* 自定义页面路径中携带的参数,如 path?a=1&b=2 的 “?” 后面部分。默认值:当前页面路径携带的参数
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* 自定义图片路径,可以是本地文件或者网络图片。支持 PNG 及 JPG,显示图片长宽比是 1:1。默认值:小程序 Logo
|
||||
*/
|
||||
imageUrl?: string;
|
||||
/**
|
||||
* 转发的路径
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* 分享到小红书站外的截图字段 (用于站外 h5 落地页展示,不传默认容器截取栈顶页面)
|
||||
*/
|
||||
externalImageUrl?: string;
|
||||
/**
|
||||
* 好友分享的内容描述 (默认取小程序描述)
|
||||
*/
|
||||
content?: string;
|
||||
/**
|
||||
* 如果该参数存在,则以 resolve 结果为准,如果三秒内不 resolve,分享会使用上面传入的默认
|
||||
*/
|
||||
promise?: Promise<Omit<ShareChatContent, 'promise'>>;
|
||||
/**
|
||||
* 分享成功回调(回调中无分享信息)
|
||||
*/
|
||||
success?: () => void;
|
||||
/**
|
||||
* 分享失败回调(回调中无失败信息)
|
||||
*/
|
||||
fail?: () => void;
|
||||
/**
|
||||
* 分享完成回调
|
||||
*/
|
||||
complete?: () => void;
|
||||
}
|
||||
|
||||
interface OnShareChatOptions {
|
||||
/**
|
||||
* 转发事件来源。button:页面内转发按钮;menu:右上角转发菜单
|
||||
*/
|
||||
from?: 'button' | 'menu';
|
||||
/**
|
||||
* 当前页面的 pageId
|
||||
*/
|
||||
pageId?: string;
|
||||
/**
|
||||
* 分享类型
|
||||
*/
|
||||
shareType?: string;
|
||||
/**
|
||||
* 如果 from 值是 button,则 target 是触发这次转发事件的 button,否则为 undefined
|
||||
*/
|
||||
target?: Record<string, any>;
|
||||
}
|
||||
|
||||
interface OnCopyUrlOptions {
|
||||
/**
|
||||
* 转发事件来源。button:页面内转发按钮;menu:右上角转发菜单
|
||||
*/
|
||||
from?: 'button' | 'menu';
|
||||
/**
|
||||
* 当前页面的 pageId
|
||||
*/
|
||||
pageId?: string;
|
||||
/**
|
||||
* 分享类型
|
||||
*/
|
||||
shareType?: string;
|
||||
}
|
||||
|
||||
interface CopyUrlContent {
|
||||
/**
|
||||
* 转发的路径 (默认为当前页面路径)
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* 自定义页面路径中携带的参数,如 path?a=1&b=2 的 “?” 后面部分 (默认为当前页面路径携带的参数)
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* 分享到小红书站外的截图字段 (用于站外 h5 落地页展示,不传默认容器截取栈顶页面)
|
||||
*/
|
||||
externalImageUrl?: string;
|
||||
/**
|
||||
* 分享成功回调(回调中无分享信息)
|
||||
*/
|
||||
success?: () => void;
|
||||
/**
|
||||
* 分享失败回调(回调中无失败信息)
|
||||
*/
|
||||
fail?: () => void;
|
||||
/**
|
||||
* 分享完成回调
|
||||
*/
|
||||
complete?: () => void;
|
||||
}
|
||||
|
||||
interface UploadDouyinVideoOptions {
|
||||
target: {
|
||||
id: string;
|
||||
dataset: Record<string, any>;
|
||||
offsetTop: number;
|
||||
offsetLeft: number;
|
||||
};
|
||||
from: 'anchor' | 'menu' | 'button' | 'mission_publish' | 'mission_select';
|
||||
webViewUrl: string;
|
||||
}
|
||||
|
||||
interface UploadDouyinVideoSuccessCallback {
|
||||
videoId?: string;
|
||||
taskResult?: Array<{
|
||||
taskId?: string;
|
||||
completed?: boolean;
|
||||
successCount?: number;
|
||||
failCount?: number;
|
||||
isValid?: boolean;
|
||||
errMsg?: string;
|
||||
errNo?: number;
|
||||
}>;
|
||||
errMsg?: string;
|
||||
}
|
||||
|
||||
interface UploadDouyinVideoFailCallback {
|
||||
errNo?: number;
|
||||
errMsg?: string;
|
||||
}
|
||||
|
||||
interface UploadDouyinVideoContent {
|
||||
videoPath?: string;
|
||||
taskIds?: string[];
|
||||
extra: {
|
||||
anchor?: {
|
||||
anchorType?: 'none' | 'app';
|
||||
title?: string;
|
||||
path?: string;
|
||||
};
|
||||
createChallenge?: boolean;
|
||||
};
|
||||
titleConfig?: {
|
||||
title?: string;
|
||||
mentionMarkers?: Array<{ start?: number; openId?: string }>;
|
||||
hashtagMarkers?: Array<{ start?: number; hashtag?: string }>;
|
||||
};
|
||||
stickersConfig?: {
|
||||
text?: Array<{
|
||||
text: string;
|
||||
color?: string;
|
||||
fontSize?: number;
|
||||
scale?: number;
|
||||
x?: number;
|
||||
y?: number;
|
||||
}>;
|
||||
hashtag?: Array<{ name: string; x?: number; y?: number }>;
|
||||
mention?: Array<{ openId: string }>;
|
||||
custom?: Array<{
|
||||
path: string;
|
||||
scale?: number;
|
||||
rotate?: number;
|
||||
x?: number;
|
||||
y?: number;
|
||||
}>;
|
||||
};
|
||||
success?: (callback: UploadDouyinVideoSuccessCallback) => void;
|
||||
fail?: (callback: UploadDouyinVideoFailCallback) => void;
|
||||
complete?: (callback: UploadDouyinVideoSuccessCallback | UploadDouyinVideoFailCallback) => void;
|
||||
}
|
||||
|
||||
interface LiveMountSuccessCallback {
|
||||
errMsg?: string;
|
||||
}
|
||||
interface LiveMountFailCallback {
|
||||
errNo?: number;
|
||||
errMsg?: string;
|
||||
}
|
||||
|
||||
interface LiveMountOptions {
|
||||
webViewUrl: string;
|
||||
}
|
||||
interface LiveMountContent {
|
||||
title?: string;
|
||||
path?: string;
|
||||
success?: (callback: LiveMountSuccessCallback) => void;
|
||||
fail?: (callback: LiveMountFailCallback) => void;
|
||||
complete?: (callback: LiveMountSuccessCallback | LiveMountFailCallback) => void;
|
||||
}
|
||||
|
||||
interface PageInstance<D extends AnyObject = any, T extends AnyObject = any>
|
||||
extends PageInstanceBaseProps<D> {
|
||||
/**
|
||||
* 生命周期回调 监听页面初始化
|
||||
*
|
||||
* 页面初始化时触发。一个页面只会调用一次,可以在 onInit 的参数中获取打开当前页面路径中的参数。
|
||||
* @param query 打开当前页面路径中的参数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "hostVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "alipay": {
|
||||
* "hostVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "baidu": {
|
||||
* "hostVer": ">=3.160.12",
|
||||
* "uniVer": ">=3.1.0",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "toutiao": {
|
||||
* "hostVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "lark": {
|
||||
* "hostVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "qq": {
|
||||
* "hostVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "kuaishou": {
|
||||
* "hostVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "jd": {
|
||||
* "hostVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "360": {
|
||||
* "hostVer": "x",
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* },
|
||||
* "quickapp": {
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
onInit?(query?: AnyObject): void;
|
||||
/**
|
||||
* 生命周期回调 监听页面加载
|
||||
*
|
||||
* 页面加载时触发。一个页面只会调用一次,可以在 onLoad 的参数中获取打开当前页面路径中的参数。
|
||||
* @param query 打开当前页面路径中的参数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onLoad?(query?: AnyObject): void;
|
||||
/**
|
||||
* 生命周期回调 监听页面显示
|
||||
*
|
||||
* 页面显示/切入前台时触发。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onShow?(): void;
|
||||
onPageShow?(): void;
|
||||
/**
|
||||
* 生命周期回调 监听页面初次渲染完成
|
||||
*
|
||||
* 页面初次渲染完成时触发。一个页面只会调用一次,代表页面已经准备妥当,可以和视图层进行交互。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onReady?(): void;
|
||||
/**
|
||||
* 生命周期回调 监听页面隐藏
|
||||
*
|
||||
* 页面隐藏/切入后台时触发。 如 `navigateTo` 或底部 `tab` 切换到其他页面,应用切入后台等。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onHide?(): void;
|
||||
onPageHide?(): void;
|
||||
/**
|
||||
* 生命周期回调 监听页面卸载
|
||||
*
|
||||
* 页面卸载时触发。如 `redirectTo` 或 `navigateBack` 到其他页面时。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onUnload?(): void;
|
||||
/**
|
||||
* 监听用户下拉动作
|
||||
* - 需要在 `pages.json` 的页面配置中开启 `enablePullDownRefresh` 。
|
||||
* - 可以通过 `uni.startPullDownRefresh` 触发下拉刷新,调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
|
||||
* - 当处理完数据刷新后,`uni.stopPullDownRefresh` 可以停止当前页面的下拉刷新。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onPullDownRefresh?(): void;
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
* - 可以在 `pages.json` 的页面配置中设置触发距离 `onReachBottomDistance` 。
|
||||
* - 在触发距离内滑动期间,本事件只会被触发一次。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onReachBottom?(): void;
|
||||
/**
|
||||
* 支付宝小程序点击标题时触发
|
||||
* 文档: [https://opendocs.alipay.com/mini/framework/page-detail#onTitleClick()](https://opendocs.alipay.com/mini/framework/page-detail#onTitleClick())
|
||||
*/
|
||||
onTitleClick?(): void;
|
||||
/**
|
||||
* 在抖音直播中挂载小程序锚点时触发
|
||||
* 文档: [https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/api/open-interface/retweet/live-mount/live-param](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/api/open-interface/retweet/live-mount/live-param)
|
||||
*/
|
||||
onLiveMount?(options: LiveMountOptions): LiveMountContent | Promise<LiveMountContent>;
|
||||
/**
|
||||
* 发布抖音视频时触发
|
||||
* 文档: [https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/api/open-interface/retweet/video-publish/upload-param](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/api/open-interface/retweet/video-publish/upload-param)
|
||||
*/
|
||||
onUploadDouyinVideo?(
|
||||
options: UploadDouyinVideoOptions
|
||||
): UploadDouyinVideoContent | Promise<UploadDouyinVideoContent>;
|
||||
/**
|
||||
* 用户点击右上角转发
|
||||
*
|
||||
* 监听用户点击页面内转发按钮(`<button>` 组件 `open-type="share"`)或右上角菜单“转发”按钮的行为,并自定义转发内容。
|
||||
* @param options 分享发起来源参数
|
||||
* @return 转发内容
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onShareAppMessage?(
|
||||
options: ShareAppMessageOption
|
||||
): CustomShareContent | Promise<Omit<CustomShareContent, "promise">>;
|
||||
/**
|
||||
* 用户点击右上角转发到朋友圈
|
||||
*
|
||||
* 监听右上角菜单“分享到朋友圈”按钮的行为,并自定义发享内容。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onShareTimeline?(options: OnShareTimelineOptions): ShareTimelineContent;
|
||||
/**
|
||||
* 用户点击右上角收藏
|
||||
*
|
||||
* 监听用户点击右上角菜单“收藏”按钮的行为,并自定义收藏内容。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onAddToFavorites?(options: AddToFavoritesOption): CustomFavoritesContent;
|
||||
/**
|
||||
* 页面滚动触发事件的处理函数
|
||||
*
|
||||
* 监听用户滑动页面事件。
|
||||
* @param options 页面滚动参数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onPageScroll?(options: PageScrollOption): void;
|
||||
/**
|
||||
* 页面尺寸改变时触发
|
||||
* @param options 页面滚动参数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
* @uniPlatform {
|
||||
* "App": {
|
||||
* "baidu": {
|
||||
* "hostVer": ">=3.160.12",
|
||||
* "uniVer": ">=3.1.0",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
onResize?(options: ResizeOption): void;
|
||||
/**
|
||||
* 当前是 tab 页时,点击 tab 时触发
|
||||
* @param options tab 点击参数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onTabItemTap?(options: TabItemTapOption): void;
|
||||
/**
|
||||
* 监听原生标题栏按钮点击事件
|
||||
* @param options tab 点击参数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onNavigationBarButtonTap?(options: NavigationBarButtonTapOption): void;
|
||||
/**
|
||||
* 监听页面返回
|
||||
* @param options tab 点击参数
|
||||
* @return 返回 `true` 时阻止页面返回
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onBackPress?(options: BackPressOption): any;
|
||||
/**
|
||||
* 监听原生标题栏搜索输入框输入内容变化事件
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onNavigationBarSearchInputChanged?(
|
||||
event: NavigationBarSearchInputEvent
|
||||
): void;
|
||||
/**
|
||||
* 监听原生标题栏搜索输入框搜索事件,用户点击软键盘上的“搜索”按钮时触发。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onNavigationBarSearchInputConfirmed?(
|
||||
event: NavigationBarSearchInputEvent
|
||||
): void;
|
||||
/**
|
||||
* 监听原生标题栏搜索输入框点击事件
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
|
||||
*/
|
||||
onNavigationBarSearchInputClicked?(): void;
|
||||
/**
|
||||
* 小红书特有生命周期:监听右上角菜单“分享到微信群组”按钮的行为,并自定义分享内容。
|
||||
*
|
||||
* 文档: [https://miniapp.xiaohongshu.com/docs?path=/docs/frame/Page#onShareChat](https://miniapp.xiaohongshu.com/docs?path=/docs/frame/Page#onShareChat)
|
||||
*/
|
||||
onShareChat?(options: OnShareChatOptions): ShareChatContent;
|
||||
/**
|
||||
* 小红书特有生命周期:监听右上角菜单“复制链接”按钮的行为,并自定义分享内容。
|
||||
*
|
||||
* 文档:[https://miniapp.xiaohongshu.com/doc/DC686827#anchorId-oncopyurl](https://miniapp.xiaohongshu.com/doc/DC686827#anchorId-oncopyurl)
|
||||
*/
|
||||
onCopyUrl?(options: OnCopyUrlOptions): CopyUrlContent;
|
||||
}
|
||||
|
||||
type PageConstructor = <T extends AnyObject & PageInstance>(
|
||||
options: PageInstance<AnyObject, T> & T
|
||||
) => void;
|
||||
|
||||
type GetCurrentPages = <T extends AnyObject = {}>() => Array<
|
||||
PageInstance<AnyObject, T> & T
|
||||
>;
|
||||
}
|
||||
|
||||
declare const getCurrentPages: Page.GetCurrentPages;
|
||||
+256
@@ -0,0 +1,256 @@
|
||||
declare namespace UniCloudNamespace {
|
||||
interface CurrentUserInfo {
|
||||
/**
|
||||
* 当前用户uid
|
||||
*/
|
||||
uid: string;
|
||||
/**
|
||||
* 当前用户角色列表
|
||||
*/
|
||||
role: any[];
|
||||
/**
|
||||
* 当前用户权限列表
|
||||
*/
|
||||
permission: any[];
|
||||
}
|
||||
|
||||
interface UniCloudOptions {
|
||||
/**
|
||||
* 选择服务供应商
|
||||
* - tencent: 选择腾讯云作为服务商
|
||||
* - aliyun: 选择阿里云作为服务商
|
||||
*/
|
||||
provider: 'tencent' | 'aliyun';
|
||||
/**
|
||||
* 服务空间ID
|
||||
*/
|
||||
spaceId: string;
|
||||
/**
|
||||
* 服务空间对应的clientSecret
|
||||
*/
|
||||
clientSecret?: string;
|
||||
/**
|
||||
* 服务空间地址
|
||||
*/
|
||||
endpoint?: string;
|
||||
}
|
||||
|
||||
interface UniError {
|
||||
/**
|
||||
* 错误模块名
|
||||
*/
|
||||
errSubject?: string;
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
errCode: number | string;
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
errMsg: string;
|
||||
/**
|
||||
* 请求id方便排错
|
||||
*/
|
||||
requestId?: string;
|
||||
/**
|
||||
* 错误详情
|
||||
*/
|
||||
detail?: any;
|
||||
/**
|
||||
* 上级错误
|
||||
*/
|
||||
cause?: UniError;
|
||||
}
|
||||
|
||||
interface CallFunctionResult {
|
||||
/**
|
||||
* 云函数执行结果
|
||||
*/
|
||||
result: any;
|
||||
/**
|
||||
* 请求序列号,用于错误排查
|
||||
*/
|
||||
requestId?: string;
|
||||
}
|
||||
|
||||
enum SECRET_TYPE {
|
||||
/**
|
||||
* 不加密
|
||||
*/
|
||||
none = 'none',
|
||||
/**
|
||||
* 仅请求参数加密
|
||||
*/
|
||||
request = 'request',
|
||||
/**
|
||||
* 仅响应结果加密
|
||||
*/
|
||||
response = 'response',
|
||||
/**
|
||||
* 请求响应均加密
|
||||
*/
|
||||
both = 'both'
|
||||
}
|
||||
interface CallFunctionOptions {
|
||||
/**
|
||||
* 云函数名
|
||||
*/
|
||||
name: string | string.CloudFunctionString;
|
||||
/**
|
||||
* 传递给云函数的参数
|
||||
*/
|
||||
data?: any;
|
||||
|
||||
/** 云函数请求超时配置 */
|
||||
timeout?: number;
|
||||
|
||||
/**
|
||||
* 安全网络类型
|
||||
* - none:不加密
|
||||
* - request:仅请求参数加密
|
||||
* - response:仅响应结果加密
|
||||
* - both:请求响应均加密
|
||||
*/
|
||||
secretType?: keyof typeof SECRET_TYPE;
|
||||
/**
|
||||
* 成功返回的回调函数
|
||||
*/
|
||||
success?: (result: CallFunctionResult) => void;
|
||||
/**
|
||||
* 失败返回的回调函数
|
||||
*/
|
||||
fail?: (result: any) => void;
|
||||
/**
|
||||
* 结束的回调函数(调用成功、失败都会执行
|
||||
*/
|
||||
complete?: (result: CallFunctionResult) => void;
|
||||
}
|
||||
|
||||
interface ImportObjectLoadingOptions {
|
||||
/**
|
||||
* loading界面文字
|
||||
*/
|
||||
text?: string;
|
||||
/**
|
||||
* loading是否显示透明遮罩
|
||||
*/
|
||||
mask?: boolean;
|
||||
}
|
||||
|
||||
interface ImportObjectErrorOptions {
|
||||
/**
|
||||
* 错误提示类型,modal | toast
|
||||
*/
|
||||
type?: 'modal' | 'toast';
|
||||
/**
|
||||
* 是否显示重试按钮,type为modal时生效
|
||||
*/
|
||||
retry?: boolean;
|
||||
}
|
||||
|
||||
interface ParseSystemErrorOptions {
|
||||
/**
|
||||
* 云对象名
|
||||
*/
|
||||
objectName: string;
|
||||
/**
|
||||
* 调用的方法名
|
||||
*/
|
||||
methodName: string;
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
params: Array<any>;
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
errCode: string | number;
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
errMsg: string;
|
||||
}
|
||||
|
||||
interface ParsedSystemErrorResult {
|
||||
errMsg: string;
|
||||
}
|
||||
|
||||
interface ImportObjectOptions {
|
||||
/**
|
||||
* 是否移除自动展示的ui
|
||||
*/
|
||||
customUI?: boolean;
|
||||
/**
|
||||
* loading界面配置
|
||||
*/
|
||||
loadingOptions?: ImportObjectLoadingOptions;
|
||||
/**
|
||||
* 错误提示配置
|
||||
*/
|
||||
errorOptions?: ImportObjectErrorOptions;
|
||||
/**
|
||||
* 使用安全网络的方法及安全网络类型
|
||||
*/
|
||||
secretMethods?: Record<string, keyof typeof SECRET_TYPE>;
|
||||
/**
|
||||
* 转化云对象内未捕获的错误或客户端网络错误
|
||||
*/
|
||||
parseSystemError?: (options: ParseSystemErrorOptions) => Promise<ParsedSystemErrorResult> | ParsedSystemErrorResult;
|
||||
}
|
||||
|
||||
interface InitSecureNetworkByWeixinOptions {
|
||||
/**
|
||||
* 是否握手并自动调用uni-id-co的微信登录,默认仅调用uni-id-co的secureNetworkHandshakeByWeixin不调用微信登录
|
||||
*/
|
||||
callLoginByWeixin?: boolean;
|
||||
/**
|
||||
* 用户openid,传此参数时不会调用uni-id-co的任何方法
|
||||
*/
|
||||
openid?: string;
|
||||
}
|
||||
|
||||
interface InitSecureNetworkByWeixinResponse {
|
||||
code?: string;
|
||||
}
|
||||
|
||||
interface UniCloud {
|
||||
/** 用于快速开发datacom规范的组件 */
|
||||
mixinDatacom: any;
|
||||
/**
|
||||
* 服务空间初始化,返回uniCloud实例
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/init](https://uniapp.dcloud.io/uniCloud/init)
|
||||
*/
|
||||
init(options: UniCloudOptions): UniCloud;
|
||||
/**
|
||||
* 设置自定义clientInfo信息
|
||||
*
|
||||
* 文档: [https://doc.dcloud.net.cn/uniCloud/client-sdk.html#set-custom-client-info](https://doc.dcloud.net.cn/uniCloud/client-sdk.html#set-custom-client-info)
|
||||
*/
|
||||
setCustomClientInfo(options: object): void;
|
||||
/**
|
||||
* 调用云函数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/cf-functions?id=clientcallfunction](https://uniapp.dcloud.io/uniCloud/cf-functions?id=clientcallfunction)
|
||||
*/
|
||||
callFunction(options: CallFunctionOptions): Promise<any>;
|
||||
/**
|
||||
* 引用云对象
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/cloud-obj](https://uniapp.dcloud.io/uniCloud/cloud-obj)
|
||||
*/
|
||||
importObject(objectName: string | string.CloudObjectString, importObjectOptions?: ImportObjectOptions): any;
|
||||
/**
|
||||
* 获取当前用户缓存在token内的信息
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#client-getcurrentuserinfo](https://uniapp.dcloud.io/uniCloud/client-sdk.html#client-getcurrentuserinfo)
|
||||
*/
|
||||
getCurrentUserInfo(): CurrentUserInfo;
|
||||
/**
|
||||
* 微信小程序安全网络初始化
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#client-getcurrentuserinfo](https://uniapp.dcloud.io/uniCloud/client-sdk.html#init-secure-network-by-weixin)
|
||||
*/
|
||||
initSecureNetworkByWeixin(options?: InitSecureNetworkByWeixinOptions): Promise<InitSecureNetworkByWeixinResponse>;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
declare namespace UniCloudNamespace {
|
||||
interface UserInfo {
|
||||
/**
|
||||
* 用户在uniCloud的唯一ID
|
||||
*/
|
||||
uid: string;
|
||||
/**
|
||||
* 自定义登录的用户ID
|
||||
*/
|
||||
customUserId: string;
|
||||
}
|
||||
|
||||
interface Auth {
|
||||
/**
|
||||
* 任何方式登录成功后,可以调用 getUserInfo 获得用户的身份信息
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/authentication?id=authgetuserinfo](https://uniapp.dcloud.io/uniCloud/authentication?id=authgetuserinfo)
|
||||
*/
|
||||
getUserInfo(): UserInfo;
|
||||
/**
|
||||
* 开发者可以通过 getLoginState() 来获取当前的登录状态,调用 getLoginState() 后,SDK 会识别本地是否有登录状态,如果有,则会尝试刷新登录状态,若刷新登录状态成功,则会返回新的登录状态,否则返回 undefined
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/authentication?id=authgetloginstate](https://uniapp.dcloud.io/uniCloud/authentication?id=authgetloginstate)
|
||||
*/
|
||||
getLoginState(): void;
|
||||
/**
|
||||
* 进行匿名登录
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/authentication?id=authsigninanonymously](https://uniapp.dcloud.io/uniCloud/authentication?id=authsigninanonymously)
|
||||
*/
|
||||
signInAnonymously(): void;
|
||||
/**
|
||||
* 进行自定义登录
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/authentication?id=authsigninwithticket](https://uniapp.dcloud.io/uniCloud/authentication?id=authsigninwithticket)
|
||||
*/
|
||||
signInWithTicket(): void;
|
||||
/**
|
||||
* 进行自定义登录
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/authentication?id=authshouldrefreshaccesstoken](https://uniapp.dcloud.io/uniCloud/authentication?id=authshouldrefreshaccesstoken)
|
||||
*/
|
||||
shouldRefreshAccessToken(callback: (result: any) => void): void;
|
||||
}
|
||||
|
||||
interface UniCloud {
|
||||
/**
|
||||
* 获取登录对象
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/authentication?id=custom-auth](https://uniapp.dcloud.io/uniCloud/authentication?id=custom-auth)
|
||||
*/
|
||||
customAuth(): Auth;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+1597
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
declare namespace UniCloudNamespace {
|
||||
interface UniCloudResponseEvent {
|
||||
type: 'clientdb' | 'cloudobject' | 'cloudfunction';
|
||||
content: any;
|
||||
}
|
||||
|
||||
interface UniCloudNeedLoginEvent {
|
||||
errCode: string | number;
|
||||
errMsg: string;
|
||||
uniIdRedirectUrl: string;
|
||||
}
|
||||
|
||||
interface UniCloudRefreshTokenEvent {
|
||||
token: string;
|
||||
tokenExpired: number;
|
||||
}
|
||||
|
||||
interface UniCloud {
|
||||
/** 事件回调 */
|
||||
on(eventName: string, callback: (result: any) => void): void;
|
||||
/**
|
||||
* 监听云函数、云对象、clientDB的响应
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#on-response](https://uniapp.dcloud.io/uniCloud/client-sdk.html#on-response)
|
||||
*/
|
||||
onResponse(callback: (result?: UniCloudResponseEvent) => void): void;
|
||||
/**
|
||||
* 移除监听云函数、云对象、clientDB的响应
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#off-response](https://uniapp.dcloud.io/uniCloud/client-sdk.html#off-response)
|
||||
*/
|
||||
offResponse(callback: (result?: UniCloudResponseEvent) => void): void;
|
||||
/**
|
||||
* 监听需要登录事件
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#on-need-login](https://uniapp.dcloud.io/uniCloud/client-sdk.html#on-need-login)
|
||||
*/
|
||||
onNeedLogin(callback: (result?: UniCloudNeedLoginEvent) => void): void;
|
||||
/**
|
||||
* 移除监听需要登录事件
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#off-need-login](https://uniapp.dcloud.io/uniCloud/client-sdk.html#off-need-login)
|
||||
*/
|
||||
offNeedLogin(callback: (result?: UniCloudNeedLoginEvent) => void): void;
|
||||
/**
|
||||
* 监听token刷新事件
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#on-refresh-token](https://uniapp.dcloud.io/uniCloud/client-sdk.html#on-refresh-token)
|
||||
*/
|
||||
onRefreshToken(callback: (result?: UniCloudRefreshTokenEvent) => void): void;
|
||||
/**
|
||||
* 移除监听token刷新事件
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#off-refresh-token](https://uniapp.dcloud.io/uniCloud/client-sdk.html#off-refresh-token)
|
||||
*/
|
||||
offRefreshToken(callback: (result: UniCloudRefreshTokenEvent) => void): void;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
/// <reference path="custom-auth.d.ts" />
|
||||
/// <reference path="database.d.ts" />
|
||||
/// <reference path="event.d.ts" />
|
||||
/// <reference path="interceptor.d.ts" />
|
||||
/// <reference path="sse-channel.d.ts" />
|
||||
/// <reference path="storage.d.ts" />
|
||||
/// <reference path="websocket.d.ts" />
|
||||
Generated
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
declare namespace UniCloudNamespace {
|
||||
interface Interceptor {
|
||||
invoke?: (result: any) => void;
|
||||
success?: (result: any) => void;
|
||||
fail?: (result: any) => void;
|
||||
complete?: (result: any) => void;
|
||||
}
|
||||
|
||||
interface BaseObjectInterceptorArgs {
|
||||
objectName: string;
|
||||
methodName: string;
|
||||
params: string;
|
||||
}
|
||||
|
||||
interface SuccessObjectInterceptorArgs extends BaseObjectInterceptorArgs {
|
||||
result: any;
|
||||
}
|
||||
|
||||
interface FailObjectInterceptorArgs extends BaseObjectInterceptorArgs {
|
||||
error: UniError;
|
||||
}
|
||||
|
||||
type CompleteObjectInterceptorArgs = SuccessObjectInterceptorArgs | FailObjectInterceptorArgs;
|
||||
|
||||
interface ObjectInterceptor {
|
||||
invoke?: (result: BaseObjectInterceptorArgs) => void;
|
||||
success?: (result: SuccessObjectInterceptorArgs) => void;
|
||||
fail?: (result: FailObjectInterceptorArgs) => void;
|
||||
complete?: (result: CompleteObjectInterceptorArgs) => void;
|
||||
}
|
||||
|
||||
interface UniCloud {
|
||||
/**
|
||||
* 添加拦截器
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#add-interceptor](https://uniapp.dcloud.io/uniCloud/client-sdk.html#add-interceptor)
|
||||
*/
|
||||
addInterceptor(apiName: string, interceptor: Interceptor): void;
|
||||
/**
|
||||
* 移除拦截器
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#remove-interceptor](https://uniapp.dcloud.io/uniCloud/client-sdk.html#remove-interceptor)
|
||||
*/
|
||||
removeInterceptor(apiName: string, interceptor?: Interceptor): void;
|
||||
/**
|
||||
* 拦截云对象请求
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/client-sdk.html#intercept-object](https://uniapp.dcloud.io/uniCloud/client-sdk.html#intercept-object)
|
||||
*/
|
||||
interceptObject(interceptor: ObjectInterceptor): void;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+110
@@ -0,0 +1,110 @@
|
||||
declare namespace UniCloudNamespace {
|
||||
class SSEChannel {
|
||||
constructor();
|
||||
/**
|
||||
* 开启消息通道
|
||||
*
|
||||
* 文档:[https://uniapp.dcloud.net.cn/uniCloud/sse-channel.html#channel-open](https://uniapp.dcloud.net.cn/uniCloud/sse-channel.html#channel-open)
|
||||
*/
|
||||
open: () => Promise<void>;
|
||||
/**
|
||||
* 关闭消息通道
|
||||
*
|
||||
* 文档:[https://uniapp.dcloud.net.cn/uniCloud/sse-channel.html#channel-close](https://uniapp.dcloud.net.cn/uniCloud/sse-channel.html#channel-close)
|
||||
*/
|
||||
close: () => void;
|
||||
/**
|
||||
* 添加通道开启事件监听器
|
||||
*/
|
||||
on(event: 'open', callback: () => any): void;
|
||||
/**
|
||||
* 添加消息接收事件监听器
|
||||
*/
|
||||
on(event: 'message', callback: (message?: any) => any): void;
|
||||
/**
|
||||
* 添加通道消息完毕事件监听器
|
||||
*/
|
||||
on(event: 'end', callback: (message?: any) => any): void;
|
||||
/**
|
||||
* 添加通道关闭事件监听器
|
||||
*/
|
||||
on(event: 'close', callback: () => any): void;
|
||||
/**
|
||||
* 添加通道错误事件监听器
|
||||
*/
|
||||
on(event: 'error', callback: (err?: any) => any): void;
|
||||
/**
|
||||
* 添加通道开启事件监听器
|
||||
*/
|
||||
addListener(event: 'open', callback: () => any): void;
|
||||
/**
|
||||
* 添加消息接收事件监听器
|
||||
*/
|
||||
addListener(event: 'message', callback: (message?: any) => any): void;
|
||||
/**
|
||||
* 添加通道消息完毕事件监听器
|
||||
*/
|
||||
addListener(event: 'end', callback: (message?: any) => any): void;
|
||||
/**
|
||||
* 添加通道关闭事件监听器
|
||||
*/
|
||||
addListener(event: 'close', callback: () => any): void;
|
||||
/**
|
||||
* 添加通道错误事件监听器
|
||||
*/
|
||||
addListener(event: 'error', callback: (err?: any) => any): void;
|
||||
/**
|
||||
* 移除通道开启事件监听器
|
||||
*/
|
||||
off(event: 'open', callback: () => any): void;
|
||||
/**
|
||||
* 移除消息接收事件监听器
|
||||
*/
|
||||
off(event: 'message', callback: (message?: any) => any): void;
|
||||
/**
|
||||
* 移除通道消息完毕事件监听器
|
||||
*/
|
||||
off(event: 'end', callback: (message?: any) => any): void;
|
||||
/**
|
||||
* 移除通道关闭事件监听器
|
||||
*/
|
||||
off(event: 'close', callback: () => any): void;
|
||||
/**
|
||||
* 移除通道错误事件监听器
|
||||
*/
|
||||
off(event: 'error', callback: (err?: any) => any): void;
|
||||
/**
|
||||
* 移除通道开启事件监听器
|
||||
*/
|
||||
removeListener(event: 'open', callback: () => any): void;
|
||||
/**
|
||||
* 移除消息接收事件监听器
|
||||
*/
|
||||
removeListener(event: 'message', callback: (message?: any) => any): void;
|
||||
/**
|
||||
* 移除通道消息完毕事件监听器
|
||||
*/
|
||||
removeListener(event: 'end', callback: (message?: any) => any): void;
|
||||
/**
|
||||
* 移除通道关闭事件监听器
|
||||
*/
|
||||
removeListener(event: 'close', callback: () => any): void;
|
||||
/**
|
||||
* 移除通道错误事件监听器
|
||||
*/
|
||||
removeListener(event: 'error', callback: (err?: any) => any): void;
|
||||
/**
|
||||
* 移除指定事件的所有监听器
|
||||
*/
|
||||
removeAllListener(event: 'open' | 'message' | 'end' | 'close' | 'error'): void;
|
||||
}
|
||||
|
||||
interface UniCloud {
|
||||
/**
|
||||
* 云函数请求中的中间状态通知通道类
|
||||
*
|
||||
* 文档:[https://uniapp.dcloud.net.cn/uniCloud/sse-channel.html#create-sse-channel](https://uniapp.dcloud.net.cn/uniCloud/sse-channel.html#create-sse-channel)
|
||||
*/
|
||||
SSEChannel: SSEChannel;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+324
@@ -0,0 +1,324 @@
|
||||
declare namespace UniCloudNamespace {
|
||||
interface GeneralCallbackResult {
|
||||
/**
|
||||
* 状态码,操作成功则不返回
|
||||
*/
|
||||
errCode: string;
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
errMsg: string;
|
||||
}
|
||||
|
||||
interface OnUploadProgressResult {
|
||||
/**
|
||||
* 已上传大小
|
||||
*/
|
||||
loaded: number;
|
||||
/**
|
||||
* 上传文件总大小
|
||||
*/
|
||||
total: number;
|
||||
}
|
||||
|
||||
interface UploadFileResult {
|
||||
/**
|
||||
* 文件唯一 ID,用来访问文件,建议存储起来
|
||||
*/
|
||||
fileID: string;
|
||||
}
|
||||
|
||||
interface UploadFileOptions {
|
||||
/**
|
||||
* 文件的绝对路径,包含文件名。例如 foo/bar.jpg、foo/bar/baz.jpg 等
|
||||
*/
|
||||
cloudPath: string;
|
||||
/**
|
||||
* 要上传的文件对象
|
||||
*/
|
||||
filePath: string;
|
||||
/**
|
||||
* 阿里云是否以cloudPath作为实际存储路径,默认为false(否)
|
||||
*/
|
||||
cloudPathAsRealPath?: boolean;
|
||||
/**
|
||||
* 上传进度回调
|
||||
*/
|
||||
onUploadProgress?: (result: OnUploadProgressResult) => void;
|
||||
/**
|
||||
* 成功返回的回调函数
|
||||
*/
|
||||
success?: (result: UploadFileResult) => void;
|
||||
/**
|
||||
* 失败返回的回调函数
|
||||
*/
|
||||
fail?: (result: GeneralCallbackResult) => void;
|
||||
/**
|
||||
* 结束的回调函数(调用成功、失败都会执行
|
||||
*/
|
||||
complete?: (result: UploadFileResult) => void;
|
||||
}
|
||||
|
||||
interface DeleteFileItem {
|
||||
/**
|
||||
* 云端fileID
|
||||
*/
|
||||
fileID: string;
|
||||
/**
|
||||
* 状态码,操作成功则不返回
|
||||
*/
|
||||
code: string;
|
||||
}
|
||||
|
||||
interface DeleteFileResult {
|
||||
/**
|
||||
* 要删除的文件 ID 组成的数组
|
||||
*/
|
||||
fileList: DeleteFileItem[];
|
||||
}
|
||||
|
||||
interface DeleteFileOptions {
|
||||
/**
|
||||
* 文件ID组成的数组
|
||||
*/
|
||||
fileList: any[];
|
||||
/**
|
||||
* 成功返回的回调函数
|
||||
*/
|
||||
success?: (result: DeleteFileResult) => void;
|
||||
/**
|
||||
* 失败返回的回调函数
|
||||
*/
|
||||
fail?: (result: GeneralCallbackResult) => void;
|
||||
/**
|
||||
* 结束的回调函数(调用成功、失败都会执行
|
||||
*/
|
||||
complete?: (result: DeleteFileResult) => void;
|
||||
}
|
||||
|
||||
interface GetTempFileURLItem {
|
||||
/**
|
||||
* 文件 ID
|
||||
*/
|
||||
fileID: string;
|
||||
/**
|
||||
* 状态码,操作成功则为 SUCCESS
|
||||
*/
|
||||
code: string;
|
||||
/**
|
||||
* 文件访问链接
|
||||
*/
|
||||
tempFileURL: string;
|
||||
}
|
||||
|
||||
interface GetTempFileURLResult {
|
||||
/**
|
||||
* 存储下载链接的数组
|
||||
*/
|
||||
fileList: any[];
|
||||
}
|
||||
|
||||
interface GetTempFileURLOptions {
|
||||
/**
|
||||
* 文件ID组成的数组
|
||||
*/
|
||||
fileList: any[];
|
||||
/**
|
||||
* 成功返回的回调函数
|
||||
*/
|
||||
success?: (result: GetTempFileURLResult) => void;
|
||||
/**
|
||||
* 失败返回的回调函数
|
||||
*/
|
||||
fail?: (result: GeneralCallbackResult) => void;
|
||||
/**
|
||||
* 结束的回调函数(调用成功、失败都会执行
|
||||
*/
|
||||
complete?: (result: GetTempFileURLResult) => void;
|
||||
}
|
||||
|
||||
interface ChooseAndUploadFileSuccessCallbackResult {
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
errMsg: string;
|
||||
/**
|
||||
* 临时文件路径列表
|
||||
*/
|
||||
tempFilePaths: any[];
|
||||
/**
|
||||
* 文件列表,每一项是一个 File 对象
|
||||
*/
|
||||
tempFiles: any[];
|
||||
}
|
||||
|
||||
interface ChooseAndUploadFileOnUploadProgressCallbackResult {
|
||||
/**
|
||||
* 触发当前上传进度回调的文件序号
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* 已上传大小
|
||||
*/
|
||||
loaded: number;
|
||||
/**
|
||||
* 总大小
|
||||
*/
|
||||
total: number;
|
||||
/**
|
||||
* 临时文件路径
|
||||
*/
|
||||
tempFilePath: string;
|
||||
/**
|
||||
* 文件对象
|
||||
*/
|
||||
tempFile: any;
|
||||
}
|
||||
|
||||
interface ChooseAndUploadFileOnChooseFileCallbackResult {
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
errMsg: string;
|
||||
/**
|
||||
* 临时文件路径列表
|
||||
*/
|
||||
tempFilePaths: any[];
|
||||
/**
|
||||
* 文件列表,每一项是一个 File 对象
|
||||
*/
|
||||
tempFiles: any[];
|
||||
}
|
||||
|
||||
interface ChooseAndUploadFileOptions {
|
||||
/**
|
||||
* 文件类型
|
||||
* - image: 图片
|
||||
* - video: 视频
|
||||
* - all: 任意文件
|
||||
*/
|
||||
type: 'image' | 'video' | 'all';
|
||||
/**
|
||||
* 文件数量
|
||||
*/
|
||||
count?: number;
|
||||
/**
|
||||
* 允许的文件后缀数组
|
||||
*/
|
||||
extension?: any[];
|
||||
/**
|
||||
* original 原图,compressed 压缩图,默认二者都有
|
||||
*/
|
||||
sizeType?: string | string[];
|
||||
/**
|
||||
* album 从相册选图,camera 使用相机,默认二者都有
|
||||
*/
|
||||
sourceType?: string | string[];
|
||||
/**
|
||||
* 摄像切换
|
||||
* - front: 前置摄像头
|
||||
* - back: 后置摄像头
|
||||
*/
|
||||
camera?: 'front' | 'back';
|
||||
/**
|
||||
* 是否压缩所选的视频源文件,默认值为true,需要压缩
|
||||
*/
|
||||
compressed?: boolean;
|
||||
/**
|
||||
* 拍摄视频最长拍摄时间,单位秒。最长支持 60 秒
|
||||
*/
|
||||
maxDuration?: number;
|
||||
/**
|
||||
* 选择文件后的回调
|
||||
*/
|
||||
onChooseFile?: (result: ChooseAndUploadFileOnChooseFileCallbackResult) => void;
|
||||
/**
|
||||
* 上传进度回调
|
||||
*/
|
||||
onUploadProgress?: (result: ChooseAndUploadFileOnUploadProgressCallbackResult) => void;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: (result: ChooseAndUploadFileSuccessCallbackResult) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: (result: any) => void;
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: (result: any) => void;
|
||||
}
|
||||
|
||||
interface GetFileInfoOptions {
|
||||
fileList: Array<string>;
|
||||
}
|
||||
|
||||
interface GetFileInfoResponseFileItem {
|
||||
/**
|
||||
* 文件ID
|
||||
*/
|
||||
fileId: string;
|
||||
/**
|
||||
* 文件上传时间(秒)
|
||||
*/
|
||||
gmtCreate: number;
|
||||
/**
|
||||
* 文件最近更改时间(秒)
|
||||
*/
|
||||
gmtModified: number;
|
||||
/**
|
||||
* 文件原始名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 文件大小(Byte)
|
||||
*/
|
||||
size: number;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* 文件CDN加速访问下载链接
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface GetFileInfoResponse {
|
||||
fileList: Array<GetFileInfoResponseFileItem>;
|
||||
}
|
||||
|
||||
interface UniCloud {
|
||||
/**
|
||||
* 上传文件到云端
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/storage?id=uploadfile](https://uniapp.dcloud.io/uniCloud/storage?id=uploadfile)
|
||||
*/
|
||||
uploadFile(options: UploadFileOptions): Promise<any>;
|
||||
/**
|
||||
* 选择并上传文件
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/storage?id=chooseanduploadfile](https://uniapp.dcloud.io/uniCloud/storage?id=chooseanduploadfile)
|
||||
*/
|
||||
chooseAndUploadFile(options: ChooseAndUploadFileOptions): Promise<any>;
|
||||
/**
|
||||
* 删除云端文件
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/storage?id=deletefile](https://uniapp.dcloud.io/uniCloud/storage?id=deletefile)
|
||||
*/
|
||||
deleteFile(options: DeleteFileOptions): Promise<any>;
|
||||
/**
|
||||
* 获取文件临时链接
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/storage?id=gettempfileurl](https://uniapp.dcloud.io/uniCloud/storage?id=gettempfileurl)
|
||||
*/
|
||||
getTempFileURL(options: GetTempFileURLOptions): Promise<any>;
|
||||
/**
|
||||
* 获取文件信息,阿里云专用
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.io/uniCloud/storage?id=get-file-info](https://uniapp.dcloud.io/uniCloud/storage?id=get-file-info)
|
||||
*/
|
||||
getFileInfo(options: GetFileInfoOptions): Promise<GetFileInfoResponse>;
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
declare namespace UniCloudNamespace {
|
||||
interface ConnectWebSocketOptions {
|
||||
/**
|
||||
* WebSocket云函数/云对象名称
|
||||
*/
|
||||
name: string | string.CloudFunctionString;
|
||||
/**
|
||||
* 建立连接时需要传递的参数, 仅在 connection 事件中接收到
|
||||
*/
|
||||
query?: Record<string, string>;
|
||||
}
|
||||
|
||||
interface UniCloud {
|
||||
/**
|
||||
* 快速连接 WebSocket 服务
|
||||
*
|
||||
* 文档: [uniCloud.connectWebSocket](https://doc.dcloud.net.cn/uniCloud/websocket.html#unicloud-connectwebsocket)
|
||||
*/
|
||||
connectWebSocket(options: ConnectWebSocketOptions): UniApp.SocketTask;
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/// <reference path="./base.d.ts" />
|
||||
/// <reference path="./extension/index.d.ts" />
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/// <reference path="./wx/index.d.ts" />
|
||||
/// <reference path="./promisify/index.d.ts" />
|
||||
Generated
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
declare namespace UniNamespace {
|
||||
type PromisifySuccessResult<
|
||||
P,
|
||||
T extends {
|
||||
success?: (...args: any[]) => void
|
||||
},
|
||||
R = void
|
||||
> = P extends {
|
||||
success: any
|
||||
}
|
||||
? R
|
||||
: P extends { fail: any }
|
||||
? R
|
||||
: P extends { complete: any }
|
||||
? R
|
||||
: Promise<Parameters<Exclude<T['success'], undefined>>[0]>;
|
||||
|
||||
type ErrorFirstArray<T> = [any, T];
|
||||
|
||||
type PromisifySuccessResultLegacy<
|
||||
P,
|
||||
T extends {
|
||||
success?: (...args: any[]) => void
|
||||
}
|
||||
> = P extends {
|
||||
success: any
|
||||
}
|
||||
? void
|
||||
: P extends { fail: any }
|
||||
? void
|
||||
: P extends { complete: any }
|
||||
? void
|
||||
: Promise<ErrorFirstArray<Parameters<Exclude<T['success'], undefined>>[0]>>;
|
||||
}
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/// <reference path="./common.d.ts" />
|
||||
/// <reference path="./uni.d.ts" />
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
interface Uni {
|
||||
startFacialRecognitionVerify<T extends UniNamespace.StartFacialRecognitionVerifyOption = UniNamespace.StartFacialRecognitionVerifyOption>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StartFacialRecognitionVerifyOption>;
|
||||
getBatteryInfo<T extends UniNamespace.GetBatteryInfoOption = UniNamespace.GetBatteryInfoOption>(option?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetBatteryInfoOption>;
|
||||
startWifi<T extends UniNamespace.StartWifiOption = UniNamespace.StartWifiOption>(option?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StartWifiOption>;
|
||||
stopWifi<T extends UniNamespace.StopWifiOption = UniNamespace.StopWifiOption>(option?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StopWifiOption>;
|
||||
connectWifi<T extends UniNamespace.ConnectWifiOption = UniNamespace.ConnectWifiOption>(option: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ConnectWifiOption>;
|
||||
getConnectedWifi<T extends UniNamespace.GetConnectedWifiOption = UniNamespace.GetConnectedWifiOption>(option?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetConnectedWifiOption>;
|
||||
getWifiList<T extends UniNamespace.GetWifiListOption = UniNamespace.GetWifiListOption>(option?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetWifiListOption>;
|
||||
configMTLS<T extends UniNamespace.ConfigMTLSOptions = UniNamespace.ConfigMTLSOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ConfigMTLSOptions>;
|
||||
sendSocketMessage<T extends UniNamespace.SendSocketMessageOptions = UniNamespace.SendSocketMessageOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SendSocketMessageOptions>;
|
||||
closeSocket<T extends UniNamespace.CloseSocketOptions = UniNamespace.CloseSocketOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CloseSocketOptions>;
|
||||
chooseImage<T extends UniNamespace.ChooseImageOptions = UniNamespace.ChooseImageOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ChooseImageOptions>;
|
||||
chooseFile<T extends UniNamespace.ChooseFileOptions = UniNamespace.ChooseFileOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ChooseFileOptions>;
|
||||
previewImage<T extends UniNamespace.PreviewImageOptions = UniNamespace.PreviewImageOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.PreviewImageOptions>;
|
||||
closePreviewImage<T extends UniNamespace.CallBackOptions = UniNamespace.CallBackOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CallBackOptions>;
|
||||
getImageInfo<T extends UniNamespace.GetImageInfoOptions = UniNamespace.GetImageInfoOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetImageInfoOptions>;
|
||||
saveImageToPhotosAlbum<T extends UniNamespace.SaveImageToPhotosAlbumOptions = UniNamespace.SaveImageToPhotosAlbumOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SaveImageToPhotosAlbumOptions>;
|
||||
compressImage<T extends UniNamespace.CompressImageOptions = UniNamespace.CompressImageOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CompressImageOptions>;
|
||||
chooseVideo<T extends UniNamespace.ChooseVideoOptions = UniNamespace.ChooseVideoOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ChooseVideoOptions>;
|
||||
compressVideo<T extends UniNamespace.CompressVideoOptions = UniNamespace.CompressVideoOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CompressVideoOptions>;
|
||||
getVideoInfo<T extends UniNamespace.GetVideoInfoOptions = UniNamespace.GetVideoInfoOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetVideoInfoOptions>;
|
||||
openVideoEditor<T extends UniNamespace.OpenVideoEditorOptions = UniNamespace.OpenVideoEditorOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.OpenVideoEditorOptions>;
|
||||
saveVideoToPhotosAlbum<T extends UniNamespace.SaveVideoToPhotosAlbumOptions = UniNamespace.SaveVideoToPhotosAlbumOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SaveVideoToPhotosAlbumOptions>;
|
||||
saveFile<T extends UniNamespace.SaveFileOptions = UniNamespace.SaveFileOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SaveFileOptions>;
|
||||
getFileInfo<T extends UniNamespace.GetFileInfoOptions = UniNamespace.GetFileInfoOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetFileInfoOptions>;
|
||||
getSavedFileList<T extends UniNamespace.GetSavedFileListOptions = UniNamespace.GetSavedFileListOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetSavedFileListOptions>;
|
||||
getSavedFileInfo<T extends UniNamespace.GetSavedFileInfoOptions = UniNamespace.GetSavedFileInfoOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetSavedFileInfoOptions>;
|
||||
removeSavedFile<T extends UniNamespace.RemoveSavedFileOptions = UniNamespace.RemoveSavedFileOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.RemoveSavedFileOptions>;
|
||||
openDocument<T extends UniNamespace.OpenDocumentOptions = UniNamespace.OpenDocumentOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.OpenDocumentOptions>;
|
||||
setStorage<T extends UniNamespace.SetStorageOptions = UniNamespace.SetStorageOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetStorageOptions>;
|
||||
getStorage<T = any, U extends UniNamespace.GetStorageOptions<T> = UniNamespace.GetStorageOptions<T>>(options: U): UniNamespace.PromisifySuccessResult<U, UniNamespace.GetStorageOptions<T>>;
|
||||
getStorageInfo<T extends UniNamespace.GetStorageInfoOptions = UniNamespace.GetStorageInfoOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetStorageInfoOptions>;
|
||||
removeStorage<T extends UniNamespace.RemoveStorageOptions = UniNamespace.RemoveStorageOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.RemoveStorageOptions>;
|
||||
getLocation<T extends UniNamespace.GetLocationOptions = UniNamespace.GetLocationOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetLocationOptions>;
|
||||
chooseLocation<T extends UniNamespace.ChooseLocationOptions = UniNamespace.ChooseLocationOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ChooseLocationOptions>;
|
||||
openLocation<T extends UniNamespace.OpenLocationOptions = UniNamespace.OpenLocationOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.OpenLocationOptions>;
|
||||
getSystemInfo<T extends UniNamespace.GetSystemInfoOptions = UniNamespace.GetSystemInfoOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetSystemInfoOptions>;
|
||||
getNetworkType<T extends UniNamespace.GetNetworkTypeOptions = UniNamespace.GetNetworkTypeOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetNetworkTypeOptions>;
|
||||
startAccelerometer<T extends UniNamespace.StartAccelerometerOptions = UniNamespace.StartAccelerometerOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StartAccelerometerOptions>;
|
||||
stopAccelerometer<T extends UniNamespace.StopAccelerometerOptions = UniNamespace.StopAccelerometerOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StopAccelerometerOptions>;
|
||||
startCompass<T extends UniNamespace.StartCompassOptions = UniNamespace.StartCompassOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StartCompassOptions>;
|
||||
stopCompass<T extends UniNamespace.StopCompassOptions = UniNamespace.StopCompassOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StopCompassOptions>;
|
||||
makePhoneCall<T extends UniNamespace.MakePhoneCallOptions = UniNamespace.MakePhoneCallOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.MakePhoneCallOptions>;
|
||||
scanCode<T extends UniNamespace.ScanCodeOptions = UniNamespace.ScanCodeOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ScanCodeOptions>;
|
||||
setClipboardData<T extends UniNamespace.SetClipboardDataOptions = UniNamespace.SetClipboardDataOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetClipboardDataOptions>;
|
||||
getClipboardData<T extends UniNamespace.GetClipboardDataOptions = UniNamespace.GetClipboardDataOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetClipboardDataOptions>;
|
||||
openAppAuthorizeSetting<T extends UniNamespace.CallBackOptions = UniNamespace.CallBackOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CallBackOptions>;
|
||||
getSelectedTextRange<T extends UniNamespace.GetSelectedTextRangeOptions = UniNamespace.GetSelectedTextRangeOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetSelectedTextRangeOptions>;
|
||||
setScreenBrightness<T extends UniNamespace.SetScreenBrightnessOptions = UniNamespace.SetScreenBrightnessOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetScreenBrightnessOptions>;
|
||||
getScreenBrightness<T extends UniNamespace.GetScreenBrightnessOptions = UniNamespace.GetScreenBrightnessOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetScreenBrightnessOptions>;
|
||||
setKeepScreenOn<T extends UniNamespace.SetKeepScreenOnOptions = UniNamespace.SetKeepScreenOnOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetKeepScreenOnOptions>;
|
||||
vibrate<T extends UniNamespace.VibrateOptions = UniNamespace.VibrateOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.VibrateOptions>;
|
||||
vibrateLong<T extends UniNamespace.VibrateLongOptions = UniNamespace.VibrateLongOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.VibrateLongOptions>;
|
||||
vibrateShort<T extends UniNamespace.VibrateShortOptions = UniNamespace.VibrateShortOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.VibrateShortOptions>;
|
||||
addPhoneContact<T extends UniNamespace.AddPhoneContactOptions = UniNamespace.AddPhoneContactOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.AddPhoneContactOptions>;
|
||||
getBeacons<T extends UniNamespace.GetBeaconsOptions = UniNamespace.GetBeaconsOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetBeaconsOptions>;
|
||||
startBeaconDiscovery<T extends UniNamespace.StartBeaconDiscoveryOptions = UniNamespace.StartBeaconDiscoveryOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StartBeaconDiscoveryOptions>;
|
||||
stopBeaconDiscovery<T extends UniNamespace.StopBeaconDiscoveryOptions = UniNamespace.StopBeaconDiscoveryOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StopBeaconDiscoveryOptions>;
|
||||
closeBluetoothAdapter<T extends UniNamespace.CloseBluetoothAdapterOptions = UniNamespace.CloseBluetoothAdapterOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CloseBluetoothAdapterOptions>;
|
||||
getBluetoothAdapterState<T extends UniNamespace.GetBluetoothAdapterStateOptions = UniNamespace.GetBluetoothAdapterStateOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetBluetoothAdapterStateOptions>;
|
||||
getBluetoothDevices<T extends UniNamespace.GetBluetoothDevicesOptions = UniNamespace.GetBluetoothDevicesOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetBluetoothDevicesOptions>;
|
||||
getConnectedBluetoothDevices<T extends UniNamespace.GetConnectedBluetoothDevicesOptions = UniNamespace.GetConnectedBluetoothDevicesOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetConnectedBluetoothDevicesOptions>;
|
||||
openBluetoothAdapter<T extends UniNamespace.OpenBluetoothAdapterOptions = UniNamespace.OpenBluetoothAdapterOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.OpenBluetoothAdapterOptions>;
|
||||
startBluetoothDevicesDiscovery<T extends UniNamespace.StartBluetoothDevicesDiscoveryOptions = UniNamespace.StartBluetoothDevicesDiscoveryOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StartBluetoothDevicesDiscoveryOptions>;
|
||||
stopBluetoothDevicesDiscovery<T extends UniNamespace.StopBluetoothDevicesDiscoveryOptions = UniNamespace.StopBluetoothDevicesDiscoveryOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StopBluetoothDevicesDiscoveryOptions>;
|
||||
closeBLEConnection<T extends UniNamespace.CloseBLEConnectionOptions = UniNamespace.CloseBLEConnectionOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CloseBLEConnectionOptions>;
|
||||
createBLEConnection<T extends UniNamespace.CreateBLEConnectionOptions = UniNamespace.CreateBLEConnectionOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CreateBLEConnectionOptions>;
|
||||
getBLEDeviceCharacteristics<T extends UniNamespace.GetBLEDeviceCharacteristicsOptions = UniNamespace.GetBLEDeviceCharacteristicsOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetBLEDeviceCharacteristicsOptions>;
|
||||
getBLEDeviceServices<T extends UniNamespace.GetBLEDeviceServicesOptions = UniNamespace.GetBLEDeviceServicesOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetBLEDeviceServicesOptions>;
|
||||
notifyBLECharacteristicValueChange<T extends UniNamespace.NotifyBLECharacteristicValueChangeOptions = UniNamespace.NotifyBLECharacteristicValueChangeOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.NotifyBLECharacteristicValueChangeOptions>;
|
||||
readBLECharacteristicValue<T extends UniNamespace.ReadBLECharacteristicValueOptions = UniNamespace.ReadBLECharacteristicValueOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ReadBLECharacteristicValueOptions>;
|
||||
writeBLECharacteristicValue<T extends UniNamespace.WriteBLECharacteristicValueOptions = UniNamespace.WriteBLECharacteristicValueOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.WriteBLECharacteristicValueOptions>;
|
||||
setBLEMTU<T extends UniNamespace.SetBLEMTUOptions = UniNamespace.SetBLEMTUOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetBLEMTUOptions>;
|
||||
getBLEDeviceRSSI<T extends UniNamespace.GetBLEDeviceRSSIOptions = UniNamespace.GetBLEDeviceRSSIOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetBLEDeviceRSSIOptions>;
|
||||
showToast<T extends UniNamespace.ShowToastOptions = UniNamespace.ShowToastOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ShowToastOptions>;
|
||||
showLoading<T extends UniNamespace.ShowLoadingOptions = UniNamespace.ShowLoadingOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ShowLoadingOptions>;
|
||||
showModal<T extends UniNamespace.ShowModalOptions = UniNamespace.ShowModalOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ShowModalOptions>;
|
||||
showActionSheet<T extends UniNamespace.ShowActionSheetOptions = UniNamespace.ShowActionSheetOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ShowActionSheetOptions>;
|
||||
setNavigationBarTitle<T extends UniNamespace.SetNavigationBarTitleOptions = UniNamespace.SetNavigationBarTitleOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetNavigationBarTitleOptions>;
|
||||
setNavigationBarColor<T extends UniNamespace.SetNavigationbarColorOptions = UniNamespace.SetNavigationbarColorOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetNavigationbarColorOptions>;
|
||||
setTabBarItem<T extends UniNamespace.SetTabBarItemOptions = UniNamespace.SetTabBarItemOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetTabBarItemOptions>;
|
||||
setTabBarStyle<T extends UniNamespace.SetTabBarStyleOptions = UniNamespace.SetTabBarStyleOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetTabBarStyleOptions>;
|
||||
hideTabBar<T extends UniNamespace.HideTabBarOptions = UniNamespace.HideTabBarOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.HideTabBarOptions>;
|
||||
showTabBar<T extends UniNamespace.ShowTabBarOptions = UniNamespace.ShowTabBarOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ShowTabBarOptions>;
|
||||
setTabBarBadge<T extends UniNamespace.SetTabBarBadgeOptions = UniNamespace.SetTabBarBadgeOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetTabBarBadgeOptions>;
|
||||
removeTabBarBadge<T extends UniNamespace.RemoveTabBarBadgeOptions = UniNamespace.RemoveTabBarBadgeOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.RemoveTabBarBadgeOptions>;
|
||||
showTabBarRedDot<T extends UniNamespace.ShowTabBarRedDotOptions = UniNamespace.ShowTabBarRedDotOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ShowTabBarRedDotOptions>;
|
||||
hideTabBarRedDot<T extends UniNamespace.HideTabBarRedDotOptions = UniNamespace.HideTabBarRedDotOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.HideTabBarRedDotOptions>;
|
||||
navigateTo<T extends UniNamespace.NavigateToOptions = UniNamespace.NavigateToOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.NavigateToOptions>;
|
||||
redirectTo<T extends UniNamespace.RedirectToOptions = UniNamespace.RedirectToOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.RedirectToOptions>;
|
||||
reLaunch<T extends UniNamespace.ReLaunchOptions = UniNamespace.ReLaunchOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ReLaunchOptions>;
|
||||
switchTab<T extends UniNamespace.SwitchTabOptions = UniNamespace.SwitchTabOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SwitchTabOptions>;
|
||||
navigateBack<T extends UniNamespace.NavigateBackOptions = UniNamespace.NavigateBackOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.NavigateBackOptions>;
|
||||
preloadPage<T extends UniNamespace.PreloadPageOptions = UniNamespace.PreloadPageOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.PreloadPageOptions>;
|
||||
pageScrollTo<T extends UniNamespace.PageScrollToOptions = UniNamespace.PageScrollToOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.PageScrollToOptions>;
|
||||
startPullDownRefresh<T extends UniNamespace.StartPullDownRefreshOptions = UniNamespace.StartPullDownRefreshOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StartPullDownRefreshOptions>;
|
||||
canvasToTempFilePath<T extends UniNamespace.CanvasToTempFilePathOptions = UniNamespace.CanvasToTempFilePathOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CanvasToTempFilePathOptions>;
|
||||
canvasGetImageData<T extends UniNamespace.CanvasGetImageDataOptions = UniNamespace.CanvasGetImageDataOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CanvasGetImageDataOptions>;
|
||||
canvasPutImageData<T extends UniNamespace.CanvasPutImageDataOptions = UniNamespace.CanvasPutImageDataOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CanvasPutImageDataOptions>;
|
||||
showTopWindow<T extends UniNamespace.CommonOptions = UniNamespace.CommonOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CommonOptions>;
|
||||
hideTopWindow<T extends UniNamespace.CommonOptions = UniNamespace.CommonOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CommonOptions>;
|
||||
showLeftWindow<T extends UniNamespace.CommonOptions = UniNamespace.CommonOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CommonOptions>;
|
||||
hideLeftWindow<T extends UniNamespace.CommonOptions = UniNamespace.CommonOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CommonOptions>;
|
||||
showRightWindow<T extends UniNamespace.CommonOptions = UniNamespace.CommonOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CommonOptions>;
|
||||
hideRightWindow<T extends UniNamespace.CommonOptions = UniNamespace.CommonOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CommonOptions>;
|
||||
getProvider<T extends UniNamespace.GetProviderOptions = UniNamespace.GetProviderOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetProviderOptions>;
|
||||
login<T extends UniNamespace.LoginOptions = UniNamespace.LoginOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.LoginOptions>;
|
||||
checkSession<T extends UniNamespace.CheckSessionOptions = UniNamespace.CheckSessionOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CheckSessionOptions>;
|
||||
getUserInfo<T extends UniNamespace.GetUserInfoOptions = UniNamespace.GetUserInfoOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetUserInfoOptions>;
|
||||
getUserProfile<T extends UniNamespace.GetUserProfileOptions = UniNamespace.GetUserProfileOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetUserProfileOptions>;
|
||||
preLogin<T extends UniNamespace.PreLoginOptions = UniNamespace.PreLoginOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.PreLoginOptions>;
|
||||
getCheckBoxState<T extends UniNamespace.GetCheckBoxStateOptions = UniNamespace.GetCheckBoxStateOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetCheckBoxStateOptions>;
|
||||
share<T extends UniNamespace.ShareOptions = UniNamespace.ShareOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ShareOptions>;
|
||||
shareWithSystem<T extends UniNamespace.ShareWithSystemOptions = UniNamespace.ShareWithSystemOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ShareWithSystemOptions>;
|
||||
getPushClientId<T extends UniNamespace.GetPushClientIdOptions = UniNamespace.GetPushClientIdOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetPushClientIdOptions>;
|
||||
requestPayment<T extends UniNamespace.RequestPaymentOptions = UniNamespace.RequestPaymentOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.RequestPaymentOptions>;
|
||||
authorize<T extends UniNamespace.AuthorizeOptions = UniNamespace.AuthorizeOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.AuthorizeOptions>;
|
||||
openSetting<T extends UniNamespace.OpenSettingOptions = UniNamespace.OpenSettingOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.OpenSettingOptions>;
|
||||
getSetting<T extends UniNamespace.GetSettingOptions = UniNamespace.GetSettingOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetSettingOptions>;
|
||||
chooseAddress<T extends UniNamespace.ChooseAddressOptions = UniNamespace.ChooseAddressOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ChooseAddressOptions>;
|
||||
chooseInvoiceTitle<T extends UniNamespace.ChooseInvoiceTitleOptions = UniNamespace.ChooseInvoiceTitleOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ChooseInvoiceTitleOptions>;
|
||||
navigateToMiniProgram<T extends UniNamespace.NavigateToMiniProgramOptions = UniNamespace.NavigateToMiniProgramOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.NavigateToMiniProgramOptions>;
|
||||
navigateBackMiniProgram<T extends UniNamespace.NavigateBackMiniProgramOptions = UniNamespace.NavigateBackMiniProgramOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.NavigateBackMiniProgramOptions>;
|
||||
setEnableDebug<T extends UniNamespace.SetEnableDebugOptions = UniNamespace.SetEnableDebugOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetEnableDebugOptions>;
|
||||
getExtConfig<T extends UniNamespace.GetExtConfigOptions = UniNamespace.GetExtConfigOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.GetExtConfigOptions>;
|
||||
showShareMenu<T extends UniNamespace.ShowShareMenuOptions = UniNamespace.ShowShareMenuOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ShowShareMenuOptions>;
|
||||
hideShareMenu<T extends UniNamespace.HideShareMenuOptions = UniNamespace.HideShareMenuOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.HideShareMenuOptions>;
|
||||
setBackgroundColor<T extends UniNamespace.SetBackgroundColorOptions = UniNamespace.SetBackgroundColorOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetBackgroundColorOptions>;
|
||||
setBackgroundTextStyle<T extends UniNamespace.SetBackgroundTextStyleOptions = UniNamespace.SetBackgroundTextStyleOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.SetBackgroundTextStyleOptions>;
|
||||
startGyroscope<T extends UniNamespace.StartGyroscopeOptions = UniNamespace.StartGyroscopeOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StartGyroscopeOptions>;
|
||||
stopGyroscope<T extends UniNamespace.StopGyroscopeOptions = UniNamespace.StopGyroscopeOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StopGyroscopeOptions>;
|
||||
loadFontFace<T extends UniNamespace.LoadFontFaceOptions = UniNamespace.LoadFontFaceOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.LoadFontFaceOptions>;
|
||||
startSoterAuthentication<T extends UniNamespace.StartSoterAuthenticationOptions = UniNamespace.StartSoterAuthenticationOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.StartSoterAuthenticationOptions>;
|
||||
checkIsSupportSoterAuthentication<T extends UniNamespace.CheckIsSupportSoterAuthenticationOptions = UniNamespace.CheckIsSupportSoterAuthenticationOptions>(options?: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CheckIsSupportSoterAuthenticationOptions>;
|
||||
checkIsSoterEnrolledInDevice<T extends UniNamespace.CheckIsSoterEnrolledInDeviceOptions = UniNamespace.CheckIsSoterEnrolledInDeviceOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.CheckIsSoterEnrolledInDeviceOptions>;
|
||||
connectSocket<T extends UniNamespace.ConnectSocketOption = UniNamespace.ConnectSocketOption>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.ConnectSocketOption, UniNamespace.SocketTask>;
|
||||
request<T extends UniNamespace.RequestOptions = UniNamespace.RequestOptions>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.RequestOptions, UniNamespace.RequestTask>;
|
||||
uploadFile<T extends UniNamespace.UploadFileOption = UniNamespace.UploadFileOption>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.UploadFileOption, UniNamespace.UploadTask>;
|
||||
downloadFile<T extends UniNamespace.DownloadFileOption = UniNamespace.DownloadFileOption>(options: T): UniNamespace.PromisifySuccessResult<T, UniNamespace.DownloadFileOption, UniNamespace.DownloadTask>;
|
||||
}
|
||||
+21847
File diff suppressed because it is too large
Load Diff
+68
@@ -0,0 +1,68 @@
|
||||
declare namespace UniNamespace {
|
||||
interface GeneralCallbackResult {
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
errMsg: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序错误事件的监听函数
|
||||
*/
|
||||
type OnAppErrorCallback = (
|
||||
/** 错误信息,包含堆栈 */
|
||||
error: string
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* onError 传入的监听函数。不传此参数则移除所有监听函数。
|
||||
*/
|
||||
type OffAppErrorCallback = (res: GeneralCallbackResult) => void;
|
||||
|
||||
interface SourceError {
|
||||
subject?: string;
|
||||
code?: number;
|
||||
message?: string;
|
||||
cause?: SourceError | AggregateError;
|
||||
}
|
||||
|
||||
// 聚合源错误信息
|
||||
interface AggregateError extends SourceError {
|
||||
errors: Array<SourceError | AggregateError>;
|
||||
}
|
||||
|
||||
interface UniError {
|
||||
errSubject: string;
|
||||
errCode: number;
|
||||
errMsg: string;
|
||||
data?: object;
|
||||
cause?: SourceError | AggregateError;
|
||||
}
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
/**
|
||||
*
|
||||
* 需要基础库: `2.1.2`
|
||||
*
|
||||
* 在插件中使用:不支持
|
||||
*
|
||||
* 监听小程序错误事件。如脚本错误或 API 调用报错等。该事件与 [`App.onError`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onerrorstring-error) 的回调时机与参数一致。
|
||||
*
|
||||
* 文档: [https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html)
|
||||
*/
|
||||
onError(listener: UniNamespace.OnAppErrorCallback): void;
|
||||
|
||||
/**
|
||||
*
|
||||
* 需要基础库: `2.1.2`
|
||||
*
|
||||
* 在插件中使用:不支持
|
||||
*
|
||||
* 移除小程序错误事件的监听函数
|
||||
*
|
||||
*
|
||||
* 文档: [https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offError.html](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offError.html)
|
||||
*/
|
||||
offError(listener?: UniNamespace.OffAppErrorCallback): void;
|
||||
}
|
||||
+402
@@ -0,0 +1,402 @@
|
||||
import { AsyncOptions } from './Utils';
|
||||
|
||||
declare global {
|
||||
namespace UniNamespace {
|
||||
interface MapContext {
|
||||
/**
|
||||
* 获取当前地图中心的经纬度,返回的是 gcj02 坐标系,可以用于 uni.openLocation
|
||||
*/
|
||||
getCenterLocation(options: MapContextGetCenterLocationOptions): void;
|
||||
/**
|
||||
* 将地图中心移动到当前定位点,需要配合map组件的show-location使用
|
||||
*/
|
||||
moveToLocation(options: MapContextMoveToLocationOptions): void;
|
||||
/**
|
||||
* 平移marker,带动画
|
||||
*/
|
||||
translateMarker(options: MapContextTranslateMarkerOptions): void;
|
||||
/**
|
||||
* 缩放视野展示所有经纬度
|
||||
*/
|
||||
includePoints(options: MapContextIncludePointsOptions): void;
|
||||
/**
|
||||
* 获取当前地图的视野范围
|
||||
*/
|
||||
getRegion(options: MapContextGetRegionOptions): void;
|
||||
/**
|
||||
* 获取当前地图的缩放级别
|
||||
*/
|
||||
getScale(options: MapContextGetScaleOptions): void;
|
||||
/**
|
||||
* 添加个性化图层
|
||||
*/
|
||||
addCustomLayer?: (options: MapContextAddCustomLayerOptions) => void;
|
||||
/**
|
||||
* 创建自定义图片图层,图片会随着地图缩放而缩放
|
||||
*/
|
||||
addGroundOverlay(options: MapContextAddGroundOverlayOptions): void;
|
||||
/**
|
||||
* 添加 marker
|
||||
*/
|
||||
addMarkers(options: MapContextAddMarkersOptions): void;
|
||||
/**
|
||||
* 获取屏幕上的点对应的经纬度,坐标原点为地图左上角
|
||||
*/
|
||||
fromScreenLocation?: (options: MapContextFromScreenLocationOptions) => void;
|
||||
/**
|
||||
* 初始化点聚合的配置,未调用时采用默认配置
|
||||
*/
|
||||
initMarkerCluster(options: MapContextInitMarkerClusterOptions): void;
|
||||
/**
|
||||
* 沿指定路径移动 marker,用于轨迹回放等场景。动画完成时触发回调事件,若动画进行中,对同一 marker 再次调用 moveAlong 方法,前一次的动画将被打断。
|
||||
*/
|
||||
moveAlong(options: MapContextMoveAlongOptions): void;
|
||||
/**
|
||||
* 拉起地图APP选择导航。
|
||||
*/
|
||||
openMapApp(options: MapContextOpenMapAppOptions): void;
|
||||
/**
|
||||
* 移除个性化图层
|
||||
*/
|
||||
removeCustomLayer(options: MapContextRemoveCustomLayerOptions): void;
|
||||
/**
|
||||
* 移除自定义图片图层
|
||||
*/
|
||||
removeGroundOverlay(options: MapContextRemoveGroundOverlayOptions): void;
|
||||
/**
|
||||
* 移除 marker
|
||||
*/
|
||||
removeMarkers(options: MapContextRemoveMarkersOptions): void;
|
||||
/**
|
||||
* 设置地图中心点偏移,向后向下为增长,屏幕比例范围(0.25~0.75),默认偏移为[0.5, 0.5]
|
||||
*/
|
||||
setCenterOffset?: (options: MapContextSetCenterOffsetOptions) => void;
|
||||
/**
|
||||
* 获取经纬度对应的屏幕坐标,坐标原点为地图左上角。
|
||||
*/
|
||||
toScreenLocation?: (options: MapContextToScreenLocationOptions) => void;
|
||||
/**
|
||||
* 更新自定义图片图层。
|
||||
*/
|
||||
updateGroundOverlay(options: MapContextUpdateGroundOverlayOptions): void;
|
||||
/**
|
||||
* 监听地图事件。
|
||||
*/
|
||||
on(event: 'markerClusterCreate' | 'markerClusterClick', callback: (...args: any[]) => any): void;
|
||||
/**
|
||||
* 获取原生地图对象 plus.maps.Map
|
||||
*/
|
||||
$getAppMap(): any;
|
||||
}
|
||||
|
||||
interface MapContextGetCenterLocationOptions extends AsyncOptions {
|
||||
/**
|
||||
* 接口调用成功的回调函数 ,res = { longitude: "经度", latitude: "纬度"}
|
||||
*/
|
||||
success?: (result: LocationObject) => void;
|
||||
}
|
||||
|
||||
interface MapContextMoveToLocationOptions extends AsyncOptions {
|
||||
/**
|
||||
* 纬度,浮点数,范围为-90~90,负数表示南纬
|
||||
*/
|
||||
latitude?: number;
|
||||
/**
|
||||
* 经度,范围为-180~180,负数表示西经
|
||||
*/
|
||||
longitude?: number;
|
||||
}
|
||||
|
||||
interface LocationObject {
|
||||
/**
|
||||
* 纬度,浮点数,范围为-90~90,负数表示南纬
|
||||
*/
|
||||
latitude: number;
|
||||
/**
|
||||
* 经度,范围为-180~180,负数表示西经
|
||||
*/
|
||||
longitude: number;
|
||||
}
|
||||
|
||||
interface MapContextTranslateMarkerOptions extends AsyncOptions {
|
||||
/**
|
||||
* 指定marker
|
||||
*/
|
||||
markerId: number;
|
||||
/**
|
||||
* 指定marker移动到的目标点
|
||||
*/
|
||||
destination: LocationObject;
|
||||
/**
|
||||
* 移动过程中是否自动旋转marker
|
||||
*/
|
||||
autoRotate: boolean;
|
||||
/**
|
||||
* marker的旋转角度
|
||||
*/
|
||||
rotate: number;
|
||||
/**
|
||||
* 平移和旋转同时进行,默认值false(仅微信小程序2.13.0支持)
|
||||
*/
|
||||
moveWithRotate?: boolean;
|
||||
/**
|
||||
* 动画持续时长,默认值1000ms,平移与旋转分别计算
|
||||
*/
|
||||
duration?: number;
|
||||
/**
|
||||
* 动画结束回调函数
|
||||
*/
|
||||
animationEnd?: (result: any) => void;
|
||||
}
|
||||
|
||||
interface MapContextIncludePointsOptions extends AsyncOptions {
|
||||
/**
|
||||
* 要显示在可视区域内的坐标点列表,[{latitude, longitude}]
|
||||
*/
|
||||
points: LocationObject[];
|
||||
/**
|
||||
* 坐标点形成的矩形边缘到地图边缘的距离,单位像素。格式为[上,右,下,左],安卓上只能识别数组第一项,上下左右的padding一致。开发者工具暂不支持padding参数。
|
||||
*/
|
||||
padding?: number[];
|
||||
}
|
||||
|
||||
interface MapContextGetRegionOptions extends AsyncOptions {
|
||||
/**
|
||||
* 接口调用成功的回调函数,res = {southwest, northeast},西南角与东北角的经纬度
|
||||
*/
|
||||
success?: (result: MapContextGetRegionResult) => void;
|
||||
}
|
||||
|
||||
interface MapContextGetRegionResult {
|
||||
/**
|
||||
* 西南角的经纬度
|
||||
*/
|
||||
southwest: LocationObject;
|
||||
/**
|
||||
* 东北角的经纬度
|
||||
*/
|
||||
northeast: LocationObject;
|
||||
}
|
||||
|
||||
interface MapContextGetScaleOptions extends AsyncOptions {
|
||||
/**
|
||||
* 接口调用成功的回调函数,res = {scale}
|
||||
*/
|
||||
success?: (result: MapContextGetScaleResult) => void;
|
||||
}
|
||||
|
||||
interface MapContextGetScaleResult {
|
||||
/**
|
||||
* 地图缩放级别
|
||||
*/
|
||||
scale: number;
|
||||
}
|
||||
|
||||
interface MapContextAddCustomLayerOptions extends AsyncOptions {
|
||||
/**
|
||||
* 个性化图层id
|
||||
*/
|
||||
layerId: string;
|
||||
}
|
||||
|
||||
interface MapContextAddGroundOverlayOptions extends AsyncOptions {
|
||||
/**
|
||||
* 图片图层 id
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 图片路径,支持网络图片、临时路径、代码包路径
|
||||
*/
|
||||
src: string;
|
||||
/**
|
||||
* 图片覆盖的经纬度范围
|
||||
*/
|
||||
bounds: Bounds;
|
||||
/**
|
||||
* 是否可见
|
||||
*/
|
||||
visible?: boolean;
|
||||
/**
|
||||
* 图层绘制顺序
|
||||
*/
|
||||
zIndex?: number;
|
||||
/**
|
||||
* 图层透明度
|
||||
*/
|
||||
opacity?: number;
|
||||
}
|
||||
|
||||
interface Bounds {
|
||||
/**
|
||||
* 西南角的经纬度
|
||||
*/
|
||||
southwest: LocationObject;
|
||||
/**
|
||||
* 东北角的经纬度
|
||||
*/
|
||||
northeast: LocationObject;
|
||||
}
|
||||
|
||||
interface MapContextAddMarkersOptions extends AsyncOptions {
|
||||
/**
|
||||
* 同传入 map 组件的 marker 属性
|
||||
*/
|
||||
markers: any[];
|
||||
/**
|
||||
* 是否先清空地图上所有 marker
|
||||
*/
|
||||
clear: boolean;
|
||||
}
|
||||
|
||||
interface MapContextFromScreenLocationOptions extends AsyncOptions {
|
||||
/**
|
||||
* x 坐标值
|
||||
*/
|
||||
x: number;
|
||||
/**
|
||||
* y 坐标值
|
||||
*/
|
||||
y: number;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: (result: LocationObject) => void;
|
||||
}
|
||||
|
||||
interface MapContextInitMarkerClusterOptions extends AsyncOptions {
|
||||
/**
|
||||
* 启用默认的聚合样式
|
||||
*/
|
||||
enableDefaultStyle: boolean;
|
||||
/**
|
||||
* 点击已经聚合的标记点时是否实现聚合分离
|
||||
*/
|
||||
zoomOnClick: boolean;
|
||||
/**
|
||||
* 聚合算法的可聚合距离,即距离小于该值的点会聚合至一起,以像素为单位
|
||||
*/
|
||||
gridSize: number;
|
||||
}
|
||||
|
||||
interface MapContextMoveAlongOptions extends AsyncOptions {
|
||||
/**
|
||||
* 指定 marker
|
||||
*/
|
||||
markerId: number;
|
||||
/**
|
||||
* 移动路径的坐标串,坐标点格式 {longitude, latitude}
|
||||
*/
|
||||
path: LocationObject[];
|
||||
/**
|
||||
* 根据路径方向自动改变 marker 的旋转角度
|
||||
*/
|
||||
autoRotate?: boolean;
|
||||
/**
|
||||
* 平滑移动的时间
|
||||
*/
|
||||
duration: number;
|
||||
}
|
||||
|
||||
interface MapContextOpenMapAppOptions extends AsyncOptions {
|
||||
/**
|
||||
* 目的地名称
|
||||
*/
|
||||
destination: string;
|
||||
/**
|
||||
* 目的地纬度
|
||||
*/
|
||||
latitude: number;
|
||||
/**
|
||||
* 目的地经度
|
||||
*/
|
||||
longitude: number;
|
||||
}
|
||||
|
||||
interface MapContextRemoveCustomLayerOptions extends AsyncOptions {
|
||||
/**
|
||||
* 个性化图层id
|
||||
*/
|
||||
layerId: string;
|
||||
}
|
||||
|
||||
interface MapContextRemoveGroundOverlayOptions extends AsyncOptions {
|
||||
/**
|
||||
* 图片图层 id
|
||||
*/
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface MapContextRemoveMarkersOptions extends AsyncOptions {
|
||||
/**
|
||||
* 要被删除的marker的id属性组成的数组
|
||||
*/
|
||||
markerIds: any[];
|
||||
}
|
||||
|
||||
interface MapContextSetCenterOffsetOptions {
|
||||
/**
|
||||
* 偏移量,两位数组
|
||||
*/
|
||||
offset: number[];
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: (result: any) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: (result: any) => void;
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: (result: any) => void;
|
||||
}
|
||||
|
||||
interface MapContextToScreenLocationOptions extends AsyncOptions {
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
latitude: number;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
longitude: number;
|
||||
}
|
||||
|
||||
interface MapContextUpdateGroundOverlayOptions extends AsyncOptions {
|
||||
/**
|
||||
* 图片图层 id
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 图片路径,支持网络图片、临时路径、代码包路径
|
||||
*/
|
||||
src: string;
|
||||
/**
|
||||
* 图片路径,支持网络图片、临时路径、代码包路径
|
||||
*/
|
||||
bounds: Bounds;
|
||||
/**
|
||||
* 是否可见
|
||||
*/
|
||||
visible?: boolean;
|
||||
/**
|
||||
* 图层绘制顺序
|
||||
*/
|
||||
zIndex?: number;
|
||||
/**
|
||||
* 图层透明度
|
||||
*/
|
||||
opacity?: number;
|
||||
}
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
/**
|
||||
* 创建并返回 map 上下文 mapContext 对象
|
||||
*
|
||||
* 文档: [http://uniapp.dcloud.io/api/location/map?id=createmapcontext](http://uniapp.dcloud.io/api/location/map?id=createmapcontext)
|
||||
*/
|
||||
createMapContext(mapId: string, currentComponent?: any): UniNamespace.MapContext;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
declare namespace UniNamespace {
|
||||
interface OnThemeChangeCallbackResult {
|
||||
/**
|
||||
* 主题名称
|
||||
*/
|
||||
theme: 'dark' | 'light';
|
||||
}
|
||||
type OnThemeChangeCallback = (res: OnThemeChangeCallbackResult) => void;
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
/**
|
||||
* 监听系统主题状态变化。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/theme.html#onthemechange](https://uniapp.dcloud.net.cn/api/system/theme.html#onthemechange)
|
||||
*/
|
||||
onThemeChange(callback: UniNamespace.OnThemeChangeCallback): void;
|
||||
/**
|
||||
* 取消监听系统主题状态变化。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/theme.html#offthemechange](https://uniapp.dcloud.net.cn/api/system/theme.html#offthemechange)
|
||||
*/
|
||||
offThemeChange(callback: UniNamespace.OnThemeChangeCallback): void;
|
||||
}
|
||||
Generated
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
declare namespace UniNamespace {
|
||||
interface OnUnhandledRejectionCallbackResult {
|
||||
/**
|
||||
* 被拒绝的 Promise 对象
|
||||
*/
|
||||
promise: Promise<any>;
|
||||
/**
|
||||
* 拒绝原因,一般是一个 Error 对象
|
||||
*/
|
||||
reason: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 未处理的 Promise 拒绝事件的回调函数
|
||||
*/
|
||||
type OnUnhandledRejectionCallback = (result: OnUnhandledRejectionCallbackResult) => void;
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
/**
|
||||
* 监听未处理的 Promise 拒绝事件。该事件与 `App.onUnhandledRejection` 的回调时机与参数一致。
|
||||
*
|
||||
* **注意**
|
||||
*
|
||||
*
|
||||
* - 安卓平台暂时不支持该事件
|
||||
* - 所有的 unhandledRejection 都可以被这一监听捕获,但只有 Error 类型的才会在小程序后台触发报警。
|
||||
*
|
||||
* 最低基础库: `2.10.0`
|
||||
*
|
||||
* 文档: [https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html)
|
||||
*/
|
||||
onUnhandledRejection(callback: UniNamespace.OnUnhandledRejectionCallback): void;
|
||||
|
||||
/**
|
||||
* 取消监听未处理的 Promise 拒绝事件
|
||||
*
|
||||
* 最低基础库: `2.10.0`
|
||||
*
|
||||
* 文档: [https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offUnhandledRejection.html](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offUnhandledRejection.html)
|
||||
*/
|
||||
offUnhandledRejection(callback: UniNamespace.OnUnhandledRejectionCallback): void;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
export interface AsyncOptions {
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: (result: any) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: (result: any) => void;
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: (result: any) => void;
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/// <reference path="./ThemeChange.d.ts" />
|
||||
/// <reference path="./UnhandledRejectiond.d.ts" />
|
||||
/// <reference path="./Error.d.ts" />
|
||||
/// <reference path="./MapContext.d.ts" />
|
||||
/// <reference path="./request.d.ts" />
|
||||
+200
@@ -0,0 +1,200 @@
|
||||
declare namespace UniNamespace {
|
||||
interface RequestOptions {
|
||||
/**
|
||||
* 资源url
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* 请求的参数
|
||||
*/
|
||||
data?: string | AnyObject | ArrayBuffer;
|
||||
/**
|
||||
* 设置请求的 header,header 中不能设置 Referer。
|
||||
*/
|
||||
header?: any;
|
||||
/**
|
||||
* 默认为 GET
|
||||
* 可以是:OPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE,CONNECT
|
||||
*/
|
||||
method?: 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT';
|
||||
/**
|
||||
* 超时时间
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* 如果设为json,会尝试对返回的数据做一次 JSON.parse
|
||||
*/
|
||||
dataType?: string;
|
||||
/**
|
||||
* 设置响应的数据类型。合法值:text、arraybuffer
|
||||
*/
|
||||
responseType?: string;
|
||||
/**
|
||||
* 验证 ssl 证书
|
||||
*/
|
||||
sslVerify?: boolean;
|
||||
/**
|
||||
* 跨域请求时是否携带凭证
|
||||
*/
|
||||
withCredentials?: boolean;
|
||||
/**
|
||||
* DNS解析时优先使用 ipv4
|
||||
*/
|
||||
firstIpv4?: boolean;
|
||||
/**
|
||||
* 开启 http2
|
||||
*/
|
||||
enableHttp2?: boolean;
|
||||
/**
|
||||
* 开启 quic
|
||||
*/
|
||||
enableQuic?: boolean;
|
||||
/**
|
||||
* 开启 cache
|
||||
*/
|
||||
enableCache?: boolean;
|
||||
/**
|
||||
* 是否开启 HttpDNS 服务。如开启,需要同时填入 httpDNSServiceId 。 HttpDNS 用法详见 [移动解析HttpDNS](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/HTTPDNS.html)
|
||||
*/
|
||||
enableHttpDNS?: boolean;
|
||||
/**
|
||||
* HttpDNS 服务商 Id。 HttpDNS 用法详见 [移动解析HttpDNS](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/HTTPDNS.html)
|
||||
*/
|
||||
httpDNSServiceId?: string;
|
||||
/**
|
||||
* 开启 transfer-encoding chunked
|
||||
*/
|
||||
enableChunked?: boolean;
|
||||
/**
|
||||
* wifi下使用移动网络发送请求
|
||||
*/
|
||||
forceCellularNetwork?: boolean;
|
||||
/**
|
||||
* 默认 false,开启后可在headers中编辑cookie(支付宝小程序10.2.33版本开始支持)
|
||||
*/
|
||||
enableCookie?: boolean;
|
||||
/**
|
||||
* 是否开启云加速(详见[云加速服务](https://smartprogram.baidu.com/docs/develop/extended/component-codeless/cloud-speed/introduction/))
|
||||
*/
|
||||
cloudCache?: object | boolean;
|
||||
/**
|
||||
* 控制当前请求是否延时至首屏内容渲染后发送
|
||||
*/
|
||||
defer?: boolean;
|
||||
success?: (result: RequestSuccessCallbackResult) => void;
|
||||
/**
|
||||
* 失败的回调函数
|
||||
*/
|
||||
fail?: (result: GeneralCallbackResult) => void;
|
||||
/**
|
||||
* 结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: (result: GeneralCallbackResult) => void;
|
||||
}
|
||||
interface RequestSuccessCallbackResult {
|
||||
/**
|
||||
* 开发者服务器返回的数据
|
||||
*/
|
||||
data: string | AnyObject | ArrayBuffer;
|
||||
/**
|
||||
* 开发者服务器返回的 HTTP 状态码
|
||||
*/
|
||||
statusCode: number;
|
||||
/**
|
||||
* 开发者服务器返回的 HTTP Response Header
|
||||
*/
|
||||
header: any;
|
||||
/**
|
||||
* 开发者服务器返回的 cookies,格式为字符串数组
|
||||
*/
|
||||
cookies: string[];
|
||||
}
|
||||
|
||||
interface RequestTask {
|
||||
/**
|
||||
* 中断请求任务
|
||||
* @tutorial https://uniapp.dcloud.net.cn/api/request/request.html#request
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "4.4",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "3.9.0"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "9.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "3.9.0"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @example ```typescript
|
||||
* var requestTask = uni.request({
|
||||
* url: 'http://192.168.12.106:8080/postHalo', //仅为示例,并非真实接口地址。
|
||||
* complete: ()=> {}
|
||||
* });
|
||||
* requestTask.abort();
|
||||
* ```
|
||||
*/
|
||||
abort(): void;
|
||||
/**
|
||||
* 监听 HTTP Response Header 事件
|
||||
*/
|
||||
onHeadersReceived(callback: (result: any) => void): void;
|
||||
/**
|
||||
* 取消监听 HTTP Response Header 事件
|
||||
*/
|
||||
offHeadersReceived(callback: (result: any) => void): void;
|
||||
}
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
/**
|
||||
* 发起网络请求
|
||||
*
|
||||
* 文档: [http://uniapp.dcloud.io/api/request/request?id=request](http://uniapp.dcloud.io/api/request/request?id=request)
|
||||
* @tutorial https://uniapp.dcloud.net.cn/api/request/request.html
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "4.4",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "3.9.0"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "9.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "3.9.0"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* @example ```typescript
|
||||
* uni.request({
|
||||
* url: "http://192.168.12.106:8080/postHalo",
|
||||
* dataType: "json",
|
||||
* responseType: "json",
|
||||
* method: "POST",
|
||||
* data: {
|
||||
* platform: "ios",
|
||||
* },
|
||||
* // header: {
|
||||
* // "Content-Type": "application/json",
|
||||
* // },
|
||||
* timeout: 6000,
|
||||
* sslVerify: false,
|
||||
* withCredentials: false,
|
||||
* firstIpv4: false,
|
||||
* success(res) {
|
||||
* console.log("success :", res.data);
|
||||
* },
|
||||
* fail(e) {
|
||||
* console.log(e);
|
||||
* },
|
||||
* complete(res) {
|
||||
* console.log("complete :", res);
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
request(options: UniNamespace.RequestOptions): UniNamespace.RequestTask;
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
declare namespace UniNamespace {
|
||||
// 监听消息Callback
|
||||
type WorkerOnMessageCallback = (message: any) => void;
|
||||
// Worker错误callback
|
||||
type WorkerOnErrorCallback = (error: any) => void;
|
||||
|
||||
interface WorkerOptions {
|
||||
/**
|
||||
* 可转移对象数组,默认值为空数组
|
||||
* 仅鸿蒙、web平台支持,参考:https://developer.mozilla.org/zh-CN/docs/Web/API/Web_Workers_API/Transferable_objects
|
||||
*/
|
||||
transfer?: any[];
|
||||
}
|
||||
|
||||
// Worker对象
|
||||
interface Worker {
|
||||
onMessage(listener: WorkerOnMessageCallback): void;
|
||||
onError(listener: WorkerOnErrorCallback): void;
|
||||
postMessage(message: any, options?: WorkerOptions): void;
|
||||
terminate(): void;
|
||||
}
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
createWorker(url: string): UniNamespace.Worker;
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
declare namespace UniNamespace {
|
||||
interface StartFacialRecognitionVerifyCallbackResult {
|
||||
/**
|
||||
* 错误码,成功时为0
|
||||
*/
|
||||
errCode: number;
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
errMsg: string;
|
||||
/**
|
||||
* 抛出错误的模块/主题名
|
||||
*/
|
||||
errSubject?: string;
|
||||
/**
|
||||
* 引起此错误的下层错误
|
||||
*/
|
||||
cause?: any;
|
||||
}
|
||||
interface StartFacialRecognitionVerifyOption {
|
||||
/**
|
||||
* 认证流水号,由服务端根据接入的业务模式调用对应的初始化接口获取
|
||||
*/
|
||||
certifyId: string;
|
||||
/**
|
||||
* 刷脸圈的颜色
|
||||
*/
|
||||
progressBarColor?: string;
|
||||
/**
|
||||
* 认证界面UI朝向。port 为竖屏,land 为横屏,默认为 port
|
||||
*/
|
||||
screenOrientation?: string;
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: (result: StartFacialRecognitionVerifyCallbackResult) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: (result: StartFacialRecognitionVerifyCallbackResult) => void;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: (result: StartFacialRecognitionVerifyCallbackResult) => void;
|
||||
}
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
/**
|
||||
* 获取设备信息MetaInfo
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/uniCloud/frv/dev.html#get-meta-info](https://uniapp.dcloud.net.cn/uniCloud/frv/dev.html#get-meta-info)
|
||||
*/
|
||||
getFacialRecognitionMetaInfo(): string;
|
||||
/**
|
||||
* 调起实人认证界面
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/uniCloud/frv/dev.html#start-frv](https://uniapp.dcloud.net.cn/uniCloud/frv/dev.html#start-frv)
|
||||
*/
|
||||
startFacialRecognitionVerify(options: UniNamespace.StartFacialRecognitionVerifyOption): void;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
declare namespace UniNamespace {
|
||||
interface OnMemoryWarningCallbackResult {
|
||||
/**
|
||||
* 仅 Android 有该字段,对应系统内存告警等级宏定义
|
||||
*/
|
||||
level: number;
|
||||
}
|
||||
type OnMemoryWarningCallback = (res: OnMemoryWarningCallbackResult) => void;
|
||||
}
|
||||
interface Uni {
|
||||
/**
|
||||
* 监听内存不足告警事件。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/memory.html#onmemorywarning](https://uniapp.dcloud.net.cn/api/system/memory.html#onmemorywarning)
|
||||
*/
|
||||
onMemoryWarning(callback: UniNamespace.OnMemoryWarningCallback): void;
|
||||
/**
|
||||
* 取消监听内存不足告警事件。不传入 callback 则取消所有监听。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/memory.html#offmemorywarning](https://uniapp.dcloud.net.cn/api/system/memory.html#offmemorywarning)
|
||||
*/
|
||||
offMemoryWarning(callback?: UniNamespace.OnMemoryWarningCallback): void;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
declare namespace UniNamespace {
|
||||
type OnUserCaptureScreenCallback = (res?: { errMsg: string }) => void;
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
/**
|
||||
* 监听用户主动截屏事件,用户使用系统截屏按键截屏时触发此事件。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen](https://uniapp.dcloud.net.cn/api/system/capture-screen.html#onusercapturescreen)
|
||||
*/
|
||||
onUserCaptureScreen(callback: UniNamespace.OnUserCaptureScreenCallback): void;
|
||||
/**
|
||||
* 用户主动截屏事件。取消事件监听。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen](https://uniapp.dcloud.net.cn/api/system/capture-screen.html#offusercapturescreen)
|
||||
*/
|
||||
offUserCaptureScreen(callback: UniNamespace.OnUserCaptureScreenCallback): void;
|
||||
}
|
||||
+386
@@ -0,0 +1,386 @@
|
||||
declare namespace UniNamespace {
|
||||
interface WifiError {
|
||||
/**
|
||||
* 错误信息
|
||||
*
|
||||
* | 错误码 | 错误信息 | 说明 |
|
||||
* | - | - | - |
|
||||
* | 0 | ok | 正常 |
|
||||
* | 12000 | not init | 未先调用 `startWifi` 接口 |
|
||||
* | 12001 | system not support | 当前系统不支持相关能力 |
|
||||
* | 12002 | password error Wi-Fi | 密码错误 |
|
||||
* | 12003 | connection timeout | 连接超时, 仅 Android 支持 |
|
||||
* | 12004 | duplicate request | 重复连接 Wi-Fi |
|
||||
* | 12005 | wifi not turned on | Android 特有,未打开 Wi-Fi 开关 |
|
||||
* | 12006 | gps not turned on | Android 特有,未打开 GPS 定位开关 |
|
||||
* | 12007 | user denied | 用户拒绝授权链接 Wi-Fi |
|
||||
* | 12008 | invalid SSID | 无效 SSID |
|
||||
* | 12009 | system config err | 系统运营商配置拒绝连接 Wi-Fi |
|
||||
* | 12010 | system internal error | 系统其他错误,需要在 errmsg 打印具体的错误原因 |
|
||||
* | 12011 | weapp in background | 应用在后台无法配置 Wi-Fi |
|
||||
* | 12013 | wifi config may be expired | 系统保存的 Wi-Fi 配置过期,建议忘记 Wi-Fi 后重试,仅 Android 支持 |
|
||||
* | 12014 | invalid WEP / WPA password | iOS 特有,无效的 WEP / WPA 密码 |
|
||||
*/
|
||||
errMsg: string;
|
||||
/**
|
||||
* 错误码
|
||||
*
|
||||
* | 错误码 | 错误信息 | 说明 |
|
||||
* | - | - | - |
|
||||
* | 0 | ok | 正常 |
|
||||
* | 12000 | not init | 未先调用 `startWifi` 接口 |
|
||||
* | 12001 | system not support | 当前系统不支持相关能力 |
|
||||
* | 12002 | password error Wi-Fi | 密码错误 |
|
||||
* | 12003 | connection timeout | 连接超时, 仅 Android 支持 |
|
||||
* | 12004 | duplicate request | 重复连接 Wi-Fi |
|
||||
* | 12005 | wifi not turned on | Android 特有,未打开 Wi-Fi 开关 |
|
||||
* | 12006 | gps not turned on | Android 特有,未打开 GPS 定位开关 |
|
||||
* | 12007 | user denied | 用户拒绝授权链接 Wi-Fi |
|
||||
* | 12008 | invalid SSID | 无效 SSID |
|
||||
* | 12009 | system config err | 系统运营商配置拒绝连接 Wi-Fi |
|
||||
* | 12010 | system internal error | 系统其他错误,需要在 errmsg 打印具体的错误原因 |
|
||||
* | 12011 | weapp in background | 应用在后台无法配置 Wi-Fi |
|
||||
* | 12013 | wifi config may be expired | 系统保存的 Wi-Fi 配置过期,建议忘记 Wi-Fi 后重试,仅 Android 支持 |
|
||||
* | 12014 | invalid WEP / WPA password | iOS 特有,无效的 WEP / WPA 密码 |
|
||||
*/
|
||||
errCode: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
type StartWifiCompleteCallback = (res: WifiError) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
type StartWifiFailCallback = (res: WifiError) => void;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
type StartWifiSuccessCallback = (res: WifiError) => void;
|
||||
|
||||
interface StartWifiOption {
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: StartWifiCompleteCallback;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: StartWifiFailCallback;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: StartWifiSuccessCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
type StopWifiCompleteCallback = (res: WifiError) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
type StopWifiFailCallback = (res: WifiError) => void;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
type StopWifiSuccessCallback = (res: WifiError) => void;
|
||||
|
||||
interface StopWifiOption {
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: StopWifiCompleteCallback;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: StopWifiFailCallback;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: StopWifiSuccessCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
type ConnectWifiCompleteCallback = (res: WifiError) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
type ConnectWifiFailCallback = (res: WifiError) => void;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
type ConnectWifiSuccessCallback = (res: WifiError) => void;
|
||||
|
||||
interface ConnectWifiOption {
|
||||
/**
|
||||
* Wi-Fi 设备 SSID
|
||||
*/
|
||||
SSID: string;
|
||||
/**
|
||||
* Wi-Fi 设备 BSSID
|
||||
*/
|
||||
BSSID?: string;
|
||||
/**
|
||||
* Wi-Fi 设备密码
|
||||
*/
|
||||
password: string;
|
||||
/**
|
||||
* 需要基础库: `2.12.0`
|
||||
*
|
||||
* 跳转到系统设置页进行连接
|
||||
*/
|
||||
maunal?: boolean;
|
||||
/**
|
||||
* 需要基础库: `2.22.0`
|
||||
*
|
||||
* 是否需要返回部分 Wi-Fi 信息,仅安卓生效
|
||||
*/
|
||||
partialInfo?: boolean;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: ConnectWifiSuccessCallback;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: ConnectWifiFailCallback;
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: ConnectWifiCompleteCallback;
|
||||
}
|
||||
|
||||
interface WifiInfo {
|
||||
/**
|
||||
* Wi-Fi 的 SSID
|
||||
*/
|
||||
SSID: string;
|
||||
/**
|
||||
* Wi-Fi 的 BSSID
|
||||
*/
|
||||
BSSID: string;
|
||||
/**
|
||||
* Wi-Fi 是否安全
|
||||
*/
|
||||
secure: boolean;
|
||||
/**
|
||||
* Wi-Fi 信号强度, 安卓取值 0 ~ 100 ,iOS 取值 0 ~ 1 ,值越大强度越大
|
||||
*/
|
||||
signalStrength: number;
|
||||
/**
|
||||
* Wi-Fi 频段单位 MHz
|
||||
*/
|
||||
frequency: number;
|
||||
}
|
||||
interface OnWifiConnectedListenerResult {
|
||||
/**
|
||||
* Wi-Fi 信息
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#WifiInfo](https://uniapp.dcloud.net.cn/api/system/wifi.html#WifiInfo)
|
||||
*/
|
||||
wifi: WifiInfo;
|
||||
}
|
||||
/**
|
||||
* 连接上 Wi-Fi 的事件的监听函数
|
||||
*/
|
||||
type OnWifiConnectedCallback = (
|
||||
result: OnWifiConnectedListenerResult
|
||||
) => void;
|
||||
/**
|
||||
* onWifiConnected 传入的监听函数。不传此参数则移除所有监听函数。
|
||||
*/
|
||||
type OffWifiConnectedCallback = (
|
||||
result: OnWifiConnectedListenerResult
|
||||
) => void;
|
||||
|
||||
interface OnWifiConnectedWithPartialInfoListenerResult {
|
||||
/**
|
||||
*
|
||||
* 只包含 SSID 属性的 WifiInfo 对象
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#WifiInfo](https://uniapp.dcloud.net.cn/api/system/wifi.html#WifiInfo)
|
||||
*/
|
||||
wifi: WifiInfo;
|
||||
}
|
||||
/**
|
||||
* 连接上 Wi-Fi 的事件的监听函数
|
||||
*/
|
||||
type OnWifiConnectedWithPartialInfoCallback = (
|
||||
result: OnWifiConnectedWithPartialInfoListenerResult
|
||||
) => void;
|
||||
|
||||
interface GetConnectedWifiSuccessCallbackResult {
|
||||
/**
|
||||
* Wi-Fi 信息
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#WifiInfo](https://uniapp.dcloud.net.cn/api/system/wifi.html#WifiInfo)
|
||||
*/
|
||||
wifi: WifiInfo;
|
||||
errMsg: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
type GetConnectedWifiSuccessCallback = (
|
||||
result: GetConnectedWifiSuccessCallbackResult
|
||||
) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
type GetConnectedWifiFailCallback = (res: WifiError) => void;
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
type GetConnectedWifiCompleteCallback = (res: WifiError) => void;
|
||||
interface GetConnectedWifiOption {
|
||||
/**
|
||||
* 是否需要返回部分 Wi-Fi 信息
|
||||
*/
|
||||
partialInfo?: boolean;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: GetConnectedWifiSuccessCallback;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: GetConnectedWifiFailCallback;
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: GetConnectedWifiCompleteCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
type GetWifiListSuccessCallback = (res: WifiError) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
type GetWifiListFailCallback = (res: WifiError) => void;
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
type GetWifiListCompleteCallback = (res: WifiError) => void;
|
||||
interface GetWifiListOption {
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: GetWifiListSuccessCallback;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: GetWifiListFailCallback;
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: GetWifiListCompleteCallback;
|
||||
}
|
||||
|
||||
interface OnGetWifiListListenerResult {
|
||||
/**
|
||||
* Wi-Fi 列表数据
|
||||
*/
|
||||
wifiList: WifiInfo[];
|
||||
}
|
||||
/**
|
||||
* 获取到 Wi-Fi 列表数据事件的监听函数
|
||||
*/
|
||||
type OnGetWifiListCallback = (result: OnGetWifiListListenerResult) => void;
|
||||
/**
|
||||
* onGetWifiList 传入的监听函数。不传此参数则移除所有监听函数。
|
||||
*/
|
||||
type OffGetWifiListCallback = (result: OnGetWifiListListenerResult) => void;
|
||||
|
||||
/**
|
||||
* onWifiConnectedWithPartialInfo 传入的监听函数。不传此参数则移除所有监听函数。
|
||||
*/
|
||||
type OffWifiConnectedWithPartialInfoCallback = (
|
||||
result: OnWifiConnectedWithPartialInfoListenerResult
|
||||
) => void;
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
/**
|
||||
* 初始化 Wi-Fi 模块
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#startwifi](https://uniapp.dcloud.net.cn/api/system/wifi.html#startwifi)
|
||||
*/
|
||||
startWifi(option?: UniNamespace.StartWifiOption): void;
|
||||
|
||||
/**
|
||||
* 关闭 Wi-Fi 模块
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#stopwifi](https://uniapp.dcloud.net.cn/api/system/wifi.html#stopwifi)
|
||||
*/
|
||||
stopWifi(option?: UniNamespace.StopWifiOption): void;
|
||||
|
||||
/**
|
||||
* 连接 Wi-Fi。若已知 Wi-Fi 信息,可以直接利用该接口连接。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#connectwifi](https://uniapp.dcloud.net.cn/api/system/wifi.html#connectwifi)
|
||||
*/
|
||||
connectWifi(option: UniNamespace.ConnectWifiOption): void;
|
||||
|
||||
/**
|
||||
* 监听连接上 Wi-Fi 的事件。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#onwificonnected](https://uniapp.dcloud.net.cn/api/system/wifi.html#onwificonnected)
|
||||
*/
|
||||
onWifiConnected(listener: UniNamespace.OnWifiConnectedCallback): void;
|
||||
|
||||
/**
|
||||
* 移除连接上 Wi-Fi 的事件的监听函数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#offwificonnected](https://uniapp.dcloud.net.cn/api/system/wifi.html#offwificonnected)
|
||||
*/
|
||||
offWifiConnected(listener?: UniNamespace.OffWifiConnectedCallback): void;
|
||||
|
||||
/**
|
||||
* 获取已连接的 Wi-Fi 信息。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#getconnectedwifi](https://uniapp.dcloud.net.cn/api/system/wifi.html#getconnectedwifi)
|
||||
*/
|
||||
getConnectedWifi(option: UniNamespace.GetConnectedWifiOption): void;
|
||||
|
||||
/**
|
||||
* 请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#getwifilist](https://uniapp.dcloud.net.cn/api/system/wifi.html#getwifilist)
|
||||
*/
|
||||
getWifiList(option?: UniNamespace.GetWifiListOption): void;
|
||||
|
||||
/**
|
||||
* 监听获取到 Wi-Fi 列表数据事件。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#ongetwifilist](https://uniapp.dcloud.net.cn/api/system/wifi.html#ongetwifilist)
|
||||
*/
|
||||
onGetWifiList(listener: UniNamespace.OnGetWifiListCallback): void;
|
||||
|
||||
/**
|
||||
* 移除获取到 Wi-Fi 列表数据事件的监听函数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#offgetwifilist](https://uniapp.dcloud.net.cn/api/system/wifi.html#offgetwifilist)
|
||||
*/
|
||||
offGetWifiList(listener?: UniNamespace.OffGetWifiListCallback): void;
|
||||
|
||||
/**
|
||||
* 监听连接上 Wi-Fi 的事件。
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#onwificonnectedwithpartialinfo](https://uniapp.dcloud.net.cn/api/system/wifi.html#onwificonnectedwithpartialinfo)
|
||||
*/
|
||||
onWifiConnectedWithPartialInfo(listener: UniNamespace.OnWifiConnectedWithPartialInfoCallback): void;
|
||||
|
||||
/**
|
||||
* 移除连接上 Wi-Fi 的事件的监听函数
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/wifi.html#offwificonnectedwithpartialinfo](https://uniapp.dcloud.net.cn/api/system/wifi.html#offwificonnectedwithpartialinfo)
|
||||
*/
|
||||
offWifiConnectedWithPartialInfo(listener?: UniNamespace.OffWifiConnectedWithPartialInfoCallback): void;
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
declare namespace UniNamespace {
|
||||
interface GetBatteryInfoSuccessCallbackResult {
|
||||
/**
|
||||
* 是否正在充电中
|
||||
*/
|
||||
isCharging: boolean;
|
||||
/**
|
||||
* 设备电量,范围 1 - 100
|
||||
*/
|
||||
level: number;
|
||||
errMsg: string;
|
||||
}
|
||||
|
||||
interface GetBatteryInfoOption {
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
*/
|
||||
complete?: (result: any) => void;
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
*/
|
||||
fail?: (result: any) => void;
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
*/
|
||||
success?: (result: GetBatteryInfoSuccessCallbackResult) => void;
|
||||
}
|
||||
}
|
||||
|
||||
interface Uni {
|
||||
/**
|
||||
* 获取设备电量
|
||||
*
|
||||
* 文档: [https://uniapp.dcloud.net.cn/api/system/batteryInfo.html](https://uniapp.dcloud.net.cn/api/system/batteryInfo.html)
|
||||
*/
|
||||
getBatteryInfo(option?: UniNamespace.GetBatteryInfoOption): void;
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/// <reference path="./getBatteryInfo.d.ts" />
|
||||
/// <reference path="./MemoryWarning.d.ts" />
|
||||
/// <reference path="./UserCaptureScreen.d.ts" />
|
||||
/// <reference path="./Wifi.d.ts" />
|
||||
/// <reference path="./FacialRecognition.d.ts" />
|
||||
/// <reference path="./CreateWorker.d.ts" />
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
/// <reference path="./legacy/uni.d.ts" />
|
||||
/// <reference path="./base/index.d.ts" />
|
||||
/// <reference path="./ext/index.d.ts" />
|
||||
+11918
File diff suppressed because it is too large
Load Diff
+202
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+2756
File diff suppressed because one or more lines are too long
+142
@@ -0,0 +1,142 @@
|
||||
import { defineAsyncApi as originalDefineAsyncApi, defineOffApi as originalDefineOffApi, defineOnApi as originalDefineOnApi, defineSyncApi as originalDefineSyncApi, defineTaskApi as originalDefineTaskApi } from "@dcloudio/uni-mp-sdk";
|
||||
interface UniProvider {
|
||||
id: string;
|
||||
description: string;
|
||||
}
|
||||
const providers: Map<String, Map<String, UniProvider>> = new Map();
|
||||
function getUniProvider<T extends UniProvider>(service: string, providerName: String): T | null {
|
||||
return providers.get(service)?.get(providerName) as T | null;
|
||||
}
|
||||
function getUniProviders(service: string): UniProvider[] {
|
||||
const result: UniProvider[] = [];
|
||||
providers.get(service)?.forEach((provider)=>{
|
||||
result.push(provider);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
function registerUniProvider<T extends UniProvider>(service: string, providerName: string, provider: T) {
|
||||
if (!providers.has(service)) {
|
||||
providers.set(service, new Map());
|
||||
}
|
||||
providers.get(service)?.set(providerName, provider);
|
||||
}
|
||||
type Anything = Object | null | undefined;
|
||||
type NullType = null | undefined;
|
||||
type FormatArgsValueType = Function | string | number | boolean;
|
||||
interface AsyncApiSuccessResult {
|
||||
}
|
||||
interface AsyncApiResult {
|
||||
}
|
||||
interface ApiError {
|
||||
errMsg?: string | null;
|
||||
errCode?: number | null;
|
||||
}
|
||||
interface ApiExecutor<K> {
|
||||
resolve: (res?: K | void) => void;
|
||||
reject: (errMsg?: string, errRes?: ApiError) => void;
|
||||
}
|
||||
interface ProtocolOptions {
|
||||
name?: string | null;
|
||||
type?: string | null;
|
||||
required?: boolean | null;
|
||||
validator?: (value: Object) => boolean | undefined | string;
|
||||
}
|
||||
interface ApiOptions<T> {
|
||||
beforeInvoke?: (args: Object) => boolean | void | string;
|
||||
beforeAll?: (res: Object) => void;
|
||||
beforeSuccess?: (res: Object, args: T) => void;
|
||||
formatArgs?: Map<string, FormatArgsValueType>;
|
||||
}
|
||||
interface AsyncMethodOptionLike {
|
||||
success?: Function | null;
|
||||
}
|
||||
const TYPE_MAP = new Map<string, Object>([
|
||||
[
|
||||
'string',
|
||||
String
|
||||
],
|
||||
[
|
||||
'number',
|
||||
Number
|
||||
],
|
||||
[
|
||||
'boolean',
|
||||
Boolean
|
||||
],
|
||||
[
|
||||
'array',
|
||||
Array
|
||||
],
|
||||
[
|
||||
'object',
|
||||
Object
|
||||
]
|
||||
]);
|
||||
function getPropType(type: string | NullType): Anything {
|
||||
if (!type) {
|
||||
return;
|
||||
}
|
||||
return TYPE_MAP.get(type);
|
||||
}
|
||||
function buildProtocol(protocol: Map<string, ProtocolOptions> | null = null) {
|
||||
const originalProtocol = {} as Record<string, Object>;
|
||||
protocol?.forEach((value, key)=>{
|
||||
const protocol = originalProtocol[key] = {} as Record<string, Anything>;
|
||||
protocol.name = value.name;
|
||||
protocol.type = getPropType(value.type);
|
||||
protocol.required = value.required;
|
||||
protocol.validator = value.validator;
|
||||
});
|
||||
return originalProtocol;
|
||||
}
|
||||
function buildOptions(options: ApiOptions<AsyncMethodOptionLike> | null = null) {
|
||||
const originalFormatArgs = {} as Record<string, FormatArgsValueType>;
|
||||
const originalOptions = {} as Record<string, Anything>;
|
||||
if (options) {
|
||||
if (options.formatArgs) {
|
||||
options.formatArgs.forEach((value, key)=>{
|
||||
originalFormatArgs[key] = value;
|
||||
});
|
||||
}
|
||||
originalOptions.beforeInvoke = options.beforeInvoke;
|
||||
originalOptions.beforeAll = options.beforeAll;
|
||||
originalOptions.beforeSuccess = options.beforeSuccess;
|
||||
originalOptions.formatArgs = originalFormatArgs;
|
||||
}
|
||||
return originalOptions;
|
||||
}
|
||||
function defineAsyncApi<T extends AsyncMethodOptionLike, K>(name: string, fn: (options: T, res: ApiExecutor<K>) => void, protocol: Map<string, ProtocolOptions> | null = null, options: ApiOptions<T> | null = null): Function {
|
||||
const originalProtocol = buildProtocol(protocol);
|
||||
const originalOptions = buildOptions(options as ApiOptions<AsyncMethodOptionLike>);
|
||||
return originalDefineAsyncApi(name, fn, originalProtocol, originalOptions);
|
||||
}
|
||||
function defineTaskApi<T, K, TASK>(name: string, fn: (options: T, res: ApiExecutor<K>) => TASK, protocol: Map<string, ProtocolOptions>, options: ApiOptions<T>): Object {
|
||||
const originalProtocol = buildProtocol(protocol);
|
||||
const originalOptions = buildOptions(options as ApiOptions<AsyncMethodOptionLike>);
|
||||
return originalDefineTaskApi(name, fn, originalProtocol, originalOptions);
|
||||
}
|
||||
function defineSyncApi<K>(name: string, fn: Function, protocol: Map<string, ProtocolOptions> | null = null, options: ApiOptions<Object> | null = null): (...args: Object[]) => K {
|
||||
const originalProtocol = buildProtocol(protocol);
|
||||
const originalOptions = buildOptions(options as ApiOptions<AsyncMethodOptionLike>);
|
||||
return originalDefineSyncApi(name, fn, originalProtocol, originalOptions);
|
||||
}
|
||||
function defineOnApi<T>(name: string, fn: () => void, options: ApiOptions<T> | null = null): Function {
|
||||
const originalOptions = buildOptions(options as ApiOptions<AsyncMethodOptionLike>);
|
||||
return originalDefineOnApi(name, fn, originalOptions);
|
||||
}
|
||||
function defineOffApi<T>(name: string, fn: () => void, options: ApiOptions<T> | null = null): Function {
|
||||
const originalOptions = buildOptions(options as ApiOptions<AsyncMethodOptionLike>);
|
||||
return originalDefineOffApi(name, fn, originalOptions);
|
||||
}
|
||||
export { UniProvider as UniProvider, getUniProvider as getUniProvider, getUniProviders as getUniProviders, registerUniProvider as registerUniProvider };
|
||||
export { AsyncApiSuccessResult as AsyncApiSuccessResult };
|
||||
export { AsyncApiResult as AsyncApiResult };
|
||||
export { ApiError as ApiError };
|
||||
export { ApiExecutor as ApiExecutor };
|
||||
export { ProtocolOptions as ProtocolOptions };
|
||||
export { ApiOptions as ApiOptions };
|
||||
export { defineAsyncApi as defineAsyncApi };
|
||||
export { defineTaskApi as defineTaskApi };
|
||||
export { defineSyncApi as defineSyncApi };
|
||||
export { defineOnApi as defineOnApi };
|
||||
export { defineOffApi as defineOffApi };
|
||||
+26711
File diff suppressed because it is too large
Load Diff
+10585
File diff suppressed because it is too large
Load Diff
+615
@@ -0,0 +1,615 @@
|
||||
import { isArray, hasOwn, isString, isPlainObject, isObject, toRawType, capitalize, makeMap, isFunction, isPromise, extend, remove } from '@vue/shared';
|
||||
|
||||
function validateProtocolFail(name, msg) {
|
||||
console.warn(`${name}: ${msg}`);
|
||||
}
|
||||
function validateProtocol(name, data, protocol, onFail) {
|
||||
if (!onFail) {
|
||||
onFail = validateProtocolFail;
|
||||
}
|
||||
for (const key in protocol) {
|
||||
const errMsg = validateProp(key, data[key], protocol[key], !hasOwn(data, key));
|
||||
if (isString(errMsg)) {
|
||||
onFail(name, errMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
function validateProtocols(name, args, protocol, onFail) {
|
||||
if (!protocol) {
|
||||
return;
|
||||
}
|
||||
if (!isArray(protocol)) {
|
||||
return validateProtocol(name, args[0] || Object.create(null), protocol, onFail);
|
||||
}
|
||||
const len = protocol.length;
|
||||
const argsLen = args.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
const opts = protocol[i];
|
||||
const data = Object.create(null);
|
||||
if (argsLen > i) {
|
||||
data[opts.name] = args[i];
|
||||
}
|
||||
validateProtocol(name, data, { [opts.name]: opts }, onFail);
|
||||
}
|
||||
}
|
||||
function validateProp(name, value, prop, isAbsent) {
|
||||
if (!isPlainObject(prop)) {
|
||||
prop = { type: prop };
|
||||
}
|
||||
const { type, required, validator } = prop;
|
||||
// required!
|
||||
if (required && isAbsent) {
|
||||
return 'Missing required args: "' + name + '"';
|
||||
}
|
||||
// missing but optional
|
||||
if (value == null && !required) {
|
||||
return;
|
||||
}
|
||||
// type check
|
||||
if (type != null) {
|
||||
let isValid = false;
|
||||
const types = isArray(type) ? type : [type];
|
||||
const expectedTypes = [];
|
||||
// value is valid as long as one of the specified types match
|
||||
for (let i = 0; i < types.length && !isValid; i++) {
|
||||
const { valid, expectedType } = assertType(value, types[i]);
|
||||
expectedTypes.push(expectedType || '');
|
||||
isValid = valid;
|
||||
}
|
||||
if (!isValid) {
|
||||
return getInvalidTypeMessage(name, value, expectedTypes);
|
||||
}
|
||||
}
|
||||
// custom validator
|
||||
if (validator) {
|
||||
return validator(value);
|
||||
}
|
||||
}
|
||||
const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol');
|
||||
function assertType(value, type) {
|
||||
let valid;
|
||||
const expectedType = getType(type);
|
||||
if (isSimpleType(expectedType)) {
|
||||
const t = typeof value;
|
||||
valid = t === expectedType.toLowerCase();
|
||||
// for primitive wrapper objects
|
||||
if (!valid && t === 'object') {
|
||||
valid = value instanceof type;
|
||||
}
|
||||
}
|
||||
else if (expectedType === 'Object') {
|
||||
valid = isObject(value);
|
||||
}
|
||||
else if (expectedType === 'Array') {
|
||||
valid = isArray(value);
|
||||
}
|
||||
else {
|
||||
if (__PLATFORM__ === 'app') {
|
||||
// App平台ArrayBuffer等参数跨实例传输,无法通过 instanceof 识别
|
||||
valid = value instanceof type || toRawType(value) === getType(type);
|
||||
}
|
||||
else {
|
||||
valid = value instanceof type;
|
||||
}
|
||||
}
|
||||
return {
|
||||
valid,
|
||||
expectedType,
|
||||
};
|
||||
}
|
||||
function getInvalidTypeMessage(name, value, expectedTypes) {
|
||||
let message = `Invalid args: type check failed for args "${name}".` +
|
||||
` Expected ${expectedTypes.map(capitalize).join(', ')}`;
|
||||
const expectedType = expectedTypes[0];
|
||||
const receivedType = toRawType(value);
|
||||
const expectedValue = styleValue(value, expectedType);
|
||||
const receivedValue = styleValue(value, receivedType);
|
||||
// check if we need to specify expected value
|
||||
if (expectedTypes.length === 1 &&
|
||||
isExplicable(expectedType) &&
|
||||
!isBoolean(expectedType, receivedType)) {
|
||||
message += ` with value ${expectedValue}`;
|
||||
}
|
||||
message += `, got ${receivedType} `;
|
||||
// check if we need to specify received value
|
||||
if (isExplicable(receivedType)) {
|
||||
message += `with value ${receivedValue}.`;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
function getType(ctor) {
|
||||
const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
|
||||
return match ? match[1] : '';
|
||||
}
|
||||
function styleValue(value, type) {
|
||||
if (type === 'String') {
|
||||
return `"${value}"`;
|
||||
}
|
||||
else if (type === 'Number') {
|
||||
return `${Number(value)}`;
|
||||
}
|
||||
else {
|
||||
return `${value}`;
|
||||
}
|
||||
}
|
||||
function isExplicable(type) {
|
||||
const explicitTypes = ['string', 'number', 'boolean'];
|
||||
return explicitTypes.some((elem) => type.toLowerCase() === elem);
|
||||
}
|
||||
function isBoolean(...args) {
|
||||
return args.some((elem) => elem.toLowerCase() === 'boolean');
|
||||
}
|
||||
|
||||
function tryCatch(fn) {
|
||||
return function () {
|
||||
try {
|
||||
return fn.apply(fn, arguments);
|
||||
}
|
||||
catch (e) {
|
||||
// TODO
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let invokeCallbackId = 1;
|
||||
const invokeCallbacks = {};
|
||||
function addInvokeCallback(id, name, callback, keepAlive = false) {
|
||||
invokeCallbacks[id] = {
|
||||
name,
|
||||
keepAlive,
|
||||
callback,
|
||||
};
|
||||
return id;
|
||||
}
|
||||
// onNativeEventReceive((event,data)=>{}) 需要两个参数,目前写死最多两个参数
|
||||
function invokeCallback(id, res, extras) {
|
||||
if (typeof id === 'number') {
|
||||
const opts = invokeCallbacks[id];
|
||||
if (opts) {
|
||||
if (!opts.keepAlive) {
|
||||
delete invokeCallbacks[id];
|
||||
}
|
||||
return opts.callback(res, extras);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function findInvokeCallbackByName(name) {
|
||||
for (const key in invokeCallbacks) {
|
||||
if (invokeCallbacks[key].name === name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function removeKeepAliveApiCallback(name, callback) {
|
||||
for (const key in invokeCallbacks) {
|
||||
const item = invokeCallbacks[key];
|
||||
if (item.callback === callback && item.name === name) {
|
||||
delete invokeCallbacks[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
function offKeepAliveApiCallback(name) {
|
||||
UniServiceJSBridge.off('api.' + name);
|
||||
}
|
||||
function onKeepAliveApiCallback(name) {
|
||||
UniServiceJSBridge.on('api.' + name, (res) => {
|
||||
for (const key in invokeCallbacks) {
|
||||
const opts = invokeCallbacks[key];
|
||||
if (opts.name === name) {
|
||||
opts.callback(res);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function createKeepAliveApiCallback(name, callback) {
|
||||
return addInvokeCallback(invokeCallbackId++, name, callback, true);
|
||||
}
|
||||
const API_SUCCESS = 'success';
|
||||
const API_FAIL = 'fail';
|
||||
const API_COMPLETE = 'complete';
|
||||
function getApiCallbacks(args) {
|
||||
const apiCallbacks = {};
|
||||
for (const name in args) {
|
||||
const fn = args[name];
|
||||
if (isFunction(fn)) {
|
||||
apiCallbacks[name] = tryCatch(fn);
|
||||
delete args[name];
|
||||
}
|
||||
}
|
||||
return apiCallbacks;
|
||||
}
|
||||
function normalizeErrMsg(errMsg, name) {
|
||||
if (!errMsg || errMsg.indexOf(':fail') === -1) {
|
||||
return name + ':ok';
|
||||
}
|
||||
return name + errMsg.substring(errMsg.indexOf(':fail'));
|
||||
}
|
||||
function createAsyncApiCallback(name, args = {}, { beforeAll, beforeSuccess } = {}) {
|
||||
if (!isPlainObject(args)) {
|
||||
args = {};
|
||||
}
|
||||
const { success, fail, complete } = getApiCallbacks(args);
|
||||
const hasSuccess = isFunction(success);
|
||||
const hasFail = isFunction(fail);
|
||||
const hasComplete = isFunction(complete);
|
||||
const callbackId = invokeCallbackId++;
|
||||
addInvokeCallback(callbackId, name, (res) => {
|
||||
res = res || {};
|
||||
res.errMsg = normalizeErrMsg(res.errMsg, name);
|
||||
isFunction(beforeAll) && beforeAll(res);
|
||||
if (res.errMsg === name + ':ok') {
|
||||
isFunction(beforeSuccess) && beforeSuccess(res, args);
|
||||
hasSuccess && success(res);
|
||||
}
|
||||
else {
|
||||
hasFail && fail(res);
|
||||
}
|
||||
hasComplete && complete(res);
|
||||
});
|
||||
return callbackId;
|
||||
}
|
||||
|
||||
const HOOK_SUCCESS = 'success';
|
||||
const HOOK_FAIL = 'fail';
|
||||
const HOOK_COMPLETE = 'complete';
|
||||
const globalInterceptors = {};
|
||||
const scopedInterceptors = {};
|
||||
function wrapperHook(hook, params) {
|
||||
return function (data) {
|
||||
return hook(data, params) || data;
|
||||
};
|
||||
}
|
||||
function queue(hooks, data, params) {
|
||||
let promise = false;
|
||||
for (let i = 0; i < hooks.length; i++) {
|
||||
const hook = hooks[i];
|
||||
if (promise) {
|
||||
promise = Promise.resolve(wrapperHook(hook, params));
|
||||
}
|
||||
else {
|
||||
const res = hook(data, params);
|
||||
if (isPromise(res)) {
|
||||
promise = Promise.resolve(res);
|
||||
}
|
||||
if (res === false) {
|
||||
return {
|
||||
then() { },
|
||||
catch() { },
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return (promise || {
|
||||
then(callback) {
|
||||
return callback(data);
|
||||
},
|
||||
catch() { },
|
||||
});
|
||||
}
|
||||
function wrapperOptions(interceptors, options = {}) {
|
||||
[HOOK_SUCCESS, HOOK_FAIL, HOOK_COMPLETE].forEach((name) => {
|
||||
const hooks = interceptors[name];
|
||||
if (!isArray(hooks)) {
|
||||
return;
|
||||
}
|
||||
const oldCallback = options[name];
|
||||
options[name] = function callbackInterceptor(res) {
|
||||
queue(hooks, res, options).then((res) => {
|
||||
return (isFunction(oldCallback) && oldCallback(res)) || res;
|
||||
});
|
||||
};
|
||||
});
|
||||
return options;
|
||||
}
|
||||
function wrapperReturnValue(method, returnValue) {
|
||||
const returnValueHooks = [];
|
||||
if (isArray(globalInterceptors.returnValue)) {
|
||||
returnValueHooks.push(...globalInterceptors.returnValue);
|
||||
}
|
||||
const interceptor = scopedInterceptors[method];
|
||||
if (interceptor && isArray(interceptor.returnValue)) {
|
||||
returnValueHooks.push(...interceptor.returnValue);
|
||||
}
|
||||
returnValueHooks.forEach((hook) => {
|
||||
returnValue = hook(returnValue) || returnValue;
|
||||
});
|
||||
return returnValue;
|
||||
}
|
||||
function getApiInterceptorHooks(method) {
|
||||
const interceptor = Object.create(null);
|
||||
Object.keys(globalInterceptors).forEach((hook) => {
|
||||
if (hook !== 'returnValue') {
|
||||
interceptor[hook] = globalInterceptors[hook].slice();
|
||||
}
|
||||
});
|
||||
const scopedInterceptor = scopedInterceptors[method];
|
||||
if (scopedInterceptor) {
|
||||
Object.keys(scopedInterceptor).forEach((hook) => {
|
||||
if (hook !== 'returnValue') {
|
||||
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
|
||||
}
|
||||
});
|
||||
}
|
||||
return interceptor;
|
||||
}
|
||||
function invokeApi(method, api, options, params) {
|
||||
const interceptor = getApiInterceptorHooks(method);
|
||||
if (interceptor && Object.keys(interceptor).length) {
|
||||
if (isArray(interceptor.invoke)) {
|
||||
const res = queue(interceptor.invoke, options);
|
||||
return res.then((options) => {
|
||||
// 重新访问 getApiInterceptorHooks, 允许 invoke 中再次调用 addInterceptor,removeInterceptor
|
||||
return api(wrapperOptions(getApiInterceptorHooks(method), options), ...params);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return api(wrapperOptions(interceptor, options), ...params);
|
||||
}
|
||||
}
|
||||
return api(options, ...params);
|
||||
}
|
||||
|
||||
function hasCallback(args) {
|
||||
if (isPlainObject(args) &&
|
||||
[API_SUCCESS, API_FAIL, API_COMPLETE].find((cb) => isFunction(args[cb]))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function handlePromise(promise) {
|
||||
// if (__UNI_FEATURE_PROMISE__) {
|
||||
// return promise
|
||||
// .then((data) => {
|
||||
// return [null, data]
|
||||
// })
|
||||
// .catch((err) => [err])
|
||||
// }
|
||||
return promise;
|
||||
}
|
||||
function promisify(name, fn) {
|
||||
return (args = {}, ...rest) => {
|
||||
if (hasCallback(args)) {
|
||||
return wrapperReturnValue(name, invokeApi(name, fn, args, rest));
|
||||
}
|
||||
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
|
||||
invokeApi(name, fn, extend(args, { success: resolve, fail: reject }), rest);
|
||||
})));
|
||||
};
|
||||
}
|
||||
|
||||
function formatApiArgs(args, options) {
|
||||
const params = args[0];
|
||||
if (!options ||
|
||||
!options.formatArgs ||
|
||||
(!isPlainObject(options.formatArgs) && isPlainObject(params))) {
|
||||
return;
|
||||
}
|
||||
const formatArgs = options.formatArgs;
|
||||
const keys = Object.keys(formatArgs);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const name = keys[i];
|
||||
const formatterOrDefaultValue = formatArgs[name];
|
||||
if (isFunction(formatterOrDefaultValue)) {
|
||||
const errMsg = formatterOrDefaultValue(args[0][name], params);
|
||||
if (isString(errMsg)) {
|
||||
return errMsg;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// defaultValue
|
||||
if (!hasOwn(params, name)) {
|
||||
params[name] = formatterOrDefaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function invokeSuccess(id, name, res) {
|
||||
const result = {
|
||||
errMsg: name + ':ok',
|
||||
};
|
||||
{
|
||||
result.errSubject = name;
|
||||
}
|
||||
return invokeCallback(id, extend((res || {}), result));
|
||||
}
|
||||
function invokeFail(id, name, errMsg, errRes = {}) {
|
||||
const errMsgPrefix = name + ':fail';
|
||||
let apiErrMsg = '';
|
||||
if (!errMsg) {
|
||||
apiErrMsg = errMsgPrefix;
|
||||
}
|
||||
else if (errMsg.indexOf(errMsgPrefix) === 0) {
|
||||
apiErrMsg = errMsg;
|
||||
}
|
||||
else {
|
||||
apiErrMsg = errMsgPrefix + ' ' + errMsg;
|
||||
}
|
||||
let res = extend({ errMsg: apiErrMsg }, errRes);
|
||||
{
|
||||
if (typeof UniError !== 'undefined') {
|
||||
res =
|
||||
typeof errRes.errCode !== 'undefined'
|
||||
? new UniError(name, errRes.errCode, apiErrMsg)
|
||||
: new UniError(apiErrMsg, errRes);
|
||||
}
|
||||
}
|
||||
return invokeCallback(id, res);
|
||||
}
|
||||
function beforeInvokeApi(name, args, protocol, options) {
|
||||
if ((process.env.NODE_ENV !== 'production')) {
|
||||
validateProtocols(name, args, protocol);
|
||||
}
|
||||
if (options && options.beforeInvoke) {
|
||||
const errMsg = options.beforeInvoke(args);
|
||||
if (isString(errMsg)) {
|
||||
return errMsg;
|
||||
}
|
||||
}
|
||||
const errMsg = formatApiArgs(args, options);
|
||||
if (errMsg) {
|
||||
return errMsg;
|
||||
}
|
||||
}
|
||||
function checkCallback(callback) {
|
||||
if (!isFunction(callback)) {
|
||||
throw new Error('Invalid args: type check failed for args "callback". Expected Function');
|
||||
}
|
||||
}
|
||||
function wrapperOnApi(name, fn, options) {
|
||||
return (callback) => {
|
||||
checkCallback(callback);
|
||||
const errMsg = beforeInvokeApi(name, [callback], undefined, options);
|
||||
if (errMsg) {
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
// 是否是首次调用on,如果是首次,需要初始化onMethod监听
|
||||
const isFirstInvokeOnApi = !findInvokeCallbackByName(name);
|
||||
createKeepAliveApiCallback(name, callback);
|
||||
if (isFirstInvokeOnApi) {
|
||||
onKeepAliveApiCallback(name);
|
||||
fn();
|
||||
}
|
||||
};
|
||||
}
|
||||
function wrapperOffApi(name, fn, options) {
|
||||
return (callback) => {
|
||||
checkCallback(callback);
|
||||
const errMsg = beforeInvokeApi(name, [callback], undefined, options);
|
||||
if (errMsg) {
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
name = name.replace('off', 'on');
|
||||
removeKeepAliveApiCallback(name, callback);
|
||||
// 是否还存在监听,若已不存在,则移除onMethod监听
|
||||
const hasInvokeOnApi = findInvokeCallbackByName(name);
|
||||
if (!hasInvokeOnApi) {
|
||||
offKeepAliveApiCallback(name);
|
||||
fn();
|
||||
}
|
||||
};
|
||||
}
|
||||
function parseErrMsg(errMsg) {
|
||||
if (!errMsg || isString(errMsg)) {
|
||||
return errMsg;
|
||||
}
|
||||
if (errMsg.stack) {
|
||||
return errMsg.message;
|
||||
}
|
||||
return errMsg;
|
||||
}
|
||||
function wrapperTaskApi(name, fn, protocol, options) {
|
||||
return (args) => {
|
||||
const id = createAsyncApiCallback(name, args, options);
|
||||
const errMsg = beforeInvokeApi(name, [args], protocol, options);
|
||||
if (errMsg) {
|
||||
return invokeFail(id, name, errMsg);
|
||||
}
|
||||
return fn(args, {
|
||||
resolve: (res) => invokeSuccess(id, name, res),
|
||||
reject: (errMsg, errRes) => invokeFail(id, name, parseErrMsg(errMsg), errRes),
|
||||
});
|
||||
};
|
||||
}
|
||||
function wrapperSyncApi(name, fn, protocol, options) {
|
||||
return (...args) => {
|
||||
const errMsg = beforeInvokeApi(name, args, protocol, options);
|
||||
if (errMsg) {
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
return fn.apply(null, args);
|
||||
};
|
||||
}
|
||||
function wrapperAsyncApi(name, fn, protocol, options) {
|
||||
return wrapperTaskApi(name, fn, protocol, options);
|
||||
}
|
||||
function defineOnApi(name, fn, options) {
|
||||
return wrapperOnApi(name, fn, options);
|
||||
}
|
||||
function defineOffApi(name, fn, options) {
|
||||
return wrapperOffApi(name, fn, options);
|
||||
}
|
||||
function defineTaskApi(name, fn, protocol, options) {
|
||||
return promisify(name, wrapperTaskApi(name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options));
|
||||
}
|
||||
function defineSyncApi(name, fn, protocol, options) {
|
||||
return wrapperSyncApi(name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options);
|
||||
}
|
||||
function defineAsyncApi(name, fn, protocol, options) {
|
||||
return promisify(name, wrapperAsyncApi(name, fn, (process.env.NODE_ENV !== 'production') ? protocol : undefined, options));
|
||||
}
|
||||
|
||||
const API_ADD_INTERCEPTOR = 'addInterceptor';
|
||||
const API_REMOVE_INTERCEPTOR = 'removeInterceptor';
|
||||
const AddInterceptorProtocol = [
|
||||
{
|
||||
name: 'method',
|
||||
type: [String, Object],
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
const RemoveInterceptorProtocol = AddInterceptorProtocol;
|
||||
|
||||
function mergeInterceptorHook(interceptors, interceptor) {
|
||||
Object.keys(interceptor).forEach((hook) => {
|
||||
if (isFunction(interceptor[hook])) {
|
||||
interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]);
|
||||
}
|
||||
});
|
||||
}
|
||||
function removeInterceptorHook(interceptors, interceptor) {
|
||||
if (!interceptors || !interceptor) {
|
||||
return;
|
||||
}
|
||||
Object.keys(interceptor).forEach((name) => {
|
||||
const hooks = interceptors[name];
|
||||
const hook = interceptor[name];
|
||||
if (isArray(hooks) && isFunction(hook)) {
|
||||
remove(hooks, hook);
|
||||
}
|
||||
});
|
||||
}
|
||||
function mergeHook(parentVal, childVal) {
|
||||
const res = childVal
|
||||
? parentVal
|
||||
? parentVal.concat(childVal)
|
||||
: isArray(childVal)
|
||||
? childVal
|
||||
: [childVal]
|
||||
: parentVal;
|
||||
return res ? dedupeHooks(res) : res;
|
||||
}
|
||||
function dedupeHooks(hooks) {
|
||||
const res = [];
|
||||
for (let i = 0; i < hooks.length; i++) {
|
||||
if (res.indexOf(hooks[i]) === -1) {
|
||||
res.push(hooks[i]);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
const addInterceptor = defineSyncApi(API_ADD_INTERCEPTOR, (method, interceptor) => {
|
||||
if (isString(method) && isPlainObject(interceptor)) {
|
||||
mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor);
|
||||
}
|
||||
else if (isPlainObject(method)) {
|
||||
mergeInterceptorHook(globalInterceptors, method);
|
||||
}
|
||||
}, AddInterceptorProtocol);
|
||||
const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interceptor) => {
|
||||
if (isString(method)) {
|
||||
if (isPlainObject(interceptor)) {
|
||||
removeInterceptorHook(scopedInterceptors[method], interceptor);
|
||||
}
|
||||
else {
|
||||
delete scopedInterceptors[method];
|
||||
}
|
||||
}
|
||||
else if (isPlainObject(method)) {
|
||||
removeInterceptorHook(globalInterceptors, method);
|
||||
}
|
||||
}, RemoveInterceptorProtocol);
|
||||
|
||||
export { addInterceptor, defineAsyncApi, defineOffApi, defineOnApi, defineSyncApi, defineTaskApi, removeInterceptor };
|
||||
+557
@@ -0,0 +1,557 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var appVite = require('@dcloudio/uni-app-vite');
|
||||
var uniAppUts = require('@dcloudio/uni-app-uts');
|
||||
var path = require('path');
|
||||
var uniCliShared = require('@dcloudio/uni-cli-shared');
|
||||
|
||||
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
||||
|
||||
var appVite__default = /*#__PURE__*/_interopDefault(appVite);
|
||||
var path__default = /*#__PURE__*/_interopDefault(path);
|
||||
|
||||
var ExternalModuls = [
|
||||
{
|
||||
type: "extapi",
|
||||
plugin: "uni-facialVerify",
|
||||
apis: [
|
||||
"startFacialRecognitionVerify",
|
||||
"getFacialRecognitionMetaInfo"
|
||||
],
|
||||
version: "1.0.2"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-getLocation-system",
|
||||
provider: "system",
|
||||
service: "location",
|
||||
version: "1.0.0"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-oauth-huawei",
|
||||
provider: "huawei",
|
||||
service: "oauth",
|
||||
version: "1.0.2"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-payment-alipay",
|
||||
provider: "alipay",
|
||||
service: "payment",
|
||||
version: "1.0.2"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-payment-huawei",
|
||||
provider: "huawei",
|
||||
service: "payment",
|
||||
version: "1.0.0"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-payment-wxpay",
|
||||
provider: "wxpay",
|
||||
service: "payment",
|
||||
version: "1.0.0"
|
||||
},
|
||||
{
|
||||
type: "extapi",
|
||||
plugin: "uni-push",
|
||||
apis: [
|
||||
"getPushClientId",
|
||||
"onPushMessage",
|
||||
"offPushMessage",
|
||||
"createPushMessage",
|
||||
"setAppBadgeNumber"
|
||||
],
|
||||
version: "1.0.2"
|
||||
}
|
||||
];
|
||||
|
||||
var ExternalModulesX = [
|
||||
{
|
||||
type: "extapi",
|
||||
plugin: "uni-facialVerify",
|
||||
apis: [
|
||||
"startFacialRecognitionVerify",
|
||||
"getFacialRecognitionMetaInfo"
|
||||
],
|
||||
version: "1.0.2"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-getLocation-system",
|
||||
provider: "system",
|
||||
service: "location",
|
||||
version: "1.0.0"
|
||||
},
|
||||
{
|
||||
type: "extapi",
|
||||
plugin: "uni-map-tencent",
|
||||
apis: [
|
||||
"createMapContext"
|
||||
],
|
||||
version: "1.0.0"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-oauth-huawei",
|
||||
provider: "huawei",
|
||||
service: "oauth",
|
||||
version: "1.0.2"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-payment-alipay",
|
||||
provider: "alipay",
|
||||
service: "payment",
|
||||
version: "1.0.2"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-payment-huawei",
|
||||
provider: "huawei",
|
||||
service: "payment",
|
||||
version: "1.0.0"
|
||||
},
|
||||
{
|
||||
type: "provider",
|
||||
plugin: "uni-payment-wxpay",
|
||||
provider: "wxpay",
|
||||
service: "payment",
|
||||
version: "1.0.0"
|
||||
},
|
||||
{
|
||||
type: "extapi",
|
||||
plugin: "uni-push",
|
||||
apis: [
|
||||
"getPushClientId",
|
||||
"onPushMessage",
|
||||
"offPushMessage",
|
||||
"createPushMessage",
|
||||
"setAppBadgeNumber"
|
||||
],
|
||||
version: "1.0.2"
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* uni-app内部extapi发行到ohpm的uni_modules组织下的包列表
|
||||
* 注意此列表会同时被框架编译器和用户项目编译器引用
|
||||
*/
|
||||
// type ExternalModuleSubType = 'customElements' | 'components' | 'pages' | 'utssdk'
|
||||
// TODO 未来component类型的provider需要重构,比如uni-map-tencent需要依赖内置基础模块uni-map,先基于现状实现。
|
||||
const ComponentsWithProvider = [];
|
||||
const ComponentsWithProviderX = ['uni-map'];
|
||||
|
||||
const isX = process.env.UNI_APP_X === 'true';
|
||||
const StandaloneExtApis = isX ? ExternalModulesX : ExternalModuls;
|
||||
const Providers = StandaloneExtApis.filter((item) => item.type === 'provider');
|
||||
const ComponentWithProviderList = isX
|
||||
? ComponentsWithProviderX
|
||||
: ComponentsWithProvider;
|
||||
if (isX) {
|
||||
Providers.push({
|
||||
type: 'provider',
|
||||
plugin: 'uni-map',
|
||||
provider: 'tencent',
|
||||
service: 'map',
|
||||
version: '1.0.0',
|
||||
});
|
||||
}
|
||||
const ApiModules = StandaloneExtApis.filter((item) => item.type === 'extapi');
|
||||
const commandGlobals = {
|
||||
vue: 'Vue',
|
||||
'@vue/shared': 'uni.VueShared',
|
||||
};
|
||||
const harmonyGlobals = [
|
||||
/^@ohos\./,
|
||||
/^@kit\./,
|
||||
/^@hms\./,
|
||||
/^@arkts\./,
|
||||
/^@system\./,
|
||||
'@ohos/hypium',
|
||||
'@ohos/hamock',
|
||||
];
|
||||
function isHarmonyGlobal(id) {
|
||||
return harmonyGlobals.some((harmonyGlobal) => typeof harmonyGlobal === 'string'
|
||||
? harmonyGlobal === id
|
||||
: harmonyGlobal.test(id));
|
||||
}
|
||||
function generateHarmonyImportSpecifier(id) {
|
||||
return id.replace(/([@\/\.])/g, function (_, $1) {
|
||||
switch ($1) {
|
||||
case '.':
|
||||
return '_';
|
||||
case '/':
|
||||
return '__';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
});
|
||||
}
|
||||
function generateHarName(moduleName) {
|
||||
return moduleName.replace(/@/g, '').replace(/\//g, '__').replace(/-/g, '_');
|
||||
}
|
||||
function generateHarmonyImportExternalCode(harmonyPackageNames) {
|
||||
return harmonyPackageNames
|
||||
.filter((harmonyPackageName) => isHarmonyGlobal(harmonyPackageName))
|
||||
.map((harmonyPackageName) => `import ${generateHarmonyImportSpecifier(harmonyPackageName)} from '${harmonyPackageName}';`)
|
||||
.join('');
|
||||
}
|
||||
function uniAppHarmonyPlugin() {
|
||||
return {
|
||||
name: 'uni:app-harmony',
|
||||
apply: 'build',
|
||||
config() {
|
||||
return {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
external: [...Object.keys(commandGlobals), ...harmonyGlobals],
|
||||
output: {
|
||||
globals: function (id) {
|
||||
if (id.startsWith('@kit.')) {
|
||||
console.warn('@kit开头的包无法在页面或组件内正常使用,请改用其他方式引用,或使用uts插件引用。');
|
||||
}
|
||||
return (commandGlobals[id] ||
|
||||
(isHarmonyGlobal(id)
|
||||
? generateHarmonyImportSpecifier(id)
|
||||
: ''));
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
async generateBundle(_, bundle) {
|
||||
const utsExtApis = new Set();
|
||||
const utsPlugins = uniCliShared.getCurrentCompiledUTSPlugins();
|
||||
const utsProviders = uniCliShared.getCurrentCompiledUTSProviders();
|
||||
// utsPlugins.difference(utsProviders)
|
||||
utsPlugins.forEach((plugin) => {
|
||||
if (utsProviders.has(plugin)) {
|
||||
return;
|
||||
}
|
||||
utsExtApis.add(plugin);
|
||||
});
|
||||
if (uniCliShared.isNormalCompileTarget()) {
|
||||
// 此方法仅需要处理非provider
|
||||
genAppHarmonyUniModules(this, process.env.UNI_INPUT_DIR, utsExtApis);
|
||||
for (const key in bundle) {
|
||||
const serviceBundle = bundle[key];
|
||||
if (serviceBundle.code) {
|
||||
serviceBundle.code =
|
||||
generateHarmonyImportExternalCode(serviceBundle.imports) +
|
||||
serviceBundle.code;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
async writeBundle() {
|
||||
if (!uniCliShared.isNormalCompileTarget()) {
|
||||
return;
|
||||
}
|
||||
// 1.0 特有逻辑,x 上由其他插件完成
|
||||
if (process.env.UNI_APP_X !== 'true') {
|
||||
// x 上暂时编译所有uni ext api,不管代码里是否调用了
|
||||
await uniCliShared.buildUniExtApis();
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* TODO 微信支付上线时,务必提醒相关同事统一使用wxpay,不要用weixin
|
||||
*/
|
||||
function getProviders(module, allProviders) {
|
||||
return allProviders.filter((item) => item.plugin.startsWith(module + '-'));
|
||||
}
|
||||
const DefaultModule = {
|
||||
// 'uni-getLocation': {
|
||||
// system: {},
|
||||
// },
|
||||
};
|
||||
function getManifestModules(inputDir) {
|
||||
const manifest = uniCliShared.parseManifestJsonOnce(inputDir);
|
||||
const modules = manifest?.[isX ? 'app' : 'app-harmony']?.distribute?.modules;
|
||||
const realModules = {};
|
||||
for (const moduleName in modules) {
|
||||
if (DefaultModule[moduleName]) {
|
||||
realModules[moduleName] = Object.assign({}, DefaultModule[moduleName], modules[moduleName]);
|
||||
}
|
||||
else {
|
||||
realModules[moduleName] = modules[moduleName];
|
||||
}
|
||||
}
|
||||
return realModules;
|
||||
}
|
||||
/**
|
||||
* 获取manifest.json中勾选的provider
|
||||
* 仅处理payment等参数内包含provider的api,地图模块不在此处理
|
||||
*/
|
||||
function getRelatedProviders(inputDir, allProviders) {
|
||||
const relatedProviders = [];
|
||||
const manifestModules = getManifestModules(inputDir);
|
||||
if (!manifestModules) {
|
||||
return relatedProviders;
|
||||
}
|
||||
for (const uniModule in manifestModules) {
|
||||
const providers = getProviders(uniModule, allProviders);
|
||||
if (!providers.length) {
|
||||
continue;
|
||||
}
|
||||
const manifestModule = manifestModules[uniModule];
|
||||
for (const name in manifestModule) {
|
||||
const providerConf = manifestModule[name];
|
||||
if (!providerConf) {
|
||||
continue;
|
||||
}
|
||||
if (!isHarmonyOSProvider(providerConf)) {
|
||||
continue;
|
||||
}
|
||||
const plugin = uniModule + '-' + name;
|
||||
const provider = providers.find((item) => item.plugin === plugin);
|
||||
if (!provider) {
|
||||
continue;
|
||||
}
|
||||
relatedProviders.push({
|
||||
service: provider.service,
|
||||
name,
|
||||
plugin: uniModule + '-' + name,
|
||||
});
|
||||
}
|
||||
}
|
||||
return relatedProviders;
|
||||
}
|
||||
function isHarmonyOSProvider(providerConf) {
|
||||
return (!providerConf.__platform__ ||
|
||||
!Array.isArray(providerConf.__platform__) ||
|
||||
providerConf.__platform__.includes('harmonyos'));
|
||||
}
|
||||
const ModuleAlias = {
|
||||
'uni-facialRecognitionVerify': 'uni-facialVerify',
|
||||
};
|
||||
// 获取uni_modules中的相关模块
|
||||
function getRelatedModules(inputDir) {
|
||||
const modules = [];
|
||||
const manifestModules = getManifestModules(inputDir);
|
||||
if (!manifestModules) {
|
||||
return modules;
|
||||
}
|
||||
for (let manifestModuleName in manifestModules) {
|
||||
if (ComponentWithProviderList.includes(manifestModuleName)) {
|
||||
const manifestModuleInfo = manifestModules[manifestModuleName];
|
||||
for (const provider in manifestModuleInfo) {
|
||||
const manifestPlugin = manifestModuleName + '-' + provider;
|
||||
const providerConf = manifestModuleInfo[provider];
|
||||
if (!isHarmonyOSProvider(providerConf)) {
|
||||
continue;
|
||||
}
|
||||
const apiModule = ApiModules.find((item) => item.plugin === manifestPlugin);
|
||||
if (apiModule) {
|
||||
modules.push(manifestPlugin);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ModuleAlias[manifestModuleName]) {
|
||||
manifestModuleName = ModuleAlias[manifestModuleName];
|
||||
}
|
||||
const apiModule = ApiModules.find((item) => item.plugin === manifestModuleName);
|
||||
if (!apiModule) {
|
||||
continue;
|
||||
}
|
||||
modules.push(manifestModuleName);
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
function genAppHarmonyUniModules(context, inputDir, utsPlugins) {
|
||||
const uniModulesDir = path__default.default.resolve(inputDir, 'uni_modules');
|
||||
const importCodes = [];
|
||||
const extApiCodes = [];
|
||||
const registerCodes = [];
|
||||
const projectDeps = [];
|
||||
Array.from(utsPlugins)
|
||||
.sort()
|
||||
.forEach((plugin) => {
|
||||
const injects = uniCliShared.parseUniExtApi(path__default.default.resolve(uniModulesDir, plugin), plugin, true, 'app-harmony', 'arkts');
|
||||
const harmonyPackageName = `@uni_modules/${plugin.toLowerCase()}`;
|
||||
if (injects) {
|
||||
Object.keys(injects).forEach((key) => {
|
||||
const inject = injects[key];
|
||||
if (Array.isArray(inject) && inject.length > 1) {
|
||||
const apiName = inject[1];
|
||||
importCodes.push(`import { ${inject[1]} } from '${harmonyPackageName}'`);
|
||||
extApiCodes.push(`uni.${apiName} = ${apiName}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
const ident = uniCliShared.camelize(plugin);
|
||||
importCodes.push(`import * as ${ident} from '${harmonyPackageName}'`);
|
||||
registerCodes.push(`uni.registerUTSPlugin('uni_modules/${plugin}', ${ident})`);
|
||||
projectDeps.push({
|
||||
moduleSpecifier: harmonyPackageName,
|
||||
plugin,
|
||||
source: 'local',
|
||||
});
|
||||
});
|
||||
const relatedModules = getRelatedModules(inputDir);
|
||||
relatedModules.sort().forEach((module) => {
|
||||
const harmonyModuleName = `@uni_modules/${module.toLowerCase()}`;
|
||||
if (utsPlugins.has(module)) ;
|
||||
else {
|
||||
const matchedStandaloneExtApi = StandaloneExtApis.find((item) => item.plugin === module);
|
||||
if (matchedStandaloneExtApi) {
|
||||
projectDeps.push({
|
||||
moduleSpecifier: harmonyModuleName,
|
||||
plugin: module,
|
||||
source: 'ohpm',
|
||||
version: '*',
|
||||
});
|
||||
matchedStandaloneExtApi.apis?.forEach((apiName) => {
|
||||
importCodes.push(`import { ${apiName} } from '${harmonyModuleName}'`);
|
||||
extApiCodes.push(`uni.${apiName} = ${apiName}`);
|
||||
});
|
||||
if (module.startsWith('uni-map-')) {
|
||||
// TODO 临时处理,后续需要内置基础uni-map模块并优化此问题
|
||||
importCodes.push(`import { UniMapElement } from '${harmonyModuleName}'`);
|
||||
extApiCodes.push(`globalThis.UniMapElement = UniMapElement`);
|
||||
const ident = uniCliShared.camelize(module);
|
||||
importCodes.push(`import * as ${ident} from '${harmonyModuleName}'`);
|
||||
registerCodes.push(`uni.registerUTSPlugin('uni_modules/${module}', ${ident})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
const importProviderCodes = [];
|
||||
const registerProviderCodes = [];
|
||||
const providers = uniCliShared.getUniExtApiProviderRegisters();
|
||||
const allProviders = providers.map((provider) => {
|
||||
return {
|
||||
service: provider.service,
|
||||
name: provider.name,
|
||||
moduleSpecifier: `@uni_modules/${provider.plugin.toLowerCase()}`,
|
||||
plugin: provider.plugin,
|
||||
source: 'local',
|
||||
version: undefined,
|
||||
};
|
||||
});
|
||||
Providers.forEach((provider) => {
|
||||
if (allProviders.find((item) => item.plugin === provider.plugin)) {
|
||||
return;
|
||||
}
|
||||
allProviders.push({
|
||||
service: provider.service,
|
||||
name: provider.provider,
|
||||
moduleSpecifier: `@uni_modules/${provider.plugin.toLowerCase()}`,
|
||||
plugin: provider.plugin,
|
||||
source: 'ohpm',
|
||||
version: '*',
|
||||
});
|
||||
});
|
||||
const relatedProviders = getRelatedProviders(inputDir, allProviders);
|
||||
relatedProviders.sort().forEach((relatedProvider) => {
|
||||
const provider = allProviders.find((item) => item.service === relatedProvider.service &&
|
||||
item.name === relatedProvider.name);
|
||||
if (!provider) {
|
||||
return;
|
||||
}
|
||||
projectDeps.push({
|
||||
moduleSpecifier: provider.moduleSpecifier,
|
||||
plugin: provider.plugin,
|
||||
source: provider.source,
|
||||
version: provider.version,
|
||||
});
|
||||
const className = uniCliShared.formatExtApiProviderName(provider.service, provider.name);
|
||||
importProviderCodes.push(`import { ${className} } from '${provider.moduleSpecifier}'`);
|
||||
registerProviderCodes.push(`registerUniProvider('${provider.service}', '${provider.name}', new ${className}())`);
|
||||
});
|
||||
if (importProviderCodes.length) {
|
||||
importCodes.push(...importProviderCodes);
|
||||
extApiCodes.push(...registerProviderCodes);
|
||||
}
|
||||
const pluginCustomElements = uniCliShared.getUTSPluginCustomElements();
|
||||
Object.keys(pluginCustomElements)
|
||||
.sort()
|
||||
.forEach((pluginId) => {
|
||||
if (!utsPlugins.has(pluginId)) {
|
||||
// 可能没使用,没编译
|
||||
return;
|
||||
}
|
||||
const elements = [...pluginCustomElements[pluginId]];
|
||||
if (elements.length) {
|
||||
importCodes.push(`import { ${elements
|
||||
.map((name) => uniCliShared.capitalize(uniCliShared.camelize(name)) + 'Element')
|
||||
.join(', ')} } from '@uni_modules/${pluginId.toLowerCase()}'`);
|
||||
elements.forEach((element) => {
|
||||
registerCodes.push(`customElements.define('${element.replace('uni-', '')}', ${uniCliShared.capitalize(uniCliShared.camelize(element)) + 'Element'})`);
|
||||
});
|
||||
}
|
||||
});
|
||||
const importIds = [];
|
||||
if (relatedProviders.length) {
|
||||
importIds.push('registerUniProvider');
|
||||
}
|
||||
if (Object.keys(pluginCustomElements).length) {
|
||||
importIds.push('customElements');
|
||||
}
|
||||
importIds.push('uni');
|
||||
importCodes.unshift(`import { ${importIds.join(', ')} } from '${process.env.UNI_APP_X !== 'true'
|
||||
? '@dcloudio/uni-app-runtime'
|
||||
: '@dcloudio/uni-app-x-runtime'}'`);
|
||||
context.emitFile({
|
||||
type: 'asset',
|
||||
fileName: 'uni_modules/index.generated.ets',
|
||||
source: `// This file is automatically generated by uni-app.
|
||||
// Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
${importCodes.join('\n')}
|
||||
|
||||
export function initUniModules() {
|
||||
initUniExtApi()
|
||||
${registerCodes.join('\n ')}
|
||||
}
|
||||
|
||||
function initUniExtApi() {
|
||||
${extApiCodes.join('\n ')}
|
||||
}
|
||||
`,
|
||||
});
|
||||
const dependencies = {};
|
||||
const modules = [];
|
||||
projectDeps.forEach((dep) => {
|
||||
if (dep.source === 'local') {
|
||||
const depPath = './uni_modules/' + dep.plugin;
|
||||
dependencies[dep.moduleSpecifier] = depPath;
|
||||
modules.push({
|
||||
name: generateHarName(dep.moduleSpecifier),
|
||||
srcPath: depPath,
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (!dependencies[dep.moduleSpecifier]) {
|
||||
dependencies[dep.moduleSpecifier] = `./libs/${generateHarName(dep.moduleSpecifier)}.har`;
|
||||
}
|
||||
}
|
||||
});
|
||||
context.emitFile({
|
||||
type: 'asset',
|
||||
fileName: 'uni_modules/oh-package.json5',
|
||||
source: JSON.stringify({ dependencies }, null, 2),
|
||||
});
|
||||
context.emitFile({
|
||||
type: 'asset',
|
||||
fileName: 'uni_modules/build-profile.json5',
|
||||
source: JSON.stringify({ modules }, null, 2),
|
||||
});
|
||||
}
|
||||
|
||||
const externalModulesX = ExternalModulesX;
|
||||
var index = [
|
||||
process.env.UNI_APP_X === 'true' ? uniAppUts.initUniAppXHarmonyPlugin : appVite__default.default,
|
||||
uniAppHarmonyPlugin,
|
||||
];
|
||||
|
||||
exports.default = index;
|
||||
exports.externalModulesX = externalModulesX;
|
||||
+13769
File diff suppressed because it is too large
Load Diff
+15
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
[https://dcloud.io/license/uni-app.html](https://dcloud.io/license/uni-app.html)
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "@dcloudio/uni-app-harmony",
|
||||
"version": "3.0.0-4060620250520001",
|
||||
"description": "@dcloudio/uni-app-harmony",
|
||||
"files": [
|
||||
"dist",
|
||||
"lib"
|
||||
],
|
||||
"sideEffects": [
|
||||
"lib/automator.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/dcloudio/uni-app.git",
|
||||
"directory": "packages/uni-app-harmony"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/dcloudio/uni-app/issues"
|
||||
},
|
||||
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
||||
"uni-app": {
|
||||
"name": "uni-app-harmony",
|
||||
"apply": [
|
||||
"app-harmony"
|
||||
],
|
||||
"main": "dist/uni.compiler.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.3.3",
|
||||
"fs-extra": "^10.0.0",
|
||||
"licia": "^1.29.0",
|
||||
"postcss-selector-parser": "^6.0.6",
|
||||
"@dcloudio/uni-app-uts": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-app-vite": "3.0.0-4060620250520001"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/pako": "1.0.2",
|
||||
"@types/google.maps": "^3.45.6",
|
||||
"@amap/amap-jsapi-types": "^0.0.8",
|
||||
"@vue/compiler-sfc": "3.4.21",
|
||||
"autoprefixer": "^10.4.18",
|
||||
"pako": "^1.0.11",
|
||||
"postcss": "^8.4.21",
|
||||
"vue": "3.4.21",
|
||||
"@dcloudio/uni-cli-shared": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-app-plus": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-components": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-i18n": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-shared": "3.0.0-4060620250520001"
|
||||
}
|
||||
}
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
# @dcloudio/uni-app-plus
|
||||
|
||||
uni-app 处理 App。
|
||||
|
||||
包含 `uni-app-x` 内置 api/components 等逻辑
|
||||
|
||||
## 项目结构
|
||||
|
||||
本身是一个 vite 项目,存在 `vite.config.ts` 和 `x.vite.config.ts` 两个配置文件。
|
||||
|
||||
### 处理 `uni-app-x`
|
||||
|
||||
通过 `node scripts/build.js uni-app-plus` 运行编译时候,会通过 `vite build --config x.vite.config.ts`
|
||||
|
||||
最终得到 `dist/uni.x.runtime.esm.js`,后续其他项目会依赖产物进一步处理。
|
||||
|
||||
## 参与贡献
|
||||
|
||||
### uni-app-x
|
||||
|
||||
如果你想参与到 `uni-app-x` 的贡献中,你可以着重了解 `src/x` 目录。
|
||||
+1
File diff suppressed because one or more lines are too long
+178
@@ -0,0 +1,178 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Tools = {}));
|
||||
})(this, (function (exports) { 'use strict';
|
||||
|
||||
/**
|
||||
* @vue/shared v3.4.21
|
||||
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
||||
* @license MIT
|
||||
**/
|
||||
|
||||
!!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
|
||||
!!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
||||
|
||||
const ACTION_TYPE_PAGE_CREATE = 1;
|
||||
const ACTION_TYPE_PAGE_CREATED = 2;
|
||||
const ACTION_TYPE_CREATE = 3;
|
||||
const ACTION_TYPE_INSERT = 4;
|
||||
const ACTION_TYPE_REMOVE = 5;
|
||||
const ACTION_TYPE_SET_ATTRIBUTE = 6;
|
||||
const ACTION_TYPE_REMOVE_ATTRIBUTE = 7;
|
||||
const ACTION_TYPE_ADD_EVENT = 8;
|
||||
const ACTION_TYPE_REMOVE_EVENT = 9;
|
||||
const ACTION_TYPE_SET_TEXT = 10;
|
||||
const ACTION_TYPE_ADD_WXS_EVENT = 12;
|
||||
|
||||
const ACTION_TYPE_DICT = 0;
|
||||
|
||||
function createGetDict(dict) {
|
||||
if (!dict.length) {
|
||||
return (v) => v;
|
||||
}
|
||||
const getDict = (value, includeValue = true) => {
|
||||
if (typeof value === 'number') {
|
||||
return dict[value];
|
||||
}
|
||||
const res = {};
|
||||
value.forEach(([n, v]) => {
|
||||
if (includeValue) {
|
||||
res[getDict(n)] = getDict(v);
|
||||
}
|
||||
else {
|
||||
res[getDict(n)] = v;
|
||||
}
|
||||
});
|
||||
return res;
|
||||
};
|
||||
return getDict;
|
||||
}
|
||||
function decodeActions(actions) {
|
||||
const [type, dict] = actions[0];
|
||||
if (type !== ACTION_TYPE_DICT) {
|
||||
return actions;
|
||||
}
|
||||
const getDict = createGetDict(dict);
|
||||
return actions.map((action) => {
|
||||
switch (action[0]) {
|
||||
case ACTION_TYPE_DICT:
|
||||
return action;
|
||||
case ACTION_TYPE_PAGE_CREATE:
|
||||
return decodePageCreateAction(action);
|
||||
case ACTION_TYPE_PAGE_CREATED:
|
||||
return decodePageCreatedAction(action);
|
||||
case ACTION_TYPE_CREATE:
|
||||
return decodeCreateAction(action, getDict);
|
||||
case ACTION_TYPE_INSERT:
|
||||
return decodeInsertAction(action, getDict);
|
||||
case ACTION_TYPE_REMOVE:
|
||||
return decodeRemoveAction(action);
|
||||
case ACTION_TYPE_SET_ATTRIBUTE:
|
||||
return decodeSetAttributeAction(action, getDict);
|
||||
case ACTION_TYPE_REMOVE_ATTRIBUTE:
|
||||
return decodeRemoveAttributeAction(action, getDict);
|
||||
case ACTION_TYPE_ADD_EVENT:
|
||||
return decodeAddEventAction(action, getDict);
|
||||
case ACTION_TYPE_ADD_WXS_EVENT:
|
||||
return decodeAddWxsEventAction(action, getDict);
|
||||
case ACTION_TYPE_REMOVE_EVENT:
|
||||
return decodeRemoveEventAction(action, getDict);
|
||||
case ACTION_TYPE_SET_TEXT:
|
||||
return decodeSetTextAction(action, getDict);
|
||||
}
|
||||
});
|
||||
}
|
||||
function decodePageCreateAction([, pageCreateData]) {
|
||||
return ['pageCreate', pageCreateData];
|
||||
}
|
||||
function decodePageCreatedAction([]) {
|
||||
return ['pageCreated'];
|
||||
}
|
||||
function decodeNodeJson(getDict, nodeJson) {
|
||||
if (!nodeJson) {
|
||||
return;
|
||||
}
|
||||
if (hasOwn(nodeJson, 'a')) {
|
||||
nodeJson.a = getDict(nodeJson.a);
|
||||
}
|
||||
if (hasOwn(nodeJson, 'e')) {
|
||||
nodeJson.e = getDict(nodeJson.e, false);
|
||||
}
|
||||
if (hasOwn(nodeJson, 'w')) {
|
||||
nodeJson.w = getWxsEventDict(nodeJson.w, getDict);
|
||||
}
|
||||
if (hasOwn(nodeJson, 's')) {
|
||||
nodeJson.s = getDict(nodeJson.s);
|
||||
}
|
||||
if (hasOwn(nodeJson, 't')) {
|
||||
nodeJson.t = getDict(nodeJson.t);
|
||||
}
|
||||
return nodeJson;
|
||||
}
|
||||
function getWxsEventDict(w, getDict) {
|
||||
const res = {};
|
||||
w.forEach(([name, [wxsEvent, flag]]) => {
|
||||
res[getDict(name)] = [getDict(wxsEvent), flag];
|
||||
});
|
||||
return res;
|
||||
}
|
||||
function decodeCreateAction([, nodeId, nodeName, parentNodeId, refNodeId, nodeJson], getDict) {
|
||||
return [
|
||||
'create',
|
||||
nodeId,
|
||||
getDict(nodeName),
|
||||
parentNodeId,
|
||||
refNodeId,
|
||||
decodeNodeJson(getDict, nodeJson),
|
||||
];
|
||||
}
|
||||
function decodeInsertAction([, ...action], getDict) {
|
||||
return [
|
||||
'insert',
|
||||
action[0],
|
||||
action[1],
|
||||
action[2],
|
||||
action[3] ? decodeNodeJson(getDict, action[3]) : {},
|
||||
];
|
||||
}
|
||||
function decodeRemoveAction([, ...action]) {
|
||||
return ['remove', ...action];
|
||||
}
|
||||
function decodeAddEventAction([, ...action], getDict) {
|
||||
return ['addEvent', action[0], getDict(action[1]), action[2]];
|
||||
}
|
||||
function decodeAddWxsEventAction([, ...action], getDict) {
|
||||
return [
|
||||
'addWxsEvent',
|
||||
action[0],
|
||||
getDict(action[1]),
|
||||
getDict(action[2]),
|
||||
action[3],
|
||||
];
|
||||
}
|
||||
function decodeRemoveEventAction([, ...action], getDict) {
|
||||
return ['removeEvent', action[0], getDict(action[1])];
|
||||
}
|
||||
function decodeSetAttributeAction([, ...action], getDict) {
|
||||
return [
|
||||
'setAttr',
|
||||
action[0],
|
||||
getDict(action[1]),
|
||||
getDict(action[2]),
|
||||
];
|
||||
}
|
||||
function decodeRemoveAttributeAction([, ...action], getDict) {
|
||||
return ['removeAttr', action[0], getDict(action[1])];
|
||||
}
|
||||
function decodeSetTextAction([, ...action], getDict) {
|
||||
return ['setText', action[0], getDict(action[1])];
|
||||
}
|
||||
|
||||
exports.createGetDict = createGetDict;
|
||||
exports.decodeActions = decodeActions;
|
||||
exports.decodeNodeJson = decodeNodeJson;
|
||||
|
||||
}));
|
||||
+7
File diff suppressed because one or more lines are too long
+13
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
var appVite = require('@dcloudio/uni-app-vite');
|
||||
var appUVue = require('@dcloudio/uni-app-uts');
|
||||
|
||||
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
||||
|
||||
var appVite__default = /*#__PURE__*/_interopDefault(appVite);
|
||||
var appUVue__default = /*#__PURE__*/_interopDefault(appUVue);
|
||||
|
||||
var index = [process.env.UNI_APP_X === 'true' ? appUVue__default.default : appVite__default.default];
|
||||
|
||||
module.exports = index;
|
||||
+21291
File diff suppressed because it is too large
Load Diff
+311
@@ -0,0 +1,311 @@
|
||||
import { invokeArrayFns, isUniLifecycleHook, decodedQuery, ON_LOAD, ON_SHOW, LINEFEED, RENDERJS_MODULES, formatLog, WXS_PROTOCOL, WXS_MODULES, ON_ERROR, UniLifecycleHooks, invokeCreateErrorHandler, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
|
||||
import { isString, isArray, hasOwn, isFunction } from '@vue/shared';
|
||||
import { injectHook, logError } from 'vue';
|
||||
|
||||
function get$pageByPage(page) {
|
||||
return page.$page;
|
||||
}
|
||||
|
||||
function getCurrentPage() {
|
||||
const pages = getCurrentPages();
|
||||
const len = pages.length;
|
||||
if (len) {
|
||||
return pages[len - 1];
|
||||
}
|
||||
}
|
||||
function getCurrentPageVm() {
|
||||
const page = getCurrentPage();
|
||||
if (page) {
|
||||
return page.$vm;
|
||||
}
|
||||
}
|
||||
|
||||
function invokeHook(vm, name, args) {
|
||||
if (isString(vm)) {
|
||||
args = name;
|
||||
name = vm;
|
||||
vm = getCurrentPageVm();
|
||||
}
|
||||
else if (typeof vm === 'number') {
|
||||
const page = getCurrentPages().find((page) => get$pageByPage(page).id === vm);
|
||||
if (page) {
|
||||
vm = page.$vm;
|
||||
}
|
||||
else {
|
||||
vm = getCurrentPageVm();
|
||||
}
|
||||
}
|
||||
if (!vm) {
|
||||
return;
|
||||
}
|
||||
// 兼容 nvue
|
||||
{
|
||||
if (vm.__call_hook) {
|
||||
return vm.__call_hook(name, args);
|
||||
}
|
||||
}
|
||||
const hooks = vm.$[name];
|
||||
return hooks && invokeArrayFns(hooks, args);
|
||||
}
|
||||
|
||||
function injectLifecycleHook(name, hook, publicThis, instance) {
|
||||
if (isFunction(hook)) {
|
||||
injectHook(name, hook.bind(publicThis), instance);
|
||||
}
|
||||
}
|
||||
function initHooks(options, instance, publicThis) {
|
||||
const mpType = options.mpType || publicThis.$mpType;
|
||||
if (!mpType || mpType === 'component') {
|
||||
// 仅 App,Page 类型支持在 options 中配置 on 生命周期,组件可以使用组合式 API 定义页面生命周期
|
||||
return;
|
||||
}
|
||||
Object.keys(options).forEach((name) => {
|
||||
if (isUniLifecycleHook(name, options[name], false)) {
|
||||
const hooks = options[name];
|
||||
if (isArray(hooks)) {
|
||||
hooks.forEach((hook) => injectLifecycleHook(name, hook, publicThis, instance));
|
||||
}
|
||||
else {
|
||||
injectLifecycleHook(name, hooks, publicThis, instance);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (mpType === 'page') {
|
||||
instance.__isVisible = true;
|
||||
// 直接触发页面 onLoad、onShow 组件内的 onLoad 和 onShow 在注册时,直接触发一次
|
||||
try {
|
||||
let query = instance.attrs.__pageQuery;
|
||||
// onLoad 的 query 进行 decode
|
||||
if (false) ;
|
||||
if ('app' === 'app' && false) ;
|
||||
invokeHook(publicThis, ON_LOAD, query);
|
||||
delete instance.attrs.__pageQuery;
|
||||
// iOS-X 的非 Tab 页面与 uni-app 一致固定触发 onShow
|
||||
const $basePage = false
|
||||
? publicThis.$basePage
|
||||
: publicThis.$page;
|
||||
if (!('app' === 'app' && false && ($basePage === null || $basePage === void 0 ? void 0 : $basePage.meta.isTabBar))) {
|
||||
if (($basePage === null || $basePage === void 0 ? void 0 : $basePage.openType) !== 'preloadPage') {
|
||||
invokeHook(publicThis, ON_SHOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e.message + LINEFEED + e.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initRenderjs(options, instance) {
|
||||
initModules(instance, options.$renderjs, options['$' + RENDERJS_MODULES]);
|
||||
}
|
||||
function initModules(instance, modules, moduleIds = {}) {
|
||||
if (!isArray(modules)) {
|
||||
return;
|
||||
}
|
||||
const ownerId = instance.uid;
|
||||
// 在vue的定制内核中,通过$wxsModules来判断事件函数源码中是否包含该模块调用
|
||||
// !$wxsModules.find(module => invokerSourceCode.indexOf('.' + module + '.') > -1)
|
||||
const $wxsModules = (instance.$wxsModules ||
|
||||
(instance.$wxsModules = []));
|
||||
const ctx = instance.ctx;
|
||||
modules.forEach((module) => {
|
||||
if (moduleIds[module]) {
|
||||
ctx[module] = proxyModule(ownerId, moduleIds[module], module);
|
||||
$wxsModules.push(module);
|
||||
}
|
||||
else {
|
||||
if ((process.env.NODE_ENV !== 'production')) {
|
||||
console.error(formatLog('initModules', modules, moduleIds));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function proxyModule(ownerId, moduleId, module) {
|
||||
const target = {};
|
||||
return new Proxy(target, {
|
||||
get(_, p) {
|
||||
return (target[p] ||
|
||||
(target[p] = createModuleFunction(ownerId, moduleId, module, p)));
|
||||
},
|
||||
});
|
||||
}
|
||||
function createModuleFunction(ownerId, moduleId, module, name) {
|
||||
const target = () => { };
|
||||
const toJSON = () => WXS_PROTOCOL + JSON.stringify([ownerId, moduleId, module + '.' + name]);
|
||||
return new Proxy(target, {
|
||||
get(_, p) {
|
||||
if (p === 'toJSON') {
|
||||
return toJSON;
|
||||
}
|
||||
return (target[p] ||
|
||||
(target[p] = createModuleFunction(ownerId, moduleId, module + '.' + name, p)));
|
||||
},
|
||||
apply(_target, _thisArg, args) {
|
||||
return (WXS_PROTOCOL +
|
||||
JSON.stringify([ownerId, moduleId, module + '.' + name, [...args]]));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function initWxs(options, instance) {
|
||||
initModules(instance, options.$wxs, options['$' + WXS_MODULES]);
|
||||
}
|
||||
|
||||
function applyOptions(options, instance, publicThis) {
|
||||
{
|
||||
initWxs(options, instance);
|
||||
initRenderjs(options, instance);
|
||||
}
|
||||
initHooks(options, instance, publicThis);
|
||||
}
|
||||
|
||||
function set(target, key, val) {
|
||||
return (target[key] = val);
|
||||
}
|
||||
function $callMethod(method, ...args) {
|
||||
const fn = this[method];
|
||||
if (fn) {
|
||||
return fn(...args);
|
||||
}
|
||||
console.error(`method ${method} not found`);
|
||||
return null;
|
||||
}
|
||||
|
||||
function createErrorHandler(app) {
|
||||
const userErrorHandler = app.config.errorHandler;
|
||||
return function errorHandler(err, instance, info) {
|
||||
if (userErrorHandler) {
|
||||
userErrorHandler(err, instance, info);
|
||||
}
|
||||
const appInstance = app._instance;
|
||||
if (!appInstance || !appInstance.proxy) {
|
||||
throw err;
|
||||
}
|
||||
if (appInstance[ON_ERROR]) {
|
||||
{
|
||||
invokeHook(appInstance.proxy, ON_ERROR, err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logError(err, info, instance ? instance.$.vnode : null, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
function mergeAsArray(to, from) {
|
||||
return to ? [...new Set([].concat(to, from))] : from;
|
||||
}
|
||||
function initOptionMergeStrategies(optionMergeStrategies) {
|
||||
UniLifecycleHooks.forEach((name) => {
|
||||
optionMergeStrategies[name] = mergeAsArray;
|
||||
});
|
||||
}
|
||||
|
||||
let realAtob;
|
||||
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
|
||||
if (typeof atob !== 'function') {
|
||||
realAtob = function (str) {
|
||||
str = String(str).replace(/[\t\n\f\r ]+/g, '');
|
||||
if (!b64re.test(str)) {
|
||||
throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
|
||||
}
|
||||
// Adding the padding if missing, for semplicity
|
||||
str += '=='.slice(2 - (str.length & 3));
|
||||
var bitmap;
|
||||
var result = '';
|
||||
var r1;
|
||||
var r2;
|
||||
var i = 0;
|
||||
for (; i < str.length;) {
|
||||
bitmap =
|
||||
(b64.indexOf(str.charAt(i++)) << 18) |
|
||||
(b64.indexOf(str.charAt(i++)) << 12) |
|
||||
((r1 = b64.indexOf(str.charAt(i++))) << 6) |
|
||||
(r2 = b64.indexOf(str.charAt(i++)));
|
||||
result +=
|
||||
r1 === 64
|
||||
? String.fromCharCode((bitmap >> 16) & 255)
|
||||
: r2 === 64
|
||||
? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
|
||||
: String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
else {
|
||||
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
|
||||
realAtob = atob;
|
||||
}
|
||||
function b64DecodeUnicode(str) {
|
||||
return decodeURIComponent(realAtob(str)
|
||||
.split('')
|
||||
.map(function (c) {
|
||||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
||||
})
|
||||
.join(''));
|
||||
}
|
||||
function getCurrentUserInfo() {
|
||||
const token = uni.getStorageSync('uni_id_token') || '';
|
||||
const tokenArr = token.split('.');
|
||||
if (!token || tokenArr.length !== 3) {
|
||||
return {
|
||||
uid: null,
|
||||
role: [],
|
||||
permission: [],
|
||||
tokenExpired: 0,
|
||||
};
|
||||
}
|
||||
let userInfo;
|
||||
try {
|
||||
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message);
|
||||
}
|
||||
userInfo.tokenExpired = userInfo.exp * 1000;
|
||||
delete userInfo.exp;
|
||||
delete userInfo.iat;
|
||||
return userInfo;
|
||||
}
|
||||
function uniIdMixin(globalProperties) {
|
||||
globalProperties.uniIDHasRole = function (roleId) {
|
||||
const { role } = getCurrentUserInfo();
|
||||
return role.indexOf(roleId) > -1;
|
||||
};
|
||||
globalProperties.uniIDHasPermission = function (permissionId) {
|
||||
const { permission } = getCurrentUserInfo();
|
||||
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1;
|
||||
};
|
||||
globalProperties.uniIDTokenValid = function () {
|
||||
const { tokenExpired } = getCurrentUserInfo();
|
||||
return tokenExpired > Date.now();
|
||||
};
|
||||
}
|
||||
|
||||
function initApp(app) {
|
||||
const appConfig = app.config;
|
||||
// 该逻辑全平台会调用
|
||||
// - 需要兼容支持开发者自定义的 errorHandler
|
||||
// - nvue、vue 需要使用同一个(once) errorHandler
|
||||
// - 需要支持 uni.onError 注册监听
|
||||
// * 目前仅部分小程序平台支持,调用uni.onError时,如果app已存在,则添加到instance的hooks中,如果不存在,则临时存储,初始化instance时添加到hooks中
|
||||
// * 目前在 errorHandler 中,会调用 app.$callHook(ON_ERROR, err),所以上一步需要将 uni.onError 存储到 app 的 hooks 中
|
||||
// - 部分平台(目前主要是小程序)开发阶段 uni-console 会调用 uni.onError 注册监听
|
||||
appConfig.errorHandler = invokeCreateErrorHandler(app, createErrorHandler);
|
||||
initOptionMergeStrategies(appConfig.optionMergeStrategies);
|
||||
const globalProperties = appConfig.globalProperties;
|
||||
{
|
||||
uniIdMixin(globalProperties);
|
||||
}
|
||||
{
|
||||
globalProperties.$set = set;
|
||||
globalProperties.$applyOptions = applyOptions;
|
||||
globalProperties.$callMethod = $callMethod;
|
||||
}
|
||||
{
|
||||
invokeCreateVueAppHook(app);
|
||||
}
|
||||
}
|
||||
|
||||
export { initApp };
|
||||
+9369
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+9936
File diff suppressed because it is too large
Load Diff
+325
@@ -0,0 +1,325 @@
|
||||
import { invokeArrayFns, isUniLifecycleHook, decodedQuery, ON_LOAD, ON_SHOW, LINEFEED, RENDERJS_MODULES, formatLog, WXS_PROTOCOL, WXS_MODULES, ON_ERROR, UniLifecycleHooks, invokeCreateErrorHandler, invokeCreateVueAppHook } from '@dcloudio/uni-shared';
|
||||
import { isString, isArray, hasOwn, isFunction } from '@vue/shared';
|
||||
import { injectHook, logError } from 'vue';
|
||||
|
||||
function get$pageByPage(page) {
|
||||
return page.vm.$basePage
|
||||
;
|
||||
}
|
||||
|
||||
function getCurrentPage() {
|
||||
const pages = getCurrentPages();
|
||||
const len = pages.length;
|
||||
if (len) {
|
||||
return pages[len - 1];
|
||||
}
|
||||
}
|
||||
function getCurrentPageVm() {
|
||||
var _a;
|
||||
const page = (_a = getCurrentPage()) === null || _a === void 0 ? void 0 : _a.vm
|
||||
;
|
||||
if (page) {
|
||||
return page.$vm;
|
||||
}
|
||||
}
|
||||
|
||||
function invokeHook(vm, name, args) {
|
||||
if (isString(vm)) {
|
||||
args = name;
|
||||
name = vm;
|
||||
vm = getCurrentPageVm();
|
||||
}
|
||||
else if (typeof vm === 'number') {
|
||||
const page = getCurrentPages().find((page) => get$pageByPage(page).id === vm);
|
||||
if (page) {
|
||||
vm = page.$vm;
|
||||
}
|
||||
else {
|
||||
vm = getCurrentPageVm();
|
||||
}
|
||||
}
|
||||
if (!vm) {
|
||||
return;
|
||||
}
|
||||
// 兼容 nvue
|
||||
{
|
||||
if (vm.__call_hook) {
|
||||
return vm.__call_hook(name, args);
|
||||
}
|
||||
}
|
||||
const hooks = vm.$[name];
|
||||
return hooks && invokeArrayFns(hooks, args);
|
||||
}
|
||||
|
||||
function injectLifecycleHook(name, hook, publicThis, instance) {
|
||||
if (isFunction(hook)) {
|
||||
injectHook(name, hook.bind(publicThis), instance);
|
||||
}
|
||||
}
|
||||
function initHooks(options, instance, publicThis) {
|
||||
const mpType = options.mpType || publicThis.$mpType;
|
||||
if (!mpType || mpType === 'component') {
|
||||
// 仅 App,Page 类型支持在 options 中配置 on 生命周期,组件可以使用组合式 API 定义页面生命周期
|
||||
return;
|
||||
}
|
||||
Object.keys(options).forEach((name) => {
|
||||
if (isUniLifecycleHook(name, options[name], false)) {
|
||||
const hooks = options[name];
|
||||
if (isArray(hooks)) {
|
||||
hooks.forEach((hook) => injectLifecycleHook(name, hook, publicThis, instance));
|
||||
}
|
||||
else {
|
||||
injectLifecycleHook(name, hooks, publicThis, instance);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (mpType === 'page') {
|
||||
instance.__isVisible = true;
|
||||
// 直接触发页面 onLoad、onShow 组件内的 onLoad 和 onShow 在注册时,直接触发一次
|
||||
try {
|
||||
let query = instance.attrs.__pageQuery;
|
||||
// onLoad 的 query 进行 decode
|
||||
if (true) {
|
||||
query = new UTSJSONObject(decodedQuery(query));
|
||||
}
|
||||
if ('app' === 'app' && true) {
|
||||
// TODO 统一处理 Web
|
||||
// @ts-expect-error
|
||||
const { setupState } = instance;
|
||||
// 组合式 API 时,如果开发者定义了 options 变量,再次赋值会导致 warn & error issues:15107
|
||||
// 现有规范开发者不需要再从 pageVm 上获取 options, 但为了控制修改影响范围,只在上述情况下不再赋值
|
||||
if (!(setupState.__isScriptSetup && hasOwn(setupState, 'options'))) {
|
||||
publicThis.options = query || {};
|
||||
}
|
||||
}
|
||||
invokeHook(publicThis, ON_LOAD, query);
|
||||
delete instance.attrs.__pageQuery;
|
||||
// iOS-X 的非 Tab 页面与 uni-app 一致固定触发 onShow
|
||||
const $basePage = true
|
||||
? publicThis.$basePage
|
||||
: publicThis.$page;
|
||||
if (!('app' === 'app' && true && ($basePage === null || $basePage === void 0 ? void 0 : $basePage.meta.isTabBar))) {
|
||||
if (($basePage === null || $basePage === void 0 ? void 0 : $basePage.openType) !== 'preloadPage') {
|
||||
invokeHook(publicThis, ON_SHOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e.message + LINEFEED + e.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initRenderjs(options, instance) {
|
||||
initModules(instance, options.$renderjs, options['$' + RENDERJS_MODULES]);
|
||||
}
|
||||
function initModules(instance, modules, moduleIds = {}) {
|
||||
if (!isArray(modules)) {
|
||||
return;
|
||||
}
|
||||
const ownerId = instance.uid;
|
||||
// 在vue的定制内核中,通过$wxsModules来判断事件函数源码中是否包含该模块调用
|
||||
// !$wxsModules.find(module => invokerSourceCode.indexOf('.' + module + '.') > -1)
|
||||
const $wxsModules = (instance.$wxsModules ||
|
||||
(instance.$wxsModules = []));
|
||||
const ctx = instance.ctx;
|
||||
modules.forEach((module) => {
|
||||
if (moduleIds[module]) {
|
||||
ctx[module] = proxyModule(ownerId, moduleIds[module], module);
|
||||
$wxsModules.push(module);
|
||||
}
|
||||
else {
|
||||
if ((process.env.NODE_ENV !== 'production')) {
|
||||
console.error(formatLog('initModules', modules, moduleIds));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function proxyModule(ownerId, moduleId, module) {
|
||||
const target = {};
|
||||
return new Proxy(target, {
|
||||
get(_, p) {
|
||||
return (target[p] ||
|
||||
(target[p] = createModuleFunction(ownerId, moduleId, module, p)));
|
||||
},
|
||||
});
|
||||
}
|
||||
function createModuleFunction(ownerId, moduleId, module, name) {
|
||||
const target = () => { };
|
||||
const toJSON = () => WXS_PROTOCOL + JSON.stringify([ownerId, moduleId, module + '.' + name]);
|
||||
return new Proxy(target, {
|
||||
get(_, p) {
|
||||
if (p === 'toJSON') {
|
||||
return toJSON;
|
||||
}
|
||||
return (target[p] ||
|
||||
(target[p] = createModuleFunction(ownerId, moduleId, module + '.' + name, p)));
|
||||
},
|
||||
apply(_target, _thisArg, args) {
|
||||
return (WXS_PROTOCOL +
|
||||
JSON.stringify([ownerId, moduleId, module + '.' + name, [...args]]));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function initWxs(options, instance) {
|
||||
initModules(instance, options.$wxs, options['$' + WXS_MODULES]);
|
||||
}
|
||||
|
||||
function applyOptions(options, instance, publicThis) {
|
||||
{
|
||||
initWxs(options, instance);
|
||||
initRenderjs(options, instance);
|
||||
}
|
||||
initHooks(options, instance, publicThis);
|
||||
}
|
||||
|
||||
function set(target, key, val) {
|
||||
return (target[key] = val);
|
||||
}
|
||||
function $callMethod(method, ...args) {
|
||||
const fn = this[method];
|
||||
if (fn) {
|
||||
return fn(...args);
|
||||
}
|
||||
console.error(`method ${method} not found`);
|
||||
return null;
|
||||
}
|
||||
|
||||
function createErrorHandler(app) {
|
||||
const userErrorHandler = app.config.errorHandler;
|
||||
return function errorHandler(err, instance, info) {
|
||||
if (userErrorHandler) {
|
||||
userErrorHandler(err, instance, info);
|
||||
}
|
||||
const appInstance = app._instance;
|
||||
if (!appInstance || !appInstance.proxy) {
|
||||
throw err;
|
||||
}
|
||||
if (appInstance[ON_ERROR]) {
|
||||
{
|
||||
invokeHook(appInstance.proxy, ON_ERROR, err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logError(err, info, instance ? instance.$.vnode : null, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
function mergeAsArray(to, from) {
|
||||
return to ? [...new Set([].concat(to, from))] : from;
|
||||
}
|
||||
function initOptionMergeStrategies(optionMergeStrategies) {
|
||||
UniLifecycleHooks.forEach((name) => {
|
||||
optionMergeStrategies[name] = mergeAsArray;
|
||||
});
|
||||
}
|
||||
|
||||
let realAtob;
|
||||
const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
|
||||
if (typeof atob !== 'function') {
|
||||
realAtob = function (str) {
|
||||
str = String(str).replace(/[\t\n\f\r ]+/g, '');
|
||||
if (!b64re.test(str)) {
|
||||
throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");
|
||||
}
|
||||
// Adding the padding if missing, for semplicity
|
||||
str += '=='.slice(2 - (str.length & 3));
|
||||
var bitmap;
|
||||
var result = '';
|
||||
var r1;
|
||||
var r2;
|
||||
var i = 0;
|
||||
for (; i < str.length;) {
|
||||
bitmap =
|
||||
(b64.indexOf(str.charAt(i++)) << 18) |
|
||||
(b64.indexOf(str.charAt(i++)) << 12) |
|
||||
((r1 = b64.indexOf(str.charAt(i++))) << 6) |
|
||||
(r2 = b64.indexOf(str.charAt(i++)));
|
||||
result +=
|
||||
r1 === 64
|
||||
? String.fromCharCode((bitmap >> 16) & 255)
|
||||
: r2 === 64
|
||||
? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
|
||||
: String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
else {
|
||||
// 注意atob只能在全局对象上调用,例如:`const Base64 = {atob};Base64.atob('xxxx')`是错误的用法
|
||||
realAtob = atob;
|
||||
}
|
||||
function b64DecodeUnicode(str) {
|
||||
return decodeURIComponent(realAtob(str)
|
||||
.split('')
|
||||
.map(function (c) {
|
||||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
||||
})
|
||||
.join(''));
|
||||
}
|
||||
function getCurrentUserInfo() {
|
||||
const token = uni.getStorageSync('uni_id_token') || '';
|
||||
const tokenArr = token.split('.');
|
||||
if (!token || tokenArr.length !== 3) {
|
||||
return {
|
||||
uid: null,
|
||||
role: [],
|
||||
permission: [],
|
||||
tokenExpired: 0,
|
||||
};
|
||||
}
|
||||
let userInfo;
|
||||
try {
|
||||
userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
|
||||
}
|
||||
catch (error) {
|
||||
throw new Error('获取当前用户信息出错,详细错误信息为:' + error.message);
|
||||
}
|
||||
userInfo.tokenExpired = userInfo.exp * 1000;
|
||||
delete userInfo.exp;
|
||||
delete userInfo.iat;
|
||||
return userInfo;
|
||||
}
|
||||
function uniIdMixin(globalProperties) {
|
||||
globalProperties.uniIDHasRole = function (roleId) {
|
||||
const { role } = getCurrentUserInfo();
|
||||
return role.indexOf(roleId) > -1;
|
||||
};
|
||||
globalProperties.uniIDHasPermission = function (permissionId) {
|
||||
const { permission } = getCurrentUserInfo();
|
||||
return this.uniIDHasRole('admin') || permission.indexOf(permissionId) > -1;
|
||||
};
|
||||
globalProperties.uniIDTokenValid = function () {
|
||||
const { tokenExpired } = getCurrentUserInfo();
|
||||
return tokenExpired > Date.now();
|
||||
};
|
||||
}
|
||||
|
||||
function initApp(app) {
|
||||
const appConfig = app.config;
|
||||
// 该逻辑全平台会调用
|
||||
// - 需要兼容支持开发者自定义的 errorHandler
|
||||
// - nvue、vue 需要使用同一个(once) errorHandler
|
||||
// - 需要支持 uni.onError 注册监听
|
||||
// * 目前仅部分小程序平台支持,调用uni.onError时,如果app已存在,则添加到instance的hooks中,如果不存在,则临时存储,初始化instance时添加到hooks中
|
||||
// * 目前在 errorHandler 中,会调用 app.$callHook(ON_ERROR, err),所以上一步需要将 uni.onError 存储到 app 的 hooks 中
|
||||
// - 部分平台(目前主要是小程序)开发阶段 uni-console 会调用 uni.onError 注册监听
|
||||
appConfig.errorHandler = invokeCreateErrorHandler(app, createErrorHandler);
|
||||
initOptionMergeStrategies(appConfig.optionMergeStrategies);
|
||||
const globalProperties = appConfig.globalProperties;
|
||||
{
|
||||
uniIdMixin(globalProperties);
|
||||
}
|
||||
{
|
||||
globalProperties.$set = set;
|
||||
globalProperties.$applyOptions = applyOptions;
|
||||
globalProperties.$callMethod = $callMethod;
|
||||
}
|
||||
{
|
||||
invokeCreateVueAppHook(app);
|
||||
}
|
||||
}
|
||||
|
||||
export { initApp };
|
||||
+15
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
[https://dcloud.io/license/uni-app.html](https://dcloud.io/license/uni-app.html)
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "@dcloudio/uni-app-plus",
|
||||
"version": "3.0.0-4060620250520001",
|
||||
"description": "@dcloudio/uni-app-plus",
|
||||
"files": [
|
||||
"dist",
|
||||
"lib",
|
||||
"style"
|
||||
],
|
||||
"sideEffects": [
|
||||
"lib/automator.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/dcloudio/uni-app.git",
|
||||
"directory": "packages/uni-app-plus"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/dcloudio/uni-app/issues"
|
||||
},
|
||||
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
||||
"uni-app": {
|
||||
"name": "uni-app-plus",
|
||||
"apply": [
|
||||
"app"
|
||||
],
|
||||
"uvue": true,
|
||||
"main": "dist/uni.compiler.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.3.3",
|
||||
"fs-extra": "^10.0.0",
|
||||
"licia": "^1.29.0",
|
||||
"postcss-selector-parser": "^6.0.6",
|
||||
"@dcloudio/uni-app-uts": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-app-vite": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-app-vue": "3.0.0-4060620250520001"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/pako": "1.0.2",
|
||||
"@types/google.maps": "^3.45.6",
|
||||
"@amap/amap-jsapi-types": "^0.0.8",
|
||||
"@vue/compiler-sfc": "3.4.21",
|
||||
"autoprefixer": "^10.4.19",
|
||||
"pako": "^1.0.11",
|
||||
"postcss": "^8.4.21",
|
||||
"vue": "3.4.21",
|
||||
"@dcloudio/uni-cli-shared": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-components": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-h5": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-i18n": "3.0.0-4060620250520001",
|
||||
"@dcloudio/uni-shared": "3.0.0-4060620250520001"
|
||||
}
|
||||
}
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
.uni-system-choose-location {
|
||||
display: block;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #f8f8f8;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .map {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .map-location {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 50%;
|
||||
width: 32px;
|
||||
height: 52px;
|
||||
margin-left: -16px;
|
||||
cursor: pointer;
|
||||
background-size: 100%;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .map-move {
|
||||
position: absolute;
|
||||
bottom: 50px;
|
||||
right: 10px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
box-sizing: border-box;
|
||||
line-height: 40px;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
box-shadow: 0px 0 5px 1px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.uni-system-choose-location .map-move>svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .nav {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: calc(44px + var(--status-bar-height));
|
||||
background-color: transparent;
|
||||
background-image: linear-gradient( to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
.uni-system-choose-location .nav-btn {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
top: var(--status-bar-height);
|
||||
left: 0;
|
||||
width: 60px;
|
||||
height: 44px;
|
||||
padding: 6px;
|
||||
line-height: 32px;
|
||||
font-size: 26px;
|
||||
color: white;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .nav-btn.confirm {
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .nav-btn.disable {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .nav-btn>svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
/* line-height: inherit; */
|
||||
border-radius: 2px;
|
||||
box-sizing: border-box;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .nav-btn.confirm>svg {
|
||||
background-color: #007aff;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .menu {
|
||||
position: absolute;
|
||||
top: 300px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .search {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 50px;
|
||||
padding: 8px;
|
||||
line-height: 34px;
|
||||
box-sizing: border-box;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .search-input {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
border-radius: 5px;
|
||||
padding: 0 5px;
|
||||
background: #ebebeb;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .search-btn {
|
||||
margin-left: 5px;
|
||||
color: #007aff;
|
||||
font-size: 17px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .list {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
padding-bottom: 10px;
|
||||
/* background-color: #f6f6f6; */
|
||||
}
|
||||
|
||||
.uni-system-choose-location .list-loading {
|
||||
display: flex;
|
||||
height: 50px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .list-item {
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
padding-right: 40px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .list-item>svg {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 10px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-top: -15px;
|
||||
box-sizing: border-box;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .list-item.selected>svg {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .list-item:not(:last-child)::after {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 1px;
|
||||
left: 10px;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
background-color: #d3d3d3;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .list-item-title {
|
||||
font-size: 14px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.uni-system-choose-location .list-item-detail {
|
||||
font-size: 12px;
|
||||
color: #808080;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 800px) {
|
||||
.uni-system-choose-location .map {
|
||||
top: 0;
|
||||
height: 100%;
|
||||
}
|
||||
.uni-system-choose-location .map-move {
|
||||
bottom: 10px;
|
||||
right: 320px;
|
||||
}
|
||||
.uni-system-choose-location .menu {
|
||||
top: calc(54px + var(--status-bar-height));
|
||||
left: auto;
|
||||
right: 10px;
|
||||
width: 300px;
|
||||
bottom: 10px;
|
||||
max-height: 600px;
|
||||
box-shadow: 0px 0 20px 5px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
.uni-system-open-location {
|
||||
display: block;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #f8f8f8;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.uni-system-open-location .map {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
bottom: 80px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.uni-system-open-location .info {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
background-color: white;
|
||||
padding: 15px;
|
||||
box-sizing: border-box;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.uni-system-open-location .info>.name {
|
||||
font-size: 17px;
|
||||
color: #111111;
|
||||
}
|
||||
|
||||
.uni-system-open-location .info>.address {
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.uni-system-open-location .info>.nav {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 15px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
margin-top: -25px;
|
||||
background-color: #007aff;
|
||||
}
|
||||
|
||||
.uni-system-open-location .info>.nav>svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.uni-system-open-location .map-move {
|
||||
position: absolute;
|
||||
bottom: 50px;
|
||||
right: 10px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
box-sizing: border-box;
|
||||
line-height: 40px;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
box-shadow: 0px 0 5px 1px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.uni-system-open-location .map-move>svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.uni-system-open-location .nav-btn-back {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
top: var(--status-bar-height);
|
||||
left: 0;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
padding: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.uni-system-open-location .nav-btn-back>svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
padding: 3px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.uni-system-open-location .map-content {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0px;
|
||||
width: 100%;
|
||||
bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.uni-system-open-location .map-content.fix-position {
|
||||
top: -74px;
|
||||
bottom: -44px;
|
||||
}
|
||||
|
||||
.uni-system-open-location .map-content>iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.uni-system-open-location .actTonav {
|
||||
position: absolute;
|
||||
right: 16px;
|
||||
bottom: 56px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 60px;
|
||||
}
|
||||
|
||||
.uni-system-open-location .nav-view {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.uni-system-open-location .nav-view-top-placeholder {
|
||||
width: 100%;
|
||||
height: var(--status-bar-height);
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.uni-system-open-location .nav-view-frame {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
uni-cover-image {
|
||||
display: block;
|
||||
line-height: 1.2;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
uni-cover-image[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
uni-cover-image .uni-cover-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
uni-cover-view {
|
||||
display: block;
|
||||
line-height: 1.2;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
uni-cover-view[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
uni-cover-view .uni-cover-view {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
visibility: hidden;
|
||||
text-overflow: inherit;
|
||||
white-space: inherit;
|
||||
-webkit-align-items: inherit;
|
||||
align-items: inherit;
|
||||
-webkit-justify-content: inherit;
|
||||
justify-content: inherit;
|
||||
-webkit-flex-direction: inherit;
|
||||
flex-direction: inherit;
|
||||
-webkit-flex-wrap: inherit;
|
||||
flex-wrap: inherit;
|
||||
display: inherit;
|
||||
overflow: inherit;
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
* {
|
||||
margin: 0;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
width: 100vw;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow-x: hidden;
|
||||
background-color: white;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
#app{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
input[type='search']::-webkit-search-cancel-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.uni-loading,
|
||||
uni-button[loading]:before {
|
||||
background: transparent
|
||||
url('data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=')
|
||||
no-repeat;
|
||||
}
|
||||
|
||||
.uni-loading {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
animation: uni-loading 1s steps(12, end) infinite;
|
||||
background-size: 100%;
|
||||
}
|
||||
|
||||
@keyframes uni-loading {
|
||||
0% {
|
||||
transform: rotate3d(0, 0, 1, 0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate3d(0, 0, 1, 360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
html {
|
||||
--UI-BG-COLOR-ACTIVE: #373737;
|
||||
--UI-BORDER-COLOR-1: #373737;
|
||||
/* UI */
|
||||
--UI-BG: #000;
|
||||
--UI-BG-0: #191919;
|
||||
--UI-BG-1: #1f1f1f;
|
||||
--UI-BG-2: #232323;
|
||||
--UI-BG-3: #2f2f2f;
|
||||
--UI-BG-4: #606060;
|
||||
--UI-BG-5: #2c2c2c;
|
||||
--UI-FG: #fff;
|
||||
--UI-FG-0: hsla(0, 0%, 100%, 0.8);
|
||||
--UI-FG-HALF: hsla(0, 0%, 100%, 0.6);
|
||||
--UI-FG-1: hsla(0, 0%, 100%, 0.5);
|
||||
--UI-FG-2: hsla(0, 0%, 100%, 0.3);
|
||||
--UI-FG-3: hsla(0, 0%, 100%, 0.05);
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--UI-BG-0);
|
||||
color: var(--UI-FG-0);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
uni-live-pusher {
|
||||
width: 320px;
|
||||
height: 240px;
|
||||
display: inline-block;
|
||||
line-height: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
uni-live-pusher[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.uni-live-pusher-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
overflow: hidden;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.uni-live-pusher-slot {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
uni-map {
|
||||
width: 300px;
|
||||
height: 225px;
|
||||
display: inline-block;
|
||||
line-height: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
uni-map[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.uni-map-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
overflow: hidden;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.uni-map-slot {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* web */
|
||||
uni-map.web {
|
||||
position: relative;
|
||||
width: 300px;
|
||||
height: 150px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
uni-map.web[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 处理高德地图 marker label 默认样式 */
|
||||
uni-map.web .amap-marker-label {
|
||||
padding: 0;
|
||||
border: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/* 处理高德地图 open-location icon 被遮挡问题 */
|
||||
uni-map.web .amap-marker>.amap-icon>img {
|
||||
left: 0 !important;
|
||||
top: 0 !important;
|
||||
}
|
||||
|
||||
uni-map.web .uni-map-control {
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
uni-map.web .uni-map-control-icon {
|
||||
position: absolute;
|
||||
max-width: initial;
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
uni-video {
|
||||
width: 300px;
|
||||
height: 225px;
|
||||
display: inline-block;
|
||||
line-height: 0;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
uni-video[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.uni-video-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
overflow: hidden;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.uni-video-slot {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
uni-web-view {
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* 需要需要确保 vue 文件是处理过条件编译的
|
||||
* @param platform
|
||||
* @param vueFileName
|
||||
* @returns
|
||||
*/
|
||||
export declare function transformExtApiVueFile(platform: 'app-android' | 'app-ios', // | 'app-harmony',
|
||||
vueFileName: string): Promise<string | void | null>;
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.transformExtApiVueFile = void 0;
|
||||
const path_1 = require("path");
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const uni_nvue_styler_1 = require("@dcloudio/uni-nvue-styler");
|
||||
const main_1 = require("./plugins/android/uvue/sfc/main");
|
||||
/**
|
||||
* 需要需要确保 vue 文件是处理过条件编译的
|
||||
* @param platform
|
||||
* @param vueFileName
|
||||
* @returns
|
||||
*/
|
||||
async function transformExtApiVueFile(platform, // | 'app-harmony',
|
||||
vueFileName) {
|
||||
vueFileName = (0, uni_cli_shared_1.normalizePath)(vueFileName);
|
||||
(0, uni_cli_shared_1.initPreContext)(platform === 'app-android' || platform === 'app-ios' ? 'app' : platform, process.env.UNI_CUSTOM_CONTEXT, platform, true);
|
||||
const code = (0, fs_extra_1.readFileSync)(vueFileName, 'utf8');
|
||||
if (platform === 'app-android') {
|
||||
return transformAppAndroidExtApiComponent(vueFileName, code);
|
||||
}
|
||||
else if (platform === 'app-ios') {
|
||||
return transformAppIosExtApiComponent(vueFileName, code);
|
||||
}
|
||||
}
|
||||
exports.transformExtApiVueFile = transformExtApiVueFile;
|
||||
async function transformAppAndroidExtApiComponent(vueFileName, code) {
|
||||
const result = await (0, main_1.transformMain)(code, vueFileName, {
|
||||
root: (0, path_1.dirname)(vueFileName),
|
||||
targetLanguage: 'kotlin',
|
||||
classNamePrefix: 'Uni',
|
||||
genDefaultAs: '__sfc__',
|
||||
sourceMap: false,
|
||||
componentType: 'component',
|
||||
});
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
const { errors, uts, descriptor } = result;
|
||||
if (errors.length > 0) {
|
||||
throw new Error(errors.join('\n'));
|
||||
}
|
||||
const componentName = (0, path_1.basename)(vueFileName).split('.')[0];
|
||||
const styleCode = await parseAppAndroidVueStyle(componentName, vueFileName, descriptor.styles.length > 0 ? descriptor.styles[0].content : '');
|
||||
return uts.replace(`/*${(0, uni_cli_shared_1.genUTSClassName)(componentName, 'Uni')}Styles*/`, styleCode);
|
||||
}
|
||||
async function transformAppIosExtApiComponent(vueFileName, code) {
|
||||
// TODO 编译vue为一个独立的js文件
|
||||
}
|
||||
async function parseAppAndroidVueStyle(name, vueFileName, cssCode) {
|
||||
if (!cssCode) {
|
||||
return `const ${(0, uni_cli_shared_1.genUTSClassName)(name, 'Uni')}Styles = []`;
|
||||
}
|
||||
const { code, messages } = await (0, uni_nvue_styler_1.parse)(cssCode, {
|
||||
filename: vueFileName,
|
||||
logLevel: 'ERROR',
|
||||
map: true,
|
||||
ts: true,
|
||||
type: 'uvue',
|
||||
platform: 'app-android',
|
||||
});
|
||||
if (messages.length) {
|
||||
messages.forEach((m) => {
|
||||
console.error(m);
|
||||
});
|
||||
}
|
||||
return `const ${(0, uni_cli_shared_1.genUTSClassName)(name, 'Uni')}Styles = [${code}]`;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
declare const _default: () => any[];
|
||||
export default _default;
|
||||
export { genUTSClassName as genClassName } from '@dcloudio/uni-cli-shared';
|
||||
export { transformMain as transformVue } from './plugins/android/uvue/sfc/main';
|
||||
export { transformExtApiVueFile } from './extApiComponents';
|
||||
export { initUniAppJsEngineCssPlugin } from './plugins/js/plugin';
|
||||
export { init as initUniAppXHarmonyPlugin } from './plugins/harmony';
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initUniAppXHarmonyPlugin = exports.initUniAppJsEngineCssPlugin = exports.transformExtApiVueFile = exports.transformVue = exports.genClassName = void 0;
|
||||
const plugins_1 = require("./plugins");
|
||||
exports.default = () => {
|
||||
return process.env.UNI_UTS_PLATFORM === 'app-android'
|
||||
? (0, plugins_1.initAndroid)()
|
||||
: process.env.UNI_UTS_PLATFORM === 'app-ios'
|
||||
? (0, plugins_1.initIOS)()
|
||||
: [];
|
||||
};
|
||||
var uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
Object.defineProperty(exports, "genClassName", { enumerable: true, get: function () { return uni_cli_shared_1.genUTSClassName; } });
|
||||
var main_1 = require("./plugins/android/uvue/sfc/main");
|
||||
Object.defineProperty(exports, "transformVue", { enumerable: true, get: function () { return main_1.transformMain; } });
|
||||
var extApiComponents_1 = require("./extApiComponents");
|
||||
Object.defineProperty(exports, "transformExtApiVueFile", { enumerable: true, get: function () { return extApiComponents_1.transformExtApiVueFile; } });
|
||||
var plugin_1 = require("./plugins/js/plugin");
|
||||
Object.defineProperty(exports, "initUniAppJsEngineCssPlugin", { enumerable: true, get: function () { return plugin_1.initUniAppJsEngineCssPlugin; } });
|
||||
var harmony_1 = require("./plugins/harmony");
|
||||
Object.defineProperty(exports, "initUniAppXHarmonyPlugin", { enumerable: true, get: function () { return harmony_1.init; } });
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import type { Plugin } from 'vite';
|
||||
export declare function uniAppCssPrePlugin(): Plugin;
|
||||
export declare function uniAppCssPlugin(): Plugin;
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniAppCssPlugin = exports.uniAppCssPrePlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const picocolors_1 = __importDefault(require("picocolors"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const uni_nvue_styler_1 = require("@dcloudio/uni-nvue-styler");
|
||||
const descriptorCache_1 = require("./uvue/descriptorCache");
|
||||
const utils_1 = require("./utils");
|
||||
function uniAppCssPrePlugin() {
|
||||
const name = 'uni:app-uvue-css-pre';
|
||||
const descriptorOptions = {
|
||||
...(0, descriptorCache_1.getResolvedOptions)(),
|
||||
sourceMap: false,
|
||||
};
|
||||
const mainPath = (0, uni_cli_shared_1.resolveMainPathOnce)(process.env.UNI_INPUT_DIR);
|
||||
return {
|
||||
name,
|
||||
// 需要提前,因为unocss会在configResolved读取vite:css-post插件
|
||||
// 所以需要在它之前做替换
|
||||
enforce: 'pre',
|
||||
apply: 'build',
|
||||
configResolved(config) {
|
||||
(0, uni_cli_shared_1.removePlugins)(['vite:css', 'vite:css-post'], config);
|
||||
const uvueCssPostPlugin = (0, uni_cli_shared_1.cssPostPlugin)(config, {
|
||||
isJsCode: true,
|
||||
platform: process.env.UNI_PLATFORM,
|
||||
includeComponentCss: false,
|
||||
chunkCssFilename(id) {
|
||||
const { filename } = (0, uni_cli_shared_1.parseVueRequest)(id);
|
||||
if (filename === mainPath) {
|
||||
// 合并到App
|
||||
return `App.uvue.style.uts`;
|
||||
}
|
||||
if ((0, utils_1.isVue)(filename)) {
|
||||
return (0, uni_cli_shared_1.normalizeNodeModules)((path_1.default.isAbsolute(filename)
|
||||
? path_1.default.relative(process.env.UNI_INPUT_DIR, filename)
|
||||
: filename) + '.style.uts');
|
||||
}
|
||||
},
|
||||
async chunkCssCode(filename, cssCode) {
|
||||
cssCode = (0, uni_cli_shared_1.parseAssets)(config, cssCode);
|
||||
const { code, messages } = await (0, uni_nvue_styler_1.parse)(cssCode, {
|
||||
filename,
|
||||
logLevel: 'ERROR',
|
||||
mapOf: 'utsMapOf',
|
||||
chunk: 100,
|
||||
type: 'uvue',
|
||||
platform: process.env.UNI_UTS_PLATFORM,
|
||||
trim: true,
|
||||
});
|
||||
messages.forEach((message) => {
|
||||
if (message.type === 'error') {
|
||||
let msg = `[plugin:uni:app-uvue-css] ${message.text}`;
|
||||
if (message.line && message.column) {
|
||||
msg += `\n${(0, uni_cli_shared_1.generateCodeFrame)(cssCode, {
|
||||
line: message.line,
|
||||
column: message.column,
|
||||
}).replace(/\t/g, ' ')}`;
|
||||
}
|
||||
msg += `\n${(0, uni_cli_shared_1.formatAtFilename)(filename)}`;
|
||||
config.logger.error(picocolors_1.default.red(msg));
|
||||
}
|
||||
});
|
||||
const fileName = filename.replace('.style.uts', '');
|
||||
const className = process.env.UNI_COMPILE_TARGET === 'ext-api'
|
||||
? // components/map/map.vue => UniMap
|
||||
(0, uni_cli_shared_1.genUTSClassName)(path_1.default.basename(fileName), descriptorOptions.classNamePrefix)
|
||||
: (0, uni_cli_shared_1.genUTSClassName)(fileName, descriptorOptions.classNamePrefix);
|
||||
return `export const ${className}Styles = ${code}`;
|
||||
},
|
||||
});
|
||||
// 增加 css plugins
|
||||
// TODO 加密插件
|
||||
(0, uni_cli_shared_1.insertBeforePlugin)((0, uni_cli_shared_1.cssPlugin)(config, {
|
||||
isAndroidX: true,
|
||||
getDescriptor: (filename) => {
|
||||
return (0, descriptorCache_1.getDescriptor)(filename, descriptorOptions, false);
|
||||
},
|
||||
}), name, config);
|
||||
const plugins = config.plugins;
|
||||
const index = plugins.findIndex((p) => p.name === 'uni:app-uvue');
|
||||
plugins.splice(index, 0, uvueCssPostPlugin);
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniAppCssPrePlugin = uniAppCssPrePlugin;
|
||||
function uniAppCssPlugin() {
|
||||
let resolvedConfig;
|
||||
return {
|
||||
name: 'uni:app-uvue-css',
|
||||
apply: 'build',
|
||||
configResolved(config) {
|
||||
resolvedConfig = config;
|
||||
},
|
||||
async transform(source, filename) {
|
||||
if (!uni_cli_shared_1.cssLangRE.test(filename) || uni_cli_shared_1.commonjsProxyRE.test(filename)) {
|
||||
return;
|
||||
}
|
||||
if (filename.endsWith('__uno.css')) {
|
||||
return;
|
||||
}
|
||||
if (source.includes('#endif')) {
|
||||
source = (0, uni_cli_shared_1.preUVueCss)(source, filename);
|
||||
}
|
||||
source = (0, uni_cli_shared_1.parseAssets)(resolvedConfig, source);
|
||||
// 仅做校验使用
|
||||
const { messages } = await (0, uni_nvue_styler_1.parse)(source, {
|
||||
filename,
|
||||
logLevel: 'WARNING',
|
||||
map: true,
|
||||
ts: true,
|
||||
noCode: true,
|
||||
type: 'uvue',
|
||||
platform: process.env.UNI_UTS_PLATFORM,
|
||||
});
|
||||
messages.forEach((message) => {
|
||||
if (message.type === 'warning') {
|
||||
// 拆分成多行,第一行输出信息(有颜色),后续输出错误代码+文件行号
|
||||
resolvedConfig.logger.warn(picocolors_1.default.yellow(`[plugin:uni:app-uvue-css] ${message.text}`));
|
||||
let msg = '';
|
||||
if (message.line && message.column) {
|
||||
msg += `\n${(0, uni_cli_shared_1.generateCodeFrame)(source, {
|
||||
line: message.line,
|
||||
column: message.column,
|
||||
}).replace(/\t/g, ' ')}\n`;
|
||||
}
|
||||
msg += `${(0, uni_cli_shared_1.formatAtFilename)(filename)}`;
|
||||
resolvedConfig.logger.warn(msg);
|
||||
}
|
||||
});
|
||||
return {
|
||||
code: source,
|
||||
map: {
|
||||
mappings: '',
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniAppCssPlugin = uniAppCssPlugin;
|
||||
+1
@@ -0,0 +1 @@
|
||||
export declare function init(): any[];
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.init = void 0;
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const pre_1 = require("./pre");
|
||||
const plugin_1 = require("./plugin");
|
||||
const css_1 = require("./css");
|
||||
const mainUTS_1 = require("./mainUTS");
|
||||
const manifestJson_1 = require("./manifestJson");
|
||||
const pagesJson_1 = require("./pagesJson");
|
||||
const uvue_1 = require("./uvue");
|
||||
const unicloud_1 = require("./unicloud");
|
||||
function init() {
|
||||
return [
|
||||
(0, css_1.uniAppCssPrePlugin)(),
|
||||
...((0, uni_cli_shared_1.isNormalCompileTarget)()
|
||||
? [
|
||||
require('@dcloudio/uni-console/lib/uni.plugin.js')(),
|
||||
(0, uni_cli_shared_1.uniDecryptUniModulesPlugin)(),
|
||||
]
|
||||
: []),
|
||||
(0, pre_1.uniPrePlugin)(),
|
||||
...((0, uni_cli_shared_1.isNormalCompileTarget)()
|
||||
? [
|
||||
(0, uni_cli_shared_1.uniUTSAppUniModulesPlugin)({
|
||||
x: true,
|
||||
isSingleThread: process.env.UNI_APP_X_SINGLE_THREAD !== 'false',
|
||||
extApis: (0, uni_cli_shared_1.parseUniExtApiNamespacesOnce)(process.env.UNI_UTS_PLATFORM, process.env.UNI_UTS_TARGET_LANGUAGE),
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
(0, plugin_1.uniAppPlugin)(),
|
||||
...(process.env.UNI_COMPILE_TARGET === 'ext-api'
|
||||
? [(0, uni_cli_shared_1.uniUniModulesExtApiPlugin)()]
|
||||
: process.env.UNI_COMPILE_TARGET === 'uni_modules'
|
||||
? [(0, uni_cli_shared_1.uniEncryptUniModulesPlugin)()]
|
||||
: [
|
||||
// 需要放到 uniAppPlugin 之后(TSC模式无需),让 uniAppPlugin 先 emit 出真实的 main.uts,然后 MainPlugin 再返回仅包含 import 的 js code
|
||||
(0, mainUTS_1.uniAppMainPlugin)(),
|
||||
(0, manifestJson_1.uniAppManifestPlugin)(),
|
||||
(0, pagesJson_1.uniAppPagesPlugin)(),
|
||||
]),
|
||||
(0, css_1.uniAppCssPlugin)(),
|
||||
// 解决所有的src引入
|
||||
(0, uni_cli_shared_1.uniViteSfcSrcImportPlugin)({ onlyVue: false }),
|
||||
(0, uvue_1.uniAppUVuePlugin)(),
|
||||
(0, unicloud_1.uniCloudPlugin)(),
|
||||
];
|
||||
}
|
||||
exports.init = init;
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
import type { Plugin } from 'vite';
|
||||
export declare function uniAppMainPlugin(): Plugin;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniAppMainPlugin = void 0;
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const utils_1 = require("./utils");
|
||||
function uniAppMainPlugin() {
|
||||
const mainUTS = (0, uni_cli_shared_1.resolveMainPathOnce)(process.env.UNI_INPUT_DIR);
|
||||
return {
|
||||
name: 'uni:app-main',
|
||||
apply: 'build',
|
||||
async transform(code, id) {
|
||||
if ((0, uni_cli_shared_1.normalizePath)(id) === mainUTS) {
|
||||
code = await (0, utils_1.parseImports)(code, (0, utils_1.createTryResolve)(id, this.resolve.bind(this)));
|
||||
return {
|
||||
code: `import './${uni_cli_shared_1.MANIFEST_JSON_UTS}';import './${uni_cli_shared_1.PAGES_JSON_UTS}';${code}`,
|
||||
map: {
|
||||
mappings: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniAppMainPlugin = uniAppMainPlugin;
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import type { Plugin } from 'vite';
|
||||
export declare function getOutputManifestJson(): Record<string, any> | undefined;
|
||||
export declare function uniAppManifestPlugin(): Plugin;
|
||||
Generated
Vendored
+102
@@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniAppManifestPlugin = exports.getOutputManifestJson = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const utils_1 = require("./utils");
|
||||
const utils_2 = require("../utils");
|
||||
let outputManifestJson = undefined;
|
||||
function getOutputManifestJson() {
|
||||
return outputManifestJson;
|
||||
}
|
||||
exports.getOutputManifestJson = getOutputManifestJson;
|
||||
function uniAppManifestPlugin() {
|
||||
const manifestJsonPath = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'manifest.json');
|
||||
const manifestJsonUTSPath = path_1.default.resolve(process.env.UNI_INPUT_DIR, uni_cli_shared_1.MANIFEST_JSON_UTS);
|
||||
let manifestJson = {};
|
||||
return {
|
||||
name: 'uni:app-manifest',
|
||||
apply: 'build',
|
||||
resolveId(id) {
|
||||
if ((0, utils_2.isManifest)(id)) {
|
||||
return manifestJsonUTSPath;
|
||||
}
|
||||
},
|
||||
load(id) {
|
||||
if ((0, utils_2.isManifest)(id)) {
|
||||
return fs_extra_1.default.readFileSync(manifestJsonPath, 'utf8');
|
||||
}
|
||||
},
|
||||
transform(code, id) {
|
||||
if ((0, utils_2.isManifest)(id)) {
|
||||
this.addWatchFile(path_1.default.resolve(process.env.UNI_INPUT_DIR, 'manifest.json'));
|
||||
manifestJson = (0, uni_cli_shared_1.parseJson)(code, false, id);
|
||||
return {
|
||||
code: `export default 'manifest.json'`,
|
||||
map: {
|
||||
mappings: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
generateBundle(_, bundle) {
|
||||
if (bundle[(0, utils_1.ENTRY_FILENAME)()]) {
|
||||
const asset = bundle[(0, utils_1.ENTRY_FILENAME)()];
|
||||
const singleThreadCode = manifestJson?.['uni-app-x']?.['singleThread'] === false
|
||||
? `override singleThread = false`
|
||||
: '';
|
||||
const flexDir = (0, uni_cli_shared_1.parseUniXFlexDirection)(manifestJson);
|
||||
const flexDirCode = flexDir !== 'column' ? `override flexDirection = "${flexDir}"` : '';
|
||||
const splashScreen = (0, uni_cli_shared_1.parseUniXSplashScreen)(manifestJson);
|
||||
const splashScreenCode = splashScreen && Object.keys(splashScreen).length > 0
|
||||
? `override splashScreen: Map<string, any> | null = ${(0, utils_1.stringifyMap)(splashScreen)}`
|
||||
: '';
|
||||
const uniStatistics = (0, uni_cli_shared_1.parseUniXUniStatistics)(manifestJson);
|
||||
const uniStatisticsCode = uniStatistics && Object.keys(uniStatistics).length > 0
|
||||
? `override uniStatistics: UTSJSONObject | null = ${JSON.stringify(uniStatistics)}`
|
||||
: '';
|
||||
const hasAppDefaultAppTheme = (0, uni_cli_shared_1.validateThemeValue)(manifestJson.app?.defaultAppTheme);
|
||||
const hasDefaultAppTheme = (0, uni_cli_shared_1.validateThemeValue)(manifestJson.defaultAppTheme);
|
||||
const defaultAppThemeCode = hasAppDefaultAppTheme
|
||||
? `override defaultAppTheme: string = "${manifestJson.app.defaultAppTheme}"`
|
||||
: hasDefaultAppTheme
|
||||
? `override defaultAppTheme: string = "${manifestJson.defaultAppTheme}"`
|
||||
: '';
|
||||
const codes = [
|
||||
singleThreadCode,
|
||||
flexDirCode,
|
||||
splashScreenCode,
|
||||
defaultAppThemeCode,
|
||||
uniStatisticsCode,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
asset.source =
|
||||
asset.source +
|
||||
`
|
||||
export class UniAppConfig extends io.dcloud.uniapp.appframe.AppConfig {
|
||||
override name: string = "${manifestJson.name || ''}"
|
||||
override appid: string = "${manifestJson.appid || ''}"
|
||||
override versionName: string = "${manifestJson.versionName || ''}"
|
||||
override versionCode: string = "${manifestJson.versionCode || ''}"
|
||||
override uniCompilerVersion: string = "${process.env.UNI_COMPILER_VERSION || ''}"
|
||||
${codes}
|
||||
constructor() { super() }
|
||||
}
|
||||
`;
|
||||
}
|
||||
},
|
||||
writeBundle() {
|
||||
outputManifestJson = (0, utils_2.normalizeManifestJson)(manifestJson);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// 发行模式下,需要等解析ext-api模块
|
||||
fs_extra_1.default.outputFileSync(path_1.default.resolve(process.env.UNI_OUTPUT_DIR, 'manifest.json'), JSON.stringify(outputManifestJson, null, 2));
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniAppManifestPlugin = uniAppManifestPlugin;
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
import type { Plugin } from 'vite';
|
||||
export declare function uniAppPagesPlugin(): Plugin;
|
||||
Generated
Vendored
+165
@@ -0,0 +1,165 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniAppPagesPlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const utils_1 = require("./utils");
|
||||
const utils_2 = require("../utils");
|
||||
function uniAppPagesPlugin() {
|
||||
const pagesJsonPath = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'pages.json');
|
||||
const pagesJsonUTSPath = path_1.default.resolve(process.env.UNI_INPUT_DIR, uni_cli_shared_1.PAGES_JSON_UTS);
|
||||
let imports = [];
|
||||
let routes = [];
|
||||
let globalStyle = 'new Map()';
|
||||
let tabBar = 'null';
|
||||
let launchPage = 'null';
|
||||
let conditionUrl = '';
|
||||
let uniIdRouter = 'new Map()';
|
||||
let themeConfig = '';
|
||||
const codes = [];
|
||||
return {
|
||||
name: 'uni:app-pages',
|
||||
apply: 'build',
|
||||
resolveId(id) {
|
||||
if ((0, utils_2.isPages)(id)) {
|
||||
return pagesJsonUTSPath;
|
||||
}
|
||||
},
|
||||
load(id) {
|
||||
if ((0, utils_2.isPages)(id)) {
|
||||
return fs_extra_1.default.readFileSync(pagesJsonPath, 'utf8');
|
||||
}
|
||||
},
|
||||
transform(code, id) {
|
||||
if ((0, utils_2.isPages)(id)) {
|
||||
this.addWatchFile(path_1.default.resolve(process.env.UNI_INPUT_DIR, 'pages.json'));
|
||||
this.addWatchFile(path_1.default.resolve(process.env.UNI_INPUT_DIR, 'theme.json'));
|
||||
let pagesJson = {
|
||||
pages: [],
|
||||
globalStyle: {
|
||||
navigationBar: {},
|
||||
},
|
||||
};
|
||||
// 调整换行符,确保 parseTree 的loc正确
|
||||
code = code.replace(/\r\n/g, '\n');
|
||||
try {
|
||||
pagesJson = (0, uni_cli_shared_1.normalizeUniAppXAppPagesJson)(code);
|
||||
}
|
||||
catch (err) {
|
||||
if (err.loc) {
|
||||
const error = (0, uni_cli_shared_1.createRollupError)('uni:app-pages', pagesJsonPath, err, code);
|
||||
this.error(error);
|
||||
}
|
||||
else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
imports = [];
|
||||
routes = [];
|
||||
process.env.UNI_APP_X_PAGE_COUNT = pagesJson.pages.length + '';
|
||||
(0, utils_2.setGlobalPageOrientation)(pagesJson.globalStyle?.pageOrientation || '');
|
||||
pagesJson.pages.forEach((page, index) => {
|
||||
const className = (0, uni_cli_shared_1.genUTSClassName)(page.path);
|
||||
let isQuit = index === 0;
|
||||
imports.push(page.path);
|
||||
routes.push(`{ path: "${page.path}", component: ${className}Class, meta: { isQuit: ${isQuit} } as UniPageMeta, style: ${stringifyPageStyle(page.style)}${page.needLogin === undefined
|
||||
? ''
|
||||
: ', needLogin: ' + page.needLogin} } as UniPageRoute`);
|
||||
});
|
||||
if (pagesJson.globalStyle) {
|
||||
globalStyle = stringifyPageStyle(pagesJson.globalStyle);
|
||||
}
|
||||
if (pagesJson.tabBar) {
|
||||
tabBar = (0, utils_1.stringifyMap)(pagesJson.tabBar);
|
||||
}
|
||||
if (pagesJson.condition) {
|
||||
const conditionInfo = (0, uni_cli_shared_1.parseArguments)(pagesJson);
|
||||
if (conditionInfo) {
|
||||
const { path, query } = JSON.parse(conditionInfo);
|
||||
conditionUrl = `${path}${query ? '?' + query : ''}`;
|
||||
}
|
||||
}
|
||||
if (pagesJson.uniIdRouter) {
|
||||
uniIdRouter = (0, utils_1.stringifyMap)(pagesJson.uniIdRouter);
|
||||
}
|
||||
launchPage = stringifyLaunchPage(pagesJson.pages[0]);
|
||||
codes.length = 0;
|
||||
// theme.json
|
||||
themeConfig = readThemeJSONFileAsStringifyMap();
|
||||
if (themeConfig) {
|
||||
codes.push(`__uniConfig.themeConfig = ${themeConfig}`);
|
||||
}
|
||||
return {
|
||||
code: `${imports
|
||||
.map((p) => `import './${p}.uvue?type=page'`)
|
||||
.join('\n')}
|
||||
export default 'pages.json'`,
|
||||
map: {
|
||||
mappings: '',
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
generateBundle(_, bundle) {
|
||||
if (bundle[(0, utils_1.ENTRY_FILENAME)()]) {
|
||||
const asset = bundle[(0, utils_1.ENTRY_FILENAME)()];
|
||||
asset.source =
|
||||
asset.source +
|
||||
`
|
||||
${imports
|
||||
.map((p) => {
|
||||
const className = (0, uni_cli_shared_1.genUTSClassName)(p);
|
||||
return `import ${className}Class from './${p}.uvue?type=page'`;
|
||||
})
|
||||
.join('\n')}
|
||||
function definePageRoutes() {
|
||||
${routes.map((route) => `__uniRoutes.push(${route})`).join('\n')}
|
||||
}
|
||||
const __uniTabBar: Map<string, any | null> | null = ${tabBar}
|
||||
const __uniLaunchPage: Map<string, any | null> = ${launchPage}
|
||||
function defineAppConfig(){
|
||||
__uniConfig.entryPagePath = '/${imports[0]}'
|
||||
__uniConfig.globalStyle = ${globalStyle}
|
||||
__uniConfig.getTabBarConfig = ():Map<string, any> | null => ${tabBar}
|
||||
__uniConfig.tabBar = __uniConfig.getTabBarConfig()
|
||||
__uniConfig.conditionUrl = '${conditionUrl}'
|
||||
__uniConfig.uniIdRouter = ${uniIdRouter}
|
||||
${codes.join('\n ')}
|
||||
__uniConfig.ready = true
|
||||
}
|
||||
`;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniAppPagesPlugin = uniAppPagesPlugin;
|
||||
function stringifyLaunchPage(launchPage) {
|
||||
return (0, utils_1.stringifyMap)({
|
||||
url: launchPage.path,
|
||||
style: launchPage.style,
|
||||
}, true);
|
||||
}
|
||||
function stringifyPageStyle(pageStyle) {
|
||||
return (0, utils_1.stringifyMap)(pageStyle);
|
||||
}
|
||||
// function readUniSassAsStringifyMap() {
|
||||
// const uniScssPath = path.resolve(process.env.UNI_INPUT_DIR, 'uni.scss')
|
||||
// let result = {}
|
||||
// if (fs.existsSync(uniScssPath)) {
|
||||
// const content = fs.readFileSync(uniScssPath, 'utf8')
|
||||
// const parser = new ThemeSassParser()
|
||||
// result = parser.parse(content)
|
||||
// }
|
||||
// return stringifyMap(result)
|
||||
// }
|
||||
function readThemeJSONFileAsStringifyMap() {
|
||||
const themeJsonPath = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'theme.json');
|
||||
if (fs_extra_1.default.existsSync(themeJsonPath)) {
|
||||
return (0, utils_1.stringifyMap)(JSON.parse(fs_extra_1.default.readFileSync(themeJsonPath, 'utf8')));
|
||||
}
|
||||
return '';
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { type UniVitePlugin } from '@dcloudio/uni-cli-shared';
|
||||
export declare function uniAppPlugin(): UniVitePlugin;
|
||||
+374
@@ -0,0 +1,374 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniAppPlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const utils_1 = require("./utils");
|
||||
const manifestJson_1 = require("./manifestJson");
|
||||
const utils_2 = require("../utils");
|
||||
const uniCloudSpaceList = (0, utils_1.getUniCloudSpaceList)();
|
||||
let isFirst = true;
|
||||
let isFirstBundleSuccess = false;
|
||||
function uniAppPlugin() {
|
||||
const inputDir = process.env.UNI_INPUT_DIR;
|
||||
const outputDir = process.env.UNI_OUTPUT_DIR;
|
||||
// const uniModulesDir = normalizePath(path.resolve(inputDir, 'uni_modules'))
|
||||
const mainUTS = (0, uni_cli_shared_1.resolveMainPathOnce)(inputDir);
|
||||
const pagesJsonPath = (0, uni_cli_shared_1.normalizePath)(path_1.default.resolve(inputDir, 'pages.json'));
|
||||
const uvueOutputDir = (0, uni_cli_shared_1.uvueOutDir)('app-android');
|
||||
const tscOutputDir = (0, uni_cli_shared_1.tscOutDir)('app-android');
|
||||
const manifestJson = (0, uni_cli_shared_1.parseManifestJsonOnce)(inputDir);
|
||||
// 预留一个口子,方便切换测试
|
||||
const split = manifestJson['uni-app-x']?.split;
|
||||
// 开始编译时,清空输出目录
|
||||
function emptyOutDir() {
|
||||
// ext-api 编译时,需要同时编译多个平台,并保留多个平台的输出目录
|
||||
if (process.env.UNI_COMPILE_TARGET === 'ext-api') {
|
||||
return;
|
||||
}
|
||||
if (fs_extra_1.default.existsSync(outputDir)) {
|
||||
(0, uni_cli_shared_1.emptyDir)(outputDir);
|
||||
}
|
||||
}
|
||||
emptyOutDir();
|
||||
function emptyUVueDir() {
|
||||
if (fs_extra_1.default.existsSync(uvueOutputDir)) {
|
||||
(0, uni_cli_shared_1.emptyDir)(uvueOutputDir);
|
||||
}
|
||||
}
|
||||
emptyUVueDir();
|
||||
function emptyTscDir() {
|
||||
if (fs_extra_1.default.existsSync(tscOutputDir)) {
|
||||
(0, uni_cli_shared_1.emptyDir)(tscOutputDir);
|
||||
}
|
||||
}
|
||||
emptyTscDir();
|
||||
let resolvedConfig;
|
||||
const uniXKotlinCompiler = process.env.UNI_APP_X_TSC === 'true'
|
||||
? (0, uni_cli_shared_1.resolveUTSCompiler)().createUniXKotlinCompilerOnce()
|
||||
: null;
|
||||
const changedFiles = [];
|
||||
return {
|
||||
name: 'uni:app-uts',
|
||||
apply: 'build',
|
||||
uni: (0, utils_2.createUniOptions)('app-android'),
|
||||
config() {
|
||||
return {
|
||||
base: '/', // 强制 base
|
||||
build: {
|
||||
// 手动清理
|
||||
emptyOutDir: false,
|
||||
outDir: process.env.UNI_APP_X_TSC === 'true' ? tscOutputDir : uvueOutputDir,
|
||||
lib: {
|
||||
// 必须使用 lib 模式
|
||||
fileName: 'output',
|
||||
entry: (0, uni_cli_shared_1.resolveMainPathOnce)(inputDir),
|
||||
formats: ['cjs'],
|
||||
},
|
||||
rollupOptions: {
|
||||
external(source) {
|
||||
if (['vue', 'vuex', 'pinia', '@dcloudio/uni-app'].includes(source)) {
|
||||
return true;
|
||||
}
|
||||
// 相对目录
|
||||
if (source.startsWith('@/') || source.startsWith('.')) {
|
||||
return false;
|
||||
}
|
||||
if (path_1.default.isAbsolute(source)) {
|
||||
return false;
|
||||
}
|
||||
// 'virtual:uno.css'
|
||||
if (source.includes(':')) {
|
||||
return false;
|
||||
}
|
||||
// android 系统库,三方库,iOS 的库呢?一般不包含.
|
||||
if (source.includes('.')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
output: {
|
||||
chunkFileNames(chunk) {
|
||||
// if (chunk.isDynamicEntry && chunk.facadeModuleId) {
|
||||
// const { filename } = parseVueRequest(chunk.facadeModuleId)
|
||||
// if (filename.endsWith('.nvue')) {
|
||||
// return (
|
||||
// removeExt(
|
||||
// normalizePath(path.relative(inputDir, filename))
|
||||
// ) + '.js'
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
return '[name].js';
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
async configResolved(config) {
|
||||
(0, utils_2.configResolved)(config, true);
|
||||
resolvedConfig = config;
|
||||
if (uniXKotlinCompiler) {
|
||||
await uniXKotlinCompiler.init();
|
||||
}
|
||||
},
|
||||
async transform(code, id) {
|
||||
const { filename } = (0, uni_cli_shared_1.parseVueRequest)(id);
|
||||
if (!filename.endsWith('.uts') && !filename.endsWith('.ts')) {
|
||||
if (filename.endsWith('.json')) {
|
||||
this.emitFile({
|
||||
type: 'asset',
|
||||
fileName: (0, uni_cli_shared_1.normalizeEmitAssetFileName)(normalizeFilename(id, false)),
|
||||
source: code,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 仅处理 uts 文件
|
||||
// 忽略 uni-app-uts/lib/automator/index.uts
|
||||
if (!filename.includes('uni-app-uts')) {
|
||||
code = (await (0, utils_1.transformAutoImport)((0, utils_1.transformUniCloudMixinDataCom)((0, uni_cli_shared_1.rewriteUniModulesConsoleExpr)(id, code)), id)).code;
|
||||
const isMainUTS = (0, uni_cli_shared_1.normalizePath)(id) === mainUTS;
|
||||
this.emitFile({
|
||||
type: 'asset',
|
||||
fileName: (0, uni_cli_shared_1.normalizeEmitAssetFileName)(normalizeFilename(id, isMainUTS)),
|
||||
source: normalizeCode(code, isMainUTS),
|
||||
});
|
||||
}
|
||||
code = await (0, utils_1.parseImports)(code, (0, utils_1.createTryResolve)(id, this.resolve.bind(this)));
|
||||
return {
|
||||
code,
|
||||
map: {
|
||||
mappings: '',
|
||||
},
|
||||
};
|
||||
},
|
||||
generateBundle(_, bundle) {
|
||||
if (!(0, uni_cli_shared_1.isNormalCompileTarget)()) {
|
||||
return;
|
||||
}
|
||||
// 开发者仅在 script 中引入了 easyCom 类型,但模板里边没用到,此时额外生成一个辅助的.uvue文件
|
||||
// checkUTSEasyComAutoImports(inputDir, bundle, this)
|
||||
},
|
||||
watchChange(fileName, change) {
|
||||
if (uniXKotlinCompiler) {
|
||||
// watcher && watcher.watch(3000)
|
||||
fileName = (0, uni_cli_shared_1.normalizePath)(fileName);
|
||||
if (fileName === pagesJsonPath) {
|
||||
// pages.json 被注入了main.uts,需要触发main.uts的重新编译
|
||||
changedFiles.push({
|
||||
fileName: (0, uni_cli_shared_1.normalizePath)(mainUTS),
|
||||
event: change.event,
|
||||
});
|
||||
}
|
||||
else {
|
||||
// 主工程可能引入uni_modules中的文件
|
||||
// if (fileName.startsWith(uniModulesDir)) {
|
||||
// // 忽略uni_modules uts原生插件中的文件
|
||||
// const plugin = fileName
|
||||
// .slice(uniModulesDir.length + 1)
|
||||
// .split('/')[0]
|
||||
// if (getCurrentCompiledUTSPlugins().has(plugin)) {
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
const depMap = (0, uni_cli_shared_1.getCssDepMap)();
|
||||
if (depMap.has(fileName)) {
|
||||
for (const id of depMap.get(fileName)) {
|
||||
changedFiles.push({ fileName: id, event: change.event });
|
||||
}
|
||||
}
|
||||
}
|
||||
changedFiles.push({ fileName, event: change.event });
|
||||
}
|
||||
},
|
||||
async writeBundle() {
|
||||
const { compileApp } = (0, uni_cli_shared_1.resolveUTSCompiler)();
|
||||
if (!(0, uni_cli_shared_1.isNormalCompileTarget)()) {
|
||||
if (process.env.UNI_COMPILE_TARGET === 'ext-api') {
|
||||
if (uniXKotlinCompiler) {
|
||||
await uniXKotlinCompiler.addRootFile(path_1.default.join(tscOutputDir, 'main.uts.ts'));
|
||||
await uniXKotlinCompiler.close();
|
||||
const res = await compileApp(path_1.default.join(uvueOutputDir, 'main.uts'), {
|
||||
pageCount: 0,
|
||||
split: false,
|
||||
disableSplitManifest: process.env.NODE_ENV !== 'development',
|
||||
inputDir: uvueOutputDir,
|
||||
outputDir: outputDir,
|
||||
outFilename: `${process.env.UNI_COMPILE_EXT_API_OUT_FILE_NAME || 'components'}.kt`,
|
||||
package: (0, uni_cli_shared_1.parseKotlinPackageWithPluginId)(process.env.UNI_COMPILE_EXT_API_PLUGIN_ID, true),
|
||||
sourceMap: false,
|
||||
uni_modules: [process.env.UNI_COMPILE_EXT_API_PLUGIN_ID],
|
||||
extApiComponents: [],
|
||||
uvueClassNamePrefix: utils_1.UVUE_CLASS_NAME_PREFIX,
|
||||
transform: {
|
||||
uvueClassNamePrefix: 'Uni',
|
||||
uvueClassNameOnlyBasename: true,
|
||||
},
|
||||
});
|
||||
if (res?.error) {
|
||||
throw res.error;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (uniXKotlinCompiler) {
|
||||
// 如果 main.uts.ts 没有被添加到 uniXKotlinCompiler 中,则添加
|
||||
// 有可能首次编译失败,并没有走到这里,二次编译导致了changedFiles有内容
|
||||
const mainFile = path_1.default.join(tscOutputDir, 'main.uts.ts');
|
||||
if (!uniXKotlinCompiler.hasRootFile(mainFile)) {
|
||||
await uniXKotlinCompiler.addRootFile(mainFile);
|
||||
}
|
||||
if (changedFiles.length) {
|
||||
const files = changedFiles.splice(0);
|
||||
await uniXKotlinCompiler.invalidate(files);
|
||||
}
|
||||
}
|
||||
let pageCount = 0;
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
}
|
||||
// 首次编译成功后,不再显示页面数量进度条
|
||||
if (!isFirstBundleSuccess) {
|
||||
// 自动化测试时,不显示页面数量进度条
|
||||
// if (!process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
|
||||
pageCount = parseInt(process.env.UNI_APP_X_PAGE_COUNT) || 0;
|
||||
// }
|
||||
}
|
||||
// x 上暂时编译所有uni ext api,不管代码里是否调用了
|
||||
await (0, uni_cli_shared_1.buildUniExtApis)();
|
||||
const uniCloudObjectInfo = (0, utils_1.getUniCloudObjectInfo)(uniCloudSpaceList);
|
||||
if (uniCloudObjectInfo.length > 0) {
|
||||
process.env.UNI_APP_X_UNICLOUD_OBJECT = 'true';
|
||||
}
|
||||
else {
|
||||
process.env.UNI_APP_X_UNICLOUD_OBJECT = 'false';
|
||||
}
|
||||
const res = await compileApp(path_1.default.join(uvueOutputDir, 'main.uts'), {
|
||||
pageCount,
|
||||
uniCloudObjectInfo,
|
||||
split: split !== false,
|
||||
disableSplitManifest: process.env.NODE_ENV !== 'development',
|
||||
inputDir: uvueOutputDir,
|
||||
outputDir: outputDir,
|
||||
package: 'uni.' + (manifestJson.appid || utils_1.DEFAULT_APPID).replace(/_/g, ''),
|
||||
sourceMap: (0, uni_cli_shared_1.enableSourceMap)(),
|
||||
uni_modules: [...(0, uni_cli_shared_1.getCurrentCompiledUTSPlugins)()],
|
||||
extApis: (0, uni_cli_shared_1.parseUniExtApiNamespacesOnce)(process.env.UNI_UTS_PLATFORM, process.env.UNI_UTS_TARGET_LANGUAGE),
|
||||
extApiComponents: [...(0, utils_2.getExtApiComponents)()],
|
||||
uvueClassNamePrefix: utils_1.UVUE_CLASS_NAME_PREFIX,
|
||||
autoImports: await (0, uni_cli_shared_1.initUTSKotlinAutoImportsOnce)(),
|
||||
extApiProviders: parseUniExtApiProviders(),
|
||||
uniModulesArtifacts: (0, uni_cli_shared_1.parseUniModulesArtifacts)(),
|
||||
env: parseProcessEnv(resolvedConfig),
|
||||
});
|
||||
if (uniXKotlinCompiler && process.env.NODE_ENV !== 'development') {
|
||||
await uniXKotlinCompiler.close();
|
||||
}
|
||||
if (res) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
const files = [];
|
||||
if (process.env.UNI_APP_UTS_CHANGED_FILES) {
|
||||
try {
|
||||
files.push(...JSON.parse(process.env.UNI_APP_UTS_CHANGED_FILES));
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
if (res.changed) {
|
||||
// 触发了kotlinc编译,且没有编译成功
|
||||
if (!res.changed.length && res.kotlinc) {
|
||||
throw new Error('编译失败');
|
||||
}
|
||||
files.push(...res.changed);
|
||||
}
|
||||
process.env.UNI_APP_UTS_CHANGED_FILES = JSON.stringify([
|
||||
...new Set(files),
|
||||
]);
|
||||
}
|
||||
else {
|
||||
// 生产环境,记录使用到的modules
|
||||
const modules = res.inject_modules;
|
||||
const manifest = (0, manifestJson_1.getOutputManifestJson)();
|
||||
if (manifest) {
|
||||
// 执行了摇树逻辑,就需要设置 modules 节点
|
||||
(0, utils_2.updateManifestModules)(manifest, modules);
|
||||
fs_extra_1.default.outputFileSync(path_1.default.resolve(process.env.UNI_OUTPUT_DIR, 'manifest.json'), JSON.stringify(manifest, null, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
isFirstBundleSuccess = true;
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniAppPlugin = uniAppPlugin;
|
||||
function normalizeFilename(filename, isMain = false) {
|
||||
if (isMain) {
|
||||
return 'main.uts';
|
||||
}
|
||||
return (0, utils_1.parseUTSRelativeFilename)(filename, process.env.UNI_INPUT_DIR);
|
||||
}
|
||||
function commentUnoCssImport(code) {
|
||||
// 使用正则表达式匹配 'import 'virtual:uno.css'' 语句
|
||||
const regex = /^import\s+['"]virtual:uno\.css['"];?/gm;
|
||||
return code.replace(regex, '// $&');
|
||||
}
|
||||
function normalizeCode(code, isMain = false) {
|
||||
code = commentUnoCssImport(code);
|
||||
if (!(0, uni_cli_shared_1.isNormalCompileTarget)()) {
|
||||
return code;
|
||||
}
|
||||
if (!isMain) {
|
||||
return code;
|
||||
}
|
||||
const automatorCode = process.env.UNI_AUTOMATOR_WS_ENDPOINT &&
|
||||
process.env.UNI_AUTOMATOR_APP_WEBVIEW !== 'true'
|
||||
? 'initAutomator();\n'
|
||||
: '';
|
||||
return `${code}
|
||||
export function main(app: IApp) {
|
||||
definePageRoutes();
|
||||
defineAppConfig();
|
||||
${automatorCode}(createApp()['app'] as VueApp).mount(app, ${utils_1.UVUE_CLASS_NAME_PREFIX}UniApp());
|
||||
}
|
||||
`;
|
||||
}
|
||||
function parseUniExtApiProviders() {
|
||||
const providers = [];
|
||||
const customProviders = (0, uni_cli_shared_1.getUniExtApiProviderRegisters)();
|
||||
customProviders.forEach((provider) => {
|
||||
providers.push([provider.service, provider.name, provider.class]);
|
||||
});
|
||||
return providers;
|
||||
}
|
||||
function parseProcessEnv(resolvedConfig) {
|
||||
const env = {};
|
||||
const defines = {};
|
||||
const userDefines = resolvedConfig.define;
|
||||
Object.keys(userDefines).forEach((key) => {
|
||||
if (key.startsWith('process.env.')) {
|
||||
defines[key.replace('process.env.', '')] = userDefines[key];
|
||||
}
|
||||
});
|
||||
(0, shared_1.extend)(defines, resolvedConfig.env);
|
||||
Object.keys(defines).forEach((key) => {
|
||||
let value = defines[key];
|
||||
if ((0, shared_1.isString)(value)) {
|
||||
try {
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
if (!(0, shared_1.isString)(value)) {
|
||||
value = JSON.stringify(value);
|
||||
}
|
||||
env[key] = value;
|
||||
});
|
||||
return env;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import type { Plugin } from 'vite';
|
||||
import { type FilterPattern } from '@rollup/pluginutils';
|
||||
export interface UniPrePluginOptions {
|
||||
include?: FilterPattern;
|
||||
exclude?: FilterPattern;
|
||||
}
|
||||
export declare function uniPrePlugin(options?: UniPrePluginOptions): Plugin;
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniPrePlugin = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
|
||||
const debugPreJs = (0, debug_1.default)('uni:pre-js');
|
||||
const debugPreHtml = (0, debug_1.default)('uni:pre-html');
|
||||
// const debugPreJsTry = debug('uni:pre-js-try')
|
||||
const PRE_HTML_EXTNAME = ['.vue', '.uvue'];
|
||||
const PRE_JS_EXTNAME = ['.json', '.css', '.uts', '.ts'].concat(PRE_HTML_EXTNAME);
|
||||
function uniPrePlugin(options = {}) {
|
||||
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
||||
const preJsFile = uni_cli_shared_1.preUVueJs;
|
||||
const preHtmlFile = uni_cli_shared_1.preUVueHtml;
|
||||
return {
|
||||
name: 'uni:pre-android',
|
||||
enforce: 'pre',
|
||||
transform(code, id) {
|
||||
if (!filter(id)) {
|
||||
return;
|
||||
}
|
||||
const { filename } = (0, uni_cli_shared_1.parseVueRequest)(id);
|
||||
const extname = path_1.default.extname(filename);
|
||||
const isHtml = PRE_HTML_EXTNAME.includes(extname);
|
||||
const isJs = PRE_JS_EXTNAME.includes(extname);
|
||||
const isPre = isHtml || isJs;
|
||||
if (isPre) {
|
||||
// debugPreJsTry(id)
|
||||
}
|
||||
const hasEndif = isPre && code.includes('#endif');
|
||||
if (!hasEndif) {
|
||||
return;
|
||||
}
|
||||
if (isHtml) {
|
||||
code = preHtmlFile(code, id);
|
||||
debugPreHtml(id);
|
||||
}
|
||||
if (isJs) {
|
||||
code = preJsFile(code, id);
|
||||
debugPreJs(id);
|
||||
}
|
||||
return {
|
||||
code,
|
||||
map: {
|
||||
mappings: '',
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.uniPrePlugin = uniPrePlugin;
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
import type { Plugin } from 'vite';
|
||||
export declare function uniCloudPlugin(): Plugin;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user