@spcsn/taro 0.1.2 → 1.0.1
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/README.md +13 -6
- package/dist/index.js +223 -1
- package/dist/index.js.map +1 -1
- package/package.json +17 -48
- package/types/api/ad/index.d.ts +3 -6
- package/types/api/base/debug.d.ts +8 -8
- package/types/api/base/env.d.ts +3 -3
- package/types/api/base/index.d.ts +3 -3
- package/types/api/base/performance.d.ts +5 -5
- package/types/api/base/system.d.ts +8 -16
- package/types/api/base/update.d.ts +6 -6
- package/types/api/base/weapp/app-event.d.ts +12 -12
- package/types/api/base/weapp/life-cycle.d.ts +1 -1
- package/types/api/canvas/index.d.ts +71 -72
- package/types/api/data-analysis/index.d.ts +1 -1
- package/types/api/device/accelerometer.d.ts +4 -4
- package/types/api/device/accessibility.d.ts +1 -1
- package/types/api/device/battery.d.ts +2 -2
- package/types/api/device/bluetooth-ble.d.ts +14 -14
- package/types/api/device/bluetooth-peripheral.d.ts +15 -15
- package/types/api/device/bluetooth.d.ts +11 -11
- package/types/api/device/calendar.d.ts +2 -2
- package/types/api/device/clipboard.d.ts +2 -4
- package/types/api/device/compass.d.ts +4 -4
- package/types/api/device/gyroscope.d.ts +4 -4
- package/types/api/device/iBeacon.d.ts +7 -7
- package/types/api/device/keyboard.d.ts +3 -3
- package/types/api/device/memory.d.ts +2 -2
- package/types/api/device/motion.d.ts +4 -4
- package/types/api/device/network.d.ts +5 -20
- package/types/api/device/nfc.d.ts +17 -17
- package/types/api/device/phone.d.ts +1 -1
- package/types/api/device/scan.d.ts +1 -1
- package/types/api/device/screen.d.ts +6 -6
- package/types/api/device/sms.d.ts +1 -1
- package/types/api/device/vibrate.d.ts +2 -2
- package/types/api/device/wifi.d.ts +10 -10
- package/types/api/ext/index.d.ts +2 -2
- package/types/api/files/index.d.ts +46 -46
- package/types/api/framework/index.d.ts +2 -2
- package/types/api/location/index.d.ts +38 -45
- package/types/api/media/audio.d.ts +30 -30
- package/types/api/media/background-audio.d.ts +1 -1
- package/types/api/media/camera.d.ts +12 -25
- package/types/api/media/image.d.ts +8 -13
- package/types/api/media/map.d.ts +15 -15
- package/types/api/media/recorder.d.ts +11 -11
- package/types/api/media/video.d.ts +19 -21
- package/types/api/navigate/index.d.ts +2 -2
- package/types/api/network/download.d.ts +7 -8
- package/types/api/network/request.d.ts +14 -33
- package/types/api/network/upload.d.ts +7 -9
- package/types/api/network/websocket.d.ts +14 -14
- package/types/api/open-api/account.d.ts +1 -1
- package/types/api/open-api/address.d.ts +5 -5
- package/types/api/open-api/authorize.d.ts +1 -1
- package/types/api/open-api/login.d.ts +5 -5
- package/types/api/open-api/settings.d.ts +2 -2
- package/types/api/open-api/subscribe-message.d.ts +15 -15
- package/types/api/open-api/user-info.d.ts +2 -3
- package/types/api/payment/index.d.ts +1 -1
- package/types/api/route/index.d.ts +5 -8
- package/types/api/share/index.d.ts +3 -3
- package/types/api/storage/background-fetch.d.ts +6 -9
- package/types/api/storage/index.d.ts +11 -11
- package/types/api/taro.extend.d.ts +7 -24
- package/types/api/taro.hooks.d.ts +8 -33
- package/types/api/ui/animation.d.ts +33 -36
- package/types/api/ui/background.d.ts +2 -4
- package/types/api/ui/custom-component.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +1 -10
- package/types/api/ui/interaction.d.ts +6 -6
- package/types/api/ui/menu.d.ts +1 -1
- package/types/api/ui/navigation-bar.d.ts +5 -7
- package/types/api/ui/pull-down-refresh.d.ts +2 -3
- package/types/api/ui/scroll.d.ts +3 -4
- package/types/api/ui/tab-bar.d.ts +8 -8
- package/types/api/ui/window.d.ts +2 -2
- package/types/api/wxml/index.d.ts +19 -23
- package/types/compile/compiler.d.ts +4 -10
- package/types/compile/config/index.d.ts +0 -3
- package/types/compile/config/mini.d.ts +17 -39
- package/types/compile/config/plugin.d.ts +14 -4
- package/types/compile/config/project.d.ts +23 -61
- package/types/compile/config/util.d.ts +18 -73
- package/types/compile/index.d.ts +16 -1
- package/types/compile/viteCompilerContext.d.ts +18 -52
- package/types/global.d.ts +1 -12
- package/types/index.d.ts +0 -11
- package/types/taro.api.d.ts +0 -9
- package/types/taro.component.d.ts +0 -2
- package/types/taro.config.d.ts +0 -120
- package/types/taro.runtime.d.ts +7 -3
- package/types/api/alipay/index.d.ts +0 -69
- package/types/api/qq/index.d.ts +0 -354
- package/types/api/swan/bookshelf.d.ts +0 -307
- package/types/api/swan/download-package.d.ts +0 -80
- package/types/api/swan/index.d.ts +0 -251
- package/types/api/swan/pay.d.ts +0 -139
- package/types/compile/config/h5.d.ts +0 -134
- package/types/compile/config/harmony.d.ts +0 -118
- package/types/compile/config/rn.d.ts +0 -85
package/README.md
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@spcsn/taro`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@spcsn/taro` 是业务代码使用的核心运行时 API 入口,面向 React 19 开发微信小程序(Skyline / glass-easel)链路。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 包定位
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 业务侧公开依赖,应由小程序应用显式安装。
|
|
8
|
+
- 提供 Taro API、生命周期 hooks、配置类型和小程序端运行时入口。
|
|
9
|
+
- 依赖 `@spcsn/taro-runtime` 与 `@spcsn/taro-shared`,它们目前仍是发布期实现依赖。
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## 发布入口
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
- `index.js`: 兼容入口,运行时加载 `dist/index.js`。
|
|
14
|
+
- `dist/index.js`: 由源码通过 Rolldown 构建生成的小程序端入口。
|
|
15
|
+
- `types/index.d.ts`: 业务项目使用的类型声明入口。
|
|
12
16
|
|
|
17
|
+
## 支持范围
|
|
18
|
+
|
|
19
|
+
当前只维护 React 开发 WeApp 小程序路径。H5、React Native、Harmony、Vue、Solid、Nerv 和 Webpack 不属于本包的维护目标。
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,227 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
2
7
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
8
|
+
var __exportAll = (all, no_symbols) => {
|
|
9
|
+
let target = {};
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
+
return target;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
+
key = keys[i];
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
+
get: ((k) => from[k]).bind(null, key),
|
|
22
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
//#endregion
|
|
29
|
+
let _spcsn_taro_runtime = require("@spcsn/taro-runtime");
|
|
30
|
+
let _spcsn_taro_shared = require("@spcsn/taro-shared");
|
|
31
|
+
//#region src/api/env.ts
|
|
32
|
+
function getEnv() {
|
|
33
|
+
return ENV_TYPE.WEAPP;
|
|
34
|
+
}
|
|
35
|
+
var ENV_TYPE;
|
|
36
|
+
var init_env = __esmMin((() => {
|
|
37
|
+
ENV_TYPE = { WEAPP: "WEAPP" };
|
|
38
|
+
}));
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/api/interceptor/chain.ts
|
|
41
|
+
var Chain;
|
|
42
|
+
var init_chain = __esmMin((() => {
|
|
43
|
+
Chain = class Chain {
|
|
44
|
+
index;
|
|
45
|
+
requestParams;
|
|
46
|
+
interceptors;
|
|
47
|
+
constructor(requestParams, interceptors, index) {
|
|
48
|
+
this.index = index || 0;
|
|
49
|
+
this.requestParams = requestParams || {};
|
|
50
|
+
this.interceptors = interceptors || [];
|
|
51
|
+
}
|
|
52
|
+
proceed(requestParams = {}) {
|
|
53
|
+
this.requestParams = requestParams;
|
|
54
|
+
if (this.index >= this.interceptors.length) throw new Error("chain 参数错误, 请勿直接修改 request.chain");
|
|
55
|
+
const p = this._getNextInterceptor()(this._getNextChain());
|
|
56
|
+
const res = p.catch((err) => Promise.reject(err));
|
|
57
|
+
Object.keys(p).forEach((k) => (0, _spcsn_taro_shared.isFunction)(p[k]) && (res[k] = p[k]));
|
|
58
|
+
return res;
|
|
59
|
+
}
|
|
60
|
+
_getNextInterceptor() {
|
|
61
|
+
return this.interceptors[this.index];
|
|
62
|
+
}
|
|
63
|
+
_getNextChain() {
|
|
64
|
+
return new Chain(this.requestParams, this.interceptors, this.index + 1);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}));
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/api/interceptor/index.ts
|
|
70
|
+
function interceptorify(promisifyApi) {
|
|
71
|
+
return new Link(function(chain) {
|
|
72
|
+
return promisifyApi(chain.requestParams);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
var Link;
|
|
76
|
+
var init_interceptor = __esmMin((() => {
|
|
77
|
+
init_chain();
|
|
78
|
+
Link = class {
|
|
79
|
+
taroInterceptor;
|
|
80
|
+
chain;
|
|
81
|
+
constructor(interceptor) {
|
|
82
|
+
this.taroInterceptor = interceptor;
|
|
83
|
+
this.chain = new Chain();
|
|
84
|
+
}
|
|
85
|
+
request(requestParams) {
|
|
86
|
+
const chain = this.chain;
|
|
87
|
+
const taroInterceptor = this.taroInterceptor;
|
|
88
|
+
chain.interceptors = chain.interceptors.filter((interceptor) => interceptor !== taroInterceptor).concat(taroInterceptor);
|
|
89
|
+
return chain.proceed({ ...requestParams });
|
|
90
|
+
}
|
|
91
|
+
addInterceptor(interceptor) {
|
|
92
|
+
this.chain.interceptors.push(interceptor);
|
|
93
|
+
}
|
|
94
|
+
cleanInterceptors() {
|
|
95
|
+
this.chain = new Chain();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}));
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/api/interceptor/interceptors.ts
|
|
101
|
+
function attachAbort(source, target) {
|
|
102
|
+
const abortableTarget = target;
|
|
103
|
+
if ((0, _spcsn_taro_shared.isFunction)(source?.abort)) abortableTarget.abort = source.abort;
|
|
104
|
+
return abortableTarget;
|
|
105
|
+
}
|
|
106
|
+
function timeoutInterceptor(chain) {
|
|
107
|
+
const requestParams = chain.requestParams;
|
|
108
|
+
let proceedPromise;
|
|
109
|
+
const res = new Promise((resolve, reject) => {
|
|
110
|
+
const timeout = setTimeout(() => {
|
|
111
|
+
clearTimeout(timeout);
|
|
112
|
+
reject(/* @__PURE__ */ new Error("网络链接超时,请稍后再试!"));
|
|
113
|
+
}, requestParams && requestParams.timeout || 6e4);
|
|
114
|
+
proceedPromise = chain.proceed(requestParams);
|
|
115
|
+
proceedPromise.then((res) => {
|
|
116
|
+
if (!timeout) return;
|
|
117
|
+
clearTimeout(timeout);
|
|
118
|
+
resolve(res);
|
|
119
|
+
}).catch((err) => {
|
|
120
|
+
timeout && clearTimeout(timeout);
|
|
121
|
+
reject(err);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
return attachAbort(proceedPromise, res);
|
|
125
|
+
}
|
|
126
|
+
function logInterceptor(chain) {
|
|
127
|
+
const requestParams = chain.requestParams;
|
|
128
|
+
const { method, data, url } = requestParams;
|
|
129
|
+
globalThis.console.log(`http ${method || "GET"} --> ${url} data: `, data);
|
|
130
|
+
const p = chain.proceed(requestParams);
|
|
131
|
+
return attachAbort(p, p.then((res) => {
|
|
132
|
+
globalThis.console.log(`http <-- ${url} result:`, res);
|
|
133
|
+
return res;
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
var init_interceptors = __esmMin((() => {}));
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/api/tools.ts
|
|
139
|
+
function Behavior(options) {
|
|
140
|
+
return options;
|
|
141
|
+
}
|
|
142
|
+
function getPreload(current) {
|
|
143
|
+
return function(key, val) {
|
|
144
|
+
current.preloadData = (0, _spcsn_taro_shared.isObject)(key) ? key : { [key]: val };
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function getInitPxTransform(taro) {
|
|
148
|
+
return function(config) {
|
|
149
|
+
const { designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, targetUnit = defaultTargetUnit, unitPrecision = defaultUnitPrecision } = config;
|
|
150
|
+
taro.config = taro.config || {};
|
|
151
|
+
taro.config.designWidth = designWidth;
|
|
152
|
+
taro.config.deviceRatio = deviceRatio;
|
|
153
|
+
taro.config.baseFontSize = baseFontSize;
|
|
154
|
+
taro.config.targetUnit = targetUnit;
|
|
155
|
+
taro.config.unitPrecision = unitPrecision;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function getPxTransform(taro) {
|
|
159
|
+
return function(size) {
|
|
160
|
+
const config = taro.config || {};
|
|
161
|
+
const baseFontSize = config.baseFontSize;
|
|
162
|
+
const deviceRatio = config.deviceRatio || defaultDesignRatio;
|
|
163
|
+
const designWidth = ((input = 0) => (0, _spcsn_taro_shared.isFunction)(config.designWidth) ? config.designWidth(input) : config.designWidth || defaultDesignWidth)(size);
|
|
164
|
+
if (!(designWidth in deviceRatio)) throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`);
|
|
165
|
+
const targetUnit = config.targetUnit || defaultTargetUnit;
|
|
166
|
+
const unitPrecision = config.unitPrecision || defaultUnitPrecision;
|
|
167
|
+
const formatSize = ~~size;
|
|
168
|
+
let rootValue = 1 / deviceRatio[designWidth];
|
|
169
|
+
switch (targetUnit) {
|
|
170
|
+
case "rem":
|
|
171
|
+
rootValue *= baseFontSize * 2;
|
|
172
|
+
break;
|
|
173
|
+
case "px":
|
|
174
|
+
rootValue *= 2;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
let val = formatSize / rootValue;
|
|
178
|
+
if (unitPrecision >= 0 && unitPrecision <= 100) val = Number(val.toFixed(unitPrecision));
|
|
179
|
+
return val + targetUnit;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
var defaultDesignWidth, defaultDesignRatio, defaultBaseFontSize, defaultUnitPrecision, defaultTargetUnit;
|
|
183
|
+
var init_tools = __esmMin((() => {
|
|
184
|
+
defaultDesignWidth = 750;
|
|
185
|
+
defaultDesignRatio = {
|
|
186
|
+
640: 2.34 / 2,
|
|
187
|
+
750: 1,
|
|
188
|
+
828: 1.81 / 2
|
|
189
|
+
};
|
|
190
|
+
defaultBaseFontSize = 20;
|
|
191
|
+
defaultUnitPrecision = 5;
|
|
192
|
+
defaultTargetUnit = "rpx";
|
|
193
|
+
}));
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/api/index.ts
|
|
196
|
+
var api_exports = /* @__PURE__ */ __exportAll({ default: () => Taro });
|
|
197
|
+
var Taro;
|
|
198
|
+
var init_api = __esmMin((() => {
|
|
199
|
+
init_env();
|
|
200
|
+
init_interceptor();
|
|
201
|
+
init_interceptors();
|
|
202
|
+
init_tools();
|
|
203
|
+
Taro = {
|
|
204
|
+
Behavior,
|
|
205
|
+
getEnv,
|
|
206
|
+
ENV_TYPE,
|
|
207
|
+
Link,
|
|
208
|
+
interceptors: {
|
|
209
|
+
logInterceptor,
|
|
210
|
+
timeoutInterceptor
|
|
211
|
+
},
|
|
212
|
+
Current: _spcsn_taro_runtime.Current,
|
|
213
|
+
getCurrentInstance: _spcsn_taro_runtime.getCurrentInstance,
|
|
214
|
+
options: _spcsn_taro_runtime.options,
|
|
215
|
+
nextTick: _spcsn_taro_runtime.nextTick,
|
|
216
|
+
eventCenter: _spcsn_taro_runtime.eventCenter,
|
|
217
|
+
Events: _spcsn_taro_runtime.Events,
|
|
218
|
+
getInitPxTransform,
|
|
219
|
+
interceptorify
|
|
220
|
+
};
|
|
221
|
+
Taro.initPxTransform = getInitPxTransform(Taro);
|
|
222
|
+
Taro.preload = getPreload(_spcsn_taro_runtime.Current);
|
|
223
|
+
Taro.pxTransform = getPxTransform(Taro);
|
|
224
|
+
}));
|
|
3
225
|
//#endregion
|
|
4
226
|
//#region src/react-hooks-fallback.js
|
|
5
227
|
var require_react_hooks_fallback = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -134,7 +356,7 @@ var require_native_api_fallback = /* @__PURE__ */ __commonJSMin(((exports, modul
|
|
|
134
356
|
//#endregion
|
|
135
357
|
//#region src/index.js
|
|
136
358
|
const { hooks } = require("@spcsn/taro-runtime");
|
|
137
|
-
const taro =
|
|
359
|
+
const taro = (init_api(), __toCommonJS(api_exports)).default;
|
|
138
360
|
const { initReactHooksFallback } = require_react_hooks_fallback();
|
|
139
361
|
const { initWeappNativeApiFallback } = require_native_api_fallback();
|
|
140
362
|
if (hooks.isExist("initNativeApi")) hooks.call("initNativeApi", taro);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["initWeappNativeApiFallback"],"sources":["../src/react-hooks-fallback.js","../src/native-api-fallback.js","../src/index.js"],"sourcesContent":["const { Current, getPageInstance, injectPageInstance } = require('@spcsn/taro-runtime');\nconst React = require('react');\n\nconst hooksMap = {\n useAddToFavorites: 'onAddToFavorites',\n useDidHide: 'componentDidHide',\n useDidShow: 'componentDidShow',\n useError: 'onError',\n useKeyboardHeight: 'onKeyboardHeight',\n useLaunch: 'onLaunch',\n useLoad: 'onLoad',\n useOptionMenuClick: 'onOptionMenuClick',\n usePageNotFound: 'onPageNotFound',\n usePageScroll: 'onPageScroll',\n usePullDownRefresh: 'onPullDownRefresh',\n usePullIntercept: 'onPullIntercept',\n useReachBottom: 'onReachBottom',\n useReady: 'onReady',\n useResize: 'onResize',\n useSaveExitState: 'onSaveExitState',\n useShareAppMessage: 'onShareAppMessage',\n useShareTimeline: 'onShareTimeline',\n useTabItemTap: 'onTabItemTap',\n useTitleClick: 'onTitleClick',\n useUnhandledRejection: 'onUnhandledRejection',\n useUnload: 'onUnload',\n};\n\nfunction createHook(lifecycle) {\n return (fn) => {\n const router = Current.router;\n const id = router?.$taroPath || router?.path || 'taro-app';\n const instRef = React.useRef();\n const fnRef = React.useRef(fn);\n if (fnRef.current !== fn) fnRef.current = fn;\n\n React.useLayoutEffect(() => {\n let inst = (instRef.current = getPageInstance(id));\n if (!inst) {\n inst = instRef.current = Object.create(null);\n injectPageInstance(inst, id);\n }\n\n const callback = (...args) => fnRef.current(...args);\n if (typeof inst[lifecycle] === 'function') {\n inst[lifecycle] = [inst[lifecycle], callback];\n } else {\n inst[lifecycle] = [...(inst[lifecycle] || []), callback];\n }\n\n return () => {\n const inst = instRef.current;\n if (!inst) return;\n\n const list = inst[lifecycle];\n if (list === callback) {\n inst[lifecycle] = undefined;\n } else if (Array.isArray(list)) {\n inst[lifecycle] = list.filter((item) => item !== callback);\n }\n instRef.current = undefined;\n };\n }, []);\n };\n}\n\nfunction initReactHooksFallback(taro) {\n if (typeof taro.useShareAppMessage === 'function') return;\n\n Object.keys(hooksMap).forEach((key) => {\n taro[key] = createHook(hooksMap[key]);\n });\n\n taro.useRouter = function useRouter(dynamic = false) {\n if (dynamic) return Current.router;\n return React.useMemo(() => Current.router, []);\n };\n\n taro.useScope = function useScope() {\n return undefined;\n };\n}\n\nmodule.exports = {\n initReactHooksFallback,\n};\n","const needPromiseApis = new Set([\n 'addFileToFavorites',\n 'addVideoToFavorites',\n 'authPrivateMessage',\n 'checkIsAddedToMyMiniProgram',\n 'chooseContact',\n 'cropImage',\n 'disableAlertBeforeUnload',\n 'editImage',\n 'enableAlertBeforeUnload',\n 'getBackgroundFetchData',\n 'getChannelsLiveInfo',\n 'getChannelsLiveNoticeInfo',\n 'getFuzzyLocation',\n 'getGroupEnterInfo',\n 'getLocalIPAddress',\n 'getShareInfo',\n 'getUserProfile',\n 'getWeRunData',\n 'join1v1Chat',\n 'openChannelsActivity',\n 'openChannelsEvent',\n 'openChannelsLive',\n 'openChannelsUserProfile',\n 'openCustomerServiceChat',\n 'openVideoEditor',\n 'saveFileToDisk',\n 'scanItem',\n 'setEnable1v1Chat',\n 'setWindowSize',\n 'sendBizRedPacket',\n 'startFacialRecognitionVerify',\n]);\n\nfunction initWeappNativeApiFallback(taro) {\n if (typeof wx === 'undefined' || typeof taro.addInterceptor === 'function') return;\n\n const { processApis } = require('@spcsn/taro-shared');\n\n processApis(taro, wx, {\n needPromiseApis,\n modifyApis(apis) {\n apis.delete('lanDebug');\n },\n transformMeta(api, options) {\n if (api === 'showShareMenu') {\n options.menus = options.showShareItems?.map((item) =>\n item === 'wechatFriends' ? 'shareAppMessage' : item === 'wechatMoment' ? 'shareTimeline' : item,\n );\n }\n\n return {\n key: api,\n options,\n };\n },\n });\n\n taro.cloud = wx.cloud;\n taro.getTabBar = function (pageCtx) {\n if (typeof pageCtx?.getTabBar === 'function') {\n return pageCtx.getTabBar()?.$taroInstances;\n }\n };\n taro.getRenderer = function () {\n return taro.getCurrentInstance()?.page?.renderer ?? 'webview';\n };\n}\n\nmodule.exports = {\n initWeappNativeApiFallback,\n};\n","const { hooks } = require('@spcsn/taro-runtime');\nconst taro = require('@spcsn/taro-api').default;\n\nconst { initReactHooksFallback } = require('./react-hooks-fallback');\nconst { initWeappNativeApiFallback } = require('./native-api-fallback');\n\nif (hooks.isExist('initNativeApi')) {\n hooks.call('initNativeApi', taro);\n}\n\ninitReactHooksFallback(taro);\ninitWeappNativeApiFallback(taro);\n\nmodule.exports = taro;\nmodule.exports.default = module.exports;\n"],"mappings":";;;;;CAAA,MAAM,EAAE,SAAS,iBAAiB,uBAAuB,QAAQ,qBAAqB;CACtF,MAAM,QAAQ,QAAQ,OAAO;CAE7B,MAAM,WAAW;EACf,mBAAmB;EACnB,YAAY;EACZ,YAAY;EACZ,UAAU;EACV,mBAAmB;EACnB,WAAW;EACX,SAAS;EACT,oBAAoB;EACpB,iBAAiB;EACjB,eAAe;EACf,oBAAoB;EACpB,kBAAkB;EAClB,gBAAgB;EAChB,UAAU;EACV,WAAW;EACX,kBAAkB;EAClB,oBAAoB;EACpB,kBAAkB;EAClB,eAAe;EACf,eAAe;EACf,uBAAuB;EACvB,WAAW;CACb;CAEA,SAAS,WAAW,WAAW;EAC7B,QAAQ,OAAO;GACb,MAAM,SAAS,QAAQ;GACvB,MAAM,KAAK,QAAQ,aAAa,QAAQ,QAAQ;GAChD,MAAM,UAAU,MAAM,OAAO;GAC7B,MAAM,QAAQ,MAAM,OAAO,EAAE;GAC7B,IAAI,MAAM,YAAY,IAAI,MAAM,UAAU;GAE1C,MAAM,sBAAsB;IAC1B,IAAI,OAAQ,QAAQ,UAAU,gBAAgB,EAAE;IAChD,IAAI,CAAC,MAAM;KACT,OAAO,QAAQ,UAAU,OAAO,OAAO,IAAI;KAC3C,mBAAmB,MAAM,EAAE;IAC7B;IAEA,MAAM,YAAY,GAAG,SAAS,MAAM,QAAQ,GAAG,IAAI;IACnD,IAAI,OAAO,KAAK,eAAe,YAC7B,KAAK,aAAa,CAAC,KAAK,YAAY,QAAQ;SAE5C,KAAK,aAAa,CAAC,GAAI,KAAK,cAAc,CAAC,GAAI,QAAQ;IAGzD,aAAa;KACX,MAAM,OAAO,QAAQ;KACrB,IAAI,CAAC,MAAM;KAEX,MAAM,OAAO,KAAK;KACl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OAAO,QAAQ,UAAU,GAAG;EAEhC;EACA,KAAK,cAAc,WAAY;GAC7B,OAAO,KAAK,mBAAmB,GAAG,MAAM,YAAY;EACtD;CACF;CAEA,OAAO,UAAU,EACf,4BAAA,6BACF;;;;ACvEA,MAAM,EAAE,UAAU,QAAQ,qBAAqB;AAC/C,MAAM,OAAO,QAAQ,iBAAiB,EAAE;AAExC,MAAM,EAAE,2BAAA,6BAAA;AACR,MAAM,EAAE,+BAAA,4BAAA;AAER,IAAI,MAAM,QAAQ,eAAe,GAC/B,MAAM,KAAK,iBAAiB,IAAI;AAGlC,uBAAuB,IAAI;AAC3B,2BAA2B,IAAI;AAE/B,OAAO,UAAU;AACjB,OAAO,QAAQ,UAAU,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["envType","Current","initWeappNativeApiFallback"],"sources":["../src/api/env.ts","../src/api/interceptor/chain.ts","../src/api/interceptor/index.ts","../src/api/interceptor/interceptors.ts","../src/api/tools.ts","../src/api/index.ts","../src/react-hooks-fallback.js","../src/native-api-fallback.js","../src/index.js"],"sourcesContent":["export const ENV_TYPE = {\n WEAPP: 'WEAPP',\n};\n\nexport function getEnv() {\n return ENV_TYPE.WEAPP;\n}\n","import { isFunction } from '@spcsn/taro-shared';\n\nexport type TInterceptor = (c: Chain) => Promise<void>;\n\nexport interface IRequestParams {\n timeout?: number;\n method?: string;\n url?: string;\n data?: unknown;\n}\n\nexport default class Chain {\n index: number;\n requestParams: IRequestParams;\n interceptors: TInterceptor[];\n\n constructor(requestParams?: IRequestParams, interceptors?: TInterceptor[], index?: number) {\n this.index = index || 0;\n this.requestParams = requestParams || {};\n this.interceptors = interceptors || [];\n }\n\n proceed(requestParams: IRequestParams = {}) {\n this.requestParams = requestParams;\n if (this.index >= this.interceptors.length) {\n throw new Error('chain 参数错误, 请勿直接修改 request.chain');\n }\n const nextInterceptor = this._getNextInterceptor();\n const nextChain = this._getNextChain();\n const p = nextInterceptor(nextChain);\n const res = p.catch((err) => Promise.reject(err));\n Object.keys(p).forEach((k) => isFunction(p[k]) && (res[k] = p[k]));\n return res;\n }\n\n _getNextInterceptor() {\n return this.interceptors[this.index];\n }\n\n _getNextChain() {\n return new Chain(this.requestParams, this.interceptors, this.index + 1);\n }\n}\n","import Chain from './chain';\n\nimport type { IRequestParams, TInterceptor } from './chain';\n\nexport default class Link {\n taroInterceptor: TInterceptor;\n chain: Chain;\n\n constructor(interceptor: TInterceptor) {\n this.taroInterceptor = interceptor;\n this.chain = new Chain();\n }\n\n request(requestParams: IRequestParams) {\n const chain = this.chain;\n const taroInterceptor = this.taroInterceptor;\n\n chain.interceptors = chain.interceptors\n .filter((interceptor) => interceptor !== taroInterceptor)\n .concat(taroInterceptor);\n\n return chain.proceed({ ...requestParams });\n }\n\n addInterceptor(interceptor: TInterceptor) {\n this.chain.interceptors.push(interceptor);\n }\n\n cleanInterceptors() {\n this.chain = new Chain();\n }\n}\n\nexport function interceptorify(promisifyApi) {\n return new Link(function (chain) {\n return promisifyApi(chain.requestParams);\n });\n}\n","import { isFunction } from '@spcsn/taro-shared';\n\nimport type Chain from './chain';\n\ntype AbortablePromise<T> = Promise<T> & {\n abort?: () => void;\n};\n\nfunction attachAbort<T>(source: AbortablePromise<T> | undefined, target: Promise<T>): AbortablePromise<T> {\n const abortableTarget = target as AbortablePromise<T>;\n if (isFunction(source?.abort)) {\n abortableTarget.abort = source.abort;\n }\n return abortableTarget;\n}\n\nexport function timeoutInterceptor(chain: Chain) {\n const requestParams = chain.requestParams;\n let proceedPromise: AbortablePromise<void> | undefined;\n const res = new Promise<void>((resolve, reject) => {\n const timeout: ReturnType<typeof setTimeout> = setTimeout(\n () => {\n clearTimeout(timeout);\n reject(new Error('网络链接超时,请稍后再试!'));\n },\n (requestParams && requestParams.timeout) || 60000,\n );\n\n proceedPromise = chain.proceed(requestParams);\n proceedPromise\n .then((res) => {\n if (!timeout) return;\n clearTimeout(timeout);\n resolve(res);\n })\n .catch((err) => {\n timeout && clearTimeout(timeout);\n reject(err);\n });\n });\n return attachAbort(proceedPromise, res);\n}\n\nexport function logInterceptor(chain: Chain) {\n const requestParams = chain.requestParams;\n const { method, data, url } = requestParams;\n\n globalThis.console.log(`http ${method || 'GET'} --> ${url} data: `, data);\n\n const p = chain.proceed(requestParams);\n const res = p.then((res) => {\n globalThis.console.log(`http <-- ${url} result:`, res);\n return res;\n });\n return attachAbort(p, res);\n}\n","import { isFunction, isObject } from '@spcsn/taro-shared';\n\nexport function Behavior(options) {\n return options;\n}\n\nexport function getPreload(current) {\n return function (key: any, val: unknown) {\n current.preloadData = isObject(key)\n ? key\n : {\n [key]: val,\n };\n };\n}\n\nconst defaultDesignWidth = 750;\nconst defaultDesignRatio = {\n 640: 2.34 / 2,\n 750: 1,\n 828: 1.81 / 2,\n};\nconst defaultBaseFontSize = 20;\nconst defaultUnitPrecision = 5;\nconst defaultTargetUnit = 'rpx';\n\nexport function getInitPxTransform(taro) {\n return function (config) {\n const {\n designWidth = defaultDesignWidth,\n deviceRatio = defaultDesignRatio,\n baseFontSize = defaultBaseFontSize,\n targetUnit = defaultTargetUnit,\n unitPrecision = defaultUnitPrecision,\n } = config;\n taro.config = taro.config || {};\n taro.config.designWidth = designWidth;\n taro.config.deviceRatio = deviceRatio;\n taro.config.baseFontSize = baseFontSize;\n taro.config.targetUnit = targetUnit;\n taro.config.unitPrecision = unitPrecision;\n };\n}\n\nexport function getPxTransform(taro) {\n return function (size) {\n const config = taro.config || {};\n const baseFontSize = config.baseFontSize;\n const deviceRatio = config.deviceRatio || defaultDesignRatio;\n const designWidth = ((input = 0) =>\n isFunction(config.designWidth) ? config.designWidth(input) : config.designWidth || defaultDesignWidth)(size);\n if (!(designWidth in deviceRatio)) {\n throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`);\n }\n const targetUnit = config.targetUnit || defaultTargetUnit;\n const unitPrecision = config.unitPrecision || defaultUnitPrecision;\n const formatSize = ~~size;\n let rootValue = 1 / deviceRatio[designWidth];\n switch (targetUnit) {\n case 'rem':\n rootValue *= baseFontSize * 2;\n break;\n case 'px':\n rootValue *= 2;\n break;\n }\n let val = formatSize / rootValue;\n if (unitPrecision >= 0 && unitPrecision <= 100) {\n val = Number(val.toFixed(unitPrecision));\n }\n return val + targetUnit;\n };\n}\n","import { Current, eventCenter, Events, getCurrentInstance, nextTick, options } from '@spcsn/taro-runtime';\n\nimport { ENV_TYPE as envType, getEnv } from './env';\nimport Link, { interceptorify } from './interceptor';\nimport { logInterceptor, timeoutInterceptor } from './interceptor/interceptors';\nimport { Behavior, getInitPxTransform, getPreload, getPxTransform } from './tools';\n\nconst interceptors = {\n logInterceptor,\n timeoutInterceptor,\n};\n\nconst Taro: Record<string, unknown> = {\n Behavior,\n getEnv,\n ENV_TYPE: envType,\n Link,\n interceptors,\n Current,\n getCurrentInstance,\n options,\n nextTick,\n eventCenter,\n Events,\n getInitPxTransform,\n interceptorify,\n};\n\nTaro.initPxTransform = getInitPxTransform(Taro);\nTaro.preload = getPreload(Current);\nTaro.pxTransform = getPxTransform(Taro);\n\nexport default Taro;\n","const { Current, getPageInstance, injectPageInstance } = require('@spcsn/taro-runtime');\nconst React = require('react');\n\nconst hooksMap = {\n useAddToFavorites: 'onAddToFavorites',\n useDidHide: 'componentDidHide',\n useDidShow: 'componentDidShow',\n useError: 'onError',\n useKeyboardHeight: 'onKeyboardHeight',\n useLaunch: 'onLaunch',\n useLoad: 'onLoad',\n useOptionMenuClick: 'onOptionMenuClick',\n usePageNotFound: 'onPageNotFound',\n usePageScroll: 'onPageScroll',\n usePullDownRefresh: 'onPullDownRefresh',\n usePullIntercept: 'onPullIntercept',\n useReachBottom: 'onReachBottom',\n useReady: 'onReady',\n useResize: 'onResize',\n useSaveExitState: 'onSaveExitState',\n useShareAppMessage: 'onShareAppMessage',\n useShareTimeline: 'onShareTimeline',\n useTabItemTap: 'onTabItemTap',\n useTitleClick: 'onTitleClick',\n useUnhandledRejection: 'onUnhandledRejection',\n useUnload: 'onUnload',\n};\n\nfunction createHook(lifecycle) {\n return (fn) => {\n const router = Current.router;\n const id = router?.$taroPath || router?.path || 'taro-app';\n const instRef = React.useRef();\n const fnRef = React.useRef(fn);\n if (fnRef.current !== fn) fnRef.current = fn;\n\n React.useLayoutEffect(() => {\n let inst = (instRef.current = getPageInstance(id));\n if (!inst) {\n inst = instRef.current = Object.create(null);\n injectPageInstance(inst, id);\n }\n\n const callback = (...args) => fnRef.current(...args);\n if (typeof inst[lifecycle] === 'function') {\n inst[lifecycle] = [inst[lifecycle], callback];\n } else {\n inst[lifecycle] = [...(inst[lifecycle] || []), callback];\n }\n\n return () => {\n const inst = instRef.current;\n if (!inst) return;\n\n const list = inst[lifecycle];\n if (list === callback) {\n inst[lifecycle] = undefined;\n } else if (Array.isArray(list)) {\n inst[lifecycle] = list.filter((item) => item !== callback);\n }\n instRef.current = undefined;\n };\n }, []);\n };\n}\n\nfunction initReactHooksFallback(taro) {\n if (typeof taro.useShareAppMessage === 'function') return;\n\n Object.keys(hooksMap).forEach((key) => {\n taro[key] = createHook(hooksMap[key]);\n });\n\n taro.useRouter = function useRouter(dynamic = false) {\n if (dynamic) return Current.router;\n return React.useMemo(() => Current.router, []);\n };\n\n taro.useScope = function useScope() {\n return undefined;\n };\n}\n\nmodule.exports = {\n initReactHooksFallback,\n};\n","const needPromiseApis = new Set([\n 'addFileToFavorites',\n 'addVideoToFavorites',\n 'authPrivateMessage',\n 'checkIsAddedToMyMiniProgram',\n 'chooseContact',\n 'cropImage',\n 'disableAlertBeforeUnload',\n 'editImage',\n 'enableAlertBeforeUnload',\n 'getBackgroundFetchData',\n 'getChannelsLiveInfo',\n 'getChannelsLiveNoticeInfo',\n 'getFuzzyLocation',\n 'getGroupEnterInfo',\n 'getLocalIPAddress',\n 'getShareInfo',\n 'getUserProfile',\n 'getWeRunData',\n 'join1v1Chat',\n 'openChannelsActivity',\n 'openChannelsEvent',\n 'openChannelsLive',\n 'openChannelsUserProfile',\n 'openCustomerServiceChat',\n 'openVideoEditor',\n 'saveFileToDisk',\n 'scanItem',\n 'setEnable1v1Chat',\n 'setWindowSize',\n 'sendBizRedPacket',\n 'startFacialRecognitionVerify',\n]);\n\nfunction initWeappNativeApiFallback(taro) {\n if (typeof wx === 'undefined' || typeof taro.addInterceptor === 'function') return;\n\n const { processApis } = require('@spcsn/taro-shared');\n\n processApis(taro, wx, {\n needPromiseApis,\n modifyApis(apis) {\n apis.delete('lanDebug');\n },\n transformMeta(api, options) {\n if (api === 'showShareMenu') {\n options.menus = options.showShareItems?.map((item) =>\n item === 'wechatFriends' ? 'shareAppMessage' : item === 'wechatMoment' ? 'shareTimeline' : item,\n );\n }\n\n return {\n key: api,\n options,\n };\n },\n });\n\n taro.cloud = wx.cloud;\n taro.getTabBar = function (pageCtx) {\n if (typeof pageCtx?.getTabBar === 'function') {\n return pageCtx.getTabBar()?.$taroInstances;\n }\n };\n taro.getRenderer = function () {\n return taro.getCurrentInstance()?.page?.renderer ?? 'webview';\n };\n}\n\nmodule.exports = {\n initWeappNativeApiFallback,\n};\n","const { hooks } = require('@spcsn/taro-runtime');\nconst taro = require('./api').default;\n\nconst { initReactHooksFallback } = require('./react-hooks-fallback');\nconst { initWeappNativeApiFallback } = require('./native-api-fallback');\n\nif (hooks.isExist('initNativeApi')) {\n hooks.call('initNativeApi', taro);\n}\n\ninitReactHooksFallback(taro);\ninitWeappNativeApiFallback(taro);\n\nmodule.exports = taro;\nmodule.exports.default = module.exports;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAgB,SAAS;CACvB,OAAO,SAAS;AAClB;;;CANa,WAAW,EACtB,OAAO,QACT;;;;;;CCSqB,QAArB,MAAqB,MAAM;EACzB;EACA;EACA;EAEA,YAAY,eAAgC,cAA+B,OAAgB;GACzF,KAAK,QAAQ,SAAS;GACtB,KAAK,gBAAgB,iBAAiB,CAAC;GACvC,KAAK,eAAe,gBAAgB,CAAC;EACvC;EAEA,QAAQ,gBAAgC,CAAC,GAAG;GAC1C,KAAK,gBA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,MAAM,EAAE,2BAAA,6BAAA;AACR,MAAM,EAAE,+BAAA,4BAAA;AAER,IAAI,MAAM,QAAQ,eAAe,GAC/B,MAAM,KAAK,iBAAiB,IAAI;AAGlC,uBAAuB,IAAI;AAC3B,2BAA2B,IAAI;AAE/B,OAAO,UAAU;AACjB,OAAO,QAAQ,UAAU,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spcsn/taro",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "Taro
|
|
5
|
-
"author": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "SPCSN Taro runtime API entry",
|
|
5
|
+
"author": "Samuel Ouyang",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"types": "types/index.d.ts",
|
|
9
|
-
"typings": "types/index.d.ts",
|
|
10
9
|
"files": [
|
|
11
10
|
"index.js",
|
|
12
11
|
"dist",
|
|
@@ -14,8 +13,12 @@
|
|
|
14
13
|
],
|
|
15
14
|
"repository": {
|
|
16
15
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/
|
|
16
|
+
"url": "git+https://github.com/specificshen/taro-lite.git"
|
|
18
17
|
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/specificshen/taro-lite/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/specificshen/taro-lite#readme",
|
|
19
22
|
"keywords": [
|
|
20
23
|
"taro"
|
|
21
24
|
],
|
|
@@ -23,63 +26,29 @@
|
|
|
23
26
|
"node": ">= 22"
|
|
24
27
|
},
|
|
25
28
|
"dependencies": {
|
|
26
|
-
"@
|
|
27
|
-
"@spcsn/taro-
|
|
28
|
-
"@spcsn/taro-runtime": "0.1.2",
|
|
29
|
-
"@spcsn/taro-react": "0.1.2",
|
|
30
|
-
"@spcsn/taro-shared": "0.1.2"
|
|
29
|
+
"@spcsn/taro-runtime": "1.0.1",
|
|
30
|
+
"@spcsn/taro-shared": "1.0.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"rollup": "^3.29.4",
|
|
38
|
-
"@spcsn/taro-components": "0.1.2",
|
|
39
|
-
"@spcsn/taro-shared": "0.1.2",
|
|
40
|
-
"@spcsn/taro-helper": "0.1.1"
|
|
33
|
+
"@spcsn/taro-components": "1.0.1",
|
|
34
|
+
"@spcsn/taro-helper": "1.0.1",
|
|
35
|
+
"@spcsn/taro-shared": "1.0.1",
|
|
36
|
+
"rolldown": "^1.0.1"
|
|
41
37
|
},
|
|
42
38
|
"peerDependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"rollup": "^3",
|
|
46
|
-
"postcss": "^8",
|
|
47
|
-
"vue": "^3",
|
|
48
|
-
"webpack": "^5",
|
|
49
|
-
"webpack-chain": "^6",
|
|
50
|
-
"webpack-dev-server": "^4",
|
|
51
|
-
"@spcsn/taro-helper": "0.1.1",
|
|
52
|
-
"@spcsn/taro-components": "0.1.2",
|
|
53
|
-
"@spcsn/taro-shared": "0.1.2"
|
|
39
|
+
"@spcsn/taro-components": "1.0.1",
|
|
40
|
+
"@types/react": "^19"
|
|
54
41
|
},
|
|
55
42
|
"peerDependenciesMeta": {
|
|
56
43
|
"@types/react": {
|
|
57
44
|
"optional": true
|
|
58
|
-
},
|
|
59
|
-
"html-webpack-plugin": {
|
|
60
|
-
"optional": true
|
|
61
|
-
},
|
|
62
|
-
"rollup": {
|
|
63
|
-
"optional": true
|
|
64
|
-
},
|
|
65
|
-
"vue": {
|
|
66
|
-
"optional": true
|
|
67
|
-
},
|
|
68
|
-
"webpack": {
|
|
69
|
-
"optional": true
|
|
70
|
-
},
|
|
71
|
-
"webpack-chain": {
|
|
72
|
-
"optional": true
|
|
73
|
-
},
|
|
74
|
-
"webpack-dev-server": {
|
|
75
|
-
"optional": true
|
|
76
45
|
}
|
|
77
46
|
},
|
|
78
47
|
"scripts": {
|
|
79
48
|
"prod": "pnpm run build",
|
|
80
49
|
"prebuild": "pnpm run clean",
|
|
81
50
|
"build": "pnpm run rolldown --environment NODE_ENV:production",
|
|
82
|
-
"clean": "
|
|
51
|
+
"clean": "bun ../../scripts/clean.ts dist",
|
|
83
52
|
"dev": "pnpm run rolldown --environment NODE_ENV:development -w",
|
|
84
53
|
"rolldown": "rolldown --config rolldown.config.mjs"
|
|
85
54
|
}
|
package/types/api/ad/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare module '../../index' {
|
|
|
4
4
|
namespace createRewardedVideoAd {
|
|
5
5
|
interface Option {
|
|
6
6
|
/** 小程序广告位 ID
|
|
7
|
-
* @supported weapp
|
|
7
|
+
* @supported weapp
|
|
8
8
|
*/
|
|
9
9
|
adUnitId: string
|
|
10
10
|
/** 是否启用多例模式
|
|
@@ -12,10 +12,7 @@ declare module '../../index' {
|
|
|
12
12
|
* @supported weapp
|
|
13
13
|
*/
|
|
14
14
|
multiton?: boolean
|
|
15
|
-
/** 小程序应用 ID
|
|
16
|
-
* @supported swan
|
|
17
|
-
* @swan 必填
|
|
18
|
-
*/
|
|
15
|
+
/** 小程序应用 ID */
|
|
19
16
|
appSid?: string
|
|
20
17
|
}
|
|
21
18
|
}
|
|
@@ -182,7 +179,7 @@ declare module '../../index' {
|
|
|
182
179
|
|
|
183
180
|
interface TaroStatic {
|
|
184
181
|
/** 创建激励视频广告组件。
|
|
185
|
-
* @supported weapp
|
|
182
|
+
* @supported weapp
|
|
186
183
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/wx.createRewardedVideoAd.html
|
|
187
184
|
*/
|
|
188
185
|
createRewardedVideoAd (option: createRewardedVideoAd.Option): RewardedVideoAd
|
|
@@ -39,12 +39,12 @@ declare module '../../index' {
|
|
|
39
39
|
* **注意**
|
|
40
40
|
* - 由于 vConsole 功能有限,以及不同客户端对 console 方法的支持情况有差异,建议开发者在小程序中只使用本文档中提供的方法。
|
|
41
41
|
* - 部分内容展示的限制请参见调试
|
|
42
|
-
* @supported weapp
|
|
42
|
+
* @supported weapp
|
|
43
43
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.html
|
|
44
44
|
*/
|
|
45
45
|
interface console {
|
|
46
46
|
/** 向调试面板中打印 debug 日志
|
|
47
|
-
* @supported weapp
|
|
47
|
+
* @supported weapp
|
|
48
48
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.debug.html
|
|
49
49
|
*/
|
|
50
50
|
debug(
|
|
@@ -52,7 +52,7 @@ declare module '../../index' {
|
|
|
52
52
|
...args: any[]
|
|
53
53
|
): void
|
|
54
54
|
/** 向调试面板中打印 error 日志
|
|
55
|
-
* @supported weapp
|
|
55
|
+
* @supported weapp
|
|
56
56
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.error.html
|
|
57
57
|
*/
|
|
58
58
|
error(
|
|
@@ -63,7 +63,7 @@ declare module '../../index' {
|
|
|
63
63
|
*
|
|
64
64
|
* **注意**
|
|
65
65
|
* 仅在工具中有效,在 vConsole 中为空函数实现。
|
|
66
|
-
* @supported weapp
|
|
66
|
+
* @supported weapp
|
|
67
67
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.group.html
|
|
68
68
|
*/
|
|
69
69
|
group(
|
|
@@ -74,12 +74,12 @@ declare module '../../index' {
|
|
|
74
74
|
*
|
|
75
75
|
* **注意**
|
|
76
76
|
* 仅在工具中有效,在 vConsole 中为空函数实现。
|
|
77
|
-
* @supported weapp
|
|
77
|
+
* @supported weapp
|
|
78
78
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.groupEnd.html
|
|
79
79
|
*/
|
|
80
80
|
groupEnd(): void
|
|
81
81
|
/** 向调试面板中打印 info 日志
|
|
82
|
-
* @supported weapp
|
|
82
|
+
* @supported weapp
|
|
83
83
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.info.html
|
|
84
84
|
*/
|
|
85
85
|
info(
|
|
@@ -87,7 +87,7 @@ declare module '../../index' {
|
|
|
87
87
|
...args: any[]
|
|
88
88
|
): void
|
|
89
89
|
/** 向调试面板中打印 log 日志
|
|
90
|
-
* @supported weapp
|
|
90
|
+
* @supported weapp
|
|
91
91
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.log.html
|
|
92
92
|
*/
|
|
93
93
|
log(
|
|
@@ -95,7 +95,7 @@ declare module '../../index' {
|
|
|
95
95
|
...args: any[]
|
|
96
96
|
): void
|
|
97
97
|
/** 向调试面板中打印 warn 日志
|
|
98
|
-
* @supported weapp
|
|
98
|
+
* @supported weapp
|
|
99
99
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.warn.html
|
|
100
100
|
*/
|
|
101
101
|
warn(
|
package/types/api/base/env.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ import Taro from '../../index'
|
|
|
3
3
|
declare module '../../index' {
|
|
4
4
|
interface TaroStatic {
|
|
5
5
|
/**
|
|
6
|
-
* @supported weapp
|
|
6
|
+
* @supported weapp
|
|
7
7
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/env/envObj.html
|
|
8
8
|
*/
|
|
9
9
|
env: {
|
|
10
10
|
[key: string]: string | undefined
|
|
11
11
|
/** 框架 */
|
|
12
|
-
FRAMEWORK: 'react'
|
|
12
|
+
FRAMEWORK: 'react'
|
|
13
13
|
/** Taro 环境变量 */
|
|
14
|
-
TARO_ENV: 'weapp'
|
|
14
|
+
TARO_ENV: 'weapp'
|
|
15
15
|
/** 文件系统中的用户目录路径 (本地路径) */
|
|
16
16
|
USER_DATA_PATH?: string
|
|
17
17
|
}
|
|
@@ -3,7 +3,7 @@ import Taro from '../../index'
|
|
|
3
3
|
declare module '../../index' {
|
|
4
4
|
interface TaroStatic {
|
|
5
5
|
/** 判断小程序的 API,回调,参数,组件等是否在当前版本可用。
|
|
6
|
-
* @supported weapp
|
|
6
|
+
* @supported weapp
|
|
7
7
|
* @example
|
|
8
8
|
* ```tsx
|
|
9
9
|
* Taro.canIUse('openBluetoothAdapter')
|
|
@@ -44,7 +44,7 @@ declare module '../../index' {
|
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* 将 Base64 字符串转成 ArrayBuffer 数据。
|
|
47
|
-
* @supported weapp
|
|
47
|
+
* @supported weapp
|
|
48
48
|
* @example
|
|
49
49
|
* ```tsx
|
|
50
50
|
* const base64 = 'CxYh'
|
|
@@ -59,7 +59,7 @@ declare module '../../index' {
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* 将 ArrayBuffer 数据转成 Base64 字符串。
|
|
62
|
-
* @supported weapp
|
|
62
|
+
* @supported weapp
|
|
63
63
|
* @example
|
|
64
64
|
* ```tsx
|
|
65
65
|
* const arrayBuffer = new Uint8Array([11, 22, 33])
|
|
@@ -24,7 +24,7 @@ declare module '../../index' {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/** Performance 对象,用于获取性能数据及创建性能监听器
|
|
27
|
-
* @supported weapp
|
|
27
|
+
* @supported weapp
|
|
28
28
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.html
|
|
29
29
|
*/
|
|
30
30
|
interface Performance {
|
|
@@ -34,17 +34,17 @@ declare module '../../index' {
|
|
|
34
34
|
*/
|
|
35
35
|
createObserver(callback: TaroGeneral.TFunc): PerformanceObserver
|
|
36
36
|
/** 该方法返回当前缓冲区中的所有性能数据
|
|
37
|
-
* @supported weapp
|
|
37
|
+
* @supported weapp
|
|
38
38
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntries.html
|
|
39
39
|
*/
|
|
40
40
|
getEntries(): PerformanceEntry[]
|
|
41
41
|
/** 获取当前缓冲区中所有名称为 [name] 且类型为 [entryType] 的性能数据
|
|
42
|
-
* @supported weapp
|
|
42
|
+
* @supported weapp
|
|
43
43
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntriesByName.html
|
|
44
44
|
*/
|
|
45
45
|
getEntriesByName(name: string, entryType: string): PerformanceEntry[]
|
|
46
46
|
/** 获取当前缓冲区中所有类型为 [entryType] 的性能数据
|
|
47
|
-
* @supported weapp
|
|
47
|
+
* @supported weapp
|
|
48
48
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntriesByType.html
|
|
49
49
|
*/
|
|
50
50
|
getEntriesByType(entryType: string): PerformanceEntry[]
|
|
@@ -242,7 +242,7 @@ declare module '../../index' {
|
|
|
242
242
|
* **注意**
|
|
243
243
|
* - 目前,当开启代码 [按需注入](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/lazyload.html) `时,evaluateScript` 将仅包含公有部分代码,页面和组件的代码注入的时间会包含在 `firstRender` 中(因为页面和组件的代码注入过程成为了首次渲染过程的一部分)。因此开启按需注入后,脚本耗时降低,渲染时间提高属于正常现象,优化效果可以关注整体启动耗时(`appLaunch`)来评估。
|
|
244
244
|
* - `firstPaint` 和 `firstContentfulPaint` 指标在开启 `vconsole` 的情况下,由于绘制 `vconsoel` 的面板,会导致数据提前。
|
|
245
|
-
* @supported weapp
|
|
245
|
+
* @supported weapp
|
|
246
246
|
* @example
|
|
247
247
|
* ```tsx
|
|
248
248
|
* const performance = Taro.getPerformance()
|