@wevu/api 0.2.0 → 0.2.2

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.cjs DELETED
@@ -1,2512 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/core/adapter.ts
3
- const GLOBAL_ADAPTER_KEYS = [
4
- {
5
- platform: "wx",
6
- key: "wx"
7
- },
8
- {
9
- platform: "my",
10
- key: "my"
11
- },
12
- {
13
- platform: "tt",
14
- key: "tt"
15
- },
16
- {
17
- platform: "qq",
18
- key: "qq"
19
- },
20
- {
21
- platform: "swan",
22
- key: "swan"
23
- },
24
- {
25
- platform: "ks",
26
- key: "ks"
27
- },
28
- {
29
- platform: "jd",
30
- key: "jd"
31
- },
32
- {
33
- platform: "xhs",
34
- key: "xhs"
35
- },
36
- {
37
- platform: "dd",
38
- key: "dd"
39
- },
40
- {
41
- platform: "qa",
42
- key: "qa"
43
- },
44
- {
45
- platform: "qapp",
46
- key: "qapp"
47
- },
48
- {
49
- platform: "uni",
50
- key: "uni"
51
- }
52
- ];
53
- function resolveGlobalThis() {
54
- if (typeof globalThis !== "undefined") return globalThis;
55
- if (typeof window !== "undefined") return window;
56
- }
57
- function isAdapterCandidate(value) {
58
- return typeof value === "object" || typeof value === "function";
59
- }
60
- /**
61
- * @description 侦测当前运行环境的全局 API 对象
62
- */
63
- function detectGlobalAdapter() {
64
- const root = resolveGlobalThis();
65
- if (!root) return {};
66
- for (const item of GLOBAL_ADAPTER_KEYS) {
67
- const candidate = root[item.key];
68
- if (isAdapterCandidate(candidate)) return {
69
- adapter: candidate,
70
- platform: item.platform
71
- };
72
- }
73
- return {};
74
- }
75
- //#endregion
76
- //#region src/core/utils.ts
77
- function isPlainObject(value) {
78
- return Object.prototype.toString.call(value) === "[object Object]";
79
- }
80
- function hasCallbacks(value) {
81
- if (!isPlainObject(value)) return false;
82
- return typeof value.success === "function" || typeof value.fail === "function" || typeof value.complete === "function";
83
- }
84
- function isSyncMethod(name) {
85
- return name.endsWith("Sync");
86
- }
87
- function isEventMethod(name) {
88
- return /^on[A-Z]/.test(name) || /^off[A-Z]/.test(name);
89
- }
90
- function shouldSkipPromise(name) {
91
- return isSyncMethod(name) || isEventMethod(name) || name === "createInterstitialAd" || name === "createRewardedVideoAd" || name === "createVKSession" || name === "createCameraContext" || name === "cancelIdleCallback" || name === "nextTick" || name === "getLogManager" || name === "reportAnalytics";
92
- }
93
- function createNotSupportedError(methodName, platform) {
94
- return { errMsg: `${platform ? `${platform}.${methodName}` : methodName}:fail method not supported` };
95
- }
96
- //#endregion
97
- //#region src/core/callBridge.ts
98
- function resolveOptionsArg$1(args) {
99
- const nextArgs = args.slice();
100
- const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
101
- if (isPlainObject(lastArg)) {
102
- const options = { ...lastArg };
103
- nextArgs[nextArgs.length - 1] = options;
104
- return {
105
- args: nextArgs,
106
- options
107
- };
108
- }
109
- const options = {};
110
- nextArgs.push(options);
111
- return {
112
- args: nextArgs,
113
- options
114
- };
115
- }
116
- /**
117
- * @description 将错误按小程序回调风格分发;若无回调则返回 reject Promise。
118
- */
119
- function callWithError(error, args) {
120
- const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
121
- if (hasCallbacks(lastArg)) {
122
- lastArg.fail?.(error);
123
- lastArg.complete?.(error);
124
- return;
125
- }
126
- return Promise.reject(error);
127
- }
128
- /**
129
- * @description 统一 Promise 调用桥接,支持在 options/runtime result 阶段注入 hook。
130
- */
131
- function callWithPromise(context, method, args, mapResult, hooks) {
132
- return new Promise((resolve, reject) => {
133
- const { args: nextArgs, options } = resolveOptionsArg$1(args);
134
- let settled = false;
135
- options.success = (res) => {
136
- settled = true;
137
- resolve(mapResult ? mapResult(res, args) : res);
138
- };
139
- options.fail = (err) => {
140
- settled = true;
141
- reject(err);
142
- };
143
- options.complete = (res) => {
144
- if (!settled) resolve(mapResult ? mapResult(res, args) : res);
145
- };
146
- try {
147
- hooks?.onOptions?.(options, nextArgs);
148
- const invoke = () => {
149
- try {
150
- const invokeResult = method.apply(context, nextArgs);
151
- hooks?.onInvokeResult?.(invokeResult);
152
- return invokeResult;
153
- } catch (err) {
154
- hooks?.onInvokeError?.(err);
155
- reject(err);
156
- return;
157
- }
158
- };
159
- if (hooks?.invoke) hooks.invoke(invoke);
160
- else invoke();
161
- } catch (err) {
162
- hooks?.onInvokeError?.(err);
163
- reject(err);
164
- }
165
- });
166
- }
167
- /**
168
- * @description 处理方法缺失时的回调/Promise 行为。
169
- */
170
- function callMissingApi(methodName, platform, args) {
171
- return callWithError(createNotSupportedError(methodName, platform), args);
172
- }
173
- //#endregion
174
- //#region src/core/apiCatalog/myMethodsAddPhoneContactToOnGyroscopeChange.ts
175
- /**
176
- * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
177
- * @generated by scripts/sync-api-catalog.mjs
178
- */
179
- const WEAPI_MY_METHODS_ADD_PHONE_CONTACT_TO_ON_GYROSCOPE_CHANGE = [
180
- "addPhoneContact",
181
- "alert",
182
- "arrayBufferToBase64",
183
- "base64ToArrayBuffer",
184
- "calculateRoute",
185
- "call",
186
- "cancelBluetoothPair",
187
- "canIUse",
188
- "canvasToTempFilePath",
189
- "checkBeforeAddOrder",
190
- "checkIsIfaaEnrolledInDevice",
191
- "checkIsSupportIfaaAuthentication",
192
- "chooseAlipayContact",
193
- "chooseCity",
194
- "chooseContact",
195
- "chooseDistrict",
196
- "chooseImage",
197
- "chooseLocation",
198
- "choosePhoneContact",
199
- "chooseVideo",
200
- "clearStorage",
201
- "clearStorageSync",
202
- "closeBluetoothAdapter",
203
- "closeSocket",
204
- "compressImage",
205
- "confirm",
206
- "connectBLEDevice",
207
- "connectSocket",
208
- "connectWifi",
209
- "createAnimation",
210
- "createCanvasContext",
211
- "createInnerAudioContext",
212
- "createIntersectionObserver",
213
- "createLottieContext",
214
- "createMapContext",
215
- "createOffscreenCanvas",
216
- "createRewardedAd",
217
- "createSelectorQuery",
218
- "createVideoContext",
219
- "createWebViewContext",
220
- "createWorker",
221
- "datePicker",
222
- "detectFileType",
223
- "disableAlertBeforeUnload",
224
- "disconnectBLEDevice",
225
- "downloadFile",
226
- "enableAlertBeforeUnload",
227
- "exitMiniProgram",
228
- "generateImageFromCode",
229
- "getAccessibilityManager",
230
- "getAccountInfoSync",
231
- "getAddress",
232
- "getAppAuthorizeSetting",
233
- "getAppBaseInfo",
234
- "getAppIdSync",
235
- "getAuthCode",
236
- "getAvailableAudioSources",
237
- "getBackgroundAudioManager",
238
- "getBackgroundFetchData",
239
- "getBatteryInfo",
240
- "getBatteryInfoSync",
241
- "getBeacons",
242
- "getBLEDeviceCharacteristics",
243
- "getBLEDeviceRSSI",
244
- "getBLEDeviceServices",
245
- "getBLEDeviceStatus",
246
- "getBLEMTU",
247
- "getBluetoothAdapterState",
248
- "getBluetoothDevices",
249
- "getBluetoothPairs",
250
- "getClipboard",
251
- "getConnectedBluetoothDevices",
252
- "getConnectedWifi",
253
- "getEnterOptionsSync",
254
- "getExtConfig",
255
- "getExtConfigSync",
256
- "getFileInfo",
257
- "getFileSystemManager",
258
- "getGeocoder",
259
- "getImageInfo",
260
- "getLaunchOptionsSync",
261
- "getLeftButtonsBoundingClientRect",
262
- "getLocalIPAddress",
263
- "getLocation",
264
- "getMapInfo",
265
- "getMenuButtonBoundingClientRect",
266
- "getNetworkType",
267
- "getOpenUserInfo",
268
- "getParentAppId",
269
- "getParentAppIdSync",
270
- "getPhoneNumber",
271
- "getPluginIdSync",
272
- "getRecorderManager",
273
- "getRunData",
274
- "getRunScene",
275
- "getSavedFileInfo",
276
- "getSavedFileList",
277
- "getScreenBrightness",
278
- "getServerTime",
279
- "getSetting",
280
- "getStorage",
281
- "getStorageInfo",
282
- "getStorageInfoSync",
283
- "getStorageSync",
284
- "getSystemInfo",
285
- "getSystemInfoSync",
286
- "getSystemSetting",
287
- "getTitleColor",
288
- "getUpdateManager",
289
- "getVideoInfo",
290
- "getWifiList",
291
- "getWindowInfo",
292
- "hideAddToDesktopMenu",
293
- "hideAllAddToDesktopMenu",
294
- "hideBackHome",
295
- "hideKeyboard",
296
- "hideLoading",
297
- "hideNavigationBarLoading",
298
- "hideShareMenu",
299
- "hideTabBar",
300
- "hideTabBarRedDot",
301
- "hideToast",
302
- "isScreenReaderEnabled",
303
- "loadFontFace",
304
- "loadPlugin",
305
- "makeBluetoothPair",
306
- "makePhoneCall",
307
- "multiLevelSelect",
308
- "navigateBack",
309
- "navigateBackMiniProgram",
310
- "navigateTo",
311
- "navigateToMiniProgram",
312
- "notifyBLECharacteristicValueChange",
313
- "off",
314
- "offAccelerometerChange",
315
- "offAppHide",
316
- "offAppShow",
317
- "offAudioInterruptionBegin",
318
- "offAudioInterruptionEnd",
319
- "offBeaconServiceChange",
320
- "offBeaconUpdate",
321
- "offBLECharacteristicValueChange",
322
- "offBLEConnectionStateChanged",
323
- "offBluetoothAdapterStateChange",
324
- "offBluetoothDeviceFound",
325
- "offCompassChange",
326
- "offComponentError",
327
- "offDeviceMotionChange",
328
- "offError",
329
- "offGetWifiList",
330
- "offGyroscopeChange",
331
- "offLocatedComplete",
332
- "offMemoryWarning",
333
- "offNetworkStatusChange",
334
- "offPageNotFound",
335
- "offSocketClose",
336
- "offSocketError",
337
- "offSocketMessage",
338
- "offSocketOpen",
339
- "offUnhandledRejection",
340
- "offUserCaptureScreen",
341
- "offWifiConnected",
342
- "on",
343
- "onAccelerometerChange",
344
- "onAppHide",
345
- "onAppShow",
346
- "onAudioInterruptionBegin",
347
- "onAudioInterruptionEnd",
348
- "onBeaconServiceChange",
349
- "onBeaconUpdate",
350
- "onBLECharacteristicValueChange",
351
- "onBLEConnectionStateChanged",
352
- "onBluetoothAdapterStateChange",
353
- "onBluetoothDeviceFound",
354
- "onCompassChange",
355
- "onComponentError",
356
- "onDeviceMotionChange",
357
- "onError",
358
- "onGetWifiList",
359
- "onGyroscopeChange"
360
- ];
361
- //#endregion
362
- //#region src/core/apiCatalog/myMethodsOnLocatedCompleteToWriteBLECharacteristicValue.ts
363
- /**
364
- * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
365
- * @generated by scripts/sync-api-catalog.mjs
366
- */
367
- const WEAPI_MY_METHODS_ON_LOCATED_COMPLETE_TO_WRITE_BLECHARACTERISTIC_VALUE = [
368
- "onLocatedComplete",
369
- "onMemoryWarning",
370
- "onNetworkStatusChange",
371
- "onPageNotFound",
372
- "onSocketClose",
373
- "onSocketError",
374
- "onSocketMessage",
375
- "onSocketOpen",
376
- "onUnhandledRejection",
377
- "onUserCaptureScreen",
378
- "onWifiConnected",
379
- "openBluetoothAdapter",
380
- "openDocument",
381
- "openKBVoucherDetail",
382
- "openLocation",
383
- "openMerchantTicketList",
384
- "openMerchantVoucherList",
385
- "openOtherApp",
386
- "openSetting",
387
- "openTicketDetail",
388
- "openTicketList",
389
- "openVoucherDetail",
390
- "openVoucherList",
391
- "optionsSelect",
392
- "pageScrollTo",
393
- "paySignCenter",
394
- "previewImage",
395
- "prompt",
396
- "readBLECharacteristicValue",
397
- "redirectTo",
398
- "regionPicker",
399
- "registerSSID",
400
- "reLaunch",
401
- "removeSavedFile",
402
- "removeStorage",
403
- "removeStorageSync",
404
- "removeTabBarBadge",
405
- "request",
406
- "requestSubscribeMessage",
407
- "rsa",
408
- "saveFile",
409
- "saveFileToDisk",
410
- "saveImage",
411
- "saveImageToPhotosAlbum",
412
- "saveVideoToPhotosAlbum",
413
- "scan",
414
- "sendSocketMessage",
415
- "setBackgroundColor",
416
- "setBackgroundTextStyle",
417
- "setBLEMTU",
418
- "setCanPullDown",
419
- "setClipboard",
420
- "setKeepScreenOn",
421
- "setLocatedCity",
422
- "setNavigationBar",
423
- "setNavigationBarBottomLineColor",
424
- "setNavigationBarColor",
425
- "setNavigationBarTitle",
426
- "setScreenBrightness",
427
- "setStorage",
428
- "setStorageSync",
429
- "setTabBarBadge",
430
- "setTabBarItem",
431
- "setTabBarStyle",
432
- "setVisualEffectOnCapture",
433
- "setWifiList",
434
- "showActionSheet",
435
- "showAuthGuide",
436
- "showBLEPermissionGuide",
437
- "showLoading",
438
- "showModal",
439
- "showNavigationBarLoading",
440
- "showShareMenu",
441
- "showSharePanel",
442
- "showTabBar",
443
- "showTabBarRedDot",
444
- "showToast",
445
- "startAccelerometer",
446
- "startAPVerify",
447
- "startBeaconDiscovery",
448
- "startBluetoothDevicesDiscovery",
449
- "startCompass",
450
- "startGyroscope",
451
- "startIfaaAuthentication",
452
- "startPullDownRefresh",
453
- "startWifi",
454
- "stopAccelerometer",
455
- "stopBeaconDiscovery",
456
- "stopBluetoothDevicesDiscovery",
457
- "stopCompass",
458
- "stopGyroscope",
459
- "stopPullDownRefresh",
460
- "stopWifi",
461
- "switchTab",
462
- "tradePay",
463
- "unregisterSSID",
464
- "unsubscribeMessage",
465
- "uploadFile",
466
- "vibrate",
467
- "vibrateLong",
468
- "vibrateShort",
469
- "watchShake",
470
- "writeBLECharacteristicValue"
471
- ];
472
- //#endregion
473
- //#region src/core/apiCatalog/myMethods.ts
474
- /**
475
- * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
476
- * @generated by scripts/sync-api-catalog.mjs
477
- */
478
- const WEAPI_MY_METHODS = [...WEAPI_MY_METHODS_ADD_PHONE_CONTACT_TO_ON_GYROSCOPE_CHANGE, ...WEAPI_MY_METHODS_ON_LOCATED_COMPLETE_TO_WRITE_BLECHARACTERISTIC_VALUE];
479
- //#endregion
480
- //#region src/core/apiCatalog/ttMethodsApplyEcCouponToUnsubscribeAllSpecifiedUserComment.ts
481
- /**
482
- * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
483
- * @generated by scripts/sync-api-catalog.mjs
484
- */
485
- const WEAPI_TT_METHODS_APPLY_EC_COUPON_TO_UNSUBSCRIBE_ALL_SPECIFIED_USER_COMMENT = [
486
- "applyEcCoupon",
487
- "applyRefund",
488
- "arrayBufferToBase64",
489
- "authorize",
490
- "base64ToArrayBuffer",
491
- "canIPutStuffOverComponent",
492
- "canIUse",
493
- "canvasToTempFilePath",
494
- "checkFollowAwemeState",
495
- "checkFollowState",
496
- "checkSession",
497
- "chooseAddress",
498
- "chooseImage",
499
- "chooseLocation",
500
- "chooseMedia",
501
- "clearStorage",
502
- "clearStorageSync",
503
- "completePaySync",
504
- "completeRefundSync",
505
- "compressImage",
506
- "connectSocket",
507
- "continueToPay",
508
- "createAnimation",
509
- "createBytennEngineContext",
510
- "createCanvasContext",
511
- "createCloud",
512
- "createInnerAudioContext",
513
- "createIntersectionObserver",
514
- "createInterstitialAd",
515
- "createLivePlayerContext",
516
- "createMapContext",
517
- "createMediaRecorder",
518
- "createMerchantOrder",
519
- "createOffscreenCanvas",
520
- "createOrder",
521
- "createRefundOrder",
522
- "createRewardedVideoAd",
523
- "createRtcRoomContext",
524
- "createSelectorQuery",
525
- "createStickerManager",
526
- "createVideoContext",
527
- "createWorker",
528
- "downloadFile",
529
- "exitMiniProgram",
530
- "followAwemeUser",
531
- "followOfficialAccount",
532
- "getAnalysisInfo",
533
- "getBackgroundAudioManager",
534
- "getClipboardData",
535
- "getConnectedWifi",
536
- "getCustomButtonBoundingClientRect",
537
- "getEnvInfoSync",
538
- "getExtConfig",
539
- "getExtConfigSync",
540
- "getFileInfo",
541
- "getFileSystemManager",
542
- "getImageInfo",
543
- "getLaunchOptionsSync",
544
- "getLiveUserInfo",
545
- "getLocation",
546
- "getMenuButtonBoundingClientRect",
547
- "getMenuButtonLayout",
548
- "getMicroappInfo",
549
- "getRecorderManager",
550
- "getRefundOrder",
551
- "getRoomInfo",
552
- "getSavedFileList",
553
- "getScreenBrightness",
554
- "getSelfCommentCountDuringPluginRunning",
555
- "getSetting",
556
- "getShopRecordToken",
557
- "getSidebarActivity",
558
- "getStorage",
559
- "getStorageInfo",
560
- "getStorageInfoSync",
561
- "getStorageSync",
562
- "getSystemInfo",
563
- "getSystemInfoSync",
564
- "getUpdateManager",
565
- "getUserInfo",
566
- "getUserProfile",
567
- "getWifiList",
568
- "hideHomeButton",
569
- "hideInteractionBar",
570
- "hideKeyboard",
571
- "hideLoading",
572
- "hideNavigationBarLoading",
573
- "hideShareMenu",
574
- "hideTabBar",
575
- "hideTabBarRedDot",
576
- "hideToast",
577
- "isFollowingAnchor",
578
- "login",
579
- "makePhoneCall",
580
- "navigateBack",
581
- "navigateBackMiniProgram",
582
- "navigateTo",
583
- "navigateToMiniProgram",
584
- "navigateToScene",
585
- "navigateToVideoView",
586
- "offAppHide",
587
- "offAppShow",
588
- "offCompassChange",
589
- "offError",
590
- "offGetWifiList",
591
- "offLazyLoadError",
592
- "offNetworkStatusChange",
593
- "offPageNotFound",
594
- "offUnhandledRejection",
595
- "offUserCaptureScreen",
596
- "offWindowResize",
597
- "onAccelerometerChange",
598
- "onAppHide",
599
- "onAppShow",
600
- "onCompassChange",
601
- "onError",
602
- "onGetWifiList",
603
- "onLazyLoadError",
604
- "onMemoryWarning",
605
- "onNetworkStatusChange",
606
- "onPageNotFound",
607
- "onReceiveAudiencesFollowAction",
608
- "onReceiveSpecifiedComment",
609
- "onUnhandledRejection",
610
- "onUserCaptureScreen",
611
- "onWindowResize",
612
- "openAwemeUserProfile",
613
- "openLocation",
614
- "openSetting",
615
- "pageScrollTo",
616
- "pay",
617
- "preloadDrawAd",
618
- "prerenderVideo",
619
- "previewImage",
620
- "redirectTo",
621
- "reLaunch",
622
- "removeSavedFile",
623
- "removeStorage",
624
- "removeStorageSync",
625
- "removeTabBarBadge",
626
- "reportAnalytics",
627
- "request",
628
- "requestSubscribeMessage",
629
- "saveFile",
630
- "saveImageToPhotosAlbum",
631
- "scanCode",
632
- "setClipboardData",
633
- "setKeepScreenOn",
634
- "setNavigationBarColor",
635
- "setNavigationBarTitle",
636
- "setScreenBrightness",
637
- "setStorage",
638
- "setStorageSync",
639
- "setTabBarBadge",
640
- "setTabBarItem",
641
- "setTabBarStyle",
642
- "showActionSheet",
643
- "showDouyinOpenAuth",
644
- "showFavoriteGuide",
645
- "showInteractionBar",
646
- "showLoading",
647
- "showModal",
648
- "showNavigationBarLoading",
649
- "showShareMenu",
650
- "showTabBar",
651
- "showTabBarRedDot",
652
- "showToast",
653
- "startAccelerometer",
654
- "startCompass",
655
- "startPullDownRefresh",
656
- "stopAccelerometer",
657
- "stopCompass",
658
- "stopPullDownRefresh",
659
- "submitEcCustomGoods",
660
- "subscribeAudiencesFollowAction",
661
- "subscribeSpecifiedContentComment",
662
- "subscribeSpecifiedUserComment",
663
- "switchTab",
664
- "unsubscribeAllSpecifiedContentComment",
665
- "unsubscribeAllSpecifiedUserComment"
666
- ];
667
- //#endregion
668
- //#region src/core/apiCatalog/ttMethodsUnsubscribeAudiencesFollowActionToVibrateShort.ts
669
- /**
670
- * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
671
- * @generated by scripts/sync-api-catalog.mjs
672
- */
673
- const WEAPI_TT_METHODS_UNSUBSCRIBE_AUDIENCES_FOLLOW_ACTION_TO_VIBRATE_SHORT = [
674
- "unsubscribeAudiencesFollowAction",
675
- "updateExitGuideWindowInfo",
676
- "updateShopMemberPoints",
677
- "updateSidebarActivity",
678
- "uploadFile",
679
- "vibrateLong",
680
- "vibrateShort"
681
- ];
682
- //#endregion
683
- //#region src/core/apiCatalog/ttMethods.ts
684
- /**
685
- * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
686
- * @generated by scripts/sync-api-catalog.mjs
687
- */
688
- const WEAPI_TT_METHODS = [...WEAPI_TT_METHODS_APPLY_EC_COUPON_TO_UNSUBSCRIBE_ALL_SPECIFIED_USER_COMMENT, ...WEAPI_TT_METHODS_UNSUBSCRIBE_AUDIENCES_FOLLOW_ACTION_TO_VIBRATE_SHORT];
689
- //#endregion
690
- //#region src/core/apiCatalog/wxMethodsAddCardToJoinVoIPChat.ts
691
- /**
692
- * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
693
- * @generated by scripts/sync-api-catalog.mjs
694
- */
695
- const WEAPI_WX_METHODS_ADD_CARD_TO_JOIN_VO_IPCHAT = [
696
- "addCard",
697
- "addFileToFavorites",
698
- "addPaymentPassFinish",
699
- "addPaymentPassGetCertificateData",
700
- "addPhoneCalendar",
701
- "addPhoneContact",
702
- "addPhoneRepeatCalendar",
703
- "addVideoToFavorites",
704
- "arrayBufferToBase64",
705
- "authorize",
706
- "authorizeForMiniProgram",
707
- "authPrivateMessage",
708
- "base64ToArrayBuffer",
709
- "batchGetStorage",
710
- "batchGetStorageSync",
711
- "batchSetStorage",
712
- "batchSetStorageSync",
713
- "bindEmployeeRelation",
714
- "canAddSecureElementPass",
715
- "cancelIdleCallback",
716
- "canIUse",
717
- "canvasGetImageData",
718
- "canvasPutImageData",
719
- "canvasToTempFilePath",
720
- "checkDeviceSupportHevc",
721
- "checkEmployeeRelation",
722
- "checkIsAddedToMyMiniProgram",
723
- "checkIsOpenAccessibility",
724
- "checkIsPictureInPictureActive",
725
- "checkIsSoterEnrolledInDevice",
726
- "checkIsSupportSoterAuthentication",
727
- "checkSession",
728
- "chooseAddress",
729
- "chooseContact",
730
- "chooseImage",
731
- "chooseInvoice",
732
- "chooseInvoiceTitle",
733
- "chooseLicensePlate",
734
- "chooseLocation",
735
- "chooseMedia",
736
- "chooseMessageFile",
737
- "choosePoi",
738
- "chooseVideo",
739
- "clearStorage",
740
- "clearStorageSync",
741
- "closeBLEConnection",
742
- "closeBluetoothAdapter",
743
- "closeSocket",
744
- "compressImage",
745
- "compressVideo",
746
- "connectSocket",
747
- "connectWifi",
748
- "createAnimation",
749
- "createAudioContext",
750
- "createBLEConnection",
751
- "createBLEPeripheralServer",
752
- "createBufferURL",
753
- "createCacheManager",
754
- "createCameraContext",
755
- "createCanvasContext",
756
- "createGlobalPayment",
757
- "createInferenceSession",
758
- "createInnerAudioContext",
759
- "createIntersectionObserver",
760
- "createInterstitialAd",
761
- "createLivePlayerContext",
762
- "createLivePusherContext",
763
- "createMapContext",
764
- "createMediaAudioPlayer",
765
- "createMediaContainer",
766
- "createMediaRecorder",
767
- "createOffscreenCanvas",
768
- "createRewardedVideoAd",
769
- "createSelectorQuery",
770
- "createTCPSocket",
771
- "createUDPSocket",
772
- "createVideoContext",
773
- "createVideoDecoder",
774
- "createVKSession",
775
- "createWebAudioContext",
776
- "createWorker",
777
- "cropImage",
778
- "disableAlertBeforeUnload",
779
- "downloadFile",
780
- "editImage",
781
- "enableAlertBeforeUnload",
782
- "exitMiniProgram",
783
- "exitVoIPChat",
784
- "faceDetect",
785
- "getAccountInfoSync",
786
- "getApiCategory",
787
- "getAppAuthorizeSetting",
788
- "getAppBaseInfo",
789
- "getAvailableAudioSources",
790
- "getBackgroundAudioManager",
791
- "getBackgroundAudioPlayerState",
792
- "getBackgroundFetchData",
793
- "getBackgroundFetchToken",
794
- "getBatteryInfo",
795
- "getBatteryInfoSync",
796
- "getBeacons",
797
- "getBLEDeviceCharacteristics",
798
- "getBLEDeviceRSSI",
799
- "getBLEDeviceServices",
800
- "getBLEMTU",
801
- "getBluetoothAdapterState",
802
- "getBluetoothDevices",
803
- "getChannelsLiveInfo",
804
- "getChannelsLiveNoticeInfo",
805
- "getChannelsShareKey",
806
- "getChatToolInfo",
807
- "getClipboardData",
808
- "getCommonConfig",
809
- "getConnectedBluetoothDevices",
810
- "getConnectedWifi",
811
- "getDeviceBenchmarkInfo",
812
- "getDeviceInfo",
813
- "getDeviceVoIPList",
814
- "getEnterOptionsSync",
815
- "getExptInfoSync",
816
- "getExtConfig",
817
- "getExtConfigSync",
818
- "getFileSystemManager",
819
- "getFuzzyLocation",
820
- "getGroupEnterInfo",
821
- "getHCEState",
822
- "getImageInfo",
823
- "getInferenceEnvInfo",
824
- "getLaunchOptionsSync",
825
- "getLocalIPAddress",
826
- "getLocation",
827
- "getLogManager",
828
- "getMenuButtonBoundingClientRect",
829
- "getNetworkType",
830
- "getNFCAdapter",
831
- "getPerformance",
832
- "getPrivacySetting",
833
- "getRandomValues",
834
- "getRealtimeLogManager",
835
- "getRecorderManager",
836
- "getRendererUserAgent",
837
- "getScreenBrightness",
838
- "getScreenRecordingState",
839
- "getSecureElementPasses",
840
- "getSelectedTextRange",
841
- "getSetting",
842
- "getShareInfo",
843
- "getShowSplashAdStatus",
844
- "getSkylineInfo",
845
- "getSkylineInfoSync",
846
- "getStorage",
847
- "getStorageInfo",
848
- "getStorageInfoSync",
849
- "getStorageSync",
850
- "getSystemInfo",
851
- "getSystemInfoAsync",
852
- "getSystemInfoSync",
853
- "getSystemSetting",
854
- "getUpdateManager",
855
- "getUserCryptoManager",
856
- "getUserInfo",
857
- "getUserProfile",
858
- "getVideoInfo",
859
- "getWeRunData",
860
- "getWifiList",
861
- "getWindowInfo",
862
- "getXrFrameSystem",
863
- "hideHomeButton",
864
- "hideKeyboard",
865
- "hideLoading",
866
- "hideNavigationBarLoading",
867
- "hideShareMenu",
868
- "hideTabBar",
869
- "hideTabBarRedDot",
870
- "hideToast",
871
- "initFaceDetect",
872
- "isBluetoothDevicePaired",
873
- "isVKSupport",
874
- "join1v1Chat",
875
- "joinVoIPChat"
876
- ];
877
- //#endregion
878
- //#region src/core/apiCatalog/wxMethodsLoadBuiltInFontFaceToPreloadAssets.ts
879
- /**
880
- * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
881
- * @generated by scripts/sync-api-catalog.mjs
882
- */
883
- const WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_PRELOAD_ASSETS = [
884
- "loadBuiltInFontFace",
885
- "loadFontFace",
886
- "login",
887
- "makeBluetoothPair",
888
- "makePhoneCall",
889
- "navigateBack",
890
- "navigateBackMiniProgram",
891
- "navigateTo",
892
- "navigateToMiniProgram",
893
- "nextTick",
894
- "notifyBLECharacteristicValueChange",
895
- "notifyGroupMembers",
896
- "offAccelerometerChange",
897
- "offAfterPageLoad",
898
- "offAfterPageUnload",
899
- "offApiCategoryChange",
900
- "offAppHide",
901
- "offAppRoute",
902
- "offAppRouteDone",
903
- "offAppShow",
904
- "offAudioInterruptionBegin",
905
- "offAudioInterruptionEnd",
906
- "offBatteryInfoChange",
907
- "offBeaconServiceChange",
908
- "offBeaconUpdate",
909
- "offBeforeAppRoute",
910
- "offBeforePageLoad",
911
- "offBeforePageUnload",
912
- "offBLECharacteristicValueChange",
913
- "offBLEConnectionStateChange",
914
- "offBLEMTUChange",
915
- "offBLEPeripheralConnectionStateChanged",
916
- "offBluetoothAdapterStateChange",
917
- "offBluetoothDeviceFound",
918
- "offCompassChange",
919
- "offCopyUrl",
920
- "offDeviceMotionChange",
921
- "offEmbeddedMiniProgramHeightChange",
922
- "offError",
923
- "offGeneratePoster",
924
- "offGetWifiList",
925
- "offGyroscopeChange",
926
- "offHCEMessage",
927
- "offKeyboardHeightChange",
928
- "offKeyDown",
929
- "offKeyUp",
930
- "offLazyLoadError",
931
- "offLocalServiceDiscoveryStop",
932
- "offLocalServiceFound",
933
- "offLocalServiceLost",
934
- "offLocalServiceResolveFail",
935
- "offLocationChange",
936
- "offLocationChangeError",
937
- "offMemoryWarning",
938
- "offMenuButtonBoundingClientRectWeightChange",
939
- "offNetworkStatusChange",
940
- "offNetworkWeakChange",
941
- "offOnUserTriggerTranslation",
942
- "offPageNotFound",
943
- "offParallelStateChange",
944
- "offScreenRecordingStateChanged",
945
- "offThemeChange",
946
- "offUnhandledRejection",
947
- "offUserCaptureScreen",
948
- "offVoIPChatInterrupted",
949
- "offVoIPChatMembersChanged",
950
- "offVoIPChatSpeakersChanged",
951
- "offVoIPChatStateChanged",
952
- "offVoIPVideoMembersChanged",
953
- "offWifiConnected",
954
- "offWifiConnectedWithPartialInfo",
955
- "offWindowResize",
956
- "offWindowStateChange",
957
- "onAccelerometerChange",
958
- "onAfterPageLoad",
959
- "onAfterPageUnload",
960
- "onApiCategoryChange",
961
- "onAppHide",
962
- "onAppRoute",
963
- "onAppRouteDone",
964
- "onAppShow",
965
- "onAudioInterruptionBegin",
966
- "onAudioInterruptionEnd",
967
- "onBackgroundAudioPause",
968
- "onBackgroundAudioPlay",
969
- "onBackgroundAudioStop",
970
- "onBackgroundFetchData",
971
- "onBatteryInfoChange",
972
- "onBeaconServiceChange",
973
- "onBeaconUpdate",
974
- "onBeforeAppRoute",
975
- "onBeforePageLoad",
976
- "onBeforePageUnload",
977
- "onBLECharacteristicValueChange",
978
- "onBLEConnectionStateChange",
979
- "onBLEMTUChange",
980
- "onBLEPeripheralConnectionStateChanged",
981
- "onBluetoothAdapterStateChange",
982
- "onBluetoothDeviceFound",
983
- "onCompassChange",
984
- "onCopyUrl",
985
- "onDeviceMotionChange",
986
- "onEmbeddedMiniProgramHeightChange",
987
- "onError",
988
- "onGeneratePoster",
989
- "onGetWifiList",
990
- "onGyroscopeChange",
991
- "onHCEMessage",
992
- "onKeyboardHeightChange",
993
- "onKeyDown",
994
- "onKeyUp",
995
- "onLazyLoadError",
996
- "onLocalServiceDiscoveryStop",
997
- "onLocalServiceFound",
998
- "onLocalServiceLost",
999
- "onLocalServiceResolveFail",
1000
- "onLocationChange",
1001
- "onLocationChangeError",
1002
- "onMemoryWarning",
1003
- "onMenuButtonBoundingClientRectWeightChange",
1004
- "onNeedPrivacyAuthorization",
1005
- "onNetworkStatusChange",
1006
- "onNetworkWeakChange",
1007
- "onOnUserTriggerTranslation",
1008
- "onPageNotFound",
1009
- "onParallelStateChange",
1010
- "onScreenRecordingStateChanged",
1011
- "onSocketClose",
1012
- "onSocketError",
1013
- "onSocketMessage",
1014
- "onSocketOpen",
1015
- "onThemeChange",
1016
- "onUnhandledRejection",
1017
- "onUserCaptureScreen",
1018
- "onVoIPChatInterrupted",
1019
- "onVoIPChatMembersChanged",
1020
- "onVoIPChatSpeakersChanged",
1021
- "onVoIPChatStateChanged",
1022
- "onVoIPVideoMembersChanged",
1023
- "onWifiConnected",
1024
- "onWifiConnectedWithPartialInfo",
1025
- "onWindowResize",
1026
- "onWindowStateChange",
1027
- "openAppAuthorizeSetting",
1028
- "openBluetoothAdapter",
1029
- "openCard",
1030
- "openChannelsActivity",
1031
- "openChannelsEvent",
1032
- "openChannelsLive",
1033
- "openChannelsLiveNoticeInfo",
1034
- "openChannelsUserProfile",
1035
- "openChatTool",
1036
- "openCustomerServiceChat",
1037
- "openDocument",
1038
- "openEmbeddedMiniProgram",
1039
- "openHKOfflinePayView",
1040
- "openInquiriesTopic",
1041
- "openLocation",
1042
- "openOfficialAccountArticle",
1043
- "openOfficialAccountChat",
1044
- "openOfficialAccountProfile",
1045
- "openPrivacyContract",
1046
- "openSetting",
1047
- "openSingleStickerView",
1048
- "openStickerIPView",
1049
- "openStickerSetView",
1050
- "openStoreCouponDetail",
1051
- "openStoreOrderDetail",
1052
- "openSystemBluetoothSetting",
1053
- "openVideoEditor",
1054
- "pageScrollTo",
1055
- "pauseBackgroundAudio",
1056
- "pauseVoice",
1057
- "playBackgroundAudio",
1058
- "playVoice",
1059
- "pluginLogin",
1060
- "postMessageToReferrerMiniProgram",
1061
- "postMessageToReferrerPage",
1062
- "preDownloadSubpackage",
1063
- "preloadAssets"
1064
- ];
1065
- //#endregion
1066
- //#region src/core/apiCatalog/wxMethodsPreloadSkylineViewToWriteBLECharacteristicValue.ts
1067
- /**
1068
- * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
1069
- * @generated by scripts/sync-api-catalog.mjs
1070
- */
1071
- const WEAPI_WX_METHODS_PRELOAD_SKYLINE_VIEW_TO_WRITE_BLECHARACTERISTIC_VALUE = [
1072
- "preloadSkylineView",
1073
- "preloadWebview",
1074
- "previewImage",
1075
- "previewMedia",
1076
- "readBLECharacteristicValue",
1077
- "redirectTo",
1078
- "reLaunch",
1079
- "removeSecureElementPass",
1080
- "removeStorage",
1081
- "removeStorageSync",
1082
- "removeTabBarBadge",
1083
- "reportAnalytics",
1084
- "reportEvent",
1085
- "reportMonitor",
1086
- "reportPerformance",
1087
- "request",
1088
- "requestCommonPayment",
1089
- "requestDeviceVoIP",
1090
- "requestIdleCallback",
1091
- "requestMerchantTransfer",
1092
- "requestOrderPayment",
1093
- "requestPayment",
1094
- "requestPluginPayment",
1095
- "requestSubscribeDeviceMessage",
1096
- "requestSubscribeEmployeeMessage",
1097
- "requestSubscribeMessage",
1098
- "requestVirtualPayment",
1099
- "requirePrivacyAuthorize",
1100
- "reserveChannelsLive",
1101
- "restartMiniProgram",
1102
- "revokeBufferURL",
1103
- "rewriteRoute",
1104
- "saveFileToDisk",
1105
- "saveImageToPhotosAlbum",
1106
- "saveVideoToPhotosAlbum",
1107
- "scanCode",
1108
- "seekBackgroundAudio",
1109
- "selectGroupMembers",
1110
- "sendHCEMessage",
1111
- "sendSms",
1112
- "sendSocketMessage",
1113
- "setBackgroundColor",
1114
- "setBackgroundFetchToken",
1115
- "setBackgroundTextStyle",
1116
- "setBLEMTU",
1117
- "setClipboardData",
1118
- "setEnable1v1Chat",
1119
- "setEnableDebug",
1120
- "setInnerAudioOption",
1121
- "setKeepScreenOn",
1122
- "setNavigationBarColor",
1123
- "setNavigationBarTitle",
1124
- "setScreenBrightness",
1125
- "setStorage",
1126
- "setStorageSync",
1127
- "setTabBarBadge",
1128
- "setTabBarItem",
1129
- "setTabBarStyle",
1130
- "setTopBarText",
1131
- "setVisualEffectOnCapture",
1132
- "setWifiList",
1133
- "setWindowSize",
1134
- "shareAppMessageToGroup",
1135
- "shareEmojiToGroup",
1136
- "shareFileMessage",
1137
- "shareFileToGroup",
1138
- "shareImageToGroup",
1139
- "shareToOfficialAccount",
1140
- "shareToWeRun",
1141
- "shareVideoMessage",
1142
- "shareVideoToGroup",
1143
- "showActionSheet",
1144
- "showLoading",
1145
- "showModal",
1146
- "showNavigationBarLoading",
1147
- "showRedPackage",
1148
- "showShareImageMenu",
1149
- "showShareMenu",
1150
- "showTabBar",
1151
- "showTabBarRedDot",
1152
- "showToast",
1153
- "startAccelerometer",
1154
- "startBeaconDiscovery",
1155
- "startBluetoothDevicesDiscovery",
1156
- "startCompass",
1157
- "startDeviceMotionListening",
1158
- "startGyroscope",
1159
- "startHCE",
1160
- "startLocalServiceDiscovery",
1161
- "startLocationUpdate",
1162
- "startLocationUpdateBackground",
1163
- "startPullDownRefresh",
1164
- "startRecord",
1165
- "startSoterAuthentication",
1166
- "startWifi",
1167
- "stopAccelerometer",
1168
- "stopBackgroundAudio",
1169
- "stopBeaconDiscovery",
1170
- "stopBluetoothDevicesDiscovery",
1171
- "stopCompass",
1172
- "stopDeviceMotionListening",
1173
- "stopFaceDetect",
1174
- "stopGyroscope",
1175
- "stopHCE",
1176
- "stopLocalServiceDiscovery",
1177
- "stopLocationUpdate",
1178
- "stopPullDownRefresh",
1179
- "stopRecord",
1180
- "stopVoice",
1181
- "stopWifi",
1182
- "subscribeVoIPVideoMembers",
1183
- "switchTab",
1184
- "updateShareMenu",
1185
- "updateVoIPChatMuteConfig",
1186
- "updateWeChatApp",
1187
- "uploadFile",
1188
- "vibrateLong",
1189
- "vibrateShort",
1190
- "writeBLECharacteristicValue"
1191
- ];
1192
- [
1193
- ...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
1196
- ];
1197
- //#endregion
1198
- //#region src/core/methodMapping/rules/helpersDeviceAndStorage.ts
1199
- const PLATFORM_ALIASES$1 = {
1200
- alipay: "my",
1201
- douyin: "tt"
1202
- };
1203
- function mapSaveFileArgs(args) {
1204
- if (args.length === 0) return args;
1205
- const nextArgs = [...args];
1206
- const lastIndex = nextArgs.length - 1;
1207
- const lastArg = nextArgs[lastIndex];
1208
- if (!isPlainObject(lastArg)) return nextArgs;
1209
- const nextOptions = { ...lastArg };
1210
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "apFilePath") && Object.prototype.hasOwnProperty.call(nextOptions, "tempFilePath")) nextOptions.apFilePath = nextOptions.tempFilePath;
1211
- nextArgs[lastIndex] = nextOptions;
1212
- return nextArgs;
1213
- }
1214
- function mapCreateRewardedVideoAdArgs(args) {
1215
- if (args.length === 0) return args;
1216
- const nextArgs = [...args];
1217
- const lastIndex = nextArgs.length - 1;
1218
- const lastArg = nextArgs[lastIndex];
1219
- 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");
1222
- const adUnitId = lastArg.adUnitId;
1223
- if (typeof adUnitId === "string" && adUnitId.length > 0) nextArgs[lastIndex] = adUnitId;
1224
- return nextArgs;
1225
- }
1226
- function mapRewardedAdInstance(result, args = []) {
1227
- if (typeof result !== "object" || result === null) return result;
1228
- const adUnitIdArg = args.length > 0 ? args[args.length - 1] : void 0;
1229
- const adUnitId = typeof adUnitIdArg === "string" ? adUnitIdArg : void 0;
1230
- if (!adUnitId) return result;
1231
- const rewardedAd = result;
1232
- const wrapMethod = (name) => {
1233
- const method = rewardedAd[name];
1234
- if (typeof method !== "function") return method;
1235
- return (options) => {
1236
- if (isPlainObject(options)) return method.call(rewardedAd, {
1237
- ...options,
1238
- adUnitId
1239
- });
1240
- if (options === void 0) return method.call(rewardedAd, { adUnitId });
1241
- return method.call(rewardedAd, options);
1242
- };
1243
- };
1244
- const nextRewardedAd = Object.create(rewardedAd);
1245
- nextRewardedAd.destroy = wrapMethod("destroy");
1246
- nextRewardedAd.load = wrapMethod("load");
1247
- nextRewardedAd.show = wrapMethod("show");
1248
- return nextRewardedAd;
1249
- }
1250
- function mapCheckIsSoterEnrolledInDeviceArgs(args) {
1251
- if (args.length === 0) return args;
1252
- const nextArgs = [...args];
1253
- const lastArg = nextArgs[nextArgs.length - 1];
1254
- if (!isPlainObject(lastArg)) return nextArgs;
1255
- if (lastArg.checkAuthMode === "speech") throw createNotSupportedError("checkIsSoterEnrolledInDevice", "my");
1256
- return nextArgs;
1257
- }
1258
- function mapSoterCheckResult(methodName, result) {
1259
- if (!isPlainObject(result)) return result;
1260
- if (Object.prototype.hasOwnProperty.call(result, "errMsg")) return result;
1261
- return {
1262
- ...result,
1263
- errMsg: `${methodName}:ok`
1264
- };
1265
- }
1266
- function toNumberCode(value) {
1267
- if (typeof value === "number" && Number.isFinite(value)) return value;
1268
- if (typeof value === "string") {
1269
- const parsed = Number(value);
1270
- if (Number.isFinite(parsed)) return parsed;
1271
- }
1272
- }
1273
- function mapBleConnectionResult(methodName, codeKey, result) {
1274
- if (!isPlainObject(result)) return result;
1275
- const nextResult = { ...result };
1276
- if (!Object.prototype.hasOwnProperty.call(nextResult, "errCode")) {
1277
- const code = toNumberCode(nextResult[codeKey]);
1278
- if (typeof code === "number") nextResult.errCode = code;
1279
- }
1280
- if (!Object.prototype.hasOwnProperty.call(nextResult, "errMsg")) {
1281
- if (typeof nextResult.errorMessage === "string" && nextResult.errorMessage.length > 0) nextResult.errMsg = nextResult.errorMessage;
1282
- else if (nextResult.errCode === 0) nextResult.errMsg = `${methodName}:ok`;
1283
- }
1284
- return nextResult;
1285
- }
1286
- function mapCreateBleConnectionResult(result) {
1287
- return mapBleConnectionResult("createBLEConnection", "error", result);
1288
- }
1289
- function mapCloseBleConnectionResult(result) {
1290
- return mapBleConnectionResult("closeBLEConnection", "errorCode", result);
1291
- }
1292
- function mapSaveFileResult(result) {
1293
- if (!isPlainObject(result)) return result;
1294
- if (!Object.prototype.hasOwnProperty.call(result, "savedFilePath") && Object.prototype.hasOwnProperty.call(result, "apFilePath")) return {
1295
- ...result,
1296
- savedFilePath: result.apFilePath
1297
- };
1298
- return result;
1299
- }
1300
- function mapDouyinSaveFileResult(result) {
1301
- if (!isPlainObject(result)) return result;
1302
- if (!Object.prototype.hasOwnProperty.call(result, "savedFilePath") && Object.prototype.hasOwnProperty.call(result, "filePath")) return {
1303
- ...result,
1304
- savedFilePath: result.filePath
1305
- };
1306
- return result;
1307
- }
1308
- function normalizePlatformName$1(value) {
1309
- if (!value) return;
1310
- const normalized = value.trim().toLowerCase();
1311
- if (!normalized) return;
1312
- return PLATFORM_ALIASES$1[normalized] ?? normalized;
1313
- }
1314
- //#endregion
1315
- //#region src/core/methodMapping/rules/helpersUi.ts
1316
- function mapToastType(type) {
1317
- if (type === "error") return "fail";
1318
- if (type === "loading") return "none";
1319
- return type;
1320
- }
1321
- function mapToastArgs(args) {
1322
- if (args.length === 0) return args;
1323
- const nextArgs = [...args];
1324
- const lastIndex = nextArgs.length - 1;
1325
- const lastArg = nextArgs[lastIndex];
1326
- if (!isPlainObject(lastArg)) return nextArgs;
1327
- 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);
1330
- nextArgs[lastIndex] = nextOptions;
1331
- return nextArgs;
1332
- }
1333
- function mapDouyinToastArgs(args) {
1334
- if (args.length === 0) return args;
1335
- const nextArgs = [...args];
1336
- const lastIndex = nextArgs.length - 1;
1337
- const lastArg = nextArgs[lastIndex];
1338
- if (!isPlainObject(lastArg)) return nextArgs;
1339
- const nextOptions = { ...lastArg };
1340
- if (nextOptions.icon === "error") nextOptions.icon = "fail";
1341
- nextArgs[lastIndex] = nextOptions;
1342
- return nextArgs;
1343
- }
1344
- function mapLoadingArgs(args) {
1345
- if (args.length === 0) return args;
1346
- const nextArgs = [...args];
1347
- const lastIndex = nextArgs.length - 1;
1348
- const lastArg = nextArgs[lastIndex];
1349
- if (!isPlainObject(lastArg)) return nextArgs;
1350
- const nextOptions = { ...lastArg };
1351
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "content") && Object.prototype.hasOwnProperty.call(nextOptions, "title")) nextOptions.content = nextOptions.title;
1352
- nextArgs[lastIndex] = nextOptions;
1353
- return nextArgs;
1354
- }
1355
- function mapActionSheetArgs(args) {
1356
- if (args.length === 0) return args;
1357
- const nextArgs = [...args];
1358
- const lastIndex = nextArgs.length - 1;
1359
- const lastArg = nextArgs[lastIndex];
1360
- if (!isPlainObject(lastArg)) return nextArgs;
1361
- const nextOptions = { ...lastArg };
1362
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "items") && Array.isArray(nextOptions.itemList)) nextOptions.items = nextOptions.itemList;
1363
- nextArgs[lastIndex] = nextOptions;
1364
- return nextArgs;
1365
- }
1366
- function mapActionSheetResult(result) {
1367
- if (!isPlainObject(result)) return result;
1368
- if (!Object.prototype.hasOwnProperty.call(result, "tapIndex") && Object.prototype.hasOwnProperty.call(result, "index")) return {
1369
- ...result,
1370
- tapIndex: result.index
1371
- };
1372
- return result;
1373
- }
1374
- function mapModalArgs(args) {
1375
- if (args.length === 0) return args;
1376
- const nextArgs = [...args];
1377
- const lastIndex = nextArgs.length - 1;
1378
- const lastArg = nextArgs[lastIndex];
1379
- if (!isPlainObject(lastArg)) return nextArgs;
1380
- 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;
1386
- nextArgs[lastIndex] = nextOptions;
1387
- return nextArgs;
1388
- }
1389
- function mapModalResult(result) {
1390
- if (!isPlainObject(result)) return result;
1391
- let changed = false;
1392
- const nextResult = { ...result };
1393
- if (!Object.prototype.hasOwnProperty.call(nextResult, "cancel") && Object.prototype.hasOwnProperty.call(nextResult, "confirm")) {
1394
- nextResult.cancel = !nextResult.confirm;
1395
- changed = true;
1396
- }
1397
- if (!Object.prototype.hasOwnProperty.call(nextResult, "content")) {
1398
- nextResult.content = "";
1399
- changed = true;
1400
- }
1401
- return changed ? nextResult : result;
1402
- }
1403
- function mapChooseImageResult(result) {
1404
- if (!isPlainObject(result)) return result;
1405
- if (!Object.prototype.hasOwnProperty.call(result, "tempFilePaths") && Array.isArray(result.apFilePaths)) return {
1406
- ...result,
1407
- tempFilePaths: result.apFilePaths
1408
- };
1409
- return result;
1410
- }
1411
- function mapDouyinChooseImageResult(result) {
1412
- if (!isPlainObject(result)) return result;
1413
- if (typeof result.tempFilePaths === "string") return {
1414
- ...result,
1415
- tempFilePaths: [result.tempFilePaths]
1416
- };
1417
- if (!Array.isArray(result.tempFilePaths) && Array.isArray(result.tempFiles)) {
1418
- const fallbackPaths = result.tempFiles.map((item) => {
1419
- if (!isPlainObject(item)) return;
1420
- const path = item.path;
1421
- if (typeof path === "string" && path) return path;
1422
- const filePath = item.filePath;
1423
- if (typeof filePath === "string" && filePath) return filePath;
1424
- }).filter((item) => typeof item === "string");
1425
- if (fallbackPaths.length > 0) return {
1426
- ...result,
1427
- tempFilePaths: fallbackPaths
1428
- };
1429
- }
1430
- return result;
1431
- }
1432
- //#endregion
1433
- //#region src/core/methodMapping/rules/helpersMediaClipboard.ts
1434
- function mapSetClipboardArgs(args) {
1435
- if (args.length === 0) return args;
1436
- const nextArgs = [...args];
1437
- const lastIndex = nextArgs.length - 1;
1438
- const lastArg = nextArgs[lastIndex];
1439
- if (!isPlainObject(lastArg)) return nextArgs;
1440
- const nextOptions = { ...lastArg };
1441
- if (!Object.prototype.hasOwnProperty.call(nextOptions, "text") && Object.prototype.hasOwnProperty.call(nextOptions, "data")) nextOptions.text = nextOptions.data;
1442
- nextArgs[lastIndex] = nextOptions;
1443
- return nextArgs;
1444
- }
1445
- function mapClipboardResult(result) {
1446
- if (!isPlainObject(result)) return result;
1447
- if (!Object.prototype.hasOwnProperty.call(result, "data") && Object.prototype.hasOwnProperty.call(result, "text")) return {
1448
- ...result,
1449
- data: result.text
1450
- };
1451
- return result;
1452
- }
1453
- function resolveFilePaths(result) {
1454
- if (!isPlainObject(result)) return [];
1455
- if (typeof result.tempFilePaths === "string" && result.tempFilePaths) return [result.tempFilePaths];
1456
- if (Array.isArray(result.tempFilePaths)) return result.tempFilePaths.filter((item) => typeof item === "string" && item.length > 0);
1457
- if (Array.isArray(result.apFilePaths)) return result.apFilePaths.filter((item) => typeof item === "string" && item.length > 0);
1458
- if (Array.isArray(result.tempFiles)) return result.tempFiles.map((item) => {
1459
- if (!isPlainObject(item)) return;
1460
- if (typeof item.tempFilePath === "string" && item.tempFilePath) return item.tempFilePath;
1461
- if (typeof item.path === "string" && item.path) return item.path;
1462
- if (typeof item.filePath === "string" && item.filePath) return item.filePath;
1463
- }).filter((item) => typeof item === "string");
1464
- return [];
1465
- }
1466
- function mapChooseMediaResultFromImage(result) {
1467
- const normalized = mapChooseImageResult(result);
1468
- if (!isPlainObject(normalized)) return normalized;
1469
- if (Array.isArray(normalized.tempFiles) && normalized.tempFiles.length > 0) return normalized;
1470
- const tempFilePaths = resolveFilePaths(normalized);
1471
- if (tempFilePaths.length === 0) return normalized;
1472
- return {
1473
- ...normalized,
1474
- tempFilePaths,
1475
- tempFiles: tempFilePaths.map((tempFilePath) => ({
1476
- tempFilePath,
1477
- fileType: "image"
1478
- })),
1479
- type: "image"
1480
- };
1481
- }
1482
- //#endregion
1483
- //#region src/core/methodMapping/rules/myBindEmployeeRelationToSendHCEMessage.ts
1484
- const MY_METHOD_MAPPINGS_BIND_EMPLOYEE_RELATION_TO_SEND_HCEMESSAGE = {
1485
- bindEmployeeRelation: { target: "bindEmployeeRelation" },
1486
- canAddSecureElementPass: { target: "canAddSecureElementPass" },
1487
- canvasGetImageData: { target: "canvasGetImageData" },
1488
- canvasPutImageData: { target: "canvasPutImageData" },
1489
- checkDeviceSupportHevc: { target: "checkDeviceSupportHevc" },
1490
- checkEmployeeRelation: { target: "checkEmployeeRelation" },
1491
- checkIsAddedToMyMiniProgram: { target: "checkIsAddedToMyMiniProgram" },
1492
- checkIsOpenAccessibility: { target: "checkIsOpenAccessibility" },
1493
- checkIsPictureInPictureActive: { target: "checkIsPictureInPictureActive" },
1494
- checkIsSoterEnrolledInDevice: {
1495
- target: "checkIsIfaaEnrolledInDevice",
1496
- mapArgs: mapCheckIsSoterEnrolledInDeviceArgs,
1497
- mapResult: (result) => mapSoterCheckResult("checkIsSoterEnrolledInDevice", result)
1498
- },
1499
- checkIsSupportSoterAuthentication: {
1500
- target: "checkIsSupportIfaaAuthentication",
1501
- mapResult: (result) => mapSoterCheckResult("checkIsSupportSoterAuthentication", result)
1502
- },
1503
- openCard: { target: "openCard" },
1504
- openChannelsActivity: { target: "openChannelsActivity" },
1505
- openChannelsEvent: { target: "openChannelsEvent" },
1506
- openChannelsLive: { target: "openChannelsLive" },
1507
- openChannelsLiveNoticeInfo: { target: "openChannelsLiveNoticeInfo" },
1508
- openChannelsUserProfile: { target: "openChannelsUserProfile" },
1509
- openChatTool: { target: "openChatTool" },
1510
- openHKOfflinePayView: { target: "openHKOfflinePayView" },
1511
- openInquiriesTopic: { target: "openInquiriesTopic" },
1512
- openOfficialAccountArticle: { target: "openOfficialAccountArticle" },
1513
- openOfficialAccountChat: { target: "openOfficialAccountChat" },
1514
- openOfficialAccountProfile: { target: "openOfficialAccountProfile" },
1515
- openPrivacyContract: { target: "openPrivacyContract" },
1516
- openSystemBluetoothSetting: { target: "openSystemBluetoothSetting" },
1517
- reportEvent: { target: "reportEvent" },
1518
- reportMonitor: { target: "reportMonitor" },
1519
- reportPerformance: { target: "reportPerformance" },
1520
- openSingleStickerView: { target: "openSingleStickerView" },
1521
- openStickerIPView: { target: "openStickerIPView" },
1522
- openStickerSetView: { target: "openStickerSetView" },
1523
- openStoreCouponDetail: { target: "openStoreCouponDetail" },
1524
- openStoreOrderDetail: { target: "openStoreOrderDetail" },
1525
- pauseBackgroundAudio: { target: "pauseBackgroundAudio" },
1526
- pauseVoice: { target: "pauseVoice" },
1527
- playBackgroundAudio: { target: "playBackgroundAudio" },
1528
- playVoice: { target: "playVoice" },
1529
- postMessageToReferrerMiniProgram: { target: "postMessageToReferrerMiniProgram" },
1530
- postMessageToReferrerPage: { target: "postMessageToReferrerPage" },
1531
- preDownloadSubpackage: { target: "preDownloadSubpackage" },
1532
- preloadAssets: { target: "preloadAssets" },
1533
- preloadSkylineView: { target: "preloadSkylineView" },
1534
- preloadWebview: { target: "preloadWebview" },
1535
- removeSecureElementPass: { target: "removeSecureElementPass" },
1536
- chooseInvoiceTitle: { target: "chooseInvoiceTitle" },
1537
- chooseLicensePlate: { target: "chooseLicensePlate" },
1538
- choosePoi: { target: "choosePoi" },
1539
- closeBLEConnection: {
1540
- target: "disconnectBLEDevice",
1541
- mapResult: mapCloseBleConnectionResult
1542
- },
1543
- createBLEConnection: {
1544
- target: "connectBLEDevice",
1545
- mapResult: mapCreateBleConnectionResult
1546
- },
1547
- cropImage: { target: "cropImage" },
1548
- editImage: { target: "editImage" },
1549
- exitVoIPChat: { target: "exitVoIPChat" },
1550
- faceDetect: { target: "faceDetect" },
1551
- getApiCategory: { target: "getApiCategory" },
1552
- getBackgroundFetchToken: { target: "getBackgroundFetchToken" },
1553
- getChannelsLiveInfo: { target: "getChannelsLiveInfo" },
1554
- getChannelsLiveNoticeInfo: { target: "getChannelsLiveNoticeInfo" },
1555
- getChannelsShareKey: { target: "getChannelsShareKey" },
1556
- getChatToolInfo: { target: "getChatToolInfo" },
1557
- getCommonConfig: { target: "getCommonConfig" },
1558
- getGroupEnterInfo: { target: "getGroupEnterInfo" },
1559
- getPrivacySetting: { target: "getPrivacySetting" },
1560
- initFaceDetect: { target: "initFaceDetect" },
1561
- join1v1Chat: { target: "join1v1Chat" },
1562
- requestCommonPayment: { target: "requestCommonPayment" },
1563
- requestDeviceVoIP: { target: "requestDeviceVoIP" },
1564
- requestMerchantTransfer: { target: "requestMerchantTransfer" },
1565
- requirePrivacyAuthorize: { target: "requirePrivacyAuthorize" },
1566
- reserveChannelsLive: { target: "reserveChannelsLive" },
1567
- selectGroupMembers: { target: "selectGroupMembers" },
1568
- sendHCEMessage: { target: "sendHCEMessage" }
1569
- };
1570
- //#endregion
1571
- //#region src/core/methodMapping/rules/myCreateVKSessionToOffBLEConnectionStateChange.ts
1572
- const MY_METHOD_MAPPINGS_CREATE_VKSESSION_TO_OFF_BLECONNECTION_STATE_CHANGE = {
1573
- createVKSession: { target: "createVKSession" },
1574
- compressVideo: { target: "compressVideo" },
1575
- openVideoEditor: { target: "openVideoEditor" },
1576
- getShareInfo: { target: "getShareInfo" },
1577
- joinVoIPChat: { target: "joinVoIPChat" },
1578
- openDocument: { target: "openDocument" },
1579
- saveVideoToPhotosAlbum: { target: "saveVideoToPhotosAlbum" },
1580
- batchSetStorage: { target: "batchSetStorage" },
1581
- batchGetStorage: { target: "batchGetStorage" },
1582
- batchSetStorageSync: { target: "batchSetStorageSync" },
1583
- batchGetStorageSync: { target: "batchGetStorageSync" },
1584
- createCameraContext: { target: "createCameraContext" },
1585
- offMemoryWarning: { target: "offMemoryWarning" },
1586
- cancelIdleCallback: { target: "cancelIdleCallback" },
1587
- onBLEConnectionStateChange: { target: "onBLEConnectionStateChanged" },
1588
- offBLEConnectionStateChange: { target: "offBLEConnectionStateChanged" }
1589
- };
1590
- //#endregion
1591
- //#region src/core/methodMapping/rules/mySendSmsToOpenCustomerServiceChat.ts
1592
- const MY_METHOD_MAPPINGS_SEND_SMS_TO_OPEN_CUSTOMER_SERVICE_CHAT = {
1593
- sendSms: { target: "sendSms" },
1594
- setBackgroundFetchToken: { target: "setBackgroundFetchToken" },
1595
- setEnable1v1Chat: { target: "setEnable1v1Chat" },
1596
- setTopBarText: { target: "setTopBarText" },
1597
- setWindowSize: { target: "setWindowSize" },
1598
- stopHCE: { target: "stopHCE" },
1599
- stopLocalServiceDiscovery: { target: "stopLocalServiceDiscovery" },
1600
- stopLocationUpdate: { target: "stopLocationUpdate" },
1601
- stopRecord: { target: "stopRecord" },
1602
- stopVoice: { target: "stopVoice" },
1603
- subscribeVoIPVideoMembers: { target: "subscribeVoIPVideoMembers" },
1604
- updateVoIPChatMuteConfig: { target: "updateVoIPChatMuteConfig" },
1605
- updateWeChatApp: { target: "updateWeChatApp" },
1606
- getBackgroundAudioPlayerState: { target: "getBackgroundAudioPlayerState" },
1607
- getDeviceBenchmarkInfo: { target: "getDeviceBenchmarkInfo" },
1608
- getDeviceVoIPList: { target: "getDeviceVoIPList" },
1609
- getHCEState: { target: "getHCEState" },
1610
- getInferenceEnvInfo: { target: "getInferenceEnvInfo" },
1611
- getNFCAdapter: { target: "getNFCAdapter" },
1612
- getPerformance: { target: "getPerformance" },
1613
- getRandomValues: { target: "getRandomValues" },
1614
- getRealtimeLogManager: { target: "getRealtimeLogManager" },
1615
- getRendererUserAgent: { target: "getRendererUserAgent" },
1616
- getScreenRecordingState: { target: "getScreenRecordingState" },
1617
- getSecureElementPasses: { target: "getSecureElementPasses" },
1618
- getSelectedTextRange: { target: "getSelectedTextRange" },
1619
- getShowSplashAdStatus: { target: "getShowSplashAdStatus" },
1620
- getSkylineInfo: { target: "getSkylineInfo" },
1621
- getUserCryptoManager: { target: "getUserCryptoManager" },
1622
- getWeRunData: { target: "getWeRunData" },
1623
- getXrFrameSystem: { target: "getXrFrameSystem" },
1624
- isBluetoothDevicePaired: { target: "isBluetoothDevicePaired" },
1625
- isVKSupport: { target: "isVKSupport" },
1626
- createBLEPeripheralServer: { target: "createBLEPeripheralServer" },
1627
- createBufferURL: { target: "createBufferURL" },
1628
- createCacheManager: { target: "createCacheManager" },
1629
- createGlobalPayment: { target: "createGlobalPayment" },
1630
- createInferenceSession: { target: "createInferenceSession" },
1631
- createMediaAudioPlayer: { target: "createMediaAudioPlayer" },
1632
- createMediaContainer: { target: "createMediaContainer" },
1633
- createMediaRecorder: { target: "createMediaRecorder" },
1634
- createTCPSocket: { target: "createTCPSocket" },
1635
- createUDPSocket: { target: "createUDPSocket" },
1636
- createVideoDecoder: { target: "createVideoDecoder" },
1637
- loadBuiltInFontFace: { target: "loadBuiltInFontFace" },
1638
- notifyGroupMembers: { target: "notifyGroupMembers" },
1639
- requestIdleCallback: { target: "requestIdleCallback" },
1640
- revokeBufferURL: { target: "revokeBufferURL" },
1641
- rewriteRoute: { target: "rewriteRoute" },
1642
- seekBackgroundAudio: { target: "seekBackgroundAudio" },
1643
- setEnableDebug: { target: "setEnableDebug" },
1644
- setInnerAudioOption: { target: "setInnerAudioOption" },
1645
- shareAppMessageToGroup: { target: "shareAppMessageToGroup" },
1646
- shareEmojiToGroup: { target: "shareEmojiToGroup" },
1647
- shareFileMessage: { target: "shareFileMessage" },
1648
- shareFileToGroup: { target: "shareFileToGroup" },
1649
- shareImageToGroup: { target: "shareImageToGroup" },
1650
- shareToOfficialAccount: { target: "shareToOfficialAccount" },
1651
- shareToWeRun: { target: "shareToWeRun" },
1652
- shareVideoMessage: { target: "shareVideoMessage" },
1653
- shareVideoToGroup: { target: "shareVideoToGroup" },
1654
- showRedPackage: { target: "showRedPackage" },
1655
- startDeviceMotionListening: { target: "startDeviceMotionListening" },
1656
- startHCE: { target: "startHCE" },
1657
- startLocalServiceDiscovery: { target: "startLocalServiceDiscovery" },
1658
- startLocationUpdate: { target: "startLocationUpdate" },
1659
- startLocationUpdateBackground: { target: "startLocationUpdateBackground" },
1660
- startRecord: { target: "startRecord" },
1661
- startSoterAuthentication: { target: "startSoterAuthentication" },
1662
- stopBackgroundAudio: { target: "stopBackgroundAudio" },
1663
- stopDeviceMotionListening: { target: "stopDeviceMotionListening" },
1664
- stopFaceDetect: { target: "stopFaceDetect" },
1665
- openCustomerServiceChat: { target: "openCustomerServiceChat" }
1666
- };
1667
- //#endregion
1668
- //#region src/core/methodMapping/rules/my.ts
1669
- const MY_METHOD_MAPPINGS = {
1670
- showToast: {
1671
- target: "showToast",
1672
- mapArgs: mapToastArgs
1673
- },
1674
- showLoading: {
1675
- target: "showLoading",
1676
- mapArgs: mapLoadingArgs
1677
- },
1678
- showActionSheet: {
1679
- target: "showActionSheet",
1680
- mapArgs: mapActionSheetArgs,
1681
- mapResult: mapActionSheetResult
1682
- },
1683
- showModal: {
1684
- target: "confirm",
1685
- mapArgs: mapModalArgs,
1686
- mapResult: mapModalResult
1687
- },
1688
- chooseImage: {
1689
- target: "chooseImage",
1690
- mapResult: mapChooseImageResult
1691
- },
1692
- chooseMedia: { target: "chooseMedia" },
1693
- chooseMessageFile: { target: "chooseMessageFile" },
1694
- getFuzzyLocation: { target: "getFuzzyLocation" },
1695
- previewMedia: { target: "previewMedia" },
1696
- createInterstitialAd: { target: "createInterstitialAd" },
1697
- createRewardedVideoAd: {
1698
- target: "createRewardedAd",
1699
- mapArgs: mapCreateRewardedVideoAdArgs,
1700
- mapResult: mapRewardedAdInstance
1701
- },
1702
- createLivePlayerContext: { target: "createLivePlayerContext" },
1703
- createLivePusherContext: { target: "createLivePusherContext" },
1704
- getVideoInfo: { target: "getVideoInfo" },
1705
- saveFile: {
1706
- target: "saveFile",
1707
- mapArgs: mapSaveFileArgs,
1708
- mapResult: mapSaveFileResult
1709
- },
1710
- setClipboardData: {
1711
- target: "setClipboard",
1712
- mapArgs: mapSetClipboardArgs
1713
- },
1714
- getClipboardData: {
1715
- target: "getClipboard",
1716
- mapResult: mapClipboardResult
1717
- },
1718
- chooseAddress: { target: "chooseAddress" },
1719
- createAudioContext: { target: "createAudioContext" },
1720
- createWebAudioContext: { target: "createWebAudioContext" },
1721
- getSystemInfoAsync: { target: "getSystemInfo" },
1722
- openAppAuthorizeSetting: { target: "openAppAuthorizeSetting" },
1723
- pluginLogin: { target: "pluginLogin" },
1724
- login: { target: "login" },
1725
- authorize: { target: "authorize" },
1726
- checkSession: { target: "checkSession" },
1727
- requestSubscribeDeviceMessage: { target: "requestSubscribeDeviceMessage" },
1728
- requestSubscribeEmployeeMessage: { target: "requestSubscribeEmployeeMessage" },
1729
- restartMiniProgram: { target: "restartMiniProgram" },
1730
- scanCode: { target: "scanCode" },
1731
- requestPayment: { target: "requestPayment" },
1732
- requestOrderPayment: { target: "requestOrderPayment" },
1733
- requestPluginPayment: { target: "requestPluginPayment" },
1734
- requestVirtualPayment: { target: "requestVirtualPayment" },
1735
- showShareImageMenu: { target: "showShareImageMenu" },
1736
- updateShareMenu: { target: "updateShareMenu" },
1737
- openEmbeddedMiniProgram: { target: "openEmbeddedMiniProgram" },
1738
- saveFileToDisk: { target: "saveFileToDisk" },
1739
- getEnterOptionsSync: { target: "getEnterOptionsSync" },
1740
- getSystemSetting: { target: "getSystemSetting" },
1741
- getUserProfile: { target: "getUserProfile" },
1742
- getUserInfo: { target: "getUserInfo" },
1743
- getAppAuthorizeSetting: { target: "getAppAuthorizeSetting" },
1744
- getAppBaseInfo: { target: "getAppBaseInfo" },
1745
- chooseVideo: { target: "chooseVideo" },
1746
- hideHomeButton: { target: "hideBackHome" },
1747
- getWindowInfo: { target: "getWindowInfo" },
1748
- getDeviceInfo: { target: "getDeviceInfo" },
1749
- getAccountInfoSync: { target: "getAccountInfoSync" },
1750
- setBackgroundColor: { target: "setBackgroundColor" },
1751
- setBackgroundTextStyle: { target: "setBackgroundTextStyle" },
1752
- getNetworkType: { target: "getNetworkType" },
1753
- getBatteryInfo: { target: "getBatteryInfo" },
1754
- getBatteryInfoSync: { target: "getBatteryInfoSync" },
1755
- getLogManager: { target: "getLogManager" },
1756
- nextTick: { target: "nextTick" },
1757
- onWindowResize: { target: "onWindowResize" },
1758
- offWindowResize: { target: "offWindowResize" },
1759
- reportAnalytics: { target: "reportAnalytics" },
1760
- addCard: { target: "addCard" },
1761
- addFileToFavorites: { target: "addFileToFavorites" },
1762
- addPaymentPassFinish: { target: "addPaymentPassFinish" },
1763
- addPaymentPassGetCertificateData: { target: "addPaymentPassGetCertificateData" },
1764
- addPhoneCalendar: { target: "addPhoneCalendar" },
1765
- addPhoneContact: { target: "addPhoneContact" },
1766
- addPhoneRepeatCalendar: { target: "addPhoneRepeatCalendar" },
1767
- addVideoToFavorites: { target: "addVideoToFavorites" },
1768
- authorizeForMiniProgram: { target: "authorizeForMiniProgram" },
1769
- authPrivateMessage: { target: "authPrivateMessage" },
1770
- ...MY_METHOD_MAPPINGS_BIND_EMPLOYEE_RELATION_TO_SEND_HCEMESSAGE,
1771
- ...MY_METHOD_MAPPINGS_SEND_SMS_TO_OPEN_CUSTOMER_SERVICE_CHAT,
1772
- ...MY_METHOD_MAPPINGS_CREATE_VKSESSION_TO_OFF_BLECONNECTION_STATE_CHANGE
1773
- };
1774
- //#endregion
1775
- //#region src/core/methodMapping/rules/ttCanvasGetImageDataToSetTopBarText.ts
1776
- const TT_METHOD_MAPPINGS_CANVAS_GET_IMAGE_DATA_TO_SET_TOP_BAR_TEXT = {
1777
- canvasGetImageData: { target: "canvasGetImageData" },
1778
- canvasPutImageData: { target: "canvasPutImageData" },
1779
- checkDeviceSupportHevc: { target: "checkDeviceSupportHevc" },
1780
- checkEmployeeRelation: { target: "checkEmployeeRelation" },
1781
- checkIsAddedToMyMiniProgram: { target: "checkIsAddedToMyMiniProgram" },
1782
- checkIsOpenAccessibility: { target: "checkIsOpenAccessibility" },
1783
- checkIsPictureInPictureActive: { target: "checkIsPictureInPictureActive" },
1784
- checkIsSoterEnrolledInDevice: { target: "checkIsSoterEnrolledInDevice" },
1785
- checkIsSupportSoterAuthentication: { target: "checkIsSupportSoterAuthentication" },
1786
- openCard: { target: "openCard" },
1787
- openChannelsActivity: { target: "openChannelsActivity" },
1788
- openChannelsEvent: { target: "openChannelsEvent" },
1789
- openChannelsLive: { target: "openChannelsLive" },
1790
- openChannelsLiveNoticeInfo: { target: "openChannelsLiveNoticeInfo" },
1791
- openChannelsUserProfile: { target: "openChannelsUserProfile" },
1792
- openChatTool: { target: "openChatTool" },
1793
- openHKOfflinePayView: { target: "openHKOfflinePayView" },
1794
- openInquiriesTopic: { target: "openInquiriesTopic" },
1795
- openOfficialAccountArticle: { target: "openOfficialAccountArticle" },
1796
- openOfficialAccountChat: { target: "openOfficialAccountChat" },
1797
- openOfficialAccountProfile: { target: "openOfficialAccountProfile" },
1798
- openPrivacyContract: { target: "openPrivacyContract" },
1799
- openSystemBluetoothSetting: { target: "openSystemBluetoothSetting" },
1800
- reportEvent: { target: "reportEvent" },
1801
- reportMonitor: { target: "reportMonitor" },
1802
- reportPerformance: { target: "reportPerformance" },
1803
- openSingleStickerView: { target: "openSingleStickerView" },
1804
- openStickerIPView: { target: "openStickerIPView" },
1805
- openStickerSetView: { target: "openStickerSetView" },
1806
- openStoreCouponDetail: { target: "openStoreCouponDetail" },
1807
- openStoreOrderDetail: { target: "openStoreOrderDetail" },
1808
- pauseBackgroundAudio: { target: "pauseBackgroundAudio" },
1809
- pauseVoice: { target: "pauseVoice" },
1810
- playBackgroundAudio: { target: "playBackgroundAudio" },
1811
- playVoice: { target: "playVoice" },
1812
- postMessageToReferrerMiniProgram: { target: "postMessageToReferrerMiniProgram" },
1813
- postMessageToReferrerPage: { target: "postMessageToReferrerPage" },
1814
- preDownloadSubpackage: { target: "preDownloadSubpackage" },
1815
- preloadAssets: { target: "preloadAssets" },
1816
- preloadSkylineView: { target: "preloadSkylineView" },
1817
- preloadWebview: { target: "preloadWebview" },
1818
- removeSecureElementPass: { target: "removeSecureElementPass" },
1819
- chooseInvoiceTitle: { target: "chooseInvoiceTitle" },
1820
- chooseLicensePlate: { target: "chooseLicensePlate" },
1821
- choosePoi: { target: "choosePoi" },
1822
- closeBLEConnection: { target: "closeBLEConnection" },
1823
- createBLEConnection: { target: "createBLEConnection" },
1824
- cropImage: { target: "cropImage" },
1825
- editImage: { target: "editImage" },
1826
- exitVoIPChat: { target: "exitVoIPChat" },
1827
- faceDetect: { target: "faceDetect" },
1828
- getApiCategory: { target: "getApiCategory" },
1829
- getBackgroundFetchToken: { target: "getBackgroundFetchToken" },
1830
- getChannelsLiveInfo: { target: "getChannelsLiveInfo" },
1831
- getChannelsLiveNoticeInfo: { target: "getChannelsLiveNoticeInfo" },
1832
- getChannelsShareKey: { target: "getChannelsShareKey" },
1833
- getChatToolInfo: { target: "getChatToolInfo" },
1834
- getCommonConfig: { target: "getCommonConfig" },
1835
- getGroupEnterInfo: { target: "getGroupEnterInfo" },
1836
- getPrivacySetting: { target: "getPrivacySetting" },
1837
- initFaceDetect: { target: "initFaceDetect" },
1838
- join1v1Chat: { target: "join1v1Chat" },
1839
- requestCommonPayment: { target: "requestCommonPayment" },
1840
- requestDeviceVoIP: { target: "requestDeviceVoIP" },
1841
- requestMerchantTransfer: { target: "requestMerchantTransfer" },
1842
- requirePrivacyAuthorize: { target: "requirePrivacyAuthorize" },
1843
- reserveChannelsLive: { target: "reserveChannelsLive" },
1844
- selectGroupMembers: { target: "selectGroupMembers" },
1845
- sendHCEMessage: { target: "sendHCEMessage" },
1846
- sendSms: { target: "sendSms" },
1847
- setBackgroundFetchToken: { target: "setBackgroundFetchToken" },
1848
- setEnable1v1Chat: { target: "setEnable1v1Chat" },
1849
- setTopBarText: { target: "setTopBarText" }
1850
- };
1851
- //#endregion
1852
- //#region src/core/methodMapping/rules/ttJoinVoIPChatToOffBLEConnectionStateChange.ts
1853
- const TT_METHOD_MAPPINGS_JOIN_VO_IPCHAT_TO_OFF_BLECONNECTION_STATE_CHANGE = {
1854
- joinVoIPChat: { target: "joinVoIPChat" },
1855
- openDocument: { target: "openDocument" },
1856
- saveVideoToPhotosAlbum: { target: "saveVideoToPhotosAlbum" },
1857
- batchSetStorage: { target: "batchSetStorage" },
1858
- batchGetStorage: { target: "batchGetStorage" },
1859
- batchSetStorageSync: { target: "batchSetStorageSync" },
1860
- batchGetStorageSync: { target: "batchGetStorageSync" },
1861
- createCameraContext: { target: "createCameraContext" },
1862
- offMemoryWarning: { target: "offMemoryWarning" },
1863
- cancelIdleCallback: { target: "cancelIdleCallback" },
1864
- onBLEConnectionStateChange: { target: "onBLEConnectionStateChange" },
1865
- offBLEConnectionStateChange: { target: "offBLEConnectionStateChange" }
1866
- };
1867
- //#endregion
1868
- //#region src/core/methodMapping/rules/ttSetWindowSizeToGetShareInfo.ts
1869
- const TT_METHOD_MAPPINGS_SET_WINDOW_SIZE_TO_GET_SHARE_INFO = {
1870
- setWindowSize: { target: "setWindowSize" },
1871
- stopHCE: { target: "stopHCE" },
1872
- stopLocalServiceDiscovery: { target: "stopLocalServiceDiscovery" },
1873
- stopLocationUpdate: { target: "stopLocationUpdate" },
1874
- stopRecord: { target: "stopRecord" },
1875
- stopVoice: { target: "stopVoice" },
1876
- subscribeVoIPVideoMembers: { target: "subscribeVoIPVideoMembers" },
1877
- updateVoIPChatMuteConfig: { target: "updateVoIPChatMuteConfig" },
1878
- updateWeChatApp: { target: "updateWeChatApp" },
1879
- getBackgroundAudioPlayerState: { target: "getBackgroundAudioPlayerState" },
1880
- getDeviceBenchmarkInfo: { target: "getDeviceBenchmarkInfo" },
1881
- getDeviceVoIPList: { target: "getDeviceVoIPList" },
1882
- getHCEState: { target: "getHCEState" },
1883
- getInferenceEnvInfo: { target: "getInferenceEnvInfo" },
1884
- getNFCAdapter: { target: "getNFCAdapter" },
1885
- getPerformance: { target: "getPerformance" },
1886
- getRandomValues: { target: "getRandomValues" },
1887
- getRealtimeLogManager: { target: "getRealtimeLogManager" },
1888
- getRendererUserAgent: { target: "getRendererUserAgent" },
1889
- getScreenRecordingState: { target: "getScreenRecordingState" },
1890
- getSecureElementPasses: { target: "getSecureElementPasses" },
1891
- getSelectedTextRange: { target: "getSelectedTextRange" },
1892
- getShowSplashAdStatus: { target: "getShowSplashAdStatus" },
1893
- getSkylineInfo: { target: "getSkylineInfo" },
1894
- getUserCryptoManager: { target: "getUserCryptoManager" },
1895
- getWeRunData: { target: "getWeRunData" },
1896
- getXrFrameSystem: { target: "getXrFrameSystem" },
1897
- isBluetoothDevicePaired: { target: "isBluetoothDevicePaired" },
1898
- isVKSupport: { target: "isVKSupport" },
1899
- createBLEPeripheralServer: { target: "createBLEPeripheralServer" },
1900
- createBufferURL: { target: "createBufferURL" },
1901
- createCacheManager: { target: "createCacheManager" },
1902
- createGlobalPayment: { target: "createGlobalPayment" },
1903
- createInferenceSession: { target: "createInferenceSession" },
1904
- createMediaAudioPlayer: { target: "createMediaAudioPlayer" },
1905
- createMediaContainer: { target: "createMediaContainer" },
1906
- createMediaRecorder: { target: "createMediaRecorder" },
1907
- createTCPSocket: { target: "createTCPSocket" },
1908
- createUDPSocket: { target: "createUDPSocket" },
1909
- createVideoDecoder: { target: "createVideoDecoder" },
1910
- loadBuiltInFontFace: { target: "loadBuiltInFontFace" },
1911
- notifyGroupMembers: { target: "notifyGroupMembers" },
1912
- requestIdleCallback: { target: "requestIdleCallback" },
1913
- revokeBufferURL: { target: "revokeBufferURL" },
1914
- rewriteRoute: { target: "rewriteRoute" },
1915
- seekBackgroundAudio: { target: "seekBackgroundAudio" },
1916
- setEnableDebug: { target: "setEnableDebug" },
1917
- setInnerAudioOption: { target: "setInnerAudioOption" },
1918
- shareAppMessageToGroup: { target: "shareAppMessageToGroup" },
1919
- shareEmojiToGroup: { target: "shareEmojiToGroup" },
1920
- shareFileMessage: { target: "shareFileMessage" },
1921
- shareFileToGroup: { target: "shareFileToGroup" },
1922
- shareImageToGroup: { target: "shareImageToGroup" },
1923
- shareToOfficialAccount: { target: "shareToOfficialAccount" },
1924
- shareToWeRun: { target: "shareToWeRun" },
1925
- shareVideoMessage: { target: "shareVideoMessage" },
1926
- shareVideoToGroup: { target: "shareVideoToGroup" },
1927
- showRedPackage: { target: "showRedPackage" },
1928
- startDeviceMotionListening: { target: "startDeviceMotionListening" },
1929
- startHCE: { target: "startHCE" },
1930
- startLocalServiceDiscovery: { target: "startLocalServiceDiscovery" },
1931
- startLocationUpdate: { target: "startLocationUpdate" },
1932
- startLocationUpdateBackground: { target: "startLocationUpdateBackground" },
1933
- startRecord: { target: "startRecord" },
1934
- startSoterAuthentication: { target: "startSoterAuthentication" },
1935
- stopBackgroundAudio: { target: "stopBackgroundAudio" },
1936
- stopDeviceMotionListening: { target: "stopDeviceMotionListening" },
1937
- stopFaceDetect: { target: "stopFaceDetect" },
1938
- openCustomerServiceChat: { target: "openCustomerServiceChat" },
1939
- createVKSession: { target: "createVKSession" },
1940
- compressVideo: { target: "compressVideo" },
1941
- openVideoEditor: { target: "openVideoEditor" },
1942
- getShareInfo: { target: "getShareInfo" }
1943
- };
1944
- //#endregion
1945
- //#region src/core/methodMapping/rules/index.ts
1946
- const METHOD_MAPPINGS = {
1947
- my: MY_METHOD_MAPPINGS,
1948
- tt: {
1949
- showToast: {
1950
- target: "showToast",
1951
- mapArgs: mapDouyinToastArgs
1952
- },
1953
- showLoading: { target: "showLoading" },
1954
- showActionSheet: {
1955
- target: "showActionSheet",
1956
- mapResult: mapActionSheetResult
1957
- },
1958
- showModal: { target: "showModal" },
1959
- chooseImage: {
1960
- target: "chooseImage",
1961
- mapResult: mapDouyinChooseImageResult
1962
- },
1963
- chooseMedia: {
1964
- target: "chooseMedia",
1965
- mapResult: mapChooseMediaResultFromImage
1966
- },
1967
- chooseMessageFile: { target: "chooseMessageFile" },
1968
- getFuzzyLocation: { target: "getFuzzyLocation" },
1969
- previewMedia: { target: "previewMedia" },
1970
- createInterstitialAd: { target: "createInterstitialAd" },
1971
- createRewardedVideoAd: { target: "createRewardedVideoAd" },
1972
- createLivePlayerContext: { target: "createLivePlayerContext" },
1973
- createLivePusherContext: { target: "createLivePusherContext" },
1974
- getVideoInfo: { target: "getVideoInfo" },
1975
- saveFile: {
1976
- target: "saveFile",
1977
- mapResult: mapDouyinSaveFileResult
1978
- },
1979
- setClipboardData: { target: "setClipboardData" },
1980
- getClipboardData: { target: "getClipboardData" },
1981
- chooseAddress: { target: "chooseAddress" },
1982
- createAudioContext: { target: "createAudioContext" },
1983
- createWebAudioContext: { target: "createWebAudioContext" },
1984
- getSystemInfoAsync: { target: "getSystemInfo" },
1985
- openAppAuthorizeSetting: { target: "openAppAuthorizeSetting" },
1986
- pluginLogin: { target: "pluginLogin" },
1987
- login: { target: "login" },
1988
- authorize: { target: "authorize" },
1989
- checkSession: { target: "checkSession" },
1990
- requestSubscribeDeviceMessage: { target: "requestSubscribeDeviceMessage" },
1991
- requestSubscribeEmployeeMessage: { target: "requestSubscribeEmployeeMessage" },
1992
- restartMiniProgram: { target: "restartMiniProgram" },
1993
- scanCode: { target: "scanCode" },
1994
- requestPayment: { target: "requestPayment" },
1995
- requestOrderPayment: { target: "requestOrderPayment" },
1996
- requestPluginPayment: { target: "requestPluginPayment" },
1997
- requestVirtualPayment: { target: "requestVirtualPayment" },
1998
- showShareImageMenu: { target: "showShareImageMenu" },
1999
- updateShareMenu: { target: "updateShareMenu" },
2000
- openEmbeddedMiniProgram: { target: "openEmbeddedMiniProgram" },
2001
- saveFileToDisk: { target: "saveFileToDisk" },
2002
- getEnterOptionsSync: { target: "getEnterOptionsSync" },
2003
- getSystemSetting: { target: "getSystemSetting" },
2004
- getUserProfile: { target: "getUserProfile" },
2005
- getUserInfo: { target: "getUserInfo" },
2006
- getAppAuthorizeSetting: { target: "getAppAuthorizeSetting" },
2007
- getAppBaseInfo: { target: "getAppBaseInfo" },
2008
- chooseVideo: { target: "chooseVideo" },
2009
- hideHomeButton: { target: "hideHomeButton" },
2010
- getWindowInfo: { target: "getWindowInfo" },
2011
- getDeviceInfo: { target: "getDeviceInfo" },
2012
- getAccountInfoSync: { target: "getAccountInfoSync" },
2013
- setBackgroundColor: { target: "setBackgroundColor" },
2014
- setBackgroundTextStyle: { target: "setBackgroundTextStyle" },
2015
- getNetworkType: { target: "getNetworkType" },
2016
- getBatteryInfo: { target: "getBatteryInfo" },
2017
- getBatteryInfoSync: { target: "getBatteryInfoSync" },
2018
- getLogManager: { target: "getLogManager" },
2019
- nextTick: { target: "nextTick" },
2020
- onWindowResize: { target: "onWindowResize" },
2021
- offWindowResize: { target: "offWindowResize" },
2022
- reportAnalytics: { target: "reportAnalytics" },
2023
- addCard: { target: "addCard" },
2024
- addFileToFavorites: { target: "addFileToFavorites" },
2025
- addPaymentPassFinish: { target: "addPaymentPassFinish" },
2026
- addPaymentPassGetCertificateData: { target: "addPaymentPassGetCertificateData" },
2027
- addPhoneCalendar: { target: "addPhoneCalendar" },
2028
- addPhoneContact: { target: "addPhoneContact" },
2029
- addPhoneRepeatCalendar: { target: "addPhoneRepeatCalendar" },
2030
- addVideoToFavorites: { target: "addVideoToFavorites" },
2031
- authorizeForMiniProgram: { target: "authorizeForMiniProgram" },
2032
- authPrivateMessage: { target: "authPrivateMessage" },
2033
- bindEmployeeRelation: { target: "bindEmployeeRelation" },
2034
- canAddSecureElementPass: { target: "canAddSecureElementPass" },
2035
- ...TT_METHOD_MAPPINGS_CANVAS_GET_IMAGE_DATA_TO_SET_TOP_BAR_TEXT,
2036
- ...TT_METHOD_MAPPINGS_SET_WINDOW_SIZE_TO_GET_SHARE_INFO,
2037
- ...TT_METHOD_MAPPINGS_JOIN_VO_IPCHAT_TO_OFF_BLECONNECTION_STATE_CHANGE
2038
- }
2039
- };
2040
- const PLATFORM_METHOD_SET = {
2041
- my: new Set(WEAPI_MY_METHODS),
2042
- tt: new Set(WEAPI_TT_METHODS)
2043
- };
2044
- function createFallbackMappingRule(platform, methodName) {}
2045
- function resolveMappingRule(platform, methodName, options = {}) {
2046
- const methodSet = PLATFORM_METHOD_SET[platform];
2047
- const explicitRule = METHOD_MAPPINGS[platform]?.[methodName];
2048
- if (explicitRule) return {
2049
- target: explicitRule.target,
2050
- source: "explicit",
2051
- rule: explicitRule
2052
- };
2053
- if (methodSet.has(methodName)) return {
2054
- target: methodName,
2055
- source: "identity"
2056
- };
2057
- if (options.allowFallback === false) return {
2058
- target: methodName,
2059
- source: "identity"
2060
- };
2061
- const fallbackRule = createFallbackMappingRule(platform, methodName);
2062
- if (fallbackRule) return {
2063
- target: fallbackRule.target,
2064
- source: "fallback",
2065
- rule: fallbackRule
2066
- };
2067
- return {
2068
- target: methodName,
2069
- source: "identity"
2070
- };
2071
- }
2072
- /**
2073
- * @description 解析平台 API 映射规则及映射来源
2074
- */
2075
- function resolveMethodMappingWithMeta(platform, methodName, options = {}) {
2076
- const normalizedPlatform = normalizePlatformName$1(platform);
2077
- if (!normalizedPlatform) return;
2078
- if (normalizedPlatform !== "my" && normalizedPlatform !== "tt") return;
2079
- return resolveMappingRule(normalizedPlatform, methodName, options);
2080
- }
2081
- //#endregion
2082
- //#region src/core/networkRequestPolicy/types.ts
2083
- const NETWORK_METHODS = new Set([
2084
- "request",
2085
- "uploadFile",
2086
- "downloadFile",
2087
- "connectSocket"
2088
- ]);
2089
- const HTTP_METHODS = new Set([
2090
- "request",
2091
- "uploadFile",
2092
- "downloadFile"
2093
- ]);
2094
- const DEFAULT_TIMEOUT_CONFIG = {
2095
- request: 6e4,
2096
- uploadFile: 6e4,
2097
- downloadFile: 6e4,
2098
- connectSocket: 6e4
2099
- };
2100
- const NETWORK_BUCKET_LIMIT = {
2101
- http: 10,
2102
- socket: 5
2103
- };
2104
- const BACKGROUND_INTERRUPT_DELAY = 5e3;
2105
- //#endregion
2106
- //#region src/core/networkRequestPolicy/helpers.ts
2107
- function isFinitePositiveNumber(value) {
2108
- return typeof value === "number" && Number.isFinite(value) && value > 0;
2109
- }
2110
- function resolveQueueSize(value) {
2111
- if (!isFinitePositiveNumber(value)) return 100;
2112
- return Math.max(1, Math.floor(value));
2113
- }
2114
- function resolveHostTimeoutConfig() {
2115
- const networkTimeout = globalThis.__wxConfig?.networkTimeout;
2116
- if (!isPlainObject(networkTimeout)) return {};
2117
- const result = {};
2118
- if (isFinitePositiveNumber(networkTimeout.request)) result.request = networkTimeout.request;
2119
- if (isFinitePositiveNumber(networkTimeout.uploadFile)) result.uploadFile = networkTimeout.uploadFile;
2120
- if (isFinitePositiveNumber(networkTimeout.downloadFile)) result.downloadFile = networkTimeout.downloadFile;
2121
- if (isFinitePositiveNumber(networkTimeout.connectSocket)) result.connectSocket = networkTimeout.connectSocket;
2122
- return result;
2123
- }
2124
- function createNetworkError(methodName, platform, reason) {
2125
- return { errMsg: `${platform ? `${platform}.${methodName}` : methodName}:fail ${reason}` };
2126
- }
2127
- function resolveBucket(methodName) {
2128
- return HTTP_METHODS.has(methodName) ? "http" : "socket";
2129
- }
2130
- function clearTimer(timer) {
2131
- if (timer) clearTimeout(timer);
2132
- }
2133
- function resolveOptionsArg(args) {
2134
- const nextArgs = args.slice();
2135
- const lastArg = nextArgs.length > 0 ? nextArgs[nextArgs.length - 1] : void 0;
2136
- if (isPlainObject(lastArg)) {
2137
- const options = { ...lastArg };
2138
- nextArgs[nextArgs.length - 1] = options;
2139
- return {
2140
- args: nextArgs,
2141
- options
2142
- };
2143
- }
2144
- const options = {};
2145
- nextArgs.push(options);
2146
- return {
2147
- args: nextArgs,
2148
- options
2149
- };
2150
- }
2151
- function stripRefererHeader(options) {
2152
- if (!isPlainObject(options.header)) return;
2153
- const nextHeader = {};
2154
- for (const [key, value] of Object.entries(options.header)) {
2155
- if (key.toLowerCase() === "referer") continue;
2156
- nextHeader[key] = value;
2157
- }
2158
- options.header = nextHeader;
2159
- }
2160
- function resolveTimeoutValue(timeout, method, timeoutConfig) {
2161
- return isFinitePositiveNumber(timeout) ? timeout : timeoutConfig[method];
2162
- }
2163
- function toNetworkMethod(name) {
2164
- return NETWORK_METHODS.has(name) ? name : void 0;
2165
- }
2166
- //#endregion
2167
- //#region src/core/networkRequestPolicy/index.ts
2168
- /**
2169
- * @description 创建微信网络请求语义策略(超时、并发、前后台中断、referer 过滤)。
2170
- */
2171
- function createNetworkRequestPolicy(getPlatform, options = void 0) {
2172
- const boundAdapters = /* @__PURE__ */ new WeakSet();
2173
- const activeCalls = /* @__PURE__ */ new Set();
2174
- const queueByBucket = {
2175
- http: [],
2176
- socket: []
2177
- };
2178
- const activeCountByBucket = {
2179
- http: 0,
2180
- socket: 0
2181
- };
2182
- const timeoutConfig = {
2183
- ...DEFAULT_TIMEOUT_CONFIG,
2184
- ...resolveHostTimeoutConfig()
2185
- };
2186
- const overflowPolicy = options?.overflowPolicy ?? "queue";
2187
- const maxQueueSize = resolveQueueSize(options?.maxQueueSize);
2188
- let isBackground = false;
2189
- const cleanupCall = (call) => {
2190
- if (call.settled) return;
2191
- call.settled = true;
2192
- activeCalls.delete(call);
2193
- activeCountByBucket[call.bucket] = Math.max(0, activeCountByBucket[call.bucket] - 1);
2194
- clearTimer(call.timeoutTimer);
2195
- clearTimer(call.backgroundTimer);
2196
- };
2197
- const drainQueue = (bucket) => {
2198
- if (isBackground) return;
2199
- const limit = NETWORK_BUCKET_LIMIT[bucket];
2200
- const queue = queueByBucket[bucket];
2201
- while (activeCountByBucket[bucket] < limit && queue.length > 0) queue.shift()?.start();
2202
- };
2203
- const scheduleBackgroundInterrupt = (call) => {
2204
- clearTimer(call.backgroundTimer);
2205
- call.backgroundTimer = setTimeout(() => {
2206
- call.abort?.();
2207
- call.failWith(createNetworkError(call.method, call.platform, "interrupted"));
2208
- }, BACKGROUND_INTERRUPT_DELAY);
2209
- };
2210
- const clearBackgroundInterrupt = (call) => {
2211
- clearTimer(call.backgroundTimer);
2212
- call.backgroundTimer = void 0;
2213
- };
2214
- const setBackgroundState = (nextBackground) => {
2215
- isBackground = nextBackground;
2216
- for (const call of activeCalls) if (nextBackground) scheduleBackgroundInterrupt(call);
2217
- else clearBackgroundInterrupt(call);
2218
- if (!nextBackground) {
2219
- drainQueue("http");
2220
- drainQueue("socket");
2221
- }
2222
- };
2223
- const bindAdapter = (adapter) => {
2224
- if (!adapter || typeof adapter !== "object") return;
2225
- if (boundAdapters.has(adapter)) return;
2226
- boundAdapters.add(adapter);
2227
- const onAppHide = adapter.onAppHide;
2228
- if (typeof onAppHide === "function") onAppHide(() => {
2229
- setBackgroundState(true);
2230
- });
2231
- const onAppShow = adapter.onAppShow;
2232
- if (typeof onAppShow === "function") onAppShow(() => {
2233
- setBackgroundState(false);
2234
- });
2235
- };
2236
- const prepareCall = (methodName, args) => {
2237
- const networkMethod = toNetworkMethod(methodName);
2238
- if (!networkMethod) return;
2239
- const platform = getPlatform();
2240
- if (isBackground) return {
2241
- args,
2242
- blockedError: createNetworkError(methodName, platform, "interrupted"),
2243
- invoke() {}
2244
- };
2245
- const { args: nextArgs, options } = resolveOptionsArg(args);
2246
- if (networkMethod !== "connectSocket") stripRefererHeader(options);
2247
- const timeout = resolveTimeoutValue(options.timeout, networkMethod, timeoutConfig);
2248
- options.timeout = timeout;
2249
- const bucket = resolveBucket(networkMethod);
2250
- const limit = NETWORK_BUCKET_LIMIT[bucket];
2251
- const queue = queueByBucket[bucket];
2252
- if (activeCountByBucket[bucket] >= limit && overflowPolicy === "strict") return {
2253
- args: nextArgs,
2254
- blockedError: createNetworkError(methodName, platform, `exceed max concurrency limit ${limit}`),
2255
- invoke() {}
2256
- };
2257
- if (activeCountByBucket[bucket] >= limit && queue.length >= maxQueueSize) return {
2258
- args: nextArgs,
2259
- blockedError: createNetworkError(methodName, platform, `exceed max queue size ${maxQueueSize}`),
2260
- invoke() {}
2261
- };
2262
- const originalSuccess = options.success;
2263
- const originalFail = options.fail;
2264
- const originalComplete = options.complete;
2265
- const call = {
2266
- bucket,
2267
- method: networkMethod,
2268
- platform,
2269
- settled: false,
2270
- failWith: (error) => {
2271
- if (call.settled) return;
2272
- cleanupCall(call);
2273
- originalFail?.(error);
2274
- originalComplete?.(error);
2275
- drainQueue(bucket);
2276
- }
2277
- };
2278
- options.success = (res) => {
2279
- if (call.settled) return;
2280
- cleanupCall(call);
2281
- originalSuccess?.(res);
2282
- drainQueue(bucket);
2283
- };
2284
- options.fail = (error) => {
2285
- if (call.settled) return;
2286
- cleanupCall(call);
2287
- originalFail?.(error);
2288
- drainQueue(bucket);
2289
- };
2290
- options.complete = (res) => {
2291
- if (call.settled) return;
2292
- cleanupCall(call);
2293
- originalComplete?.(res);
2294
- drainQueue(bucket);
2295
- };
2296
- const startInvoke = (invokeRuntime) => {
2297
- if (call.settled) return;
2298
- activeCountByBucket[bucket] += 1;
2299
- activeCalls.add(call);
2300
- call.timeoutTimer = setTimeout(() => {
2301
- call.abort?.();
2302
- call.failWith(createNetworkError(methodName, platform, "timeout"));
2303
- }, timeout);
2304
- if (isBackground) scheduleBackgroundInterrupt(call);
2305
- try {
2306
- const result = invokeRuntime();
2307
- if (isPlainObject(result) && typeof result.abort === "function") call.abort = result.abort.bind(result);
2308
- return result;
2309
- } catch (error) {
2310
- call.failWith(error);
2311
- return;
2312
- }
2313
- };
2314
- return {
2315
- args: nextArgs,
2316
- invoke(invokeRuntime) {
2317
- if (activeCountByBucket[bucket] < limit) return startInvoke(invokeRuntime);
2318
- if (overflowPolicy !== "queue") return;
2319
- queue.push({ start: () => startInvoke(invokeRuntime) });
2320
- }
2321
- };
2322
- };
2323
- return {
2324
- bindAdapter,
2325
- prepareCall
2326
- };
2327
- }
2328
- //#endregion
2329
- //#region src/core/createWeapi.ts
2330
- const INTERNAL_KEYS = new Set([
2331
- "setAdapter",
2332
- "getAdapter",
2333
- "platform",
2334
- "raw",
2335
- "resolveTarget",
2336
- "supports"
2337
- ]);
2338
- const PLATFORM_ALIASES = {
2339
- alipay: "my",
2340
- douyin: "tt"
2341
- };
2342
- function normalizePlatformName(value) {
2343
- if (!value) return;
2344
- const normalized = value.trim().toLowerCase();
2345
- if (!normalized) return;
2346
- return PLATFORM_ALIASES[normalized] ?? normalized;
2347
- }
2348
- /**
2349
- * @description 创建跨平台 API 实例
2350
- */
2351
- function createWeapi(options = {}) {
2352
- let adapter = options.adapter;
2353
- let platformName = normalizePlatformName(options.platform);
2354
- const allowFallback = false;
2355
- const cache = /* @__PURE__ */ new Map();
2356
- const networkPolicy = createNetworkRequestPolicy(() => platformName, options.network);
2357
- const resolveAdapter = () => {
2358
- if (adapter) return adapter;
2359
- const detected = detectGlobalAdapter();
2360
- if (detected.adapter) {
2361
- adapter = detected.adapter;
2362
- platformName = platformName ?? normalizePlatformName(detected.platform);
2363
- }
2364
- return adapter;
2365
- };
2366
- const setAdapter = (nextAdapter, nextPlatform) => {
2367
- adapter = nextAdapter;
2368
- platformName = normalizePlatformName(nextPlatform);
2369
- cache.clear();
2370
- };
2371
- const getAdapter = () => {
2372
- if (!adapter) resolveAdapter();
2373
- return adapter;
2374
- };
2375
- const getPlatform = () => {
2376
- if (!platformName) resolveAdapter();
2377
- return platformName;
2378
- };
2379
- const resolveTarget = (methodName) => {
2380
- const runtimeAdapter = resolveAdapter();
2381
- const platform = getPlatform();
2382
- const mappingInfo = resolveMethodMappingWithMeta(platform, methodName, { allowFallback });
2383
- const target = mappingInfo?.target ?? methodName;
2384
- const supported = typeof (runtimeAdapter ? runtimeAdapter[target] : void 0) === "function";
2385
- const supportLevel = !supported ? "unsupported" : mappingInfo?.source === "fallback" ? "fallback" : mappingInfo?.source === "explicit" ? "mapped" : "native";
2386
- return {
2387
- method: methodName,
2388
- target,
2389
- platform,
2390
- mapped: target !== methodName,
2391
- supported,
2392
- supportLevel,
2393
- semanticAligned: supportLevel === "native" || supportLevel === "mapped"
2394
- };
2395
- };
2396
- const supports = (methodName, queryOptions = {}) => {
2397
- const resolved = resolveTarget(methodName);
2398
- if (queryOptions.semantic === true) return resolved.semanticAligned;
2399
- return resolved.supported;
2400
- };
2401
- return new Proxy({}, { get(_target, prop) {
2402
- if (prop === Symbol.toStringTag) return "Weapi";
2403
- if (prop === "then") return;
2404
- if (INTERNAL_KEYS.has(prop)) {
2405
- if (prop === "setAdapter") return setAdapter;
2406
- if (prop === "getAdapter") return getAdapter;
2407
- if (prop === "platform") return getPlatform();
2408
- if (prop === "raw") return getAdapter();
2409
- if (prop === "resolveTarget") return resolveTarget;
2410
- if (prop === "supports") return supports;
2411
- }
2412
- if (cache.has(prop)) return cache.get(prop);
2413
- const currentAdapter = resolveAdapter();
2414
- if (!currentAdapter) {
2415
- if (typeof prop !== "string") return;
2416
- return (...args) => callMissingApi(prop, getPlatform(), args);
2417
- }
2418
- const platform = getPlatform();
2419
- const value = currentAdapter[(typeof prop === "string" ? resolveMethodMappingWithMeta(platform, prop, { allowFallback }) : void 0)?.target ?? prop];
2420
- if (typeof value !== "function") {
2421
- if (value === void 0 && typeof prop === "string") {
2422
- const missing = (...args) => callMissingApi(prop, getPlatform(), args);
2423
- cache.set(prop, missing);
2424
- return missing;
2425
- }
2426
- cache.set(prop, value);
2427
- return value;
2428
- }
2429
- const wrapped = (...args) => {
2430
- const runtimeAdapter = resolveAdapter();
2431
- const mappingInfo = resolveMethodMappingWithMeta(getPlatform(), prop, { allowFallback });
2432
- const mappingRule = mappingInfo?.rule;
2433
- const methodName = mappingInfo?.target ?? prop;
2434
- const runtimeMethod = runtimeAdapter ? runtimeAdapter[methodName] : void 0;
2435
- let runtimeArgs = args;
2436
- try {
2437
- runtimeArgs = mappingRule?.mapArgs ? mappingRule.mapArgs(args) : args;
2438
- } catch (error) {
2439
- const lastArg = args.length > 0 ? args[args.length - 1] : void 0;
2440
- if (hasCallbacks(lastArg)) {
2441
- lastArg.fail?.(error);
2442
- lastArg.complete?.(error);
2443
- return;
2444
- }
2445
- return Promise.reject(error);
2446
- }
2447
- if (typeof runtimeMethod !== "function") return callMissingApi(prop, getPlatform(), args);
2448
- if (shouldSkipPromise(prop)) {
2449
- const result = runtimeMethod.apply(runtimeAdapter, runtimeArgs);
2450
- return mappingRule?.mapResult ? mappingRule.mapResult(result, runtimeArgs) : result;
2451
- }
2452
- const lastArg = runtimeArgs.length > 0 ? runtimeArgs[runtimeArgs.length - 1] : void 0;
2453
- if (hasCallbacks(lastArg)) {
2454
- if (mappingRule?.mapResult && isPlainObject(lastArg)) {
2455
- const options = lastArg;
2456
- const originalSuccess = options.success;
2457
- const originalComplete = options.complete;
2458
- options.success = (res) => {
2459
- originalSuccess?.(mappingRule.mapResult(res, runtimeArgs));
2460
- };
2461
- options.complete = (res) => {
2462
- originalComplete?.(mappingRule.mapResult(res, runtimeArgs));
2463
- };
2464
- }
2465
- networkPolicy.bindAdapter(runtimeAdapter);
2466
- const networkCall = networkPolicy.prepareCall(prop, runtimeArgs);
2467
- if (networkCall?.blockedError) return callWithError(networkCall.blockedError, runtimeArgs);
2468
- const nextRuntimeArgs = networkCall?.args ?? runtimeArgs;
2469
- const invokeRuntime = () => runtimeMethod.apply(runtimeAdapter, nextRuntimeArgs);
2470
- const result = networkCall ? networkCall.invoke(invokeRuntime) : invokeRuntime();
2471
- return mappingRule?.mapResult ? mappingRule.mapResult(result, nextRuntimeArgs) : result;
2472
- }
2473
- let networkCall;
2474
- return callWithPromise(runtimeAdapter, runtimeMethod, runtimeArgs, mappingRule?.mapResult, {
2475
- onOptions: (_options, nextArgs) => {
2476
- networkPolicy.bindAdapter(runtimeAdapter);
2477
- networkCall = networkPolicy.prepareCall(prop, nextArgs);
2478
- if (networkCall?.blockedError) throw networkCall.blockedError;
2479
- if (!networkCall) return;
2480
- nextArgs.splice(0, nextArgs.length, ...networkCall.args);
2481
- },
2482
- invoke: (invoke) => {
2483
- if (networkCall) {
2484
- networkCall.invoke(invoke);
2485
- return;
2486
- }
2487
- invoke();
2488
- }
2489
- });
2490
- };
2491
- cache.set(prop, wrapped);
2492
- return wrapped;
2493
- } });
2494
- }
2495
- //#endregion
2496
- //#region src/index.ts
2497
- /**
2498
- * @description 默认跨平台 API 实例(推荐使用)
2499
- *
2500
- * @generated weapi-platform-matrix:start
2501
- * | 平台 | 类型来源 | 支持度 |
2502
- * | --- | --- | --- |
2503
- * | 微信小程序 (`wx`) | `miniprogram-api-typings` | ✅ 全量 |
2504
- * | 支付宝小程序 (`my`) | `@mini-types/alipay` | ✅ 全量 |
2505
- * | 抖音小程序 (`tt`) | `@douyin-microapp/typings` | ✅ 全量 |
2506
- * | 其他平台对象 (`swan/jd/xhs/...`) | 运行时对象透传 | ⚠️ 按宿主能力支持 |
2507
- * @generated weapi-platform-matrix:end
2508
- */
2509
- const wpi = createWeapi();
2510
- //#endregion
2511
- exports.createWeapi = createWeapi;
2512
- exports.wpi = wpi;