@tarojs/plugin-platform-harmony-ets 4.0.0-beta.6 → 4.0.0-beta.61

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 (126) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +9 -0
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +27 -17
  6. package/dist/apis/network/request.ts +5 -5
  7. package/dist/apis/route/index.ts +15 -0
  8. package/dist/apis/storage/index.ts +148 -80
  9. package/dist/apis/ui/animation/animation.ts +71 -28
  10. package/dist/apis/ui/background.ts +2 -1
  11. package/dist/apis/ui/interaction/index.ts +42 -59
  12. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  13. package/dist/apis/ui/scroll/index.ts +1 -1
  14. package/dist/apis/utils/index.ts +1 -1
  15. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  16. package/dist/apis/wxml/index.ts +2 -0
  17. package/dist/apis/wxml/selectorQuery.ts +25 -12
  18. package/dist/components-harmony-ets/button.ets +48 -34
  19. package/dist/components-harmony-ets/canvas.ets +51 -0
  20. package/dist/components-harmony-ets/checkbox.ets +69 -61
  21. package/dist/components-harmony-ets/form.ets +51 -29
  22. package/dist/components-harmony-ets/icon.ets +31 -19
  23. package/dist/components-harmony-ets/image.ets +34 -14
  24. package/dist/components-harmony-ets/index.ets +92 -0
  25. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  26. package/dist/components-harmony-ets/input.ets +42 -40
  27. package/dist/components-harmony-ets/label.ets +69 -42
  28. package/dist/components-harmony-ets/listView.ets +26 -0
  29. package/dist/components-harmony-ets/movableArea.ets +126 -0
  30. package/dist/components-harmony-ets/movableView.ets +73 -0
  31. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  32. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  33. package/dist/components-harmony-ets/picker.ets +42 -38
  34. package/dist/components-harmony-ets/progress.ets +52 -0
  35. package/dist/components-harmony-ets/pseudo.ets +80 -0
  36. package/dist/components-harmony-ets/radio.ets +71 -64
  37. package/dist/components-harmony-ets/richText.ets +14 -30
  38. package/dist/components-harmony-ets/scrollList.ets +94 -0
  39. package/dist/components-harmony-ets/scrollView.ets +61 -57
  40. package/dist/components-harmony-ets/slider.ets +15 -14
  41. package/dist/components-harmony-ets/stickySection.ets +42 -0
  42. package/dist/components-harmony-ets/style.ets +372 -130
  43. package/dist/components-harmony-ets/swiper.ets +61 -20
  44. package/dist/components-harmony-ets/switch.ets +30 -28
  45. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  46. package/dist/components-harmony-ets/text.ets +159 -51
  47. package/dist/components-harmony-ets/textArea.ets +35 -34
  48. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  49. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  50. package/dist/components-harmony-ets/utils/flexManager.ets +47 -19
  51. package/dist/components-harmony-ets/utils/helper.ets +18 -5
  52. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  53. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  54. package/dist/components-harmony-ets/utils/index.ts +54 -50
  55. package/dist/components-harmony-ets/utils/styles.ets +170 -93
  56. package/dist/components-harmony-ets/video.ets +34 -20
  57. package/dist/components-harmony-ets/view.ets +63 -52
  58. package/dist/components-harmony-ets/webView.ets +40 -34
  59. package/dist/index.d.ts +152 -0
  60. package/dist/index.js +82 -39
  61. package/dist/index.js.map +1 -1
  62. package/dist/runtime-ets/bom/document.ts +6 -4
  63. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  64. package/dist/runtime-ets/bom/window.ts +7 -0
  65. package/dist/runtime-ets/current.ts +3 -0
  66. package/dist/runtime-ets/dom/bind.ts +30 -13
  67. package/dist/runtime-ets/dom/cssNesting.ts +411 -0
  68. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +27 -41
  69. package/dist/runtime-ets/dom/document.ts +22 -8
  70. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  71. package/dist/runtime-ets/dom/element/element.ts +334 -58
  72. package/dist/runtime-ets/dom/element/form.ts +23 -26
  73. package/dist/runtime-ets/dom/element/index.ts +25 -2
  74. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  75. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  76. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  77. package/dist/runtime-ets/dom/element/progress.ts +12 -0
  78. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  79. package/dist/runtime-ets/dom/element/text.ts +1 -8
  80. package/dist/runtime-ets/dom/element/video.ts +5 -3
  81. package/dist/runtime-ets/dom/element/webView.ts +11 -3
  82. package/dist/runtime-ets/dom/event.ts +0 -1
  83. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  84. package/dist/runtime-ets/dom/node.ts +46 -28
  85. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +416 -235
  86. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  87. package/dist/runtime-ets/dom/stylesheet/type.ts +49 -9
  88. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  89. package/dist/runtime-ets/index.ts +2 -2
  90. package/dist/runtime-ets/interface/event.ts +1 -1
  91. package/dist/runtime-ets/utils/index.ts +67 -11
  92. package/dist/runtime-ets/utils/info.ts +1 -1
  93. package/dist/runtime-framework/react/app.ts +7 -2
  94. package/dist/runtime-framework/react/index.ts +0 -2
  95. package/dist/runtime-framework/react/native-page.ts +32 -14
  96. package/dist/runtime-framework/react/page.ts +3 -8
  97. package/dist/runtime-framework/solid/app.ts +25 -45
  98. package/dist/runtime-framework/solid/connect.ts +21 -3
  99. package/dist/runtime-framework/solid/hooks.ts +16 -11
  100. package/dist/runtime-framework/solid/index.ts +6 -2
  101. package/dist/runtime-framework/solid/page.ts +84 -30
  102. package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
  103. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  104. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  105. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  106. package/dist/runtime-utils.d.ts +827 -0
  107. package/dist/runtime-utils.js +411 -200
  108. package/dist/runtime-utils.js.map +1 -1
  109. package/dist/runtime.d.ts +1 -0
  110. package/dist/runtime.js +411 -200
  111. package/dist/runtime.js.map +1 -1
  112. package/index.js +3 -1
  113. package/package.json +13 -13
  114. package/static/media/cancel.svg +1 -1
  115. package/static/media/circle.svg +1 -1
  116. package/static/media/clear.svg +1 -1
  117. package/static/media/download.svg +1 -1
  118. package/static/media/info.svg +1 -1
  119. package/static/media/info_circle.svg +1 -1
  120. package/static/media/search.svg +1 -1
  121. package/static/media/success.svg +1 -1
  122. package/static/media/success_no_circle.svg +1 -1
  123. package/static/media/warn.svg +1 -1
  124. package/types/harmony.d.ts +4 -0
  125. package/types/index.d.ts +4 -0
  126. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,14 +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, 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
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
8
  import errorManager from '@ohos.app.ability.errorManager';
