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

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 +205 -63
  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 +273 -109
  94. package/dist/runtime-utils.js.map +1 -1
  95. package/dist/runtime.d.ts +1 -0
  96. package/dist/runtime.js +273 -109
  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,212 @@ 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 && context) {
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
  };
3257
+ function checkContextExist(api, isAsync = false) {
3258
+ if (!context) {
3259
+ const message = `${api} 调用失败,Taro 不支持过早地调用 ${api},请确保页面已经渲染完成再调用此 API`;
3260
+ if (isAsync) {
3261
+ return {
3262
+ isExist: false,
3263
+ error: Promise.reject(new Error(message))
3264
+ };
3265
+ }
3266
+ else {
3267
+ console.warn(message);
3268
+ return {
3269
+ isExist: false,
3270
+ };
3271
+ }
3272
+ }
3273
+ return {
3274
+ isExist: true,
3275
+ };
3276
+ }
3207
3277
  function getStorage(options) {
3278
+ const name = 'getStorage';
3279
+ const { isExist, error } = checkContextExist(name, true);
3280
+ if (!isExist) {
3281
+ return error;
3282
+ }
3283
+ const { key, success, fail, complete } = options || {};
3284
+ const handle = new MethodHandler({ name, success, fail, complete });
3208
3285
  return new Promise((resolve, reject) => {
3209
3286
  try {
3210
- validateParams('getStorage', options, storageSchema);
3287
+ validateParams(name, options, storageSchema);
3211
3288
  }
3212
3289
  catch (error) {
3213
3290
  const res = { errMsg: error.message };
3214
- return callAsyncFail(reject, res, options);
3291
+ return handle.fail(res, { resolve, reject });
3292
+ }
3293
+ const preferences = getPreferences();
3294
+ if (!preferences)
3295
+ return handle.fail({}, { resolve, reject });
3296
+ const data = preferences.getSync(key, null);
3297
+ if (data) {
3298
+ return handle.success({ data }, { resolve, reject });
3299
+ }
3300
+ else {
3301
+ return handle.success({ errMsg: 'data not found' }, { resolve, reject });
3215
3302
  }
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
3303
  });
3228
3304
  }
3305
+ function getStorageSync(key) {
3306
+ const name = 'getStorageSync';
3307
+ const { isExist, error } = checkContextExist(name, false);
3308
+ if (!isExist) {
3309
+ return error;
3310
+ }
3311
+ if (!key) {
3312
+ throw new Error(`${name}:fail parameter error: parameter should be String`);
3313
+ }
3314
+ const preferences = getPreferences();
3315
+ if (!preferences) {
3316
+ throw new Error(`${name}:fail:preferences is null`);
3317
+ }
3318
+ const data = preferences.getSync(key, null);
3319
+ if (data) {
3320
+ return data;
3321
+ }
3322
+ else {
3323
+ throw new Error('data not found');
3324
+ }
3325
+ }
3229
3326
  function setStorage(options) {
3327
+ const name = 'setStorage';
3328
+ const { isExist, error } = checkContextExist(name, true);
3329
+ if (!isExist) {
3330
+ return error;
3331
+ }
3332
+ const { key, data, success, fail, complete } = options || {};
3333
+ const handle = new MethodHandler({ name, success, fail, complete });
3230
3334
  return new Promise((resolve, reject) => {
3231
3335
  try {
3232
- validateParams('setStorage', options, storageSchema);
3336
+ validateParams(name, options, storageSchema);
3233
3337
  }
3234
3338
  catch (error) {
3235
3339
  const res = { errMsg: error.message };
3236
- return callAsyncFail(reject, res, options);
3340
+ return handle.fail(res, { resolve, reject });
3237
3341
  }
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
- }));
3342
+ const preferences = getPreferences();
3343
+ if (!preferences)
3344
+ return handle.fail({}, { resolve, reject });
3345
+ preferences.putSync(key, data);
3346
+ preferences.flush();
3347
+ return handle.success({}, { resolve, reject });
3245
3348
  });
3246
3349
  }
