@tarojs/plugin-platform-harmony-ets 4.0.0-canary.8 → 4.0.0

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 (135) hide show
  1. package/dist/apis/base/system.ts +73 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +23 -8
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +27 -17
  6. package/dist/apis/media/image/index.ts +169 -17
  7. package/dist/apis/network/request.ts +5 -5
  8. package/dist/apis/route/index.ts +15 -0
  9. package/dist/apis/storage/index.ts +146 -78
  10. package/dist/apis/ui/animation/animation.ts +71 -29
  11. package/dist/apis/ui/background.ts +2 -1
  12. package/dist/apis/ui/interaction/index.ts +58 -59
  13. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  14. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  15. package/dist/apis/ui/scroll/index.ts +5 -5
  16. package/dist/apis/ui/tab-bar.ts +3 -3
  17. package/dist/apis/utils/index.ts +21 -2
  18. package/dist/apis/utils/permissions.ts +6 -0
  19. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  20. package/dist/apis/wxml/index.ts +2 -0
  21. package/dist/apis/wxml/selectorQuery.ts +26 -13
  22. package/dist/components-harmony-ets/button.ets +63 -77
  23. package/dist/components-harmony-ets/canvas.ets +51 -0
  24. package/dist/components-harmony-ets/checkbox.ets +75 -258
  25. package/dist/components-harmony-ets/form.ets +51 -158
  26. package/dist/components-harmony-ets/icon.ets +33 -83
  27. package/dist/components-harmony-ets/image.ets +35 -79
  28. package/dist/components-harmony-ets/index.ets +92 -0
  29. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  30. package/dist/components-harmony-ets/input.ets +64 -101
  31. package/dist/components-harmony-ets/label.ets +72 -174
  32. package/dist/components-harmony-ets/listView.ets +31 -0
  33. package/dist/components-harmony-ets/movableArea.ets +126 -0
  34. package/dist/components-harmony-ets/movableView.ets +93 -0
  35. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  36. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  37. package/dist/components-harmony-ets/picker.ets +46 -163
  38. package/dist/components-harmony-ets/progress.ets +52 -0
  39. package/dist/components-harmony-ets/pseudo.ets +80 -0
  40. package/dist/components-harmony-ets/radio.ets +80 -264
  41. package/dist/components-harmony-ets/richText.ets +20 -102
  42. package/dist/components-harmony-ets/scrollList.ets +108 -0
  43. package/dist/components-harmony-ets/scrollView.ets +71 -160
  44. package/dist/components-harmony-ets/slider.ets +22 -82
  45. package/dist/components-harmony-ets/stickySection.ets +42 -0
  46. package/dist/components-harmony-ets/style.ets +410 -0
  47. package/dist/components-harmony-ets/swiper.ets +64 -87
  48. package/dist/components-harmony-ets/switch.ets +39 -99
  49. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  50. package/dist/components-harmony-ets/text.ets +111 -113
  51. package/dist/components-harmony-ets/textArea.ets +51 -95
  52. package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
  53. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
  54. package/dist/components-harmony-ets/utils/flexManager.ets +50 -19
  55. package/dist/components-harmony-ets/utils/helper.ets +20 -8
  56. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  57. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  58. package/dist/components-harmony-ets/utils/index.ts +54 -50
  59. package/dist/components-harmony-ets/utils/styles.ets +172 -92
  60. package/dist/components-harmony-ets/video.ets +37 -88
  61. package/dist/components-harmony-ets/view.ets +63 -159
  62. package/dist/components-harmony-ets/webView.ets +41 -98
  63. package/dist/index.d.ts +152 -0
  64. package/dist/index.js +187 -56
  65. package/dist/index.js.map +1 -1
  66. package/dist/runtime-ets/bom/document.ts +6 -4
  67. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  68. package/dist/runtime-ets/bom/window.ts +9 -2
  69. package/dist/runtime-ets/current.ts +5 -1
  70. package/dist/runtime-ets/dom/bind.ts +28 -12
  71. package/dist/runtime-ets/dom/class-list.ts +2 -2
  72. package/dist/runtime-ets/dom/cssNesting.ts +419 -0
  73. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
  74. package/dist/runtime-ets/dom/document.ts +22 -8
  75. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  76. package/dist/runtime-ets/dom/element/element.ts +376 -57
  77. package/dist/runtime-ets/dom/element/form.ts +31 -26
  78. package/dist/runtime-ets/dom/element/index.ts +30 -2
  79. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  80. package/dist/runtime-ets/dom/element/movableView.ts +248 -0
  81. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  82. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  83. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  84. package/dist/runtime-ets/dom/element/text.ts +1 -8
  85. package/dist/runtime-ets/dom/element/video.ts +5 -4
  86. package/dist/runtime-ets/dom/element/webView.ts +12 -5
  87. package/dist/runtime-ets/dom/event.ts +3 -5
  88. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  89. package/dist/runtime-ets/dom/node.ts +65 -32
  90. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
  91. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  92. package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
  93. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  94. package/dist/runtime-ets/index.ts +2 -2
  95. package/dist/runtime-ets/interface/event.ts +1 -1
  96. package/dist/runtime-ets/utils/index.ts +74 -13
  97. package/dist/runtime-ets/utils/info.ts +2 -2
  98. package/dist/runtime-framework/react/app.ts +25 -30
  99. package/dist/runtime-framework/react/hooks.ts +3 -4
  100. package/dist/runtime-framework/react/index.ts +0 -2
  101. package/dist/runtime-framework/react/native-page.ts +219 -82
  102. package/dist/runtime-framework/react/page.ts +6 -10
  103. package/dist/runtime-framework/react/utils/index.ts +3 -3
  104. package/dist/runtime-framework/solid/app.ts +30 -46
  105. package/dist/runtime-framework/solid/connect.ts +21 -3
  106. package/dist/runtime-framework/solid/hooks.ts +17 -12
  107. package/dist/runtime-framework/solid/index.ts +6 -2
  108. package/dist/runtime-framework/solid/page.ts +85 -31
  109. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  110. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  111. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  112. package/dist/runtime-framework/solid/utils/index.ts +3 -5
  113. package/dist/runtime-utils.d.ts +827 -0
  114. package/dist/runtime-utils.js +618 -245
  115. package/dist/runtime-utils.js.map +1 -1
  116. package/dist/runtime.d.ts +1 -0
  117. package/dist/runtime.js +618 -245
  118. package/dist/runtime.js.map +1 -1
  119. package/index.js +3 -1
  120. package/package.json +14 -15
  121. package/static/media/cancel.svg +1 -1
  122. package/static/media/circle.svg +1 -1
  123. package/static/media/clear.svg +1 -1
  124. package/static/media/download.svg +1 -1
  125. package/static/media/info.svg +1 -1
  126. package/static/media/info_circle.svg +1 -1
  127. package/static/media/search.svg +1 -1
  128. package/static/media/success.svg +1 -1
  129. package/static/media/success_no_circle.svg +1 -1
  130. package/static/media/warn.svg +1 -1
  131. package/types/harmony.d.ts +5 -0
  132. package/types/index.d.ts +4 -0
  133. package/types/runtime.d.ts +3 -1
  134. package/dist/runtime-ets/utils/bind.ts +0 -24
  135. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,10 +1,11 @@
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, hooks, document as document$1, getPageScrollerOrNode, findChildNodeWithDFS, setNodeEventCallbackAndTriggerComponentUpdate, AREA_CHANGE_EVENT_NAME, disconnectEvent, VISIBLE_CHANGE_EVENT_NAME } 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
+ import '@ohos.abilityAccessCtrl';
4
5
  import { eventCenter, Events, History } from '@tarojs/runtime/dist/runtime.esm';
6
+ import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
5
7
  import deviceInfo from '@ohos.deviceInfo';
6
8
  import i18n from '@ohos.i18n';
7
- import deviceMethod from '@system.device';
8
9
  import errorManager from '@ohos.app.ability.errorManager';
9
10
  import sensor from '@ohos.sensor';
10
11
  import batteryInfo, { BatteryChargeState } from '@ohos.batteryInfo';
@@ -21,6 +22,7 @@ import app from '@system.app';
21
22
  import file from '@system.file';
22
23
  import geoLocationManager from '@ohos.geoLocationManager';
23
24
  import mediaLibrary from '@ohos.multimedia.mediaLibrary';
25
+ import fs from '@ohos.file.fs';
24
26
  import picker from '@ohos.file.picker';
25
27
  import image from '@ohos.multimedia.image';
26
28
  import request$1 from '@ohos.request';
@@ -28,11 +30,9 @@ import http from '@ohos.net.http';
28
30
  import webSocket from '@ohos.net.webSocket';
29
31
  import router from '@ohos.router';
30
32
  import bundleManager from '@ohos.bundle.bundleManager';
31
- import dataPreferences from '@ohos.data.preferences';
32
- import hilog from '@ohos.hilog';
33
+ import distributedKVStore from '@ohos.data.distributedKVStore';
33
34
  import matrix4 from '@ohos.matrix4';