9
9
  import sensor from '@ohos.sensor';
10
10
  import batteryInfo, { BatteryChargeState } from '@ohos.batteryInfo';
11
11
  import pasteboard from '@ohos.pasteboard';
12
+ import promptAction from '@ohos.promptAction';
12
13
  import inputMethodEngine from '@ohos.inputMethodEngine';
13
14
  import network from '@system.network';
14
15
  import call from '@ohos.telephony.call';
@@ -28,11 +29,9 @@ import http from '@ohos.net.http';
28
29
  import webSocket from '@ohos.net.webSocket';
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';
35
- import { pxTransformHelper } from '@tarojs/taro';
34
+ import { pxTransformHelper as pxTransformHelper$1 } from '@tarojs/taro';
36
35
 
37
36
  class MethodHandler {
38
37
  constructor({ name, success, fail, complete }) {
@@ -186,7 +185,7 @@ function temporarilyNotSupport(name, recommended) {
186
185
  return (option = {}, ...args) => {
187
186
  const { success, fail, complete } = option;
188
187
  const handle = new MethodHandler({ name, success, fail, complete });
189
- let errMsg = '暂时不支持 API';
188
+ let errMsg = `暂时不支持 API ${name}`;
190
189
  if (recommended) {
191
190
  errMsg += `, 请使用 ${recommended}`;
192
191
  }
@@ -266,16 +265,49 @@ const preloadWebview = /* @__PURE__ */ temporarilyNotSupport('preloadWebview');
266
265
  const preloadSkylineView = /* @__PURE__ */ temporarilyNotSupport('preloadSkylineView');
267
266
  const preloadAssets = /* @__PURE__ */ temporarilyNotSupport('preloadAssets');
268
267
 
269
- // 设备信息,从 API Version 6 开始支持
270
- const display = _display.getDefaultDisplaySync();
271
- let device;
272
- deviceMethod.getInfo({
273
- success: data => {
274
- device = data;
275
- }
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
+ // @ts-ignore
283
+ display$1.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} } = {}) => {
284
+ var _a, _b, _c, _d, _e, _f;
285
+ if (err === null || err === void 0 ? void 0 : err.code) {
286
+ console.error('Failed to get cutout info', JSON.stringify(err));
287
+ return;
288
+ }
289
+ 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);
290
+ 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);
291
+ const left = ((_d = waterfallDisplayAreaRects.left) === null || _d === void 0 ? void 0 : _d.left) + ((_e = waterfallDisplayAreaRects.left) === null || _e === void 0 ? void 0 : _e.width);
292
+ const right = display$1.width - ((_f = waterfallDisplayAreaRects.right) === null || _f === void 0 ? void 0 : _f.left);
293
+ safeArea = {
294
+ top,
295
+ bottom,
296
+ left,
297
+ right,
298
+ height: bottom - top,
299
+ width: right - left,
300
+ };
301
+ });
302
+ }
303
+ catch (e) {
304
+ console.error('Failed to get display', e);
305
+ }
306
+ });
276
307
  });
277
308
  /* 同步版本 */
