@wevu/api 0.2.0 → 0.2.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 CHANGED
@@ -34,11 +34,11 @@
34
34
 
35
35
  | 平台 | 可调用 API 数 | 语义对齐 API 数 | fallback API 数 | API 总数 | 可调用覆盖率 | 语义对齐覆盖率 |
36
36
  | --- | --- | --- | --- | --- | --- | --- |
37
- | 微信小程序 (`wx`) | 479 | 479 | 0 | 479 | 100.00% | 100.00% |
38
- | 支付宝小程序 (`my`) | 201 | 201 | 0 | 479 | 41.96% | 41.96% |
39
- | 抖音小程序 (`tt`) | 133 | 133 | 0 | 479 | 27.77% | 27.77% |
40
- | 三端可调用完全对齐 (wx/my/tt) | 117 | - | - | 479 | 24.43% | - |
41
- | 三端语义完全对齐 (wx/my/tt) | - | 117 | - | 479 | - | 24.43% |
37
+ | 微信小程序 (`wx`) | 481 | 481 | 0 | 481 | 100.00% | 100.00% |
38
+ | 支付宝小程序 (`my`) | 201 | 201 | 0 | 481 | 41.79% | 41.79% |
39
+ | 抖音小程序 (`tt`) | 133 | 133 | 0 | 481 | 27.65% | 27.65% |
40
+ | 三端可调用完全对齐 (wx/my/tt) | 117 | - | - | 481 | 24.32% | - |
41
+ | 三端语义完全对齐 (wx/my/tt) | - | 117 | - | 481 | - | 24.32% |
42
42
 
43
43
  > 该报告由 `WEAPI_METHOD_SUPPORT_MATRIX` 与映射规则自动计算生成。
44
44
 
