@wevu/api 0.2.6 → 0.2.8
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 +92 -50
- 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
|
|
@@ -107,6 +153,9 @@ function isNonPromisifiedMethod(name) {
|
|
|
107
153
|
function isPlainObject(value) {
|
|
108
154
|
return Object.prototype.toString.call(value) === "[object Object]";
|
|
109
155
|
}
|
|
156
|
+
function hasOwn(source, key) {
|
|
157
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
158
|
+
}
|
|
110
159
|
function hasCallbacks(value) {
|
|
111
160
|
if (!isPlainObject(value)) return false;
|
|
112
161
|
return typeof value.success === "function" || typeof value.fail === "function" || typeof value.complete === "function";
|
|
@@ -129,7 +178,7 @@ function createNotSupportedError(methodName, platform) {
|
|
|
129
178
|
//#region src/core/callBridge.ts
|
|
130
179
|
function resolveOptionsArg$1(args) {
|
|
131
180
|
const nextArgs = args.slice();
|
|
132
|
-
const lastArg = nextArgs.length > 0 ? nextArgs.
|
|
181
|
+
const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
|
|
133
182
|
if (isPlainObject(lastArg)) {
|
|
134
183
|
const options = { ...lastArg };
|
|
135
184
|
nextArgs[nextArgs.length - 1] = options;
|
|
@@ -149,7 +198,7 @@ function resolveOptionsArg$1(args) {
|
|
|
149
198
|
* @description 将错误按小程序回调风格分发;若无回调则返回 reject Promise。
|
|
150
199
|
*/
|
|
151
200
|
function callWithError(error, args) {
|
|
152
|
-
const lastArg = args.length > 0 ? args.
|
|
201
|
+
const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
|
|
153
202
|
if (hasCallbacks(lastArg)) {
|
|
154
203
|
lastArg.fail?.(error);
|
|
155
204
|
lastArg.complete?.(error);
|
|
@@ -727,11 +776,11 @@ const WEAPI_TT_METHODS = [...WEAPI_TT_METHODS_APPLY_EC_COUPON_TO_UNSUBSCRIBE_ALL
|
|
|
727
776
|
const WEAPI_TYPE_SOURCES = {
|
|
728
777
|
default: {
|
|
729
778
|
package: "miniprogram-api-typings",
|
|
730
|
-
version: "5.
|
|
779
|
+
version: "5.2.0"
|
|
731
780
|
},
|
|
732
781
|
wechat: {
|
|
733
782
|
package: "miniprogram-api-typings",
|
|
734
|
-
version: "5.
|
|
783
|
+
version: "5.2.0"
|
|
735
784
|
},
|
|
736
785
|
alipay: {
|
|
737
786
|
package: "@mini-types/alipay",
|
|
@@ -743,7 +792,7 @@ const WEAPI_TYPE_SOURCES = {
|
|
|
743
792
|
},
|
|
744
793
|
wx: {
|
|
745
794
|
package: "miniprogram-api-typings",
|
|
746
|
-
version: "5.
|
|
795
|
+
version: "5.2.0"
|
|
747
796
|
},
|
|
748
797
|
my: {
|
|
749
798
|
package: "@mini-types/alipay",
|
|
@@ -1293,7 +1342,7 @@ function mapSaveFileArgs(args) {
|
|
|
1293
1342
|
const lastArg = nextArgs[lastIndex];
|
|
1294
1343
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1295
1344
|
const nextOptions = { ...lastArg };
|
|
1296
|
-
if (!
|
|
1345
|
+
if (!hasOwn(nextOptions, "apFilePath") && hasOwn(nextOptions, "tempFilePath")) nextOptions.apFilePath = nextOptions.tempFilePath;
|
|
1297
1346
|
nextArgs[lastIndex] = nextOptions;
|
|
1298
1347
|
return nextArgs;
|
|
1299
1348
|
}
|
|
@@ -1303,15 +1352,15 @@ function mapCreateRewardedVideoAdArgs(args) {
|
|
|
1303
1352
|
const lastIndex = nextArgs.length - 1;
|
|
1304
1353
|
const lastArg = nextArgs[lastIndex];
|
|
1305
1354
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1306
|
-
if (
|
|
1307
|
-
if (
|
|
1355
|
+
if (hasOwn(lastArg, "multiton") && lastArg.multiton === true) throw createNotSupportedError("createRewardedVideoAd", "my");
|
|
1356
|
+
if (hasOwn(lastArg, "disableFallbackSharePage") && lastArg.disableFallbackSharePage === true) throw createNotSupportedError("createRewardedVideoAd", "my");
|
|
1308
1357
|
const adUnitId = lastArg.adUnitId;
|
|
1309
1358
|
if (typeof adUnitId === "string" && adUnitId.length > 0) nextArgs[lastIndex] = adUnitId;
|
|
1310
1359
|
return nextArgs;
|
|
1311
1360
|
}
|
|
1312
1361
|
function mapRewardedAdInstance(result, args = []) {
|
|
1313
1362
|
if (typeof result !== "object" || result === null) return result;
|
|
1314
|
-
const adUnitIdArg = args.length > 0 ? args.
|
|
1363
|
+
const adUnitIdArg = args.length > 0 ? args[args.length - 1] : void 0;
|
|
1315
1364
|
const adUnitId = typeof adUnitIdArg === "string" ? adUnitIdArg : void 0;
|
|
1316
1365
|
if (!adUnitId) return result;
|
|
1317
1366
|
const rewardedAd = result;
|
|
@@ -1343,7 +1392,7 @@ function mapCheckIsSoterEnrolledInDeviceArgs(args) {
|
|
|
1343
1392
|
}
|
|
1344
1393
|
function mapSoterCheckResult(methodName, result) {
|
|
1345
1394
|
if (!isPlainObject(result)) return result;
|
|
1346
|
-
if (
|
|
1395
|
+
if (hasOwn(result, "errMsg")) return result;
|
|
1347
1396
|
return {
|
|
1348
1397
|
...result,
|
|
1349
1398
|
errMsg: `${methodName}:ok`
|
|
@@ -1359,11 +1408,11 @@ function toNumberCode(value) {
|
|
|
1359
1408
|
function mapBleConnectionResult(methodName, codeKey, result) {
|
|
1360
1409
|
if (!isPlainObject(result)) return result;
|
|
1361
1410
|
const nextResult = { ...result };
|
|
1362
|
-
if (!
|
|
1411
|
+
if (!hasOwn(nextResult, "errCode")) {
|
|
1363
1412
|
const code = toNumberCode(nextResult[codeKey]);
|
|
1364
1413
|
if (typeof code === "number") nextResult.errCode = code;
|
|
1365
1414
|
}
|
|
1366
|
-
if (!
|
|
1415
|
+
if (!hasOwn(nextResult, "errMsg")) {
|
|
1367
1416
|
if (typeof nextResult.errorMessage === "string" && nextResult.errorMessage.length > 0) nextResult.errMsg = nextResult.errorMessage;
|
|
1368
1417
|
else if (nextResult.errCode === 0) nextResult.errMsg = `${methodName}:ok`;
|
|
1369
1418
|
}
|
|
@@ -1377,7 +1426,7 @@ function mapCloseBleConnectionResult(result) {
|
|
|
1377
1426
|
}
|
|
1378
1427
|
function mapSaveFileResult(result) {
|
|
1379
1428
|
if (!isPlainObject(result)) return result;
|
|
1380
|
-
if (!
|
|
1429
|
+
if (!hasOwn(result, "savedFilePath") && hasOwn(result, "apFilePath")) return {
|
|
1381
1430
|
...result,
|
|
1382
1431
|
savedFilePath: result.apFilePath
|
|
1383
1432
|
};
|
|
@@ -1385,7 +1434,7 @@ function mapSaveFileResult(result) {
|
|
|
1385
1434
|
}
|
|
1386
1435
|
function mapDouyinSaveFileResult(result) {
|
|
1387
1436
|
if (!isPlainObject(result)) return result;
|
|
1388
|
-
if (!
|
|
1437
|
+
if (!hasOwn(result, "savedFilePath") && hasOwn(result, "filePath")) return {
|
|
1389
1438
|
...result,
|
|
1390
1439
|
savedFilePath: result.filePath
|
|
1391
1440
|
};
|
|
@@ -1412,8 +1461,8 @@ function mapToastArgs(args) {
|
|
|
1412
1461
|
const lastArg = nextArgs[lastIndex];
|
|
1413
1462
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1414
1463
|
const nextOptions = { ...lastArg };
|
|
1415
|
-
if (!
|
|
1416
|
-
if (
|
|
1464
|
+
if (!hasOwn(nextOptions, "content") && hasOwn(nextOptions, "title")) nextOptions.content = nextOptions.title;
|
|
1465
|
+
if (hasOwn(nextOptions, "icon")) nextOptions.type = mapToastType(nextOptions.icon);
|
|
1417
1466
|
nextArgs[lastIndex] = nextOptions;
|
|
1418
1467
|
return nextArgs;
|
|
1419
1468
|
}
|
|
@@ -1435,7 +1484,7 @@ function mapLoadingArgs(args) {
|
|
|
1435
1484
|
const lastArg = nextArgs[lastIndex];
|
|
1436
1485
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1437
1486
|
const nextOptions = { ...lastArg };
|
|
1438
|
-
if (!
|
|
1487
|
+
if (!hasOwn(nextOptions, "content") && hasOwn(nextOptions, "title")) nextOptions.content = nextOptions.title;
|
|
1439
1488
|
nextArgs[lastIndex] = nextOptions;
|
|
1440
1489
|
return nextArgs;
|
|
1441
1490
|
}
|
|
@@ -1446,13 +1495,13 @@ function mapActionSheetArgs(args) {
|
|
|
1446
1495
|
const lastArg = nextArgs[lastIndex];
|
|
1447
1496
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1448
1497
|
const nextOptions = { ...lastArg };
|
|
1449
|
-
if (!
|
|
1498
|
+
if (!hasOwn(nextOptions, "items") && Array.isArray(nextOptions.itemList)) nextOptions.items = nextOptions.itemList;
|
|
1450
1499
|
nextArgs[lastIndex] = nextOptions;
|
|
1451
1500
|
return nextArgs;
|
|
1452
1501
|
}
|
|
1453
1502
|
function mapActionSheetResult(result) {
|
|
1454
1503
|
if (!isPlainObject(result)) return result;
|
|
1455
|
-
if (!
|
|
1504
|
+
if (!hasOwn(result, "tapIndex") && hasOwn(result, "index")) return {
|
|
1456
1505
|
...result,
|
|
1457
1506
|
tapIndex: result.index
|
|
1458
1507
|
};
|
|
@@ -1465,11 +1514,11 @@ function mapModalArgs(args) {
|
|
|
1465
1514
|
const lastArg = nextArgs[lastIndex];
|
|
1466
1515
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1467
1516
|
const nextOptions = { ...lastArg };
|
|
1468
|
-
if (
|
|
1469
|
-
if (
|
|
1470
|
-
if (
|
|
1471
|
-
if (!
|
|
1472
|
-
if (!
|
|
1517
|
+
if (hasOwn(nextOptions, "showCancel") && nextOptions.showCancel === false) throw createNotSupportedError("showModal", "my");
|
|
1518
|
+
if (hasOwn(nextOptions, "editable") && nextOptions.editable === true) throw createNotSupportedError("showModal", "my");
|
|
1519
|
+
if (hasOwn(nextOptions, "placeholderText")) throw createNotSupportedError("showModal", "my");
|
|
1520
|
+
if (!hasOwn(nextOptions, "confirmButtonText") && hasOwn(nextOptions, "confirmText")) nextOptions.confirmButtonText = nextOptions.confirmText;
|
|
1521
|
+
if (!hasOwn(nextOptions, "cancelButtonText") && hasOwn(nextOptions, "cancelText")) nextOptions.cancelButtonText = nextOptions.cancelText;
|
|
1473
1522
|
nextArgs[lastIndex] = nextOptions;
|
|
1474
1523
|
return nextArgs;
|
|
1475
1524
|
}
|
|
@@ -1477,11 +1526,11 @@ function mapModalResult(result) {
|
|
|
1477
1526
|
if (!isPlainObject(result)) return result;
|
|
1478
1527
|
let changed = false;
|
|
1479
1528
|
const nextResult = { ...result };
|
|
1480
|
-
if (!
|
|
1529
|
+
if (!hasOwn(nextResult, "cancel") && hasOwn(nextResult, "confirm")) {
|
|
1481
1530
|
nextResult.cancel = !nextResult.confirm;
|
|
1482
1531
|
changed = true;
|
|
1483
1532
|
}
|
|
1484
|
-
if (!
|
|
1533
|
+
if (!hasOwn(nextResult, "content")) {
|
|
1485
1534
|
nextResult.content = "";
|
|
1486
1535
|
changed = true;
|
|
1487
1536
|
}
|
|
@@ -1489,7 +1538,7 @@ function mapModalResult(result) {
|
|
|
1489
1538
|
}
|
|
1490
1539
|
function mapChooseImageResult(result) {
|
|
1491
1540
|
if (!isPlainObject(result)) return result;
|
|
1492
|
-
if (!
|
|
1541
|
+
if (!hasOwn(result, "tempFilePaths") && Array.isArray(result.apFilePaths)) return {
|
|
1493
1542
|
...result,
|
|
1494
1543
|
tempFilePaths: result.apFilePaths
|
|
1495
1544
|
};
|
|
@@ -1525,13 +1574,13 @@ function mapSetClipboardArgs(args) {
|
|
|
1525
1574
|
const lastArg = nextArgs[lastIndex];
|
|
1526
1575
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1527
1576
|
const nextOptions = { ...lastArg };
|
|
1528
|
-
if (!
|
|
1577
|
+
if (!hasOwn(nextOptions, "text") && hasOwn(nextOptions, "data")) nextOptions.text = nextOptions.data;
|
|
1529
1578
|
nextArgs[lastIndex] = nextOptions;
|
|
1530
1579
|
return nextArgs;
|
|
1531
1580
|
}
|
|
1532
1581
|
function mapClipboardResult(result) {
|
|
1533
1582
|
if (!isPlainObject(result)) return result;
|
|
1534
|
-
if (!
|
|
1583
|
+
if (!hasOwn(result, "data") && hasOwn(result, "text")) return {
|
|
1535
1584
|
...result,
|
|
1536
1585
|
data: result.text
|
|
1537
1586
|
};
|
|
@@ -2129,7 +2178,6 @@ const PLATFORM_METHOD_SET = {
|
|
|
2129
2178
|
my: new Set(WEAPI_ALIPAY_METHODS),
|
|
2130
2179
|
tt: new Set(WEAPI_DOUYIN_METHODS)
|
|
2131
2180
|
};
|
|
2132
|
-
function createFallbackMappingRule(platform, methodName) {}
|
|
2133
2181
|
function resolveMappingRule(platform, methodName, options = {}) {
|
|
2134
2182
|
const methodSet = PLATFORM_METHOD_SET[platform];
|
|
2135
2183
|
const explicitRule = METHOD_MAPPINGS[platform]?.[methodName];
|
|
@@ -2146,12 +2194,6 @@ function resolveMappingRule(platform, methodName, options = {}) {
|
|
|
2146
2194
|
target: methodName,
|
|
2147
2195
|
source: "identity"
|
|
2148
2196
|
};
|
|
2149
|
-
const fallbackRule = createFallbackMappingRule(platform, methodName);
|
|
2150
|
-
if (fallbackRule) return {
|
|
2151
|
-
target: fallbackRule.target,
|
|
2152
|
-
source: "fallback",
|
|
2153
|
-
rule: fallbackRule
|
|
2154
|
-
};
|
|
2155
2197
|
return {
|
|
2156
2198
|
target: methodName,
|
|
2157
2199
|
source: "identity"
|
|
@@ -2200,13 +2242,13 @@ function resolveQueueSize(value) {
|
|
|
2200
2242
|
return Math.max(1, Math.floor(value));
|
|
2201
2243
|
}
|
|
2202
2244
|
function resolveCurrentMiniProgramHostConfig() {
|
|
2203
|
-
const runtimeRoot =
|
|
2245
|
+
const runtimeRoot = resolveRuntimeRoot();
|
|
2204
2246
|
for (const globalKey of getMiniProgramRuntimeGlobalKeys()) {
|
|
2205
|
-
if (!runtimeRoot
|
|
2206
|
-
const hostConfig =
|
|
2247
|
+
if (!resolveRuntimeGlobalValue(globalKey, runtimeRoot)) continue;
|
|
2248
|
+
const hostConfig = resolveRuntimeGlobalValue(getMiniProgramRuntimeHostConfigKey(getMiniProgramPlatformByRuntimeGlobalKey(globalKey)), runtimeRoot);
|
|
2207
2249
|
return isPlainObject(hostConfig) ? hostConfig : void 0;
|
|
2208
2250
|
}
|
|
2209
|
-
const defaultHostConfig =
|
|
2251
|
+
const defaultHostConfig = resolveRuntimeGlobalValue(getMiniProgramRuntimeHostConfigKey(void 0), runtimeRoot);
|
|
2210
2252
|
return isPlainObject(defaultHostConfig) ? defaultHostConfig : void 0;
|
|
2211
2253
|
}
|
|
2212
2254
|
function resolveHostTimeoutConfig() {
|
|
@@ -2230,7 +2272,7 @@ function clearTimer(timer) {
|
|
|
2230
2272
|
}
|
|
2231
2273
|
function resolveOptionsArg(args) {
|
|
2232
2274
|
const nextArgs = args.slice();
|
|
2233
|
-
const lastArg = nextArgs.length > 0 ? nextArgs.
|
|
2275
|
+
const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
|
|
2234
2276
|
if (isPlainObject(lastArg)) {
|
|
2235
2277
|
const options = { ...lastArg };
|
|
2236
2278
|
nextArgs[nextArgs.length - 1] = options;
|
|
@@ -2532,7 +2574,7 @@ function createWeapi(options = {}) {
|
|
|
2532
2574
|
try {
|
|
2533
2575
|
runtimeArgs = mappingRule?.mapArgs ? mappingRule.mapArgs(args) : args;
|
|
2534
2576
|
} catch (error) {
|
|
2535
|
-
const lastArg = args.length > 0 ? args.
|
|
2577
|
+
const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
|
|
2536
2578
|
if (hasCallbacks(lastArg)) {
|
|
2537
2579
|
lastArg.fail?.(error);
|
|
2538
2580
|
lastArg.complete?.(error);
|
|
@@ -2545,7 +2587,7 @@ function createWeapi(options = {}) {
|
|
|
2545
2587
|
const result = runtimeMethod.apply(runtimeAdapter, runtimeArgs);
|
|
2546
2588
|
return mappingRule?.mapResult ? mappingRule.mapResult(result, runtimeArgs) : result;
|
|
2547
2589
|
}
|
|
2548
|
-
const lastArg = runtimeArgs.length > 0 ? runtimeArgs.
|
|
2590
|
+
const lastArg = runtimeArgs.length > 0 ? runtimeArgs[runtimeArgs.length - 1] : void 0;
|
|
2549
2591
|
if (hasCallbacks(lastArg)) {
|
|
2550
2592
|
if (mappingRule?.mapResult && isPlainObject(lastArg)) {
|
|
2551
2593
|
const options = lastArg;
|
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.8",
|
|
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": {
|