3350
+ function setStorageSync(key, data) {
3351
+ const name = 'setStorageSync';
3352
+ const { isExist, error } = checkContextExist(name, false);
3353
+ if (!isExist) {
3354
+ return error;
3355
+ }
3356
+ if (!key) {
3357
+ throw new Error(`${name}:fail key error: key should be String`);
3358
+ }
3359
+ const preferences = getPreferences();
3360
+ if (!preferences) {
3361
+ throw new Error(`${name}:fail:preferences is null`);
3362
+ }
3363
+ preferences.putSync(key, data);
3364
+ preferences.flush();
3365
+ }
3247
3366
  function removeStorage(options) {
3367
+ const name = 'removeStorage';
3368
+ const { isExist, error } = checkContextExist(name, true);
3369
+ if (!isExist) {
3370
+ return error;
3371
+ }
3372
+ const { key, success, fail, complete } = options || {};
3373
+ const handle = new MethodHandler({ name, success, fail, complete });
3248
3374
  return new Promise((resolve, reject) => {
3249
3375
  try {
3250
- validateParams('removeStorage', options, storageSchema);
3376
+ validateParams(name, options, storageSchema);
3251
3377
  }
3252
3378
  catch (error) {
3253
3379
  const res = { errMsg: error.message };
3254
- return callAsyncFail(reject, res, options);
3380
+ return handle.fail(res, { resolve, reject });
3255
3381
  }
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
- }));
3382
+ const preferences = getPreferences();
3383
+ if (!preferences)
3384
+ return handle.fail({}, { resolve, reject });
3385
+ preferences.deleteSync(key);
3386
+ preferences.flush();
3387
+ return handle.success({}, { resolve, reject });
3263
3388
  });
3264
3389
  }
3390
+ function removeStorageSync(key) {
3391
+ const name = 'removeStorageSync';
3392
+ const { isExist, error } = checkContextExist(name, false);
3393
+ if (!isExist) {
3394
+ return error;
3395
+ }
3396
+ if (!key) {
3397
+ throw new Error(`${name}:fail key error: key should be String`);
3398
+ }
3399
+ const preferences = getPreferences();
3400
+ if (!preferences) {
3401
+ throw new Error(`${name}:fail:preferences is null`);
3402
+ }
3403
+ preferences.deleteSync(key);
3404
+ preferences.flush();
3405
+ }
3265
3406
  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
- }));
3407
+ const name = 'clearStorage';
3408
+ const { isExist, error } = checkContextExist(name, true);
3409
+ if (!isExist) {
3410
+ return error;
3411
+ }
3412
+ const { success, fail, complete } = options || {};
3413
+ const handle = new MethodHandler({ name, success, fail, complete });
3414
+ return new Promise((resolve, reject) => {
3415
+ const preferences = getPreferences();
3416
+ if (!preferences)
3417
+ return handle.fail({}, { resolve, reject });
3418
+ preferences.clearSync();
3419
+ preferences.flush();
3420
+ return handle.success({}, { resolve, reject });
3273
3421
  });
3274
3422
  }
3423
+ function clearStorageSync() {
3424
+ const name = 'clearStorageSync';
3425
+ const { isExist, error } = checkContextExist(name, false);
3426
+ if (!isExist) {
3427
+ return error;
3428
+ }
3429
+ const preferences = getPreferences();
3430
+ if (!preferences) {
3431
+ throw new Error(`${name}:fail:preferences is null`);
3432
+ }
3433
+ preferences.clearSync();
3434
+ preferences.flush();
3435
+ }
3275
3436
  const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync');
3276
3437
  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
3438
  const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL');
3282
3439
  const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL');
3283
3440
  const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStorageSync');
@@ -3347,7 +3504,7 @@ class Animation {
3347
3504
  return this;
3348
3505
  }
3349
3506
  scale(sx, sy) {
3350
- this.rule.scale = { x: sx, y: sy };
3507
+ this.rule.scale = { x: sx, y: isUndefined(sy) ? sx : sy };
3351
3508
  return this;
3352
3509
  }
3353
3510
  scale3d(sx, sy, sz) {
@@ -3908,19 +4065,16 @@ class IntersectionObserver {
3908
4065
  };
3909
4066
  const taro = Current.taro;
3910
4067
  const page = taro.getCurrentInstance().page;
3911
- const currentPage = getPageScrollerOrNode(page.node, page);
3912
- this._component = component || currentPage;
4068
+ this._component = component || getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
3913
4069
  Object.assign(this._options, options);
3914
4070
  }