34
- import prompt from '@ohos.prompt';
35
- import { pxTransformHelper } from '@tarojs/taro';
35
+ import { pxTransformHelper as pxTransformHelper$1 } from '@tarojs/taro';
36
36
 
37
37
  class MethodHandler {
38
38
  constructor({ name, success, fail, complete }) {
@@ -186,7 +186,7 @@ function temporarilyNotSupport(name, recommended) {
186
186
  return (option = {}, ...args) => {
187
187
  const { success, fail, complete } = option;
188
188
  const handle = new MethodHandler({ name, success, fail, complete });
189
- let errMsg = '暂时不支持 API';
189
+ let errMsg = `暂时不支持 API ${name}`;
190
190
  if (recommended) {
191
191
  errMsg += `, 请使用 ${recommended}`;
192
192
  }
@@ -266,16 +266,63 @@ const preloadWebview = /* @__PURE__ */ temporarilyNotSupport('preloadWebview');
266
266
  const preloadSkylineView = /* @__PURE__ */ temporarilyNotSupport('preloadSkylineView');
267
267
  const preloadAssets = /* @__PURE__ */ temporarilyNotSupport('preloadAssets');
268
268
 
269
- // 设备信息,从 API Version 6 开始支持
270
- const display = _display.getDefaultDisplaySync();
271
- let device;
272
- deviceMethod.getInfo({
273
- success: data => {
274
- device = data;
275
- }
269
+ let display$1;
270
+ let navigationIndicatorRect;
271
+ let safeArea = null;
272
+ let statusBarHeight;
273
+ let windowRect;
274
+ Current.contextPromise.then((context) => {
275
+ const win = window.__ohos.getLastWindow(context);
276
+ win.then(mainWindow => {
277
+ const topRect = mainWindow.getWindowAvoidArea(window.__ohos.AvoidAreaType.TYPE_SYSTEM).topRect;
278
+ navigationIndicatorRect = mainWindow.getWindowAvoidArea(window.__ohos.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect;
279
+ statusBarHeight = topRect.top + topRect.height;
280
+ windowRect = mainWindow.getWindowProperties().windowRect;
281
+ try {
282
+ display$1 = _display.getDefaultDisplaySync();
283
+ setSafeArea({
284
+ top: statusBarHeight,
285
+ left: 0,
286
+ right: display$1.width,
287
+ bottom: navigationIndicatorRect === null || navigationIndicatorRect === void 0 ? void 0 : navigationIndicatorRect.top
288
+ });
289
+ // @ts-ignore
290
+ display$1.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} } = {}) => {
291
+ var _a, _b, _c, _d, _e, _f;
292
+ if (err === null || err === void 0 ? void 0 : err.code) {
293
+ console.error('Failed to get cutout info', JSON.stringify(err));
294
+ return;
295
+ }
296
+ 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);
297
+ 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);
298
+ const left = ((_d = waterfallDisplayAreaRects.left) === null || _d === void 0 ? void 0 : _d.left) + ((_e = waterfallDisplayAreaRects.left) === null || _e === void 0 ? void 0 : _e.width);
299
+ const right = display$1.width - ((_f = waterfallDisplayAreaRects.right) === null || _f === void 0 ? void 0 : _f.left);
300
+ setSafeArea({
301
+ top,
302
+ left,
303
+ right,
304
+ bottom
305
+ });
306
+ });
307
+ }
308
+ catch (e) {
309
+ console.error('Failed to get display', e);
310
+ }
311
+ });
276
312
  });
313
+ function setSafeArea({ top, left, right, bottom }) {
314
+ safeArea = {
315
+ top,
316
+ bottom,
317
+ left,
318
+ right,
319
+ height: bottom - top,
320
+ width: right - left,
321
+ };
322
+ }
277
323
  /* 同步版本 */
278
324
  const getSystemInfoSync = function () {
325
+ var _a, _b;
279
326
  const res = {};
280
327
  res.SDKVersion = deviceInfo && deviceInfo.sdkApiVersion; // 客户端基础库版本 string
281
328
  res.albumAuthorized = false; // 允许使用相册的开关(仅 iOS 有效) boolean
@@ -285,7 +332,7 @@ const getSystemInfoSync = function () {
285
332
  res.cameraAuthorized = null; // 允许使用摄像头的开关 boolean
286
333
  res.enableDebug = null; // 是否已打开调试 boolean
287
334
  res.fontSizeSetting = null; // 用户字体大小(单位px) number
288
- res.language = i18n && i18n.getSystemLanguage && i18n.getSystemLanguage(); // string
335
+ res.language = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.getSystemLanguage) === null || _a === void 0 ? void 0 : _a.call(i18n); // string
289
336
  res.locationAuthorized = null; // 定位的开关 boolean
290
337
  res.locationEnabled = null; // 地理位置的系统开关 boolean
291
338
  res.microphoneAuthorized = null; // 麦克风的开关 boolean
@@ -296,17 +343,18 @@ const getSystemInfoSync = function () {
296
343
  res.notificationSoundAuthorized = false; // 通知带有声音的开关(仅 iOS 有效)boolean
297
344
  res.phoneCalendarAuthorized = null; // 使用日历的开关 boolean
298
345
  res.wifiEnabled = false; // Wi-Fi 的系统开关 boolean
299
- res.pixelRatio = null; // 设备像素比,number
300
- res.platform = 'android'; // 客户端平台 string
301
- res.safeArea = null; // 在竖屏正方向下的安全区域 General.SafeAreaResult
302
- res.screenHeight = display && display.height; // 屏幕高度,单位px number
303
- res.screenWidth = display && display.width; // 屏幕宽度,单位px number
304
- res.statusBarHeight = null; // 状态栏的高度,单位px number
305
- res.system = deviceInfo && deviceInfo.osFullName; // 操作系统及版本 string
306
- res.theme = null; // 系统当前主题,取值为light或dark 'light' | 'dark'
307
- res.windowWidth = device && device.windowWidth; // 可使用窗口宽度,单位px number
308
- res.windowHeight = device && device.windowHeight; // 可使用窗口高度,单位px number
309
- res.version = deviceInfo && deviceInfo.displayVersion; // 版本号 string
346
+ res.pixelRatio = display$1 && display$1.densityPixels; // 设备像素比,number
347
+ res.platform = 'harmony'; // 客户端平台 string
348
+ res.safeArea = safeArea; // 在竖屏正方向下的安全区域 General.SafeAreaResult
349
+ res.screenHeight = display$1 === null || display$1 === void 0 ? void 0 : display$1.height; // 屏幕高度,单位px number
350
+ res.screenWidth = display$1 === null || display$1 === void 0 ? void 0 : display$1.width; // 屏幕宽度,单位px number
351
+ res.statusBarHeight = statusBarHeight; // 状态栏的高度,单位px number
352
+ res.system = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.osFullName; // 操作系统及版本 string
353
+ // Note: 更新配置时才能记录
354
+ 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'
355
+ res.windowHeight = windowRect === null || windowRect === void 0 ? void 0 : windowRect.height; // 可使用窗口高度,单位px number
356
+ res.windowWidth = windowRect === null || windowRect === void 0 ? void 0 : windowRect.width; // 可使用窗口宽度,单位px number
357
+ res.version = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.displayVersion; // 版本号 string
310
358
  return res;
311
359
  };
312
360
  /* 异步版本 */
@@ -412,7 +460,13 @@ const base64ToArrayBuffer = /* @__PURE__ */ temporarilyNotSupport('base64ToArray
412
460
  /** 创建离屏 canvas 实例 */
413
461
  const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
414
462
  /** 创建 canvas 的绘图上下文 CanvasContext 对象 */
415
- const createCanvasContext = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
463
+ // export const createCanvasContext = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
464
+ const createCanvasContext = (canvasId) => {
465
+ const dom = eventSource.get(`canvasId-${canvasId}`);
466
+ // return dom as TaroCanvasElement
467
+ if (dom)
468
+ return dom.context;
469
+ };
416
470
  /** 把当前画布指定区域的内容导出生成指定大小的图片 */
417
471
  const canvasToTempFilePath = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
418
472
  /** 将像素数据绘制到画布 */
@@ -533,7 +587,7 @@ const getBatteryInfoSync = () => ({
533
587
  isCharging: [BatteryChargeState.ENABLE, BatteryChargeState.FULL].includes(batteryInfo.chargingStatus),
534
588
  level: batteryInfo.batterySOC
535
589
  });
536
- const getBatteryInfo = ({ success, fail, complete } = {}) => __awaiter(void 0, void 0, void 0, function* () {
590
+ const getBatteryInfo = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ success, fail, complete } = {}) {
537
591
  const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete });
538
592
  try {
539
593
  return handle.success(getBatteryInfoSync());
@@ -605,9 +659,26 @@ const setClipboardData = function (options) {
605
659
  });
606
660
  }
607
661
  return new Promise((resolve, reject) => {
662
+ var _a, _b;
608
663
  const systemPasteboard = pasteboard.getSystemPasteboard();
609
- const pasteData = pasteboard.createPlainTextData(data);
610
- systemPasteboard.setPasteData(pasteData, (error, data) => {
664
+ const pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, data);
665
+ try {
666
+ systemPasteboard.setDataSync(pasteData);
667
+ // @ts-ignore
668
+ const uiContext = (_b = (_a = Current === null || Current === void 0 ? void 0 : Current.page) === null || _a === void 0 ? void 0 : _a.getUIContext) === null || _b === void 0 ? void 0 : _b.call(_a);
669
+ if (!uiContext)
670
+ return;
671
+ uiContext.getPromptAction().showToast({
672
+ message: '内容已复制',
673
+ duration: 1500,
674
+ bottom: '50%',
675
+ showMode: 1 // 设置弹窗显示模式,显示在应用之上。
676
+ });
677
+ return handle.success({
678
+ data,
679
+ }, { resolve, reject });
680
+ }
681
+ catch (error) {
611
682
  if (error) {
612
683
  console.error('Failed to set PasteData. Cause: ' + JSON.stringify(error));
613
684
  res = {
@@ -616,12 +687,7 @@ const setClipboardData = function (options) {
616
687
  };
617
688
  callAsyncFail(reject, res, options);
618
689
  }
619
- else {
620
- return handle.success({
621
- data,
622
- }, { resolve, reject });
623
- }
624
- });
690
+ }
625
691
  });
626
692
  };
