@tarojs/plugin-platform-harmony-ets 4.0.0-beta.3 → 4.0.0-beta.30

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 (103) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/framework/index.ts +1 -5
  4. package/dist/apis/index.ts +27 -12
  5. package/dist/apis/network/request.ts +5 -5
  6. package/dist/apis/route/index.ts +15 -0
  7. package/dist/apis/storage/index.ts +124 -60
  8. package/dist/apis/ui/animation/animation.ts +2 -1
  9. package/dist/apis/utils/index.ts +1 -1
  10. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  11. package/dist/apis/wxml/index.ts +2 -0
  12. package/dist/components-harmony-ets/button.ets +50 -78
  13. package/dist/components-harmony-ets/canvas.ets +51 -0
  14. package/dist/components-harmony-ets/checkbox.ets +23 -209
  15. package/dist/components-harmony-ets/form.ets +44 -158
  16. package/dist/components-harmony-ets/icon.ets +38 -83
  17. package/dist/components-harmony-ets/image.ets +29 -78
  18. package/dist/components-harmony-ets/index.ets +53 -0
  19. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  20. package/dist/components-harmony-ets/input.ets +11 -67
  21. package/dist/components-harmony-ets/label.ets +58 -172
  22. package/dist/components-harmony-ets/movableArea.ets +96 -0
  23. package/dist/components-harmony-ets/movableView.ets +74 -0
  24. package/dist/components-harmony-ets/picker.ets +32 -147
  25. package/dist/components-harmony-ets/progress.ets +54 -0
  26. package/dist/components-harmony-ets/pseudo.ets +80 -0
  27. package/dist/components-harmony-ets/radio.ets +23 -210
  28. package/dist/components-harmony-ets/richText.ets +22 -102
  29. package/dist/components-harmony-ets/scrollView.ets +73 -169
  30. package/dist/components-harmony-ets/slider.ets +11 -72
  31. package/dist/components-harmony-ets/style.ets +280 -0
  32. package/dist/components-harmony-ets/swiper.ets +37 -87
  33. package/dist/components-harmony-ets/switch.ets +11 -71
  34. package/dist/components-harmony-ets/text.ets +57 -89
  35. package/dist/components-harmony-ets/textArea.ets +11 -67
  36. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  37. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  38. package/dist/components-harmony-ets/utils/flexManager.ets +11 -9
  39. package/dist/components-harmony-ets/utils/helper.ets +4 -5
  40. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  41. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  42. package/dist/components-harmony-ets/utils/index.ts +50 -51
  43. package/dist/components-harmony-ets/utils/styles.ets +167 -87
  44. package/dist/components-harmony-ets/video.ets +41 -89
  45. package/dist/components-harmony-ets/view.ets +53 -159
  46. package/dist/components-harmony-ets/webView.ets +44 -99
  47. package/dist/index.d.ts +151 -0
  48. package/dist/index.js +69 -32
  49. package/dist/index.js.map +1 -1
  50. package/dist/runtime-ets/bom/window.ts +7 -0
  51. package/dist/runtime-ets/current.ts +3 -0
  52. package/dist/runtime-ets/dom/bind.ts +20 -6
  53. package/dist/runtime-ets/dom/cssNesting.ts +393 -0
  54. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +12 -40
  55. package/dist/runtime-ets/dom/document.ts +22 -8
  56. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  57. package/dist/runtime-ets/dom/element/element.ts +128 -51
  58. package/dist/runtime-ets/dom/element/form.ts +15 -18
  59. package/dist/runtime-ets/dom/element/index.ts +16 -3
  60. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  61. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  62. package/dist/runtime-ets/dom/element/normal.ts +8 -3
  63. package/dist/runtime-ets/dom/element/progress.ts +12 -0
  64. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  65. package/dist/runtime-ets/dom/element/text.ts +1 -8
  66. package/dist/runtime-ets/dom/element/video.ts +5 -3
  67. package/dist/runtime-ets/dom/element/webView.ts +8 -0
  68. package/dist/runtime-ets/dom/event.ts +0 -1
  69. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  70. package/dist/runtime-ets/dom/node.ts +29 -27
  71. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +189 -211
  72. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  73. package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
  74. package/dist/runtime-ets/dom/stylesheet/util.ts +31 -25
  75. package/dist/runtime-ets/index.ts +2 -2
  76. package/dist/runtime-ets/interface/event.ts +1 -1
  77. package/dist/runtime-ets/utils/index.ts +43 -10
  78. package/dist/runtime-ets/utils/info.ts +1 -1
  79. package/dist/runtime-framework/react/app.ts +7 -2
  80. package/dist/runtime-framework/react/index.ts +0 -2
  81. package/dist/runtime-framework/react/native-page.ts +22 -12
  82. package/dist/runtime-framework/react/page.ts +3 -8
  83. package/dist/runtime-framework/solid/app.ts +25 -45
  84. package/dist/runtime-framework/solid/connect.ts +21 -3
  85. package/dist/runtime-framework/solid/hooks.ts +16 -11
  86. package/dist/runtime-framework/solid/index.ts +6 -2
  87. package/dist/runtime-framework/solid/page.ts +84 -30
  88. package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
  89. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  90. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  91. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  92. package/dist/runtime-utils.d.ts +827 -0
  93. package/dist/runtime-utils.js +210 -106
  94. package/dist/runtime-utils.js.map +1 -1
  95. package/dist/runtime.d.ts +1 -0
  96. package/dist/runtime.js +210 -106
  97. package/dist/runtime.js.map +1 -1
  98. package/index.js +3 -1
  99. package/package.json +13 -13
  100. package/types/index.d.ts +4 -0
  101. package/dist/runtime-ets/utils/bind.ts +0 -24
  102. /package/dist/components-harmony-ets/{index.ts → tag.ts} +0 -0
  103. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -0,0 +1 @@