package/dist/index.cjs CHANGED
@@ -84,8 +84,10 @@ function hasCallbacks(value) {
84
84
  function isSyncMethod(name) {
85
85
  return name.endsWith("Sync");
86
86
  }
87
+ const ON_EVENT_RE = /^on[A-Z]/;
88
+ const OFF_EVENT_RE = /^off[A-Z]/;
87
89
  function isEventMethod(name) {
88
- return /^on[A-Z]/.test(name) || /^off[A-Z]/.test(name);
90
+ return ON_EVENT_RE.test(name) || OFF_EVENT_RE.test(name);
89
91
  }
90
92
  function shouldSkipPromise(name) {
91
93
  return isSyncMethod(name) || isEventMethod(name) || name === "createInterstitialAd" || name === "createRewardedVideoAd" || name === "createVKSession" || name === "createCameraContext" || name === "cancelIdleCallback" || name === "nextTick" || name === "getLogManager" || name === "reportAnalytics";
@@ -97,7 +99,7 @@ function createNotSupportedError(methodName, platform) {
97
99
  //#region src/core/callBridge.ts
98
100
  function resolveOptionsArg$1(args) {
99
101
  const nextArgs = args.slice();
100
- const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
102
+ const lastArg = nextArgs.length > 0 ? nextArgs.at(-1) : void 0;
101
103
  if (isPlainObject(lastArg)) {
102
104
  const options = { ...lastArg };
103
105
  nextArgs[nextArgs.length - 1] = options;
@@ -117,7 +119,7 @@ function resolveOptionsArg$1(args) {
117
119
  * @description 将错误按小程序回调风格分发;若无回调则返回 reject Promise。
118
120
  */
119
121
  function callWithError(error, args) {
120
- const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
122
+ const lastArg = args.length > 0 ? args.at(-1) : void 0;
121
123
  if (hasCallbacks(lastArg)) {
122
124
  lastArg.fail?.(error);
123
125
  lastArg.complete?.(error);
@@ -875,12 +877,12 @@ const WEAPI_WX_METHODS_ADD_CARD_TO_JOIN_VO_IPCHAT = [
875
877
  "joinVoIPChat"
876
878
  ];
877
879
  //#endregion
878
- //#region src/core/apiCatalog/wxMethodsLoadBuiltInFontFaceToPreloadAssets.ts
880
+ //#region src/core/apiCatalog/wxMethodsLoadBuiltInFontFaceToPostMessageToReferrerPage.ts
879
881
  /**
880
882
  * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
881
883
  * @generated by scripts/sync-api-catalog.mjs
882
884
  */
883
- const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
885
+ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_POST_MESSAGE_TO_REFERRER_PAGE = [
884
886
  "loadBuiltInFontFace",
885
887
  "loadFontFace",
886
888
  "login",
@@ -938,13 +940,14 @@ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
938
940
  "offMenuButtonBoundingClientRectWeightChange",
939
941
  "offNetworkStatusChange",
940
942
  "offNetworkWeakChange",
941
- "offOnUserTriggerTranslation",
942
943
  "offPageNotFound",
943
944
  "offParallelStateChange",
944
945
  "offScreenRecordingStateChanged",
945
946
  "offThemeChange",
946
947
  "offUnhandledRejection",
947
948
  "offUserCaptureScreen",
949
+ "offUserOffTranslation",
950
+ "offUserTriggerTranslation",
948
951
  "offVoIPChatInterrupted",
949
952
  "offVoIPChatMembersChanged",
950
953
  "offVoIPChatSpeakersChanged",
@@ -1004,7 +1007,6 @@ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
1004
1007
  "onNeedPrivacyAuthorization",
1005
1008
  "onNetworkStatusChange",
1006
1009
  "onNetworkWeakChange",
1007
- "onOnUserTriggerTranslation",
1008
1010
  "onPageNotFound",
1009
1011
  "onParallelStateChange",
1010
1012
  "onScreenRecordingStateChanged",
@@ -1015,6 +1017,8 @@ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
1015
1017
  "onThemeChange",
1016
1018
  "onUnhandledRejection",
1017
1019
  "onUserCaptureScreen",
1020
+ "onUserOffTranslation",
1021
+ "onUserTriggerTranslation",
1018
1022
  "onVoIPChatInterrupted",
1019
1023
  "onVoIPChatMembersChanged",
1020
1024
  "onVoIPChatSpeakersChanged",
@@ -1058,17 +1062,17 @@ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
1058
1062
  "playVoice",
1059
1063
  "pluginLogin",
1060
1064
  "postMessageToReferrerMiniProgram",
1061
- "postMessageToReferrerPage",
1062
- "preDownloadSubpackage",
1063
- "preloadAssets"
1065
+ "postMessageToReferrerPage"
1064
1066
  ];
1065
1067
  //#endregion
1066
- //#region src/core/apiCatalog/wxMethodsPreloadSkylineViewToWriteBLECharacteristicValue.ts
1068
+ //#region src/core/apiCatalog/wxMethodsPreDownloadSubpackageToWriteBLECharacteristicValue.ts
1067
1069
  /**
1068
1070
  * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
1069
1071
  * @generated by scripts/sync-api-catalog.mjs
1070
1072
  */
1071
- const WEAPI_WX_METHODS_PRELOAD_SKYLINE_VIEW_TO_WRITE_BLECHARACTERISTIC_VALUE = [
1073
+ const WEAPI_WX_METHODS_PRE_DOWNLOAD_SUBPACKAGE_TO_WRITE_BLECHARACTERISTIC_VALUE = [
1074
+ "preDownloadSubpackage",
1075
+ "preloadAssets",
1072
1076
  "preloadSkylineView",
1073
1077
  "preloadWebview",
1074
1078
  "previewImage",
@@ -1191,8 +1195,8 @@ const WEAPI_WX_METHODS_PRELOAD_SKYLINE_VIEW_TO_WRITE_BLECHARACTERISTIC_VALUE = [
1191
1195
  ];
1192
1196
  [
1193
1197
  ...WEAPI_WX_METHODS_ADD_CARD_TO_JOIN_VO_IPCHAT,
1194
- ...WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS,
1195
- ...WEAPI_WX_METHODS_PRELOAD_SKYLINE_VIEW_TO_WRITE_BLECHARACTERISTIC_VALUE
1198
+ ...WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_POST_MESSAGE_TO_REFERRER_PAGE,
1199
+ ...WEAPI_WX_METHODS_PRE_DOWNLOAD_SUBPACKAGE_TO_WRITE_BLECHARACTERISTIC_VALUE
1196
1200
  ];
1197
1201
  //#endregion
1198
1202
  //#region src/core/methodMapping/rules/helpersDeviceAndStorage.ts
@@ -1207,7 +1211,7 @@ function mapSaveFileArgs(args) {
1207
1211
  const lastArg = nextArgs[lastIndex];
1208
1212
  if (!isPlainObject(lastArg)) return nextArgs;
1209
1213
  const nextOptions = { ...lastArg };
1210
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "apFilePath") && Object.prototype.hasOwnProperty.call(nextOptions, "tempFilePath")) nextOptions.apFilePath = nextOptions.tempFilePath;
1214
+ if (!Object.hasOwn(nextOptions, "apFilePath") && Object.hasOwn(nextOptions, "tempFilePath")) nextOptions.apFilePath = nextOptions.tempFilePath;
1211
1215
  nextArgs[lastIndex] = nextOptions;
1212
1216
  return nextArgs;
1213
1217
  }
@@ -1217,15 +1221,15 @@ function mapCreateRewardedVideoAdArgs(args) {
1217
1221
  const lastIndex = nextArgs.length - 1;
1218
1222
  const lastArg = nextArgs[lastIndex];
1219
1223
  if (!isPlainObject(lastArg)) return nextArgs;
1220
- if (Object.prototype.hasOwnProperty.call(lastArg, "multiton") && lastArg.multiton === true) throw createNotSupportedError("createRewardedVideoAd", "my");
1221
- if (Object.prototype.hasOwnProperty.call(lastArg, "disableFallbackSharePage") && lastArg.disableFallbackSharePage === true) throw createNotSupportedError("createRewardedVideoAd", "my");
1224
+ if (Object.hasOwn(lastArg, "multiton") && lastArg.multiton === true) throw createNotSupportedError("createRewardedVideoAd", "my");
1225
+ if (Object.hasOwn(lastArg, "disableFallbackSharePage") && lastArg.disableFallbackSharePage === true) throw createNotSupportedError("createRewardedVideoAd", "my");
1222
1226
  const adUnitId = lastArg.adUnitId;
1223
1227
  if (typeof adUnitId === "string" && adUnitId.length > 0) nextArgs[lastIndex] = adUnitId;
1224
1228
  return nextArgs;
1225
1229
  }
1226
1230
  function mapRewardedAdInstance(result, args = []) {
1227
1231
  if (typeof result !== "object" || result === null) return result;
1228
- const adUnitIdArg = args.length > 0 ? args[args.length - 1] : void 0;
1232
+ const adUnitIdArg = args.length > 0 ? args.at(-1) : void 0;
1229
1233
  const adUnitId = typeof adUnitIdArg === "string" ? adUnitIdArg : void 0;
1230
1234
  if (!adUnitId) return result;
1231
1235
  const rewardedAd = result;
@@ -1257,7 +1261,7 @@ function mapCheckIsSoterEnrolledInDeviceArgs(args) {
1257
1261
  }
1258
1262
  function mapSoterCheckResult(methodName, result) {
1259
1263
  if (!isPlainObject(result)) return result;
1260
- if (Object.prototype.hasOwnProperty.call(result, "errMsg")) return result;
1264
+ if (Object.hasOwn(result, "errMsg")) return result;
1261
1265
  return {
1262
1266
  ...result,
1263
1267
  errMsg: `${methodName}:ok`
@@ -1273,11 +1277,11 @@ function toNumberCode(value) {
1273
1277
  function mapBleConnectionResult(methodName, codeKey, result) {
1274
1278
  if (!isPlainObject(result)) return result;
1275
1279
  const nextResult = { ...result };
1276
- if (!Object.prototype.hasOwnProperty.call(nextResult, "errCode")) {
1280
+ if (!Object.hasOwn(nextResult, "errCode")) {
1277
1281
  const code = toNumberCode(nextResult[codeKey]);
1278
1282
  if (typeof code === "number") nextResult.errCode = code;
1279
1283
  }
1280
- if (!Object.prototype.hasOwnProperty.call(nextResult, "errMsg")) {
1284
+ if (!Object.hasOwn(nextResult, "errMsg")) {
1281
1285
  if (typeof nextResult.errorMessage === "string" && nextResult.errorMessage.length > 0) nextResult.errMsg = nextResult.errorMessage;
1282
1286
  else if (nextResult.errCode === 0) nextResult.errMsg = `${methodName}:ok`;
1283
1287
  }
@@ -1291,7 +1295,7 @@ function mapCloseBleConnectionResult(result) {
1291
1295
  }
1292
1296
  function mapSaveFileResult(result) {
1293
1297
  if (!isPlainObject(result)) return result;
1294
- if (!Object.prototype.hasOwnProperty.call(result, "savedFilePath") && Object.prototype.hasOwnProperty.call(result, "apFilePath")) return {
1298
+ if (!Object.hasOwn(result, "savedFilePath") && Object.hasOwn(result, "apFilePath")) return {
1295
1299
  ...result,
1296
1300
  savedFilePath: result.apFilePath
1297
1301
  };
@@ -1299,7 +1303,7 @@ function mapSaveFileResult(result) {
1299
1303
  }
1300
1304
  function mapDouyinSaveFileResult(result) {
1301
1305
  if (!isPlainObject(result)) return result;
1302
- if (!Object.prototype.hasOwnProperty.call(result, "savedFilePath") && Object.prototype.hasOwnProperty.call(result, "filePath")) return {
1306
+ if (!Object.hasOwn(result, "savedFilePath") && Object.hasOwn(result, "filePath")) return {
1303
1307
  ...result,
1304
1308
  savedFilePath: result.filePath
1305
1309
  };
@@ -1325,8 +1329,8 @@ function mapToastArgs(args) {
1325
1329
  const lastArg = nextArgs[lastIndex];
1326
1330
  if (!isPlainObject(lastArg)) return nextArgs;
1327
1331
  const nextOptions = { ...lastArg };
1328
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "content") && Object.prototype.hasOwnProperty.call(nextOptions, "title")) nextOptions.content = nextOptions.title;
1329
- if (Object.prototype.hasOwnProperty.call(nextOptions, "icon")) nextOptions.type = mapToastType(nextOptions.icon);
1332
+ if (!Object.hasOwn(nextOptions, "content") && Object.hasOwn(nextOptions, "title")) nextOptions.content = nextOptions.title;
1333
+ if (Object.hasOwn(nextOptions, "icon")) nextOptions.type = mapToastType(nextOptions.icon);
1330
1334
  nextArgs[lastIndex] = nextOptions;
1331
1335
  return nextArgs;
1332
1336
  }
@@ -1348,7 +1352,7 @@ function mapLoadingArgs(args) {
1348
1352
  const lastArg = nextArgs[lastIndex];
1349
1353
  if (!isPlainObject(lastArg)) return nextArgs;
1350
1354
  const nextOptions = { ...lastArg };
1351
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "content") && Object.prototype.hasOwnProperty.call(nextOptions, "title")) nextOptions.content = nextOptions.title;
1355
+ if (!Object.hasOwn(nextOptions, "content") && Object.hasOwn(nextOptions, "title")) nextOptions.content = nextOptions.title;
1352
1356
  nextArgs[lastIndex] = nextOptions;
1353
1357
  return nextArgs;
1354
1358
  }
@@ -1359,13 +1363,13 @@ function mapActionSheetArgs(args) {
1359
1363
  const lastArg = nextArgs[lastIndex];
1360
1364
  if (!isPlainObject(lastArg)) return nextArgs;
1361
1365
  const nextOptions = { ...lastArg };
1362
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "items") && Array.isArray(nextOptions.itemList)) nextOptions.items = nextOptions.itemList;
1366
+ if (!Object.hasOwn(nextOptions, "items") && Array.isArray(nextOptions.itemList)) nextOptions.items = nextOptions.itemList;
1363
1367
  nextArgs[lastIndex] = nextOptions;
1364
1368
  return nextArgs;
1365
1369
  }
1366
1370
  function mapActionSheetResult(result) {
1367
1371
  if (!isPlainObject(result)) return result;
1368
- if (!Object.prototype.hasOwnProperty.call(result, "tapIndex") && Object.prototype.hasOwnProperty.call(result, "index")) return {
1372
+ if (!Object.hasOwn(result, "tapIndex") && Object.hasOwn(result, "index")) return {
1369
1373
  ...result,
1370
1374
  tapIndex: result.index
1371
1375
  };
@@ -1378,11 +1382,11 @@ function mapModalArgs(args) {
1378
1382
  const lastArg = nextArgs[lastIndex];
1379
1383
  if (!isPlainObject(lastArg)) return nextArgs;
1380
1384
  const nextOptions = { ...lastArg };
1381
- if (Object.prototype.hasOwnProperty.call(nextOptions, "showCancel") && nextOptions.showCancel === false) throw createNotSupportedError("showModal", "my");
1382
- if (Object.prototype.hasOwnProperty.call(nextOptions, "editable") && nextOptions.editable === true) throw createNotSupportedError("showModal", "my");
1383
- if (Object.prototype.hasOwnProperty.call(nextOptions, "placeholderText")) throw createNotSupportedError("showModal", "my");
1384
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "confirmButtonText") && Object.prototype.hasOwnProperty.call(nextOptions, "confirmText")) nextOptions.confirmButtonText = nextOptions.confirmText;
1385
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "cancelButtonText") && Object.prototype.hasOwnProperty.call(nextOptions, "cancelText")) nextOptions.cancelButtonText = nextOptions.cancelText;
1385
+ if (Object.hasOwn(nextOptions, "showCancel") && nextOptions.showCancel === false) throw createNotSupportedError("showModal", "my");
1386
+ if (Object.hasOwn(nextOptions, "editable") && nextOptions.editable === true) throw createNotSupportedError("showModal", "my");
1387
+ if (Object.hasOwn(nextOptions, "placeholderText")) throw createNotSupportedError("showModal", "my");
1388
+ if (!Object.hasOwn(nextOptions, "confirmButtonText") && Object.hasOwn(nextOptions, "confirmText")) nextOptions.confirmButtonText = nextOptions.confirmText;
1389
+ if (!Object.hasOwn(nextOptions, "cancelButtonText") && Object.hasOwn(nextOptions, "cancelText")) nextOptions.cancelButtonText = nextOptions.cancelText;
1386
1390
  nextArgs[lastIndex] = nextOptions;
1387
1391
  return nextArgs;
1388
1392
  }
@@ -1390,11 +1394,11 @@ function mapModalResult(result) {
1390
1394
  if (!isPlainObject(result)) return result;
1391
1395
  let changed = false;
1392
1396
  const nextResult = { ...result };
1393
- if (!Object.prototype.hasOwnProperty.call(nextResult, "cancel") && Object.prototype.hasOwnProperty.call(nextResult, "confirm")) {
1397
+ if (!Object.hasOwn(nextResult, "cancel") && Object.hasOwn(nextResult, "confirm")) {
1394
1398
  nextResult.cancel = !nextResult.confirm;
1395
1399
  changed = true;
1396
1400
  }
1397
- if (!Object.prototype.hasOwnProperty.call(nextResult, "content")) {
1401
+ if (!Object.hasOwn(nextResult, "content")) {
1398
1402
  nextResult.content = "";
1399
1403
  changed = true;
1400
1404
  }
@@ -1402,7 +1406,7 @@ function mapModalResult(result) {
1402
1406
  }
1403
1407
  function mapChooseImageResult(result) {
1404
1408
  if (!isPlainObject(result)) return result;
1405
- if (!Object.prototype.hasOwnProperty.call(result, "tempFilePaths") && Array.isArray(result.apFilePaths)) return {
1409
+ if (!Object.hasOwn(result, "tempFilePaths") && Array.isArray(result.apFilePaths)) return {
1406
1410
  ...result,
1407
1411
  tempFilePaths: result.apFilePaths
1408
1412
  };
@@ -1438,13 +1442,13 @@ function mapSetClipboardArgs(args) {
1438
1442
  const lastArg = nextArgs[lastIndex];
1439
1443
  if (!isPlainObject(lastArg)) return nextArgs;
1440
1444
  const nextOptions = { ...lastArg };
1441
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "text") && Object.prototype.hasOwnProperty.call(nextOptions, "data")) nextOptions.text = nextOptions.data;
1445
+ if (!Object.hasOwn(nextOptions, "text") && Object.hasOwn(nextOptions, "data")) nextOptions.text = nextOptions.data;
1442
1446
  nextArgs[lastIndex] = nextOptions;
1443
1447
  return nextArgs;
1444
1448
  }
1445
1449
  function mapClipboardResult(result) {
1446
1450
  if (!isPlainObject(result)) return result;
1447
- if (!Object.prototype.hasOwnProperty.call(result, "data") && Object.prototype.hasOwnProperty.call(result, "text")) return {
1451
+ if (!Object.hasOwn(result, "data") && Object.hasOwn(result, "text")) return {
1448
1452
  ...result,
1449
1453
  data: result.text
1450
1454
  };
@@ -2132,7 +2136,7 @@ function clearTimer(timer) {
2132
2136
  }
2133
2137
  function resolveOptionsArg(args) {
2134
2138
  const nextArgs = args.slice();
2135
- const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
2139
+ const lastArg = nextArgs.length > 0 ? nextArgs.at(-1) : void 0;
2136
2140
  if (isPlainObject(lastArg)) {
2137
2141
  const options = { ...lastArg };
2138
2142
  nextArgs[nextArgs.length - 1] = options;
@@ -2436,7 +2440,7 @@ function createWeapi(options = {}) {
2436
2440
  try {
2437
2441
  runtimeArgs = mappingRule?.mapArgs ? mappingRule.mapArgs(args) : args;
2438
2442
  } catch (error) {
2439
- const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
2443
+ const lastArg = args.length > 0 ? args.at(-1) : void 0;
2440
2444
  if (hasCallbacks(lastArg)) {
2441
2445
  lastArg.fail?.(error);
2442
2446
  lastArg.complete?.(error);
@@ -2449,7 +2453,7 @@ function createWeapi(options = {}) {
2449
2453
  const result = runtimeMethod.apply(runtimeAdapter, runtimeArgs);
2450
2454
  return mappingRule?.mapResult ? mappingRule.mapResult(result, runtimeArgs) : result;
2451
2455
  }
2452
- const lastArg = runtimeArgs.length > 0 ? runtimeArgs[runtimeArgs.length - 1] : void 0;
2456
+ const lastArg = runtimeArgs.length > 0 ? runtimeArgs.at(-1) : void 0;
2453
2457
  if (hasCallbacks(lastArg)) {
2454
2458
  if (mappingRule?.mapResult && isPlainObject(lastArg)) {
2455
2459
  const options = lastArg;
package/dist/index.mjs CHANGED
@@ -83,8 +83,10 @@ function hasCallbacks(value) {
83
83
  function isSyncMethod(name) {
84
84
  return name.endsWith("Sync");
85
85
  }
86
+ const ON_EVENT_RE = /^on[A-Z]/;
87
+ const OFF_EVENT_RE = /^off[A-Z]/;
86
88
  function isEventMethod(name) {
87
- return /^on[A-Z]/.test(name) || /^off[A-Z]/.test(name);
89
+ return ON_EVENT_RE.test(name) || OFF_EVENT_RE.test(name);
88
90
  }
89
91
  function shouldSkipPromise(name) {
90
92
  return isSyncMethod(name) || isEventMethod(name) || name === "createInterstitialAd" || name === "createRewardedVideoAd" || name === "createVKSession" || name === "createCameraContext" || name === "cancelIdleCallback" || name === "nextTick" || name === "getLogManager" || name === "reportAnalytics";
@@ -96,7 +98,7 @@ function createNotSupportedError(methodName, platform) {
96
98
  //#region src/core/callBridge.ts
97
99
  function resolveOptionsArg$1(args) {
98
100
  const nextArgs = args.slice();
99
- const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
101
+ const lastArg = nextArgs.length > 0 ? nextArgs.at(-1) : void 0;
100
102
  if (isPlainObject(lastArg)) {
101
103
  const options = { ...lastArg };
102
104
  nextArgs[nextArgs.length - 1] = options;
@@ -116,7 +118,7 @@ function resolveOptionsArg$1(args) {
116
118
  * @description 将错误按小程序回调风格分发;若无回调则返回 reject Promise。
117
119
  */
118
120
  function callWithError(error, args) {
119
- const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
121
+ const lastArg = args.length > 0 ? args.at(-1) : void 0;
120
122
  if (hasCallbacks(lastArg)) {
121
123
  lastArg.fail?.(error);
122
124
  lastArg.complete?.(error);
@@ -874,12 +876,12 @@ const WEAPI_WX_METHODS_ADD_CARD_TO_JOIN_VO_IPCHAT = [
874
876
  "joinVoIPChat"
875
877
  ];
876
878
  //#endregion
877
- //#region src/core/apiCatalog/wxMethodsLoadBuiltInFontFaceToPreloadAssets.ts
879
+ //#region src/core/apiCatalog/wxMethodsLoadBuiltInFontFaceToPostMessageToReferrerPage.ts
878
880
  /**
879
881
  * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
880
882
  * @generated by scripts/sync-api-catalog.mjs
881
883
  */
882
- const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
884
+ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_POST_MESSAGE_TO_REFERRER_PAGE = [
883
885
  "loadBuiltInFontFace",
884
886
  "loadFontFace",
885
887
  "login",
@@ -937,13 +939,14 @@ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
937
939
  "offMenuButtonBoundingClientRectWeightChange",
938
940
  "offNetworkStatusChange",
939
941
  "offNetworkWeakChange",
940
- "offOnUserTriggerTranslation",
941
942
  "offPageNotFound",
942
943
  "offParallelStateChange",
943
944
  "offScreenRecordingStateChanged",
944
945
  "offThemeChange",
945
946
  "offUnhandledRejection",
946
947
  "offUserCaptureScreen",
948
+ "offUserOffTranslation",
949
+ "offUserTriggerTranslation",
947
950
  "offVoIPChatInterrupted",
948
951
  "offVoIPChatMembersChanged",
949
952
  "offVoIPChatSpeakersChanged",
@@ -1003,7 +1006,6 @@ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
1003
1006
  "onNeedPrivacyAuthorization",
1004
1007
  "onNetworkStatusChange",
1005
1008
  "onNetworkWeakChange",
1006
- "onOnUserTriggerTranslation",
1007
1009
  "onPageNotFound",
1008
1010
  "onParallelStateChange",
1009
1011
  "onScreenRecordingStateChanged",
@@ -1014,6 +1016,8 @@ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
1014
1016
  "onThemeChange",
1015
1017
  "onUnhandledRejection",
1016
1018
  "onUserCaptureScreen",
1019
+ "onUserOffTranslation",
1020
+ "onUserTriggerTranslation",
1017
1021
  "onVoIPChatInterrupted",
1018
1022
  "onVoIPChatMembersChanged",
1019
1023
  "onVoIPChatSpeakersChanged",
@@ -1057,17 +1061,17 @@ const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
1057
1061
  "playVoice",
1058
1062
  "pluginLogin",
1059
1063
  "postMessageToReferrerMiniProgram",
1060
- "postMessageToReferrerPage",
1061
- "preDownloadSubpackage",
1062
- "preloadAssets"
1064
+ "postMessageToReferrerPage"
1063
1065
  ];
1064
1066
  //#endregion
1065
- //#region src/core/apiCatalog/wxMethodsPreloadSkylineViewToWriteBLECharacteristicValue.ts
1067
+ //#region src/core/apiCatalog/wxMethodsPreDownloadSubpackageToWriteBLECharacteristicValue.ts
1066
1068
  /**
1067
1069
  * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
1068
1070
  * @generated by scripts/sync-api-catalog.mjs
1069
1071
  */
1070
- const WEAPI_WX_METHODS_PRELOAD_SKYLINE_VIEW_TO_WRITE_BLECHARACTERISTIC_VALUE = [
1072
+ const WEAPI_WX_METHODS_PRE_DOWNLOAD_SUBPACKAGE_TO_WRITE_BLECHARACTERISTIC_VALUE = [
1073
+ "preDownloadSubpackage",
1074
+ "preloadAssets",
1071
1075
  "preloadSkylineView",
1072
1076
  "preloadWebview",
1073
1077
  "previewImage",
@@ -1190,8 +1194,8 @@ const WEAPI_WX_METHODS_PRELOAD_SKYLINE_VIEW_TO_WRITE_BLECHARACTERISTIC_VALUE = [
1190
1194
  ];
1191
1195
  [
1192
1196
  ...WEAPI_WX_METHODS_ADD_CARD_TO_JOIN_VO_IPCHAT,
1193
- ...WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS,
1194
- ...WEAPI_WX_METHODS_PRELOAD_SKYLINE_VIEW_TO_WRITE_BLECHARACTERISTIC_VALUE
1197
+ ...WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_POST_MESSAGE_TO_REFERRER_PAGE,
1198
+ ...WEAPI_WX_METHODS_PRE_DOWNLOAD_SUBPACKAGE_TO_WRITE_BLECHARACTERISTIC_VALUE
1195
1199
  ];
1196
1200
  //#endregion
1197
1201
  //#region src/core/methodMapping/rules/helpersDeviceAndStorage.ts
@@ -1206,7 +1210,7 @@ function mapSaveFileArgs(args) {
1206
1210
  const lastArg = nextArgs[lastIndex];
1207
1211
  if (!isPlainObject(lastArg)) return nextArgs;
1208
1212
  const nextOptions = { ...lastArg };
1209
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "apFilePath") && Object.prototype.hasOwnProperty.call(nextOptions, "tempFilePath")) nextOptions.apFilePath = nextOptions.tempFilePath;
1213
+ if (!Object.hasOwn(nextOptions, "apFilePath") && Object.hasOwn(nextOptions, "tempFilePath")) nextOptions.apFilePath = nextOptions.tempFilePath;
1210
1214
  nextArgs[lastIndex] = nextOptions;
1211
1215
  return nextArgs;
1212
1216
  }
@@ -1216,15 +1220,15 @@ function mapCreateRewardedVideoAdArgs(args) {
1216
1220
  const lastIndex = nextArgs.length - 1;
1217
1221
  const lastArg = nextArgs[lastIndex];
1218
1222
  if (!isPlainObject(lastArg)) return nextArgs;
1219
- if (Object.prototype.hasOwnProperty.call(lastArg, "multiton") && lastArg.multiton === true) throw createNotSupportedError("createRewardedVideoAd", "my");
1220
- if (Object.prototype.hasOwnProperty.call(lastArg, "disableFallbackSharePage") && lastArg.disableFallbackSharePage === true) throw createNotSupportedError("createRewardedVideoAd", "my");
1223
+ if (Object.hasOwn(lastArg, "multiton") && lastArg.multiton === true) throw createNotSupportedError("createRewardedVideoAd", "my");
1224
+ if (Object.hasOwn(lastArg, "disableFallbackSharePage") && lastArg.disableFallbackSharePage === true) throw createNotSupportedError("createRewardedVideoAd", "my");
1221
1225
  const adUnitId = lastArg.adUnitId;
1222
1226
  if (typeof adUnitId === "string" && adUnitId.length > 0) nextArgs[lastIndex] = adUnitId;
1223
1227
  return nextArgs;
1224
1228
  }
1225
1229
  function mapRewardedAdInstance(result, args = []) {
1226
1230
  if (typeof result !== "object" || result === null) return result;
1227
- const adUnitIdArg = args.length > 0 ? args[args.length - 1] : void 0;
1231
+ const adUnitIdArg = args.length > 0 ? args.at(-1) : void 0;
1228
1232
  const adUnitId = typeof adUnitIdArg === "string" ? adUnitIdArg : void 0;
1229
1233
  if (!adUnitId) return result;
1230
1234
  const rewardedAd = result;
@@ -1256,7 +1260,7 @@ function mapCheckIsSoterEnrolledInDeviceArgs(args) {
1256
1260
  }
1257
1261
  function mapSoterCheckResult(methodName, result) {
1258
1262
  if (!isPlainObject(result)) return result;
1259
- if (Object.prototype.hasOwnProperty.call(result, "errMsg")) return result;
1263
+ if (Object.hasOwn(result, "errMsg")) return result;
1260
1264
  return {
1261
1265
  ...result,
1262
1266
  errMsg: `${methodName}:ok`
@@ -1272,11 +1276,11 @@ function toNumberCode(value) {
1272
1276
  function mapBleConnectionResult(methodName, codeKey, result) {
1273
1277
  if (!isPlainObject(result)) return result;
1274
1278
  const nextResult = { ...result };
1275
- if (!Object.prototype.hasOwnProperty.call(nextResult, "errCode")) {
1279
+ if (!Object.hasOwn(nextResult, "errCode")) {
1276
1280
  const code = toNumberCode(nextResult[codeKey]);
1277
1281
  if (typeof code === "number") nextResult.errCode = code;
1278
1282
  }
1279
- if (!Object.prototype.hasOwnProperty.call(nextResult, "errMsg")) {
1283
+ if (!Object.hasOwn(nextResult, "errMsg")) {
1280
1284
  if (typeof nextResult.errorMessage === "string" && nextResult.errorMessage.length > 0) nextResult.errMsg = nextResult.errorMessage;
1281
1285
  else if (nextResult.errCode === 0) nextResult.errMsg = `${methodName}:ok`;
1282
1286
  }
@@ -1290,7 +1294,7 @@ function mapCloseBleConnectionResult(result) {
1290
1294
  }
1291
1295
  function mapSaveFileResult(result) {
1292
1296
  if (!isPlainObject(result)) return result;
1293
- if (!Object.prototype.hasOwnProperty.call(result, "savedFilePath") && Object.prototype.hasOwnProperty.call(result, "apFilePath")) return {
1297
+ if (!Object.hasOwn(result, "savedFilePath") && Object.hasOwn(result, "apFilePath")) return {
1294
1298
  ...result,
1295
1299
  savedFilePath: result.apFilePath
1296
1300
  };
@@ -1298,7 +1302,7 @@ function mapSaveFileResult(result) {
1298
1302
  }
1299
1303
  function mapDouyinSaveFileResult(result) {
1300
1304
  if (!isPlainObject(result)) return result;
1301
- if (!Object.prototype.hasOwnProperty.call(result, "savedFilePath") && Object.prototype.hasOwnProperty.call(result, "filePath")) return {
1305
+ if (!Object.hasOwn(result, "savedFilePath") && Object.hasOwn(result, "filePath")) return {
1302
1306
  ...result,
1303
1307
  savedFilePath: result.filePath
1304
1308
  };
@@ -1324,8 +1328,8 @@ function mapToastArgs(args) {
1324
1328
  const lastArg = nextArgs[lastIndex];
1325
1329
  if (!isPlainObject(lastArg)) return nextArgs;
1326
1330
  const nextOptions = { ...lastArg };
1327
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "content") && Object.prototype.hasOwnProperty.call(nextOptions, "title")) nextOptions.content = nextOptions.title;
1328
- if (Object.prototype.hasOwnProperty.call(nextOptions, "icon")) nextOptions.type = mapToastType(nextOptions.icon);
1331
+ if (!Object.hasOwn(nextOptions, "content") && Object.hasOwn(nextOptions, "title")) nextOptions.content = nextOptions.title;
1332
+ if (Object.hasOwn(nextOptions, "icon")) nextOptions.type = mapToastType(nextOptions.icon);
1329
1333
  nextArgs[lastIndex] = nextOptions;
1330
1334
  return nextArgs;
1331
1335
  }
@@ -1347,7 +1351,7 @@ function mapLoadingArgs(args) {
1347
1351
  const lastArg = nextArgs[lastIndex];
1348
1352
  if (!isPlainObject(lastArg)) return nextArgs;
1349
1353
  const nextOptions = { ...lastArg };
1350
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "content") && Object.prototype.hasOwnProperty.call(nextOptions, "title")) nextOptions.content = nextOptions.title;
1354
+ if (!Object.hasOwn(nextOptions, "content") && Object.hasOwn(nextOptions, "title")) nextOptions.content = nextOptions.title;
1351
1355
  nextArgs[lastIndex] = nextOptions;
1352
1356
  return nextArgs;
1353
1357
  }
@@ -1358,13 +1362,13 @@ function mapActionSheetArgs(args) {
1358
1362
  const lastArg = nextArgs[lastIndex];
1359
1363
  if (!isPlainObject(lastArg)) return nextArgs;
1360
1364
  const nextOptions = { ...lastArg };
1361
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "items") && Array.isArray(nextOptions.itemList)) nextOptions.items = nextOptions.itemList;
1365
+ if (!Object.hasOwn(nextOptions, "items") && Array.isArray(nextOptions.itemList)) nextOptions.items = nextOptions.itemList;
1362
1366
  nextArgs[lastIndex] = nextOptions;
1363
1367
  return nextArgs;
1364
1368
  }
1365
1369
  function mapActionSheetResult(result) {
1366
1370
  if (!isPlainObject(result)) return result;
1367
- if (!Object.prototype.hasOwnProperty.call(result, "tapIndex") && Object.prototype.hasOwnProperty.call(result, "index")) return {
1371
+ if (!Object.hasOwn(result, "tapIndex") && Object.hasOwn(result, "index")) return {
1368
1372
  ...result,
1369
1373
  tapIndex: result.index
1370
1374
  };
@@ -1377,11 +1381,11 @@ function mapModalArgs(args) {
1377
1381
  const lastArg = nextArgs[lastIndex];
1378
1382
  if (!isPlainObject(lastArg)) return nextArgs;
1379
1383
  const nextOptions = { ...lastArg };
1380
- if (Object.prototype.hasOwnProperty.call(nextOptions, "showCancel") && nextOptions.showCancel === false) throw createNotSupportedError("showModal", "my");
1381
- if (Object.prototype.hasOwnProperty.call(nextOptions, "editable") && nextOptions.editable === true) throw createNotSupportedError("showModal", "my");
1382
- if (Object.prototype.hasOwnProperty.call(nextOptions, "placeholderText")) throw createNotSupportedError("showModal", "my");
1383
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "confirmButtonText") && Object.prototype.hasOwnProperty.call(nextOptions, "confirmText")) nextOptions.confirmButtonText = nextOptions.confirmText;
1384
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "cancelButtonText") && Object.prototype.hasOwnProperty.call(nextOptions, "cancelText")) nextOptions.cancelButtonText = nextOptions.cancelText;
1384
+ if (Object.hasOwn(nextOptions, "showCancel") && nextOptions.showCancel === false) throw createNotSupportedError("showModal", "my");
1385
+ if (Object.hasOwn(nextOptions, "editable") && nextOptions.editable === true) throw createNotSupportedError("showModal", "my");
1386
+ if (Object.hasOwn(nextOptions, "placeholderText")) throw createNotSupportedError("showModal", "my");
1387
+ if (!Object.hasOwn(nextOptions, "confirmButtonText") && Object.hasOwn(nextOptions, "confirmText")) nextOptions.confirmButtonText = nextOptions.confirmText;
1388
+ if (!Object.hasOwn(nextOptions, "cancelButtonText") && Object.hasOwn(nextOptions, "cancelText")) nextOptions.cancelButtonText = nextOptions.cancelText;
1385
1389
  nextArgs[lastIndex] = nextOptions;
1386
1390
  return nextArgs;
1387
1391
  }
@@ -1389,11 +1393,11 @@ function mapModalResult(result) {
1389
1393
  if (!isPlainObject(result)) return result;
1390
1394
  let changed = false;
1391
1395
  const nextResult = { ...result };
1392
- if (!Object.prototype.hasOwnProperty.call(nextResult, "cancel") && Object.prototype.hasOwnProperty.call(nextResult, "confirm")) {
1396
+ if (!Object.hasOwn(nextResult, "cancel") && Object.hasOwn(nextResult, "confirm")) {
1393
1397
  nextResult.cancel = !nextResult.confirm;
1394
1398
  changed = true;
1395
1399
  }
1396
- if (!Object.prototype.hasOwnProperty.call(nextResult, "content")) {
1400
+ if (!Object.hasOwn(nextResult, "content")) {
1397
1401
  nextResult.content = "";
1398
1402
  changed = true;
1399
1403
  }
@@ -1401,7 +1405,7 @@ function mapModalResult(result) {
1401
1405
  }
1402
1406
  function mapChooseImageResult(result) {
1403
1407
  if (!isPlainObject(result)) return result;
1404
- if (!Object.prototype.hasOwnProperty.call(result, "tempFilePaths") && Array.isArray(result.apFilePaths)) return {
1408
+ if (!Object.hasOwn(result, "tempFilePaths") && Array.isArray(result.apFilePaths)) return {
1405
1409
  ...result,
1406
1410
  tempFilePaths: result.apFilePaths
1407
1411
  };
@@ -1437,13 +1441,13 @@ function mapSetClipboardArgs(args) {
1437
1441
  const lastArg = nextArgs[lastIndex];
1438
1442
  if (!isPlainObject(lastArg)) return nextArgs;
1439
1443
  const nextOptions = { ...lastArg };
1440
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "text") && Object.prototype.hasOwnProperty.call(nextOptions, "data")) nextOptions.text = nextOptions.data;
1444
+ if (!Object.hasOwn(nextOptions, "text") && Object.hasOwn(nextOptions, "data")) nextOptions.text = nextOptions.data;
1441
1445
  nextArgs[lastIndex] = nextOptions;
1442
1446
  return nextArgs;
1443
1447
  }
1444
1448
  function mapClipboardResult(result) {
1445
1449
  if (!isPlainObject(result)) return result;
1446
- if (!Object.prototype.hasOwnProperty.call(result, "data") && Object.prototype.hasOwnProperty.call(result, "text")) return {
1450
+ if (!Object.hasOwn(result, "data") && Object.hasOwn(result, "text")) return {
1447
1451
  ...result,
1448
1452
  data: result.text
1449
1453
  };
@@ -2131,7 +2135,7 @@ function clearTimer(timer) {
2131
2135
  }
2132
2136
  function resolveOptionsArg(args) {
2133
2137
  const nextArgs = args.slice();
2134
- const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
2138
+ const lastArg = nextArgs.length > 0 ? nextArgs.at(-1) : void 0;
2135
2139
  if (isPlainObject(lastArg)) {
2136
2140
  const options = { ...lastArg };
2137
2141
  nextArgs[nextArgs.length - 1] = options;
@@ -2435,7 +2439,7 @@ function createWeapi(options = {}) {
2435
2439
  try {
2436
2440
  runtimeArgs = mappingRule?.mapArgs ? mappingRule.mapArgs(args) : args;
2437
2441
  } catch (error) {
2438
- const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
2442
+ const lastArg = args.length > 0 ? args.at(-1) : void 0;
2439
2443
  if (hasCallbacks(lastArg)) {
2440
2444
  lastArg.fail?.(error);
2441
2445
  lastArg.complete?.(error);
@@ -2448,7 +2452,7 @@ function createWeapi(options = {}) {
2448
2452
  const result = runtimeMethod.apply(runtimeAdapter, runtimeArgs);
2449
2453
  return mappingRule?.mapResult ? mappingRule.mapResult(result, runtimeArgs) : result;
2450
2454
  }
2451
- const lastArg = runtimeArgs.length > 0 ? runtimeArgs[runtimeArgs.length - 1] : void 0;
2455
+ const lastArg = runtimeArgs.length > 0 ? runtimeArgs.at(-1) : void 0;
2452
2456
  if (hasCallbacks(lastArg)) {
2453
2457
  if (mappingRule?.mapResult && isPlainObject(lastArg)) {
2454
2458
  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.0",
4
+ "version": "0.2.1",
5
5
  "description": "tsdown bundler template",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@douyin-microapp/typings": "^1.3.1",
40
40
  "@mini-types/alipay": "^3.0.14",
41
- "miniprogram-api-typings": "^5.1.1"
41
+ "miniprogram-api-typings": "^5.1.2"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"