627
693
  /**
@@ -632,7 +698,7 @@ const getClipboardData = function (options) {
632
698
  const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete });
633
699
  return new Promise((resolve, reject) => {
634
700
  const systemPasteboard = pasteboard.getSystemPasteboard();
635
- systemPasteboard.getPasteData((error, pasteData) => {
701
+ systemPasteboard.getData((error, pasteData) => {
636
702
  if (error) {
637
703
  console.error('Failed to obtain PasteData. Cause: ' + JSON.stringify(error));
638
704
  return handle.fail({
@@ -771,7 +837,7 @@ const getNetworkType = (options = {}) => {
771
837
  });
772
838
  };
773
839
  const networkStatusManager = new CallbackManager();
774
- const networkStatusListener = (data, code = 0) => __awaiter(void 0, void 0, void 0, function* () {
840
+ const networkStatusListener = (data_1, ...args_1) => __awaiter(void 0, [data_1, ...args_1], void 0, function* (data, code = 0) {
775
841
  if (code > 0) {
776
842
  return networkStatusManager.trigger({ isConnected: false, networkType: 'none' });
777
843
  }
@@ -1984,7 +2050,6 @@ function getEnv() {
1984
2050
  }
1985
2051
  // TODO
1986
2052
  const getCurrentPages = () => [];
1987
- const getCurrentInstance = () => Current;
1988
2053
  const requirePlugin$1 = temporarilyNotSupport('requirePlugin');
1989
2054
 
1990
2055
  // @ts-nocheck
@@ -2014,7 +2079,7 @@ function formatLocation(location) {
2014
2079
  altitude: location.altitude,
2015
2080
  accuracy: location.accuracy,
2016
2081
  speed: location.speed,
2017
- verticalAccuracy: 0,
2082
+ verticalAccuracy: 0, // OHOS 不支持返回此参数,直接设置为默认值
2018
2083
  horizontalAccuracy: 0 // OHOS 不支持返回此参数,直接设置为默认值
2019
2084
  };
2020
2085
  return wxLocate;
@@ -2206,17 +2271,11 @@ const chooseMedia = function (options) {
2206
2271
  // HarmonyOS 图片模块首批接口从API version 7开始支持。
2207
2272
  // HarmonyOS 文档链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-image-0000001122977382
2208
2273
  // WX 文档链接:https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.saveImageToPhotosAlbum.html
2209
- // ✅ wx.getImageInfo(Object object) API7以上支持
2210
- // ✅ wx.compressImage(Object object) API7以上支持
2211
- // ✅ wx.chooseImage(Object object)
2212
- // ❌ wx.chooseMessageFile(Object object) HarmonyOS不支持
2213
- // ❌ wx.saveImageToPhotosAlbum(Object object) api 9+ HarmonyOS不支持
2214
- // ❌ wx.previewImage(Object object) api 9+ HarmonyOS不支持
2215
2274
  const getImageInfoSchema = {
2216
- url: 'String'
2275
+ src: 'String'
2217
2276
  };
2218
2277
  const compressImageSchema = {
2219
- url: 'String'
2278
+ src: 'String'
2220
2279
  };
2221
2280
  const chooseImageSchema = {
2222
2281
  count: 'Number'
@@ -2246,6 +2305,42 @@ const getImageInfo = function (options) {
2246
2305
  });
2247
2306
  });
2248
2307
  };
2308
+ class CompressedImageInfo {
2309
+ constructor() {
2310
+ this.imageUri = ''; // 压缩后图片保存位置的uri
2311
+ this.imageByteLength = 0; // 压缩后图片字节长度
2312
+ }
2313
+ }
2314
+ function saveImage(compressedImageData, compressedImageUri) {
2315
+ return __awaiter(this, void 0, void 0, function* () {
2316
+ const tempArr = compressedImageUri.split('/');
2317
+ const name = tempArr[tempArr.length - 1];
2318
+ const context = getContext(Current === null || Current === void 0 ? void 0 : Current.page);
2319
+ const applicationContext = context.getApplicationContext();
2320
+ const tempDir = applicationContext.tempDir;
2321
+ const filePath = `${tempDir}/${name}`;
2322
+ try {
2323
+ const res = fs.accessSync(filePath);
2324
+ if (res) {
2325
+ // 如果图片afterCompressiona.jpeg已存在,则删除
2326
+ fs.unlinkSync(filePath);
2327
+ }
2328
+ }
2329
+ catch (err) {
2330
+ console.error(`[Taro] saveImage Error: AccessSync failed with error message: ${err.message}, error code: ${err.code}`);
2331
+ }
2332
+ // 知识点:保存图片。获取最终图片压缩数据compressedImageData,保存图片。
2333
+ // 压缩图片数据写入文件
2334
+ const file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
2335
+ fs.writeSync(file.fd, compressedImageData);
2336
+ fs.closeSync(file);
2337
+ // 获取压缩图片信息
2338
+ const compressedImageInfo = new CompressedImageInfo();
2339
+ compressedImageInfo.imageUri = filePath;
2340
+ compressedImageInfo.imageByteLength = compressedImageData.byteLength;
2341
+ return compressedImageInfo;
2342
+ });
2343
+ }
2249
2344
  const compressImage = function (options) {
2250
2345
  return new Promise((resolve, reject) => {
2251
2346
  try {
@@ -2255,27 +2350,62 @@ const compressImage = function (options) {
2255
2350
  const res = { errMsg: error.message };
2256
2351
  return callAsyncFail(reject, res, options);
2257
2352
  }
2258
- const { src, quality = 80 } = options;
2259
- const source = image.createImageSource(src);
2353
+ const { src, quality = 80, compressedWidth, compressedHeight } = options;
2354
+ const srcAfterCompress = src.includes('_after_compress') ? src : src.split('.').join('_after_compress.');
2355
+ const file = fs.openSync(src, fs.OpenMode.READ_ONLY);
2356
+ // const stat = fs.statSync(file.fd)
2357
+ // console.log('[Taro] 压缩前图片的大小为:', stat.size)
2358
+ const source = image.createImageSource(file.fd);
2260
2359
  if (isNull(source)) {
2261
2360
  const createImageSourceError = { errMsg: 'compressImage fail: createImageSource has failed.' };
2262
2361
  callAsyncFail(reject, createImageSourceError, options);
2263
2362
  return;
2264
2363
  }
2265
- const packer = image.createImagePacker(src);
2266
- if (isNull(packer)) {
2267
- const createImagePackerError = { errMsg: 'compressImage fail: createImagePacker has failed.' };
2268
- callAsyncFail(reject, createImagePackerError, options);
2364
+ const width = source.getImageInfoSync().size.width;
2365
+ const height = source.getImageInfoSync().size.height;
2366
+ let wantWidth = compressedWidth || compressedHeight || 0;
2367
+ let wantHeight = compressedHeight || compressedWidth || 0;
2368
+ if (width > wantWidth || height > wantHeight) {
2369
+ const heightRatio = height / wantHeight;
2370
+ const widthRatio = width / wantWidth;
2371
+ const finalRatio = heightRatio < widthRatio ? heightRatio : widthRatio;
2372
+ wantWidth = Math.round(width / finalRatio);
2373
+ wantHeight = Math.round(height / finalRatio);
2269
2374
  }
2270
- const packingOptionsOHOS = {
2271
- // TODO:需要获取文件名后缀
2272
- format: 'image/jpeg',
2273
- quality: quality
2375
+ const decodingOptions = {
2376
+ editable: true,
2377
+ desiredPixelFormat: image.PixelMapFormat.RGBA_8888,
2378
+ desiredSize: { width: wantWidth, height: wantHeight }
2274
2379
  };
2275
- packer.packing(source, packingOptionsOHOS).then((value) => {
2276
- callAsyncSuccess(resolve, value, options);
2277
- }).catch((error) => {
2278
- callAsyncFail(reject, error, options);
2380
+ source.createPixelMap(decodingOptions, (error, pixelMap) => {
2381
+ if (error !== undefined) {
2382
+ fs.closeSync(file);
2383
+ const res = { errMsg: error };
2384
+ callAsyncFail(reject, res, options);
2385
+ }
2386
+ else {
2387
+ const packer = image.createImagePacker(file.fd);
2388
+ if (isNull(packer)) {
2389
+ fs.closeSync(file);
2390
+ const createImagePackerError = { errMsg: 'compressImage fail: createImagePacker has failed.' };
2391
+ callAsyncFail(reject, createImagePackerError, options);
2392
+ return;
2393
+ }
2394
+ const isPNG = src.endsWith('.png');
2395
+ const packingOptionsOHOS = {
2396
+ format: isPNG ? 'image/png' : 'image/jpeg',
2397
+ quality: quality
2398
+ };
2399
+ packer.packing(pixelMap, packingOptionsOHOS).then((value) => {
2400
+ fs.closeSync(file);
2401
+ saveImage(value, srcAfterCompress).then(result => {
2402
+ callAsyncSuccess(resolve, { tempFilePath: result.imageUri }, options);
2403
+ });
2404
+ }).catch((error) => {
2405
+ fs.closeSync(file);
2406
+ callAsyncFail(reject, error, options);
2407
+ });
2408
+ }
2279
2409
  });
2280
2410
  });
2281
2411
  };
@@ -2290,10 +2420,64 @@ const chooseImage = function (options) {
2290
2420
  }
2291
2421
  const { count = 9 } = options;
2292
2422
  const photoViewPicker = new picker.PhotoViewPicker();
2423
+ let sizeType = options.sizeType;
2424
+ if (!sizeType || !sizeType.length) {
2425
+ sizeType = ['compressed', 'original'];
2426
+ }
2293
2427
  photoSelectOptions.maxSelectNumber = count; // 选择媒体文件的最大数目
2294
2428
  photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型为IMAGE
2295
2429
  photoViewPicker.select(photoSelectOptions).then((photoSelectResult) => {
2296
- callAsyncSuccess(resolve, { tempFilePaths: photoSelectResult.photoUris });
2430
+ const result = {};
2431
+ const isOrigin = photoSelectResult.isOriginalPhoto;
2432
+ if (isOrigin) {
2433
+ const tempFilePaths = [];
2434
+ const tempFiles = photoSelectResult.photoUris.map(uri => {
2435
+ const file = fs.openSync(uri, fs.OpenMode.READ_ONLY);
2436
+ const stat = fs.statSync(file.fd);
2437
+ const size = stat.size;
2438
+ fs.closeSync(file);
2439
+ tempFilePaths.push(uri);
2440
+ return {
2441
+ size,
2442
+ path: uri,
2443
+ };
2444
+ });
2445
+ result.tempFiles = tempFiles;
2446
+ result.tempFilePaths = tempFilePaths;
2447
+ callAsyncSuccess(resolve, result, options);
2448
+ }
2449
+ else {
2450
+ const actions = photoSelectResult.photoUris.map(uri => {
2451
+ return new Promise(resolve => {
2452
+ compressImage({
2453
+ src: uri,
2454
+ compressedWidth: getSystemInfoSync().screenWidth / 2,
2455
+ compressedHeight: getSystemInfoSync().screenHeight / 2,
2456
+ success: (compressResult) => {
2457
+ resolve(compressResult.tempFilePath);
2458
+ }
2459
+ });
2460
+ });
2461
+ });
2462
+ Promise.all(actions).then(tempFilePaths => {
2463
+ const tempFiles = tempFilePaths.map(uri => {
2464
+ const file = fs.openSync(uri, fs.OpenMode.READ_ONLY);
2465
+ const stat = fs.statSync(file.fd);
2466
+ const size = stat.size;
2467
+ fs.closeSync(file);
2468
+ return {
2469
+ size,
2470
+ path: uri,
2471
+ };
2472
+ });
2473
+ result.tempFilePaths = tempFilePaths;
2474
+ result.tempFiles = tempFiles;
2475
+ callAsyncSuccess(resolve, result, options);
2476
+ }).catch(error => {
2477
+ const res = { errMsg: error };
2478
+ return callAsyncFail(reject, res, options);
2479
+ });
2480
+ }
2297
2481
  }).catch((error) => {
2298
2482
  callAsyncFail(reject, error, options);
2299
2483
  });
@@ -2611,10 +2795,10 @@ const request = function (options) {
2611
2795
  header['Content-Type'] = 'application/json';
2612
2796
  }
2613
2797
  // 检查 Header 是否有 Referer
2614
- if (isUndefined(header.Referer)) {
2615
- const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' };
2616
- callAsyncFail(reject, error, options);
2617
- }
2798
+ // if (isUndefined(header.Referer)) {
2799
+ // const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
2800
+ // callAsyncFail(reject, error, options)
2801
+ // }
2618
2802
  // 检查 method 是否正确
2619
2803
  if (method) {
2620
2804
  if (!METHOD.includes(method)) {
@@ -3060,6 +3244,19 @@ function parseURL(raw = '') {
3060
3244
  const [urlStr, queryStr = ''] = raw.split('?');
3061
3245
  const query = queryToJson(queryStr);
3062
3246
  let url = urlStr.replace(/^\//, '');
3247
+ // 处理相对路径
3248
+ if (url.indexOf('.') === 0) {
3249
+ const page = router.getState();
3250
+ const parts = page.path.split('/');
3251
+ parts.pop();
3252
+ url.split('/').forEach((item) => {
3253
+ if (item === '.') {
3254
+ return;
3255
+ }
3256
+ item === '..' ? parts.pop() : parts.push(item);
3257
+ });
3258
+ url = parts.join('/');
3259
+ }
3063
3260
  if (isTabPage(url)) {
3064
3261
  query.$page = url;
3065
3262
  url = TARO_TABBAR_PAGE_PATH;
@@ -3177,113 +3374,172 @@ const getBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('getBackgro
3177
3374
  // 周期性更新
3178
3375
  const createCacheManager = /* @__PURE__ */ temporarilyNotSupport('createCacheManager');
