@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10

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.
Files changed (239) hide show
  1. package/dist/apis/apis.ts +6 -2
  2. package/dist/apis/base/crypto.ts +4 -0
  3. package/dist/apis/base/debug.ts +5 -0
  4. package/dist/apis/base/index.ts +9 -1
  5. package/dist/apis/base/performance.ts +8 -0
  6. package/dist/apis/base/system.ts +74 -21
  7. package/dist/apis/base/update.ts +5 -0
  8. package/dist/apis/base/weapp/app-event.ts +75 -0
  9. package/dist/apis/base/weapp/life-cycle.ts +21 -0
  10. package/dist/apis/canvas/index.ts +27 -0
  11. package/dist/apis/data-analysis/index.ts +6 -0
  12. package/dist/apis/device/accelerometer.ts +2 -1
  13. package/dist/apis/device/accessibility.ts +4 -0
  14. package/dist/apis/device/battery.ts +2 -2
  15. package/dist/apis/device/bluetooth-ble.ts +19 -0
  16. package/dist/apis/device/bluetooth-peripheral.ts +6 -0
  17. package/dist/apis/device/bluetooth.ts +16 -0
  18. package/dist/apis/device/calendar.ts +5 -0
  19. package/dist/apis/device/clipboard.ts +17 -9
  20. package/dist/apis/device/compass.ts +21 -0
  21. package/dist/apis/device/contact.ts +5 -0
  22. package/dist/apis/device/crypto.ts +4 -0
  23. package/dist/apis/device/gyroscope.ts +7 -0
  24. package/dist/apis/device/iBeacon.ts +10 -0
  25. package/dist/apis/device/index.ts +15 -0
  26. package/dist/apis/device/keyboard.ts +2 -1
  27. package/dist/apis/device/memory.ts +10 -3
  28. package/dist/apis/device/motion.ts +6 -0
  29. package/dist/apis/device/network.ts +26 -9
  30. package/dist/apis/device/nfc.ts +10 -0
  31. package/dist/apis/device/phone.ts +2 -1
  32. package/dist/apis/device/scan.ts +4 -0
  33. package/dist/apis/device/screen.ts +2 -1
  34. package/dist/apis/device/sms.ts +4 -0
  35. package/dist/apis/device/vibrate.ts +19 -11
  36. package/dist/apis/device/wifi.ts +15 -0
  37. package/dist/apis/ext/index.ts +5 -0
  38. package/dist/apis/files/index.ts +2 -1
  39. package/dist/apis/files/manager.ts +2 -1
  40. package/dist/apis/framework/index.ts +3 -8
  41. package/dist/apis/index.ts +27 -17
  42. package/dist/apis/location/index.ts +61 -68
  43. package/dist/apis/media/EditorContext.ts +32 -0
  44. package/dist/apis/media/audio/index.ts +18 -0
  45. package/dist/apis/media/background-audio/index.ts +16 -0
  46. package/dist/apis/media/camera.ts +16 -0
  47. package/dist/apis/media/common.ts +2 -1
  48. package/dist/apis/media/{image.ts → image/index.ts} +4 -3
  49. package/dist/apis/media/index.ts +10 -0
  50. package/dist/apis/media/live.ts +5 -0
  51. package/dist/apis/media/map.ts +4 -0
  52. package/dist/apis/media/media-recorder.ts +4 -0
  53. package/dist/apis/media/recorder.ts +6 -0
  54. package/dist/apis/media/video/VideoContext.ts +68 -0
  55. package/dist/apis/media/{video.ts → video/index.ts} +13 -2
  56. package/dist/apis/media/video-decoder.ts +4 -0
  57. package/dist/apis/media/video-processing.ts +4 -0
  58. package/dist/apis/media/voip.ts +19 -0
  59. package/dist/apis/network/index.ts +3 -0
  60. package/dist/apis/network/mdns.ts +13 -0
  61. package/dist/apis/network/request.ts +7 -6
  62. package/dist/apis/network/tcp.ts +4 -0
  63. package/dist/apis/network/udp.ts +4 -0
  64. package/dist/apis/network/webSocket.ts +2 -6
  65. package/dist/apis/open-api/account.ts +4 -0
  66. package/dist/apis/open-api/address.ts +4 -0
  67. package/dist/apis/open-api/authorize.ts +5 -0
  68. package/dist/apis/open-api/card.ts +5 -0
  69. package/dist/apis/open-api/channels-live.ts +11 -0
  70. package/dist/apis/open-api/customer-service.ts +4 -0
  71. package/dist/apis/open-api/device-voip.ts +5 -0
  72. package/dist/apis/open-api/facial.ts +7 -0
  73. package/dist/apis/open-api/favorites.ts +5 -0
  74. package/dist/apis/open-api/group.ts +4 -0
  75. package/dist/apis/open-api/index.ts +20 -6
  76. package/dist/apis/open-api/invoice.ts +5 -0
  77. package/dist/apis/open-api/license-plate.ts +4 -0
  78. package/dist/apis/open-api/login.ts +6 -0
  79. package/dist/apis/open-api/my-miniprogram.ts +4 -0
  80. package/dist/apis/open-api/privacy.ts +7 -0
  81. package/dist/apis/open-api/red-package.ts +4 -0
  82. package/dist/apis/open-api/settings.ts +5 -0
  83. package/dist/apis/open-api/soter.ts +6 -0
  84. package/dist/apis/open-api/subscribe-message.ts +6 -0
  85. package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
  86. package/dist/apis/open-api/werun.ts +5 -0
  87. package/dist/apis/payment/index.ts +6 -0
  88. package/dist/apis/route/index.ts +19 -28
  89. package/dist/apis/share/index.ts +33 -0
  90. package/dist/apis/storage/background-fetch.ts +7 -0
  91. package/dist/apis/storage/cache-manager.ts +4 -0
  92. package/dist/apis/storage/index.ts +158 -88
  93. package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
  94. package/dist/apis/ui/animation/index.ts +7 -0
  95. package/dist/apis/ui/background.ts +4 -19
  96. package/dist/apis/ui/custom-component.ts +8 -0
  97. package/dist/apis/ui/fonts.ts +4 -0
  98. package/dist/apis/ui/index.ts +8 -10
  99. package/dist/apis/ui/interaction/index.ts +45 -59
  100. package/dist/apis/ui/menu.ts +4 -0
  101. package/dist/apis/ui/navigation-bar/index.ts +60 -21
  102. package/dist/apis/ui/pull-down-refresh.ts +10 -4
  103. package/dist/apis/{page → ui/scroll}/index.ts +32 -27
  104. package/dist/apis/ui/sticky.ts +4 -0
  105. package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
  106. package/dist/apis/ui/window.ts +20 -0
  107. package/dist/apis/utils/handler.ts +4 -4
  108. package/dist/apis/utils/index.ts +1 -1
  109. package/dist/apis/worker/index.ts +4 -0
  110. package/dist/apis/wxml/IntersectionObserver.ts +24 -25
  111. package/dist/apis/wxml/index.ts +7 -2
  112. package/dist/apis/wxml/nodesRef.ts +2 -2
  113. package/dist/apis/wxml/selectorQuery.ts +29 -17
  114. package/dist/components-harmony-ets/button.ets +106 -80
  115. package/dist/components-harmony-ets/canvas.ets +51 -0
  116. package/dist/components-harmony-ets/checkbox.ets +82 -148
  117. package/dist/components-harmony-ets/form.ets +45 -132
  118. package/dist/components-harmony-ets/icon.ets +66 -69
  119. package/dist/components-harmony-ets/image.ets +26 -61
  120. package/dist/components-harmony-ets/index.ets +92 -0
  121. package/dist/components-harmony-ets/innerHtml.ets +7 -70
  122. package/dist/components-harmony-ets/input.ets +60 -146
  123. package/dist/components-harmony-ets/label.ets +86 -92
  124. package/dist/components-harmony-ets/listView.ets +26 -0
  125. package/dist/components-harmony-ets/movableArea.ets +124 -0
  126. package/dist/components-harmony-ets/movableView.ets +93 -0
  127. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  128. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  129. package/dist/components-harmony-ets/picker.ets +172 -198
  130. package/dist/components-harmony-ets/progress.ets +52 -0
  131. package/dist/components-harmony-ets/pseudo.ets +80 -0
  132. package/dist/components-harmony-ets/radio.ets +85 -155
  133. package/dist/components-harmony-ets/richText.ets +15 -87
  134. package/dist/components-harmony-ets/scrollList.ets +94 -0
  135. package/dist/components-harmony-ets/scrollView.ets +81 -149
  136. package/dist/components-harmony-ets/slider.ets +47 -94
  137. package/dist/components-harmony-ets/stickySection.ets +42 -0
  138. package/dist/components-harmony-ets/style.ets +396 -0
  139. package/dist/components-harmony-ets/swiper.ets +51 -151
  140. package/dist/components-harmony-ets/switch.ets +35 -76
  141. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  142. package/dist/components-harmony-ets/text.ets +131 -76
  143. package/dist/components-harmony-ets/textArea.ets +64 -140
  144. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  145. package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
  146. package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
  147. package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
  148. package/dist/components-harmony-ets/utils/helper.ets +18 -65
  149. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  150. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  151. package/dist/components-harmony-ets/utils/index.ts +55 -51
  152. package/dist/components-harmony-ets/utils/styles.ets +177 -65
  153. package/dist/components-harmony-ets/video.ets +70 -116
  154. package/dist/components-harmony-ets/view.ets +58 -64
  155. package/dist/components-harmony-ets/webView.ets +56 -0
  156. package/dist/index.d.ts +152 -0
  157. package/dist/index.js +230 -60
  158. package/dist/index.js.map +1 -1
  159. package/dist/runtime-ets/bom/document.ts +6 -4
  160. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  161. package/dist/runtime-ets/bom/window.ts +9 -2
  162. package/dist/runtime-ets/current.ts +3 -0
  163. package/dist/runtime-ets/dom/bind.ts +96 -0
  164. package/dist/runtime-ets/dom/class-list.ts +4 -6
  165. package/dist/runtime-ets/dom/comment.ts +1 -2
  166. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  167. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
  168. package/dist/runtime-ets/dom/dataSource.ts +64 -0
  169. package/dist/runtime-ets/dom/document.ts +36 -51
  170. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  171. package/dist/runtime-ets/dom/element/element.ts +439 -0
  172. package/dist/runtime-ets/dom/element/form.ts +403 -0
  173. package/dist/runtime-ets/dom/element/index.ts +120 -0
  174. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  175. package/dist/runtime-ets/dom/element/movableView.ts +242 -0
  176. package/dist/runtime-ets/dom/element/normal.ts +103 -0
  177. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  178. package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
  179. package/dist/runtime-ets/dom/element/text.ts +10 -0
  180. package/dist/runtime-ets/dom/element/video.ts +50 -0
  181. package/dist/runtime-ets/dom/element/webView.ts +68 -0
  182. package/dist/runtime-ets/dom/event.ts +26 -5
  183. package/dist/runtime-ets/dom/eventTarget.ts +3 -3
  184. package/dist/runtime-ets/dom/node.ts +114 -49
  185. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
  186. package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
  187. package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
  188. package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
  189. package/dist/runtime-ets/index.ts +2 -3
  190. package/dist/runtime-ets/interface/event.ts +3 -2
  191. package/dist/runtime-ets/utils/index.ts +87 -17
  192. package/dist/runtime-ets/utils/info.ts +21 -47
  193. package/dist/runtime-framework/react/app.ts +20 -28
  194. package/dist/runtime-framework/react/hooks.ts +3 -4
  195. package/dist/runtime-framework/react/index.ts +1 -2
  196. package/dist/runtime-framework/react/native-page.ts +421 -0
  197. package/dist/runtime-framework/react/page.ts +5 -17
  198. package/dist/runtime-framework/solid/app.ts +25 -45
  199. package/dist/runtime-framework/solid/connect.ts +21 -3
  200. package/dist/runtime-framework/solid/hooks.ts +17 -12
  201. package/dist/runtime-framework/solid/index.ts +6 -2
  202. package/dist/runtime-framework/solid/page.ts +84 -36
  203. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  204. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  205. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  206. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  207. package/dist/runtime-utils.d.ts +827 -0
  208. package/dist/runtime-utils.js +1633 -549
  209. package/dist/runtime-utils.js.map +1 -1
  210. package/dist/runtime.d.ts +1 -0
  211. package/dist/runtime.js +1633 -549
  212. package/dist/runtime.js.map +1 -1
  213. package/index.js +3 -1
  214. package/package.json +14 -15
  215. package/static/media/cancel.svg +1 -0
  216. package/static/media/circle.svg +1 -0
  217. package/static/media/clear.svg +1 -0
  218. package/static/media/download.svg +1 -0
  219. package/static/media/info.svg +1 -0
  220. package/static/media/info_circle.svg +1 -0
  221. package/static/media/search.svg +1 -0
  222. package/static/media/success.svg +1 -0
  223. package/static/media/success_no_circle.svg +1 -0
  224. package/static/media/taro_arrow_left.svg +1 -0
  225. package/static/media/taro_home.svg +1 -0
  226. package/static/media/waiting.svg +1 -0
  227. package/static/media/warn.svg +1 -0
  228. package/types/harmony.d.ts +4 -0
  229. package/types/index.d.ts +4 -0
  230. package/types/runtime.d.ts +7 -1
  231. package/LICENSE +0 -160
  232. package/dist/components-harmony-ets/base.ets +0 -63
  233. package/dist/components-harmony-ets/element.ets +0 -223
  234. package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
  235. package/dist/runtime-ets/dom/element.ts +0 -457
  236. package/dist/runtime-ets/dom/text.ts +0 -19
  237. package/dist/runtime-ets/utils/bind.ts +0 -35
  238. package/types/api.d.ts +0 -4
  239. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,13 +1,15 @@
1
1
  import { isFunction, isString, isArray, isObject, isNull, isNumber, isUndefined, queryToJson, PLATFORM_TYPE, singleQuote, internalComponents } from '@tarojs/shared';
2
2
  import _display from '@ohos.display';
3
- import { Current, window, getPageScrollerOrNode, findChildNodeWithDFS, setNodeEventCallbackAndTriggerComponentUpdate, AREA_CHANGE_EVENT_NAME, disconnectEvent, VISIBLE_CHANGE_EVENT_NAME, hooks } from '@tarojs/runtime';
3
+ import { Current, window, eventSource, hooks, document as document$1, getPageScrollerOrNode, findChildNodeWithDFS, setNodeEventCallbackAndTriggerComponentUpdate, AREA_CHANGE_EVENT_NAME, disconnectEvent, VISIBLE_CHANGE_EVENT_NAME, getCurrentInstance } from '@tarojs/runtime';
4
4
  import { eventCenter, Events, History } from '@tarojs/runtime/dist/runtime.esm';
5
+ import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
5
6
  import deviceInfo from '@ohos.deviceInfo';
6
7
  import i18n from '@ohos.i18n';
7
- import deviceMethod from '@system.device';
8
+ import errorManager from '@ohos.app.ability.errorManager';
8
9
  import sensor from '@ohos.sensor';
9
10
  import batteryInfo, { BatteryChargeState } from '@ohos.batteryInfo';
10
11
  import pasteboard from '@ohos.pasteboard';
12
+ import promptAction from '@ohos.promptAction';
11
13
  import inputMethodEngine from '@ohos.inputMethodEngine';
12
14
  import network from '@system.network';
13
15
  import call from '@ohos.telephony.call';
@@ -25,13 +27,11 @@ import image from '@ohos.multimedia.image';
25
27
  import request$1 from '@ohos.request';
26
28
  import http from '@ohos.net.http';
27
29
  import webSocket from '@ohos.net.webSocket';
28
- import { pxTransformHelper } from '@tarojs/taro';
29
30
  import router from '@ohos.router';
30
31
  import bundleManager from '@ohos.bundle.bundleManager';
31
- import dataPreferences from '@ohos.data.preferences';
32
- import hilog from '@ohos.hilog';
32
+ import distributedKVStore from '@ohos.data.distributedKVStore';
33
33
  import matrix4 from '@ohos.matrix4';
34
- import prompt from '@ohos.prompt';
34
+ import { pxTransformHelper as pxTransformHelper$1 } from '@tarojs/taro';
35
35
 
