@tarojs/plugin-platform-harmony-ets 4.0.0-beta.2 → 4.0.0-beta.21
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.
- package/dist/apis/base/system.ts +53 -20
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +3 -1
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +124 -60
- package/dist/apis/wxml/IntersectionObserver.ts +5 -3
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +41 -78
- package/dist/components-harmony-ets/checkbox.ets +19 -209
- package/dist/components-harmony-ets/form.ets +38 -160
- package/dist/components-harmony-ets/icon.ets +31 -83
- package/dist/components-harmony-ets/image.ets +22 -78
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +10 -67
- package/dist/components-harmony-ets/label.ets +52 -173
- package/dist/components-harmony-ets/movableArea.ets +89 -0
- package/dist/components-harmony-ets/movableView.ets +67 -0
- package/dist/components-harmony-ets/picker.ets +32 -147
- package/dist/components-harmony-ets/progress.ets +47 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +19 -210
- package/dist/components-harmony-ets/richText.ets +22 -102
- package/dist/components-harmony-ets/scrollView.ets +66 -169
- package/dist/components-harmony-ets/slider.ets +10 -72
- package/dist/components-harmony-ets/style.ets +244 -0
- package/dist/components-harmony-ets/swiper.ets +30 -87
- package/dist/components-harmony-ets/switch.ets +9 -71
- package/dist/components-harmony-ets/text.ets +38 -89
- package/dist/components-harmony-ets/textArea.ets +10 -67
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
- package/dist/components-harmony-ets/utils/flexManager.ets +8 -7
- package/dist/components-harmony-ets/utils/helper.ets +5 -4
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/index.ts +55 -2
- package/dist/components-harmony-ets/utils/styles.ets +45 -85
- package/dist/components-harmony-ets/video.ets +33 -88
- package/dist/components-harmony-ets/view.ets +47 -160
- package/dist/components-harmony-ets/webView.ets +44 -99
- package/dist/index.d.ts +151 -0
- package/dist/index.js +58 -29
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +4 -2
- package/dist/runtime-ets/current.ts +2 -0
- package/dist/runtime-ets/dom/bind.ts +0 -1
- package/dist/runtime-ets/dom/cssNesting.ts +311 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +15 -40
- package/dist/runtime-ets/dom/document.ts +21 -8
- package/dist/runtime-ets/dom/element/element.ts +53 -9
- package/dist/runtime-ets/dom/element/form.ts +11 -4
- package/dist/runtime-ets/dom/element/index.ts +12 -1
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +193 -0
- package/dist/runtime-ets/dom/element/normal.ts +8 -3
- package/dist/runtime-ets/dom/element/progress.ts +13 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -0
- package/dist/runtime-ets/dom/element/video.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +8 -0
- package/dist/runtime-ets/dom/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/node.ts +18 -17
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +184 -207
- package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
- package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
- package/dist/runtime-ets/dom/stylesheet/util.ts +19 -15
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +24 -9
- package/dist/runtime-framework/react/app.ts +5 -1
- package/dist/runtime-framework/react/hooks.ts +3 -3
- package/dist/runtime-framework/react/native-page.ts +14 -9
- package/dist/runtime-framework/react/page.ts +1 -0
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +825 -0
- package/dist/runtime-utils.js +185 -91
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +185 -91
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +10 -10
- package/types/index.d.ts +4 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
package/dist/runtime-utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, 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';
|
|
@@ -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
|
-
|
|
270
|
-
|
|
271
|
-
let
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
269
|
+
let display;
|
|
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 = _display.getDefaultDisplaySync();
|
|
283
|
+
// @ts-ignore
|
|
284
|
+
display.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.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.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
|
|
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 =
|
|
300
|
-
res.platform = '
|
|
301
|
-
res.safeArea =
|
|
302
|
-
res.screenHeight = display
|
|
303
|
-
res.screenWidth = display
|
|
304
|
-
res.statusBarHeight =
|
|
305
|
-
res.system = deviceInfo
|
|
306
|
-
|
|
307
|
-
res.
|
|
308
|
-
res.windowHeight =
|
|
309
|
-
res.
|
|
332
|
+
res.pixelRatio = display && (Math.round(display.xDPI / display.width * 100) / 100); // 设备像素比,number
|
|
333
|
+
res.platform = 'harmony'; // 客户端平台 string
|
|
334
|
+
res.safeArea = safeArea; // 在竖屏正方向下的安全区域 General.SafeAreaResult
|
|
335
|
+
res.screenHeight = display === null || display === void 0 ? void 0 : display.height; // 屏幕高度,单位px number
|
|
336
|
+
res.screenWidth = display === null || display === void 0 ? void 0 : display.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
|
/* 异步版本 */
|
|
@@ -1984,7 +2018,6 @@ function getEnv() {
|
|
|
1984
2018
|
}
|
|
1985
2019
|
// TODO
|
|
1986
2020
|
const getCurrentPages = () => [];
|
|
1987
|
-
const getCurrentInstance = () => Current;
|
|
1988
2021
|
const requirePlugin$1 = temporarilyNotSupport('requirePlugin');
|
|
1989
2022
|
|
|
1990
2023
|
// @ts-nocheck
|
|
@@ -2611,10 +2644,10 @@ const request = function (options) {
|
|
|
2611
2644
|
header['Content-Type'] = 'application/json';
|
|
2612
2645
|
}
|
|
2613
2646
|
// 检查 Header 是否有 Referer
|
|
2614
|
-
if (isUndefined(header.Referer)) {
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
}
|
|
2647
|
+
// if (isUndefined(header.Referer)) {
|
|
2648
|
+
// const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
|
|
2649
|
+
// callAsyncFail(reject, error, options)
|
|
2650
|
+
// }
|
|
2618
2651
|
// 检查 method 是否正确
|
|
2619
2652
|
if (method) {
|
|
2620
2653
|
if (!METHOD.includes(method)) {
|
|
@@ -3060,6 +3093,19 @@ function parseURL(raw = '') {
|
|
|
3060
3093
|
const [urlStr, queryStr = ''] = raw.split('?');
|
|
3061
3094
|
const query = queryToJson(queryStr);
|
|
3062
3095
|
let url = urlStr.replace(/^\//, '');
|
|
3096
|
+
// 处理相对路径
|
|
3097
|
+
if (url.indexOf('.') === 0) {
|
|
3098
|
+
const page = router.getState();
|
|
3099
|
+
const parts = page.path.split('/');
|
|
3100
|
+
parts.pop();
|
|
3101
|
+
url.split('/').forEach((item) => {
|
|
3102
|
+
if (item === '.') {
|
|
3103
|
+
return;
|
|
3104
|
+
}
|
|
3105
|
+
item === '..' ? parts.pop() : parts.push(item);
|
|
3106
|
+
});
|
|
3107
|
+
url = parts.join('/');
|
|
3108
|
+
}
|
|
3063
3109
|
if (isTabPage(url)) {
|
|
3064
3110
|
query.$page = url;
|
|
3065
3111
|
url = TARO_TABBAR_PAGE_PATH;
|
|
@@ -3177,107 +3223,152 @@ const getBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('getBackgro
|
|
|
3177
3223
|
// 周期性更新
|
|
3178
3224
|
const createCacheManager = /* @__PURE__ */ temporarilyNotSupport('createCacheManager');
|
|
3179
3225
|
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
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);
|
|
3226
|
+
/**
|
|
3227
|
+
* 从API Version 6开始,该模块不再维护,可以使用模块@ohos.data.storage。在API Version 9后,推荐使用新模块@ohos.data.preferences。
|
|
3228
|
+
* https://developer.harmonyos.com/cn/docs/documentation/doc-references-V3/js-apis-data-preferences-0000001427745052-V3
|
|
3229
|
+
*/
|
|
3230
|
+
let context;
|
|
3231
|
+
let preferences;
|
|
3232
|
+
Current.contextPromise.then((ctx) => {
|
|
3233
|
+
context = ctx;
|
|
3234
|
+
return context;
|
|
3191
3235
|
});
|
|
3192
|
-
function
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
const
|
|
3196
|
-
|
|
3197
|
-
return { result: true, data: item };
|
|
3198
|
-
}
|
|
3199
|
-
catch (error) {
|
|
3200
|
-
return { result: false };
|
|
3236
|
+
function getPreferences() {
|
|
3237
|
+
try {
|
|
3238
|
+
if (!preferences) {
|
|
3239
|
+
const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
|
|
3240
|
+
preferences = dataPreferences.getPreferencesSync(context, { name: `${data.appInfo.uid}Store` });
|
|
3201
3241
|
}
|
|
3202
|
-
}
|
|
3242
|
+
}
|
|
3243
|
+
catch (error) {
|
|
3244
|
+
hilog.error(0x0000, 'TaroFailedTag', 'Failed to load the storage. Cause: %{public}s', error.code ? JSON.stringify(error) : error.message || error);
|
|
3245
|
+
}
|
|
3246
|
+
return preferences;
|
|
3203
3247
|
}
|
|
3204
3248
|
const storageSchema = {
|
|
3205
3249
|
key: 'String'
|
|
3206
3250
|
};
|
|
3207
3251
|
function getStorage(options) {
|
|
3252
|
+
const { key, success, fail, complete } = options || {};
|
|
3253
|
+
const handle = new MethodHandler({ name: 'getStorage', success, fail, complete });
|
|
3208
3254
|
return new Promise((resolve, reject) => {
|
|
3209
3255
|
try {
|
|
3210
3256
|
validateParams('getStorage', options, storageSchema);
|
|
3211
3257
|
}
|
|
3212
3258
|
catch (error) {
|
|
3213
3259
|
const res = { errMsg: error.message };
|
|
3214
|
-
return
|
|
3260
|
+
return handle.fail(res, { resolve, reject });
|
|
3261
|
+
}
|
|
3262
|
+
const preferences = getPreferences();
|
|
3263
|
+
if (!preferences)
|
|
3264
|
+
return handle.fail({}, { resolve, reject });
|
|
3265
|
+
const data = preferences.getSync(key, null);
|
|
3266
|
+
if (data) {
|
|
3267
|
+
return handle.success({ data }, { resolve, reject });
|
|
3268
|
+
}
|
|
3269
|
+
else {
|
|
3270
|
+
return handle.success({ errMsg: 'data not found' }, { resolve, reject });
|
|
3215
3271
|
}
|
|
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
3272
|
});
|
|
3228
3273
|
}
|
|
3274
|
+
function getStorageSync(key) {
|
|
3275
|
+
if (!key) {
|
|
3276
|
+
throw new Error('getStorageSync:fail parameter error: parameter should be String');
|
|
3277
|
+
}
|
|
3278
|
+
const preferences = getPreferences();
|
|
3279
|
+
if (!preferences) {
|
|
3280
|
+
throw new Error('getStorageSync:fail:preferences is null');
|
|
3281
|
+
}
|
|
3282
|
+
const data = preferences.getSync(key, null);
|
|
3283
|
+
if (data) {
|
|
3284
|
+
return data;
|
|
3285
|
+
}
|
|
3286
|
+
else {
|
|
3287
|
+
throw new Error('data not found');
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3229
3290
|
function setStorage(options) {
|
|
3291
|
+
const { key, data, success, fail, complete } = options || {};
|
|
3292
|
+
const handle = new MethodHandler({ name: 'setStorage', success, fail, complete });
|
|
3230
3293
|
return new Promise((resolve, reject) => {
|
|
3231
3294
|
try {
|
|
3232
3295
|
validateParams('setStorage', options, storageSchema);
|
|
3233
3296
|
}
|
|
3234
3297
|
catch (error) {
|
|
3235
3298
|
const res = { errMsg: error.message };
|
|
3236
|
-
return
|
|
3299
|
+
return handle.fail(res, { resolve, reject });
|
|
3237
3300
|
}
|
|
3238
|
-
const
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
}));
|
|
3301
|
+
const preferences = getPreferences();
|
|
3302
|
+
if (!preferences)
|
|
3303
|
+
return handle.fail({}, { resolve, reject });
|
|
3304
|
+
preferences.putSync(key, data);
|
|
3305
|
+
preferences.flush();
|
|
3306
|
+
return handle.success({}, { resolve, reject });
|
|
3245
3307
|
});
|
|
3246
3308
|
}
|
|
3309
|
+
function setStorageSync(key, data) {
|
|
3310
|
+
if (!key) {
|
|
3311
|
+
throw new Error('setStorageSync:fail key error: key should be String');
|
|
3312
|
+
}
|
|
3313
|
+
const preferences = getPreferences();
|
|
3314
|
+
if (!preferences) {
|
|
3315
|
+
throw new Error('setStorageSync:fail:preferences is null');
|
|
3316
|
+
}
|
|
3317
|
+
preferences.putSync(key, data);
|
|
3318
|
+
preferences.flush();
|
|
3319
|
+
}
|
|
3247
3320
|
function removeStorage(options) {
|
|
3321
|
+
const { key, success, fail, complete } = options || {};
|
|
3322
|
+
const handle = new MethodHandler({ name: 'removeStorage', success, fail, complete });
|
|
3248
3323
|
return new Promise((resolve, reject) => {
|
|
3249
3324
|
try {
|
|
3250
3325
|
validateParams('removeStorage', options, storageSchema);
|
|
3251
3326
|
}
|
|
3252
3327
|
catch (error) {
|
|
3253
3328
|
const res = { errMsg: error.message };
|
|
3254
|
-
return
|
|
3329
|
+
return handle.fail(res, { resolve, reject });
|
|
3255
3330
|
}
|
|
3256
|
-
const
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
}));
|
|
3331
|
+
const preferences = getPreferences();
|
|
3332
|
+
if (!preferences)
|
|
3333
|
+
return handle.fail({}, { resolve, reject });
|
|
3334
|
+
preferences.deleteSync(key);
|
|
3335
|
+
preferences.flush();
|
|
3336
|
+
return handle.success({}, { resolve, reject });
|
|
3263
3337
|
});
|
|
3264
3338
|
}
|
|
3339
|
+
function removeStorageSync(key) {
|
|
3340
|
+
if (!key) {
|
|
3341
|
+
throw new Error('removeStorageSync:fail key error: key should be String');
|
|
3342
|
+
}
|
|
3343
|
+
const preferences = getPreferences();
|
|
3344
|
+
if (!preferences) {
|
|
3345
|
+
throw new Error('removeStorageSync:fail:preferences is null');
|
|
3346
|
+
}
|
|
3347
|
+
preferences.deleteSync(key);
|
|
3348
|
+
preferences.flush();
|
|
3349
|
+
}
|
|
3265
3350
|
function clearStorage(options) {
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3351
|
+
const { success, fail, complete } = options || {};
|
|
3352
|
+
const handle = new MethodHandler({ name: 'clearStorage', success, fail, complete });
|
|
3353
|
+
return new Promise((resolve, reject) => {
|
|
3354
|
+
const preferences = getPreferences();
|
|
3355
|
+
if (!preferences)
|
|
3356
|
+
return handle.fail({}, { resolve, reject });
|
|
3357
|
+
preferences.clearSync();
|
|
3358
|
+
preferences.flush();
|
|
3359
|
+
return handle.success({}, { resolve, reject });
|
|
3273
3360
|
});
|
|
3274
3361
|
}
|
|
3362
|
+
function clearStorageSync() {
|
|
3363
|
+
const preferences = getPreferences();
|
|
3364
|
+
if (!preferences) {
|
|
3365
|
+
throw new Error('clearStorageSync:fail:preferences is null');
|
|
3366
|
+
}
|
|
3367
|
+
preferences.clearSync();
|
|
3368
|
+
preferences.flush();
|
|
3369
|
+
}
|
|
3275
3370
|
const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync');
|
|
3276
3371
|
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
3372
|
const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL');
|
|
3282
3373
|
const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL');
|
|
3283
3374
|
const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStorageSync');
|
|
@@ -3908,13 +3999,12 @@ class IntersectionObserver {
|
|
|
3908
3999
|
};
|
|
3909
4000
|
const taro = Current.taro;
|
|
3910
4001
|
const page = taro.getCurrentInstance().page;
|
|
3911
|
-
|
|
3912
|
-
this._component = component || currentPage;
|
|
4002
|
+
this._component = component || getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
|
|
3913
4003
|
Object.assign(this._options, options);
|
|
3914
4004
|
}
|
|
3915
4005
|
disconnect() {
|
|
3916
4006
|
var _a;
|
|
3917
|
-
if (this._observerNodes) {
|
|
4007
|
+
if (this._observerNodes && this._component) {
|
|
3918
4008
|
if (this._observerNodes instanceof Array) {
|
|
3919
4009
|
this._observerNodes.forEach((n) => {
|
|
3920
4010
|
var _a;
|
|
@@ -3935,6 +4025,8 @@ class IntersectionObserver {
|
|
|
3935
4025
|
}
|
|
3936
4026
|
observe(targetSelector, callback) {
|
|
3937
4027
|
var _a;
|
|
4028
|
+
if (!this._component)
|
|
4029
|
+
return;
|
|
3938
4030
|
const { observeAll, thresholds } = this._options;
|
|
3939
4031
|
const node = findChildNodeWithDFS(this._component, targetSelector, observeAll);
|
|
3940
4032
|
this._observerNodes = node;
|
|
@@ -4280,6 +4372,7 @@ var apis = /*#__PURE__*/Object.freeze({
|
|
|
4280
4372
|
ENV_TYPE: ENV_TYPE,
|
|
4281
4373
|
Events: Events,
|
|
4282
4374
|
History: History,
|
|
4375
|
+
IntersectionObserver: IntersectionObserver,
|
|
4283
4376
|
addCard: addCard,
|
|
4284
4377
|
addFileToFavorites: addFileToFavorites,
|
|
4285
4378
|
addPhoneCalendar: addPhoneCalendar,
|
|
@@ -4669,7 +4762,7 @@ var apis = /*#__PURE__*/Object.freeze({
|
|
|
4669
4762
|
writeBLECharacteristicValue: writeBLECharacteristicValue
|
|
4670
4763
|
});
|
|
4671
4764
|
|
|
4672
|
-
Object.assign({}, apis);
|
|
4765
|
+
const taro = Object.assign({}, apis);
|
|
4673
4766
|
const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin');
|
|
4674
4767
|
function initNativeApi(taro) {
|
|
4675
4768
|
Current.taro = taro;
|
|
@@ -4693,7 +4786,7 @@ const defaultBaseFontSize = 20;
|
|
|
4693
4786
|
const defaultUnitPrecision = 5;
|
|
4694
4787
|
const defaultTargetUnit = 'vp';
|
|
4695
4788
|
function getApp$1() {
|
|
4696
|
-
return Current.app;
|
|
4789
|
+
return Current.app || {};
|
|
4697
4790
|
}
|
|
4698
4791
|
function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
|
|
4699
4792
|
const taro = Current.taro;
|
|
@@ -4733,6 +4826,7 @@ function getAppInfo() {
|
|
|
4733
4826
|
designWidth: config === null || config === void 0 ? void 0 : config.designWidth,
|
|
4734
4827
|
};
|
|
4735
4828
|
}
|
|
4829
|
+
initNativeApi(taro);
|
|
4736
4830
|
|
|
4737
4831
|
const components = {
|
|
4738
4832
|
Checkbox: {
|