1
+ export {};
package/dist/runtime.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { isFunction, isString, isArray, isObject, isNull, isNumber, isUndefined, queryToJson, PLATFORM_TYPE, singleQuote, internalComponents, mergeReconciler, mergeInternalComponents } 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';
@@ -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,49 @@ 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
+ // @ts-ignore
284
+ display$1.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} } = {}) => {
285
+ var _a, _b, _c, _d, _e, _f;
286
+ if (err === null || err === void 0 ? void 0 : err.code) {
287
+ console.error('Failed to get cutout info', JSON.stringify(err));
288
+ return;
289
+ }
290
+ 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);
291
+ const bottom = display$1.height - Math.min((_c = waterfallDisplayAreaRects.bottom) === null || _c === void 0 ? void 0 : _c.top, navigationIndicatorRect === null || navigationIndicatorRect === void 0 ? void 0 : navigationIndicatorRect.top);
292
+ const left = ((_d = waterfallDisplayAreaRects.left) === null || _d === void 0 ? void 0 : _d.left) + ((_e = waterfallDisplayAreaRects.left) === null || _e === void 0 ? void 0 : _e.width);
293
+ const right = display$1.width - ((_f = waterfallDisplayAreaRects.right) === null || _f === void 0 ? void 0 : _f.left);
294
+ safeArea = {
295
+ top,
296
+ bottom,
297
+ left,
298
+ right,
299
+ height: bottom - top,
300
+ width: right - left,
301
+ };
302
+ });
303
+ }
304
+ catch (e) {
305
+ console.error('Failed to get display', e);
306
+ }
307
+ });
276
308
  });
277
309
  /* 同步版本 */