278
309
  const getSystemInfoSync = function () {
310
+ var _a, _b;
279
311
  const res = {};
280
312
  res.SDKVersion = deviceInfo && deviceInfo.sdkApiVersion; // 客户端基础库版本 string
281
313
  res.albumAuthorized = false; // 允许使用相册的开关(仅 iOS 有效) boolean
@@ -285,7 +317,7 @@ const getSystemInfoSync = function () {
285
317
  res.cameraAuthorized = null; // 允许使用摄像头的开关 boolean
286
318
  res.enableDebug = null; // 是否已打开调试 boolean
287
319
  res.fontSizeSetting = null; // 用户字体大小(单位px) number
288
- res.language = i18n && i18n.getSystemLanguage && i18n.getSystemLanguage(); // string
320
+ res.language = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.getSystemLanguage) === null || _a === void 0 ? void 0 : _a.call(i18n); // string
289
321
  res.locationAuthorized = null; // 定位的开关 boolean
290
322
  res.locationEnabled = null; // 地理位置的系统开关 boolean
291
323
  res.microphoneAuthorized = null; // 麦克风的开关 boolean
@@ -296,17 +328,18 @@ const getSystemInfoSync = function () {
296
328
  res.notificationSoundAuthorized = false; // 通知带有声音的开关(仅 iOS 有效)boolean
297
329
  res.phoneCalendarAuthorized = null; // 使用日历的开关 boolean
298
330
  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
331
+ res.pixelRatio = display$1 && display$1.densityPixels; // 设备像素比,number
332
+ res.platform = 'harmony'; // 客户端平台 string
333
+ res.safeArea = safeArea; // 在竖屏正方向下的安全区域 General.SafeAreaResult
334
+ res.screenHeight = display$1 === null || display$1 === void 0 ? void 0 : display$1.height; // 屏幕高度,单位px number
335
+ res.screenWidth = display$1 === null || display$1 === void 0 ? void 0 : display$1.width; // 屏幕宽度,单位px number
336
+ res.statusBarHeight = statusBarHeight; // 状态栏的高度,单位px number
337
+ res.system = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.osFullName; // 操作系统及版本 string
338
+ // Note: 更新配置时才能记录
339
+ 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'
340
+ res.windowHeight = windowRect === null || windowRect === void 0 ? void 0 : windowRect.height; // 可使用窗口高度,单位px number
341
+ res.windowWidth = windowRect === null || windowRect === void 0 ? void 0 : windowRect.width; // 可使用窗口宽度,单位px number
342
+ res.version = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.displayVersion; // 版本号 string
310
343
  return res;
311
344
  };
312
345
  /* 异步版本 */
@@ -412,7 +445,13 @@ const base64ToArrayBuffer = /* @__PURE__ */ temporarilyNotSupport('base64ToArray
412
445
  /** 创建离屏 canvas 实例 */
413
446
  const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
414
447
  /** 创建 canvas 的绘图上下文 CanvasContext 对象 */
415
- const createCanvasContext = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
448
+
449
+ const createCanvasContext = (canvasId) => {
450
+ const dom = eventSource.get(`canvasId-${canvasId}`);
451
+ // return dom as TaroCanvasElement
452
+ if (dom)
453
+ return dom.context;
454
+ };
416
455
  /** 把当前画布指定区域的内容导出生成指定大小的图片 */
417
456
  const canvasToTempFilePath = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
418
457
  /** 将像素数据绘制到画布 */
@@ -617,6 +656,12 @@ const setClipboardData = function (options) {
617
656
  callAsyncFail(reject, res, options);
618
657
  }
619
658
  else {
659
+ promptAction.showToast({
660
+ message: '内容已复制',
661
+ duration: 1500,
662
+ bottom: '50%',
663
+ showMode: 1 // 设置弹窗显示模式,显示在应用之上。
664
+ });
620
665
  return handle.success({
621
666
  data,
622
667
  }, { resolve, reject });
@@ -1984,7 +2029,6 @@ function getEnv() {
1984
2029
  }
1985
2030
  // TODO
1986
2031
  const getCurrentPages = () => [];
1987
- const getCurrentInstance = () => Current;
1988
2032
  const requirePlugin$1 = temporarilyNotSupport('requirePlugin');
1989
2033
 
1990
2034
  // @ts-nocheck
@@ -2611,10 +2655,10 @@ const request = function (options) {
2611
2655
  header['Content-Type'] = 'application/json';
2612
2656
  }
2613
2657
  // 检查 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
- }
2658
+ // if (isUndefined(header.Referer)) {
2659
+ // const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
2660
+ // callAsyncFail(reject, error, options)
2661
+ // }
2618
2662
  // 检查 method 是否正确
2619
2663
  if (method) {
2620
2664
  if (!METHOD.includes(method)) {
@@ -3060,6 +3104,19 @@ function parseURL(raw = '') {
3060
3104
  const [urlStr, queryStr = ''] = raw.split('?');
3061
3105
  const query = queryToJson(queryStr);
3062
3106
  let url = urlStr.replace(/^\//, '');
3107
+ // 处理相对路径
3108
+ if (url.indexOf('.') === 0) {
3109
+ const page = router.getState();
3110
+ const parts = page.path.split('/');
3111
+ parts.pop();
3112
+ url.split('/').forEach((item) => {
3113
+ if (item === '.') {
3114
+ return;
3115
+ }
3116
+ item === '..' ? parts.pop() : parts.push(item);
3117
+ });
3118
+ url = parts.join('/');
3119
+ }
3063
3120
  if (isTabPage(url)) {
3064
3121
  query.$page = url;
3065
3122
  url = TARO_TABBAR_PAGE_PATH;
@@ -3177,113 +3234,172 @@ const getBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('getBackgro
3177
3234
  // 周期性更新
3178
3235
  const createCacheManager = /* @__PURE__ */ temporarilyNotSupport('createCacheManager');
3179
3236
 
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);
3237
+ /**
3238
+ * 从API Version 6开始,该模块不再维护,可以使用模块@ohos.data.storage。在API Version 9后,推荐使用新模块@ohos.data.preferences。
3239
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references-V3/js-apis-data-preferences-0000001427745052-V3
3240
+ */
3241
+ let context;
3242
+ let kvManager;
3243
+ let kvStore;
3244
+ let kvStorePromise;
3245
+ Current.contextPromise.then((ctx) => {
3246
+ context = ctx;
3247
+ const kvManagerConfig = {
3248
+ context: context,
3249
+ bundleName: 'com.example.taro'
3250
+ };
3251
+ try {
3252
+ // 创建KVManager实例
3253
+ kvManager = distributedKVStore.createKVManager(kvManagerConfig);
3254
+ // 继续创建获取数据库
3255
+ const options = {
3256
+ createIfMissing: true,
3257
+ encrypt: false,
3258
+ backup: false,
3259
+ autoSync: false,
3260
+ // kvStoreType不填时,默认创建多设备协同数据库
3261
+ kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
3262
+ // 多设备协同数据库:kvStoreType: distributedKVStore.KVStoreType.DEVICE_COLLABORATION,
3263
+ securityLevel: distributedKVStore.SecurityLevel.S1
3264
+ };
3265
+ const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
3266
+ kvStorePromise = new Promise(resolve => {
3267
+ kvManager.getKVStore(`${data.appInfo.uid}Store`, options, (err, store) => {
3268
+ if (err) {
3269
+ console.error(`Failed to get KVStore: Code:${err.code},message:${err.message}`);
3270
+ return;
3271
+ }
3272
+ kvStore = store;
3273
+ // 请确保获取到键值数据库实例后,再进行相关数据操作
3274
+ resolve();
3275
+ });
3276
+ });
3277
+ }
3278
+ catch (e) {
3279
+ console.error(`Failed to create KVManager. Code:${e.code},message:${e.message}`);
3280
+ }
3281
+ return context;
3191
3282
  });
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
3283
  const storageSchema = {
3205
3284
  key: 'String'
3206
3285
  };
3207
- function getStorage(options) {
3208
- return new Promise((resolve, reject) => {
3209
- try {
3210
- validateParams('getStorage', options, storageSchema);
3286
+ function checkContextExist(api, isAsync = false) {
3287
+ if (!context) {
3288
+ const message = `${api} 调用失败,Taro 不支持过早地调用 ${api},请确保页面已经渲染完成再调用此 API`;
3289
+ if (isAsync) {
3290
+ return {
3291
+ isExist: false,
3292
+ error: Promise.reject(new Error(message))
3293
+ };
3211
3294
  }
3212
- catch (error) {
3213
- const res = { errMsg: error.message };
3214
- return callAsyncFail(reject, res, options);
3295
+ else {
3296
+ console.warn(message);
3297
+ return {
3298
+ isExist: false,
3299
+ };
3215
3300
  }
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);
3301
+ }
3302
+ return {
3303
+ isExist: true,
3304
+ };
3305
+ }
3306
+ function getStorage(options) {
3307
+ const name = 'getStorage';
3308
+ const { isExist, error } = checkContextExist(name, true);
3309
+ if (!isExist) {
3310
+ return error;
3311
+ }
3312
+ const { key, success, fail, complete } = options || {};
3313
+ const handle = new MethodHandler({ name, success, fail, complete });
3314
+ return new Promise((resolve, reject) => {
3315
+ kvStorePromise.then(() => {
3316
+ try {
3317
+ validateParams(name, options, storageSchema);
3221
3318
  }
3222
- else {
3223
- res.errMsg = 'getStorage:fail data not found';
3224
- callAsyncFail(reject, res, options);
3319
+ catch (error) {
3320
+ const res = { errMsg: error.message };
3321
+ return handle.fail(res, { resolve, reject });
3225
3322
  }
3323
+ kvStore = kvStore;
3324
+ kvStore.get(key, (err, data) => {
3325
+ if (err) {
3326
+ handle.fail({ errMsg: `Failed to get data. Code:${err.code},message:${err.message}` }, { resolve, reject });
3327
+ return;
3328
+ }
3329
+ handle.success({ data }, { resolve, reject });
3330
+ });
3226
3331
  });
3227
3332
  });
3228
3333
  }
3229
3334
  function setStorage(options) {
3335
+ const name = 'setStorage';
3336
+ const { isExist, error } = checkContextExist(name, true);
3337
+ if (!isExist) {
3338
+ return error;
3339
+ }
3340
+ const { key, data, success, fail, complete } = options || {};
3341
+ const handle = new MethodHandler({ name, success, fail, complete });
3230
3342
  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
- }));
3343
+ kvStorePromise.then(() => {
3344
+ try {
3345
+ validateParams(name, options, storageSchema);
3346
+ }
3347
+ catch (error) {
3348
+ const res = { errMsg: error.message };
3349
+ return handle.fail(res, { resolve, reject });
3350
+ }
3351
+ kvStore = kvStore;
3352
+ kvStore.put(key, data, (err) => {
3353
+ if (err) {
3354
+ handle.fail({ errMsg: `Failed to put data. Code:${err.code},message:${err.message}` }, { resolve, reject });
3355
+ return;
3356
+ }
3357
+ handle.success({}, { resolve, reject });
3358
+ });
3359
+ });
3245
3360
  });
3246
3361
  }
3247
3362
  function removeStorage(options) {
3363
+ const name = 'removeStorage';
3364
+ const { isExist, error } = checkContextExist(name, true);
3365
+ if (!isExist) {
3366
+ return error;
3367
+ }
3368
+ const { key, success, fail, complete } = options || {};
3369
+ const handle = new MethodHandler({ name, success, fail, complete });
3248
3370
  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
- }));
3371
+ kvStorePromise.then(() => {
3372
+ try {
3373
+ validateParams(name, options, storageSchema);
3374
+ }
3375
+ catch (error) {
3376
+ const res = { errMsg: error.message };
3377
+ return handle.fail(res, { resolve, reject });
3378
+ }
3379
+ kvStore = kvStore;
3380
+ kvStore.delete(key, (err) => {
3381
+ if (err) {
3382
+ handle.fail({ errMsg: `Failed to delete data. Code:${err.code},message:${err.message}` }, { resolve, reject });
3383
+ return;
3384
+ }
3385
+ handle.success({}, { resolve, reject });
3386
+ });
3387
+ });
3273
3388
  });
3274
3389
  }
3275
3390
  const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync');
3276
3391
  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
3392
  const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL');
3282
3393
  const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL');
3283
3394
  const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStorageSync');
3284
3395
  const batchSetStorage = /* @__PURE__ */ temporarilyNotSupport('batchSetStorage');
3285
3396
  const batchGetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchGetStorageSync');
3286
3397
  const batchGetStorage = /* @__PURE__ */ temporarilyNotSupport('batchGetStorage');
3398
+ const clearStorage = temporarilyNotSupport('clearStorage');
3399
+ const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage');
3400
+ const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage');
3401
+ const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage');
3402
+ const removeStorageSync = temporarilyNotSupport('removeStorageSync', 'removeStorage');
3287
3403
 
3288
3404
  class Animation {
3289
3405
  constructor({ duration = 400, delay = 0, timingFunction = 'linear', transformOrigin = '50% 50% 0', unit = 'px' } = {}) {
@@ -3316,6 +3432,9 @@ class Animation {
3316
3432
  transformOrigin,
3317
3433
  rule: Object.assign({}, this.rule)
3318
3434
  });
3435
+ if (this.rule.transform) {
3436
+ this.rule.transform = Object.assign({}, this.rule.transform);
3437
+ }
3319
3438
  return this;
3320
3439
  }
3321
3440
  matrix(a, b, c, d, tx, ty) {
@@ -3327,75 +3446,120 @@ class Animation {
3327
3446
  return this;
3328
3447
  }
3329
3448
  rotate(angle) {
3330
- this.rule.rotate = { x: 0, y: 0, z: 1, angle };
3449
+ if (!this.rule.transform) {
3450
+ this.rule.transform = {};
3451
+ }
3452
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
3331
3453
  return this;
3332
3454
  }
3333
3455
  rotate3d(x, y, z, angle) {
3334
- this.rule.rotate = { x, y, z, angle };
3456
+ if (!this.rule.transform) {
3457
+ this.rule.transform = {};
3458
+ }
3459
+ this.rule.transform.Rotate = { x, y, z, angle };
3335
3460
  return this;
3336
3461
  }
3337
3462
  rotateX(angle) {
3338
- this.rule.rotate = { x: 1, y: 0, z: 0, angle };
3463
+ if (!this.rule.transform) {
3464
+ this.rule.transform = {};
3465
+ }
3466
+ this.rule.transform.Rotate = { x: 1, y: 0, z: 0, angle };
3339
3467
  return this;
3340
3468
  }
3341
3469
  rotateY(angle) {
3342
- this.rule.rotate = { x: 0, y: 1, z: 0, angle };
3470
+ if (!this.rule.transform) {
3471
+ this.rule.transform = {};
3472
+ }
3473
+ this.rule.transform.Rotate = { x: 0, y: 1, z: 0, angle };
3343
3474
  return this;
3344
3475
  }
3345
3476
  rotateZ(angle) {
3346
- this.rule.rotate = { x: 0, y: 0, z: 1, angle };
3477
+ if (!this.rule.transform) {
3478
+ this.rule.transform = {};
3479
+ }
3480
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
3347
3481
  return this;
3348
3482
  }
3349
3483
  scale(sx, sy) {
3350
- this.rule.scale = { x: sx, y: sy };
3484
+ if (!this.rule.transform) {
3485
+ this.rule.transform = {};
3486
+ }
3487
+ this.rule.transform.Scale = { x: sx, y: isUndefined(sy) ? sx : sy };
3351
3488
  return this;
3352
3489
  }
3353
3490
  scale3d(sx, sy, sz) {
3354
- this.rule.scale = { x: sx, y: sy, z: sz };
3491
+ if (!this.rule.transform) {
3492
+ this.rule.transform = {};
3493
+ }
3494
+ this.rule.transform.Scale = { x: sx, y: sy, z: sz };
3355
3495
  return this;
3356
3496
  }
3357
3497
  scaleX(scale) {
3358
- this.rule.scale = { x: scale };
3498
+ if (!this.rule.transform) {
3499
+ this.rule.transform = {};
3500
+ }
3501
+ this.rule.transform.Scale = { x: scale };
3359
3502
  return this;
3360
3503
  }
3361
3504
  scaleY(scale) {
3362
- this.rule.scale = { y: scale };
3505
+ if (!this.rule.transform) {
3506
+ this.rule.transform = {};
3507
+ }
3508
+ this.rule.transform.Scale = { y: scale };
3363
3509
  return this;
3364
3510
  }
3365
3511
  scaleZ(scale) {
3366
- this.rule.scale = { z: scale };
3512
+ if (!this.rule.transform) {
3513
+ this.rule.transform = {};
3514
+ }
3515
+ this.rule.transform.Scale = { z: scale };
3367
3516
  return this;
3368
3517
  }
3369
3518
  skew(ax, ay) {
3370
- this.rule.skew = { x: ax, y: ay };
3519
+ temporarilyNotSupport('animation.skew:' + `${ax}, ${ay}`)(ax, ay);
3371
3520
  return this;
3372
3521
  }
3373
3522
  skewX(angle) {
3374
- this.rule.skew = { x: angle };
3523
+ temporarilyNotSupport('animation.skewX:' + angle)(angle);
3375
3524
  return this;
3376
3525
  }
3377
3526
  skewY(angle) {
3378
- this.rule.skew = { y: angle };
3527
+ temporarilyNotSupport('animation.skewY:' + angle)(angle);
3379
3528
  return this;
3380
3529
  }
3381
3530
  translate(tx, ty) {
3382
- this.rule.translate = { x: tx, y: ty };
3531
+ if (!this.rule.transform) {
3532
+ this.rule.transform = {};
3533
+ }
3534
+ this.rule.transform.Translate = { x: tx, y: ty };
3383
3535
  return this;
3384
3536
  }
3385
3537
  translate3d(tx, ty, tz) {
3386
- this.rule.translate = { x: tx, y: ty, z: tz };
3538
+ if (!this.rule.transform) {
3539
+ this.rule.transform = {};
3540
+ }
3541
+ this.rule.transform.Translate = { x: tx, y: ty, z: tz };
3387
3542
  return this;
3388
3543
  }
3389
3544
  translateX(translation) {
3390
- this.rule.translate = { x: translation };
3545
+ if (!this.rule.transform) {
3546
+ this.rule.transform = {};
3547
+ }
3548
+ this.rule.transform.Translate = { x: translation };
3391
3549
  return this;
3392
3550
  }
3393
3551
  translateY(translation) {
3394
- this.rule.translate = { y: translation };
3552
+ if (!this.rule.transform) {
3553
+ this.rule.transform = {};
3554
+ }
3555
+ this.rule.transform.Translate = { y: translation };
3395
3556
  return this;
3396
3557
  }
3397
3558
  translateZ(translation) {
3398
- this.rule.translate = { z: translation };
3559
+ if (!this.rule.transform) {
3560
+ this.rule.transform = {};
3561
+ }
3562
+ this.rule.transform.Translate = { z: translation };
3399
3563
  return this;
3400
3564
  }
3401
3565
  opacity(value) {
@@ -3407,15 +3571,15 @@ class Animation {
3407
3571
  return this;
3408
3572
  }
3409
3573
  width(value) {
3410
- this.rule.size = Object.assign(Object.assign({}, this.rule.size), { width: value });
3574
+ this.rule.width = value;
3411
3575
  return this;
3412
3576
  }
3413
3577
  height(value) {
3414
- this.rule.size = Object.assign(Object.assign({}, this.rule.size), { height: value });
3578
+ this.rule.height = value;
3415
3579
  return this;
3416
3580
  }
3417
3581
  left(value) {
3418
- temporarilyNotSupport('animation.left:' + value)(value);
3582
+ this.rule.left = value;
3419
3583
  return this;
3420
3584
  }
3421
3585
  right(value) {
@@ -3423,7 +3587,7 @@ class Animation {
3423
3587
  return this;
3424
3588
  }
3425
3589
  top(value) {
3426
- temporarilyNotSupport('animation.top:' + value)(value);
3590
+ this.rule.top = value;
3427
3591
  return this;
3428
3592
  }
3429
3593
  bottom(value) {
@@ -3442,7 +3606,8 @@ function setBackgroundColor(options) {
3442
3606
  const handle = new MethodHandler({ name: 'setBackgroundColor', success, fail, complete });
3443
3607
  return new Promise((resolve, reject) => {
3444
3608
  eventCenter.trigger('__taroPageStyle', {
3445
- backgroundColor: options.backgroundColor || options.backgroundColorTop || options.backgroundColorBottom,
3609
+ backgroundColor: options.backgroundColorBottom || options.backgroundColor,
3610
+ backgroundColorContext: options.backgroundColorTop || options.backgroundColor
3446
3611
  });
3447
3612
  return handle.success({}, { resolve, reject });
3448
3613
  });
@@ -3481,10 +3646,11 @@ function showToast(options) {
3481
3646
  const res = { errMsg: error.message };
3482
3647
  return callAsyncFail(reject, res, options);
3483
3648
  }
3484
- prompt.showToast({
3649
+ promptAction.showToast({
3485
3650
  message: options.title,
3486
3651
  duration: options.duration,
3487
- bottom: options.bottom
3652
+ bottom: options.bottom,
3653
+ showMode: 1 // 设置弹窗显示模式,显示在应用之上。
3488
3654
  });
3489
3655
  callAsyncSuccess(resolve, resCallback('showToast'), options);
3490
3656
  });
@@ -3514,25 +3680,24 @@ function showModal(options) {
3514
3680
  color: confirmColor
3515
3681
  });
3516
3682
  }
3517
- return new Promise(resolve => {
3683
+ return new Promise((resolve, reject) => {
3518
3684
  const modalOptions = {
3519
3685
  title,
3520
3686
  message: content,
3521
3687
  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: (_) => {
3688
+ };
3689
+ promptAction.showDialog(modalOptions, (error, data) => {
3690
+ if (error) {
3691
+ const res = { errMsg: error };
3692
+ callAsyncFail(reject, res, options);
3693
+ }
3694
+ if (data.index === 0 && showCancel) {
3532
3695
  callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: false, cancel: true }), options);
3533
3696
  }
3534
- };
3535
- prompt.showDialog(modalOptions);
3697
+ else {
3698
+ callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: true, cancel: false, content: null }), options);
3699
+ }
3700
+ });
3536
3701
  });
3537
3702
  }