36
36
  class MethodHandler {
37
37
  constructor({ name, success, fail, complete }) {
@@ -185,7 +185,7 @@ function temporarilyNotSupport(name, recommended) {
185
185
  return (option = {}, ...args) => {
186
186
  const { success, fail, complete } = option;
187
187
  const handle = new MethodHandler({ name, success, fail, complete });
188
- let errMsg = '暂时不支持 API';
188
+ let errMsg = `暂时不支持 API ${name}`;
189
189
  if (recommended) {
190
190
  errMsg += `, 请使用 ${recommended}`;
191
191
  }
@@ -251,16 +251,77 @@ function callAsyncFail(reject, res, options) {
251
251
  reject(res);
252
252
  }
253
253
 
254
- // 设备信息,从 API Version 6 开始支持
255
- const display = _display.getDefaultDisplaySync();
256
- let device;
257
- deviceMethod.getInfo({
258
- success: data => {
259
- device = data;
260
- }
254
+ // 加密
255
+ const getUserCryptoManager = /* @__PURE__ */ temporarilyNotSupport('getUserCryptoManager');
256
+
257
+ const setEnableDebug = /* @__PURE__ */ temporarilyNotSupport('setEnableDebug');
258
+ const getRealtimeLogManager = /* @__PURE__ */ temporarilyNotSupport('getRealtimeLogManager');
259
+ const getLogManager = /* @__PURE__ */ temporarilyNotSupport('getLogManager');
260
+
261
+ // 性能
262
+ const reportPerformance = /* @__PURE__ */ temporarilyNotSupport('reportPerformance');
263
+ const getPerformance = /* @__PURE__ */ temporarilyNotSupport('getPerformance');
264
+ const preloadWebview = /* @__PURE__ */ temporarilyNotSupport('preloadWebview');
265
+ const preloadSkylineView = /* @__PURE__ */ temporarilyNotSupport('preloadSkylineView');
266
+ const preloadAssets = /* @__PURE__ */ temporarilyNotSupport('preloadAssets');
267
+
268
+ let display$1;
269
+ let navigationIndicatorRect;
270
+ let safeArea = null;
271
+ let statusBarHeight;
272
+ let windowRect;
273
+ Current.contextPromise.then((context) => {
274
+ const win = window.__ohos.getLastWindow(context);
275
+ win.then(mainWindow => {
276
+ const topRect = mainWindow.getWindowAvoidArea(window.__ohos.AvoidAreaType.TYPE_SYSTEM).topRect;
277
+ navigationIndicatorRect = mainWindow.getWindowAvoidArea(window.__ohos.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect;
278
+ statusBarHeight = topRect.top + topRect.height;
279
+ windowRect = mainWindow.getWindowProperties().windowRect;
280
+ try {
281
+ display$1 = _display.getDefaultDisplaySync();
282
+ setSafeArea({
283
+ top: statusBarHeight,
284
+ left: 0,
285
+ right: display$1.width,
286
+ bottom: navigationIndicatorRect === null || navigationIndicatorRect === void 0 ? void 0 : navigationIndicatorRect.top
287
+ });
288
+ // @ts-ignore
289
+ display$1.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} } = {}) => {
290
+ var _a, _b, _c, _d, _e, _f;
291
+ if (err === null || err === void 0 ? void 0 : err.code) {
292
+ console.error('Failed to get cutout info', JSON.stringify(err));
293
+ return;
294
+ }
295
+ const top = Math.max(...boundingRects.map(rect => rect.top + rect.height), ((_a = waterfallDisplayAreaRects.top) === null || _a === void 0 ? void 0 : _a.top) + ((_b = waterfallDisplayAreaRects.top) === null || _b === void 0 ? void 0 : _b.height), statusBarHeight);
296
+ const bottom = Math.min(display$1.height - ((_c = waterfallDisplayAreaRects.bottom) === null || _c === void 0 ? void 0 : _c.top), navigationIndicatorRect === null || navigationIndicatorRect === void 0 ? void 0 : navigationIndicatorRect.top);
297
+ const left = ((_d = waterfallDisplayAreaRects.left) === null || _d === void 0 ? void 0 : _d.left) + ((_e = waterfallDisplayAreaRects.left) === null || _e === void 0 ? void 0 : _e.width);
298
+ const right = display$1.width - ((_f = waterfallDisplayAreaRects.right) === null || _f === void 0 ? void 0 : _f.left);
299
+ setSafeArea({
300
+ top,
301
+ left,
302
+ right,
303
+ bottom
304
+ });
305
+ });
306
+ }
307
+ catch (e) {
308
+ console.error('Failed to get display', e);
309
+ }
310
+ });
261
311
  });
312
+ function setSafeArea({ top, left, right, bottom }) {
313
+ safeArea = {
314
+ top,
315
+ bottom,
316
+ left,
317
+ right,
318
+ height: bottom - top,
319
+ width: right - left,
320
+ };
321
+ }
262
322
  /* 同步版本 */
263
323
  const getSystemInfoSync = function () {
324
+ var _a, _b;
264
325
  const res = {};
265
326
  res.SDKVersion = deviceInfo && deviceInfo.sdkApiVersion; // 客户端基础库版本 string
266
327
  res.albumAuthorized = false; // 允许使用相册的开关(仅 iOS 有效) boolean
@@ -270,7 +331,7 @@ const getSystemInfoSync = function () {
270
331
  res.cameraAuthorized = null; // 允许使用摄像头的开关 boolean
271
332
  res.enableDebug = null; // 是否已打开调试 boolean
272
333
  res.fontSizeSetting = null; // 用户字体大小(单位px) number
273
- res.language = i18n && i18n.getSystemLanguage && i18n.getSystemLanguage(); // string
334
+ res.language = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.getSystemLanguage) === null || _a === void 0 ? void 0 : _a.call(i18n); // string
274
335
  res.locationAuthorized = null; // 定位的开关 boolean
275
336
  res.locationEnabled = null; // 地理位置的系统开关 boolean
276
337
  res.microphoneAuthorized = null; // 麦克风的开关 boolean
@@ -281,17 +342,18 @@ const getSystemInfoSync = function () {
281
342
  res.notificationSoundAuthorized = false; // 通知带有声音的开关(仅 iOS 有效)boolean
282
343
  res.phoneCalendarAuthorized = null; // 使用日历的开关 boolean
283
344
  res.wifiEnabled = false; // Wi-Fi 的系统开关 boolean
284
- res.pixelRatio = null; // 设备像素比,number
285
- res.platform = 'android'; // 客户端平台 string
286
- res.safeArea = null; // 在竖屏正方向下的安全区域 General.SafeAreaResult
287
- res.screenHeight = display && display.height; // 屏幕高度,单位px number
288
- res.screenWidth = display && display.width; // 屏幕宽度,单位px number
289
- res.statusBarHeight = null; // 状态栏的高度,单位px number
290
- res.system = deviceInfo && deviceInfo.osFullName; // 操作系统及版本 string
291
- res.theme = null; // 系统当前主题,取值为light或dark 'light' | 'dark'
292
- res.windowWidth = device && device.windowWidth; // 可使用窗口宽度,单位px number
293
- res.windowHeight = device && device.windowHeight; // 可使用窗口高度,单位px number
294
- res.version = deviceInfo && deviceInfo.displayVersion; // 版本号 string
345
+ res.pixelRatio = display$1 && display$1.densityPixels; // 设备像素比,number
346
+ res.platform = 'harmony'; // 客户端平台 string
347
+ res.safeArea = safeArea; // 在竖屏正方向下的安全区域 General.SafeAreaResult
348
+ res.screenHeight = display$1 === null || display$1 === void 0 ? void 0 : display$1.height; // 屏幕高度,单位px number
349
+ res.screenWidth = display$1 === null || display$1 === void 0 ? void 0 : display$1.width; // 屏幕宽度,单位px number
350
+ res.statusBarHeight = statusBarHeight; // 状态栏的高度,单位px number
351
+ res.system = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.osFullName; // 操作系统及版本 string
352
+ // Note: 更新配置时才能记录
353
+ res.theme = ((_b = AppStorage.get('__TARO_APP_CONFIG')) === null || _b === void 0 ? void 0 : _b.colorMode) === ConfigurationConstant.ColorMode.COLOR_MODE_DARK ? 'dark' : 'light'; // 系统当前主题,取值为light或dark 'light' | 'dark'
354
+ res.windowHeight = windowRect === null || windowRect === void 0 ? void 0 : windowRect.height; // 可使用窗口高度,单位px number
355
+ res.windowWidth = windowRect === null || windowRect === void 0 ? void 0 : windowRect.width; // 可使用窗口宽度,单位px number
356
+ res.version = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.displayVersion; // 版本号 string
295
357
  return res;
296
358
  };
297
359
  /* 异步版本 */
@@ -313,7 +375,108 @@ const getSystemInfo = function (options) {
313
375
  };
314
376
  globalThis.getSystemInfoSync = getSystemInfoSync;
315
377
 
316
- const getUpdateManager = temporarilyNotSupport('getUpdateManager');
378
+ // 更新
379
+ const updateWeChatApp = /* @__PURE__ */ temporarilyNotSupport('updateWeChatApp');
380
+ const getUpdateManager = /* @__PURE__ */ temporarilyNotSupport('getUpdateManager');
381
+
382
+ const unhandledRejectionCallbackManager = new CallbackManager();
383
+ const errorCallbackManager = new CallbackManager();
384
+ const unhandledRejectionListener = (res) => {
385
+ unhandledRejectionCallbackManager.trigger(res);
386
+ };
387
+ const errorListener = (res) => {
388
+ // @ts-ignore
389
+ errorCallbackManager.trigger(res.stack || res.message || res);
390
+ };
391
+ // 应用级事件
392
+ const onUnhandledRejection = callback => {
393
+ unhandledRejectionCallbackManager.add(callback);
394
+ if (unhandledRejectionCallbackManager.count() === 1) {
395
+ errorManager.on('error', {
396
+ unhandledRejectionListener
397
+ });
398
+ }
399
+ };
400
+ const onThemeChange = /* @__PURE__ */ temporarilyNotSupport('onThemeChange');
401
+ const onPageNotFound = /* @__PURE__ */ temporarilyNotSupport('onPageNotFound');
402
+ const onLazyLoadError = /* @__PURE__ */ temporarilyNotSupport('onLazyLoadError');
403
+ const onError = callback => {
404
+ errorCallbackManager.add(callback);
405
+ if (errorCallbackManager.count() === 1) {
406
+ errorManager.on('error', {
407
+ onException: errorListener
408
+ });
409
+ }
410
+ };
411
+ const onAudioInterruptionEnd = /* @__PURE__ */ temporarilyNotSupport('onAudioInterruptionEnd');
412
+ const onAudioInterruptionBegin = /* @__PURE__ */ temporarilyNotSupport('onAudioInterruptionBegin');
413
+ const onAppShow = /* @__PURE__ */ temporarilyNotSupport('onAppShow');
414
+ const onAppHide = /* @__PURE__ */ temporarilyNotSupport('onAppHide');
415
+ const offUnhandledRejection = callback => {
416
+ unhandledRejectionCallbackManager.remove(callback);
417
+ if (unhandledRejectionCallbackManager.count() === 0) {
418
+ errorManager.off('error', {
419
+ unhandledRejectionListener
420
+ });
421
+ }
422
+ };
423
+ const offThemeChange = /* @__PURE__ */ temporarilyNotSupport('offThemeChange');
424
+ const offPageNotFound = /* @__PURE__ */ temporarilyNotSupport('offPageNotFound');
425
+ const offLazyLoadError = /* @__PURE__ */ temporarilyNotSupport('offLazyLoadError');
426
+ const offError = callback => {
427
+ errorCallbackManager.remove(callback);
428
+ if (errorCallbackManager.count() === 0) {
429
+ errorManager.off('error', {
430
+ onException: errorListener
431
+ });
432
+ }
433
+ };
434
+ const offAudioInterruptionEnd = /* @__PURE__ */ temporarilyNotSupport('offAudioInterruptionEnd');
435
+ const offAudioInterruptionBegin = /* @__PURE__ */ temporarilyNotSupport('offAudioInterruptionBegin');
436
+ const offAppShow = /* @__PURE__ */ temporarilyNotSupport('offAppShow');
437
+ const offAppHide = /* @__PURE__ */ temporarilyNotSupport('offAppHide');
438
+
439
+ const launchOptions = {
440
+ path: '',
441
+ query: {},
442
+ scene: 0,
443
+ shareTicket: '',
444
+ referrerInfo: {}
445
+ };
446
+ function initLaunchOptions(options = {}) {
447
+ Object.assign(launchOptions, options);
448
+ }
449
+ eventCenter.once('__taroRouterLaunch', initLaunchOptions);
450
+ // 生命周期
451
+ const getLaunchOptionsSync = () => launchOptions;
452
+ const getEnterOptionsSync = () => launchOptions;
453
+
454
+ const canIUse = /* @__PURE__ */ temporarilyNotSupport('canIUse');
455
+ const arrayBufferToBase64 = /* @__PURE__ */ temporarilyNotSupport('arrayBufferToBase64');
456
+ const base64ToArrayBuffer = /* @__PURE__ */ temporarilyNotSupport('base64ToArrayBuffer');
457
+
458
+ // 画布
459
+ /** 创建离屏 canvas 实例 */
460
+ const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
461
+ /** 创建 canvas 的绘图上下文 CanvasContext 对象 */
462
+ // export const createCanvasContext = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
463
+ const createCanvasContext = (canvasId) => {
464
+ const dom = eventSource.get(`canvasId-${canvasId}`);
465
+ // return dom as TaroCanvasElement
466
+ if (dom)
467
+ return dom.context;
468
+ };
469
+ /** 把当前画布指定区域的内容导出生成指定大小的图片 */
470
+ const canvasToTempFilePath = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
471
+ /** 将像素数据绘制到画布 */
472
+ const canvasPutImageData = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
473
+ /** 获取 canvas 区域隐含的像素数据 */
474
+ const canvasGetImageData = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
475
+
476
+ const reportMonitor = /* @__PURE__ */ temporarilyNotSupport('reportMonitor');
477
+ const reportAnalytics = /* @__PURE__ */ temporarilyNotSupport('reportAnalytics');
478
+ const reportEvent = /* @__PURE__ */ temporarilyNotSupport('reportEvent');
479
+ const getExptInfoSync = /* @__PURE__ */ temporarilyNotSupport('getExptInfoSync');
317
480
 
318
481
  const callbackManager$1 = new CallbackManager();
319
482
  let devicemotionListener;
@@ -382,6 +545,9 @@ const offAccelerometerChange = callback => {
382
545
  callbackManager$1.remove(callback);
383
546
  };
384
547
 
548
+ // 无障碍
549
+ const checkIsOpenAccessibility = /* @__PURE__ */ temporarilyNotSupport('checkIsOpenAccessibility');
550
+
385
551
  /******************************************************************************
386
552
  Copyright (c) Microsoft Corporation.
387
553
 
@@ -396,7 +562,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
396
562
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
397
563
  PERFORMANCE OF THIS SOFTWARE.
398
564
  ***************************************************************************** */
399
- /* global Reflect, Promise */
565
+ /* global Reflect, Promise, SuppressedError, Symbol */
400
566
 
401
567
 
402
568
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -407,7 +573,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
407
573
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
408
574
  step((generator = generator.apply(thisArg, _arguments || [])).next());
409
575
  });
410
- }
576
+ }
577
+
578
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
579
+ var e = new Error(message);
580
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
581
+ };
411
582
 
412
583
  // 电量
413
584
  const getBatteryInfoSync = () => ({
@@ -415,7 +586,7 @@ const getBatteryInfoSync = () => ({
415
586
  isCharging: [BatteryChargeState.ENABLE, BatteryChargeState.FULL].includes(batteryInfo.chargingStatus),
416
587
  level: batteryInfo.batterySOC
417
588
  });
418
- const getBatteryInfo = ({ success, fail, complete } = {}) => __awaiter(void 0, void 0, void 0, function* () {
589
+ const getBatteryInfo = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ success, fail, complete } = {}) {
419
590
  const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete });
420
591
  try {
421
592
  return handle.success(getBatteryInfoSync());
@@ -427,6 +598,48 @@ const getBatteryInfo = ({ success, fail, complete } = {}) => __awaiter(void 0, v
427
598
  }
428
599
  });
429
600
 
601
+ // 蓝牙-通用
602
+ const stopBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBluetoothDevicesDiscovery');
603
+ const startBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBluetoothDevicesDiscovery');
604
+ const openBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('openBluetoothAdapter');
605
+ const onBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('onBluetoothDeviceFound');
606
+ const onBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('onBluetoothAdapterStateChange');
607
+ const offBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('offBluetoothDeviceFound');
608
+ const offBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('offBluetoothAdapterStateChange');
609
+ const makeBluetoothPair = /* @__PURE__ */ temporarilyNotSupport('makeBluetoothPair');
610
+ const isBluetoothDevicePaired = /* @__PURE__ */ temporarilyNotSupport('isBluetoothDevicePaired');
611
+ const getConnectedBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getConnectedBluetoothDevices');
612
+ const getBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getBluetoothDevices');
613
+ const getBluetoothAdapterState = /* @__PURE__ */ temporarilyNotSupport('getBluetoothAdapterState');
614
+ const closeBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('closeBluetoothAdapter');
615
+
616
+ // 蓝牙-低功耗中心设备
617
+ const writeBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('writeBLECharacteristicValue');
618
+ const setBLEMTU = /* @__PURE__ */ temporarilyNotSupport('setBLEMTU');
619
+ const readBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('readBLECharacteristicValue');
620
+ const onBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('onBLEMTUChange');
621
+ const onBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('onBLEConnectionStateChange');
622
+ const onBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('onBLECharacteristicValueChange');
623
+ const offBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('offBLEMTUChange');
624
+ const offBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('offBLEConnectionStateChange');
625
+ const offBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('offBLECharacteristicValueChange');
626
+ const notifyBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('notifyBLECharacteristicValueChange');
627
+ const getBLEMTU = /* @__PURE__ */ temporarilyNotSupport('getBLEMTU');
628
+ const getBLEDeviceServices = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceServices');
629
+ const getBLEDeviceRSSI = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceRSSI');
630
+ const getBLEDeviceCharacteristics = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceCharacteristics');
631
+ const createBLEConnection = /* @__PURE__ */ temporarilyNotSupport('createBLEConnection');
632
+ const closeBLEConnection = /* @__PURE__ */ temporarilyNotSupport('closeBLEConnection');
633
+
634
+ // 蓝牙-低功耗外围设备
635
+ const onBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('onBLEPeripheralConnectionStateChanged');
636
+ const offBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('offBLEPeripheralConnectionStateChanged');
637
+ const createBLEPeripheralServer = /* @__PURE__ */ temporarilyNotSupport('createBLEPeripheralServer');
638
+
639
+ // 日历
640
+ const addPhoneRepeatCalendar = temporarilyNotSupport('addPhoneRepeatCalendar');
641
+ const addPhoneCalendar = temporarilyNotSupport('addPhoneCalendar');
642
+
430
643
  // 从 API Version 6 开始支持
431
644
  /**
432
645
  * 设置系统剪贴板的内容
@@ -446,8 +659,20 @@ const setClipboardData = function (options) {
446
659
  }
447
660
  return new Promise((resolve, reject) => {
448
661
  const systemPasteboard = pasteboard.getSystemPasteboard();
449
- const pasteData = pasteboard.createPlainTextData(data);
450
- systemPasteboard.setPasteData(pasteData, (error, data) => {
662
+ const pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, data);
663
+ try {
664
+ systemPasteboard.setDataSync(pasteData);
665
+ promptAction.showToast({
666
+ message: '内容已复制',
667
+ duration: 1500,
668
+ bottom: '50%',
669
+ showMode: 1 // 设置弹窗显示模式,显示在应用之上。
670
+ });
671
+ return handle.success({
672
+ data,
673
+ }, { resolve, reject });
674
+ }
675
+ catch (error) {
451
676
  if (error) {
452
677
  console.error('Failed to set PasteData. Cause: ' + JSON.stringify(error));
453
678
  res = {
@@ -456,12 +681,7 @@ const setClipboardData = function (options) {
456
681
  };
457
682
  callAsyncFail(reject, res, options);
458
683
  }
459
- else {
460
- return handle.success({
461
- data,
462
- }, { resolve, reject });
463
- }
464
- });
684
+ }
465
685
  });
466
686
  };
467
687
  /**
@@ -472,7 +692,7 @@ const getClipboardData = function (options) {
472
692
  const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete });
473
693
  return new Promise((resolve, reject) => {
474
694
  const systemPasteboard = pasteboard.getSystemPasteboard();
475
- systemPasteboard.getPasteData((error, pasteData) => {
695
+ systemPasteboard.getData((error, pasteData) => {
476
696
  if (error) {
477
697
  console.error('Failed to obtain PasteData. Cause: ' + JSON.stringify(error));
478
698
  return handle.fail({
@@ -488,6 +708,45 @@ const getClipboardData = function (options) {
488
708
  });
489
709
  };
490
710
 
711
+ /**
712
+ * 停止监听罗盘数据
713
+ */
714
+ const stopCompass = temporarilyNotSupport('stopCompass');
715
+ /**
716
+ * 开始监听罗盘数据
717
+ */
718
+ const startCompass = temporarilyNotSupport('startCompass');
719
+ /**
720
+ * 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。
721
+ */
722
+ const onCompassChange = temporarilyNotSupport('onCompassChange');
723
+ /**
724
+ * 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
725
+ */
726
+ const offCompassChange = temporarilyNotSupport('offCompassChange');
727
+
728
+ // 联系人
729
+ const chooseContact = /* @__PURE__ */ temporarilyNotSupport('chooseContact');
730
+ const addPhoneContact = /* @__PURE__ */ temporarilyNotSupport('addPhoneContact');
731
+
732
+ // 加密
733
+ const getRandomValues = /* @__PURE__ */ temporarilyNotSupport('getRandomValues');
734
+
735
+ // 陀螺仪
736
+ const stopGyroscope = /* @__PURE__ */ temporarilyNotSupport('stopGyroscope');
737
+ const startGyroscope = /* @__PURE__ */ temporarilyNotSupport('startGyroscope');
738
+ const onGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('onGyroscopeChange');
739
+ const offGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('offGyroscopeChange');
740
+
741
+ // 蓝牙-信标(Beacon)
742
+ const stopBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBeaconDiscovery');
743
+ const startBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBeaconDiscovery');
744
+ const onBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('onBeaconUpdate');
745
+ const onBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('onBeaconServiceChange');
746
+ const offBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('offBeaconUpdate');
747
+ const offBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('offBeaconServiceChange');
748
+ const getBeacons = /* @__PURE__ */ temporarilyNotSupport('getBeacons');
749
+
491
750
  const callbackManager = new CallbackManager();