278
310
  const getSystemInfoSync = function () {
311
+ var _a, _b;
279
312
  const res = {};
280
313
  res.SDKVersion = deviceInfo && deviceInfo.sdkApiVersion; // 客户端基础库版本 string
281
314
  res.albumAuthorized = false; // 允许使用相册的开关(仅 iOS 有效) boolean
@@ -285,7 +318,7 @@ const getSystemInfoSync = function () {
285
318
  res.cameraAuthorized = null; // 允许使用摄像头的开关 boolean
286
319
  res.enableDebug = null; // 是否已打开调试 boolean
287
320
  res.fontSizeSetting = null; // 用户字体大小(单位px) number
288
- res.language = i18n && i18n.getSystemLanguage && i18n.getSystemLanguage(); // string
321
+ res.language = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.getSystemLanguage) === null || _a === void 0 ? void 0 : _a.call(i18n); // string
289
322
  res.locationAuthorized = null; // 定位的开关 boolean
290
323
  res.locationEnabled = null; // 地理位置的系统开关 boolean
291
324
  res.microphoneAuthorized = null; // 麦克风的开关 boolean
@@ -296,17 +329,18 @@ const getSystemInfoSync = function () {
296
329
  res.notificationSoundAuthorized = false; // 通知带有声音的开关(仅 iOS 有效)boolean
297
330
  res.phoneCalendarAuthorized = null; // 使用日历的开关 boolean
298
331
  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
332
+ res.pixelRatio = display$1 && display$1.densityPixels; // 设备像素比,number
333
+ res.platform = 'harmony'; // 客户端平台 string
334
+ res.safeArea = safeArea; // 在竖屏正方向下的安全区域 General.SafeAreaResult
335
+ res.screenHeight = display$1 === null || display$1 === void 0 ? void 0 : display$1.height; // 屏幕高度,单位px number
336
+ res.screenWidth = display$1 === null || display$1 === void 0 ? void 0 : display$1.width; // 屏幕宽度,单位px number
337
+ res.statusBarHeight = statusBarHeight; // 状态栏的高度,单位px number
338
+ res.system = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.osFullName; // 操作系统及版本 string
339
+ // Note: 更新配置时才能记录
340
+ 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'
341
+ res.windowHeight = windowRect === null || windowRect === void 0 ? void 0 : windowRect.height; // 可使用窗口高度,单位px number
342
+ res.windowWidth = windowRect === null || windowRect === void 0 ? void 0 : windowRect.width; // 可使用窗口宽度,单位px number
343
+ res.version = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.displayVersion; // 版本号 string
310
344
  return res;
311
345
  };
312
346
  /* 异步版本 */
@@ -412,7 +446,13 @@ const base64ToArrayBuffer = /* @__PURE__ */ temporarilyNotSupport('base64ToArray
412
446
  /** 创建离屏 canvas 实例 */
413
447
  const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
414
448
  /** 创建 canvas 的绘图上下文 CanvasContext 对象 */
415
- const createCanvasContext = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
449
+
450
+ const createCanvasContext = (canvasId) => {
451
+ const dom = eventSource.get(`canvasId-${canvasId}`);
452
+ // return dom as TaroCanvasElement
453
+ if (dom)
454
+ return dom.context;
455
+ };
416
456
  /** 把当前画布指定区域的内容导出生成指定大小的图片 */
417
457
  const canvasToTempFilePath = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
418
458
  /** 将像素数据绘制到画布 */
@@ -1984,7 +2024,6 @@ function getEnv() {
1984
2024
  }
1985
2025
  // TODO
1986
2026
  const getCurrentPages = () => [];
1987
- const getCurrentInstance = () => Current;
1988
2027
  const requirePlugin$1 = temporarilyNotSupport('requirePlugin');
1989
2028
 
1990
2029
  // @ts-nocheck
@@ -2611,10 +2650,10 @@ const request = function (options) {
2611
2650
  header['Content-Type'] = 'application/json';
2612
2651
  }
2613
2652
  // 检查 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
- }
2653
+ // if (isUndefined(header.Referer)) {
2654
+ // const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
2655
+ // callAsyncFail(reject, error, options)
2656
+ // }
2618
2657
  // 检查 method 是否正确
2619
2658
  if (method) {
2620
2659
  if (!METHOD.includes(method)) {
@@ -3060,6 +3099,19 @@ function parseURL(raw = '') {
3060
3099
  const [urlStr, queryStr = ''] = raw.split('?');
3061
3100
  const query = queryToJson(queryStr);
3062
3101
  let url = urlStr.replace(/^\//, '');
3102
+ // 处理相对路径
3103
+ if (url.indexOf('.') === 0) {
3104
+ const page = router.getState();
3105
+ const parts = page.path.split('/');
3106
+ parts.pop();
3107
+ url.split('/').forEach((item) => {
3108
+ if (item === '.') {
3109
+ return;
3110
+ }
3111
+ item === '..' ? parts.pop() : parts.push(item);
3112
+ });
3113
+ url = parts.join('/');
3114
+ }
3063
3115
  if (isTabPage(url)) {
3064
3116
  query.$page = url;
3065
3117
  url = TARO_TABBAR_PAGE_PATH;
@@ -3177,107 +3229,152 @@ const getBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('getBackgro
3177
3229
  // 周期性更新
3178
3230
  const createCacheManager = /* @__PURE__ */ temporarilyNotSupport('createCacheManager');
3179
3231
 
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);
3232
+ /**
3233
+ * 从API Version 6开始,该模块不再维护,可以使用模块@ohos.data.storage。在API Version 9后,推荐使用新模块@ohos.data.preferences。
3234
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references-V3/js-apis-data-preferences-0000001427745052-V3
3235
+ */
3236
+ let context;
3237
+ let preferences;
3238
+ Current.contextPromise.then((ctx) => {
3239
+ context = ctx;
3240
+ return context;
3191
3241
  });
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 };
3242
+ function getPreferences() {
3243
+ try {
3244
+ if (!preferences) {
3245
+ const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
3246
+ preferences = dataPreferences.getPreferencesSync(context, { name: `${data.appInfo.uid}Store` });
3201
3247
  }
3202
- });
3248
+ }
3249
+ catch (error) {
3250
+ hilog.error(0x0000, 'TaroFailedTag', 'Failed to load the storage. Cause: %{public}s', error.code ? JSON.stringify(error) : error.message || error);
3251
+ }
3252
+ return preferences;
3203
3253
  }
3204
3254
  const storageSchema = {
3205
3255
  key: 'String'
3206
3256
  };
3207
3257
  function getStorage(options) {
3258
+ const { key, success, fail, complete } = options || {};
3259
+ const handle = new MethodHandler({ name: 'getStorage', success, fail, complete });
3208
3260
  return new Promise((resolve, reject) => {
3209
3261
  try {
3210
3262
  validateParams('getStorage', options, storageSchema);
3211
3263
  }
3212
3264
  catch (error) {
3213
3265
  const res = { errMsg: error.message };
3214
- return callAsyncFail(reject, res, options);
3266
+ return handle.fail(res, { resolve, reject });
3267
+ }
3268
+ const preferences = getPreferences();
3269
+ if (!preferences)
3270
+ return handle.fail({}, { resolve, reject });
3271
+ const data = preferences.getSync(key, null);
3272
+ if (data) {
3273
+ return handle.success({ data }, { resolve, reject });
3274
+ }
3275
+ else {
3276
+ return handle.success({ errMsg: 'data not found' }, { resolve, reject });
3215
3277
  }
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);
3221
- }
3222
- else {
3223
- res.errMsg = 'getStorage:fail data not found';
3224
- callAsyncFail(reject, res, options);
3225
- }
3226
- });
3227
3278
  });
