@wevu/api 0.2.7 → 0.2.9
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 +35 -39
- 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.2.
|
|
8309
|
+
readonly version: "5.2.1";
|
|
8310
8310
|
};
|
|
8311
8311
|
readonly wechat: {
|
|
8312
8312
|
readonly package: "miniprogram-api-typings";
|
|
8313
|
-
readonly version: "5.2.
|
|
8313
|
+
readonly version: "5.2.1";
|
|
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.2.
|
|
8325
|
+
readonly version: "5.2.1";
|
|
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.2.
|
|
8339
|
+
readonly version: "5.2.1";
|
|
8340
8340
|
};
|
|
8341
8341
|
readonly wechat: {
|
|
8342
8342
|
readonly package: "miniprogram-api-typings";
|
|
8343
|
-
readonly version: "5.2.
|
|
8343
|
+
readonly version: "5.2.1";
|
|
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.2.
|
|
8357
|
+
readonly version: "5.2.1";
|
|
8358
8358
|
};
|
|
8359
8359
|
readonly my: {
|
|
8360
8360
|
readonly package: "@mini-types/alipay";
|
package/dist/index.mjs
CHANGED
|
@@ -153,6 +153,9 @@ function isNonPromisifiedMethod(name) {
|
|
|
153
153
|
function isPlainObject(value) {
|
|
154
154
|
return Object.prototype.toString.call(value) === "[object Object]";
|
|
155
155
|
}
|
|
156
|
+
function hasOwn(source, key) {
|
|
157
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
158
|
+
}
|
|
156
159
|
function hasCallbacks(value) {
|
|
157
160
|
if (!isPlainObject(value)) return false;
|
|
158
161
|
return typeof value.success === "function" || typeof value.fail === "function" || typeof value.complete === "function";
|
|
@@ -175,7 +178,7 @@ function createNotSupportedError(methodName, platform) {
|
|
|
175
178
|
//#region src/core/callBridge.ts
|
|
176
179
|
function resolveOptionsArg$1(args) {
|
|
177
180
|
const nextArgs = args.slice();
|
|
178
|
-
const lastArg = nextArgs.length > 0 ? nextArgs.
|
|
181
|
+
const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
|
|
179
182
|
if (isPlainObject(lastArg)) {
|
|
180
183
|
const options = { ...lastArg };
|
|
181
184
|
nextArgs[nextArgs.length - 1] = options;
|
|
@@ -195,7 +198,7 @@ function resolveOptionsArg$1(args) {
|
|
|
195
198
|
* @description 将错误按小程序回调风格分发;若无回调则返回 reject Promise。
|
|
196
199
|
*/
|
|
197
200
|
function callWithError(error, args) {
|
|
198
|
-
const lastArg = args.length > 0 ? args.
|
|
201
|
+
const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
|
|
199
202
|
if (hasCallbacks(lastArg)) {
|
|
200
203
|
lastArg.fail?.(error);
|
|
201
204
|
lastArg.complete?.(error);
|
|
@@ -773,11 +776,11 @@ const WEAPI_TT_METHODS = [...WEAPI_TT_METHODS_APPLY_EC_COUPON_TO_UNSUBSCRIBE_ALL
|
|
|
773
776
|
const WEAPI_TYPE_SOURCES = {
|
|
774
777
|
default: {
|
|
775
778
|
package: "miniprogram-api-typings",
|
|
776
|
-
version: "5.2.
|
|
779
|
+
version: "5.2.1"
|
|
777
780
|
},
|
|
778
781
|
wechat: {
|
|
779
782
|
package: "miniprogram-api-typings",
|
|
780
|
-
version: "5.2.
|
|
783
|
+
version: "5.2.1"
|
|
781
784
|
},
|
|
782
785
|
alipay: {
|
|
783
786
|
package: "@mini-types/alipay",
|
|
@@ -789,7 +792,7 @@ const WEAPI_TYPE_SOURCES = {
|
|
|
789
792
|
},
|
|
790
793
|
wx: {
|
|
791
794
|
package: "miniprogram-api-typings",
|
|
792
|
-
version: "5.2.
|
|
795
|
+
version: "5.2.1"
|
|
793
796
|
},
|
|
794
797
|
my: {
|
|
795
798
|
package: "@mini-types/alipay",
|
|
@@ -1339,7 +1342,7 @@ function mapSaveFileArgs(args) {
|
|
|
1339
1342
|
const lastArg = nextArgs[lastIndex];
|
|
1340
1343
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1341
1344
|
const nextOptions = { ...lastArg };
|
|
1342
|
-
if (!
|
|
1345
|
+
if (!hasOwn(nextOptions, "apFilePath") && hasOwn(nextOptions, "tempFilePath")) nextOptions.apFilePath = nextOptions.tempFilePath;
|
|
1343
1346
|
nextArgs[lastIndex] = nextOptions;
|
|
1344
1347
|
return nextArgs;
|
|
1345
1348
|
}
|
|
@@ -1349,15 +1352,15 @@ function mapCreateRewardedVideoAdArgs(args) {
|
|
|
1349
1352
|
const lastIndex = nextArgs.length - 1;
|
|
1350
1353
|
const lastArg = nextArgs[lastIndex];
|
|
1351
1354
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1352
|
-
if (
|
|
1353
|
-
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");
|
|
1354
1357
|
const adUnitId = lastArg.adUnitId;
|
|
1355
1358
|
if (typeof adUnitId === "string" && adUnitId.length > 0) nextArgs[lastIndex] = adUnitId;
|
|
1356
1359
|
return nextArgs;
|
|
1357
1360
|
}
|
|
1358
1361
|
function mapRewardedAdInstance(result, args = []) {
|
|
1359
1362
|
if (typeof result !== "object" || result === null) return result;
|
|
1360
|
-
const adUnitIdArg = args.length > 0 ? args.
|
|
1363
|
+
const adUnitIdArg = args.length > 0 ? args[args.length - 1] : void 0;
|
|
1361
1364
|
const adUnitId = typeof adUnitIdArg === "string" ? adUnitIdArg : void 0;
|
|
1362
1365
|
if (!adUnitId) return result;
|
|
1363
1366
|
const rewardedAd = result;
|
|
@@ -1389,7 +1392,7 @@ function mapCheckIsSoterEnrolledInDeviceArgs(args) {
|
|
|
1389
1392
|
}
|
|
1390
1393
|
function mapSoterCheckResult(methodName, result) {
|
|
1391
1394
|
if (!isPlainObject(result)) return result;
|
|
1392
|
-
if (
|
|
1395
|
+
if (hasOwn(result, "errMsg")) return result;
|
|
1393
1396
|
return {
|
|
1394
1397
|
...result,
|
|
1395
1398
|
errMsg: `${methodName}:ok`
|
|
@@ -1405,11 +1408,11 @@ function toNumberCode(value) {
|
|
|
1405
1408
|
function mapBleConnectionResult(methodName, codeKey, result) {
|
|
1406
1409
|
if (!isPlainObject(result)) return result;
|
|
1407
1410
|
const nextResult = { ...result };
|
|
1408
|
-
if (!
|
|
1411
|
+
if (!hasOwn(nextResult, "errCode")) {
|
|
1409
1412
|
const code = toNumberCode(nextResult[codeKey]);
|
|
1410
1413
|
if (typeof code === "number") nextResult.errCode = code;
|
|
1411
1414
|
}
|
|
1412
|
-
if (!
|
|
1415
|
+
if (!hasOwn(nextResult, "errMsg")) {
|
|
1413
1416
|
if (typeof nextResult.errorMessage === "string" && nextResult.errorMessage.length > 0) nextResult.errMsg = nextResult.errorMessage;
|
|
1414
1417
|
else if (nextResult.errCode === 0) nextResult.errMsg = `${methodName}:ok`;
|
|
1415
1418
|
}
|
|
@@ -1423,7 +1426,7 @@ function mapCloseBleConnectionResult(result) {
|
|
|
1423
1426
|
}
|
|
1424
1427
|
function mapSaveFileResult(result) {
|
|
1425
1428
|
if (!isPlainObject(result)) return result;
|
|
1426
|
-
if (!
|
|
1429
|
+
if (!hasOwn(result, "savedFilePath") && hasOwn(result, "apFilePath")) return {
|
|
1427
1430
|
...result,
|
|
1428
1431
|
savedFilePath: result.apFilePath
|
|
1429
1432
|
};
|
|
@@ -1431,7 +1434,7 @@ function mapSaveFileResult(result) {
|
|
|
1431
1434
|
}
|
|
1432
1435
|
function mapDouyinSaveFileResult(result) {
|
|
1433
1436
|
if (!isPlainObject(result)) return result;
|
|
1434
|
-
if (!
|
|
1437
|
+
if (!hasOwn(result, "savedFilePath") && hasOwn(result, "filePath")) return {
|
|
1435
1438
|
...result,
|
|
1436
1439
|
savedFilePath: result.filePath
|
|
1437
1440
|
};
|
|
@@ -1458,8 +1461,8 @@ function mapToastArgs(args) {
|
|
|
1458
1461
|
const lastArg = nextArgs[lastIndex];
|
|
1459
1462
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1460
1463
|
const nextOptions = { ...lastArg };
|
|
1461
|
-
if (!
|
|
1462
|
-
if (
|
|
1464
|
+
if (!hasOwn(nextOptions, "content") && hasOwn(nextOptions, "title")) nextOptions.content = nextOptions.title;
|
|
1465
|
+
if (hasOwn(nextOptions, "icon")) nextOptions.type = mapToastType(nextOptions.icon);
|
|
1463
1466
|
nextArgs[lastIndex] = nextOptions;
|
|
1464
1467
|
return nextArgs;
|
|
1465
1468
|
}
|
|
@@ -1481,7 +1484,7 @@ function mapLoadingArgs(args) {
|
|
|
1481
1484
|
const lastArg = nextArgs[lastIndex];
|
|
1482
1485
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1483
1486
|
const nextOptions = { ...lastArg };
|
|
1484
|
-
if (!
|
|
1487
|
+
if (!hasOwn(nextOptions, "content") && hasOwn(nextOptions, "title")) nextOptions.content = nextOptions.title;
|
|
1485
1488
|
nextArgs[lastIndex] = nextOptions;
|
|
1486
1489
|
return nextArgs;
|
|
1487
1490
|
}
|
|
@@ -1492,13 +1495,13 @@ function mapActionSheetArgs(args) {
|
|
|
1492
1495
|
const lastArg = nextArgs[lastIndex];
|
|
1493
1496
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1494
1497
|
const nextOptions = { ...lastArg };
|
|
1495
|
-
if (!
|
|
1498
|
+
if (!hasOwn(nextOptions, "items") && Array.isArray(nextOptions.itemList)) nextOptions.items = nextOptions.itemList;
|
|
1496
1499
|
nextArgs[lastIndex] = nextOptions;
|
|
1497
1500
|
return nextArgs;
|
|
1498
1501
|
}
|
|
1499
1502
|
function mapActionSheetResult(result) {
|
|
1500
1503
|
if (!isPlainObject(result)) return result;
|
|
1501
|
-
if (!
|
|
1504
|
+
if (!hasOwn(result, "tapIndex") && hasOwn(result, "index")) return {
|
|
1502
1505
|
...result,
|
|
1503
1506
|
tapIndex: result.index
|
|
1504
1507
|
};
|
|
@@ -1511,11 +1514,11 @@ function mapModalArgs(args) {
|
|
|
1511
1514
|
const lastArg = nextArgs[lastIndex];
|
|
1512
1515
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1513
1516
|
const nextOptions = { ...lastArg };
|
|
1514
|
-
if (
|
|
1515
|
-
if (
|
|
1516
|
-
if (
|
|
1517
|
-
if (!
|
|
1518
|
-
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;
|
|
1519
1522
|
nextArgs[lastIndex] = nextOptions;
|
|
1520
1523
|
return nextArgs;
|
|
1521
1524
|
}
|
|
@@ -1523,11 +1526,11 @@ function mapModalResult(result) {
|
|
|
1523
1526
|
if (!isPlainObject(result)) return result;
|
|
1524
1527
|
let changed = false;
|
|
1525
1528
|
const nextResult = { ...result };
|
|
1526
|
-
if (!
|
|
1529
|
+
if (!hasOwn(nextResult, "cancel") && hasOwn(nextResult, "confirm")) {
|
|
1527
1530
|
nextResult.cancel = !nextResult.confirm;
|
|
1528
1531
|
changed = true;
|
|
1529
1532
|
}
|
|
1530
|
-
if (!
|
|
1533
|
+
if (!hasOwn(nextResult, "content")) {
|
|
1531
1534
|
nextResult.content = "";
|
|
1532
1535
|
changed = true;
|
|
1533
1536
|
}
|
|
@@ -1535,7 +1538,7 @@ function mapModalResult(result) {
|
|
|
1535
1538
|
}
|
|
1536
1539
|
function mapChooseImageResult(result) {
|
|
1537
1540
|
if (!isPlainObject(result)) return result;
|
|
1538
|
-
if (!
|
|
1541
|
+
if (!hasOwn(result, "tempFilePaths") && Array.isArray(result.apFilePaths)) return {
|
|
1539
1542
|
...result,
|
|
1540
1543
|
tempFilePaths: result.apFilePaths
|
|
1541
1544
|
};
|
|
@@ -1571,13 +1574,13 @@ function mapSetClipboardArgs(args) {
|
|
|
1571
1574
|
const lastArg = nextArgs[lastIndex];
|
|
1572
1575
|
if (!isPlainObject(lastArg)) return nextArgs;
|
|
1573
1576
|
const nextOptions = { ...lastArg };
|
|
1574
|
-
if (!
|
|
1577
|
+
if (!hasOwn(nextOptions, "text") && hasOwn(nextOptions, "data")) nextOptions.text = nextOptions.data;
|
|
1575
1578
|
nextArgs[lastIndex] = nextOptions;
|
|
1576
1579
|
return nextArgs;
|
|
1577
1580
|
}
|
|
1578
1581
|
function mapClipboardResult(result) {
|
|
1579
1582
|
if (!isPlainObject(result)) return result;
|
|
1580
|
-
if (!
|
|
1583
|
+
if (!hasOwn(result, "data") && hasOwn(result, "text")) return {
|
|
1581
1584
|
...result,
|
|
1582
1585
|
data: result.text
|
|
1583
1586
|
};
|
|
@@ -2175,7 +2178,6 @@ const PLATFORM_METHOD_SET = {
|
|
|
2175
2178
|
my: new Set(WEAPI_ALIPAY_METHODS),
|
|
2176
2179
|
tt: new Set(WEAPI_DOUYIN_METHODS)
|
|
2177
2180
|
};
|
|
2178
|
-
function createFallbackMappingRule(platform, methodName) {}
|
|
2179
2181
|
function resolveMappingRule(platform, methodName, options = {}) {
|
|
2180
2182
|
const methodSet = PLATFORM_METHOD_SET[platform];
|
|
2181
2183
|
const explicitRule = METHOD_MAPPINGS[platform]?.[methodName];
|
|
@@ -2192,12 +2194,6 @@ function resolveMappingRule(platform, methodName, options = {}) {
|
|
|
2192
2194
|
target: methodName,
|
|
2193
2195
|
source: "identity"
|
|
2194
2196
|
};
|
|
2195
|
-
const fallbackRule = createFallbackMappingRule(platform, methodName);
|
|
2196
|
-
if (fallbackRule) return {
|
|
2197
|
-
target: fallbackRule.target,
|
|
2198
|
-
source: "fallback",
|
|
2199
|
-
rule: fallbackRule
|
|
2200
|
-
};
|
|
2201
2197
|
return {
|
|
2202
2198
|
target: methodName,
|
|
2203
2199
|
source: "identity"
|
|
@@ -2276,7 +2272,7 @@ function clearTimer(timer) {
|
|
|
2276
2272
|
}
|
|
2277
2273
|
function resolveOptionsArg(args) {
|
|
2278
2274
|
const nextArgs = args.slice();
|
|
2279
|
-
const lastArg = nextArgs.length > 0 ? nextArgs.
|
|
2275
|
+
const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
|
|
2280
2276
|
if (isPlainObject(lastArg)) {
|
|
2281
2277
|
const options = { ...lastArg };
|
|
2282
2278
|
nextArgs[nextArgs.length - 1] = options;
|
|
@@ -2578,7 +2574,7 @@ function createWeapi(options = {}) {
|
|
|
2578
2574
|
try {
|
|
2579
2575
|
runtimeArgs = mappingRule?.mapArgs ? mappingRule.mapArgs(args) : args;
|
|
2580
2576
|
} catch (error) {
|
|
2581
|
-
const lastArg = args.length > 0 ? args.
|
|
2577
|
+
const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
|
|
2582
2578
|
if (hasCallbacks(lastArg)) {
|
|
2583
2579
|
lastArg.fail?.(error);
|
|
2584
2580
|
lastArg.complete?.(error);
|
|
@@ -2591,7 +2587,7 @@ function createWeapi(options = {}) {
|
|
|
2591
2587
|
const result = runtimeMethod.apply(runtimeAdapter, runtimeArgs);
|
|
2592
2588
|
return mappingRule?.mapResult ? mappingRule.mapResult(result, runtimeArgs) : result;
|
|
2593
2589
|
}
|
|
2594
|
-
const lastArg = runtimeArgs.length > 0 ? runtimeArgs.
|
|
2590
|
+
const lastArg = runtimeArgs.length > 0 ? runtimeArgs[runtimeArgs.length - 1] : void 0;
|
|
2595
2591
|
if (hasCallbacks(lastArg)) {
|
|
2596
2592
|
if (mappingRule?.mapResult && isPlainObject(lastArg)) {
|
|
2597
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.9",
|
|
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.2.
|
|
37
|
+
"miniprogram-api-typings": "^5.2.1",
|
|
38
38
|
"@weapp-core/shared": "3.0.4"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|