492
751
  const resizeListener = (height) => {
493
752
  callbackManager.trigger({
@@ -537,8 +796,19 @@ const hideKeyboard = function (options) {
537
796
  };
538
797
  const getSelectedTextRange = /* @__PURE__ */ temporarilyNotSupport('getSelectedTextRange');
539
798
 
540
- const onMemoryWarning = temporarilyNotSupport('onMemoryWarning');
541
- const offMemoryWarning = temporarilyNotSupport('offMemoryWarning');
799
+ const onMemoryWarning = (listener) => {
800
+ hooks.tap('getMemoryLevel', (res) => {
801
+ listener(res);
802
+ });
803
+ };
804
+ const offMemoryWarning = (listener) => {
805
+ hooks.off('getMemoryLevel', listener);
806
+ };
807
+
808
+ const stopDeviceMotionListening = temporarilyNotSupport('stopDeviceMotionListening');
809
+ const startDeviceMotionListening = temporarilyNotSupport('startDeviceMotionListening');
810
+ const onDeviceMotionChange = temporarilyNotSupport('onDeviceMotionChange');
811
+ const offDeviceMotionChange = temporarilyNotSupport('offDeviceMotionChange');
542
812
 
543
813
  const getNetworkType = (options = {}) => {
544
814
  const { success, fail, complete } = options;
@@ -561,7 +831,7 @@ const getNetworkType = (options = {}) => {
561
831
  });
562
832
  };
563
833
  const networkStatusManager = new CallbackManager();
564
- const networkStatusListener = (data, code = 0) => __awaiter(void 0, void 0, void 0, function* () {
834
+ const networkStatusListener = (data_1, ...args_1) => __awaiter(void 0, [data_1, ...args_1], void 0, function* (data, code = 0) {
565
835
  if (code > 0) {
566
836
  return networkStatusManager.trigger({ isConnected: false, networkType: 'none' });
567
837
  }
@@ -580,23 +850,50 @@ const networkStatusListener = (data, code = 0) => __awaiter(void 0, void 0, void
580
850
  */
581
851
  const onNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('onNetworkWeakChange');
582
852
  const onNetworkStatusChange = callback => {
583
- networkStatusManager.add(callback);
584
- if (networkStatusManager.count() === 1) {
585
- network.subscribe({
586
- success: networkStatusListener,
587
- fail: networkStatusListener,
853
+ const name = 'onNetworkStatusChange';
854
+ const handle = new MethodHandler({ name, complete: callback });
855
+ try {
856
+ networkStatusManager.add(callback);
857
+ if (networkStatusManager.count() === 1) {
858
+ network.subscribe({
859
+ success: networkStatusListener,
860
+ fail: networkStatusListener,
861
+ });
862
+ }
863
+ }
864
+ catch (error) {
865
+ handle.fail({
866
+ errMsg: error
588
867
  });
589
868
  }
590
869
  };
591
870
  const offNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('offNetworkWeakChange');
592
871
  const offNetworkStatusChange = callback => {
593
- networkStatusManager.remove(callback);
594
- if (networkStatusManager.count() === 0) {
595
- network.unsubscribe();
872
+ const name = 'offNetworkStatusChange';
873
+ const handle = new MethodHandler({ name, complete: callback });
874
+ try {
875
+ networkStatusManager.remove(callback);
876
+ if (networkStatusManager.count() === 0) {
877
+ network.unsubscribe();
878
+ }
879
+ }
880
+ catch (error) {
881
+ handle.fail({
882
+ errMsg: error
883
+ });
596
884
  }
597
885
  };
598
886
  const getLocalIPAddress = /* @__PURE__ */ temporarilyNotSupport('getLocalIPAddress');
599
887
 
888
+ // NFC
889
+ const stopHCE = /* @__PURE__ */ temporarilyNotSupport('stopHCE');
890
+ const startHCE = /* @__PURE__ */ temporarilyNotSupport('startHCE');
891
+ const sendHCEMessage = /* @__PURE__ */ temporarilyNotSupport('sendHCEMessage');
892
+ const onHCEMessage = /* @__PURE__ */ temporarilyNotSupport('onHCEMessage');
893
+ const offHCEMessage = /* @__PURE__ */ temporarilyNotSupport('offHCEMessage');
894
+ const getNFCAdapter = /* @__PURE__ */ temporarilyNotSupport('getNFCAdapter');
895
+ const getHCEState = /* @__PURE__ */ temporarilyNotSupport('getHCEState');
896
+
600
897
  // 从 API Version 7 开始支持。
601
898
  const makePhoneCall = (options) => {
602
899
  // options must be an Object
@@ -632,6 +929,9 @@ const makePhoneCall = (options) => {
632
929
  });
633
930
  };
634
931
 
932
+ // 扫码
933
+ const scanCode = /* @__PURE__ */ temporarilyNotSupport('scanCode');
934
+
635
935
  // 从API Version 7 开始,该接口不再维护,推荐使用新接口'@ohos.brightness'
636
936
  // 但是 新接口 @ohos.brightness 没有 getValue
637
937
  // 屏幕
@@ -697,23 +997,51 @@ const onScreenRecordingStateChanged = /* @__PURE__ */ temporarilyNotSupport('onS
697
997
  const offScreenRecordingStateChanged = /* @__PURE__ */ temporarilyNotSupport('offScreenRecordingStateChanged');
698
998
  const getScreenRecordingState = /* @__PURE__ */ temporarilyNotSupport('getScreenRecordingState');
699
999
 
1000
+ // 短信
1001
+ const sendSms = /* @__PURE__ */ temporarilyNotSupport('sendSms');
1002
+
700
1003
  const VIBRATOR_LONG_TIME = 400;
701
1004
  const VIBRATOR_SHORT_TIME = 15;
702
- function vibrateBaseGenerator(time) {
703
- return (options) => {
1005
+ function vibrateBaseGenerator(duration, name = '') {
1006
+ return ({ success, fail, complete } = {}) => {
1007
+ const handle = new MethodHandler({ name, success, fail, complete });
704
1008
  return new Promise((resolve, reject) => {
705
- vibrator.vibrate(time).then(() => {
706
- const res = { errMsg: 'vibrateShort:ok' };
707
- callAsyncSuccess(resolve, res, options);
1009
+ vibrator.startVibration({
1010
+ type: 'time',
1011
+ duration,
1012
+ }, {
1013
+ usage: 'unknown'
708
1014
  }, (error) => {
709
- const res = { errMsg: 'vibrateShort:fail' + error };
710
- callAsyncFail(reject, res, options);
1015
+ if (error) {
1016
+ return handle.fail({
1017
+ errMsg: `vibrate fail, error.code: ${error.code}; error.message: ${error.message}`
1018
+ }, { resolve, reject });
1019
+ }
1020
+ return handle.success({}, { resolve, reject });
711
1021
  });
712
1022
  });
713
1023
  };
714
1024
  }
715
- const vibrateLong = vibrateBaseGenerator(VIBRATOR_LONG_TIME);
716
- const vibrateShort = vibrateBaseGenerator(VIBRATOR_SHORT_TIME);
1025
+ const vibrateLong = vibrateBaseGenerator(VIBRATOR_LONG_TIME, 'vibrateLong');
1026
+ const vibrateShort = vibrateBaseGenerator(VIBRATOR_SHORT_TIME, 'vibrateShort');
1027
+
1028
+ // Wi-Fi
1029
+ const stopWifi = /* @__PURE__ */ temporarilyNotSupport('stopWifi');
1030
+ const startWifi = /* @__PURE__ */ temporarilyNotSupport('startWifi');
1031
+ const setWifiList = /* @__PURE__ */ temporarilyNotSupport('setWifiList');
1032
+ const onWifiConnectedWithPartialInfo = /* @__PURE__ */ temporarilyNotSupport('onWifiConnectedWithPartialInfo');
1033
+ const onWifiConnected = /* @__PURE__ */ temporarilyNotSupport('onWifiConnected');
1034
+ const onGetWifiList = /* @__PURE__ */ temporarilyNotSupport('onGetWifiList');
1035
+ const offWifiConnectedWithPartialInfo = /* @__PURE__ */ temporarilyNotSupport('offWifiConnectedWithPartialInfo');
1036
+ const offWifiConnected = /* @__PURE__ */ temporarilyNotSupport('offWifiConnected');
1037
+ const offGetWifiList = /* @__PURE__ */ temporarilyNotSupport('offGetWifiList');
1038
+ const getWifiList = /* @__PURE__ */ temporarilyNotSupport('getWifiList');
1039
+ const getConnectedWifi = /* @__PURE__ */ temporarilyNotSupport('getConnectedWifi');
1040
+ const connectWifi = /* @__PURE__ */ temporarilyNotSupport('connectWifi');
1041
+
1042
+ // 第三方平台
1043
+ const getExtConfigSync = /* @__PURE__ */ temporarilyNotSupport('getExtConfigSync');
1044
+ const getExtConfig = /* @__PURE__ */ temporarilyNotSupport('getExtConfig');
717
1045
 
718
1046
  /**
719
1047
  * HarmonyOS 文档:
@@ -1714,14 +2042,11 @@ const ENV_TYPE = {
1714
2042
  function getEnv() {
1715
2043
  return ENV_TYPE.HARMONY;
1716
2044
  }
1717
- const getCurrentInstance = () => Current;
1718
- const nextTick = (cb, ctx) => {
1719
- setTimeout(function () {
1720
- ctx ? cb.call(ctx) : cb();
1721
- }, 1);
1722
- };
2045
+ // TODO
2046
+ const getCurrentPages = () => [];
1723
2047
  const requirePlugin$1 = temporarilyNotSupport('requirePlugin');
1724
2048
 
2049
+ // @ts-nocheck
1725
2050
  // HarmonyOS 文档: https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-geolocation-0000001199568865#section13752433138
1726
2051
  // WX 文档: https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.onLocationChange.html
1727
2052
  // ✅ wx.offLocationChange
@@ -1736,17 +2061,22 @@ const requirePlugin$1 = temporarilyNotSupport('requirePlugin');
1736
2061
  // ❌ wx.chooseLocation 地图相关
1737
2062
  // ❌ wx.stopLocationUpdate
1738
2063
  // ❌ wx.startLocationUpdate
2064
+ // 位置
2065
+ const stopLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('stopLocationUpdate');
2066
+ const startLocationUpdateBackground = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdateBackground');
2067
+ const startLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdate');
2068
+ const openLocation = /* @__PURE__ */ temporarilyNotSupport('openLocation');
1739
2069
  function formatLocation(location) {
1740
- const locationWX = {
2070
+ const wxLocate = {
1741
2071
  latitude: location.latitude,
1742
2072
  longitude: location.longitude,
1743
2073
  altitude: location.altitude,
1744
2074
  accuracy: location.accuracy,
1745
2075
  speed: location.speed,
1746
- verticalAccuracy: 0,
2076
+ verticalAccuracy: 0, // OHOS 不支持返回此参数,直接设置为默认值
1747
2077
  horizontalAccuracy: 0 // OHOS 不支持返回此参数,直接设置为默认值
1748
2078
  };
1749
- return locationWX;
2079
+ return wxLocate;
1750
2080
  }
1751
2081
  // TODO:增加参数校验
1752
2082
  // const getLocationSchema = {
@@ -1763,20 +2093,19 @@ const getLocation = function (options = {}) {
1763
2093
  * 二者参数不一致
1764
2094
  */
1765
2095
  const { type, altitude, isHighAccuracy, highAccuracyExpireTime } = options;
1766
- const params = {
1767
- type,
1768
- altitude,
1769
- isHighAccuracy,
1770
- highAccuracyExpireTime
1771
- };
1772
2096
  try {
1773
- return geoLocationManager.getCurrentLocation(params).then((location) => {
2097
+ return geoLocationManager.getCurrentLocation({
2098
+ type,
2099
+ altitude,
2100
+ isHighAccuracy,
2101
+ highAccuracyExpireTime
2102
+ }).then((location) => {
1774
2103
  if (location.code !== 0) {
1775
2104
  callAsyncFail(reject, location, options);
1776
2105
  }
1777
2106
  else {
1778
- const locationWX = formatLocation(location.data);
1779
- callAsyncSuccess(resolve, locationWX, options);
2107
+ const wxLocate = formatLocation(location.data);
2108
+ callAsyncSuccess(resolve, wxLocate, options);
1780
2109
  }
1781
2110
  }).catch(error => {
1782
2111
  callAsyncFail(reject, error, options);
@@ -1788,26 +2117,90 @@ const getLocation = function (options = {}) {
1788
2117
  });
1789
2118
  };
1790
2119
  const onLocationChange = function (callback) {
1791
- validateParams('onLocationChange', [callback], ['Function']);
1792
- const requestInfo = {};
1793
- geoLocationManager.on('locationChange', requestInfo, (location) => {
1794
- if (location) {
1795
- const locationWX = formatLocation(location);
1796
- callback(locationWX);
1797
- }
1798
- });
2120
+ const name = 'onLocationChange';
2121
+ const handle = new MethodHandler({ name, complete: callback });
2122
+ try {
2123
+ validateParams(name, [callback], ['Function']);
2124
+ geoLocationManager.on('locationChange', {}, (location) => {
2125
+ if (location) {
2126
+ const wxLocate = formatLocation(location);
2127
+ callback(wxLocate);
2128
+ }
2129
+ });
2130
+ }
2131
+ catch (error) {
2132
+ handle.fail({
2133
+ errMsg: error
2134
+ });
2135
+ }
1799
2136
  };
1800
2137
  const offLocationChange = function (callback) {
1801
- validateParams('offLocationChange', [callback], ['Function']);
1802
- geoLocationManager.off('locationChange', (location) => {
1803
- const status = {
1804
- errCode: 200,
1805
- errMsg: location ? 'offLocationChange is off' : 'offLocationChange err'
1806
- };
1807
- if (callback) {
1808
- callback(status);
1809
- }
1810
- });
2138
+ const name = 'offLocationChange';
2139
+ const handle = new MethodHandler({ name, complete: callback });
2140
+ try {
2141
+ validateParams(name, [callback], ['Function']);
2142
+ geoLocationManager.off('locationChange', (location) => {
2143
+ const status = {
2144
+ errCode: 200,
2145
+ errMsg: location ? 'offLocationChange is off' : 'offLocationChange err'
2146
+ };
2147
+ if (callback) {
2148
+ callback(status);
2149
+ }
2150
+ });
2151
+ }
2152
+ catch (error) {
2153
+ handle.fail({
2154
+ errMsg: error
2155
+ });
2156
+ }
2157
+ };
2158
+ const onLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('onLocationChangeError');
2159
+ const offLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('offLocationChangeError');
2160
+ const choosePoi = /* @__PURE__ */ temporarilyNotSupport('choosePoi');
2161
+ const chooseLocation = /* @__PURE__ */ temporarilyNotSupport('chooseLocation');
2162
+ const getFuzzyLocation = /* @__PURE__ */ temporarilyNotSupport('getFuzzyLocation');
2163
+
2164
+ // 音频
2165
+ const stopVoice = /* @__PURE__ */ temporarilyNotSupport('stopVoice');
2166
+ const setInnerAudioOption = /* @__PURE__ */ temporarilyNotSupport('setInnerAudioOption');
2167
+ const playVoice = /* @__PURE__ */ temporarilyNotSupport('playVoice');
2168
+ const pauseVoice = /* @__PURE__ */ temporarilyNotSupport('pauseVoice');
2169
+ const getAvailableAudioSources = /* @__PURE__ */ temporarilyNotSupport('getAvailableAudioSources');
2170
+ const createWebAudioContext = /* @__PURE__ */ temporarilyNotSupport('createWebAudioContext');
2171
+ const createMediaAudioPlayer = /* @__PURE__ */ temporarilyNotSupport('createMediaAudioPlayer');
2172
+ /**
2173
+ * 创建内部 audio 上下文 InnerAudioContext 对象。
2174
+ */
2175
+ const createInnerAudioContext = /* @__PURE__ */ temporarilyNotSupport('createInnerAudioContext');
2176
+ const createAudioContext = /* @__PURE__ */ temporarilyNotSupport('createAudioContext');
2177
+
2178
+ // 背景音频
2179
+ const stopBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('stopBackgroundAudio');
2180
+ const seekBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('seekBackgroundAudio');
2181
+ const playBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('playBackgroundAudio');
2182
+ const pauseBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('pauseBackgroundAudio');
2183
+ const onBackgroundAudioStop = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioStop');
2184
+ const onBackgroundAudioPlay = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPlay');
2185
+ const onBackgroundAudioPause = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPause');
2186
+ const getBackgroundAudioPlayerState = /* @__PURE__ */ temporarilyNotSupport('getBackgroundAudioPlayerState');
2187
+ /**
2188
+ * 获取全局唯一的背景音频管理器
2189
+ */
2190
+ const getBackgroundAudioManager = /* @__PURE__ */ temporarilyNotSupport('getBackgroundAudioManager');
2191
+
2192
+ // 相机
2193
+ class CameraContext {
2194
+ constructor() {
2195
+ this.onCameraFrame = temporarilyNotSupport('CameraContext.onCameraFrame');
2196
+ this.setZoom = temporarilyNotSupport('CameraContext.setZoom');
2197
+ this.startRecord = temporarilyNotSupport('CameraContext.startRecord');
2198
+ this.stopRecord = temporarilyNotSupport('CameraContext.stopRecord');
2199
+ this.takePhoto = temporarilyNotSupport('CameraContext.takePhoto');
2200
+ }
2201
+ }
2202
+ const createCameraContext = (_) => {
2203
+ return new CameraContext();
1811
2204
  };
1812
2205
 
1813
2206
  // HarmonyOS 文档链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-media-0000001103383404
@@ -1959,7 +2352,7 @@ const chooseImage = function (options) {
1959
2352
  photoSelectOptions.maxSelectNumber = count; // 选择媒体文件的最大数目
1960
2353
  photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型为IMAGE
1961
2354
  photoViewPicker.select(photoSelectOptions).then((photoSelectResult) => {
1962
- callAsyncSuccess(resolve, { tempFilePaths: photoSelectResult.photoUris });
2355
+ callAsyncSuccess(resolve, { tempFilePaths: photoSelectResult.photoUris }, options);
1963
2356
  }).catch((error) => {
1964
2357
  callAsyncFail(reject, error, options);
1965
2358
  });
@@ -1968,6 +2361,69 @@ const chooseImage = function (options) {
1968
2361
  const previewImage = temporarilyNotSupport('previewImage');
1969
2362
  const saveImageToPhotosAlbum = temporarilyNotSupport('saveImageToPhotosAlbum');
1970
2363
 
2364
+ // 实时音视频
2365
+ const createLivePusherContext = /* @__PURE__ */ temporarilyNotSupport('createLivePusherContext');
2366
+ const createLivePlayerContext = /* @__PURE__ */ temporarilyNotSupport('createLivePlayerContext');
2367
+
2368
+ // 地图
2369
+ const createMapContext = /* @__PURE__ */ temporarilyNotSupport('createMapContext');
2370
+
2371
+ // 画面录制器
2372
+ const createMediaRecorder = /* @__PURE__ */ temporarilyNotSupport('createMediaRecorder');
2373
+
2374
+ // 录音
2375
+ const stopRecord = /* @__PURE__ */ temporarilyNotSupport('stopRecord');
2376
+ const startRecord = /* @__PURE__ */ temporarilyNotSupport('startRecord');
2377
+ const getRecorderManager = /* @__PURE__ */ temporarilyNotSupport('getRecorderManager');
2378
+
2379
+ // @ts-nocheck
2380
+ class VideoContext {
2381
+ constructor(id) {
2382
+ this.requestBackgroundPlayback = temporarilyNotSupport('VideoContext.requestBackgroundPlayback');
2383
+ this.exitBackgroundPlayback = temporarilyNotSupport('VideoContext.exitBackgroundPlayback');
2384
+ this.exitPictureInPicture = temporarilyNotSupport('VideoContext.exitPictureInPicture');
2385
+ this.hideStatusBar = temporarilyNotSupport('VideoContext.hideStatusBar');
2386
+ this.playbackRate = temporarilyNotSupport('VideoContext.playbackRate');
2387
+ this.sendDanmu = temporarilyNotSupport('VideoContext.sendDanmu');
2388
+ this.showStatusBar = temporarilyNotSupport('VideoContext.showStatusBar');
2389
+ this.id = id;
2390
+ this.video = document$1.getElementById(id);
2391
+ if (this.video) {
2392
+ this.controller = this.video.controller;
2393
+ }
2394
+ }
2395
+ play() {
2396
+ if (!this.controller)
2397
+ return;
2398
+ this.controller.play();
2399
+ }
2400
+ pause() {
2401
+ if (!this.controller)
2402
+ return;
2403
+ this.controller.pause();
2404
+ }
2405
+ stop() {
2406
+ if (!this.controller)
2407
+ return;
2408
+ this.controller.stop();
2409
+ }
2410
+ seek(position) {
2411
+ if (!this.controller)
2412
+ return;
2413
+ this.controller.setCurrentTime(position);
2414
+ }
2415
+ requestFullScreen() {
2416
+ if (!this.controller)
2417
+ return;
2418
+ this.controller.requestFullscreen(true);
2419
+ }
2420
+ exitFullScreen() {
2421
+ if (!this.controller)
2422
+ return;
2423
+ this.controller.exitFullscreen();
2424
+ }
2425
+ }
2426
+
1971
2427
  // HarmonyOS 文档链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-media-0000001103383404
1972
2428
  // WX 文档链接:https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseVideo.html
1973
2429
  // ✅ wx.saveVideoToPhotosAlbum
@@ -1993,6 +2449,9 @@ const saveImageToPhotosAlbum = temporarilyNotSupport('saveImageToPhotosAlbum');
1993
2449
  const saveVideoToPhotosAlbumSchema = {
1994
2450
  filePath: 'String'
1995
2451
  };
2452
+ const createVideoContext = (id, _) => {
2453
+ return new VideoContext(id);
2454
+ };
1996
2455
  // TODO: 1.返回属性补全
1997
2456
  // TODO: 2.只支持从相册选择,补充摄像头拍摄功能,需要HarmonyOS提供选择组件
1998
2457
  const chooseVideo = function (options = {}) {
@@ -2015,6 +2474,9 @@ const chooseVideo = function (options = {}) {
2015
2474
  });
2016
2475
  });
2017
2476
  };
2477
+ const compressVideo = /* @__PURE__ */ temporarilyNotSupport('compressVideo');
2478
+ const getVideoInfo = /* @__PURE__ */ temporarilyNotSupport('getVideoInfo');
2479
+ const openVideoEditor = /* @__PURE__ */ temporarilyNotSupport('openVideoEditor');
2018
2480
  const saveVideoToPhotosAlbum = function (options) {
2019
2481
  return new Promise((resolve, reject) => {
2020
2482
  try {
@@ -2038,6 +2500,30 @@ const saveVideoToPhotosAlbum = function (options) {
2038
2500
  });
2039
2501
  };
2040
2502
 
2503
+ // 视频解码器
2504
+ const createVideoDecoder = /* @__PURE__ */ temporarilyNotSupport('createVideoDecoder');
2505
+
2506
+ // 音视频合成
2507
+ const createMediaContainer = /* @__PURE__ */ temporarilyNotSupport('createMediaContainer');
2508
+
2509
+ // 实时语音
2510
+ const updateVoIPChatMuteConfig = /* @__PURE__ */ temporarilyNotSupport('updateVoIPChatMuteConfig');
2511
+ const subscribeVoIPVideoMembers = /* @__PURE__ */ temporarilyNotSupport('subscribeVoIPVideoMembers');
2512
+ const setEnable1v1Chat = /* @__PURE__ */ temporarilyNotSupport('setEnable1v1Chat');
2513
+ const onVoIPVideoMembersChanged = /* @__PURE__ */ temporarilyNotSupport('onVoIPVideoMembersChanged');
2514
+ const onVoIPChatStateChanged = /* @__PURE__ */ temporarilyNotSupport('onVoIPChatStateChanged');
2515
+ const onVoIPChatSpeakersChanged = /* @__PURE__ */ temporarilyNotSupport('onVoIPChatSpeakersChanged');
2516
+ const onVoIPChatMembersChanged = /* @__PURE__ */ temporarilyNotSupport('onVoIPChatMembersChanged');
2517
+ const onVoIPChatInterrupted = /* @__PURE__ */ temporarilyNotSupport('onVoIPChatInterrupted');
2518
+ const offVoIPChatSpeakersChanged = /* @__PURE__ */ temporarilyNotSupport('offVoIPChatSpeakersChanged');
2519
+ const offVoIPVideoMembersChanged = /* @__PURE__ */ temporarilyNotSupport('offVoIPVideoMembersChanged');
2520
+ const offVoIPChatStateChanged = /* @__PURE__ */ temporarilyNotSupport('offVoIPChatStateChanged');
2521
+ const offVoIPChatMembersChanged = /* @__PURE__ */ temporarilyNotSupport('offVoIPChatMembersChanged');
2522
+ const offVoIPChatInterrupted = /* @__PURE__ */ temporarilyNotSupport('offVoIPChatInterrupted');
2523
+ const joinVoIPChat = /* @__PURE__ */ temporarilyNotSupport('joinVoIPChat');
2524
+ const join1v1Chat = /* @__PURE__ */ temporarilyNotSupport('join1v1Chat');
2525
+ const exitVoIPChat = /* @__PURE__ */ temporarilyNotSupport('exitVoIPChat');
2526
+
2041
2527
  // 跳转
2042
2528
  const openEmbeddedMiniProgram = /* @__PURE__ */ temporarilyNotSupport('openEmbeddedMiniProgram');
2043
2529
  const navigateToMiniProgram = /* @__PURE__ */ temporarilyNotSupport('navigateToMiniProgram');
@@ -2139,6 +2625,18 @@ const downloadFile = function (options) {
2139
2625
  return downloadTaskWX;
2140
2626
  };
2141
2627
 
2628
+ // mDNS
2629
+ const stopLocalServiceDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopLocalServiceDiscovery');
2630
+ const startLocalServiceDiscovery = /* @__PURE__ */ temporarilyNotSupport('startLocalServiceDiscovery');
2631
+ const onLocalServiceResolveFail = /* @__PURE__ */ temporarilyNotSupport('onLocalServiceResolveFail');
2632
+ const onLocalServiceLost = /* @__PURE__ */ temporarilyNotSupport('onLocalServiceLost');
2633
+ const onLocalServiceFound = /* @__PURE__ */ temporarilyNotSupport('onLocalServiceFound');
2634
+ const onLocalServiceDiscoveryStop = /* @__PURE__ */ temporarilyNotSupport('onLocalServiceDiscoveryStop');
2635
+ const offLocalServiceResolveFail = /* @__PURE__ */ temporarilyNotSupport('offLocalServiceResolveFail');
2636
+ const offLocalServiceLost = /* @__PURE__ */ temporarilyNotSupport('offLocalServiceLost');
2637
+ const offLocalServiceFound = /* @__PURE__ */ temporarilyNotSupport('offLocalServiceFound');
2638
+ const offLocalServiceDiscoveryStop = /* @__PURE__ */ temporarilyNotSupport('offLocalServiceDiscoveryStop');
2639
+
2142
2640
  // HarmonyOS 文档链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-net-http-0000001168304341
2143
2641
  // WX 文档链接:https://developers.weixin.qq.com/miniprogram/dev/api/network/request/wx.request.html
2144
2642
  // ✅ wx.request
@@ -2172,10 +2670,10 @@ const request = function (options) {
2172
2670
  header['Content-Type'] = 'application/json';
2173
2671
  }
2174
2672
  // 检查 Header 是否有 Referer
2175
- if (isUndefined(header.Referer)) {
2176
- const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' };
2177
- callAsyncFail(reject, error, options);
2178
- }
2673
+ // if (isUndefined(header.Referer)) {
2674
+ // const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
2675
+ // callAsyncFail(reject, error, options)
2676
+ // }
2179
2677
  // 检查 method 是否正确
2180
2678
  if (method) {
2181
2679
  if (!METHOD.includes(method)) {
@@ -2219,6 +2717,12 @@ const request = function (options) {
2219
2717
  return requestTask;
2220
2718
  };
2221
2719
 
2720
+ // TCP 通信
2721
+ const createTCPSocket = /* @__PURE__ */ temporarilyNotSupport('createTCPSocket');
2722
+
2723
+ // UDP 通信
2724
+ const createUDPSocket = /* @__PURE__ */ temporarilyNotSupport('createUDPSocket');
2725
+
2222
2726
  // HarmonyOS 文档链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-request-0000001123753962#section455311474372
2223
2727
  // WX 文档链接:https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/wx.uploadFile.html
2224
2728
  // ✅ wx.uploadFile
@@ -2451,6 +2955,88 @@ const connectSocket = function (options) {
2451
2955
  return SocketTaskWX;
2452
2956
  };
2453
2957
 
2958
+ // 帐号信息
2959
+ const getAccountInfoSync = /* @__PURE__ */ temporarilyNotSupport('getAccountInfoSync');
2960
+
2961
+ // 收货地址
2962
+ const chooseAddress = /* @__PURE__ */ temporarilyNotSupport('chooseAddress');
2963
+
2964
+ // 授权
2965
+ const authorizeForMiniProgram = /* @__PURE__ */ temporarilyNotSupport('authorizeForMiniProgram');
2966
+ const authorize = /* @__PURE__ */ temporarilyNotSupport('authorize');
2967
+
2968
+ // 卡券
2969
+ const openCard = /* @__PURE__ */ temporarilyNotSupport('openCard');
2970
+ const addCard = /* @__PURE__ */ temporarilyNotSupport('addCard');
2971
+
2972
+ // 视频号
2973
+ const reserveChannelsLive = /* @__PURE__ */ temporarilyNotSupport('reserveChannelsLive');
2974
+ const openChannelsUserProfile = /* @__PURE__ */ temporarilyNotSupport('openChannelsUserProfile');
2975
+ const openChannelsLive = /* @__PURE__ */ temporarilyNotSupport('openChannelsLive');
2976
+ const openChannelsEvent = /* @__PURE__ */ temporarilyNotSupport('openChannelsEvent');
2977
+ const openChannelsActivity = /* @__PURE__ */ temporarilyNotSupport('openChannelsActivity');
2978
+ const getChannelsShareKey = /* @__PURE__ */ temporarilyNotSupport('getChannelsShareKey');
2979
+ const getChannelsLiveNoticeInfo = /* @__PURE__ */ temporarilyNotSupport('getChannelsLiveNoticeInfo');
2980
+ const getChannelsLiveInfo = /* @__PURE__ */ temporarilyNotSupport('getChannelsLiveInfo');
2981
+
2982
+ // 微信客服
2983
+ const openCustomerServiceChat = /* @__PURE__ */ temporarilyNotSupport('openCustomerServiceChat');
2984
+
2985
+ // 设备(组)音视频通话
2986
+ const requestDeviceVoIP = /* @__PURE__ */ temporarilyNotSupport('requestDeviceVoIP');
2987
+ const getDeviceVoIPList = /* @__PURE__ */ temporarilyNotSupport('getDeviceVoIPList');
2988
+
2989
+ // 过往接口
2990
+ const checkIsSupportFacialRecognition = /* @__PURE__ */ temporarilyNotSupport('checkIsSupportFacialRecognition');
2991
+ const startFacialRecognitionVerify = /* @__PURE__ */ temporarilyNotSupport('startFacialRecognitionVerify');
2992
+ const startFacialRecognitionVerifyAndUploadVideo = /* @__PURE__ */ temporarilyNotSupport('startFacialRecognitionVerifyAndUploadVideo');
2993
+ const faceVerifyForPay = /* @__PURE__ */ temporarilyNotSupport('faceVerifyForPay');
2994
+
2995
+ // 收藏
2996
+ const addVideoToFavorites = /* @__PURE__ */ temporarilyNotSupport('addVideoToFavorites');
2997
+ const addFileToFavorites = /* @__PURE__ */ temporarilyNotSupport('addFileToFavorites');
2998
+
2999
+ // 微信群
3000
+ const getGroupEnterInfo = /* @__PURE__ */ temporarilyNotSupport('getGroupEnterInfo');
3001
+
3002
+ // 发票
3003
+ const chooseInvoiceTitle = /* @__PURE__ */ temporarilyNotSupport('chooseInvoiceTitle');
3004
+ const chooseInvoice = /* @__PURE__ */ temporarilyNotSupport('chooseInvoice');
3005
+
3006
+ // 车牌
3007
+ const chooseLicensePlate = /* @__PURE__ */ temporarilyNotSupport('chooseLicensePlate');
3008
+
3009
+ // 帐号信息
3010
+ const pluginLogin = /* @__PURE__ */ temporarilyNotSupport('pluginLogin');
3011
+ const login = /* @__PURE__ */ temporarilyNotSupport('login');
3012
+ const checkSession = /* @__PURE__ */ temporarilyNotSupport('checkSession');
3013
+
3014
+ // 我的小程序
3015
+ const checkIsAddedToMyMiniProgram = /* @__PURE__ */ temporarilyNotSupport('checkIsAddedToMyMiniProgram');
3016
+
3017
+ // 隐私信息授权
3018
+ const requirePrivacyAuthorize = /* @__PURE__ */ temporarilyNotSupport('requirePrivacyAuthorize');
3019
+ const openPrivacyContract = /* @__PURE__ */ temporarilyNotSupport('openPrivacyContract');
3020
+ const onNeedPrivacyAuthorization = /* @__PURE__ */ temporarilyNotSupport('onNeedPrivacyAuthorization');
3021
+ const getPrivacySetting = /* @__PURE__ */ temporarilyNotSupport('getPrivacySetting');
3022
+
3023
+ // 微信红包
3024
+ const showRedPackage = /* @__PURE__ */ temporarilyNotSupport('showRedPackage');
3025
+
3026
+ // 设置
3027
+ const openSetting = /* @__PURE__ */ temporarilyNotSupport('openSetting');
3028
+ const getSetting = /* @__PURE__ */ temporarilyNotSupport('getSetting');
3029
+
3030
+ // 生物认证
3031
+ const startSoterAuthentication = /* @__PURE__ */ temporarilyNotSupport('startSoterAuthentication');
3032
+ const checkIsSupportSoterAuthentication = /* @__PURE__ */ temporarilyNotSupport('checkIsSupportSoterAuthentication');
3033
+ const checkIsSoterEnrolledInDevice = /* @__PURE__ */ temporarilyNotSupport('checkIsSoterEnrolledInDevice');
3034
+
3035
+ // 订阅消息
3036
+ const requestSubscribeMessage = /* @__PURE__ */ temporarilyNotSupport('requestSubscribeMessage');
3037
+ // 订阅设备消息
3038
+ const requestSubscribeDeviceMessage = /* @__PURE__ */ temporarilyNotSupport('requestSubscribeDeviceMessage');
3039
+
2454
3040
  /**
2455
3041
  * 用户相关API, Harmony ACE API 6
2456
3042
  *
@@ -2499,18 +3085,6 @@ const getUserProfile = temporarilyNotSupport('getUserProfile');
2499
3085
  // })
2500
3086
  // })
2501
3087
  // }
2502
- /**
2503
- * 提前向用户发起授权请求
2504
- */
2505
- const authorize = temporarilyNotSupport('authorize');
2506
- /**
2507
- * 获取用户的当前设置
2508
- */
2509
- const getSetting = temporarilyNotSupport('getSetting');
2510
- /**
2511
- * 调起客户端小程序设置界面
2512
- */
2513
- const openSetting = temporarilyNotSupport('openSetting');
2514
3088
  // function generateUserInfo (hmsAuthInfo) {
2515
3089
  // const userInfo = {
2516
3090
  // nickName: String,
@@ -2527,106 +3101,43 @@ const openSetting = temporarilyNotSupport('openSetting');
2527
3101
  // return userInfo
2528
3102
  // }
2529
3103
 
2530
- const login = temporarilyNotSupport('login');
2531
- const getAccountInfoSync = temporarilyNotSupport('getAccountInfoSync');
2532
- const requestSubscribeMessage = temporarilyNotSupport('requestSubscribeMessage');
3104
+ // 微信运动
3105
+ const shareToWeRun = /* @__PURE__ */ temporarilyNotSupport('shareToWeRun');
3106
+ const getWeRunData = /* @__PURE__ */ temporarilyNotSupport('getWeRunData');
2533
3107
 
2534
- // TODO
2535
- const getCurrentPages = () => [];
2536
- const pageScrollTo = (options) => {
2537
- // eslint-disable-next-line no-async-promise-executor
2538
- return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
2539
- var _a, _b;
2540
- const taro = Current.taro;
2541
- const page = taro.getCurrentInstance().page;
2542
- const res = { errMsg: 'pageScrollTo:ok' };
2543
- const error = { errMsg: 'pageScrollTo:fail' };
2544
- const { scrollTop, selector = '', duration = 300, offsetTop = 0 } = options;
2545
- if (scrollTop && selector) {
2546
- console.warn('"scrollTop" "selector" 建议只设一个值,全部设置会忽略selector');
2547
- }
2548
- let scrollValue = -1;
2549
- let scroller = page.scroller;
2550
- const currentPageNode = getPageScrollerOrNode(page.node, page);
2551
- if (scrollTop || typeof scrollTop === 'number') {
2552
- scrollValue = scrollTop;
2553
- }
2554
- else if (selector) {
2555
- const node = findChildNodeWithDFS(currentPageNode, selector);
2556
- if (!node || !node._instance)
3108
+ // 支付
3109
+ const requestPayment = /* @__PURE__ */ temporarilyNotSupport('requestPayment');
3110
+ const requestPluginPayment = /* @__PURE__ */ temporarilyNotSupport('requestPluginPayment');
3111
+ const requestOrderPayment = /* @__PURE__ */ temporarilyNotSupport('requestOrderPayment');
3112
+
3113
+ const TARO_TABBAR_PAGE_PATH = 'taro_tabbar';
3114
+ function isTabPage(url) {
3115
+ var _a, _b;
3116
+ return (_b = (_a = window.__taroAppConfig.tabBar) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.some(item => item.pagePath === url);
3117
+ }
3118
+ function parseURL(raw = '') {
3119
+ const [urlStr, queryStr = ''] = raw.split('?');
3120
+ const query = queryToJson(queryStr);
3121
+ let url = urlStr.replace(/^\//, '');
3122
+ // 处理相对路径
3123
+ if (url.indexOf('.') === 0) {
3124
+ const page = router.getState();
3125
+ const parts = page.path.split('/');
3126
+ parts.pop();
3127
+ url.split('/').forEach((item) => {
3128
+ if (item === '.') {
2557
3129
  return;
2558
- const instance = node._instance;
2559
- const id = node === null || node === void 0 ? void 0 : node._nid;
2560
- // 获取 areaInfo,需要先调用 setNodeEventCallbackAndTriggerComponentUpdate 更新一次组件并获取组件信息
2561
- yield setNodeEventCallbackAndTriggerComponentUpdate(node, AREA_CHANGE_EVENT_NAME, null, true);
2562
- const { areaInfo } = ((_a = instance === null || instance === void 0 ? void 0 : instance.nodeInfoMap) === null || _a === void 0 ? void 0 : _a[id]) || {};
2563
- let parent = node === null || node === void 0 ? void 0 : node.parentNode;
2564
- while (!!parent && parent !== currentPageNode) {
2565
- if ((_b = parent === null || parent === void 0 ? void 0 : parent._instance) === null || _b === void 0 ? void 0 : _b.scroller) {
2566
- scroller = parent._instance.scroller;
2567
- break;
2568
- }
2569
- parent = parent === null || parent === void 0 ? void 0 : parent.parentNode;
2570
- }
2571
- scroller = getPageScrollerOrNode(scroller, page);
2572
- const { yOffset } = scroller.currentOffset();
2573
- if (areaInfo) {
2574
- scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper(offsetTop, 'px', true);
2575
3130
  }
2576
- }
2577
- const { xOffset } = scroller.currentOffset();
2578
- if (scrollValue === -1) {
2579
- return callAsyncFail(reject, { errMsg: 'pageScrollTo:fail, 请检查传入的 scrollTop 或 selector 是否合法' }, options);
2580
- }
2581
- try {
2582
- scroller.scrollTo({
2583
- xOffset,
2584
- yOffset: scrollValue,
2585
- animation: {
2586
- duration: duration,
2587
- // @ts-ignore
2588
- curve: Curve.Linear
2589
- }
2590
- });
2591
- setTimeout(() => {
2592
- callAsyncSuccess(resolve, res, options);
2593
- }, duration);
2594
- }
2595
- catch (_) {
2596
- callAsyncFail(reject, error, options);
2597
- }
2598
- }));
2599
- };
2600
-
2601
- const launchOptions = {
2602
- path: '',
2603
- query: {},
2604
- scene: 0,
2605
- shareTicket: '',
2606
- referrerInfo: {}
2607
- };
2608
- function initLaunchOptions(options = {}) {
2609
- Object.assign(launchOptions, options);
2610
- }
2611
- eventCenter.once('__taroRouterLaunch', initLaunchOptions);
2612
- const TARO_TABBAR_PAGE_PATH = 'taro_tabbar';
2613
- function isTabPage(url) {
2614
- var _a, _b;
2615
- return (_b = (_a = window.__taroAppConfig.tabBar) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.some(item => item.pagePath === url);
2616
- }
2617
- function parseURL(raw = '') {
2618
- const [urlStr, queryStr = ''] = raw.split('?');
2619
- const query = queryToJson(queryStr);
2620
- let url = urlStr.replace(/^\//, '');
3131
+ item === '..' ? parts.pop() : parts.push(item);
3132
+ });
3133
+ url = parts.join('/');
3134
+ }
2621
3135
  if (isTabPage(url)) {
2622
3136
  query.$page = url;
2623
3137
  url = TARO_TABBAR_PAGE_PATH;
2624
3138
  }
2625
3139
  return [url, query];
2626
3140
  }
2627
- // 生命周期
2628
- const getLaunchOptionsSync = () => launchOptions;
2629
- const getEnterOptionsSync = () => launchOptions;
2630
3141
  const getRouterFunc = (method) => {
2631
3142
  const methodName = method === 'navigateTo' ? 'pushUrl' : 'replaceUrl';
2632
3143
  return function (options) {
@@ -2707,231 +3218,204 @@ const getState = () => {
2707
3218
  return router.getState();
2708
3219
  };
2709
3220
 
2710
- const preferencesPromise = Current.contextPromise
2711
- .then((context) => {
2712
- return bundleManager
2713
- .getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION)
2714
- .then(data => {
2715
- return dataPreferences
2716
- .getPreferences(context, `${data.appInfo.uid}Store`);
2717
- });
2718
- })
2719
- .catch((error) => {
2720
- hilog.error(0x0000, 'TaroFailedTag', 'Failed to load the storage. Cause: %{public}s', error.code ? JSON.stringify(error) : error.message || error);
3221
+ // 转发
3222
+ /** 更新转发属性 */
3223
+ const updateShareMenu = /* @__PURE__ */ temporarilyNotSupport('updateShareMenu');
3224
+ /** 显示当前页面的转发按钮 */
3225
+ const showShareMenu = /* @__PURE__ */ temporarilyNotSupport('showShareMenu');
3226
+ /** 打开分享图片弹窗,可以将图片发送给朋友、收藏或下载 */
3227
+ const showShareImageMenu = /* @__PURE__ */ temporarilyNotSupport('showShareImageMenu');
3228
+ /** 转发视频到聊天 */
3229
+ const shareVideoMessage = /* @__PURE__ */ temporarilyNotSupport('shareVideoMessage');
3230
+ /** 转发文件到聊天 */
3231
+ const shareFileMessage = /* @__PURE__ */ temporarilyNotSupport('shareFileMessage');
3232
+ /** 监听用户点击右上角菜单的「复制链接」按钮时触发的事件 */
3233
+ const onCopyUrl = /* @__PURE__ */ temporarilyNotSupport('onCopyUrl');
3234
+ /** 移除用户点击右上角菜单的「复制链接」按钮时触发的事件的监听函数 */
3235
+ const offCopyUrl = /* @__PURE__ */ temporarilyNotSupport('offCopyUrl');
3236
+ /** 隐藏当前页面的转发按钮 */
3237
+ const hideShareMenu = /* @__PURE__ */ temporarilyNotSupport('hideShareMenu');
3238
+ /** 获取转发详细信息 */
3239
+ const getShareInfo = /* @__PURE__ */ temporarilyNotSupport('getShareInfo');
3240
+ /** 验证私密消息。 */
3241
+ const authPrivateMessage = /* @__PURE__ */ permanentlyNotSupport('authPrivateMessage');
3242
+
3243
+ // 周期性更新
3244
+ const setBackgroundFetchToken = /* @__PURE__ */ temporarilyNotSupport('setBackgroundFetchToken');
3245
+ const onBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('onBackgroundFetchData');
3246
+ const getBackgroundFetchToken = /* @__PURE__ */ temporarilyNotSupport('getBackgroundFetchToken');
3247
+ const getBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('getBackgroundFetchData');
3248
+
3249
+ // 周期性更新
3250
+ const createCacheManager = /* @__PURE__ */ temporarilyNotSupport('createCacheManager');
3251
+
3252
+ /**
3253
+ * 从API Version 6开始,该模块不再维护,可以使用模块@ohos.data.storage。在API Version 9后,推荐使用新模块@ohos.data.preferences。
3254
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references-V3/js-apis-data-preferences-0000001427745052-V3
3255
+ */
3256
+ let context;
3257
+ let kvManager;
3258
+ let kvStore;
3259
+ let kvStorePromise;
3260
+ Current.contextPromise.then((ctx) => {
3261
+ context = ctx;
3262
+ const kvManagerConfig = {
3263
+ context: context,
3264
+ bundleName: 'com.example.taro'
3265
+ };
3266
+ try {
3267
+ // 创建KVManager实例
3268
+ kvManager = distributedKVStore.createKVManager(kvManagerConfig);
3269
+ // 继续创建获取数据库
3270
+ const options = {
3271
+ createIfMissing: true,
3272
+ encrypt: false,
3273
+ backup: false,
3274
+ autoSync: false,
3275
+ // kvStoreType不填时,默认创建多设备协同数据库
3276
+ kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
3277
+ // 多设备协同数据库:kvStoreType: distributedKVStore.KVStoreType.DEVICE_COLLABORATION,
3278
+ securityLevel: distributedKVStore.SecurityLevel.S1
3279
+ };
3280
+ const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
3281
+ kvStorePromise = new Promise(resolve => {
3282
+ kvManager.getKVStore(`${data.appInfo.uid}Store`, options, (err, store) => {
3283
+ if (err) {
3284
+ console.error(`Failed to get KVStore: Code:${err.code},message:${err.message}`);
3285
+ return;
3286
+ }
3287
+ kvStore = store;
3288
+ // 请确保获取到键值数据库实例后,再进行相关数据操作
3289
+ resolve();
3290
+ });
3291
+ });
3292
+ }
3293
+ catch (e) {
3294
+ console.error(`Failed to create KVManager. Code:${e.code},message:${e.message}`);
3295
+ }
3296
+ return context;
2721
3297
  });
2722
- function getItem(key) {
2723
- return __awaiter(this, void 0, void 0, function* () {
2724
- try {
2725
- const preferences = yield preferencesPromise;
2726
- const item = yield preferences.get(key, null);
2727
- return { result: true, data: item };
2728
- }
2729
- catch (error) {
2730
- return { result: false };
2731
- }
2732
- });
2733
- }
2734
3298
  const storageSchema = {
2735
3299
  key: 'String'
2736
3300
  };
2737
- function getStorage(options) {
2738
- return new Promise((resolve, reject) => {
2739
- try {
2740
- validateParams('getStorage', options, storageSchema);
3301
+ function checkContextExist(api, isAsync = false) {
3302
+ if (!context) {
3303
+ const message = `${api} 调用失败,Taro 不支持过早地调用 ${api},请确保页面已经渲染完成再调用此 API`;
3304
+ if (isAsync) {
3305
+ return {
3306
+ isExist: false,
3307
+ error: Promise.reject(new Error(message))
3308
+ };
2741
3309
  }
2742
- catch (error) {
2743
- const res = { errMsg: error.message };
2744
- return callAsyncFail(reject, res, options);
3310
+ else {
3311
+ console.warn(message);
3312
+ return {
3313
+ isExist: false,
3314
+ };
2745
3315
  }
2746
- getItem(options.key).then(({ result, data }) => {
2747
- const res = { errMsg: 'getStorage:ok' };
2748
- if (result) {
2749
- res.data = data;
2750
- callAsyncSuccess(resolve, res, options);
3316
+ }
3317
+ return {
3318
+ isExist: true,
3319
+ };
3320
+ }
3321
+ function getStorage(options) {
3322
+ const name = 'getStorage';
3323
+ const { isExist, error } = checkContextExist(name, true);
3324
+ if (!isExist) {
3325
+ return error;
3326
+ }
3327
+ const { key, success, fail, complete } = options || {};
3328
+ const handle = new MethodHandler({ name, success, fail, complete });
3329
+ return new Promise((resolve, reject) => {
3330
+ kvStorePromise.then(() => {
3331
+ try {
3332
+ validateParams(name, options, storageSchema);
2751
3333
  }
2752
- else {
2753
- res.errMsg = 'getStorage:fail data not found';
2754
- callAsyncFail(reject, res, options);
3334
+ catch (error) {
3335
+ const res = { errMsg: error.message };
3336
+ return handle.fail(res, { resolve, reject });
2755
3337
  }
3338
+ kvStore = kvStore;
3339
+ kvStore.get(key, (err, data) => {
3340
+ if (err) {
3341
+ handle.fail({ errMsg: `Failed to get data. Code:${err.code},message:${err.message}` }, { resolve, reject });
3342
+ return;
3343
+ }
3344
+ handle.success({ data }, { resolve, reject });
3345
+ });
2756
3346
  });
2757
3347
  });
2758
3348
  }
2759
3349
  function setStorage(options) {
3350
+ const name = 'setStorage';
3351
+ const { isExist, error } = checkContextExist(name, true);
3352
+ if (!isExist) {
3353
+ return error;
3354
+ }
3355
+ const { key, data, success, fail, complete } = options || {};
3356
+ const handle = new MethodHandler({ name, success, fail, complete });
2760
3357
  return new Promise((resolve, reject) => {
2761
- try {
2762
- validateParams('setStorage', options, storageSchema);
2763
- }
2764
- catch (error) {
2765
- const res = { errMsg: error.message };
2766
- return callAsyncFail(reject, res, options);
2767
- }
2768
- const { key, data } = options;
2769
- const res = { errMsg: 'setStorage:ok' };
2770
- preferencesPromise.then((preferences) => __awaiter(this, void 0, void 0, function* () {
2771
- yield preferences.put(key, data);
2772
- yield preferences.flush();
2773
- callAsyncSuccess(resolve, res, options);
2774
- }));
3358
+ kvStorePromise.then(() => {
3359
+ try {
3360
+ validateParams(name, options, storageSchema);
3361
+ }
3362
+ catch (error) {
3363
+ const res = { errMsg: error.message };
3364
+ return handle.fail(res, { resolve, reject });
3365
+ }
3366
+ kvStore = kvStore;
3367
+ kvStore.put(key, data, (err) => {
3368
+ if (err) {
3369
+ handle.fail({ errMsg: `Failed to put data. Code:${err.code},message:${err.message}` }, { resolve, reject });
3370
+ return;
3371
+ }
3372
+ handle.success({}, { resolve, reject });
3373
+ });
3374
+ });
2775
3375
  });
2776
3376
  }
2777
3377
  function removeStorage(options) {
3378
+ const name = 'removeStorage';
3379
+ const { isExist, error } = checkContextExist(name, true);
3380
+ if (!isExist) {
3381
+ return error;
3382
+ }
3383
+ const { key, success, fail, complete } = options || {};
3384
+ const handle = new MethodHandler({ name, success, fail, complete });
2778
3385
  return new Promise((resolve, reject) => {
2779
- try {
2780
- validateParams('removeStorage', options, storageSchema);
2781
- }
2782
- catch (error) {
2783
- const res = { errMsg: error.message };
2784
- return callAsyncFail(reject, res, options);
2785
- }
2786
- const { key } = options;
2787
- preferencesPromise.then((preferences) => __awaiter(this, void 0, void 0, function* () {
2788
- yield preferences.delete(key);
2789
- yield preferences.flush();
2790
- const res = { errMsg: 'removeStorage:ok' };
2791
- callAsyncSuccess(resolve, res, options);
2792
- }));
2793
- });
2794
- }
2795
- function clearStorage(options) {
2796
- return new Promise(resolve => {
2797
- preferencesPromise.then((preferences) => __awaiter(this, void 0, void 0, function* () {
2798
- yield preferences.clear();
2799
- yield preferences.flush();
2800
- const res = { errMsg: 'clearStorage:ok' };
2801
- callAsyncSuccess(resolve, res, options);
2802
- }));
3386
+ kvStorePromise.then(() => {
3387
+ try {
3388
+ validateParams(name, options, storageSchema);
3389
+ }
3390
+ catch (error) {
3391
+ const res = { errMsg: error.message };
3392
+ return handle.fail(res, { resolve, reject });
3393
+ }
3394
+ kvStore = kvStore;
3395
+ kvStore.delete(key, (err) => {
3396
+ if (err) {
3397
+ handle.fail({ errMsg: `Failed to delete data. Code:${err.code},message:${err.message}` }, { resolve, reject });
3398
+ return;
3399
+ }
3400
+ handle.success({}, { resolve, reject });
3401
+ });
3402
+ });
2803
3403
  });
2804
3404
  }
3405
+ const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync');
3406
+ const getStorageInfo = temporarilyNotSupport('getStorageInfo');
3407
+ const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL');
3408
+ const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL');
3409
+ const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStorageSync');
3410
+ const batchSetStorage = /* @__PURE__ */ temporarilyNotSupport('batchSetStorage');
3411
+ const batchGetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchGetStorageSync');
3412
+ const batchGetStorage = /* @__PURE__ */ temporarilyNotSupport('batchGetStorage');
3413
+ const clearStorage = temporarilyNotSupport('clearStorage');
2805
3414
  const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage');
2806
3415
  const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage');
2807
3416
  const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage');
2808
3417
  const removeStorageSync = temporarilyNotSupport('removeStorageSync', 'removeStorage');
2809
3418
 
2810
- // eslint-disable-next-line import/no-duplicates
2811
- const toggleTabBar = function (type) {
2812
- return function (options) {
2813
- return new Promise((resolve, reject) => {
2814
- var _a, _b;
2815
- const taro = Current.taro;
2816
- const page = taro.getCurrentInstance().page;
2817
- const currentData = ((_a = page._data) === null || _a === void 0 ? void 0 : _a.taroTabBar) || page.tabBar;
2818
- const res = { errMsg: `${type}TabBar:ok` };
2819
- const error = { errMsg: `${type}TabBar:fail not TabBar page` };
2820
- if (!currentData) {
2821
- callAsyncFail(reject, error, options);
2822
- }
2823
- else {
2824
- const isShow = type === 'show';
2825
- const event = isShow ? '__taroShowTabBar' : '__taroHideTabBar';
2826
- eventCenter.trigger(event, {
2827
- animation: options === null || options === void 0 ? void 0 : options.animation,
2828
- });
2829
- (_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'isShowTaroTabBar', isShow);
2830
- callAsyncSuccess(resolve, res, options);
2831
- }
2832
- });
2833
- };
2834
- };
2835
- const showTabBar = toggleTabBar('show');
2836
- const hideTabBar = toggleTabBar('hide');
2837
- const setTabBarStyle = function (options = {}) {
2838
- return new Promise((resolve, reject) => {
2839
- var _a, _b;
2840
- const taro = Current.taro;
2841
- const page = taro.getCurrentInstance().page;
2842
- const currentData = ((_a = page._data) === null || _a === void 0 ? void 0 : _a.taroTabBar) || page.tabBar;
2843
- const res = { errMsg: 'setTabBarStyle:ok' };
2844
- const error = { errMsg: 'setTabBarStyle:fail not TabBar page' };
2845
- if (!currentData) {
2846
- callAsyncFail(reject, error, options);
2847
- }
2848
- else {
2849
- const data = Object.assign({}, currentData);
2850
- if (options.color)
2851
- data.color = options.color;
2852
- if (options.selectedColor)
2853
- data.selectedColor = options.selectedColor;
2854
- if (options.backgroundColor)
2855
- data.backgroundColor = options.backgroundColor;
2856
- if (options.borderStyle)
2857
- data.borderStyle = options.borderStyle;
2858
- eventCenter.trigger('__taroSetTabBarStyle', options);
2859
- (_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'taroTabBar', data);
2860
- callAsyncSuccess(resolve, res, options);
2861
- }
2862
- });
2863
- };
2864
- const setTabBarItem = function (options) {
2865
- return new Promise((resolve, reject) => {
2866
- var _a, _b;
2867
- const taro = Current.taro;
2868
- const page = taro.getCurrentInstance().page;
2869
- const currentData = ((_a = page._data) === null || _a === void 0 ? void 0 : _a.taroTabBar) || page.tabBar;
2870
- const res = { errMsg: 'setTabBarItem:ok' };
2871
- const error = { errMsg: 'setTabBarItem:fail not TabBar page' };
2872
- if (!currentData) {
2873
- callAsyncFail(reject, error, options);
2874
- }
2875
- else {
2876
- const index = options.index;
2877
- const item = Object.assign({}, currentData.list[index]);
2878
- if (options.text)
2879
- item.text = options.text;
2880
- if (options.iconPath)
2881
- item.iconPath = options.iconPath;
2882
- if (options.selectedIconPath)
2883
- item.selectedIconPath = options.selectedIconPath;
2884
- const list = [
2885
- ...currentData.list.slice(0, index),
2886
- item,
2887
- ...currentData.list.slice(index + 1)
2888
- ];
2889
- const data = Object.assign({}, currentData, { list });
2890
- eventCenter.trigger('__taroSetTabBarItem', options);
2891
- (_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'taroTabBar', data);
2892
- callAsyncSuccess(resolve, res, options);
2893
- }
2894
- });
2895
- };
2896
- function showTabBarRedDot(options) {
2897
- const res = { errMsg: 'showTabBarRedDot:ok' };
2898
- return new Promise((resolve) => {
2899
- eventCenter.trigger('__taroShowTabBarRedDotHandler', {
2900
- index: (options === null || options === void 0 ? void 0 : options.index) || 0,
2901
- });
2902
- callAsyncSuccess(resolve, res, options);
2903
- });
2904
- }
2905
- function hideTabBarRedDot(options) {
2906
- const res = { errMsg: 'hideTabBarRedDot:ok' };
2907
- return new Promise((resolve) => {
2908
- eventCenter.trigger('__taroHideTabBarRedDotHandler', {
2909
- index: (options === null || options === void 0 ? void 0 : options.index) || 0,
2910
- });
2911
- callAsyncSuccess(resolve, res, options);
2912
- });
2913
- }
2914
- function setTabBarBadge(options) {
2915
- const res = { errMsg: 'setTabBarBadge:ok' };
2916
- return new Promise((resolve) => {
2917
- const text = (options === null || options === void 0 ? void 0 : options.text) || '';
2918
- eventCenter.trigger('__taroSetTabBarBadge', {
2919
- index: (options === null || options === void 0 ? void 0 : options.index) || 0,
2920
- text: text.replace(/[\u0391-\uFFE5]/g, 'aa').length > 4 ? '...' : text,
2921
- });
2922
- callAsyncSuccess(resolve, res, options);
2923
- });
2924
- }
2925
- function removeTabBarBadge(options) {
2926
- const res = { errMsg: 'removeTabBarBadge:ok' };
2927
- return new Promise((resolve) => {
2928
- eventCenter.trigger('__taroRemoveTabBarBadge', {
2929
- index: (options === null || options === void 0 ? void 0 : options.index) || 0,
2930
- });
2931
- callAsyncSuccess(resolve, res, options);
2932
- });
2933
- }
2934
-
2935
3419
  class Animation {
2936
3420
  constructor({ duration = 400, delay = 0, timingFunction = 'linear', transformOrigin = '50% 50% 0', unit = 'px' } = {}) {
2937
3421
  // 组合动画
@@ -2963,6 +3447,9 @@ class Animation {
2963
3447
  transformOrigin,
2964
3448
  rule: Object.assign({}, this.rule)
2965
3449
  });
3450
+ if (this.rule.transform) {
3451
+ this.rule.transform = Object.assign({}, this.rule.transform);
3452
+ }
2966
3453
  return this;
2967
3454
  }
2968
3455
  matrix(a, b, c, d, tx, ty) {
@@ -2974,75 +3461,120 @@ class Animation {
2974
3461
  return this;
2975
3462
  }
2976
3463
  rotate(angle) {
2977
- this.rule.rotate = { x: 0, y: 0, z: 1, angle };
3464
+ if (!this.rule.transform) {
3465
+ this.rule.transform = {};
3466
+ }
3467
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
2978
3468
  return this;
2979
3469
  }
2980
3470
  rotate3d(x, y, z, angle) {
2981
- this.rule.rotate = { x, y, z, angle };
3471
+ if (!this.rule.transform) {
3472
+ this.rule.transform = {};
3473
+ }
3474
+ this.rule.transform.Rotate = { x, y, z, angle };
2982
3475
  return this;
2983
3476
  }
2984
3477
  rotateX(angle) {
2985
- this.rule.rotate = { x: 1, y: 0, z: 0, angle };
3478
+ if (!this.rule.transform) {
3479
+ this.rule.transform = {};
3480
+ }
3481
+ this.rule.transform.Rotate = { x: 1, y: 0, z: 0, angle };
2986
3482
  return this;
2987
3483
  }
2988
3484
  rotateY(angle) {
2989
- this.rule.rotate = { x: 0, y: 1, z: 0, angle };
3485
+ if (!this.rule.transform) {
3486
+ this.rule.transform = {};
3487
+ }
3488
+ this.rule.transform.Rotate = { x: 0, y: 1, z: 0, angle };
2990
3489
  return this;
2991
3490
  }
2992
3491
  rotateZ(angle) {
2993
- this.rule.rotate = { x: 0, y: 0, z: 1, angle };
3492
+ if (!this.rule.transform) {
3493
+ this.rule.transform = {};
3494
+ }
3495
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
2994
3496
  return this;
2995
3497
  }
2996
3498
  scale(sx, sy) {
2997
- this.rule.scale = { x: sx, y: sy };
3499
+ if (!this.rule.transform) {
3500
+ this.rule.transform = {};
3501
+ }
3502
+ this.rule.transform.Scale = { x: sx, y: isUndefined(sy) ? sx : sy };
2998
3503
  return this;
2999
3504
  }
3000
3505
  scale3d(sx, sy, sz) {
3001
- this.rule.scale = { x: sx, y: sy, z: sz };
3506
+ if (!this.rule.transform) {
3507
+ this.rule.transform = {};
3508
+ }
3509
+ this.rule.transform.Scale = { x: sx, y: sy, z: sz };
3002
3510
  return this;
3003
3511
  }
3004
3512
  scaleX(scale) {
3005
- this.rule.scale = { x: scale };
3513
+ if (!this.rule.transform) {
3514
+ this.rule.transform = {};
3515
+ }
3516
+ this.rule.transform.Scale = { x: scale };
3006
3517
  return this;
3007
3518
  }
3008
3519
  scaleY(scale) {
3009
- this.rule.scale = { y: scale };
3520
+ if (!this.rule.transform) {
3521
+ this.rule.transform = {};
3522
+ }
3523
+ this.rule.transform.Scale = { y: scale };
3010
3524
  return this;
3011
3525
  }
3012
3526
  scaleZ(scale) {
3013
- this.rule.scale = { z: scale };
3527
+ if (!this.rule.transform) {
3528
+ this.rule.transform = {};
3529
+ }
3530
+ this.rule.transform.Scale = { z: scale };
3014
3531
  return this;
3015
3532
  }
3016
3533
  skew(ax, ay) {
3017
- this.rule.skew = { x: ax, y: ay };
3534
+ temporarilyNotSupport('animation.skew:' + `${ax}, ${ay}`)(ax, ay);
3018
3535
  return this;
3019
3536
  }
3020
3537
  skewX(angle) {
3021
- this.rule.skew = { x: angle };
3538
+ temporarilyNotSupport('animation.skewX:' + angle)(angle);
3022
3539
  return this;
3023
3540
  }
3024
3541
  skewY(angle) {
3025
- this.rule.skew = { y: angle };
3542
+ temporarilyNotSupport('animation.skewY:' + angle)(angle);
3026
3543
  return this;
3027
3544
  }
3028
3545
  translate(tx, ty) {
3029
- this.rule.translate = { x: tx, y: ty };
3546
+ if (!this.rule.transform) {
3547
+ this.rule.transform = {};
3548
+ }
3549
+ this.rule.transform.Translate = { x: tx, y: ty };
3030
3550
  return this;
3031
3551
  }
3032
3552
  translate3d(tx, ty, tz) {
3033
- this.rule.translate = { x: tx, y: ty, z: tz };
3553
+ if (!this.rule.transform) {
3554
+ this.rule.transform = {};
3555
+ }
3556
+ this.rule.transform.Translate = { x: tx, y: ty, z: tz };
3034
3557
  return this;
3035
3558
  }
3036
3559
  translateX(translation) {
3037
- this.rule.translate = { x: translation };
3560
+ if (!this.rule.transform) {
3561
+ this.rule.transform = {};
3562
+ }
3563
+ this.rule.transform.Translate = { x: translation };
3038
3564
  return this;
3039
3565
  }
3040
3566
  translateY(translation) {
3041
- this.rule.translate = { y: translation };
3567
+ if (!this.rule.transform) {
3568
+ this.rule.transform = {};
3569
+ }
3570
+ this.rule.transform.Translate = { y: translation };
3042
3571
  return this;
3043
3572
  }
3044
3573
  translateZ(translation) {
3045
- this.rule.translate = { z: translation };
3574
+ if (!this.rule.transform) {
3575
+ this.rule.transform = {};
3576
+ }
3577
+ this.rule.transform.Translate = { z: translation };
3046
3578
  return this;
3047
3579
  }
3048
3580
  opacity(value) {
@@ -3054,15 +3586,15 @@ class Animation {
3054
3586
  return this;
3055
3587
  }
3056
3588
  width(value) {
3057
- this.rule.size = Object.assign(Object.assign({}, this.rule.size), { width: value });
3589
+ this.rule.width = value;
3058
3590
  return this;
3059
3591
  }
3060
3592
  height(value) {
3061
- this.rule.size = Object.assign(Object.assign({}, this.rule.size), { height: value });
3593
+ this.rule.height = value;
3062
3594
  return this;
3063
3595
  }
3064
3596
  left(value) {
3065
- temporarilyNotSupport('animation.left:' + value)(value);
3597
+ this.rule.left = value;
3066
3598
  return this;
3067
3599
  }
3068
3600
  right(value) {
@@ -3070,7 +3602,7 @@ class Animation {
3070
3602
  return this;
3071
3603
  }
3072
3604
  top(value) {
3073
- temporarilyNotSupport('animation.top:' + value)(value);
3605
+ this.rule.top = value;
3074
3606
  return this;
3075
3607
  }
3076
3608
  bottom(value) {
@@ -3079,33 +3611,33 @@ class Animation {
3079
3611
  }
3080
3612
  }
3081
3613
 
3082
- // import window from '@ohos.window'
3083
- // import { Current } from '@tarojs/runtime'
3084
- // import { callAsyncFail, callAsyncSuccess } from '../utils'
3085
- // const windowClassPromise = (Current as any).contextPromise
3086
- // .then(context => {
3087
- // return window.getTopWindow(context)
3088
- // })
3614
+ const createAnimation = (option) => {
3615
+ return new Animation(option);
3616
+ };
3617
+
3618
+ const setBackgroundTextStyle = /* @__PURE__ */ temporarilyNotSupport('setBackgroundTextStyle');
3089
3619
  function setBackgroundColor(options) {
3090
3620
  const { success, fail, complete } = options || {};
3091
3621
  const handle = new MethodHandler({ name: 'setBackgroundColor', success, fail, complete });
3092
3622
  return new Promise((resolve, reject) => {
3093
3623
  eventCenter.trigger('__taroPageStyle', {
3094
- backgroundColor: options.backgroundColor || options.backgroundColorTop || options.backgroundColorBottom,
3624
+ backgroundColor: options.backgroundColorBottom || options.backgroundColor,
3625
+ backgroundColorContext: options.backgroundColorTop || options.backgroundColor
3095
3626
  });
3096
3627
  return handle.success({}, { resolve, reject });
3097
- // windowClassPromise.then(windowClass => {
3098
- // windowClass.setBackgroundColor(color).then(() => {
3099
- // const res = { errMsg: 'setBackgroundColor:ok' }
3100
- // callAsyncSuccess(resolve, res, options)
3101
- // }, (error) => {
3102
- // const res = { errMsg: 'setBackgroundColor:fail' + error }
3103
- // callAsyncFail(reject, res, options)
3104
- // })
3105
- // })
3106
3628
  });
3107
3629
  }
3108
3630
 
3631
+ // 自定义组件
3632
+ const nextTick = (cb, ctx) => {
3633
+ setTimeout(function () {
3634
+ ctx ? cb.call(ctx) : cb();
3635
+ }, 1);
3636
+ };
3637
+
3638
+ // 字体
3639
+ const loadFontFace = /* @__PURE__ */ temporarilyNotSupport('getMenuButtonBoundingClientRect');
3640
+
3109
3641
  const resCallback = (res) => {
3110
3642
  return { errMsg: `${res}:ok` };
3111
3643
  };
@@ -3129,10 +3661,11 @@ function showToast(options) {
3129
3661
  const res = { errMsg: error.message };
3130
3662
  return callAsyncFail(reject, res, options);
3131
3663
  }
3132
- prompt.showToast({
3664
+ promptAction.showToast({
3133
3665
  message: options.title,
3134
3666
  duration: options.duration,
3135
- bottom: options.bottom
3667
+ bottom: options.bottom,
3668
+ showMode: 1 // 设置弹窗显示模式,显示在应用之上。
3136
3669
  });
3137
3670
  callAsyncSuccess(resolve, resCallback('showToast'), options);
3138
3671
  });
@@ -3162,25 +3695,24 @@ function showModal(options) {
3162
3695
  color: confirmColor
3163
3696
  });
3164
3697
  }
3165
- return new Promise(resolve => {
3698
+ return new Promise((resolve, reject) => {
3166
3699
  const modalOptions = {
3167
3700
  title,
3168
3701
  message: content,
3169
3702
  buttons: buttons,
3170
- success: (data) => {
3171
- if (data.index === 1 || !showCancel) {
3172
- callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: true, cancel: false, content: null }), options);
3173
- }
3174
- else {
3175
- callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: false, cancel: true }), options);
3176
- }
3177
- },
3178
- // 鸿蒙没有失败方法,只有取消
3179
- cancel: (_) => {
3703
+ };
3704
+ promptAction.showDialog(modalOptions, (error, data) => {
3705
+ if (error) {
3706
+ const res = { errMsg: error };
3707
+ callAsyncFail(reject, res, options);
3708
+ }
3709
+ if (data.index === 0 && showCancel) {
3180
3710
  callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: false, cancel: true }), options);
3181
3711
  }
3182
- };
3183
- prompt.showDialog(modalOptions);
3712
+ else {
3713
+ callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: true, cancel: false, content: null }), options);
3714
+ }
3715
+ });
3184
3716
  });
3185
3717
  }
3186
3718
  const showActionSheetSchema = {
@@ -3211,62 +3743,87 @@ function showActionSheet(options) {
3211
3743
  });
3212
3744
  const actionSheetOptions = {
3213
3745
  title,
3214
- buttons,
3215
- success: (data) => {
3216
- callAsyncSuccess(resolve, Object.assign(Object.assign({}, data), resCallback('showActionSheet')), options);
3217
- },
3218
- // 取消方法,并非失败
3219
- fail: (data) => {
3220
- callAsyncFail(reject, Object.assign(Object.assign({}, data), { errMsg: data.errMsg.replace('showActionMenu', 'showActionSheet') }), options);
3221
- }
3746
+ buttons
3222
3747
  };
3223
- prompt.showActionMenu(actionSheetOptions);
3224
- });
3225
- }
3226
- function hideToast(options) {
3227
- return new Promise(resolve => {
3228
- prompt.showToast({
3229
- message: '关闭中',
3230
- duration: 10,
3231
- bottom: '9999px'
3748
+ promptAction.showActionMenu(actionSheetOptions, (error, data) => {
3749
+ var _a;
3750
+ if (error) {
3751
+ callAsyncFail(reject, Object.assign(Object.assign({}, data), { errMsg: (_a = data.errMsg) === null || _a === void 0 ? void 0 : _a.replace('showActionMenu', 'showActionSheet') }), options);
3752
+ }
3753
+ callAsyncSuccess(resolve, Object.assign(Object.assign({}, data), resCallback('showActionSheet')), options);
3232
3754
  });
3233
- callAsyncSuccess(resolve, resCallback('hideToast'), options);
3234
3755
  });
3235
3756
  }
3757
+ const hideToast = /* @__PURE__ */ temporarilyNotSupport('hideToast');
3236
3758
  const showLoading = temporarilyNotSupport('showLoading');
3237
3759
  const hideLoading = temporarilyNotSupport('hideLoading');
3760
+ const enableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('enableAlertBeforeUnload');
3761
+ const disableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('disableAlertBeforeUnload');
3762
+
3763
+ // 菜单
3764
+ const getMenuButtonBoundingClientRect = /* @__PURE__ */ temporarilyNotSupport('getMenuButtonBoundingClientRect');
3238
3765
 
3239
3766
  const setNavigationBarTitle = function (options) {
3240
- return new Promise(resolve => {
3241
- var _a;
3242
- const taro = Current.taro;
3243
- const page = taro.getCurrentInstance().page;
3244
- const res = { errMsg: 'setNavigationBarTitle:ok' };
3245
- (_a = page.$set) === null || _a === void 0 ? void 0 : _a.call(page, 'taroNavBar.title', options.title);
3246
- callAsyncSuccess(resolve, res, options);
3767
+ const { success, fail, complete } = options || {};
3768
+ const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete });
3769
+ return new Promise((resolve, reject) => {
3770
+ eventCenter.trigger('__taroNavigationStyle', {
3771
+ title: options.title,
3772
+ });
3773
+ return handle.success({}, { resolve, reject });
3247
3774
  });
3248
3775
  };
3249
3776
  const setNavigationBarColor = function (options) {
3250
- return new Promise(resolve => {
3251
- var _a, _b;
3252
- const taro = Current.taro;
3253
- const page = taro.getCurrentInstance().page;
3254
- const { frontColor, backgroundColor } = options;
3255
- const res = { errMsg: 'setNavigationBarColor:ok' };
3256
- (_a = page.$set) === null || _a === void 0 ? void 0 : _a.call(page, 'taroNavBar.textStyle', frontColor);
3257
- (_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'taroNavBar.background', backgroundColor);
3258
- callAsyncSuccess(resolve, res, options);
3777
+ const { success, fail, complete } = options || {};
3778
+ const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete });
3779
+ return new Promise((resolve, reject) => {
3780
+ eventCenter.trigger('__taroNavigationStyle', {
3781
+ animation: options.animation,
3782
+ backgroundColor: options.backgroundColor,
3783
+ frontColor: options.frontColor,
3784
+ });
3785
+ return handle.success({}, { resolve, reject });
3786
+ });
3787
+ };
3788
+ const showNavigationBarLoading = function (options) {
3789
+ const { success, fail, complete } = options || {};
3790
+ const handle = new MethodHandler({ name: 'showNavigationBarLoading', success, fail, complete });
3791
+ return new Promise((resolve, reject) => {
3792
+ eventCenter.trigger('__taroNavigationStyle', {
3793
+ loading: true,
3794
+ });
3795
+ return handle.success({}, { resolve, reject });
3796
+ });
3797
+ };
3798
+ const hideNavigationBarLoading = function (options) {
3799
+ const { success, fail, complete } = options || {};
3800
+ const handle = new MethodHandler({ name: 'hideNavigationBarLoading', success, fail, complete });
3801
+ return new Promise((resolve, reject) => {
3802
+ eventCenter.trigger('__taroNavigationStyle', {
3803
+ loading: false,
3804
+ });
3805
+ return handle.success({}, { resolve, reject });
3806
+ });
3807
+ };
3808
+ const hideHomeButton = function (options) {
3809
+ const { success, fail, complete } = options || {};
3810
+ const handle = new MethodHandler({ name: 'hideHomeButton', success, fail, complete });
3811
+ return new Promise((resolve, reject) => {
3812
+ eventCenter.trigger('__taroNavigationStyle', {
3813
+ home: false,
3814
+ });
3815
+ return handle.success({}, { resolve, reject });
3259
3816
  });
3260
3817
  };
3261
- const showNavigationBarLoading = temporarilyNotSupport('showNavigationBarLoading');
3262
- const hideNavigationBarLoading = temporarilyNotSupport('hideNavigationBarLoading');
3263
- const hideHomeButton = temporarilyNotSupport('hideHomeButton');
3264
3818
 
3265
3819
  const startPullDownRefresh = function (options) {
3266
- return new Promise(resolve => {
3820
+ return new Promise((resolve, reject) => {
3267
3821
  var _a;
3268
3822
  const taro = Current.taro;
3269
3823
  const page = taro.getCurrentInstance().page;
3824
+ if (!page) {
3825
+ return callAsyncFail(reject, { errMsg: 'stopPullDownRefresh:fail' }, options);
3826
+ }
3270
3827
  if (page.isRefreshing instanceof Array) {
3271
3828
  const index = page.tabBarCurrentIndex || 0;
3272
3829
  page.isRefreshing[index] = true;
@@ -3280,10 +3837,13 @@ const startPullDownRefresh = function (options) {
3280
3837
  });
3281
3838
  };
3282
3839
  const stopPullDownRefresh = function (options) {
3283
- return new Promise(resolve => {
3840
+ return new Promise((resolve, reject) => {
3284
3841
  var _a;
3285
3842
  const taro = Current.taro;
3286
3843
  const page = taro.getCurrentInstance().page;
3844
+ if (!page) {
3845
+ return callAsyncFail(reject, { errMsg: 'stopPullDownRefresh:fail' }, options);
3846
+ }
3287
3847
  if (page.isRefreshing instanceof Array) {
3288
3848
  const index = page.tabBarCurrentIndex || 0;
3289
3849
  page.isRefreshing[index] = false;
@@ -3297,12 +3857,223 @@ const stopPullDownRefresh = function (options) {
3297
3857
  });
3298
3858
  };
3299
3859
 
3300
- const createAnimation = (option) => {
3301
- return new Animation(option);
3860
+ /**
3861
+ * 将页面滚动到目标位置
3862
+ */
3863
+ const pageScrollTo = (options) => {
3864
+ const { scrollTop, selector = '', duration = 300, offsetTop = 0, success, fail, complete } = options || {};
3865
+ const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete });
3866
+ // eslint-disable-next-line no-async-promise-executor
3867
+ return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
3868
+ if (scrollTop === undefined && !selector) {
3869
+ return handle.fail({
3870
+ errMsg: 'scrollTop" 或 "selector" 需要其之一'
3871
+ }, { resolve, reject });
3872
+ }
3873
+ if (scrollTop && selector) {
3874
+ console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector');
3875
+ }
3876
+ const taro = Current.taro;
3877
+ const page = taro.getCurrentInstance().page;
3878
+ let scrollValue = -1;
3879
+ let scroller = getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.scroller, page);
3880
+ const currentPageNode = getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
3881
+ if (scrollTop || typeof scrollTop === 'number') {
3882
+ scrollValue = scrollTop;
3883
+ }
3884
+ else if (selector) {
3885
+ const node = findChildNodeWithDFS(currentPageNode, selector);
3886
+ if (!node)
3887
+ return;
3888
+ // 获取 areaInfo,需要先调用 setNodeEventCallbackAndTriggerComponentUpdate 更新一次组件并获取组件信息
3889
+ yield setNodeEventCallbackAndTriggerComponentUpdate(node, AREA_CHANGE_EVENT_NAME, null, true);
3890
+ const { areaInfo } = node._nodeInfo || {};
3891
+ let parent = node === null || node === void 0 ? void 0 : node.parentNode;
3892
+ while (!!parent && parent !== currentPageNode) {
3893
+ if (parent === null || parent === void 0 ? void 0 : parent.scroller) {
3894
+ scroller = parent.scroller;
3895
+ break;
3896
+ }
3897
+ parent = parent === null || parent === void 0 ? void 0 : parent.parentNode;
3898
+ }
3899
+ scroller = getPageScrollerOrNode(scroller, page);
3900
+ const { yOffset } = scroller.currentOffset();
3901
+ if (areaInfo) {
3902
+ scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper$1(offsetTop, 'px', true);
3903
+ }
3904
+ }
3905
+ if (!scroller || scrollValue === -1) {
3906
+ return handle.fail({
3907
+ errMsg: '请检查传入的 scrollTop 或 selector 是否合法'
3908
+ }, { resolve, reject });
3909
+ }
3910
+ const { xOffset } = scroller.currentOffset();
3911
+ try {
3912
+ scroller.scrollTo({
3913
+ xOffset,
3914
+ yOffset: scrollValue,
3915
+ animation: {
3916
+ duration: duration,
3917
+ // @ts-ignore
3918
+ curve: Curve.Linear
3919
+ }
3920
+ });
3921
+ setTimeout(() => {
3922
+ handle.success({}, { resolve, reject });
3923
+ }, duration);
3924
+ }
3925
+ catch (err) {
3926
+ return handle.fail({
3927
+ errMsg: err.message
3928
+ }, { resolve, reject });
3929
+ }
3930
+ }));
3302
3931
  };
3303
- const getMenuButtonBoundingClientRect = temporarilyNotSupport('getMenuButtonBoundingClientRect');
3304
3932
 
3305
- // @ts-ignore
3933
+ // 置顶
3934
+ const setTopBarText = /* @__PURE__ */ temporarilyNotSupport('setTopBarText');
3935
+
3936
+ const toggleTabBar = function (type) {
3937
+ return function (options) {
3938
+ return new Promise((resolve, reject) => {
3939
+ var _a, _b;
3940
+ const taro = Current.taro;
3941
+ const page = taro.getCurrentInstance().page;
3942
+ const currentData = ((_a = page === null || page === void 0 ? void 0 : page._data) === null || _a === void 0 ? void 0 : _a.taroTabBar) || (page === null || page === void 0 ? void 0 : page.tabBar);
3943
+ const res = { errMsg: `${type}TabBar:ok` };
3944
+ const error = { errMsg: `${type}TabBar:fail not TabBar page` };
3945
+ if (!currentData) {
3946
+ callAsyncFail(reject, error, options);
3947
+ }
3948
+ else {
3949
+ const isShow = type === 'show';
3950
+ const event = isShow ? '__taroShowTabBar' : '__taroHideTabBar';
3951
+ eventCenter.trigger(event, {
3952
+ animation: options === null || options === void 0 ? void 0 : options.animation,
3953
+ });
3954
+ (_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'isShowTaroTabBar', isShow);
3955
+ callAsyncSuccess(resolve, res, options);
3956
+ }
3957
+ });
3958
+ };
3959
+ };
3960
+ const showTabBar = toggleTabBar('show');
3961
+ const hideTabBar = toggleTabBar('hide');
3962
+ const setTabBarStyle = function (options = {}) {
3963
+ return new Promise((resolve, reject) => {
3964
+ var _a, _b;
3965
+ const taro = Current.taro;
3966
+ const page = taro.getCurrentInstance().page;
3967
+ const currentData = ((_a = page === null || page === void 0 ? void 0 : page._data) === null || _a === void 0 ? void 0 : _a.taroTabBar) || (page === null || page === void 0 ? void 0 : page.tabBar);
3968
+ const res = { errMsg: 'setTabBarStyle:ok' };
3969
+ const error = { errMsg: 'setTabBarStyle:fail not TabBar page' };
3970
+ if (!currentData) {
3971
+ callAsyncFail(reject, error, options);
3972
+ }
3973
+ else {
3974
+ const data = Object.assign({}, currentData);
3975
+ if (options.color)
3976
+ data.color = options.color;
3977
+ if (options.selectedColor)
3978
+ data.selectedColor = options.selectedColor;
3979
+ if (options.backgroundColor)
3980
+ data.backgroundColor = options.backgroundColor;
3981
+ if (options.borderStyle)
3982
+ data.borderStyle = options.borderStyle;
3983
+ eventCenter.trigger('__taroSetTabBarStyle', options);
3984
+ (_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'taroTabBar', data);
3985
+ callAsyncSuccess(resolve, res, options);
3986
+ }
3987
+ });
3988
+ };
3989
+ const setTabBarItem = function (options) {
3990
+ return new Promise((resolve, reject) => {
3991
+ var _a, _b;
3992
+ const taro = Current.taro;
3993
+ const page = taro.getCurrentInstance().page;
3994
+ const currentData = ((_a = page === null || page === void 0 ? void 0 : page._data) === null || _a === void 0 ? void 0 : _a.taroTabBar) || (page === null || page === void 0 ? void 0 : page.tabBar);
3995
+ const res = { errMsg: 'setTabBarItem:ok' };
3996
+ const error = { errMsg: 'setTabBarItem:fail not TabBar page' };
3997
+ if (!currentData) {
3998
+ callAsyncFail(reject, error, options);
3999
+ }
4000
+ else {
4001
+ const index = options.index;
4002
+ const item = Object.assign({}, currentData.list[index]);
4003
+ if (options.text)
4004
+ item.text = options.text;
4005
+ if (options.iconPath)
4006
+ item.iconPath = options.iconPath;
4007
+ if (options.selectedIconPath)
4008
+ item.selectedIconPath = options.selectedIconPath;
4009
+ const list = [
4010
+ ...currentData.list.slice(0, index),
4011
+ item,
4012
+ ...currentData.list.slice(index + 1)
4013
+ ];
4014
+ const data = Object.assign({}, currentData, { list });
4015
+ eventCenter.trigger('__taroSetTabBarItem', options);
4016
+ (_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'taroTabBar', data);
4017
+ callAsyncSuccess(resolve, res, options);
4018
+ }
4019
+ });
4020
+ };
4021
+ function showTabBarRedDot(options) {
4022
+ const res = { errMsg: 'showTabBarRedDot:ok' };
4023
+ return new Promise((resolve) => {
4024
+ eventCenter.trigger('__taroShowTabBarRedDotHandler', {
4025
+ index: (options === null || options === void 0 ? void 0 : options.index) || 0,
4026
+ });
4027
+ callAsyncSuccess(resolve, res, options);
4028
+ });
4029
+ }
4030
+ function hideTabBarRedDot(options) {
4031
+ const res = { errMsg: 'hideTabBarRedDot:ok' };
4032
+ return new Promise((resolve) => {
4033
+ eventCenter.trigger('__taroHideTabBarRedDotHandler', {
4034
+ index: (options === null || options === void 0 ? void 0 : options.index) || 0,
4035
+ });
4036
+ callAsyncSuccess(resolve, res, options);
4037
+ });
4038
+ }
4039
+ function setTabBarBadge(options) {
4040
+ const res = { errMsg: 'setTabBarBadge:ok' };
4041
+ return new Promise((resolve) => {
4042
+ const text = (options === null || options === void 0 ? void 0 : options.text) || '';
4043
+ eventCenter.trigger('__taroSetTabBarBadge', {
4044
+ index: (options === null || options === void 0 ? void 0 : options.index) || 0,
4045
+ text: text.replace(/[\u0391-\uFFE5]/g, 'aa').length > 4 ? '...' : text,
4046
+ });
4047
+ callAsyncSuccess(resolve, res, options);
4048
+ });
4049
+ }
4050
+ function removeTabBarBadge(options) {
4051
+ const res = { errMsg: 'removeTabBarBadge:ok' };
4052
+ return new Promise((resolve) => {
4053
+ eventCenter.trigger('__taroRemoveTabBarBadge', {
4054
+ index: (options === null || options === void 0 ? void 0 : options.index) || 0,
4055
+ });
4056
+ callAsyncSuccess(resolve, res, options);
4057
+ });
4058
+ }
4059
+
4060
+ /**
4061
+ * 设置窗口大小,该接口仅适用于 PC 平台,使用细则请参见指南
4062
+ */
4063
+ const setWindowSize = /* @__PURE__ */ temporarilyNotSupport('setWindowSize');
4064
+ /**
4065
+ * 监听窗口尺寸变化事件
4066
+ */
4067
+ const onWindowResize = /* @__PURE__ */ temporarilyNotSupport('onWindowResize');
4068
+ /**
4069
+ * 取消监听窗口尺寸变化事件
4070
+ */
4071
+ const offWindowResize = /* @__PURE__ */ temporarilyNotSupport('offWindowResize');
4072
+ const checkIsPictureInPictureActive = /* @__PURE__ */ temporarilyNotSupport('checkIsPictureInPictureActive');
4073
+
4074
+ // Worker
4075
+ const createWorker = /* @__PURE__ */ temporarilyNotSupport('createWorker');
4076
+
3306
4077
  class IntersectionObserver {
3307
4078
  constructor(component, options = {}) {
3308
4079
  // 选项
@@ -3313,34 +4084,31 @@ class IntersectionObserver {
3313
4084
  };
3314
4085
  const taro = Current.taro;
3315
4086
  const page = taro.getCurrentInstance().page;
3316
- const currentPage = getPageScrollerOrNode(page.node, page);
3317
- this._component = component || currentPage;
4087
+ this._component = component || getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
3318
4088
  Object.assign(this._options, options);
3319
4089
  }
3320
4090
  disconnect() {
3321
- var _a, _b, _c;
3322
- if (this._observerNodes) {
4091
+ if (this._observerNodes && this._component) {
3323
4092
  if (this._observerNodes instanceof Array) {
3324
4093
  this._observerNodes.forEach((n) => {
3325
- var _a, _b, _c;
3326
4094
  disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME);
3327
- if (n._instance) {
3328
- // @ts-ignore
3329
- (_c = (_b = (_a = n._instance) === null || _a === void 0 ? void 0 : _a.nodeInfoMap) === null || _b === void 0 ? void 0 : _b[n._nid]) === null || _c === void 0 ? void 0 : _c.thresholds = null;
3330
- }
4095
+ // @ts-ignore
4096
+ n._nodeInfo.thresholds = null;
3331
4097
  });
3332
4098
  }
3333
4099
  else {
3334
4100
  disconnectEvent(this._observerNodes, VISIBLE_CHANGE_EVENT_NAME);
3335
4101
  // @ts-ignore
3336
- if (this._observerNodes._instance) {
4102
+ if (this._observerNodes._nodeInfo) {
3337
4103
  // @ts-ignore
3338
- (_c = (_b = (_a = this._observerNodes._instance) === null || _a === void 0 ? void 0 : _a.nodeInfoMap) === null || _b === void 0 ? void 0 : _b[this._observerNodes._nid]) === null || _c === void 0 ? void 0 : _c.thresholds = null;
4104
+ this._observerNodes._nodeInfo.thresholds = null;
3339
4105
  }
3340
4106
  }
3341
4107
  }
3342
4108
  }
3343
4109
  observe(targetSelector, callback) {
4110
+ if (!this._component)
4111
+ return;
3344
4112
  const { observeAll, thresholds } = this._options;
3345
4113
  const node = findChildNodeWithDFS(this._component, targetSelector, observeAll);
3346
4114
  this._observerNodes = node;
@@ -3348,28 +4116,25 @@ class IntersectionObserver {
3348
4116
  if (node instanceof Array) {
3349
4117
  node.forEach(n => {
3350
4118
  // @ts-ignore
3351
- n.awaitAppear.then(() => {
3352
- var _a, _b, _c;
3353
- // @ts-ignore
3354
- (_c = (_b = (_a = n._instance) === null || _a === void 0 ? void 0 : _a.nodeInfoMap) === null || _b === void 0 ? void 0 : _b[n._nid]) === null || _c === void 0 ? void 0 : _c.thresholds = thresholds;
3355
- setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3356
- callback(this.handleResult(isVisible, currentRatio));
3357
- });
4119
+ n._nodeInfo.thresholds = thresholds;
4120
+ setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
4121
+ callback(this.handleResult(isVisible, currentRatio, n));
3358
4122
  });
3359
4123
  });
3360
4124
  }
3361
4125
  else {
3362
4126
  // @ts-ignore
3363
- node.awaitAppear.then(() => {
3364
- var _a, _b, _c;
3365
- // @ts-ignore
3366
- (_c = (_b = (_a = node._instance) === null || _a === void 0 ? void 0 : _a.nodeInfoMap) === null || _b === void 0 ? void 0 : _b[node._nid]) === null || _c === void 0 ? void 0 : _c.thresholds = thresholds;
3367
- setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3368
- callback(this.handleResult(isVisible, currentRatio));
3369
- });
4127
+ node._nodeInfo.thresholds = thresholds;
4128
+ setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
4129
+ callback(this.handleResult(isVisible, currentRatio, node));
3370
4130
  });
3371
4131
  }
3372
4132
  }
4133
+ else {
4134
+ callback({
4135
+ errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
4136
+ });
4137
+ }
3373
4138
  }
3374
4139
  relativeTo() {
3375
4140
  temporarilyNotSupport('relativeTo')();
@@ -3380,8 +4145,10 @@ class IntersectionObserver {
3380
4145
  return this;
3381
4146
  }
3382
4147
  // @ts-ignore
3383
- handleResult(isVisible, currentRatio) {
4148
+ handleResult(isVisible, currentRatio, node) {
3384
4149
  const result = {
4150
+ id: node.id,
4151
+ dataset: node.dataset,
3385
4152
  intersectionRatio: currentRatio,
3386
4153
  // TODO 未做,等待能拿到element的info信息
3387
4154
  boundingClientRect: {
@@ -3512,7 +4279,6 @@ function parseHandler(selector, selectAll) {
3512
4279
  }
3513
4280
  // 从 TaroNode 里找到对应的 fields 内容
3514
4281
  function filter(fields, dom) {
3515
- var _a, _b;
3516
4282
  if (!dom)
3517
4283
  return null;
3518
4284
  const { id,
@@ -3549,8 +4315,7 @@ function filter(fields, dom) {
3549
4315
  // TODO harmony dataset
3550
4316
  // if (dataset) res.dataset = Object.assign({}, dom.dataset)
3551
4317
  if (rect || size) {
3552
- const id = dom === null || dom === void 0 ? void 0 : dom._nid;
3553
- const { areaInfo } = ((_b = (_a = dom === null || dom === void 0 ? void 0 : dom._instance) === null || _a === void 0 ? void 0 : _a.nodeInfoMap) === null || _b === void 0 ? void 0 : _b[id]) || {};
4318
+ const { areaInfo } = (dom === null || dom === void 0 ? void 0 : dom._nodeInfo) || {};
3554
4319
  if (areaInfo) {
3555
4320
  if (rect) {
3556
4321
  res.top = vp2px(areaInfo.globalPosition.y);
@@ -3565,7 +4330,7 @@ function filter(fields, dom) {
3565
4330
  }
3566
4331
  }
3567
4332
  if (scrollOffset) {
3568
- const scroller = dom._instance.scroller;
4333
+ const scroller = dom.scroller;
3569
4334
  if (scroller) {
3570
4335
  const { xOffset, yOffset } = scroller.currentOffset();
3571
4336
  res.scrollLeft = vp2px(xOffset);
@@ -3591,32 +4356,45 @@ function filter(fields, dom) {
3591
4356
  }
3592
4357
  function querySelector(selector, selectAll) {
3593
4358
  if (typeof selector === 'string') {
3594
- return parseHandler(selector, selectAll);
4359
+ return selector.split(',').reduce((prev, current) => {
4360
+ const item = current.trim();
4361
+ return prev.concat(parseHandler(item, selectAll));
4362
+ }, []);
3595
4363
  }
3596
- return null;
4364
+ return [];
3597
4365
  }
3598
4366
  function queryBat(queue, cb) {
3599
4367
  const result = [];
3600
4368
  const taro = Current.taro;
3601
4369
  const page = taro.getCurrentInstance().page;
3602
- const element = getPageScrollerOrNode(page.node, page);
3603
- if (element == null)
4370
+ const element = getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
4371
+ if (!element)
3604
4372
  return null;
3605
4373
  arr = [];
3606
4374
  traversalDFSDom(element);
3607
- queue.forEach(item => {
4375
+ queue.forEach((item) => {
3608
4376
  const { selector, single, fields } = item;
3609
- const nodeList = querySelector(selector, !single);
3610
- result.push(nodeList.map(dom => {
4377
+ if (single) {
4378
+ const dom = querySelector(selector, !single)[0];
3611
4379
  // eslint-disable-next-line no-async-promise-executor
3612
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
4380
+ result.push(new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
3613
4381
  yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
3614
4382
  resolve(filter(fields, dom));
4383
+ })));
4384
+ }
4385
+ else {
4386
+ const nodeList = querySelector(selector, !single);
4387
+ result.push(nodeList.map(dom => {
4388
+ // eslint-disable-next-line no-async-promise-executor
4389
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
4390
+ yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
4391
+ resolve(filter(fields, dom));
4392
+ }));
3615
4393
  }));
3616
- }));
4394
+ }
3617
4395
  });
3618
4396
  Promise.all(result.map(item => {
3619
- return Promise.all(item);
4397
+ return item instanceof Array ? Promise.all(item) : item;
3620
4398
  })).then(data => {
3621
4399
  cb(data);
3622
4400
  });
@@ -3687,109 +4465,337 @@ const createSelectorQuery = () => {
3687
4465
  const createIntersectionObserver = (component, options) => {
3688
4466
  return new IntersectionObserver(component, options);
3689
4467
  };
4468
+ const createMediaQueryObserver = /* @__PURE__ */ temporarilyNotSupport('createMediaQueryObserver');
3690
4469
 
3691
4470
  var apis = /*#__PURE__*/Object.freeze({
3692
4471
  __proto__: null,
4472
+ Current: Current,
3693
4473
  ENV_TYPE: ENV_TYPE,
3694
4474
  Events: Events,
3695
4475
  History: History,
4476
+ IntersectionObserver: IntersectionObserver,
4477
+ addCard: addCard,
4478
+ addFileToFavorites: addFileToFavorites,
4479
+ addPhoneCalendar: addPhoneCalendar,
4480
+ addPhoneContact: addPhoneContact,
4481
+ addPhoneRepeatCalendar: addPhoneRepeatCalendar,
4482
+ addVideoToFavorites: addVideoToFavorites,
4483
+ arrayBufferToBase64: arrayBufferToBase64,
4484
+ authPrivateMessage: authPrivateMessage,
3696
4485
  authorize: authorize,
4486
+ authorizeForMiniProgram: authorizeForMiniProgram,
4487
+ base64ToArrayBuffer: base64ToArrayBuffer,
4488
+ batchGetStorage: batchGetStorage,
4489
+ batchGetStorageSync: batchGetStorageSync,
4490
+ batchSetStorage: batchSetStorage,
4491
+ batchSetStorageSync: batchSetStorageSync,
4492
+ canIUse: canIUse,
4493
+ canvasGetImageData: canvasGetImageData,
4494
+ canvasPutImageData: canvasPutImageData,
4495
+ canvasToTempFilePath: canvasToTempFilePath,
4496
+ checkIsAddedToMyMiniProgram: checkIsAddedToMyMiniProgram,
4497
+ checkIsOpenAccessibility: checkIsOpenAccessibility,
4498
+ checkIsPictureInPictureActive: checkIsPictureInPictureActive,
4499
+ checkIsSoterEnrolledInDevice: checkIsSoterEnrolledInDevice,
4500
+ checkIsSupportFacialRecognition: checkIsSupportFacialRecognition,
4501
+ checkIsSupportSoterAuthentication: checkIsSupportSoterAuthentication,
4502
+ checkSession: checkSession,
4503
+ chooseAddress: chooseAddress,
4504
+ chooseContact: chooseContact,
3697
4505
  chooseImage: chooseImage,
4506
+ chooseInvoice: chooseInvoice,
4507
+ chooseInvoiceTitle: chooseInvoiceTitle,
4508
+ chooseLicensePlate: chooseLicensePlate,
4509
+ chooseLocation: chooseLocation,
3698
4510
  chooseMedia: chooseMedia,
4511
+ choosePoi: choosePoi,
3699
4512
  chooseVideo: chooseVideo,
3700
4513
  clearStorage: clearStorage,
3701
4514
  clearStorageSync: clearStorageSync,
4515
+ closeBLEConnection: closeBLEConnection,
4516
+ closeBluetoothAdapter: closeBluetoothAdapter,
3702
4517
  compressImage: compressImage,
4518
+ compressVideo: compressVideo,
3703
4519
  connectSocket: connectSocket,
4520
+ connectWifi: connectWifi,
3704
4521
  createAnimation: createAnimation,
4522
+ createAudioContext: createAudioContext,
4523
+ createBLEConnection: createBLEConnection,
4524
+ createBLEPeripheralServer: createBLEPeripheralServer,
4525
+ createBufferURL: createBufferURL,
4526
+ createCacheManager: createCacheManager,
4527
+ createCameraContext: createCameraContext,
4528
+ createCanvasContext: createCanvasContext,
4529
+ createInnerAudioContext: createInnerAudioContext,
3705
4530
  createIntersectionObserver: createIntersectionObserver,
4531
+ createLivePlayerContext: createLivePlayerContext,
4532
+ createLivePusherContext: createLivePusherContext,
4533
+ createMapContext: createMapContext,
4534
+ createMediaAudioPlayer: createMediaAudioPlayer,
4535
+ createMediaContainer: createMediaContainer,
4536
+ createMediaQueryObserver: createMediaQueryObserver,
4537
+ createMediaRecorder: createMediaRecorder,
4538
+ createOffscreenCanvas: createOffscreenCanvas,
3706
4539
  createSelectorQuery: createSelectorQuery,
4540
+ createTCPSocket: createTCPSocket,
4541
+ createUDPSocket: createUDPSocket,
4542
+ createVideoContext: createVideoContext,
4543
+ createVideoDecoder: createVideoDecoder,
4544
+ createWebAudioContext: createWebAudioContext,
4545
+ createWorker: createWorker,
4546
+ disableAlertBeforeUnload: disableAlertBeforeUnload,
3707
4547
  downloadFile: downloadFile,
4548
+ enableAlertBeforeUnload: enableAlertBeforeUnload,
3708
4549
  eventCenter: eventCenter,
3709
4550
  exitMiniProgram: exitMiniProgram,
4551
+ exitVoIPChat: exitVoIPChat,
4552
+ faceVerifyForPay: faceVerifyForPay,
3710
4553
  getAccountInfoSync: getAccountInfoSync,
4554
+ getAvailableAudioSources: getAvailableAudioSources,
4555
+ getBLEDeviceCharacteristics: getBLEDeviceCharacteristics,
4556
+ getBLEDeviceRSSI: getBLEDeviceRSSI,
4557
+ getBLEDeviceServices: getBLEDeviceServices,
4558
+ getBLEMTU: getBLEMTU,
4559
+ getBackgroundAudioManager: getBackgroundAudioManager,
4560
+ getBackgroundAudioPlayerState: getBackgroundAudioPlayerState,
4561
+ getBackgroundFetchData: getBackgroundFetchData,
4562
+ getBackgroundFetchToken: getBackgroundFetchToken,
3711
4563
  getBatteryInfo: getBatteryInfo,
3712
4564
  getBatteryInfoSync: getBatteryInfoSync,
4565
+ getBeacons: getBeacons,
4566
+ getBluetoothAdapterState: getBluetoothAdapterState,
4567
+ getBluetoothDevices: getBluetoothDevices,
4568
+ getChannelsLiveInfo: getChannelsLiveInfo,
4569
+ getChannelsLiveNoticeInfo: getChannelsLiveNoticeInfo,
4570
+ getChannelsShareKey: getChannelsShareKey,
3713
4571
  getClipboardData: getClipboardData,
4572
+ getConnectedBluetoothDevices: getConnectedBluetoothDevices,
4573
+ getConnectedWifi: getConnectedWifi,
3714
4574
  getCurrentInstance: getCurrentInstance,
3715
4575
  getCurrentPages: getCurrentPages,
4576
+ getDeviceVoIPList: getDeviceVoIPList,
3716
4577
  getEnterOptionsSync: getEnterOptionsSync,
3717
4578
  getEnv: getEnv,
4579
+ getExptInfoSync: getExptInfoSync,
4580
+ getExtConfig: getExtConfig,
4581
+ getExtConfigSync: getExtConfigSync,
3718
4582
  getFileInfo: getFileInfo,
3719
4583
  getFileSystemManager: getFileSystemManager,
4584
+ getFuzzyLocation: getFuzzyLocation,
4585
+ getGroupEnterInfo: getGroupEnterInfo,
4586
+ getHCEState: getHCEState,
3720
4587
  getImageInfo: getImageInfo,
3721
4588
  getLaunchOptionsSync: getLaunchOptionsSync,
3722
4589
  getLength: getLength,
3723
4590
  getLocalIPAddress: getLocalIPAddress,
3724
4591
  getLocation: getLocation,
4592
+ getLogManager: getLogManager,
3725
4593
  getMenuButtonBoundingClientRect: getMenuButtonBoundingClientRect,
4594
+ getNFCAdapter: getNFCAdapter,
3726
4595
  getNetworkType: getNetworkType,
4596
+ getPerformance: getPerformance,
4597
+ getPrivacySetting: getPrivacySetting,
4598
+ getRandomValues: getRandomValues,
4599
+ getRealtimeLogManager: getRealtimeLogManager,
4600
+ getRecorderManager: getRecorderManager,
3727
4601
  getSavedFileInfo: getSavedFileInfo,
3728
4602
  getSavedFileList: getSavedFileList,
3729
4603
  getScreenBrightness: getScreenBrightness,
3730
4604
  getScreenRecordingState: getScreenRecordingState,
3731
4605
  getSelectedTextRange: getSelectedTextRange,
3732
4606
  getSetting: getSetting,
4607
+ getShareInfo: getShareInfo,
3733
4608
  getState: getState,
3734
4609
  getStorage: getStorage,
4610
+ getStorageInfo: getStorageInfo,
4611
+ getStorageInfoSync: getStorageInfoSync,
3735
4612
  getStorageSync: getStorageSync,
3736
4613
  getSystemInfo: getSystemInfo,
3737
4614
  getSystemInfoSync: getSystemInfoSync,
3738
4615
  getUpdateManager: getUpdateManager,
4616
+ getUserCryptoManager: getUserCryptoManager,
3739
4617
  getUserInfo: getUserInfo,
3740
4618
  getUserProfile: getUserProfile,
4619
+ getVideoInfo: getVideoInfo,
4620
+ getWeRunData: getWeRunData,
4621
+ getWifiList: getWifiList,
3741
4622
  hideHomeButton: hideHomeButton,
3742
4623
  hideKeyboard: hideKeyboard,
3743
4624
  hideLoading: hideLoading,
3744
4625
  hideNavigationBarLoading: hideNavigationBarLoading,
4626
+ hideShareMenu: hideShareMenu,
3745
4627
  hideTabBar: hideTabBar,
3746
4628
  hideTabBarRedDot: hideTabBarRedDot,
3747
4629
  hideToast: hideToast,
4630
+ isBluetoothDevicePaired: isBluetoothDevicePaired,
4631
+ join1v1Chat: join1v1Chat,
4632
+ joinVoIPChat: joinVoIPChat,
4633
+ loadFontFace: loadFontFace,
3748
4634
  login: login,
4635
+ makeBluetoothPair: makeBluetoothPair,
3749
4636
  makePhoneCall: makePhoneCall,
3750
4637
  navigateBack: navigateBack,
3751
4638
  navigateBackMiniProgram: navigateBackMiniProgram,
3752
4639
  navigateTo: navigateTo,
3753
4640
  navigateToMiniProgram: navigateToMiniProgram,
3754
4641
  nextTick: nextTick,
4642
+ notifyBLECharacteristicValueChange: notifyBLECharacteristicValueChange,
3755
4643
  offAccelerometerChange: offAccelerometerChange,
4644
+ offAppHide: offAppHide,
4645
+ offAppShow: offAppShow,
4646
+ offAudioInterruptionBegin: offAudioInterruptionBegin,
4647
+ offAudioInterruptionEnd: offAudioInterruptionEnd,
4648
+ offBLECharacteristicValueChange: offBLECharacteristicValueChange,
4649
+ offBLEConnectionStateChange: offBLEConnectionStateChange,
4650
+ offBLEMTUChange: offBLEMTUChange,
4651
+ offBLEPeripheralConnectionStateChanged: offBLEPeripheralConnectionStateChanged,
4652
+ offBeaconServiceChange: offBeaconServiceChange,
4653
+ offBeaconUpdate: offBeaconUpdate,
4654
+ offBluetoothAdapterStateChange: offBluetoothAdapterStateChange,
4655
+ offBluetoothDeviceFound: offBluetoothDeviceFound,
4656
+ offCompassChange: offCompassChange,
4657
+ offCopyUrl: offCopyUrl,
4658
+ offDeviceMotionChange: offDeviceMotionChange,
4659
+ offError: offError,
4660
+ offGetWifiList: offGetWifiList,
4661
+ offGyroscopeChange: offGyroscopeChange,
4662
+ offHCEMessage: offHCEMessage,
3756
4663
  offKeyboardHeightChange: offKeyboardHeightChange,
4664
+ offLazyLoadError: offLazyLoadError,
4665
+ offLocalServiceDiscoveryStop: offLocalServiceDiscoveryStop,
4666
+ offLocalServiceFound: offLocalServiceFound,
4667
+ offLocalServiceLost: offLocalServiceLost,
4668
+ offLocalServiceResolveFail: offLocalServiceResolveFail,
3757
4669
  offLocationChange: offLocationChange,
4670
+ offLocationChangeError: offLocationChangeError,
3758
4671
  offMemoryWarning: offMemoryWarning,
3759
4672
  offNetworkStatusChange: offNetworkStatusChange,
3760
4673
  offNetworkWeakChange: offNetworkWeakChange,
4674
+ offPageNotFound: offPageNotFound,
3761
4675
  offScreenRecordingStateChanged: offScreenRecordingStateChanged,
4676
+ offThemeChange: offThemeChange,
4677
+ offUnhandledRejection: offUnhandledRejection,
3762
4678
  offUserCaptureScreen: offUserCaptureScreen,
4679
+ offVoIPChatInterrupted: offVoIPChatInterrupted,
4680
+ offVoIPChatMembersChanged: offVoIPChatMembersChanged,
4681
+ offVoIPChatSpeakersChanged: offVoIPChatSpeakersChanged,
4682
+ offVoIPChatStateChanged: offVoIPChatStateChanged,
4683
+ offVoIPVideoMembersChanged: offVoIPVideoMembersChanged,
4684
+ offWifiConnected: offWifiConnected,
4685
+ offWifiConnectedWithPartialInfo: offWifiConnectedWithPartialInfo,
4686
+ offWindowResize: offWindowResize,
3763
4687
  onAccelerometerChange: onAccelerometerChange,
4688
+ onAppHide: onAppHide,
4689
+ onAppShow: onAppShow,
4690
+ onAudioInterruptionBegin: onAudioInterruptionBegin,
4691
+ onAudioInterruptionEnd: onAudioInterruptionEnd,
4692
+ onBLECharacteristicValueChange: onBLECharacteristicValueChange,
4693
+ onBLEConnectionStateChange: onBLEConnectionStateChange,
4694
+ onBLEMTUChange: onBLEMTUChange,
4695
+ onBLEPeripheralConnectionStateChanged: onBLEPeripheralConnectionStateChanged,
4696
+ onBackgroundAudioPause: onBackgroundAudioPause,
4697
+ onBackgroundAudioPlay: onBackgroundAudioPlay,
4698
+ onBackgroundAudioStop: onBackgroundAudioStop,
4699
+ onBackgroundFetchData: onBackgroundFetchData,
4700
+ onBeaconServiceChange: onBeaconServiceChange,
4701
+ onBeaconUpdate: onBeaconUpdate,
4702
+ onBluetoothAdapterStateChange: onBluetoothAdapterStateChange,
4703
+ onBluetoothDeviceFound: onBluetoothDeviceFound,
4704
+ onCompassChange: onCompassChange,
4705
+ onCopyUrl: onCopyUrl,
4706
+ onDeviceMotionChange: onDeviceMotionChange,
4707
+ onError: onError,
4708
+ onGetWifiList: onGetWifiList,
4709
+ onGyroscopeChange: onGyroscopeChange,
4710
+ onHCEMessage: onHCEMessage,
3764
4711
  onKeyboardHeightChange: onKeyboardHeightChange,
4712
+ onLazyLoadError: onLazyLoadError,
4713
+ onLocalServiceDiscoveryStop: onLocalServiceDiscoveryStop,
4714
+ onLocalServiceFound: onLocalServiceFound,
4715
+ onLocalServiceLost: onLocalServiceLost,
4716
+ onLocalServiceResolveFail: onLocalServiceResolveFail,
3765
4717
  onLocationChange: onLocationChange,
4718
+ onLocationChangeError: onLocationChangeError,
3766
4719
  onMemoryWarning: onMemoryWarning,
4720
+ onNeedPrivacyAuthorization: onNeedPrivacyAuthorization,
3767
4721
  onNetworkStatusChange: onNetworkStatusChange,
3768
4722
  onNetworkWeakChange: onNetworkWeakChange,
4723
+ onPageNotFound: onPageNotFound,
3769
4724
  onScreenRecordingStateChanged: onScreenRecordingStateChanged,
4725
+ onThemeChange: onThemeChange,
4726
+ onUnhandledRejection: onUnhandledRejection,
3770
4727
  onUserCaptureScreen: onUserCaptureScreen,
4728
+ onVoIPChatInterrupted: onVoIPChatInterrupted,
4729
+ onVoIPChatMembersChanged: onVoIPChatMembersChanged,
4730
+ onVoIPChatSpeakersChanged: onVoIPChatSpeakersChanged,
4731
+ onVoIPChatStateChanged: onVoIPChatStateChanged,
4732
+ onVoIPVideoMembersChanged: onVoIPVideoMembersChanged,
4733
+ onWifiConnected: onWifiConnected,
4734
+ onWifiConnectedWithPartialInfo: onWifiConnectedWithPartialInfo,
4735
+ onWindowResize: onWindowResize,
4736
+ openBluetoothAdapter: openBluetoothAdapter,
3771
4737
  openBusinessView: openBusinessView,
4738
+ openCard: openCard,
4739
+ openChannelsActivity: openChannelsActivity,
4740
+ openChannelsEvent: openChannelsEvent,
4741
+ openChannelsLive: openChannelsLive,
4742
+ openChannelsUserProfile: openChannelsUserProfile,
4743
+ openCustomerServiceChat: openCustomerServiceChat,
3772
4744
  openDocument: openDocument,
3773
4745
  openEmbeddedMiniProgram: openEmbeddedMiniProgram,
4746
+ openLocation: openLocation,
4747
+ openPrivacyContract: openPrivacyContract,
3774
4748
  openSetting: openSetting,
4749
+ openVideoEditor: openVideoEditor,
3775
4750
  pageScrollTo: pageScrollTo,
4751
+ pauseBackgroundAudio: pauseBackgroundAudio,
4752
+ pauseVoice: pauseVoice,
4753
+ playBackgroundAudio: playBackgroundAudio,
4754
+ playVoice: playVoice,
4755
+ pluginLogin: pluginLogin,
4756
+ preloadAssets: preloadAssets,
4757
+ preloadSkylineView: preloadSkylineView,
4758
+ preloadWebview: preloadWebview,
3776
4759
  previewImage: previewImage,
3777
4760
  previewMedia: previewMedia,
3778
4761
  reLaunch: reLaunch,
4762
+ readBLECharacteristicValue: readBLECharacteristicValue,
3779
4763
  redirectTo: redirectTo,
3780
4764
  removeSavedFile: removeSavedFile,
3781
4765
  removeStorage: removeStorage,
3782
4766
  removeStorageSync: removeStorageSync,
3783
4767
  removeTabBarBadge: removeTabBarBadge,
4768
+ reportAnalytics: reportAnalytics,
4769
+ reportEvent: reportEvent,
4770
+ reportMonitor: reportMonitor,
4771
+ reportPerformance: reportPerformance,
3784
4772
  request: request,
4773
+ requestDeviceVoIP: requestDeviceVoIP,
4774
+ requestOrderPayment: requestOrderPayment,
4775
+ requestPayment: requestPayment,
4776
+ requestPluginPayment: requestPluginPayment,
4777
+ requestSubscribeDeviceMessage: requestSubscribeDeviceMessage,
3785
4778
  requestSubscribeMessage: requestSubscribeMessage,
3786
4779
  requirePlugin: requirePlugin$1,
4780
+ requirePrivacyAuthorize: requirePrivacyAuthorize,
4781
+ reserveChannelsLive: reserveChannelsLive,
4782
+ revokeBufferURL: revokeBufferURL,
3787
4783
  saveFile: saveFile,
3788
4784
  saveFileToDisk: saveFileToDisk,
3789
4785
  saveImageToPhotosAlbum: saveImageToPhotosAlbum,
3790
4786
  saveVideoToPhotosAlbum: saveVideoToPhotosAlbum,
4787
+ scanCode: scanCode,
4788
+ seekBackgroundAudio: seekBackgroundAudio,
4789
+ sendHCEMessage: sendHCEMessage,
4790
+ sendSms: sendSms,
4791
+ setBLEMTU: setBLEMTU,
3791
4792
  setBackgroundColor: setBackgroundColor,
4793
+ setBackgroundFetchToken: setBackgroundFetchToken,
4794
+ setBackgroundTextStyle: setBackgroundTextStyle,
3792
4795
  setClipboardData: setClipboardData,
4796
+ setEnable1v1Chat: setEnable1v1Chat,
4797
+ setEnableDebug: setEnableDebug,
4798
+ setInnerAudioOption: setInnerAudioOption,
3793
4799
  setKeepScreenOn: setKeepScreenOn,
3794
4800
  setNavigationBarColor: setNavigationBarColor,
3795
4801
  setNavigationBarTitle: setNavigationBarTitle,
@@ -3799,25 +4805,65 @@ var apis = /*#__PURE__*/Object.freeze({
3799
4805
  setTabBarBadge: setTabBarBadge,
3800
4806
  setTabBarItem: setTabBarItem,
3801
4807
  setTabBarStyle: setTabBarStyle,
4808
+ setTopBarText: setTopBarText,
3802
4809
  setVisualEffectOnCapture: setVisualEffectOnCapture,
4810
+ setWifiList: setWifiList,
4811
+ setWindowSize: setWindowSize,
4812
+ shareFileMessage: shareFileMessage,
4813
+ shareToWeRun: shareToWeRun,
4814
+ shareVideoMessage: shareVideoMessage,
3803
4815
  showActionSheet: showActionSheet,
3804
4816
  showLoading: showLoading,
3805
4817
  showModal: showModal,
3806
4818
  showNavigationBarLoading: showNavigationBarLoading,
4819
+ showRedPackage: showRedPackage,
4820
+ showShareImageMenu: showShareImageMenu,
4821
+ showShareMenu: showShareMenu,
3807
4822
  showTabBar: showTabBar,
3808
4823
  showTabBarRedDot: showTabBarRedDot,
3809
4824
  showToast: showToast,
3810
4825
  startAccelerometer: startAccelerometer,
4826
+ startBeaconDiscovery: startBeaconDiscovery,
4827
+ startBluetoothDevicesDiscovery: startBluetoothDevicesDiscovery,
4828
+ startCompass: startCompass,
4829
+ startDeviceMotionListening: startDeviceMotionListening,
4830
+ startFacialRecognitionVerify: startFacialRecognitionVerify,
4831
+ startFacialRecognitionVerifyAndUploadVideo: startFacialRecognitionVerifyAndUploadVideo,
4832
+ startGyroscope: startGyroscope,
4833
+ startHCE: startHCE,
4834
+ startLocalServiceDiscovery: startLocalServiceDiscovery,
4835
+ startLocationUpdate: startLocationUpdate,
4836
+ startLocationUpdateBackground: startLocationUpdateBackground,
3811
4837
  startPullDownRefresh: startPullDownRefresh,
4838
+ startRecord: startRecord,
4839
+ startSoterAuthentication: startSoterAuthentication,
4840
+ startWifi: startWifi,
3812
4841
  stopAccelerometer: stopAccelerometer,
4842
+ stopBackgroundAudio: stopBackgroundAudio,
4843
+ stopBeaconDiscovery: stopBeaconDiscovery,
4844
+ stopBluetoothDevicesDiscovery: stopBluetoothDevicesDiscovery,
4845
+ stopCompass: stopCompass,
4846
+ stopDeviceMotionListening: stopDeviceMotionListening,
4847
+ stopGyroscope: stopGyroscope,
4848
+ stopHCE: stopHCE,
4849
+ stopLocalServiceDiscovery: stopLocalServiceDiscovery,
4850
+ stopLocationUpdate: stopLocationUpdate,
3813
4851
  stopPullDownRefresh: stopPullDownRefresh,
4852
+ stopRecord: stopRecord,
4853
+ stopVoice: stopVoice,
4854
+ stopWifi: stopWifi,
4855
+ subscribeVoIPVideoMembers: subscribeVoIPVideoMembers,
3814
4856
  switchTab: switchTab,
4857
+ updateShareMenu: updateShareMenu,
4858
+ updateVoIPChatMuteConfig: updateVoIPChatMuteConfig,
4859
+ updateWeChatApp: updateWeChatApp,
3815
4860
  uploadFile: uploadFile,
3816
4861
  vibrateLong: vibrateLong,
3817
- vibrateShort: vibrateShort
4862
+ vibrateShort: vibrateShort,
4863
+ writeBLECharacteristicValue: writeBLECharacteristicValue
3818
4864
  });
3819
4865
 
3820
- Object.assign({}, apis);
4866
+ const taro = Object.assign({}, apis);
3821
4867
  const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin');
3822
4868
  function initNativeApi(taro) {
3823
4869
  Current.taro = taro;
@@ -3841,7 +4887,7 @@ const defaultBaseFontSize = 20;
3841
4887
  const defaultUnitPrecision = 5;
3842
4888
  const defaultTargetUnit = 'vp';
3843
4889
  function getApp$1() {
3844
- return Current.app;
4890
+ return Current.app || {};
3845
4891
  }
3846
4892
  function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
3847
4893
  const taro = Current.taro;
@@ -3855,19 +4901,56 @@ function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defau
3855
4901
  config.unitPrecision = unitPrecision;
3856
4902
  }
3857
4903
  }
3858
- _display.getDefaultDisplaySync();
4904
+ const display = _display.getDefaultDisplaySync();
4905
+ let displayWidth = display.width;
4906
+ let ratioCache = false;
4907
+ let designWidthFunc;
4908
+ let designWidth = defaultDesignWidth;
4909
+ function getRatio(value) {
4910
+ var _a;
4911
+ // Note: 提前调用 display 可能无法获取正确值
4912
+ if (ratioCache === false || displayWidth !== display.width) {
4913
+ const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
4914
+ if (!isFunction(designWidthFunc)) {
4915
+ designWidthFunc = isFunction(config.designWidth)
4916
+ ? config.designWidth
4917
+ : () => config.designWidth;
4918
+ designWidth = designWidthFunc(value) || defaultDesignWidth;
4919
+ }
4920
+ displayWidth = display.width;
4921
+ ratioCache = Math.min(display.width, display.height) / designWidth;
4922
+ }
4923
+ return ratioCache;
4924
+ }
4925
+ // Note: 设置为 style 单位时会自动完成设计稿转换,设计开发者调用 API 时也许抹平差异,例如 pageScrollTo[option.offsetTop]
4926
+ function pxTransformHelper(size, unit, isNumber = false) {
4927
+ var _a;
4928
+ const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
4929
+ const targetUnit = unit || config.targetUnit || defaultTargetUnit;
4930
+ if (targetUnit === 'PX') {
4931
+ return px2vp(size * display.scaledDensity) + 'vp';
4932
+ }
4933
+ const ratio = getRatio(size);
4934
+ let val = size * ratio;
4935
+ switch (targetUnit) {
4936
+ case 'vp':
4937
+ // Note: 在应用创建前调用无效
4938
+ val = px2vp(val);
4939
+ break;
4940
+ }
4941
+ return isNumber ? val : val + targetUnit;
4942
+ }
3859
4943
  function pxTransform(size) {
3860
4944
  var _a;
3861
4945
  const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
3862
4946
  const targetUnit = config.targetUnit || defaultTargetUnit;
3863
- let val = size;
4947
+ const val = size;
3864
4948
  switch (targetUnit) {
3865
4949
  case 'vp':
3866
- val = px2vp(size);
3867
- break;
4950
+ return pxTransformHelper(size, 'px');
3868
4951
  // NOTE: 鸿蒙环境下 style 会自动完成设计稿转换,无需在方法内二次调整
3869
4952
  }
3870
- return val + config.targetUnit;
4953
+ return val + targetUnit;
3871
4954
  }
3872
4955
  function canIUseWebp() {
3873
4956
  return true;
@@ -3881,6 +4964,7 @@ function getAppInfo() {
3881
4964
  designWidth: config === null || config === void 0 ? void 0 : config.designWidth,
3882
4965
  };
3883
4966
  }
4967
+ initNativeApi(taro);
3884
4968
 
3885
4969
  const components = {
3886
4970
  Checkbox: {