3228
3279
  }
3280
+ function getStorageSync(key) {
3281
+ if (!key) {
3282
+ throw new Error('getStorageSync:fail parameter error: parameter should be String');
3283
+ }
3284
+ const preferences = getPreferences();
3285
+ if (!preferences) {
3286
+ throw new Error('getStorageSync:fail:preferences is null');
3287
+ }
3288
+ const data = preferences.getSync(key, null);
3289
+ if (data) {
3290
+ return data;
3291
+ }
3292
+ else {
3293
+ throw new Error('data not found');
3294
+ }
3295
+ }
3229
3296
  function setStorage(options) {
3297
+ const { key, data, success, fail, complete } = options || {};
3298
+ const handle = new MethodHandler({ name: 'setStorage', success, fail, complete });
3230
3299
  return new Promise((resolve, reject) => {
3231
3300
  try {
3232
3301
  validateParams('setStorage', options, storageSchema);
3233
3302
  }
3234
3303
  catch (error) {
3235
3304
  const res = { errMsg: error.message };
3236
- return callAsyncFail(reject, res, options);
3305
+ return handle.fail(res, { resolve, reject });
3237
3306
  }
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
- }));
3307
+ const preferences = getPreferences();
3308
+ if (!preferences)
3309
+ return handle.fail({}, { resolve, reject });
3310
+ preferences.putSync(key, data);
3311
+ preferences.flush();
3312
+ return handle.success({}, { resolve, reject });
3245
3313
  });
3246
3314
  }