3915
4071
  disconnect() {
3916
- var _a;
3917
- if (this._observerNodes) {
4072
+ if (this._observerNodes && this._component) {
3918
4073
  if (this._observerNodes instanceof Array) {
3919
4074
  this._observerNodes.forEach((n) => {
3920
- var _a;
3921
4075
  disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME);
3922
4076
  // @ts-ignore
3923
- (_a = n._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = null;
4077
+ n._nodeInfo.thresholds = null;
3924
4078
  });
3925
4079
  }
3926
4080
  else {
@@ -3928,35 +4082,40 @@ class IntersectionObserver {
3928
4082
  // @ts-ignore
3929
4083
  if (this._observerNodes._nodeInfo) {
3930
4084
  // @ts-ignore
3931
- (_a = this._observerNodes._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = null;
4085
+ this._observerNodes._nodeInfo.thresholds = null;
3932
4086
  }
3933
4087
  }
3934
4088
  }
3935
4089
  }
3936
4090
  observe(targetSelector, callback) {
3937
- var _a;
4091
+ if (!this._component)
4092
+ return;
3938
4093
  const { observeAll, thresholds } = this._options;
3939
4094
  const node = findChildNodeWithDFS(this._component, targetSelector, observeAll);
3940
4095
  this._observerNodes = node;
3941
4096
  if (node) {
3942
4097
  if (node instanceof Array) {
3943
4098
  node.forEach(n => {
3944
- var _a;
3945
4099
  // @ts-ignore
3946
- (_a = n._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = thresholds;
4100
+ n._nodeInfo.thresholds = thresholds;
3947
4101
  setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3948
- callback(this.handleResult(isVisible, currentRatio));
4102
+ callback(this.handleResult(isVisible, currentRatio, n));
3949
4103
  });
3950
4104
  });
3951
4105
  }
3952
4106
  else {
3953
4107
  // @ts-ignore
3954
- (_a = node._nodeInfo) === null || _a === void 0 ? void 0 : _a.thresholds = thresholds;
4108
+ node._nodeInfo.thresholds = thresholds;
3955
4109
  setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
3956
- callback(this.handleResult(isVisible, currentRatio));
4110
+ callback(this.handleResult(isVisible, currentRatio, node));
3957
4111
  });
3958
4112
  }
3959
4113
  }
4114
+ else {
4115
+ callback({
4116
+ errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
4117
+ });
4118
+ }
3960
4119
  }
3961
4120
  relativeTo() {
3962
4121
  temporarilyNotSupport('relativeTo')();
@@ -3967,8 +4126,10 @@ class IntersectionObserver {
3967
4126
  return this;
3968
4127
  }
3969
4128
  // @ts-ignore
3970
- handleResult(isVisible, currentRatio) {
4129
+ handleResult(isVisible, currentRatio, node) {
3971
4130
  const result = {
4131
+ id: node.id,
4132
+ dataset: node.dataset,
3972
4133
  intersectionRatio: currentRatio,
3973
4134
  // TODO 未做,等待能拿到element的info信息
3974
4135
  boundingClientRect: {
@@ -4280,6 +4441,7 @@ var apis = /*#__PURE__*/Object.freeze({
4280
4441
  ENV_TYPE: ENV_TYPE,
4281
4442
  Events: Events,
4282
4443
  History: History,
4444
+ IntersectionObserver: IntersectionObserver,
4283
4445
  addCard: addCard,
4284
4446
  addFileToFavorites: addFileToFavorites,
4285
4447
  addPhoneCalendar: addPhoneCalendar,
@@ -4669,7 +4831,7 @@ var apis = /*#__PURE__*/Object.freeze({
4669
4831
  writeBLECharacteristicValue: writeBLECharacteristicValue
4670
4832
  });
4671
4833
 
4672
- Object.assign({}, apis);
4834
+ const taro = Object.assign({}, apis);
4673
4835
  const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin');
4674
4836
  function initNativeApi(taro) {
4675
4837
  Current.taro = taro;
@@ -4693,7 +4855,7 @@ const defaultBaseFontSize = 20;
4693
4855
  const defaultUnitPrecision = 5;
4694
4856
  const defaultTargetUnit = 'vp';
4695
4857
  function getApp$1() {
4696
- return Current.app;
4858
+ return Current.app || {};
4697
4859
  }
4698
4860
  function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
4699
4861
  const taro = Current.taro;
@@ -4707,7 +4869,8 @@ function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defau
4707
4869
  config.unitPrecision = unitPrecision;
4708
4870
  }
4709
4871
  }
4710
- _display.getDefaultDisplaySync();
4872
+ const display = _display.getDefaultDisplaySync();
4873
+ display.width;
4711
4874
  function pxTransform(size) {
4712
4875
  var _a;
4713
4876
  const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
@@ -4733,6 +4896,7 @@ function getAppInfo() {
4733
4896
  designWidth: config === null || config === void 0 ? void 0 : config.designWidth,
4734
4897
  };
4735
4898
  }
4899
+ initNativeApi(taro);
4736
4900
 
4737
4901
  const components = {
4738
4902
  Checkbox: {