@wevu/api 0.2.6 → 0.2.7
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/index.d.mts +6 -6
- package/dist/index.mjs +60 -14
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -8306,11 +8306,11 @@ declare function createWeapi<TAdapter extends WeapiAdapter = WeapiCrossPlatformR
|
|
|
8306
8306
|
declare const WEAPI_TYPE_SOURCES: {
|
|
8307
8307
|
readonly default: {
|
|
8308
8308
|
readonly package: "miniprogram-api-typings";
|
|
8309
|
-
readonly version: "5.
|
|
8309
|
+
readonly version: "5.2.0";
|
|
8310
8310
|
};
|
|
8311
8311
|
readonly wechat: {
|
|
8312
8312
|
readonly package: "miniprogram-api-typings";
|
|
8313
|
-
readonly version: "5.
|
|
8313
|
+
readonly version: "5.2.0";
|
|
8314
8314
|
};
|
|
8315
8315
|
readonly alipay: {
|
|
8316
8316
|
readonly package: "@mini-types/alipay";
|
|
@@ -8322,7 +8322,7 @@ declare const WEAPI_TYPE_SOURCES: {
|
|
|
8322
8322
|
};
|
|
8323
8323
|
readonly wx: {
|
|
8324
8324
|
readonly package: "miniprogram-api-typings";
|
|
8325
|
-
readonly version: "5.
|
|
8325
|
+
readonly version: "5.2.0";
|
|
8326
8326
|
};
|
|
8327
8327
|
readonly my: {
|
|
8328
8328
|
readonly package: "@mini-types/alipay";
|
|
@@ -8336,11 +8336,11 @@ declare const WEAPI_TYPE_SOURCES: {
|
|
|
8336
8336
|
declare const WEAPI_PLATFORM_TYPE_SOURCES: {
|
|
8337
8337
|
readonly default: {
|
|
8338
8338
|
readonly package: "miniprogram-api-typings";
|
|
8339
|
-
readonly version: "5.
|
|
8339
|
+
readonly version: "5.2.0";
|
|
8340
8340
|
};
|
|
8341
8341
|
readonly wechat: {
|
|
8342
8342
|
readonly package: "miniprogram-api-typings";
|
|
8343
|
-
readonly version: "5.
|
|
8343
|
+
readonly version: "5.2.0";
|
|
8344
8344
|
};
|
|
8345
8345
|
readonly alipay: {
|
|
8346
8346
|
readonly package: "@mini-types/alipay";
|
|
@@ -8354,7 +8354,7 @@ declare const WEAPI_PLATFORM_TYPE_SOURCES: {
|
|
|
8354
8354
|
declare const WEAPI_RUNTIME_TYPE_SOURCES: {
|
|
8355
8355
|
readonly wx: {
|
|
8356
8356
|
readonly package: "miniprogram-api-typings";
|
|
8357
|
-
readonly version: "5.
|
|
8357
|
+
readonly version: "5.2.0";
|
|
8358
8358
|
};
|
|
8359
8359
|
readonly my: {
|
|
8360
8360
|
readonly package: "@mini-types/alipay";
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,55 @@
|
|
|
1
1
|
import { getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeHostConfigKey, normalizeMiniProgramPlatform, resolveMiniProgramPlatform } from "@weapp-core/shared";
|
|
2
|
+
//#region src/core/runtimeGlobal.ts
|
|
3
|
+
/**
|
|
4
|
+
* @description 静态解析当前运行环境的全局根对象,兼容不提供 globalThis 的小程序 worker。
|
|
5
|
+
*/
|
|
6
|
+
function resolveRuntimeRoots() {
|
|
7
|
+
const roots = [];
|
|
8
|
+
const appendRoot = (root) => {
|
|
9
|
+
if (root && !roots.includes(root)) roots.push(root);
|
|
10
|
+
};
|
|
11
|
+
if (typeof globalThis !== "undefined") appendRoot(globalThis);
|
|
12
|
+
if (typeof self !== "undefined") appendRoot(self);
|
|
13
|
+
if (typeof window !== "undefined") appendRoot(window);
|
|
14
|
+
if (typeof global !== "undefined") appendRoot(global);
|
|
15
|
+
return roots;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @description 静态解析当前运行环境的首个全局根对象。
|
|
19
|
+
*/
|
|
20
|
+
function resolveRuntimeRoot() {
|
|
21
|
+
return resolveRuntimeRoots()[0];
|
|
22
|
+
}
|
|
23
|
+
function resolveTopLevelRuntimeValue(key) {
|
|
24
|
+
switch (key) {
|
|
25
|
+
case "wx": return typeof wx !== "undefined" ? wx : void 0;
|
|
26
|
+
case "my": return typeof my !== "undefined" ? my : void 0;
|
|
27
|
+
case "tt": return typeof tt !== "undefined" ? tt : void 0;
|
|
28
|
+
case "swan": return typeof swan !== "undefined" ? swan : void 0;
|
|
29
|
+
case "jd": return typeof jd !== "undefined" ? jd : void 0;
|
|
30
|
+
case "xhs": return typeof xhs !== "undefined" ? xhs : void 0;
|
|
31
|
+
case "qq": return typeof qq !== "undefined" ? qq : void 0;
|
|
32
|
+
case "ks": return typeof ks !== "undefined" ? ks : void 0;
|
|
33
|
+
case "dd": return typeof dd !== "undefined" ? dd : void 0;
|
|
34
|
+
case "qa": return typeof qa !== "undefined" ? qa : void 0;
|
|
35
|
+
case "qapp": return typeof qapp !== "undefined" ? qapp : void 0;
|
|
36
|
+
case "uni": return typeof uni !== "undefined" ? uni : void 0;
|
|
37
|
+
case "__wxConfig": return typeof __wxConfig !== "undefined" ? __wxConfig : void 0;
|
|
38
|
+
default: return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @description 从全局根对象或小程序顶层全局变量读取运行时值。
|
|
43
|
+
*/
|
|
44
|
+
function resolveRuntimeGlobalValue(key, root = resolveRuntimeRoot()) {
|
|
45
|
+
const roots = root ? [root, ...resolveRuntimeRoots().filter((item) => item !== root)] : resolveRuntimeRoots();
|
|
46
|
+
for (const item of roots) {
|
|
47
|
+
const value = item[key];
|
|
48
|
+
if (value !== void 0) return value;
|
|
49
|
+
}
|
|
50
|
+
return resolveTopLevelRuntimeValue(key);
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
2
53
|
//#region src/core/adapter.ts
|
|
3
54
|
const GLOBAL_ADAPTER_KEYS = [
|
|
4
55
|
...getMiniProgramRuntimeGlobalKeys().map((key) => ({
|
|
@@ -30,10 +81,6 @@ const GLOBAL_ADAPTER_KEYS = [
|
|
|
30
81
|
key: "uni"
|
|
31
82
|
}
|
|
32
83
|
];
|
|
33
|
-
function resolveGlobalThis() {
|
|
34
|
-
if (typeof globalThis !== "undefined") return globalThis;
|
|
35
|
-
if (typeof window !== "undefined") return window;
|
|
36
|
-
}
|
|
37
84
|
function isAdapterCandidate(value) {
|
|
38
85
|
return typeof value === "object" || typeof value === "function";
|
|
39
86
|
}
|
|
@@ -41,10 +88,9 @@ function isAdapterCandidate(value) {
|
|
|
41
88
|
* @description 侦测当前运行环境的全局 API 对象
|
|
42
89
|
*/
|
|
43
90
|
function detectGlobalAdapter() {
|
|
44
|
-
const root =
|
|
45
|
-
if (!root) return {};
|
|
91
|
+
const root = resolveRuntimeRoot();
|
|
46
92
|
for (const item of GLOBAL_ADAPTER_KEYS) {
|
|
47
|
-
const candidate =
|
|
93
|
+
const candidate = resolveRuntimeGlobalValue(item.key, root);
|
|
48
94
|
if (isAdapterCandidate(candidate)) return {
|
|
49
95
|
adapter: candidate,
|
|
50
96
|
platform: item.platform
|
|
@@ -727,11 +773,11 @@ const WEAPI_TT_METHODS = [...WEAPI_TT_METHODS_APPLY_EC_COUPON_TO_UNSUBSCRIBE_ALL
|
|
|
727
773
|
const WEAPI_TYPE_SOURCES = {
|
|
728
774
|
default: {
|
|
729
775
|
package: "miniprogram-api-typings",
|
|
730
|
-
version: "5.
|
|
776
|
+
version: "5.2.0"
|
|
731
777
|
},
|
|
732
778
|
wechat: {
|
|
733
779
|
package: "miniprogram-api-typings",
|
|
734
|
-
version: "5.
|
|
780
|
+
version: "5.2.0"
|
|
735
781
|
},
|
|
736
782
|
alipay: {
|
|
737
783
|
package: "@mini-types/alipay",
|
|
@@ -743,7 +789,7 @@ const WEAPI_TYPE_SOURCES = {
|
|
|
743
789
|
},
|
|
744
790
|
wx: {
|
|
745
791
|
package: "miniprogram-api-typings",
|
|
746
|
-
version: "5.
|
|
792
|
+
version: "5.2.0"
|
|
747
793
|
},
|
|
748
794
|
my: {
|
|
749
795
|
package: "@mini-types/alipay",
|
|
@@ -2200,13 +2246,13 @@ function resolveQueueSize(value) {
|
|
|
2200
2246
|
return Math.max(1, Math.floor(value));
|
|
2201
2247
|
}
|
|
2202
2248
|
function resolveCurrentMiniProgramHostConfig() {
|
|
2203
|
-
const runtimeRoot =
|
|
2249
|
+
const runtimeRoot = resolveRuntimeRoot();
|
|
2204
2250
|
for (const globalKey of getMiniProgramRuntimeGlobalKeys()) {
|
|
2205
|
-
if (!runtimeRoot
|
|
2206
|
-
const hostConfig =
|
|
2251
|
+
if (!resolveRuntimeGlobalValue(globalKey, runtimeRoot)) continue;
|
|
2252
|
+
const hostConfig = resolveRuntimeGlobalValue(getMiniProgramRuntimeHostConfigKey(getMiniProgramPlatformByRuntimeGlobalKey(globalKey)), runtimeRoot);
|
|
2207
2253
|
return isPlainObject(hostConfig) ? hostConfig : void 0;
|
|
2208
2254
|
}
|
|
2209
|
-
const defaultHostConfig =
|
|
2255
|
+
const defaultHostConfig = resolveRuntimeGlobalValue(getMiniProgramRuntimeHostConfigKey(void 0), runtimeRoot);
|
|
2210
2256
|
return isPlainObject(defaultHostConfig) ? defaultHostConfig : void 0;
|
|
2211
2257
|
}
|
|
2212
2258
|
function resolveHostTimeoutConfig() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"description": "tsdown bundler template",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@douyin-microapp/typings": "^1.3.1",
|
|
36
36
|
"@mini-types/alipay": "^3.0.14",
|
|
37
|
-
"miniprogram-api-typings": "^5.
|
|
37
|
+
"miniprogram-api-typings": "^5.2.0",
|
|
38
38
|
"@weapp-core/shared": "3.0.4"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|