3315
+ function setStorageSync(key, data) {
3316
+ if (!key) {
3317
+ throw new Error('setStorageSync:fail key error: key should be String');
3318
+ }
3319
+ const preferences = getPreferences();
3320
+ if (!preferences) {
3321
+ throw new Error('setStorageSync:fail:preferences is null');
3322
+ }
3323
+ preferences.putSync(key, data);
3324
+ preferences.flush();
3325
+ }
3247
3326
  function removeStorage(options) {
3327
+ const { key, success, fail, complete } = options || {};
3328
+ const handle = new MethodHandler({ name: 'removeStorage', success, fail, complete });
3248
3329
  return new Promise((resolve, reject) => {
3249
3330
  try {
3250
3331
  validateParams('removeStorage', options, storageSchema);
3251
3332
  }
3252
3333
  catch (error) {
3253
3334
  const res = { errMsg: error.message };
3254
- return callAsyncFail(reject, res, options);
3335
+ return handle.fail(res, { resolve, reject });
3255
3336
  }
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
- }));
3337
+ const preferences = getPreferences();
3338
+ if (!preferences)
3339
+ return handle.fail({}, { resolve, reject });
3340
+ preferences.deleteSync(key);
3341
+ preferences.flush();
3342
+ return handle.success({}, { resolve, reject });
3263
3343
  });
3264
3344
  }
3345
+ function removeStorageSync(key) {
3346
+ if (!key) {
3347
+ throw new Error('removeStorageSync:fail key error: key should be String');
3348
+ }
3349
+ const preferences = getPreferences();
3350
+ if (!preferences) {
3351
+ throw new Error('removeStorageSync:fail:preferences is null');
3352
+ }
3353
+ preferences.deleteSync(key);
3354
+ preferences.flush();
3355
+ }
3265
3356
  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
- }));
3357
+ const { success, fail, complete } = options || {};
3358
+ const handle = new MethodHandler({ name: 'clearStorage', success, fail, complete });
3359
+ return new Promise((resolve, reject) => {
3360
+ const preferences = getPreferences();
3361
+ if (!preferences)
3362
+ return handle.fail({}, { resolve, reject });
3363
+ preferences.clearSync();
3364
+ preferences.flush();
3365
+ return handle.success({}, { resolve, reject });
3273
3366
  });
3274
3367
  }
3368
+ function clearStorageSync() {
3369
+ const preferences = getPreferences();
3370
+ if (!preferences) {
3371
+ throw new Error('clearStorageSync:fail:preferences is null');
3372
+ }
3373
+ preferences.clearSync();
3374
+ preferences.flush();
3375
+ }
3275
3376
  const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync');
3276
3377
  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
3378
  const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL');
3282
3379
  const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL');
3283
3380
  const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStorageSync');
@@ -3347,7 +3444,7 @@ class Animation {
3347
3444
  return this;
3348
3445
  }
3349
3446
  scale(sx, sy) {
3350
- this.rule.scale = { x: sx, y: sy };
3447
+ this.rule.scale = { x: sx, y: isUndefined(sy) ? sx : sy };
3351
3448
  return this;
3352
3449
  }
3353
3450
  scale3d(sx, sy, sz) {
@@ -3908,19 +4005,16 @@ class IntersectionObserver {
3908
4005
  };
3909
4006
  const taro = Current.taro;
3910
4007
  const page = taro.getCurrentInstance().page;
3911
- const currentPage = getPageScrollerOrNode(page.node, page);
3912
- this._component = component || currentPage;
4008
+ this._component = component || getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
3913
4009
  Object.assign(this._options, options);
3914
4010
  }