3538
3703
  const showActionSheetSchema = {
@@ -3563,28 +3728,18 @@ function showActionSheet(options) {
3563
3728
  });
3564
3729
  const actionSheetOptions = {
3565
3730
  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
- }
3731
+ buttons
3574
3732
  };
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'
3733
+ promptAction.showActionMenu(actionSheetOptions, (error, data) => {
3734
+ var _a;
3735
+ if (error) {
3736
+ callAsyncFail(reject, Object.assign(Object.assign({}, data), { errMsg: (_a = data.errMsg) === null || _a === void 0 ? void 0 : _a.replace('showActionMenu', 'showActionSheet') }), options);
3737
+ }
3738
+ callAsyncSuccess(resolve, Object.assign(Object.assign({}, data), resCallback('showActionSheet')), options);
3584
3739
  });
3585
- callAsyncSuccess(resolve, resCallback('hideToast'), options);
3586
3740
  });
3587
3741
  }
3742
+ const hideToast = /* @__PURE__ */ temporarilyNotSupport('hideToast');
3588
3743
  const showLoading = temporarilyNotSupport('showLoading');
3589
3744
  const hideLoading = temporarilyNotSupport('hideLoading');
3590
3745
  const enableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('enableAlertBeforeUnload');
@@ -3605,7 +3760,7 @@ const setNavigationBarTitle = function (options) {
3605
3760
  };
