@wevu/api 0.2.1 → 0.2.3

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.mjs CHANGED
@@ -71,6 +71,56 @@ function detectGlobalAdapter() {
71
71
  }
72
72
  return {};
73
73
  }
74
+ const WEAPI_NON_PROMISIFIED_METHOD_NAME_SET = new Set([
75
+ "arrayBufferToBase64",
76
+ "base64ToArrayBuffer",
77
+ "canIUse",
78
+ "cancelIdleCallback",
79
+ "createAnimation",
80
+ "createAudioContext",
81
+ "createCameraContext",
82
+ "createCanvasContext",
83
+ "createEditorContext",
84
+ "createInnerAudioContext",
85
+ "createIntersectionObserver",
86
+ "createInterstitialAd",
87
+ "createLivePlayerContext",
88
+ "createLivePusherContext",
89
+ "createMapContext",
90
+ "createMediaAudioPlayer",
91
+ "createMediaContainer",
92
+ "createMediaRecorder",
93
+ "createOffscreenCanvas",
94
+ "createRewardedVideoAd",
95
+ "createSelectorQuery",
96
+ "createTCPSocket",
97
+ "createUDPSocket",
98
+ "createVKSession",
99
+ "createVideoContext",
100
+ "createWebAudioContext",
101
+ "createWorker",
102
+ "getBackgroundAudioManager",
103
+ "getFileSystemManager",
104
+ "getLogManager",
105
+ "getMenuButtonBoundingClientRect",
106
+ "getNFCAdapter",
107
+ "getOpenDataContext",
108
+ "getPerformance",
109
+ "getRealtimeLogManager",
110
+ "getRecorderManager",
111
+ "getUpdateManager",
112
+ "getUserCryptoManager",
113
+ "getXrFrameSystem",
114
+ "nextTick",
115
+ "reportAnalytics",
116
+ "requestIdleCallback"
117
+ ]);
118
+ /**
119
+ * @description 判断方法是否应保留原始同步返回值,而不是包装为 Promise。
120
+ */
121
+ function isNonPromisifiedMethod(name) {
122
+ return WEAPI_NON_PROMISIFIED_METHOD_NAME_SET.has(name);
123
+ }
74
124
  //#endregion
75
125
  //#region src/core/utils.ts
76
126
  function isPlainObject(value) {
@@ -89,7 +139,7 @@ function isEventMethod(name) {
89
139
  return ON_EVENT_RE.test(name) || OFF_EVENT_RE.test(name);
90
140
  }
91
141
  function shouldSkipPromise(name) {
92
- return isSyncMethod(name) || isEventMethod(name) || name === "createInterstitialAd" || name === "createRewardedVideoAd" || name === "createVKSession" || name === "createCameraContext" || name === "cancelIdleCallback" || name === "nextTick" || name === "getLogManager" || name === "reportAnalytics";
142
+ return isSyncMethod(name) || isEventMethod(name) || isNonPromisifiedMethod(name);
93
143
  }
94
144
  function createNotSupportedError(methodName, platform) {
95
145
  return { errMsg: `${platform ? `${platform}.${methodName}` : methodName}:fail method not supported` };
@@ -1192,7 +1242,13 @@ const WEAPI_WX_METHODS_PRE_DOWNLOAD_SUBPACKAGE_TO_WRITE_BLECHARACTERISTIC_VALUE
1192
1242
  "vibrateShort",
1193
1243
  "writeBLECharacteristicValue"
1194
1244
  ];
1195
- [
1245
+ //#endregion
1246
+ //#region src/core/apiCatalog/wxMethods.ts
1247
+ /**
1248
+ * @description 三端 API 名单(由 typings 自动提取,请勿手工修改)
1249
+ * @generated by scripts/sync-api-catalog.mjs
1250
+ */
1251
+ const WEAPI_WX_METHODS = [
1196
1252
  ...WEAPI_WX_METHODS_ADD_CARD_TO_JOIN_VO_IPCHAT,
1197
1253
  ...WEAPI_WX_METHODS_LOAD_BUILT_IN_FONT_FACE_TO_POST_MESSAGE_TO_REFERRER_PAGE,
1198
1254
  ...WEAPI_WX_METHODS_PRE_DOWNLOAD_SUBPACKAGE_TO_WRITE_BLECHARACTERISTIC_VALUE
@@ -2040,6 +2096,7 @@ const METHOD_MAPPINGS = {
2040
2096
  ...TT_METHOD_MAPPINGS_JOIN_VO_IPCHAT_TO_OFF_BLECONNECTION_STATE_CHANGE
2041
2097
  }
2042
2098
  };
2099
+ new Set(WEAPI_WX_METHODS);
2043
2100
  const PLATFORM_METHOD_SET = {
2044
2101
  my: new Set(WEAPI_MY_METHODS),
2045
2102
  tt: new Set(WEAPI_TT_METHODS)
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@wevu/api",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "description": "tsdown bundler template",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/weapp-vite/weapp-vite.git",
11
- "directory": "packages/weapi"
11
+ "directory": "packages-runtime/weapi"
12
12
  },
13
13
  "bugs": {
14
14
  "url": "https://github.com/weapp-vite/weapp-vite/issues"
@@ -21,14 +21,10 @@
21
21
  "import": {
22
22
  "types": "./types/index.d.ts",
23
23
  "default": "./dist/index.mjs"
24
- },
25
- "require": {
26
- "types": "./types/index.d.ts",
27
- "default": "./dist/index.cjs"
28
24
  }
29
25
  }
30
26
  },
31
- "main": "./dist/index.cjs",
27
+ "main": "./dist/index.mjs",
32
28
  "module": "./dist/index.mjs",
33
29
  "types": "./types/index.d.ts",
34
30
  "files": [