3915
4011
  disconnect() {
3916
- var _a;
3917
- if (this._observerNodes) {
4012
+ if (this._observerNodes && this._component) {
3918
4013
  if (this._observerNodes instanceof Array) {
3919
4014
  this._observerNodes.forEach((n) => {
3920
- var _a;
3921
4015
  disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME);
3922
4016
  // @ts-ignore
3923
- (_a = n._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = null;
4017
+ n._nodeInfo.thresholds = null;
3924
4018
  });
3925
4019
  }
3926
4020
  else {
@@ -3928,35 +4022,40 @@ class IntersectionObserver {
3928
4022
  // @ts-ignore
3929
4023
  if (this._observerNodes._nodeInfo) {
3930
4024
  // @ts-ignore
3931
- (_a = this._observerNodes._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = null;
4025
+ this._observerNodes._nodeInfo.thresholds = null;
3932
4026
  }
3933
4027
  }
3934
4028
  }
3935
4029
  }
3936
4030
  observe(targetSelector, callback) {
3937
- var _a;
4031
+ if (!this._component)
4032
+ return;
3938
4033
  const { observeAll, thresholds } = this._options;
3939
4034
  const node = findChildNodeWithDFS(this._component, targetSelector, observeAll);
3940
4035
  this._observerNodes = node;
3941
4036
  if (node) {
3942
4037
  if (node instanceof Array) {
3943
4038
  node.forEach(n => {
3944
- var _a;
3945
4039
  // @ts-ignore
3946
- (_a = n._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = thresholds;
4040
+ n._nodeInfo.thresholds = thresholds;
3947
4041
  setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3948
- callback(this.handleResult(isVisible, currentRatio));
4042
+ callback(this.handleResult(isVisible, currentRatio, n));
3949
4043
  });
3950
4044
  });
3951
4045
  }
3952
4046
  else {
3953
4047
  // @ts-ignore
3954
- (_a = node._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = thresholds;
4048
+ node._nodeInfo.thresholds = thresholds;
3955
4049
  setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3956
- callback(this.handleResult(isVisible, currentRatio));
4050
+ callback(this.handleResult(isVisible, currentRatio, node));
3957
4051
  });
3958
4052
  }
3959
4053
  }
4054
+ else {
4055
+ callback({
4056
+ errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
4057
+ });
4058
+ }
3960
4059
  }
3961
4060
  relativeTo() {
3962
4061
  temporarilyNotSupport('relativeTo')();
@@ -3967,8 +4066,10 @@ class IntersectionObserver {
3967
4066
  return this;
3968
4067
  }
3969
4068
  // @ts-ignore
3970
- handleResult(isVisible, currentRatio) {
4069
+ handleResult(isVisible, currentRatio, node) {
3971
4070
  const result = {
4071
+ id: node.id,
4072
+ dataset: node.dataset,
3972
4073
  intersectionRatio: currentRatio,
3973
4074
  // TODO 未做,等待能拿到element的info信息
3974
4075
  boundingClientRect: {
@@ -4280,6 +4381,7 @@ var apis = /*#__PURE__*/Object.freeze({
4280
4381
  ENV_TYPE: ENV_TYPE,
4281
4382
  Events: Events,
4282
4383
  History: History,
4384
+ IntersectionObserver: IntersectionObserver,
4283
4385
  addCard: addCard,
4284
4386
  addFileToFavorites: addFileToFavorites,
4285
4387
  addPhoneCalendar: addPhoneCalendar,
@@ -4669,7 +4771,7 @@ var apis = /*#__PURE__*/Object.freeze({
4669
4771
  writeBLECharacteristicValue: writeBLECharacteristicValue
4670
4772
  });
4671
4773
 
4672
- Object.assign({}, apis);
4774
+ const taro = Object.assign({}, apis);
4673
4775
  const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin');
4674
4776
  function initNativeApi(taro) {
4675
4777
  Current.taro = taro;
@@ -4693,7 +4795,7 @@ const defaultBaseFontSize = 20;
4693
4795
  const defaultUnitPrecision = 5;
4694
4796
  const defaultTargetUnit = 'vp';
4695
4797
  function getApp$1() {
4696
- return Current.app;
4798
+ return Current.app || {};
4697
4799
  }
4698
4800
  function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
4699
4801
  const taro = Current.taro;
@@ -4707,7 +4809,8 @@ function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defau
4707
4809
  config.unitPrecision = unitPrecision;
4708
4810
  }
4709
4811
  }
4710
- _display.getDefaultDisplaySync();
4812
+ const display = _display.getDefaultDisplaySync();
4813
+ display.width;
4711
4814
  function pxTransform(size) {
4712
4815
  var _a;
4713
4816
  const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
@@ -4733,6 +4836,7 @@ function getAppInfo() {
4733
4836
  designWidth: config === null || config === void 0 ? void 0 : config.designWidth,
4734
4837
  };
4735
4838
  }
4839
+ initNativeApi(taro);
4736
4840
 
4737
4841
  const components = {
4738
4842
  Checkbox: {