3179
3376
 
3180
- const preferencesPromise = Current.contextPromise
3181
- .then((context) => {
3182
- return bundleManager
3183
- .getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION)
3184
- .then(data => {
3185
- return dataPreferences
3186
- .getPreferences(context, `${data.appInfo.uid}Store`);
3187
- });
3188
- })
3189
- .catch((error) => {
3190
- hilog.error(0x0000, 'TaroFailedTag', 'Failed to load the storage. Cause: %{public}s', error.code ? JSON.stringify(error) : error.message || error);
3377
+ /**
3378
+ * 从API Version 6开始,该模块不再维护,可以使用模块@ohos.data.storage。在API Version 9后,推荐使用新模块@ohos.data.preferences。
3379
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references-V3/js-apis-data-preferences-0000001427745052-V3
3380
+ */
3381
+ let context;
3382
+ let kvManager;
3383
+ let kvStore;
3384
+ let kvStorePromise;
3385
+ Current.contextPromise.then((ctx) => {
3386
+ context = ctx;
3387
+ const kvManagerConfig = {
3388
+ context: context,
3389
+ bundleName: 'com.example.taro'
3390
+ };
3391
+ try {
3392
+ // 创建KVManager实例
3393
+ kvManager = distributedKVStore.createKVManager(kvManagerConfig);
3394
+ // 继续创建获取数据库
3395
+ const options = {
3396
+ createIfMissing: true,
3397
+ encrypt: false,
3398
+ backup: false,
3399
+ autoSync: false,
3400
+ // kvStoreType不填时,默认创建多设备协同数据库
3401
+ kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
3402
+ // 多设备协同数据库:kvStoreType: distributedKVStore.KVStoreType.DEVICE_COLLABORATION,
3403
+ securityLevel: distributedKVStore.SecurityLevel.S1
3404
+ };
3405
+ const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
3406
+ kvStorePromise = new Promise(resolve => {
3407
+ kvManager.getKVStore(`${data.appInfo.uid}Store`, options, (err, store) => {
3408
+ if (err) {
3409
+ console.error(`Failed to get KVStore: Code:${err.code},message:${err.message}`);
3410
+ return;
3411
+ }
3412
+ kvStore = store;
3413
+ // 请确保获取到键值数据库实例后,再进行相关数据操作
3414
+ resolve();
3415
+ });
3416
+ });
3417
+ }
3418
+ catch (e) {
3419
+ console.error(`Failed to create KVManager. Code:${e.code},message:${e.message}`);
3420
+ }
3421
+ return context;
3191
3422
  });
3192
- function getItem(key) {
3193
- return __awaiter(this, void 0, void 0, function* () {
3194
- try {
3195
- const preferences = yield preferencesPromise;
3196
- const item = yield preferences.get(key, null);
3197
- return { result: true, data: item };
3198
- }
3199
- catch (error) {
3200
- return { result: false };
3201
- }
3202
- });
3203
- }
3204
3423
  const storageSchema = {
3205
3424
  key: 'String'
3206
3425
  };
3207
- function getStorage(options) {
3208
- return new Promise((resolve, reject) => {
3209
- try {
3210
- validateParams('getStorage', options, storageSchema);
3426
+ function checkContextExist(api, isAsync = false) {
3427
+ if (!context) {
3428
+ const message = `${api} 调用失败,Taro 不支持过早地调用 ${api},请确保页面已经渲染完成再调用此 API`;
3429
+ if (isAsync) {
3430
+ return {
3431
+ isExist: false,
3432
+ error: Promise.reject(new Error(message))
3433
+ };
3211
3434
  }
3212
- catch (error) {
3213
- const res = { errMsg: error.message };
3214
- return callAsyncFail(reject, res, options);
3435
+ else {
3436
+ console.warn(message);
3437
+ return {
3438
+ isExist: false,
3439
+ };
3215
3440
  }
3216
- getItem(options.key).then(({ result, data }) => {
3217
- const res = { errMsg: 'getStorage:ok' };
3218
- if (result) {
3219
- res.data = data;
3220
- callAsyncSuccess(resolve, res, options);
3441
+ }
3442
+ return {
3443
+ isExist: true,
3444
+ };
3445
+ }
3446
+ function getStorage(options) {
3447
+ const name = 'getStorage';
3448
+ const { isExist, error } = checkContextExist(name, true);
3449
+ if (!isExist) {
3450
+ return error;
3451
+ }
3452
+ const { key, success, fail, complete } = options || {};
3453
+ const handle = new MethodHandler({ name, success, fail, complete });
3454
+ return new Promise((resolve, reject) => {
3455
+ kvStorePromise.then(() => {
3456
+ try {
3457
+ validateParams(name, options, storageSchema);
3221
3458
  }
3222
- else {
3223
- res.errMsg = 'getStorage:fail data not found';
3224
- callAsyncFail(reject, res, options);
3459
+ catch (error) {
3460
+ const res = { errMsg: error.message };
3461
+ return handle.fail(res, { resolve, reject });
3225
3462
  }
3463
+ kvStore = kvStore;
3464
+ kvStore.get(key, (err, data) => {
3465
+ if (err) {
3466
+ handle.fail({ errMsg: `Failed to get data. Code:${err.code},message:${err.message}` }, { resolve, reject });
3467
+ return;
3468
+ }
3469
+ handle.success({ data }, { resolve, reject });
3470
+ });
3226
3471
  });
3227
3472
  });
3228
3473
  }
3229
3474
  function setStorage(options) {
3475
+ const name = 'setStorage';
3476
+ const { isExist, error } = checkContextExist(name, true);
3477
+ if (!isExist) {
3478
+ return error;
3479
+ }
3480
+ const { key, data, success, fail, complete } = options || {};
3481
+ const handle = new MethodHandler({ name, success, fail, complete });
3230
3482
  return new Promise((resolve, reject) => {
3231
- try {
3232
- validateParams('setStorage', options, storageSchema);
3233
- }
3234
- catch (error) {
3235
- const res = { errMsg: error.message };
3236
- return callAsyncFail(reject, res, options);
3237
- }
3238
- const { key, data } = options;
3239
- const res = { errMsg: 'setStorage:ok' };
3240
- preferencesPromise.then((preferences) => __awaiter(this, void 0, void 0, function* () {
3241
- yield preferences.put(key, data);
3242
- yield preferences.flush();
3243
- callAsyncSuccess(resolve, res, options);
3244
- }));
3483
+ kvStorePromise.then(() => {
3484
+ try {
3485
+ validateParams(name, options, storageSchema);
3486
+ }
3487
+ catch (error) {
3488
+ const res = { errMsg: error.message };
3489
+ return handle.fail(res, { resolve, reject });
3490
+ }
3491
+ kvStore = kvStore;
3492
+ kvStore.put(key, data, (err) => {
3493
+ if (err) {
3494
+ handle.fail({ errMsg: `Failed to put data. Code:${err.code},message:${err.message}` }, { resolve, reject });
3495
+ return;
3496
+ }
3497
+ handle.success({}, { resolve, reject });
3498
+ });
3499
+ });
3245
3500
  });
3246
3501
  }
3247
3502
  function removeStorage(options) {
3503
+ const name = 'removeStorage';
3504
+ const { isExist, error } = checkContextExist(name, true);
3505
+ if (!isExist) {
3506
+ return error;
3507
+ }
3508
+ const { key, success, fail, complete } = options || {};
3509
+ const handle = new MethodHandler({ name, success, fail, complete });
3248
3510
  return new Promise((resolve, reject) => {
3249
- try {
3250
- validateParams('removeStorage', options, storageSchema);
3251
- }
3252
- catch (error) {
3253
- const res = { errMsg: error.message };
3254
- return callAsyncFail(reject, res, options);
3255
- }
3256
- const { key } = options;
3257
- preferencesPromise.then((preferences) => __awaiter(this, void 0, void 0, function* () {
3258
- yield preferences.delete(key);
3259
- yield preferences.flush();
3260
- const res = { errMsg: 'removeStorage:ok' };
3261
- callAsyncSuccess(resolve, res, options);
3262
- }));
3263
- });
3264
- }
3265
- function clearStorage(options) {
3266
- return new Promise(resolve => {
3267
- preferencesPromise.then((preferences) => __awaiter(this, void 0, void 0, function* () {
3268
- yield preferences.clear();
3269
- yield preferences.flush();
3270
- const res = { errMsg: 'clearStorage:ok' };
3271
- callAsyncSuccess(resolve, res, options);
3272
- }));
3511
+ kvStorePromise.then(() => {
3512
+ try {
3513
+ validateParams(name, options, storageSchema);
3514
+ }
3515
+ catch (error) {
3516
+ const res = { errMsg: error.message };
3517
+ return handle.fail(res, { resolve, reject });
3518
+ }
3519
+ kvStore = kvStore;
3520
+ kvStore.delete(key, (err) => {
3521
+ if (err) {
3522
+ handle.fail({ errMsg: `Failed to delete data. Code:${err.code},message:${err.message}` }, { resolve, reject });
3523
+ return;
3524
+ }
3525
+ handle.success({}, { resolve, reject });
3526
+ });
3527
+ });
3273
3528
  });
3274
3529
  }
3275
3530
  const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync');
3276
3531
  const getStorageInfo = temporarilyNotSupport('getStorageInfo');
3277
- const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage');
3278
- const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage');
3279
- const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage');
3280
- const removeStorageSync = temporarilyNotSupport('removeStorageSync', 'removeStorage');
3281
3532
  const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL');
3282
3533
  const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL');
3283
3534
  const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStorageSync');
3284
3535
  const batchSetStorage = /* @__PURE__ */ temporarilyNotSupport('batchSetStorage');
3285
3536
  const batchGetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchGetStorageSync');
3286
3537
  const batchGetStorage = /* @__PURE__ */ temporarilyNotSupport('batchGetStorage');
3538
+ const clearStorage = temporarilyNotSupport('clearStorage');
3539
+ const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage');
3540
+ const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage');
3541
+ const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage');
3542
+ const removeStorageSync = temporarilyNotSupport('removeStorageSync', 'removeStorage');
3287
3543
 
3288
3544
  class Animation {
3289
3545
  constructor({ duration = 400, delay = 0, timingFunction = 'linear', transformOrigin = '50% 50% 0', unit = 'px' } = {}) {
@@ -3316,6 +3572,9 @@ class Animation {
3316
3572
  transformOrigin,
3317
3573
  rule: Object.assign({}, this.rule)
3318
3574
  });
3575
+ if (this.rule.transform) {
3576
+ this.rule.transform = Object.assign({}, this.rule.transform);
3577
+ }
3319
3578
  return this;
3320
3579
  }
3321
3580
  matrix(a, b, c, d, tx, ty) {
@@ -3327,75 +3586,120 @@ class Animation {
3327
3586
  return this;
3328
3587
  }
3329
3588
  rotate(angle) {
3330
- this.rule.rotate = { x: 0, y: 0, z: 1, angle };
3589
+ if (!this.rule.transform) {
3590
+ this.rule.transform = {};
3591
+ }
3592
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
3331
3593
  return this;
3332
3594
  }
3333
3595
  rotate3d(x, y, z, angle) {
3334
- this.rule.rotate = { x, y, z, angle };
3596
+ if (!this.rule.transform) {
3597
+ this.rule.transform = {};
3598
+ }
3599
+ this.rule.transform.Rotate = { x, y, z, angle };
3335
3600
  return this;
3336
3601
  }
3337
3602
  rotateX(angle) {
3338
- this.rule.rotate = { x: 1, y: 0, z: 0, angle };
3603
+ if (!this.rule.transform) {
3604
+ this.rule.transform = {};
3605
+ }
3606
+ this.rule.transform.Rotate = { x: 1, y: 0, z: 0, angle };
3339
3607
  return this;
3340
3608
  }
3341
3609
  rotateY(angle) {
3342
- this.rule.rotate = { x: 0, y: 1, z: 0, angle };
3610
+ if (!this.rule.transform) {
3611
+ this.rule.transform = {};
3612
+ }
3613
+ this.rule.transform.Rotate = { x: 0, y: 1, z: 0, angle };
3343
3614
  return this;
3344
3615
  }
3345
3616
  rotateZ(angle) {
3346
- this.rule.rotate = { x: 0, y: 0, z: 1, angle };
3617
+ if (!this.rule.transform) {
3618
+ this.rule.transform = {};
3619
+ }
3620
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
3347
3621
  return this;
3348
3622
  }
3349
3623
  scale(sx, sy) {
3350
- this.rule.scale = { x: sx, y: sy };
3624
+ if (!this.rule.transform) {
3625
+ this.rule.transform = {};
3626
+ }
3627
+ this.rule.transform.Scale = { x: sx, y: isUndefined(sy) ? sx : sy };
3351
3628
  return this;
3352
3629
  }
3353
3630
  scale3d(sx, sy, sz) {
3354
- this.rule.scale = { x: sx, y: sy, z: sz };
3631
+ if (!this.rule.transform) {
3632
+ this.rule.transform = {};
3633
+ }
3634
+ this.rule.transform.Scale = { x: sx, y: sy, z: sz };
3355
3635
  return this;
3356
3636
  }
3357
3637
  scaleX(scale) {
3358
- this.rule.scale = { x: scale };
3638
+ if (!this.rule.transform) {
3639
+ this.rule.transform = {};
3640
+ }
3641
+ this.rule.transform.Scale = { x: scale };
3359
3642
  return this;
3360
3643
  }
3361
3644
  scaleY(scale) {
3362
- this.rule.scale = { y: scale };
3645
+ if (!this.rule.transform) {
3646
+ this.rule.transform = {};
3647
+ }
3648
+ this.rule.transform.Scale = { y: scale };
3363
3649
  return this;
3364
3650
  }
3365
3651
  scaleZ(scale) {
3366
- this.rule.scale = { z: scale };
3652
+ if (!this.rule.transform) {
3653
+ this.rule.transform = {};
3654
+ }
3655
+ this.rule.transform.Scale = { z: scale };
3367
3656
  return this;
3368
3657
  }
3369
3658
  skew(ax, ay) {
3370
- this.rule.skew = { x: ax, y: ay };
3659
+ temporarilyNotSupport('animation.skew:' + `${ax}, ${ay}`)(ax, ay);
3371
3660
  return this;
3372
3661
  }
3373
3662
  skewX(angle) {
3374
- this.rule.skew = { x: angle };
3663
+ temporarilyNotSupport('animation.skewX:' + angle)(angle);
3375
3664
  return this;
3376
3665
  }
3377
3666
  skewY(angle) {
3378
- this.rule.skew = { y: angle };
3667
+ temporarilyNotSupport('animation.skewY:' + angle)(angle);
3379
3668
  return this;
3380
3669
  }
3381
3670
  translate(tx, ty) {
3382
- this.rule.translate = { x: tx, y: ty };
3671
+ if (!this.rule.transform) {
3672
+ this.rule.transform = {};
3673
+ }
3674
+ this.rule.transform.Translate = { x: tx, y: ty };
3383
3675
  return this;
3384
3676
  }
3385
3677
  translate3d(tx, ty, tz) {
3386
- this.rule.translate = { x: tx, y: ty, z: tz };
3678
+ if (!this.rule.transform) {
3679
+ this.rule.transform = {};
3680
+ }
3681
+ this.rule.transform.Translate = { x: tx, y: ty, z: tz };
3387
3682
  return this;
3388
3683
  }
3389
3684
  translateX(translation) {
3390
- this.rule.translate = { x: translation };
3685
+ if (!this.rule.transform) {
3686
+ this.rule.transform = {};
3687
+ }
3688
+ this.rule.transform.Translate = { x: translation };
3391
3689
  return this;
3392
3690
  }
3393
3691
  translateY(translation) {
3394
- this.rule.translate = { y: translation };
3692
+ if (!this.rule.transform) {
3693
+ this.rule.transform = {};
3694
+ }
3695
+ this.rule.transform.Translate = { y: translation };
3395
3696
  return this;
3396
3697
  }
3397
3698
  translateZ(translation) {
3398
- this.rule.translate = { z: translation };
3699
+ if (!this.rule.transform) {
3700
+ this.rule.transform = {};
3701
+ }
3702
+ this.rule.transform.Translate = { z: translation };
3399
3703
  return this;
3400
3704
  }
3401
3705
  opacity(value) {
@@ -3407,15 +3711,15 @@ class Animation {
3407
3711
  return this;
3408
3712
  }
3409
3713
  width(value) {
3410
- this.rule.size = Object.assign(Object.assign({}, this.rule.size), { width: value });
3714
+ this.rule.width = value;
3411
3715
  return this;
3412
3716
  }
3413
3717
  height(value) {
3414
- this.rule.size = Object.assign(Object.assign({}, this.rule.size), { height: value });
3718
+ this.rule.height = value;
3415
3719
  return this;
3416
3720
  }
3417
3721
  left(value) {
3418
- temporarilyNotSupport('animation.left:' + value)(value);
3722
+ this.rule.left = value;
3419
3723
  return this;
3420
3724
  }
3421
3725
  right(value) {
@@ -3423,7 +3727,7 @@ class Animation {
3423
3727
  return this;
3424
3728
  }
3425
3729
  top(value) {
3426
- temporarilyNotSupport('animation.top:' + value)(value);
3730
+ this.rule.top = value;
3427
3731
  return this;
3428
3732
  }
3429
3733
  bottom(value) {
@@ -3442,7 +3746,8 @@ function setBackgroundColor(options) {
3442
3746
  const handle = new MethodHandler({ name: 'setBackgroundColor', success, fail, complete });
3443
3747
  return new Promise((resolve, reject) => {
3444
3748
  eventCenter.trigger('__taroPageStyle', {
3445
- backgroundColor: options.backgroundColor || options.backgroundColorTop || options.backgroundColorBottom,
3749
+ backgroundColor: options.backgroundColorBottom || options.backgroundColor,
3750
+ backgroundColorContext: options.backgroundColorTop || options.backgroundColor
3446
3751
  });
3447
3752
  return handle.success({}, { resolve, reject });
3448
3753
  });
@@ -3458,6 +3763,7 @@ const nextTick = (cb, ctx) => {
3458
3763
  // 字体
3459
3764
  const loadFontFace = /* @__PURE__ */ temporarilyNotSupport('getMenuButtonBoundingClientRect');
3460
3765
 
3766
+ // @ts-ignore
3461
3767
  const resCallback = (res) => {
3462
3768
  return { errMsg: `${res}:ok` };
3463
3769
  };
@@ -3468,6 +3774,7 @@ const showToastSchema = {
3468
3774
  };
3469
3775
  function showToast(options) {
3470
3776
  return new Promise((resolve, reject) => {
3777
+ var _a, _b;
3471
3778
  const _default = {
3472
3779
  title: '',
3473
3780
  duration: 1500,
@@ -3481,10 +3788,15 @@ function showToast(options) {
3481
3788
  const res = { errMsg: error.message };
3482
3789
  return callAsyncFail(reject, res, options);
3483
3790
  }
3484
- prompt.showToast({
3791
+ // @ts-ignore
3792
+ const uiContext = (_b = (_a = Current === null || Current === void 0 ? void 0 : Current.page) === null || _a === void 0 ? void 0 : _a.getUIContext) === null || _b === void 0 ? void 0 : _b.call(_a);
3793
+ if (!uiContext)
3794
+ return;
3795
+ uiContext.getPromptAction().showToast({
3485
3796
  message: options.title,
3486
3797
  duration: options.duration,
3487
- bottom: options.bottom
3798
+ bottom: options.bottom,
3799
+ showMode: 1 // 设置弹窗显示模式,显示在应用之上。
3488
3800
  });
3489
3801
  callAsyncSuccess(resolve, resCallback('showToast'), options);
3490
3802
  });
@@ -3514,25 +3826,29 @@ function showModal(options) {
3514
3826
  color: confirmColor
3515
3827
  });
3516
3828
  }
3517
- return new Promise(resolve => {
3829
+ return new Promise((resolve, reject) => {
3830
+ var _a, _b;
3518
3831
  const modalOptions = {
3519
3832
  title,
3520
3833
  message: content,
3521
3834
  buttons: buttons,
3522
- success: (data) => {
3523
- if (data.index === 1 || !showCancel) {
3524
- callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: true, cancel: false, content: null }), options);
3525
- }
3526
- else {
3527
- callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: false, cancel: true }), options);
3528
- }
3529
- },
3530
- // 鸿蒙没有失败方法,只有取消
3531
- cancel: (_) => {
3835
+ };
3836
+ // @ts-ignore
3837
+ const uiContext = (_b = (_a = Current === null || Current === void 0 ? void 0 : Current.page) === null || _a === void 0 ? void 0 : _a.getUIContext) === null || _b === void 0 ? void 0 : _b.call(_a);
3838
+ if (!uiContext)
3839
+ return;
3840
+ uiContext.getPromptAction().showDialog(modalOptions, (error, data) => {
3841
+ if (error) {
3842
+ const res = { errMsg: error };
3843
+ callAsyncFail(reject, res, options);
3844
+ }
3845
+ if (data.index === 0 && showCancel) {
3532
3846
  callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: false, cancel: true }), options);
3533
3847
  }
3534
- };
3535
- prompt.showDialog(modalOptions);
3848
+ else {
3849
+ callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: true, cancel: false, content: null }), options);
3850
+ }
3851
+ });
3536
3852
  });
3537
3853
  }
3538
3854
  const showActionSheetSchema = {
@@ -3541,6 +3857,7 @@ const showActionSheetSchema = {
3541
3857
  };
3542
3858
  function showActionSheet(options) {
3543
3859
  return new Promise((resolve, reject) => {
3860
+ var _a, _b;
3544
3861
  const _default = {
3545
3862
  title: '',
3546
3863
  itemList: [],
@@ -3563,28 +3880,22 @@ function showActionSheet(options) {
3563
3880
  });
3564
3881
  const actionSheetOptions = {
3565
3882
  title,
3566
- buttons,
3567
- success: (data) => {
3568
- callAsyncSuccess(resolve, Object.assign(Object.assign({}, data), resCallback('showActionSheet')), options);
3569
- },
3570
- // 取消方法,并非失败
3571
- fail: (data) => {
3572
- callAsyncFail(reject, Object.assign(Object.assign({}, data), { errMsg: data.errMsg.replace('showActionMenu', 'showActionSheet') }), options);
3573
- }
3883
+ buttons
3574
3884
  };
3575
- prompt.showActionMenu(actionSheetOptions);
3576
- });
3577
- }
3578
- function hideToast(options) {
3579
- return new Promise(resolve => {
3580
- prompt.showToast({
3581
- message: '关闭中',
3582
- duration: 10,
3583
- bottom: '9999px'
3885
+ // @ts-ignore
3886
+ const uiContext = (_b = (_a = Current === null || Current === void 0 ? void 0 : Current.page) === null || _a === void 0 ? void 0 : _a.getUIContext) === null || _b === void 0 ? void 0 : _b.call(_a);
3887
+ if (!uiContext)
3888
+ return;
3889
+ uiContext.getPromptAction().showActionMenu(actionSheetOptions, (error, data) => {
3890
+ var _a;
3891
+ if (error) {
3892
+ callAsyncFail(reject, Object.assign(Object.assign({}, data), { errMsg: (_a = data.errMsg) === null || _a === void 0 ? void 0 : _a.replace('showActionMenu', 'showActionSheet') }), options);
3893
+ }
3894
+ callAsyncSuccess(resolve, Object.assign(Object.assign({}, data), resCallback('showActionSheet')), options);
3584
3895
  });
3585
- callAsyncSuccess(resolve, resCallback('hideToast'), options);
3586
3896
  });
3587
3897
  }
3898
+ const hideToast = /* @__PURE__ */ temporarilyNotSupport('hideToast');
3588
3899
  const showLoading = temporarilyNotSupport('showLoading');
3589
3900
  const hideLoading = temporarilyNotSupport('hideLoading');
3590
3901
  const enableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('enableAlertBeforeUnload');
@@ -3605,7 +3916,7 @@ const setNavigationBarTitle = function (options) {
3605
3916
  };
3606
3917
  const setNavigationBarColor = function (options) {
3607
3918
  const { success, fail, complete } = options || {};
3608
- const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete });
3919
+ const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete });
3609
3920
  return new Promise((resolve, reject) => {
3610
3921
  eventCenter.trigger('__taroNavigationStyle', {
3611
3922
  animation: options.animation,
@@ -3647,10 +3958,13 @@ const hideHomeButton = function (options) {
3647
3958
  };
3648
3959
 
3649
3960
  const startPullDownRefresh = function (options) {
3650
- return new Promise(resolve => {
3961
+ return new Promise((resolve, reject) => {
3651
3962
  var _a;
3652
3963
  const taro = Current.taro;
3653
3964
  const page = taro.getCurrentInstance().page;
3965
+ if (!page) {
3966
+ return callAsyncFail(reject, { errMsg: 'stopPullDownRefresh:fail' }, options);
3967
+ }
3654
3968
  if (page.isRefreshing instanceof Array) {
3655
3969
  const index = page.tabBarCurrentIndex || 0;
3656
3970
  page.isRefreshing[index] = true;
@@ -3664,10 +3978,13 @@ const startPullDownRefresh = function (options) {
3664
3978
  });
3665
3979
  };
3666
3980
  const stopPullDownRefresh = function (options) {
3667
- return new Promise(resolve => {
3981
+ return new Promise((resolve, reject) => {
3668
3982
  var _a;
3669
3983
  const taro = Current.taro;
3670
3984
  const page = taro.getCurrentInstance().page;
3985
+ if (!page) {
3986
+ return callAsyncFail(reject, { errMsg: 'stopPullDownRefresh:fail' }, options);
3987
+ }
3671
3988
  if (page.isRefreshing instanceof Array) {
3672
3989
  const index = page.tabBarCurrentIndex || 0;
3673
3990
  page.isRefreshing[index] = false;
@@ -3700,8 +4017,8 @@ const pageScrollTo = (options) => {
3700
4017
  const taro = Current.taro;
3701
4018
  const page = taro.getCurrentInstance().page;
3702
4019
  let scrollValue = -1;
3703
- let scroller = page.scroller;
3704
- const currentPageNode = getPageScrollerOrNode(page.node, page);
4020
+ let scroller = getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.scroller, page);
4021
+ const currentPageNode = getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
3705
4022
  if (scrollTop || typeof scrollTop === 'number') {
3706
4023
  scrollValue = scrollTop;
3707
4024
  }
@@ -3723,15 +4040,15 @@ const pageScrollTo = (options) => {
3723
4040
  scroller = getPageScrollerOrNode(scroller, page);
3724
4041
  const { yOffset } = scroller.currentOffset();
3725
4042
  if (areaInfo) {
3726
- scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper(offsetTop, 'px', true);
4043
+ scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper$1(offsetTop, 'px', true);
3727
4044
  }
3728
4045
  }
3729
- const { xOffset } = scroller.currentOffset();
3730
- if (scrollValue === -1) {
4046
+ if (!scroller || scrollValue === -1) {
3731
4047
  return handle.fail({
3732
4048
  errMsg: '请检查传入的 scrollTop 或 selector 是否合法'
3733
4049
  }, { resolve, reject });
3734
4050
  }
4051
+ const { xOffset } = scroller.currentOffset();
3735
4052
  try {
3736
4053
  scroller.scrollTo({
3737
4054
  xOffset,
@@ -3763,7 +4080,7 @@ const toggleTabBar = function (type) {
3763
4080
  var _a, _b;
3764
4081
  const taro = Current.taro;
3765
4082
  const page = taro.getCurrentInstance().page;
3766
- const currentData = ((_a = page._data) === null || _a === void 0 ? void 0 : _a.taroTabBar) || page.tabBar;
4083
+ 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);
3767
4084
  const res = { errMsg: `${type}TabBar:ok` };
3768
4085
  const error = { errMsg: `${type}TabBar:fail not TabBar page` };
3769
4086
  if (!currentData) {
@@ -3788,7 +4105,7 @@ const setTabBarStyle = function (options = {}) {
3788
4105
  var _a, _b;
3789
4106
  const taro = Current.taro;
3790
4107
  const page = taro.getCurrentInstance().page;
3791
- const currentData = ((_a = page._data) === null || _a === void 0 ? void 0 : _a.taroTabBar) || page.tabBar;
4108
+ 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);
3792
4109
  const res = { errMsg: 'setTabBarStyle:ok' };
3793
4110
  const error = { errMsg: 'setTabBarStyle:fail not TabBar page' };
3794
4111
  if (!currentData) {
@@ -3815,7 +4132,7 @@ const setTabBarItem = function (options) {
3815
4132
  var _a, _b;
3816
4133
  const taro = Current.taro;
3817
4134
  const page = taro.getCurrentInstance().page;
3818
- const currentData = ((_a = page._data) === null || _a === void 0 ? void 0 : _a.taroTabBar) || page.tabBar;
4135
+ 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);
3819
4136
  const res = { errMsg: 'setTabBarItem:ok' };
3820
4137
  const error = { errMsg: 'setTabBarItem:fail not TabBar page' };
3821
4138
  if (!currentData) {
@@ -3908,19 +4225,16 @@ class IntersectionObserver {
3908
4225
  };
3909
4226
  const taro = Current.taro;
3910
4227
  const page = taro.getCurrentInstance().page;
3911
- const currentPage = getPageScrollerOrNode(page.node, page);
3912
- this._component = component || currentPage;
4228
+ this._component = component || getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
3913
4229
  Object.assign(this._options, options);
3914
4230
  }
3915
4231
  disconnect() {
3916
- var _a;
3917
- if (this._observerNodes) {
4232
+ if (this._observerNodes && this._component) {
3918
4233
  if (this._observerNodes instanceof Array) {
3919
4234
  this._observerNodes.forEach((n) => {
3920
- var _a;
3921
4235
  disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME);
3922
4236
  // @ts-ignore
3923
- (_a = n._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = null;
4237
+ n._nodeInfo.thresholds = null;
3924
4238
  });
3925
4239
  }
3926
4240
  else {
@@ -3928,35 +4242,40 @@ class IntersectionObserver {
3928
4242
  // @ts-ignore
3929
4243
  if (this._observerNodes._nodeInfo) {
3930
4244
  // @ts-ignore
3931
- (_a = this._observerNodes._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = null;
4245
+ this._observerNodes._nodeInfo.thresholds = null;
3932
4246
  }
3933
4247
  }
3934
4248
  }
3935
4249
  }
3936
4250
  observe(targetSelector, callback) {
3937
- var _a;
4251
+ if (!this._component)
4252
+ return;
3938
4253
  const { observeAll, thresholds } = this._options;
3939
4254
  const node = findChildNodeWithDFS(this._component, targetSelector, observeAll);
3940
4255
  this._observerNodes = node;
3941
4256
  if (node) {
3942
4257
  if (node instanceof Array) {
3943
4258
  node.forEach(n => {
3944
- var _a;
3945
4259
  // @ts-ignore
3946
- (_a = n._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = thresholds;
4260
+ n._nodeInfo.thresholds = thresholds;
3947
4261
  setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3948
- callback(this.handleResult(isVisible, currentRatio));
4262
+ callback(this.handleResult(isVisible, currentRatio, n));
3949
4263
  });
3950
4264
  });
3951
4265
  }
3952
4266
  else {
3953
4267
  // @ts-ignore
3954
- (_a = node._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = thresholds;
4268
+ node._nodeInfo.thresholds = thresholds;
3955
4269
  setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3956
- callback(this.handleResult(isVisible, currentRatio));
4270
+ callback(this.handleResult(isVisible, currentRatio, node));
3957
4271
  });
3958
4272
  }
3959
4273
  }
4274
+ else {
4275
+ callback({
4276
+ errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
4277
+ });
4278
+ }
3960
4279
  }
3961
4280
  relativeTo() {
3962
4281
  temporarilyNotSupport('relativeTo')();
@@ -3967,8 +4286,10 @@ class IntersectionObserver {
3967
4286
  return this;
3968
4287
  }
3969
4288
  // @ts-ignore
3970
- handleResult(isVisible, currentRatio) {
4289
+ handleResult(isVisible, currentRatio, node) {
3971
4290
  const result = {
4291
+ id: node.id,
4292
+ dataset: node.dataset,
3972
4293
  intersectionRatio: currentRatio,
3973
4294
  // TODO 未做,等待能拿到element的info信息
3974
4295
  boundingClientRect: {
@@ -4176,32 +4497,45 @@ function filter(fields, dom) {
4176
4497
  }
4177
4498
  function querySelector(selector, selectAll) {
4178
4499
  if (typeof selector === 'string') {
4179
- return parseHandler(selector, selectAll);
4500
+ return selector.split(',').reduce((prev, current) => {
4501
+ const item = current.trim();
4502
+ return prev.concat(parseHandler(item, selectAll));
4503
+ }, []);
4180
4504
  }
4181
- return null;
4505
+ return [];
4182
4506
  }
4183
4507
  function queryBat(queue, cb) {
4184
4508
  const result = [];
4185
4509
  const taro = Current.taro;
4186
4510
  const page = taro.getCurrentInstance().page;
4187
- const element = getPageScrollerOrNode(page.node, page);
4188
- if (element == null)
4511
+ const element = getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
4512
+ if (!element)
4189
4513
  return null;
4190
4514
  arr = [];
4191
4515
  traversalDFSDom(element);
4192
- queue.forEach(item => {
4516
+ queue.forEach((item) => {
4193
4517
  const { selector, single, fields } = item;
4194
- const nodeList = querySelector(selector, !single);
4195
- result.push(nodeList.map(dom => {
4518
+ if (single) {
4519
+ const dom = querySelector(selector, !single)[0];
4196
4520
  // eslint-disable-next-line no-async-promise-executor
4197
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
4521
+ result.push(new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
4198
4522
  yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
4199
4523
  resolve(filter(fields, dom));
4524
+ })));
4525
+ }
4526
+ else {
4527
+ const nodeList = querySelector(selector, !single);
4528
+ result.push(nodeList.map(dom => {
4529
+ // eslint-disable-next-line no-async-promise-executor
4530
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
4531
+ yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
4532
+ resolve(filter(fields, dom));
4533
+ }));
4200
4534
  }));
4201
- }));
4535
+ }
4202
4536
  });
4203
4537
  Promise.all(result.map(item => {
4204
- return Promise.all(item);
4538
+ return item instanceof Array ? Promise.all(item) : item;
4205
4539
  })).then(data => {
4206
4540
  cb(data);
4207
4541
  });
@@ -4280,6 +4614,7 @@ var apis = /*#__PURE__*/Object.freeze({
4280
4614
  ENV_TYPE: ENV_TYPE,
4281
4615
  Events: Events,
4282
4616
  History: History,
4617
+ IntersectionObserver: IntersectionObserver,
4283
4618
  addCard: addCard,
4284
4619
  addFileToFavorites: addFileToFavorites,
4285
4620
  addPhoneCalendar: addPhoneCalendar,
@@ -4669,7 +5004,7 @@ var apis = /*#__PURE__*/Object.freeze({
4669
5004
  writeBLECharacteristicValue: writeBLECharacteristicValue
4670
5005
  });
4671
5006
 
4672
- Object.assign({}, apis);
5007
+ const taro = Object.assign({}, apis);
4673
5008
  const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin');
4674
5009
  function initNativeApi(taro) {
4675
5010
  Current.taro = taro;
@@ -4693,7 +5028,7 @@ const defaultBaseFontSize = 20;
4693
5028
  const defaultUnitPrecision = 5;
4694
5029
  const defaultTargetUnit = 'vp';
4695
5030
  function getApp$1() {
4696
- return Current.app;
5031
+ return Current.app || {};
4697
5032
  }
4698
5033
  function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
4699
5034
  const taro = Current.taro;
@@ -4707,19 +5042,56 @@ function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defau
4707
5042
  config.unitPrecision = unitPrecision;
4708
5043
  }
4709
5044
  }
4710
- _display.getDefaultDisplaySync();
5045
+ const display = _display.getDefaultDisplaySync();
5046
+ let displayWidth = display.width;
5047
+ let ratioCache = false;
5048
+ let designWidthFunc;
5049
+ let designWidth = defaultDesignWidth;
5050
+ function getRatio(value) {
5051
+ var _a;
5052
+ // Note: 提前调用 display 可能无法获取正确值
5053
+ if (ratioCache === false || displayWidth !== display.width) {
5054
+ const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
5055
+ if (!isFunction(designWidthFunc)) {
5056
+ designWidthFunc = isFunction(config.designWidth)
5057
+ ? config.designWidth
5058
+ : () => config.designWidth;
5059
+ designWidth = designWidthFunc(value) || defaultDesignWidth;
5060
+ }
5061
+ displayWidth = display.width;
5062
+ ratioCache = Math.min(display.width, display.height) / designWidth;
5063
+ }
5064
+ return ratioCache;
5065
+ }
5066
+ // Note: 设置为 style 单位时会自动完成设计稿转换,设计开发者调用 API 时也许抹平差异,例如 pageScrollTo[option.offsetTop]
5067
+ function pxTransformHelper(size, unit, isNumber = false) {
5068
+ var _a;
5069
+ const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
5070
+ const targetUnit = unit || config.targetUnit || defaultTargetUnit;
5071
+ if (targetUnit === 'PX') {
5072
+ return px2vp(size * display.scaledDensity) + 'vp';
5073
+ }
5074
+ const ratio = getRatio(size);
5075
+ let val = size * ratio;
5076
+ switch (targetUnit) {
5077
+ case 'vp':
5078
+ // Note: 在应用创建前调用无效
5079
+ val = px2vp(val);
5080
+ break;
5081
+ }
5082
+ return isNumber ? val : val + targetUnit;
5083
+ }
4711
5084
  function pxTransform(size) {
4712
5085
  var _a;
4713
5086
  const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
4714
5087
  const targetUnit = config.targetUnit || defaultTargetUnit;
4715
- let val = size;
5088
+ const val = size;
4716
5089
  switch (targetUnit) {
4717
5090
  case 'vp':
4718
- val = px2vp(size);
4719
- break;
5091
+ return pxTransformHelper(size, 'px');
4720
5092
  // NOTE: 鸿蒙环境下 style 会自动完成设计稿转换,无需在方法内二次调整
4721
5093
  }
4722
- return val + config.targetUnit;
5094
+ return val + targetUnit;
4723
5095
  }
4724
5096
  function canIUseWebp() {
4725
5097
  return true;
@@ -4733,6 +5105,7 @@ function getAppInfo() {
4733
5105
  designWidth: config === null || config === void 0 ? void 0 : config.designWidth,
4734
5106
  };
4735
5107
  }
5108
+ initNativeApi(taro);
4736
5109
 
4737
5110
  const components = {
4738
5111
  Checkbox: {