3606
3761
  const setNavigationBarColor = function (options) {
3607
3762
  const { success, fail, complete } = options || {};
3608
- const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete });
3763
+ const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete });
3609
3764
  return new Promise((resolve, reject) => {
3610
3765
  eventCenter.trigger('__taroNavigationStyle', {
3611
3766
  animation: options.animation,
@@ -3700,7 +3855,7 @@ const pageScrollTo = (options) => {
3700
3855
  const taro = Current.taro;
3701
3856
  const page = taro.getCurrentInstance().page;
3702
3857
  let scrollValue = -1;
3703
- let scroller = page.scroller;
3858
+ let scroller = getPageScrollerOrNode(page.scroller, page);
3704
3859
  const currentPageNode = getPageScrollerOrNode(page.node, page);
3705
3860
  if (scrollTop || typeof scrollTop === 'number') {
3706
3861
  scrollValue = scrollTop;
@@ -3723,7 +3878,7 @@ const pageScrollTo = (options) => {
3723
3878
  scroller = getPageScrollerOrNode(scroller, page);
3724
3879
  const { yOffset } = scroller.currentOffset();
3725
3880
  if (areaInfo) {
3726
- scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper(offsetTop, 'px', true);
3881
+ scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper$1(offsetTop, 'px', true);
3727
3882
  }
3728
3883
  }
3729
3884
  const { xOffset } = scroller.currentOffset();
@@ -3908,19 +4063,16 @@ class IntersectionObserver {
3908
4063
  };
3909
4064
  const taro = Current.taro;
3910
4065
  const page = taro.getCurrentInstance().page;
3911
- const currentPage = getPageScrollerOrNode(page.node, page);
3912
- this._component = component || currentPage;
4066
+ this._component = component || getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
3913
4067
  Object.assign(this._options, options);
3914
4068
  }
3915
4069
  disconnect() {
3916
- var _a;
3917
- if (this._observerNodes) {
4070
+ if (this._observerNodes && this._component) {
3918
4071
  if (this._observerNodes instanceof Array) {
3919
4072
  this._observerNodes.forEach((n) => {
3920
- var _a;
3921
4073
  disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME);
3922
4074
  // @ts-ignore
3923
- (_a = n._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = null;
4075
+ n._nodeInfo.thresholds = null;
3924
4076
  });
3925
4077
  }
3926
4078
  else {
@@ -3928,35 +4080,40 @@ class IntersectionObserver {
3928
4080
  // @ts-ignore
3929
4081
  if (this._observerNodes._nodeInfo) {
3930
4082
  // @ts-ignore
3931
- (_a = this._observerNodes._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = null;
4083
+ this._observerNodes._nodeInfo.thresholds = null;
3932
4084
  }
3933
4085
  }
3934
4086
  }
3935
4087
  }
3936
4088
  observe(targetSelector, callback) {
3937
- var _a;
4089
+ if (!this._component)
4090
+ return;
3938
4091
  const { observeAll, thresholds } = this._options;
3939
4092
  const node = findChildNodeWithDFS(this._component, targetSelector, observeAll);
3940
4093
  this._observerNodes = node;
3941
4094
  if (node) {
3942
4095
  if (node instanceof Array) {
3943
4096
  node.forEach(n => {
3944
- var _a;
3945
4097
  // @ts-ignore
3946
- (_a = n._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = thresholds;
4098
+ n._nodeInfo.thresholds = thresholds;
3947
4099
  setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3948
- callback(this.handleResult(isVisible, currentRatio));
4100
+ callback(this.handleResult(isVisible, currentRatio, n));
3949
4101
  });
3950
4102
  });
3951
4103
  }
3952
4104
  else {
3953
4105
  // @ts-ignore
3954
- (_a = node._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = thresholds;
4106
+ node._nodeInfo.thresholds = thresholds;
3955
4107
  setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3956
- callback(this.handleResult(isVisible, currentRatio));
4108
+ callback(this.handleResult(isVisible, currentRatio, node));
3957
4109
  });
3958
4110
  }
3959
4111
  }
4112
+ else {
4113
+ callback({
4114
+ errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
4115
+ });
4116
+ }
3960
4117
  }
3961
4118
  relativeTo() {
3962
4119
  temporarilyNotSupport('relativeTo')();
@@ -3967,8 +4124,10 @@ class IntersectionObserver {
3967
4124
  return this;
3968
4125
  }
3969
4126
  // @ts-ignore
3970
- handleResult(isVisible, currentRatio) {
4127
+ handleResult(isVisible, currentRatio, node) {
3971
4128
  const result = {
4129
+ id: node.id,
4130
+ dataset: node.dataset,
3972
4131
  intersectionRatio: currentRatio,
3973
4132
  // TODO 未做,等待能拿到element的info信息
3974
4133
  boundingClientRect: {
@@ -4176,9 +4335,12 @@ function filter(fields, dom) {
4176
4335
  }
4177
4336
  function querySelector(selector, selectAll) {
4178
4337
  if (typeof selector === 'string') {
4179
- return parseHandler(selector, selectAll);
4338
+ return selector.split(',').reduce((prev, current) => {
4339
+ const item = current.trim();
4340
+ return prev.concat(parseHandler(item, selectAll));
4341
+ }, []);
4180
4342
  }
4181
- return null;
4343
+ return [];
4182
4344
  }
4183
4345
  function queryBat(queue, cb) {
4184
4346
  const result = [];
@@ -4189,19 +4351,29 @@ function queryBat(queue, cb) {
4189
4351
  return null;
4190
4352
  arr = [];
4191
4353
  traversalDFSDom(element);
4192
- queue.forEach(item => {
4354
+ queue.forEach((item) => {
4193
4355
  const { selector, single, fields } = item;
4194
- const nodeList = querySelector(selector, !single);
4195
- result.push(nodeList.map(dom => {
4356
+ if (single) {
4357
+ const dom = querySelector(selector, !single)[0];
4196
4358
  // eslint-disable-next-line no-async-promise-executor
4197
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
4359
+ result.push(new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
4198
4360
  yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
4199
4361
  resolve(filter(fields, dom));
4362
+ })));
4363
+ }
4364
+ else {
4365
+ const nodeList = querySelector(selector, !single);
4366
+ result.push(nodeList.map(dom => {
4367
+ // eslint-disable-next-line no-async-promise-executor
4368
+ return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
4369
+ yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
4370
+ resolve(filter(fields, dom));
4371
+ }));
4200
4372
  }));
4201
- }));
4373
+ }
4202
4374
  });
4203
4375
  Promise.all(result.map(item => {
4204
- return Promise.all(item);
4376
+ return item instanceof Array ? Promise.all(item) : item;
4205
4377
  })).then(data => {
4206
4378
  cb(data);
4207
4379
  });
@@ -4280,6 +4452,7 @@ var apis = /*#__PURE__*/Object.freeze({
4280
4452
  ENV_TYPE: ENV_TYPE,
4281
4453
  Events: Events,
4282
4454
  History: History,
4455
+ IntersectionObserver: IntersectionObserver,
4283
4456
  addCard: addCard,
4284
4457
  addFileToFavorites: addFileToFavorites,
4285
4458
  addPhoneCalendar: addPhoneCalendar,
@@ -4669,7 +4842,7 @@ var apis = /*#__PURE__*/Object.freeze({
4669
4842
  writeBLECharacteristicValue: writeBLECharacteristicValue
4670
4843
  });
4671
4844
 
4672
- Object.assign({}, apis);
4845
+ const taro = Object.assign({}, apis);
4673
4846
  const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin');
4674
4847
  function initNativeApi(taro) {
4675
4848
  Current.taro = taro;
@@ -4693,7 +4866,7 @@ const defaultBaseFontSize = 20;
4693
4866
  const defaultUnitPrecision = 5;
4694
4867
  const defaultTargetUnit = 'vp';
4695
4868
  function getApp$1() {
4696
- return Current.app;
4869
+ return Current.app || {};
4697
4870
  }
4698
4871
  function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
4699
4872
  const taro = Current.taro;
@@ -4707,19 +4880,56 @@ function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defau
4707
4880
  config.unitPrecision = unitPrecision;
4708
4881
  }
4709
4882
  }
4710
- _display.getDefaultDisplaySync();
4883
+ const display = _display.getDefaultDisplaySync();
4884
+ let displayWidth = display.width;
4885
+ let ratioCache = false;
4886
+ let designWidthFunc;
4887
+ let designWidth = defaultDesignWidth;
4888
+ function getRatio(value) {
4889
+ var _a;
4890
+ // Note: 提前调用 display 可能无法获取正确值
4891
+ if (ratioCache === false || displayWidth !== display.width) {
4892
+ const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
4893
+ if (!isFunction(designWidthFunc)) {
4894
+ designWidthFunc = isFunction(config.designWidth)
4895
+ ? config.designWidth
4896
+ : () => config.designWidth;
4897
+ designWidth = designWidthFunc(value) || defaultDesignWidth;
4898
+ }
4899
+ displayWidth = display.width;
4900
+ ratioCache = Math.min(display.width, display.height) / designWidth;
4901
+ }
4902
+ return ratioCache;
4903
+ }
4904
+ // Note: 设置为 style 单位时会自动完成设计稿转换,设计开发者调用 API 时也许抹平差异,例如 pageScrollTo[option.offsetTop]
4905
+ function pxTransformHelper(size, unit, isNumber = false) {
4906
+ var _a;
4907
+ const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
4908
+ const targetUnit = unit || config.targetUnit || defaultTargetUnit;
4909
+ if (targetUnit === 'PX') {
4910
+ return px2vp(size * display.scaledDensity) + 'vp';
4911
+ }
4912
+ const ratio = getRatio(size);
4913
+ let val = size * ratio;
4914
+ switch (targetUnit) {
4915
+ case 'vp':
4916
+ // Note: 在应用创建前调用无效
4917
+ val = px2vp(val);
4918
+ break;
4919
+ }
4920
+ return isNumber ? val : val + targetUnit;
4921
+ }
4711
4922
  function pxTransform(size) {
4712
4923
  var _a;
4713
4924
  const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
4714
4925
  const targetUnit = config.targetUnit || defaultTargetUnit;
4715
- let val = size;
4926
+ const val = size;
4716
4927
  switch (targetUnit) {
4717
4928
  case 'vp':
4718
- val = px2vp(size);
4719
- break;
4929
+ return pxTransformHelper(size, 'px');
4720
4930
  // NOTE: 鸿蒙环境下 style 会自动完成设计稿转换,无需在方法内二次调整
4721
4931
  }
4722
- return val + config.targetUnit;
4932
+ return val + targetUnit;
4723
4933
  }
4724
4934
  function canIUseWebp() {
4725
4935
  return true;
@@ -4733,6 +4943,7 @@ function getAppInfo() {
4733
4943
  designWidth: config === null || config === void 0 ? void 0 : config.designWidth,
4734
4944
  };
4735
4945
  }
4946
+ initNativeApi(taro);
4736
4947
 
4737
4948
  const components = {
4738
4949
  Checkbox: {