@tarojs/taro-h5 3.6.6-alpha.1 → 3.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_commonjsHelpers.js +35 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/lodash.js +4 -0
- package/dist/_virtual/lodash.js.map +1 -0
- package/dist/api/base/weapp/app-event.d.ts +10 -10
- package/dist/api/base/weapp/app-event.js +78 -9
- package/dist/api/base/weapp/app-event.js.map +1 -1
- package/dist/api/framework/index.d.ts +1 -1
- package/dist/api/taro.d.ts +7 -2
- package/dist/api/taro.js +12 -3
- package/dist/api/taro.js.map +1 -1
- package/dist/index.cjs.d.ts +31 -39
- package/dist/index.cjs.js +17493 -177
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +31 -39
- package/dist/index.esm.js +17493 -179
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/node_modules/.pnpm/registry.npmjs.org_lodash@4.17.21/node_modules/lodash/lodash.js +17220 -0
- package/dist/node_modules/.pnpm/registry.npmjs.org_lodash@4.17.21/node_modules/lodash/lodash.js.map +1 -0
- package/dist/utils/handler.d.ts +13 -26
- package/dist/utils/handler.js +4 -16
- package/dist/utils/handler.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2
|
+
|
|
3
|
+
function getDefaultExportFromCjs (x) {
|
|
4
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function getDefaultExportFromNamespaceIfPresent (n) {
|
|
8
|
+
return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getDefaultExportFromNamespaceIfNotNamed (n) {
|
|
12
|
+
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getAugmentedNamespace(n) {
|
|
16
|
+
if (n.__esModule) return n;
|
|
17
|
+
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
18
|
+
Object.keys(n).forEach(function (k) {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
20
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return n[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return a;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function commonjsRequire (path) {
|
|
31
|
+
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { commonjsGlobal, commonjsRequire, getAugmentedNamespace, getDefaultExportFromCjs, getDefaultExportFromNamespaceIfNotNamed, getDefaultExportFromNamespaceIfPresent };
|
|
35
|
+
//# sourceMappingURL=_commonjsHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_commonjsHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lodash.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
|
-
declare const onUnhandledRejection:
|
|
3
|
-
declare const onThemeChange:
|
|
4
|
-
declare const onPageNotFound:
|
|
5
|
-
declare const onError:
|
|
2
|
+
declare const onUnhandledRejection: typeof Taro.onUnhandledRejection;
|
|
3
|
+
declare const onThemeChange: typeof Taro.onThemeChange;
|
|
4
|
+
declare const onPageNotFound: typeof Taro.onPageNotFound;
|
|
5
|
+
declare const onError: typeof Taro.onError;
|
|
6
6
|
declare const onAudioInterruptionEnd: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
7
7
|
declare const onAudioInterruptionBegin: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
8
8
|
declare const onAppShow: typeof Taro.onAppShow;
|
|
9
9
|
declare const onAppHide: typeof Taro.onAppHide;
|
|
10
|
-
declare const offUnhandledRejection:
|
|
11
|
-
declare const offThemeChange:
|
|
12
|
-
declare const offPageNotFound:
|
|
13
|
-
declare const offError:
|
|
10
|
+
declare const offUnhandledRejection: typeof Taro.offUnhandledRejection;
|
|
11
|
+
declare const offThemeChange: typeof Taro.offThemeChange;
|
|
12
|
+
declare const offPageNotFound: typeof Taro.offPageNotFound;
|
|
13
|
+
declare const offError: typeof Taro.offError;
|
|
14
14
|
declare const offAudioInterruptionEnd: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
15
15
|
declare const offAudioInterruptionBegin: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
16
|
-
declare const offAppShow: typeof Taro.
|
|
17
|
-
declare const offAppHide: typeof Taro.
|
|
16
|
+
declare const offAppShow: typeof Taro.offAppShow;
|
|
17
|
+
declare const offAppHide: typeof Taro.offAppHide;
|
|
18
18
|
export { onUnhandledRejection, onThemeChange, onPageNotFound, onError, onAudioInterruptionEnd, onAudioInterruptionBegin, onAppShow, onAppHide, offUnhandledRejection, offThemeChange, offPageNotFound, offError, offAudioInterruptionEnd, offAudioInterruptionBegin, offAppShow, offAppHide };
|
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
|
+
import '../../../node_modules/.pnpm/registry.npmjs.org_lodash@4.17.21/node_modules/lodash/lodash.js';
|
|
2
3
|
import { parse } from 'query-string';
|
|
3
4
|
import { temporarilyNotSupport } from '../../../utils/index.js';
|
|
4
5
|
import { CallbackManager } from '../../../utils/handler.js';
|
|
6
|
+
import { l as lodash } from '../../../_virtual/lodash.js';
|
|
5
7
|
|
|
8
|
+
const unhandledRejectionCallbackManager = new CallbackManager();
|
|
9
|
+
const themeChangeCallbackManager = new CallbackManager();
|
|
10
|
+
const pageNotFoundCallbackManager = new CallbackManager();
|
|
11
|
+
const errorCallbackManager = new CallbackManager();
|
|
6
12
|
const appShowCallbackManager = new CallbackManager();
|
|
7
13
|
const appHideCallbackManager = new CallbackManager();
|
|
14
|
+
const unhandledRejectionListener = (res) => {
|
|
15
|
+
unhandledRejectionCallbackManager.trigger(res);
|
|
16
|
+
};
|
|
17
|
+
let themeMatchMedia = null;
|
|
18
|
+
const themeChangeListener = (res) => {
|
|
19
|
+
themeChangeCallbackManager.trigger({
|
|
20
|
+
theme: res.matches ? 'dark' : 'light'
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const pageNotFoundListener = (res) => {
|
|
24
|
+
pageNotFoundCallbackManager.trigger(res);
|
|
25
|
+
};
|
|
26
|
+
const errorListener = (res) => {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
errorCallbackManager.trigger(res.stack || res.message || res);
|
|
29
|
+
};
|
|
8
30
|
const getApp = () => {
|
|
9
31
|
var _a;
|
|
10
32
|
const path = (_a = Taro.Current.page) === null || _a === void 0 ? void 0 : _a.path;
|
|
11
33
|
return {
|
|
12
34
|
/** 小程序切前台的路径 */
|
|
13
|
-
path: path === null || path === void 0 ? void 0 : path.substring(0, path.indexOf('?')),
|
|
35
|
+
path: (path === null || path === void 0 ? void 0 : path.substring(0, path.indexOf('?'))) || '',
|
|
14
36
|
/** 小程序切前台的 query 参数 */
|
|
15
37
|
query: parse(location.search),
|
|
16
38
|
/** 来源信息。 */
|
|
@@ -32,10 +54,33 @@ const appHideListener = () => {
|
|
|
32
54
|
}
|
|
33
55
|
};
|
|
34
56
|
// 应用级事件
|
|
35
|
-
const onUnhandledRejection =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
57
|
+
const onUnhandledRejection = callback => {
|
|
58
|
+
unhandledRejectionCallbackManager.add(callback);
|
|
59
|
+
if (unhandledRejectionCallbackManager.count() === 1) {
|
|
60
|
+
window.addEventListener('unhandledrejection', unhandledRejectionListener);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const onThemeChange = callback => {
|
|
64
|
+
themeChangeCallbackManager.add(callback);
|
|
65
|
+
if (themeChangeCallbackManager.count() === 1) {
|
|
66
|
+
if (lodash.exports.isNil(themeMatchMedia)) {
|
|
67
|
+
themeMatchMedia = window.matchMedia('(prefers-color-scheme: light)');
|
|
68
|
+
}
|
|
69
|
+
themeMatchMedia.addEventListener('change', themeChangeListener);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const onPageNotFound = callback => {
|
|
73
|
+
pageNotFoundCallbackManager.add(callback);
|
|
74
|
+
if (pageNotFoundCallbackManager.count() === 1) {
|
|
75
|
+
Taro.eventCenter.on('__taroRouterNotFound', pageNotFoundListener);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const onError = callback => {
|
|
79
|
+
errorCallbackManager.add(callback);
|
|
80
|
+
if (errorCallbackManager.count() === 1) {
|
|
81
|
+
window.addEventListener('error', errorListener);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
39
84
|
const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd');
|
|
40
85
|
const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin');
|
|
41
86
|
const onAppShow = callback => {
|
|
@@ -50,10 +95,34 @@ const onAppHide = callback => {
|
|
|
50
95
|
window.addEventListener('visibilitychange', appHideListener);
|
|
51
96
|
}
|
|
52
97
|
};
|
|
53
|
-
const offUnhandledRejection =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
98
|
+
const offUnhandledRejection = callback => {
|
|
99
|
+
unhandledRejectionCallbackManager.remove(callback);
|
|
100
|
+
if (unhandledRejectionCallbackManager.count() === 0) {
|
|
101
|
+
window.removeEventListener('unhandledrejection', unhandledRejectionListener);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const offThemeChange = callback => {
|
|
105
|
+
themeChangeCallbackManager.remove(callback);
|
|
106
|
+
if (themeChangeCallbackManager.count() === 0) {
|
|
107
|
+
if (lodash.exports.isNil(themeMatchMedia)) {
|
|
108
|
+
themeMatchMedia = window.matchMedia('(prefers-color-scheme: light)');
|
|
109
|
+
}
|
|
110
|
+
themeMatchMedia.removeEventListener('change', themeChangeListener);
|
|
111
|
+
themeMatchMedia = null;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const offPageNotFound = callback => {
|
|
115
|
+
pageNotFoundCallbackManager.remove(callback);
|
|
116
|
+
if (pageNotFoundCallbackManager.count() === 0) {
|
|
117
|
+
Taro.eventCenter.off('__taroRouterNotFound', pageNotFoundListener);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const offError = callback => {
|
|
121
|
+
errorCallbackManager.remove(callback);
|
|
122
|
+
if (errorCallbackManager.count() === 0) {
|
|
123
|
+
window.removeEventListener('error', errorListener);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
57
126
|
const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd');
|
|
58
127
|
const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin');
|
|
59
128
|
const offAppShow = callback => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-event.js","sources":["../../../../src/api/base/weapp/app-event.ts"],"sourcesContent":["import Taro from '@tarojs/api'\nimport { parse } from 'query-string'\n\nimport { temporarilyNotSupport } from '../../../utils'\nimport { CallbackManager } from '../../../utils/handler'\n\nconst appShowCallbackManager = new CallbackManager()\nconst appHideCallbackManager = new CallbackManager()\n\nconst getApp = () => {\n const path = Taro.Current.page?.path\n return {\n /** 小程序切前台的路径 */\n path: path?.substring(0, path.indexOf('?')),\n /** 小程序切前台的 query 参数 */\n query: parse(location.search),\n /** 来源信息。 */\n referrerInfo: {},\n /** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */\n scene: 0,\n /** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */\n shareTicket: ''\n }\n}\n\nconst appShowListener = () => {\n if (document.visibilityState !== 'hidden') {\n appShowCallbackManager.trigger(getApp())\n }\n}\n\nconst appHideListener = () => {\n if (document.visibilityState === 'hidden') {\n appHideCallbackManager.trigger(getApp())\n }\n}\n\n// 应用级事件\nexport const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection')\nexport const onThemeChange = temporarilyNotSupport('onThemeChange')\nexport const onPageNotFound = temporarilyNotSupport('onPageNotFound')\nexport const onError = temporarilyNotSupport('onError')\nexport const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd')\nexport const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin')\n\nexport const onAppShow: typeof Taro.onAppShow = callback => {\n appShowCallbackManager.add(callback)\n if (appShowCallbackManager.count() === 1) {\n window.addEventListener('visibilitychange', appShowListener)\n }\n}\n\nexport const onAppHide: typeof Taro.onAppHide = callback => {\n appHideCallbackManager.add(callback)\n if (appHideCallbackManager.count() === 1) {\n window.addEventListener('visibilitychange', appHideListener)\n }\n}\n\nexport const offUnhandledRejection = temporarilyNotSupport('offUnhandledRejection')\nexport const offThemeChange = temporarilyNotSupport('offThemeChange')\nexport const offPageNotFound = temporarilyNotSupport('offPageNotFound')\nexport const offError = temporarilyNotSupport('offError')\nexport const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd')\nexport const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin')\n\nexport const offAppShow: typeof Taro.offWindowResize = callback => {\n appShowCallbackManager.remove(callback)\n if (appShowCallbackManager.count() === 0) {\n window.removeEventListener('visibilitychange', appShowListener)\n }\n}\n\nexport const offAppHide: typeof Taro.offWindowResize = callback => {\n appHideCallbackManager.remove(callback)\n if (appHideCallbackManager.count() === 0) {\n window.removeEventListener('visibilitychange', appHideListener)\n }\n}\n"],"names":[],"mappings":";;;;;AAMA,MAAM,sBAAsB,GAAG,IAAI,eAAe,EAAE,CAAA;AACpD,MAAM,sBAAsB,GAAG,IAAI,eAAe,EAAE,CAAA;AAEpD,MAAM,MAAM,GAAG,MAAK;;IAClB,MAAM,IAAI,GAAG,CAAA,EAAA,GAAA,IAAI,CAAC,OAAO,CAAC,IAAI,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAI,CAAA;IACpC,OAAO;;AAEL,QAAA,IAAI,EAAE,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAJ,IAAI,CAAE,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;;AAE3C,QAAA,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;;AAE7B,QAAA,YAAY,EAAE,EAAE;;AAEhB,QAAA,KAAK,EAAE,CAAC;;AAER,QAAA,WAAW,EAAE,EAAE;KAChB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,MAAK;AAC3B,IAAA,IAAI,QAAQ,CAAC,eAAe,KAAK,QAAQ,EAAE;AACzC,QAAA,sBAAsB,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;AACzC,KAAA;AACH,CAAC,CAAA;AAED,MAAM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AqB,CAAC,2BAA2B,EAAC;AAE9E,MAAA,UAAU,GAAgC,QAAQ,IAAG;AAChE,IAAA,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACvC,IAAA,IAAI,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAA;AAChE,KAAA;AACH,EAAC;AAEY,MAAA,UAAU,GAAgC,QAAQ,IAAG;AAChE,IAAA,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACvC,IAAA,IAAI,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAA;AAChE,KAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"app-event.js","sources":["../../../../src/api/base/weapp/app-event.ts"],"sourcesContent":["import Taro from '@tarojs/api'\nimport { isNil } from 'lodash'\nimport { parse } from 'query-string'\n\nimport { temporarilyNotSupport } from '../../../utils'\nimport { CallbackManager } from '../../../utils/handler'\n\nconst unhandledRejectionCallbackManager = new CallbackManager<[Taro.onUnhandledRejection.Result]>()\nconst themeChangeCallbackManager = new CallbackManager<[Taro.onThemeChange.Result]>()\nconst pageNotFoundCallbackManager = new CallbackManager<[Taro.onPageNotFound.Result]>()\nconst errorCallbackManager = new CallbackManager<Parameters<Taro.onError.Callback>>()\nconst appShowCallbackManager = new CallbackManager<[Taro.onAppShow.CallbackResult]>()\nconst appHideCallbackManager = new CallbackManager<[Taro.onAppShow.CallbackResult]>()\n\nconst unhandledRejectionListener = (res: PromiseRejectionEvent) => {\n unhandledRejectionCallbackManager.trigger(res)\n}\n\nlet themeMatchMedia: MediaQueryList | null = null\nconst themeChangeListener = (res: MediaQueryListEvent) => {\n themeChangeCallbackManager.trigger({\n theme: res.matches ? 'dark' : 'light'\n })\n}\n\nconst pageNotFoundListener = (res: Taro.onPageNotFound.Result) => {\n pageNotFoundCallbackManager.trigger(res)\n}\n\nconst errorListener = (res: ErrorEvent) => {\n // @ts-ignore\n errorCallbackManager.trigger(res.stack || res.message || res)\n}\n\nconst getApp = () => {\n const path = Taro.Current.page?.path\n return {\n /** 小程序切前台的路径 */\n path: path?.substring(0, path.indexOf('?')) || '',\n /** 小程序切前台的 query 参数 */\n query: parse(location.search),\n /** 来源信息。 */\n referrerInfo: {},\n /** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */\n scene: 0,\n /** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */\n shareTicket: ''\n }\n}\n\nconst appShowListener = () => {\n if (document.visibilityState !== 'hidden') {\n appShowCallbackManager.trigger(getApp())\n }\n}\n\nconst appHideListener = () => {\n if (document.visibilityState === 'hidden') {\n appHideCallbackManager.trigger(getApp())\n }\n}\n\n// 应用级事件\nexport const onUnhandledRejection: typeof Taro.onUnhandledRejection = callback => {\n unhandledRejectionCallbackManager.add(callback)\n if (unhandledRejectionCallbackManager.count() === 1) {\n window.addEventListener('unhandledrejection', unhandledRejectionListener)\n }\n}\n\nexport const onThemeChange: typeof Taro.onThemeChange = callback => {\n themeChangeCallbackManager.add(callback)\n if (themeChangeCallbackManager.count() === 1) {\n if (isNil(themeMatchMedia)) {\n themeMatchMedia = window.matchMedia('(prefers-color-scheme: light)')\n }\n themeMatchMedia.addEventListener('change', themeChangeListener)\n }\n}\n\nexport const onPageNotFound: typeof Taro.onPageNotFound = callback => {\n pageNotFoundCallbackManager.add(callback)\n if (pageNotFoundCallbackManager.count() === 1) {\n Taro.eventCenter.on('__taroRouterNotFound', pageNotFoundListener)\n }\n}\n\nexport const onError: typeof Taro.onError = callback => {\n errorCallbackManager.add(callback)\n if (errorCallbackManager.count() === 1) {\n window.addEventListener('error', errorListener)\n }\n}\n\nexport const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd')\nexport const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin')\n\nexport const onAppShow: typeof Taro.onAppShow = callback => {\n appShowCallbackManager.add(callback)\n if (appShowCallbackManager.count() === 1) {\n window.addEventListener('visibilitychange', appShowListener)\n }\n}\n\nexport const onAppHide: typeof Taro.onAppHide = callback => {\n appHideCallbackManager.add(callback)\n if (appHideCallbackManager.count() === 1) {\n window.addEventListener('visibilitychange', appHideListener)\n }\n}\n\nexport const offUnhandledRejection: typeof Taro.offUnhandledRejection = callback => {\n unhandledRejectionCallbackManager.remove(callback)\n if (unhandledRejectionCallbackManager.count() === 0) {\n window.removeEventListener('unhandledrejection', unhandledRejectionListener)\n }\n}\n\nexport const offThemeChange: typeof Taro.offThemeChange = callback => {\n themeChangeCallbackManager.remove(callback)\n if (themeChangeCallbackManager.count() === 0) {\n if (isNil(themeMatchMedia)) {\n themeMatchMedia = window.matchMedia('(prefers-color-scheme: light)')\n }\n themeMatchMedia.removeEventListener('change', themeChangeListener)\n themeMatchMedia = null\n }\n}\n\nexport const offPageNotFound: typeof Taro.offPageNotFound = callback => {\n pageNotFoundCallbackManager.remove(callback)\n if (pageNotFoundCallbackManager.count() === 0) {\n Taro.eventCenter.off('__taroRouterNotFound', pageNotFoundListener)\n }\n}\n\nexport const offError: typeof Taro.offError = callback => {\n errorCallbackManager.remove(callback)\n if (errorCallbackManager.count() === 0) {\n window.removeEventListener('error', errorListener)\n }\n}\n\nexport const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd')\nexport const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin')\n\nexport const offAppShow: typeof Taro.offAppShow = callback => {\n appShowCallbackManager.remove(callback)\n if (appShowCallbackManager.count() === 0) {\n window.removeEventListener('visibilitychange', appShowListener)\n }\n}\n\nexport const offAppHide: typeof Taro.offAppHide = callback => {\n appHideCallbackManager.remove(callback)\n if (appHideCallbackManager.count() === 0) {\n window.removeEventListener('visibilit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MAC1E,yBAAyB,GAAG,qBAAqB,CAAC,2BAA2B,EAAC;AAE9E,MAAA,UAAU,GAA2B,QAAQ,IAAG;AAC3D,IAAA,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACvC,IAAA,IAAI,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAA;AAChE,KAAA;AACH,EAAC;AAEY,MAAA,UAAU,GAA2B,QAAQ,IAAG;AAC3D,IAAA,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACvC,IAAA,IAAI,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;AACxC,QAAA,MAAM,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAA;AAChE,KAAA;AACH;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
2
|
declare const getApp: typeof Taro.getApp;
|
|
3
|
-
declare const getCurrentInstance: () => Taro.Current;
|
|
3
|
+
declare const getCurrentInstance: () => Taro.getCurrentInstance.Current;
|
|
4
4
|
export { getApp, getCurrentInstance };
|
|
5
5
|
export { getCurrentPages } from '@tarojs/router';
|
package/dist/api/taro.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
2
|
import { history } from '@tarojs/router';
|
|
3
|
-
declare const Behavior: any, getEnv: any, ENV_TYPE: any, Link: any, interceptors: any, Current: any, options: any, eventCenter: any, Events: any, preload: any;
|
|
3
|
+
declare const Behavior: any, getEnv: any, ENV_TYPE: any, Link: any, interceptors: any, interceptorify: any, Current: any, options: any, eventCenter: any, Events: any, preload: any;
|
|
4
4
|
declare const taro: typeof Taro;
|
|
5
5
|
declare const requirePlugin: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
6
6
|
declare const initPxTransform: ({ designWidth, deviceRatio, baseFontSize, unitPrecision, targetUnit }: {
|
|
@@ -12,4 +12,9 @@ declare const initPxTransform: ({ designWidth, deviceRatio, baseFontSize, unitPr
|
|
|
12
12
|
}) => void;
|
|
13
13
|
declare const pxTransform: (size?: number) => any;
|
|
14
14
|
declare const canIUseWebp: () => boolean;
|
|
15
|
-
|
|
15
|
+
declare const getAppInfo: () => {
|
|
16
|
+
platform: string;
|
|
17
|
+
taroVersion: string;
|
|
18
|
+
designWidth: any;
|
|
19
|
+
};
|
|
20
|
+
export { taro as default, Behavior, canIUseWebp, Current, ENV_TYPE, eventCenter, Events, getAppInfo, getEnv, history, initPxTransform, interceptorify, interceptors, Link, options, preload, pxTransform, requirePlugin };
|
package/dist/api/taro.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
2
|
import { history, navigateBack, navigateTo, reLaunch, redirectTo, getCurrentPages, switchTab } from '@tarojs/router';
|
|
3
3
|
export { history } from '@tarojs/router';
|
|
4
|
-
import { isFunction } from '@tarojs/shared';
|
|
4
|
+
import { isFunction, PLATFORM_TYPE } from '@tarojs/shared';
|
|
5
5
|
import './index.js';
|
|
6
6
|
import { permanentlyNotSupport } from '../utils/index.js';
|
|
7
7
|
import { getCurrentInstance, getApp } from './framework/index.js';
|
|
8
8
|
import { nextTick } from './ui/custom-component.js';
|
|
9
9
|
|
|
10
|
-
const { Behavior, getEnv, ENV_TYPE, Link, interceptors, Current, options, eventCenter, Events, preload } = Taro;
|
|
10
|
+
const { Behavior, getEnv, ENV_TYPE, Link, interceptors, interceptorify, Current, options, eventCenter, Events, preload } = Taro;
|
|
11
11
|
const taro = {
|
|
12
12
|
// @ts-ignore
|
|
13
13
|
Behavior,
|
|
@@ -15,6 +15,7 @@ const taro = {
|
|
|
15
15
|
ENV_TYPE,
|
|
16
16
|
Link,
|
|
17
17
|
interceptors,
|
|
18
|
+
interceptorify,
|
|
18
19
|
Current,
|
|
19
20
|
getCurrentInstance,
|
|
20
21
|
options,
|
|
@@ -82,11 +83,19 @@ const canIUseWebp = function () {
|
|
|
82
83
|
const canvas = document.createElement('canvas');
|
|
83
84
|
return canvas.toDataURL('image/webp').indexOf('data:image/webp') === 0;
|
|
84
85
|
};
|
|
86
|
+
const getAppInfo = function () {
|
|
87
|
+
const config = getConfig.call(this);
|
|
88
|
+
return {
|
|
89
|
+
platform: process.env.TARO_PLATFORM || PLATFORM_TYPE.WEB,
|
|
90
|
+
taroVersion: process.env.TARO_VERSION || 'unknown',
|
|
91
|
+
designWidth: config.designWidth,
|
|
92
|
+
};
|
|
93
|
+
};
|
|
85
94
|
taro.requirePlugin = requirePlugin;
|
|
86
95
|
taro.getApp = getApp;
|
|
87
96
|
taro.pxTransform = pxTransform;
|
|
88
97
|
taro.initPxTransform = initPxTransform;
|
|
89
98
|
taro.canIUseWebp = canIUseWebp;
|
|
90
99
|
|
|
91
|
-
export { Behavior, Current, ENV_TYPE, Events, Link, canIUseWebp, taro as default, eventCenter, getEnv, initPxTransform, interceptors, options, preload, pxTransform, requirePlugin };
|
|
100
|
+
export { Behavior, Current, ENV_TYPE, Events, Link, canIUseWebp, taro as default, eventCenter, getAppInfo, getEnv, initPxTransform, interceptorify, interceptors, options, preload, pxTransform, requirePlugin };
|
|
92
101
|
//# sourceMappingURL=taro.js.map
|
package/dist/api/taro.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taro.js","sources":["../../src/api/taro.ts"],"sourcesContent":["import Taro from '@tarojs/api'\nimport { history } from '@tarojs/router'\nimport { isFunction } from '@tarojs/shared'\n\nimport { getApp, getCurrentInstance, getCurrentPages, navigateBack, navigateTo, nextTick, redirectTo, reLaunch, switchTab } from '../api'\nimport { permanentlyNotSupport } from '../utils'\n\nconst {\n Behavior,\n getEnv,\n ENV_TYPE,\n Link,\n interceptors,\n Current,\n options,\n eventCenter,\n Events,\n preload\n} = Taro as any\n\nconst taro: typeof Taro = {\n // @ts-ignore\n Behavior,\n getEnv,\n ENV_TYPE,\n Link,\n interceptors,\n Current,\n getCurrentInstance,\n options,\n nextTick,\n eventCenter,\n Events,\n preload,\n history,\n navigateBack,\n navigateTo,\n reLaunch,\n redirectTo,\n getCurrentPages,\n switchTab\n}\n\nconst requirePlugin = permanentlyNotSupport('requirePlugin')\n\nfunction getConfig (): Record<string, any> {\n if (this?.pxTransformConfig) return this.pxTransformConfig\n return ((taro as any).config ||= {})\n}\n\nconst initPxTransform = function ({\n designWidth = 750,\n deviceRatio = {\n 640: 2.34 / 2,\n 750: 1,\n 828: 1.81 / 2\n } as TaroGeneral.TDeviceRatio,\n baseFontSize = 20,\n unitPrecision = 5,\n targetUnit = 'rem'\n}) {\n const config = getConfig.call(this)\n config.designWidth = designWidth\n config.deviceRatio = deviceRatio\n config.baseFontSize = baseFontSize\n config.targetUnit = targetUnit\n config.unitPrecision = unitPrecision\n}\n\nconst pxTransform = function (size = 0) {\n const config = getConfig.call(this)\n const baseFontSize = config.baseFontSize || 20\n const designWidth = (((input = 0) => isFunction(config.designWidth)\n ? config.designWidth(input)\n : config.designWidth))(size)\n if (!(designWidth in config.deviceRatio)) {\n throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)\n }\n const formatSize = ~~size\n let rootValue = 1 / config.deviceRatio[designWidth]\n switch (config?.targetUnit) {\n case 'vw':\n rootValue = designWidth / 100\n break\n case 'px':\n rootValue *= 2\n break\n default:\n // rem\n rootValue *= baseFontSize * 2\n }\n let val: number | string = formatSize / rootValue\n if (config.unitPrecision >= 0 && config.unitPrecision <= 100) {\n // Number(val): 0.50000 => 0.5\n val = Number(val.toFixed(config.unitPrecision))\n }\n return val + config?.targetUnit\n}\n\nconst canIUseWebp = function () {\n const canvas = document.createElement('canvas')\n return canvas.toDataURL('image/webp').indexOf('data:image/webp') === 0\n}\n\ntaro.requirePlugin = requirePlugin\ntaro.getApp = getApp\ntaro.pxTransform = pxTransform\ntaro.initPxTransform = initPxTransform\ntaro.canIUseWebp = canIUseWebp\n\nexport default taro\n\nexport {\n Behavior,\n canIUseWebp,\n Current,\n ENV_TYPE,\n eventCenter,\n Events,\n getEnv,\n history,\n initPxTransform,\n interceptors,\n Link,\n options,\n preload,\n pxTransform,\n requirePlugin\n}\n"],"names":[],"mappings":";;;;;;;;;AAOM,MAAA,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,OAAO,EACP,WAAW,EACX,MAAM,EACN,OAAO,EACR,GAAG,KAAW;AAEf,MAAM,IAAI,GAAgB;;IAExB,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,OAAO;IACP,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,WAAW;IACX,MAAM;IACN,OAAO;IACP,OAAO;IACP,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,UAAU;IACV,eAAe;IACf,SAAS;EACV;AAED,MAAM,aAAa,GAAG,qBAAqB,CAAC,eAAe,EAAC;AAE5D,SAAS,SAAS,GAAA;;AAChB,IAAA,IAAI,IAAI,KAAJ,IAAA,IAAA,IAAI,KAAJ,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,IAAI,CAAE,iBAAiB;QAAE,OAAO,IAAI,CAAC,iBAAiB,CAAA;IAC1D,QAAO,CAAA,EAAA,GAAE,IAAY,EAAC,MAAM,QAAN,MAAM,GAAK,EAAE,CAAA,EAAC;AACtC,CAAC;AAEK,MAAA,eAAe,GAAG,UAAU,EAChC,WAAW,GAAG,GAAG,EACjB,WAAW,GAAG;IACZ,GAAG,EAAE,IAAI,GAAG,CAAC;AACb,IAAA,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,IAAI,GAAG,CAAC;CACc,EAC7B,YAAY,GAAG,EAAE,EACjB,aAAa,GAAG,CAAC,EACjB,UAAU,GAAG,KAAK,EACnB,EAAA;IACC,MAAM,MAAM,GAA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,GAAG,CAAC,CAAA;AAChC,KAAA;AACD,IAAA,IAAI,GAAG,GAAoB,UAAU,GAAG,SAAS,CAAA;IACjD,IAAI,MAAM,CAAC,aAAa,IAAI,CAAC,IAAI,MAAM,CAAC,aAAa,IAAI,GAAG,EAAE;;AAE5D,QAAA,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAA;AAChD,KAAA;IACD,OAAO,GAAG,IAAG,MAAM,KAAN,IAAA,IAAA,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAA,CAAA;AACjC,EAAC;AAED,MAAM,WAAW,GAAG,YAAA;IAClB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;AAC/C,IAAA,OAAO,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;AACxE,EAAC;AAED,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;AAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;AACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;AAC9B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;AACtC,IAAI,CAAC,WAAW,GAAG,WAAW;;;;"}
|
|
1
|
+
{"version":3,"file":"taro.js","sources":["../../src/api/taro.ts"],"sourcesContent":["import Taro from '@tarojs/api'\nimport { history } from '@tarojs/router'\nimport { isFunction, PLATFORM_TYPE } from '@tarojs/shared'\n\nimport { getApp, getCurrentInstance, getCurrentPages, navigateBack, navigateTo, nextTick, redirectTo, reLaunch, switchTab } from '../api'\nimport { permanentlyNotSupport } from '../utils'\n\nconst {\n Behavior,\n getEnv,\n ENV_TYPE,\n Link,\n interceptors,\n interceptorify,\n Current,\n options,\n eventCenter,\n Events,\n preload\n} = Taro as any\n\nconst taro: typeof Taro = {\n // @ts-ignore\n Behavior,\n getEnv,\n ENV_TYPE,\n Link,\n interceptors,\n interceptorify,\n Current,\n getCurrentInstance,\n options,\n nextTick,\n eventCenter,\n Events,\n preload,\n history,\n navigateBack,\n navigateTo,\n reLaunch,\n redirectTo,\n getCurrentPages,\n switchTab\n}\n\nconst requirePlugin = permanentlyNotSupport('requirePlugin')\n\nfunction getConfig (): Record<string, any> {\n if (this?.pxTransformConfig) return this.pxTransformConfig\n return ((taro as any).config ||= {})\n}\n\nconst initPxTransform = function ({\n designWidth = 750,\n deviceRatio = {\n 640: 2.34 / 2,\n 750: 1,\n 828: 1.81 / 2\n } as TaroGeneral.TDeviceRatio,\n baseFontSize = 20,\n unitPrecision = 5,\n targetUnit = 'rem'\n}) {\n const config = getConfig.call(this)\n config.designWidth = designWidth\n config.deviceRatio = deviceRatio\n config.baseFontSize = baseFontSize\n config.targetUnit = targetUnit\n config.unitPrecision = unitPrecision\n}\n\nconst pxTransform = function (size = 0) {\n const config = getConfig.call(this)\n const baseFontSize = config.baseFontSize || 20\n const designWidth = (((input = 0) => isFunction(config.designWidth)\n ? config.designWidth(input)\n : config.designWidth))(size)\n if (!(designWidth in config.deviceRatio)) {\n throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)\n }\n const formatSize = ~~size\n let rootValue = 1 / config.deviceRatio[designWidth]\n switch (config?.targetUnit) {\n case 'vw':\n rootValue = designWidth / 100\n break\n case 'px':\n rootValue *= 2\n break\n default:\n // rem\n rootValue *= baseFontSize * 2\n }\n let val: number | string = formatSize / rootValue\n if (config.unitPrecision >= 0 && config.unitPrecision <= 100) {\n // Number(val): 0.50000 => 0.5\n val = Number(val.toFixed(config.unitPrecision))\n }\n return val + config?.targetUnit\n}\n\nconst canIUseWebp = function () {\n const canvas = document.createElement('canvas')\n return canvas.toDataURL('image/webp').indexOf('data:image/webp') === 0\n}\n\nconst getAppInfo = function () {\n const config = getConfig.call(this)\n return {\n platform: process.env.TARO_PLATFORM || PLATFORM_TYPE.WEB,\n taroVersion: process.env.TARO_VERSION || 'unknown',\n designWidth: config.designWidth,\n }\n}\n\ntaro.requirePlugin = requirePlugin\ntaro.getApp = getApp\ntaro.pxTransform = pxTransform\ntaro.initPxTransform = initPxTransform\ntaro.canIUseWebp = canIUseWebp\n\nexport default taro\n\nexport {\n Behavior,\n canIUseWebp,\n Current,\n ENV_TYPE,\n eventCenter,\n Events,\n getAppInfo,\n getEnv,\n history,\n initPxTransform,\n interceptorify,\n interceptors,\n Link,\n options,\n preload,\n pxTransform,\n requirePlugin\n}\n"],"names":[],"mappings":";;;;;;;;;AAOM,MAAA,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,cAAc,EACd,OAAO,EACP,OAAO,EACP,WAAW,EACX,MAAM,EACN,OAAO,EACR,GAAG,KAAW;AAEf,MAAM,IAAI,GAAgB;;IAExB,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,cAAc;IACd,OAAO;IACP,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,WAAW;IACX,MAAM;IACN,OAAO;IACP,OAAO;IACP,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,UAAU;IACV,eAAe;IACf,SAAS;EACV;AAED,MAAM,aAAa,GAAG,qBAAqB,CAAC,eAAe,EAAC;AAE5D,SAAS,SAAS,GAAA;;AAChB,IAAA,IAAI,IAAI,KAAJ,IAAA,IAAA,IAAI,KAAJ,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,IAAI,CAAE,iBAAiB;QAAE,OAAO,IAAI,CAAC,iBAAiB,CAAA;IAC1D,QAAO,CAAA,EAAA,GAAE,IAAY,EAAC,MAAM,QAAN,MAAM,GAAK,EAAE,CAAA,EAAC;AACtC,CAAC;AAEK,MAAA,eAAe,GAAG,UAAU,EAChC,WAAW,GAAG,GAAG,EACjB,WAAW,GAAG;IACZ,GAAG,EAAE,IAAI,GAAG,CAAC;AACb,IAAA,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,IAAI,GAAG,CAAC;C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index.cjs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Taro from "@tarojs/api";
|
|
2
2
|
import { AppConfig } from "@tarojs/api";
|
|
3
3
|
import { history } from "@tarojs/router";
|
|
4
|
-
declare const Behavior: any, getEnv: any, ENV_TYPE: any, Link: any, interceptors: any, Current: any, options: any, eventCenter: any, Events: any, preload: any;
|
|
4
|
+
declare const Behavior: any, getEnv: any, ENV_TYPE: any, Link: any, interceptors: any, interceptorify: any, Current: any, options: any, eventCenter: any, Events: any, preload: any;
|
|
5
5
|
declare const taro: typeof Taro;
|
|
6
6
|
declare const requirePlugin: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
7
7
|
declare const initPxTransform: ({ designWidth, deviceRatio, baseFontSize, unitPrecision, targetUnit }: {
|
|
@@ -13,6 +13,11 @@ declare const initPxTransform: ({ designWidth, deviceRatio, baseFontSize, unitPr
|
|
|
13
13
|
}) => void;
|
|
14
14
|
declare const pxTransform: (size?: number) => any;
|
|
15
15
|
declare const canIUseWebp: () => boolean;
|
|
16
|
+
declare const getAppInfo: () => {
|
|
17
|
+
platform: string;
|
|
18
|
+
taroVersion: string;
|
|
19
|
+
designWidth: any;
|
|
20
|
+
};
|
|
16
21
|
// 广告
|
|
17
22
|
declare const createRewardedVideoAd: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
18
23
|
declare const createInterstitialAd: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
@@ -67,22 +72,22 @@ declare const getSystemInfo: typeof Taro.getSystemInfo;
|
|
|
67
72
|
declare const updateWeChatApp: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
68
73
|
declare const getUpdateManager: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
69
74
|
// 应用级事件
|
|
70
|
-
declare const onUnhandledRejection:
|
|
71
|
-
declare const onThemeChange:
|
|
72
|
-
declare const onPageNotFound:
|
|
73
|
-
declare const onError:
|
|
75
|
+
declare const onUnhandledRejection: typeof Taro.onUnhandledRejection;
|
|
76
|
+
declare const onThemeChange: typeof Taro.onThemeChange;
|
|
77
|
+
declare const onPageNotFound: typeof Taro.onPageNotFound;
|
|
78
|
+
declare const onError: typeof Taro.onError;
|
|
74
79
|
declare const onAudioInterruptionEnd: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
75
80
|
declare const onAudioInterruptionBegin: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
76
81
|
declare const onAppShow: typeof Taro.onAppShow;
|
|
77
82
|
declare const onAppHide: typeof Taro.onAppHide;
|
|
78
|
-
declare const offUnhandledRejection:
|
|
79
|
-
declare const offThemeChange:
|
|
80
|
-
declare const offPageNotFound:
|
|
81
|
-
declare const offError:
|
|
83
|
+
declare const offUnhandledRejection: typeof Taro.offUnhandledRejection;
|
|
84
|
+
declare const offThemeChange: typeof Taro.offThemeChange;
|
|
85
|
+
declare const offPageNotFound: typeof Taro.offPageNotFound;
|
|
86
|
+
declare const offError: typeof Taro.offError;
|
|
82
87
|
declare const offAudioInterruptionEnd: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
83
88
|
declare const offAudioInterruptionBegin: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
84
|
-
declare const offAppShow: typeof Taro.
|
|
85
|
-
declare const offAppHide: typeof Taro.
|
|
89
|
+
declare const offAppShow: typeof Taro.offAppShow;
|
|
90
|
+
declare const offAppHide: typeof Taro.offAppHide;
|
|
86
91
|
// 生命周期
|
|
87
92
|
declare const getLaunchOptionsSync: typeof Taro.getLaunchOptionsSync;
|
|
88
93
|
declare const getEnterOptionsSync: typeof Taro.getEnterOptionsSync;
|
|
@@ -323,7 +328,7 @@ declare const getFileSystemManager: (option?: {}, ...args: any[]) => Promise<Par
|
|
|
323
328
|
declare const getFileInfo: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
324
329
|
declare const getApp: typeof Taro.getApp;
|
|
325
330
|
// 自定义组件
|
|
326
|
-
declare const getCurrentInstance: () => Taro.Current;
|
|
331
|
+
declare const getCurrentInstance: () => Taro.getCurrentInstance.Current;
|
|
327
332
|
// 位置
|
|
328
333
|
declare const stopLocationUpdate: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
329
334
|
declare const startLocationUpdateBackground: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
@@ -355,36 +360,23 @@ declare const createMediaAudioPlayer: (option?: {}, ...args: any[]) => Promise<P
|
|
|
355
360
|
*/
|
|
356
361
|
declare const createInnerAudioContext: typeof Taro.createInnerAudioContext;
|
|
357
362
|
declare const createAudioContext: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
358
|
-
type
|
|
359
|
-
interface ICallbackManagerOption {
|
|
360
|
-
callback?:
|
|
363
|
+
type TCallbackManagerFunc<T extends unknown[] = unknown[]> = (...arr: T) => void;
|
|
364
|
+
interface ICallbackManagerOption<T extends unknown[] = unknown[]> {
|
|
365
|
+
callback?: TCallbackManagerFunc<T>;
|
|
361
366
|
ctx?: any;
|
|
362
367
|
[key: string]: unknown;
|
|
363
368
|
}
|
|
364
|
-
type
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
add: (opt?: TCallbackManagerListItem) => void;
|
|
373
|
-
/**
|
|
374
|
-
* 移除回调
|
|
375
|
-
* @param {{ callback: function, ctx: any } | function} opt
|
|
376
|
-
*/
|
|
377
|
-
remove: (opt?: TCallbackManagerListItem) => void;
|
|
378
|
-
/**
|
|
379
|
-
* 获取回调函数数量
|
|
380
|
-
* @return {number}
|
|
381
|
-
*/
|
|
369
|
+
type TCallbackManagerUnit<T extends unknown[] = unknown[]> = (TCallbackManagerFunc<T> | ICallbackManagerOption<T>);
|
|
370
|
+
declare class CallbackManager<T extends unknown[] = unknown[]> {
|
|
371
|
+
callbacks: TCallbackManagerUnit<T>[];
|
|
372
|
+
/** 添加回调 */
|
|
373
|
+
add: (opt?: TCallbackManagerUnit<T>) => void;
|
|
374
|
+
/** 移除回调 */
|
|
375
|
+
remove: (opt?: TCallbackManagerUnit<T>) => void;
|
|
376
|
+
/** 获取回调函数数量 */
|
|
382
377
|
count: () => number;
|
|
383
|
-
/**
|
|
384
|
-
|
|
385
|
-
* @param {...any} args 回调的调用参数
|
|
386
|
-
*/
|
|
387
|
-
trigger: (...args: TCallbackManagerList) => void;
|
|
378
|
+
/** 触发回调 */
|
|
379
|
+
trigger: (...args: T) => void;
|
|
388
380
|
}
|
|
389
381
|
declare class BackgroundAudioManager implements Taro.BackgroundAudioManager {
|
|
390
382
|
Instance?: HTMLAudioElement;
|
|
@@ -771,5 +763,5 @@ declare const createWorker: (option?: {}, ...args: any[]) => Promise<Partial<Tar
|
|
|
771
763
|
declare const createSelectorQuery: typeof Taro.createSelectorQuery;
|
|
772
764
|
declare const createIntersectionObserver: typeof Taro.createIntersectionObserver;
|
|
773
765
|
declare const createMediaQueryObserver: typeof Taro.createMediaQueryObserver;
|
|
774
|
-
export { taro as default, taro, createRewardedVideoAd, createInterstitialAd, stopFaceDetect, initFaceDetect, faceDetect, isVKSupport, createVKSession, getOpenUserInfo, env, canIUse, arrayBufferToBase64, base64ToArrayBuffer, getUserCryptoManager, setEnableDebug, getRealtimeLogManager, getLogManager, reportPerformance, getPerformance, openSystemBluetoothSetting, openAppAuthorizeSetting, getWindowInfo, getSystemSetting, getDeviceInfo, getAppBaseInfo, getAppAuthorizeSetting, getSystemInfoSync, getSystemInfoAsync, getSystemInfo, updateWeChatApp, getUpdateManager, onUnhandledRejection, onThemeChange, onPageNotFound, onError, onAudioInterruptionEnd, onAudioInterruptionBegin, onAppShow, onAppHide, offUnhandledRejection, offThemeChange, offPageNotFound, offError, offAudioInterruptionEnd, offAudioInterruptionBegin, offAppShow, offAppHide, getLaunchOptionsSync, getEnterOptionsSync, createOffscreenCanvas, createCanvasContext, canvasToTempFilePath, canvasPutImageData, canvasGetImageData, cloud, reportMonitor, reportAnalytics, reportEvent, getExptInfoSync, stopAccelerometer, startAccelerometer, onAccelerometerChange, offAccelerometerChange, checkIsOpenAccessibility, getBatteryInfoSync, getBatteryInfo, stopBluetoothDevicesDiscovery, startBluetoothDevicesDiscovery, openBluetoothAdapter, onBluetoothDeviceFound, onBluetoothAdapterStateChange, offBluetoothDeviceFound, offBluetoothAdapterStateChange, makeBluetoothPair, isBluetoothDevicePaired, getConnectedBluetoothDevices, getBluetoothDevices, getBluetoothAdapterState, closeBluetoothAdapter, writeBLECharacteristicValue, setBLEMTU, readBLECharacteristicValue, onBLEMTUChange, onBLEConnectionStateChange, onBLECharacteristicValueChange, offBLEMTUChange, offBLEConnectionStateChange, offBLECharacteristicValueChange, notifyBLECharacteristicValueChange, getBLEMTU, getBLEDeviceServices, getBLEDeviceRSSI, getBLEDeviceCharacteristics, createBLEConnection, closeBLEConnection, onBLEPeripheralConnectionStateChanged, offBLEPeripheralConnectionStateChanged, createBLEPeripheralServer, addPhoneRepeatCalendar, addPhoneCalendar, setClipboardData, getClipboardData, stopCompass, startCompass, onCompassChange, offCompassChange, chooseContact, addPhoneContact, getRandomValues, stopGyroscope, startGyroscope, onGyroscopeChange, offGyroscopeChange, stopBeaconDiscovery, startBeaconDiscovery, onBeaconUpdate, onBeaconServiceChange, offBeaconUpdate, offBeaconServiceChange, getBeacons, onKeyboardHeightChange, offKeyboardHeightChange, hideKeyboard, getSelectedTextRange, onMemoryWarning, offMemoryWarning, stopDeviceMotionListening, startDeviceMotionListening, onDeviceMotionChange, offDeviceMotionChange, getNetworkType, onNetworkWeakChange, onNetworkStatusChange, offNetworkWeakChange, offNetworkStatusChange, getLocalIPAddress, stopHCE, startHCE, sendHCEMessage, onHCEMessage, offHCEMessage, getNFCAdapter, getHCEState, makePhoneCall, scanCode, setVisualEffectOnCapture, setScreenBrightness, setKeepScreenOn, onUserCaptureScreen, offUserCaptureScreen, getScreenBrightness, vibrateShort, vibrateLong, stopWifi, startWifi, setWifiList, onWifiConnectedWithPartialInfo, onWifiConnected, onGetWifiList, offWifiConnected, offGetWifiList, getWifiList, getConnectedWifi, connectWifi, getExtConfigSync, getExtConfig, saveFileToDisk, saveFile, removeSavedFile, openDocument, getSavedFileList, getSavedFileInfo, getFileSystemManager, getFileInfo, getApp, getCurrentInstance, stopLocationUpdate, startLocationUpdateBackground, startLocationUpdate, openLocation, onLocationChangeError, onLocationChange, offLocationChangeError, offLocationChange, getLocation, choosePoi, getFuzzyLocation, chooseLocation, stopVoice, setInnerAudioOption, playVoice, pauseVoice, getAvailableAudioSources, createWebAudioContext, createMediaAudioPlayer, createInnerAudioContext, createAudioContext, stopBackgroundAudio, seekBackgroundAudio, playBackgroundAudio, pauseBackgroundAudio, onBackgroundAudioStop, onBackgroundAudioPlay, onBackgroundAudioPause, getBackgroundAudioPlayerState, getBackgroundAudioManager, createCameraContext, saveImageToPhotosAlbum, previewMedia, getImageInfo, previewImage, compressImage, chooseMessageFile, chooseImage, createLivePusherContext, createLivePlayerContext, createMapContext, createMediaRecorder, stopRecord, startRecord, getRecorderManager, saveVideoToPhotosAlbum, openVideoEditor, getVideoInfo, createVideoContext, compressVideo, chooseVideo, chooseMedia, createVideoDecoder, createMediaContainer, updateVoIPChatMuteConfig, subscribeVoIPVideoMembers, setEnable1v1Chat, onVoIPVideoMembersChanged, onVoIPChatStateChanged, onVoIPChatSpeakersChanged, onVoIPChatMembersChanged, onVoIPChatInterrupted, offVoIPVideoMembersChanged, offVoIPChatStateChanged, offVoIPChatMembersChanged, offVoIPChatInterrupted, joinVoIPChat, exitVoIPChat, openEmbeddedMiniProgram, navigateToMiniProgram, navigateBackMiniProgram, exitMiniProgram, openBusinessView, downloadFile, stopLocalServiceDiscovery, startLocalServiceDiscovery, onLocalServiceResolveFail, onLocalServiceLost, onLocalServiceFound, onLocalServiceDiscoveryStop, offLocalServiceResolveFail, offLocalServiceLost, offLocalServiceFound, offLocalServiceDiscoveryStop, request, addInterceptor, cleanInterceptors, createTCPSocket, createUDPSocket, uploadFile, sendSocketMessage, onSocketOpen, onSocketMessage, onSocketError, onSocketClose, connectSocket, closeSocket, getAccountInfoSync, chooseAddress, authorizeForMiniProgram, authorize, openCard, addCard, reserveChannelsLive, openChannelsLive, openChannelsEvent, openChannelsActivity, getChannelsLiveNoticeInfo, getChannelsLiveInfo, openCustomerServiceChat, checkIsSupportFacialRecognition, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, faceVerifyForPay, addVideoToFavorites, addFileToFavorites, checkIsAddedToMyMiniProgram, getGroupEnterInfo, chooseInvoiceTitle, chooseInvoice, chooseLicensePlate, pluginLogin, login, checkSession, showRedPackage, openSetting, getSetting, startSoterAuthentication, checkIsSupportSoterAuthentication, checkIsSoterEnrolledInDevice, requestSubscribeMessage, getUserProfile, getUserInfo, shareToWeRun, getWeRunData, requestPayment, requestOrderPayment, updateShareMenu, showShareMenu, showShareImageMenu, shareVideoMessage, shareFileMessage, onCopyUrl, offCopyUrl, hideShareMenu, getShareInfo, authPrivateMessage, setStorageSync, setStorage, revokeBufferURL, removeStorageSync, removeStorage, getStorageSync, getStorageInfoSync, getStorageInfo, getStorage, createBufferURL, clearStorageSync, clearStorage, setBackgroundFetchToken, onBackgroundFetchData, getBackgroundFetchToken, getBackgroundFetchData, setPageInfo, ocrIdCard, ocrBankCard, ocrDrivingLicense, ocrVehicleLicense, textReview, textToAudio, imageAudit, advancedGeneralIdentify, objectDetectIdentify, carClassify, dishClassify, logoClassify, animalClassify, plantClassify, getSwanId, requestPolymerPayment, navigateToSmartGameProgram, navigateToSmartProgram, navigateBackSmartProgram, preloadSubPackage, createAnimation, setBackgroundTextStyle, setBackgroundColor, nextTick, loadFontFace, disableAlertBeforeUnload, enableAlertBeforeUnload, hideLoading, hideToast, showActionSheet, showLoading, showModal, showToast, getMenuButtonBoundingClientRect, showNavigationBarLoading, setNavigationBarTitle, setNavigationBarColor, hideNavigationBarLoading, hideHomeButton, startPullDownRefresh, stopPullDownRefresh, pageScrollTo, setTopBarText, initTabBarApis, showTabBarRedDot, showTabBar, setTabBarStyle, setTabBarItem, setTabBarBadge, removeTabBarBadge, hideTabBarRedDot, hideTabBar, setWindowSize, onWindowResize, offWindowResize, createWorker, createSelectorQuery, createIntersectionObserver, createMediaQueryObserver, Behavior, canIUseWebp, Current, ENV_TYPE, eventCenter, Events, getEnv, history, initPxTransform, interceptors, Link, options, preload, pxTransform, requirePlugin };
|
|
766
|
+
export { taro as default, taro, createRewardedVideoAd, createInterstitialAd, stopFaceDetect, initFaceDetect, faceDetect, isVKSupport, createVKSession, getOpenUserInfo, env, canIUse, arrayBufferToBase64, base64ToArrayBuffer, getUserCryptoManager, setEnableDebug, getRealtimeLogManager, getLogManager, reportPerformance, getPerformance, openSystemBluetoothSetting, openAppAuthorizeSetting, getWindowInfo, getSystemSetting, getDeviceInfo, getAppBaseInfo, getAppAuthorizeSetting, getSystemInfoSync, getSystemInfoAsync, getSystemInfo, updateWeChatApp, getUpdateManager, onUnhandledRejection, onThemeChange, onPageNotFound, onError, onAudioInterruptionEnd, onAudioInterruptionBegin, onAppShow, onAppHide, offUnhandledRejection, offThemeChange, offPageNotFound, offError, offAudioInterruptionEnd, offAudioInterruptionBegin, offAppShow, offAppHide, getLaunchOptionsSync, getEnterOptionsSync, createOffscreenCanvas, createCanvasContext, canvasToTempFilePath, canvasPutImageData, canvasGetImageData, cloud, reportMonitor, reportAnalytics, reportEvent, getExptInfoSync, stopAccelerometer, startAccelerometer, onAccelerometerChange, offAccelerometerChange, checkIsOpenAccessibility, getBatteryInfoSync, getBatteryInfo, stopBluetoothDevicesDiscovery, startBluetoothDevicesDiscovery, openBluetoothAdapter, onBluetoothDeviceFound, onBluetoothAdapterStateChange, offBluetoothDeviceFound, offBluetoothAdapterStateChange, makeBluetoothPair, isBluetoothDevicePaired, getConnectedBluetoothDevices, getBluetoothDevices, getBluetoothAdapterState, closeBluetoothAdapter, writeBLECharacteristicValue, setBLEMTU, readBLECharacteristicValue, onBLEMTUChange, onBLEConnectionStateChange, onBLECharacteristicValueChange, offBLEMTUChange, offBLEConnectionStateChange, offBLECharacteristicValueChange, notifyBLECharacteristicValueChange, getBLEMTU, getBLEDeviceServices, getBLEDeviceRSSI, getBLEDeviceCharacteristics, createBLEConnection, closeBLEConnection, onBLEPeripheralConnectionStateChanged, offBLEPeripheralConnectionStateChanged, createBLEPeripheralServer, addPhoneRepeatCalendar, addPhoneCalendar, setClipboardData, getClipboardData, stopCompass, startCompass, onCompassChange, offCompassChange, chooseContact, addPhoneContact, getRandomValues, stopGyroscope, startGyroscope, onGyroscopeChange, offGyroscopeChange, stopBeaconDiscovery, startBeaconDiscovery, onBeaconUpdate, onBeaconServiceChange, offBeaconUpdate, offBeaconServiceChange, getBeacons, onKeyboardHeightChange, offKeyboardHeightChange, hideKeyboard, getSelectedTextRange, onMemoryWarning, offMemoryWarning, stopDeviceMotionListening, startDeviceMotionListening, onDeviceMotionChange, offDeviceMotionChange, getNetworkType, onNetworkWeakChange, onNetworkStatusChange, offNetworkWeakChange, offNetworkStatusChange, getLocalIPAddress, stopHCE, startHCE, sendHCEMessage, onHCEMessage, offHCEMessage, getNFCAdapter, getHCEState, makePhoneCall, scanCode, setVisualEffectOnCapture, setScreenBrightness, setKeepScreenOn, onUserCaptureScreen, offUserCaptureScreen, getScreenBrightness, vibrateShort, vibrateLong, stopWifi, startWifi, setWifiList, onWifiConnectedWithPartialInfo, onWifiConnected, onGetWifiList, offWifiConnected, offGetWifiList, getWifiList, getConnectedWifi, connectWifi, getExtConfigSync, getExtConfig, saveFileToDisk, saveFile, removeSavedFile, openDocument, getSavedFileList, getSavedFileInfo, getFileSystemManager, getFileInfo, getApp, getCurrentInstance, stopLocationUpdate, startLocationUpdateBackground, startLocationUpdate, openLocation, onLocationChangeError, onLocationChange, offLocationChangeError, offLocationChange, getLocation, choosePoi, getFuzzyLocation, chooseLocation, stopVoice, setInnerAudioOption, playVoice, pauseVoice, getAvailableAudioSources, createWebAudioContext, createMediaAudioPlayer, createInnerAudioContext, createAudioContext, stopBackgroundAudio, seekBackgroundAudio, playBackgroundAudio, pauseBackgroundAudio, onBackgroundAudioStop, onBackgroundAudioPlay, onBackgroundAudioPause, getBackgroundAudioPlayerState, getBackgroundAudioManager, createCameraContext, saveImageToPhotosAlbum, previewMedia, getImageInfo, previewImage, compressImage, chooseMessageFile, chooseImage, createLivePusherContext, createLivePlayerContext, createMapContext, createMediaRecorder, stopRecord, startRecord, getRecorderManager, saveVideoToPhotosAlbum, openVideoEditor, getVideoInfo, createVideoContext, compressVideo, chooseVideo, chooseMedia, createVideoDecoder, createMediaContainer, updateVoIPChatMuteConfig, subscribeVoIPVideoMembers, setEnable1v1Chat, onVoIPVideoMembersChanged, onVoIPChatStateChanged, onVoIPChatSpeakersChanged, onVoIPChatMembersChanged, onVoIPChatInterrupted, offVoIPVideoMembersChanged, offVoIPChatStateChanged, offVoIPChatMembersChanged, offVoIPChatInterrupted, joinVoIPChat, exitVoIPChat, openEmbeddedMiniProgram, navigateToMiniProgram, navigateBackMiniProgram, exitMiniProgram, openBusinessView, downloadFile, stopLocalServiceDiscovery, startLocalServiceDiscovery, onLocalServiceResolveFail, onLocalServiceLost, onLocalServiceFound, onLocalServiceDiscoveryStop, offLocalServiceResolveFail, offLocalServiceLost, offLocalServiceFound, offLocalServiceDiscoveryStop, request, addInterceptor, cleanInterceptors, createTCPSocket, createUDPSocket, uploadFile, sendSocketMessage, onSocketOpen, onSocketMessage, onSocketError, onSocketClose, connectSocket, closeSocket, getAccountInfoSync, chooseAddress, authorizeForMiniProgram, authorize, openCard, addCard, reserveChannelsLive, openChannelsLive, openChannelsEvent, openChannelsActivity, getChannelsLiveNoticeInfo, getChannelsLiveInfo, openCustomerServiceChat, checkIsSupportFacialRecognition, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, faceVerifyForPay, addVideoToFavorites, addFileToFavorites, checkIsAddedToMyMiniProgram, getGroupEnterInfo, chooseInvoiceTitle, chooseInvoice, chooseLicensePlate, pluginLogin, login, checkSession, showRedPackage, openSetting, getSetting, startSoterAuthentication, checkIsSupportSoterAuthentication, checkIsSoterEnrolledInDevice, requestSubscribeMessage, getUserProfile, getUserInfo, shareToWeRun, getWeRunData, requestPayment, requestOrderPayment, updateShareMenu, showShareMenu, showShareImageMenu, shareVideoMessage, shareFileMessage, onCopyUrl, offCopyUrl, hideShareMenu, getShareInfo, authPrivateMessage, setStorageSync, setStorage, revokeBufferURL, removeStorageSync, removeStorage, getStorageSync, getStorageInfoSync, getStorageInfo, getStorage, createBufferURL, clearStorageSync, clearStorage, setBackgroundFetchToken, onBackgroundFetchData, getBackgroundFetchToken, getBackgroundFetchData, setPageInfo, ocrIdCard, ocrBankCard, ocrDrivingLicense, ocrVehicleLicense, textReview, textToAudio, imageAudit, advancedGeneralIdentify, objectDetectIdentify, carClassify, dishClassify, logoClassify, animalClassify, plantClassify, getSwanId, requestPolymerPayment, navigateToSmartGameProgram, navigateToSmartProgram, navigateBackSmartProgram, preloadSubPackage, createAnimation, setBackgroundTextStyle, setBackgroundColor, nextTick, loadFontFace, disableAlertBeforeUnload, enableAlertBeforeUnload, hideLoading, hideToast, showActionSheet, showLoading, showModal, showToast, getMenuButtonBoundingClientRect, showNavigationBarLoading, setNavigationBarTitle, setNavigationBarColor, hideNavigationBarLoading, hideHomeButton, startPullDownRefresh, stopPullDownRefresh, pageScrollTo, setTopBarText, initTabBarApis, showTabBarRedDot, showTabBar, setTabBarStyle, setTabBarItem, setTabBarBadge, removeTabBarBadge, hideTabBarRedDot, hideTabBar, setWindowSize, onWindowResize, offWindowResize, createWorker, createSelectorQuery, createIntersectionObserver, createMediaQueryObserver, Behavior, canIUseWebp, Current, ENV_TYPE, eventCenter, Events, getAppInfo, getEnv, history, initPxTransform, interceptorify, interceptors, Link, options, preload, pxTransform, requirePlugin };
|
|
775
767
|
export { getCurrentPages, navigateBack, navigateTo, redirectTo, reLaunch, switchTab } from "@tarojs/router";
|