@tarojs/plugin-platform-harmony-ets 4.0.0-beta.7 → 4.0.0-beta.70
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 +73 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +9 -1
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +146 -78
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +42 -59
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/ui/scroll/index.ts +1 -1
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/apis/wxml/selectorQuery.ts +24 -11
- package/dist/components-harmony-ets/button.ets +48 -34
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +69 -61
- package/dist/components-harmony-ets/form.ets +51 -29
- package/dist/components-harmony-ets/icon.ets +31 -19
- package/dist/components-harmony-ets/image.ets +34 -14
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +45 -41
- package/dist/components-harmony-ets/label.ets +69 -42
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +126 -0
- package/dist/components-harmony-ets/movableView.ets +77 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +42 -38
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +71 -64
- package/dist/components-harmony-ets/richText.ets +14 -30
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +61 -57
- package/dist/components-harmony-ets/slider.ets +15 -14
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +372 -130
- package/dist/components-harmony-ets/swiper.ets +61 -20
- package/dist/components-harmony-ets/switch.ets +30 -28
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +135 -49
- package/dist/components-harmony-ets/textArea.ets +47 -35
- 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 +47 -19
- package/dist/components-harmony-ets/utils/helper.ets +18 -5
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +170 -93
- package/dist/components-harmony-ets/video.ets +34 -21
- package/dist/components-harmony-ets/view.ets +63 -52
- package/dist/components-harmony-ets/webView.ets +40 -34
- package/dist/index.d.ts +152 -0
- package/dist/index.js +85 -42
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +7 -0
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
- package/dist/runtime-ets/dom/document.ts +22 -8
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +334 -58
- package/dist/runtime-ets/dom/element/form.ts +23 -26
- package/dist/runtime-ets/dom/element/index.ts +25 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +209 -0
- package/dist/runtime-ets/dom/element/normal.ts +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -4
- package/dist/runtime-ets/dom/element/webView.ts +12 -5
- package/dist/runtime-ets/dom/event.ts +2 -4
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +49 -28
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +416 -235
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +49 -9
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/index.ts +2 -1
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +69 -13
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-framework/react/app.ts +7 -2
- package/dist/runtime-framework/react/hooks.ts +0 -1
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +32 -14
- package/dist/runtime-framework/react/page.ts +3 -8
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +16 -11
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -30
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- 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 +827 -0
- package/dist/runtime-utils.js +425 -200
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +425 -200
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +13 -13
- package/static/media/cancel.svg +1 -1
- package/static/media/circle.svg +1 -1
- package/static/media/clear.svg +1 -1
- package/static/media/download.svg +1 -1
- package/static/media/info.svg +1 -1
- package/static/media/info_circle.svg +1 -1
- package/static/media/search.svg +1 -1
- package/static/media/success.svg +1 -1
- package/static/media/success_no_circle.svg +1 -1
- package/static/media/warn.svg +1 -1
- package/types/harmony.d.ts +4 -0
- package/types/index.d.ts +4 -0
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
package/dist/runtime.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
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';
|
|
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
|
|
32
|
-
import hilog from '@ohos.hilog';
|
|
32
|
+
import distributedKVStore from '@ohos.data.distributedKVStore';
|
|
33
33
|
import matrix4 from '@ohos.matrix4';
|
|
34
|
-
import
|
|
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 =
|
|
188
|
+
let errMsg = `暂时不支持 API ${name}`;
|
|
190
189
|
if (recommended) {
|
|
191
190
|
errMsg += `, 请使用 ${recommended}`;
|
|
192
191
|
}
|
|
@@ -266,16 +265,63 @@ const preloadWebview = /* @__PURE__ */ temporarilyNotSupport('preloadWebview');
|
|
|
266
265
|
const preloadSkylineView = /* @__PURE__ */ temporarilyNotSupport('preloadSkylineView');
|
|
267
266
|
const preloadAssets = /* @__PURE__ */ temporarilyNotSupport('preloadAssets');
|
|
268
267
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
let
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
+
setSafeArea({
|
|
283
|
+
top: statusBarHeight,
|
|
284
|
+
left: 0,
|
|
285
|
+
right: display$1.width,
|
|
286
|
+
bottom: navigationIndicatorRect === null || navigationIndicatorRect === void 0 ? void 0 : navigationIndicatorRect.top
|
|
287
|
+
});
|
|
288
|
+
// @ts-ignore
|
|
289
|
+
display$1.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} } = {}) => {
|
|
290
|
+
var _a, _b, _c, _d, _e, _f;
|
|
291
|
+
if (err === null || err === void 0 ? void 0 : err.code) {
|
|
292
|
+
console.error('Failed to get cutout info', JSON.stringify(err));
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
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);
|
|
296
|
+
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);
|
|
297
|
+
const left = ((_d = waterfallDisplayAreaRects.left) === null || _d === void 0 ? void 0 : _d.left) + ((_e = waterfallDisplayAreaRects.left) === null || _e === void 0 ? void 0 : _e.width);
|
|
298
|
+
const right = display$1.width - ((_f = waterfallDisplayAreaRects.right) === null || _f === void 0 ? void 0 : _f.left);
|
|
299
|
+
setSafeArea({
|
|
300
|
+
top,
|
|
301
|
+
left,
|
|
302
|
+
right,
|
|
303
|
+
bottom
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
catch (e) {
|
|
308
|
+
console.error('Failed to get display', e);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
276
311
|
});
|
|
312
|
+
function setSafeArea({ top, left, right, bottom }) {
|
|
313
|
+
safeArea = {
|
|
314
|
+
top,
|
|
315
|
+
bottom,
|
|
316
|
+
left,
|
|
317
|
+
right,
|
|
318
|
+
height: bottom - top,
|
|
319
|
+
width: right - left,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
277
322
|
/* 同步版本 */
|
|
278
323
|
const getSystemInfoSync = function () {
|
|
324
|
+
var _a, _b;
|
|
279
325
|
const res = {};
|
|
280
326
|
res.SDKVersion = deviceInfo && deviceInfo.sdkApiVersion; // 客户端基础库版本 string
|
|
281
327
|
res.albumAuthorized = false; // 允许使用相册的开关(仅 iOS 有效) boolean
|
|
@@ -285,7 +331,7 @@ const getSystemInfoSync = function () {
|
|
|
285
331
|
res.cameraAuthorized = null; // 允许使用摄像头的开关 boolean
|
|
286
332
|
res.enableDebug = null; // 是否已打开调试 boolean
|
|
287
333
|
res.fontSizeSetting = null; // 用户字体大小(单位px) number
|
|
288
|
-
res.language = i18n
|
|
334
|
+
res.language = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.getSystemLanguage) === null || _a === void 0 ? void 0 : _a.call(i18n); // string
|
|
289
335
|
res.locationAuthorized = null; // 定位的开关 boolean
|
|
290
336
|
res.locationEnabled = null; // 地理位置的系统开关 boolean
|
|
291
337
|
res.microphoneAuthorized = null; // 麦克风的开关 boolean
|
|
@@ -296,17 +342,18 @@ const getSystemInfoSync = function () {
|
|
|
296
342
|
res.notificationSoundAuthorized = false; // 通知带有声音的开关(仅 iOS 有效)boolean
|
|
297
343
|
res.phoneCalendarAuthorized = null; // 使用日历的开关 boolean
|
|
298
344
|
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.
|
|
345
|
+
res.pixelRatio = display$1 && display$1.densityPixels; // 设备像素比,number
|
|
346
|
+
res.platform = 'harmony'; // 客户端平台 string
|
|
347
|
+
res.safeArea = safeArea; // 在竖屏正方向下的安全区域 General.SafeAreaResult
|
|
348
|
+
res.screenHeight = display$1 === null || display$1 === void 0 ? void 0 : display$1.height; // 屏幕高度,单位px number
|
|
349
|
+
res.screenWidth = display$1 === null || display$1 === void 0 ? void 0 : display$1.width; // 屏幕宽度,单位px number
|
|
350
|
+
res.statusBarHeight = statusBarHeight; // 状态栏的高度,单位px number
|
|
351
|
+
res.system = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.osFullName; // 操作系统及版本 string
|
|
352
|
+
// Note: 更新配置时才能记录
|
|
353
|
+
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'
|
|
354
|
+
res.windowHeight = windowRect === null || windowRect === void 0 ? void 0 : windowRect.height; // 可使用窗口高度,单位px number
|
|
355
|
+
res.windowWidth = windowRect === null || windowRect === void 0 ? void 0 : windowRect.width; // 可使用窗口宽度,单位px number
|
|
356
|
+
res.version = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.displayVersion; // 版本号 string
|
|
310
357
|
return res;
|
|
311
358
|
};
|
|
312
359
|
/* 异步版本 */
|
|
@@ -412,7 +459,13 @@ const base64ToArrayBuffer = /* @__PURE__ */ temporarilyNotSupport('base64ToArray
|
|
|
412
459
|
/** 创建离屏 canvas 实例 */
|
|
413
460
|
const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
|
|
414
461
|
/** 创建 canvas 的绘图上下文 CanvasContext 对象 */
|
|
415
|
-
|
|
462
|
+
|
|
463
|
+
const createCanvasContext = (canvasId) => {
|
|
464
|
+
const dom = eventSource.get(`canvasId-${canvasId}`);
|
|
465
|
+
// return dom as TaroCanvasElement
|
|
466
|
+
if (dom)
|
|
467
|
+
return dom.context;
|
|
468
|
+
};
|
|
416
469
|
/** 把当前画布指定区域的内容导出生成指定大小的图片 */
|
|
417
470
|
const canvasToTempFilePath = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
|
|
418
471
|
/** 将像素数据绘制到画布 */
|
|
@@ -617,6 +670,12 @@ const setClipboardData = function (options) {
|
|
|
617
670
|
callAsyncFail(reject, res, options);
|
|
618
671
|
}
|
|
619
672
|
else {
|
|
673
|
+
promptAction.showToast({
|
|
674
|
+
message: '内容已复制',
|
|
675
|
+
duration: 1500,
|
|
676
|
+
bottom: '50%',
|
|
677
|
+
showMode: 1 // 设置弹窗显示模式,显示在应用之上。
|
|
678
|
+
});
|
|
620
679
|
return handle.success({
|
|
621
680
|
data,
|
|
622
681
|
}, { resolve, reject });
|
|
@@ -1984,7 +2043,6 @@ function getEnv() {
|
|
|
1984
2043
|
}
|
|
1985
2044
|
// TODO
|
|
1986
2045
|
const getCurrentPages = () => [];
|
|
1987
|
-
const getCurrentInstance = () => Current;
|
|
1988
2046
|
const requirePlugin$1 = temporarilyNotSupport('requirePlugin');
|
|
1989
2047
|
|
|
1990
2048
|
// @ts-nocheck
|
|
@@ -2611,10 +2669,10 @@ const request = function (options) {
|
|
|
2611
2669
|
header['Content-Type'] = 'application/json';
|
|
2612
2670
|
}
|
|
2613
2671
|
// 检查 Header 是否有 Referer
|
|
2614
|
-
if (isUndefined(header.Referer)) {
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
}
|
|
2672
|
+
// if (isUndefined(header.Referer)) {
|
|
2673
|
+
// const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
|
|
2674
|
+
// callAsyncFail(reject, error, options)
|
|
2675
|
+
// }
|
|
2618
2676
|
// 检查 method 是否正确
|
|
2619
2677
|
if (method) {
|
|
2620
2678
|
if (!METHOD.includes(method)) {
|
|
@@ -3060,6 +3118,19 @@ function parseURL(raw = '') {
|
|
|
3060
3118
|
const [urlStr, queryStr = ''] = raw.split('?');
|
|
3061
3119
|
const query = queryToJson(queryStr);
|
|
3062
3120
|
let url = urlStr.replace(/^\//, '');
|
|
3121
|
+
// 处理相对路径
|
|
3122
|
+
if (url.indexOf('.') === 0) {
|
|
3123
|
+
const page = router.getState();
|
|
3124
|
+
const parts = page.path.split('/');
|
|
3125
|
+
parts.pop();
|
|
3126
|
+
url.split('/').forEach((item) => {
|
|
3127
|
+
if (item === '.') {
|
|
3128
|
+
return;
|
|
3129
|
+
}
|
|
3130
|
+
item === '..' ? parts.pop() : parts.push(item);
|
|
3131
|
+
});
|
|
3132
|
+
url = parts.join('/');
|
|
3133
|
+
}
|
|
3063
3134
|
if (isTabPage(url)) {
|
|
3064
3135
|
query.$page = url;
|
|
3065
3136
|
url = TARO_TABBAR_PAGE_PATH;
|
|
@@ -3177,113 +3248,172 @@ const getBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('getBackgro
|
|
|
3177
3248
|
// 周期性更新
|
|
3178
3249
|
const createCacheManager = /* @__PURE__ */ temporarilyNotSupport('createCacheManager');
|
|
3179
3250
|
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3251
|
+
/**
|
|
3252
|
+
* 从API Version 6开始,该模块不再维护,可以使用模块@ohos.data.storage。在API Version 9后,推荐使用新模块@ohos.data.preferences。
|
|
3253
|
+
* https://developer.harmonyos.com/cn/docs/documentation/doc-references-V3/js-apis-data-preferences-0000001427745052-V3
|
|
3254
|
+
*/
|
|
3255
|
+
let context;
|
|
3256
|
+
let kvManager;
|
|
3257
|
+
let kvStore;
|
|
3258
|
+
let kvStorePromise;
|
|
3259
|
+
Current.contextPromise.then((ctx) => {
|
|
3260
|
+
context = ctx;
|
|
3261
|
+
const kvManagerConfig = {
|
|
3262
|
+
context: context,
|
|
3263
|
+
bundleName: 'com.example.taro'
|
|
3264
|
+
};
|
|
3265
|
+
try {
|
|
3266
|
+
// 创建KVManager实例
|
|
3267
|
+
kvManager = distributedKVStore.createKVManager(kvManagerConfig);
|
|
3268
|
+
// 继续创建获取数据库
|
|
3269
|
+
const options = {
|
|
3270
|
+
createIfMissing: true,
|
|
3271
|
+
encrypt: false,
|
|
3272
|
+
backup: false,
|
|
3273
|
+
autoSync: false,
|
|
3274
|
+
// kvStoreType不填时,默认创建多设备协同数据库
|
|
3275
|
+
kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
|
|
3276
|
+
// 多设备协同数据库:kvStoreType: distributedKVStore.KVStoreType.DEVICE_COLLABORATION,
|
|
3277
|
+
securityLevel: distributedKVStore.SecurityLevel.S1
|
|
3278
|
+
};
|
|
3279
|
+
const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
|
|
3280
|
+
kvStorePromise = new Promise(resolve => {
|
|
3281
|
+
kvManager.getKVStore(`${data.appInfo.uid}Store`, options, (err, store) => {
|
|
3282
|
+
if (err) {
|
|
3283
|
+
console.error(`Failed to get KVStore: Code:${err.code},message:${err.message}`);
|
|
3284
|
+
return;
|
|
3285
|
+
}
|
|
3286
|
+
kvStore = store;
|
|
3287
|
+
// 请确保获取到键值数据库实例后,再进行相关数据操作
|
|
3288
|
+
resolve();
|
|
3289
|
+
});
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
catch (e) {
|
|
3293
|
+
console.error(`Failed to create KVManager. Code:${e.code},message:${e.message}`);
|
|
3294
|
+
}
|
|
3295
|
+
return context;
|
|
3191
3296
|
});
|
|
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
3297
|
const storageSchema = {
|
|
3205
3298
|
key: 'String'
|
|
3206
3299
|
};
|
|
3207
|
-
function
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3300
|
+
function checkContextExist(api, isAsync = false) {
|
|
3301
|
+
if (!context) {
|
|
3302
|
+
const message = `${api} 调用失败,Taro 不支持过早地调用 ${api},请确保页面已经渲染完成再调用此 API`;
|
|
3303
|
+
if (isAsync) {
|
|
3304
|
+
return {
|
|
3305
|
+
isExist: false,
|
|
3306
|
+
error: Promise.reject(new Error(message))
|
|
3307
|
+
};
|
|
3211
3308
|
}
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
return
|
|
3309
|
+
else {
|
|
3310
|
+
console.warn(message);
|
|
3311
|
+
return {
|
|
3312
|
+
isExist: false,
|
|
3313
|
+
};
|
|
3215
3314
|
}
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3315
|
+
}
|
|
3316
|
+
return {
|
|
3317
|
+
isExist: true,
|
|
3318
|
+
};
|
|
3319
|
+
}
|
|
3320
|
+
function getStorage(options) {
|
|
3321
|
+
const name = 'getStorage';
|
|
3322
|
+
const { isExist, error } = checkContextExist(name, true);
|
|
3323
|
+
if (!isExist) {
|
|
3324
|
+
return error;
|
|
3325
|
+
}
|
|
3326
|
+
const { key, success, fail, complete } = options || {};
|
|
3327
|
+
const handle = new MethodHandler({ name, success, fail, complete });
|
|
3328
|
+
return new Promise((resolve, reject) => {
|
|
3329
|
+
kvStorePromise.then(() => {
|
|
3330
|
+
try {
|
|
3331
|
+
validateParams(name, options, storageSchema);
|
|
3221
3332
|
}
|
|
3222
|
-
|
|
3223
|
-
res
|
|
3224
|
-
|
|
3333
|
+
catch (error) {
|
|
3334
|
+
const res = { errMsg: error.message };
|
|
3335
|
+
return handle.fail(res, { resolve, reject });
|
|
3225
3336
|
}
|
|
3337
|
+
kvStore = kvStore;
|
|
3338
|
+
kvStore.get(key, (err, data) => {
|
|
3339
|
+
if (err) {
|
|
3340
|
+
handle.fail({ errMsg: `Failed to get data. Code:${err.code},message:${err.message}` }, { resolve, reject });
|
|
3341
|
+
return;
|
|
3342
|
+
}
|
|
3343
|
+
handle.success({ data }, { resolve, reject });
|
|
3344
|
+
});
|
|
3226
3345
|
});
|
|
3227
3346
|
});
|
|
3228
3347
|
}
|
|
3229
3348
|
function setStorage(options) {
|
|
3349
|
+
const name = 'setStorage';
|
|
3350
|
+
const { isExist, error } = checkContextExist(name, true);
|
|
3351
|
+
if (!isExist) {
|
|
3352
|
+
return error;
|
|
3353
|
+
}
|
|
3354
|
+
const { key, data, success, fail, complete } = options || {};
|
|
3355
|
+
const handle = new MethodHandler({ name, success, fail, complete });
|
|
3230
3356
|
return new Promise((resolve, reject) => {
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3357
|
+
kvStorePromise.then(() => {
|
|
3358
|
+
try {
|
|
3359
|
+
validateParams(name, options, storageSchema);
|
|
3360
|
+
}
|
|
3361
|
+
catch (error) {
|
|
3362
|
+
const res = { errMsg: error.message };
|
|
3363
|
+
return handle.fail(res, { resolve, reject });
|
|
3364
|
+
}
|
|
3365
|
+
kvStore = kvStore;
|
|
3366
|
+
kvStore.put(key, data, (err) => {
|
|
3367
|
+
if (err) {
|
|
3368
|
+
handle.fail({ errMsg: `Failed to put data. Code:${err.code},message:${err.message}` }, { resolve, reject });
|
|
3369
|
+
return;
|
|
3370
|
+
}
|
|
3371
|
+
handle.success({}, { resolve, reject });
|
|
3372
|
+
});
|
|
3373
|
+
});
|
|
3245
3374
|
});
|
|
3246
3375
|
}
|
|
3247
3376
|
function removeStorage(options) {
|
|
3377
|
+
const name = 'removeStorage';
|
|
3378
|
+
const { isExist, error } = checkContextExist(name, true);
|
|
3379
|
+
if (!isExist) {
|
|
3380
|
+
return error;
|
|
3381
|
+
}
|
|
3382
|
+
const { key, success, fail, complete } = options || {};
|
|
3383
|
+
const handle = new MethodHandler({ name, success, fail, complete });
|
|
3248
3384
|
return new Promise((resolve, reject) => {
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
}
|
|
3265
|
-
|
|
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
|
-
}));
|
|
3385
|
+
kvStorePromise.then(() => {
|
|
3386
|
+
try {
|
|
3387
|
+
validateParams(name, options, storageSchema);
|
|
3388
|
+
}
|
|
3389
|
+
catch (error) {
|
|
3390
|
+
const res = { errMsg: error.message };
|
|
3391
|
+
return handle.fail(res, { resolve, reject });
|
|
3392
|
+
}
|
|
3393
|
+
kvStore = kvStore;
|
|
3394
|
+
kvStore.delete(key, (err) => {
|
|
3395
|
+
if (err) {
|
|
3396
|
+
handle.fail({ errMsg: `Failed to delete data. Code:${err.code},message:${err.message}` }, { resolve, reject });
|
|
3397
|
+
return;
|
|
3398
|
+
}
|
|
3399
|
+
handle.success({}, { resolve, reject });
|
|
3400
|
+
});
|
|
3401
|
+
});
|
|
3273
3402
|
});
|
|
3274
3403
|
}
|
|
3275
3404
|
const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync');
|
|
3276
3405
|
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
3406
|
const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL');
|
|
3282
3407
|
const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL');
|
|
3283
3408
|
const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStorageSync');
|
|
3284
3409
|
const batchSetStorage = /* @__PURE__ */ temporarilyNotSupport('batchSetStorage');
|
|
3285
3410
|
const batchGetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchGetStorageSync');
|
|
3286
3411
|
const batchGetStorage = /* @__PURE__ */ temporarilyNotSupport('batchGetStorage');
|
|
3412
|
+
const clearStorage = temporarilyNotSupport('clearStorage');
|
|
3413
|
+
const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage');
|
|
3414
|
+
const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage');
|
|
3415
|
+
const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage');
|
|
3416
|
+
const removeStorageSync = temporarilyNotSupport('removeStorageSync', 'removeStorage');
|
|
3287
3417
|
|
|
3288
3418
|
class Animation {
|
|
3289
3419
|
constructor({ duration = 400, delay = 0, timingFunction = 'linear', transformOrigin = '50% 50% 0', unit = 'px' } = {}) {
|
|
@@ -3316,6 +3446,9 @@ class Animation {
|
|
|
3316
3446
|
transformOrigin,
|
|
3317
3447
|
rule: Object.assign({}, this.rule)
|
|
3318
3448
|
});
|
|
3449
|
+
if (this.rule.transform) {
|
|
3450
|
+
this.rule.transform = Object.assign({}, this.rule.transform);
|
|
3451
|
+
}
|
|
3319
3452
|
return this;
|
|
3320
3453
|
}
|
|
3321
3454
|
matrix(a, b, c, d, tx, ty) {
|
|
@@ -3327,75 +3460,120 @@ class Animation {
|
|
|
3327
3460
|
return this;
|
|
3328
3461
|
}
|
|
3329
3462
|
rotate(angle) {
|
|
3330
|
-
this.rule.
|
|
3463
|
+
if (!this.rule.transform) {
|
|
3464
|
+
this.rule.transform = {};
|
|
3465
|
+
}
|
|
3466
|
+
this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
|
|
3331
3467
|
return this;
|
|
3332
3468
|
}
|
|
3333
3469
|
rotate3d(x, y, z, angle) {
|
|
3334
|
-
this.rule.
|
|
3470
|
+
if (!this.rule.transform) {
|
|
3471
|
+
this.rule.transform = {};
|
|
3472
|
+
}
|
|
3473
|
+
this.rule.transform.Rotate = { x, y, z, angle };
|
|
3335
3474
|
return this;
|
|
3336
3475
|
}
|
|
3337
3476
|
rotateX(angle) {
|
|
3338
|
-
this.rule.
|
|
3477
|
+
if (!this.rule.transform) {
|
|
3478
|
+
this.rule.transform = {};
|
|
3479
|
+
}
|
|
3480
|
+
this.rule.transform.Rotate = { x: 1, y: 0, z: 0, angle };
|
|
3339
3481
|
return this;
|
|
3340
3482
|
}
|
|
3341
3483
|
rotateY(angle) {
|
|
3342
|
-
this.rule.
|
|
3484
|
+
if (!this.rule.transform) {
|
|
3485
|
+
this.rule.transform = {};
|
|
3486
|
+
}
|
|
3487
|
+
this.rule.transform.Rotate = { x: 0, y: 1, z: 0, angle };
|
|
3343
3488
|
return this;
|
|
3344
3489
|
}
|
|
3345
3490
|
rotateZ(angle) {
|
|
3346
|
-
this.rule.
|
|
3491
|
+
if (!this.rule.transform) {
|
|
3492
|
+
this.rule.transform = {};
|
|
3493
|
+
}
|
|
3494
|
+
this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
|
|
3347
3495
|
return this;
|
|
3348
3496
|
}
|
|
3349
3497
|
scale(sx, sy) {
|
|
3350
|
-
this.rule.
|
|
3498
|
+
if (!this.rule.transform) {
|
|
3499
|
+
this.rule.transform = {};
|
|
3500
|
+
}
|
|
3501
|
+
this.rule.transform.Scale = { x: sx, y: isUndefined(sy) ? sx : sy };
|
|
3351
3502
|
return this;
|
|
3352
3503
|
}
|
|
3353
3504
|
scale3d(sx, sy, sz) {
|
|
3354
|
-
this.rule.
|
|
3505
|
+
if (!this.rule.transform) {
|
|
3506
|
+
this.rule.transform = {};
|
|
3507
|
+
}
|
|
3508
|
+
this.rule.transform.Scale = { x: sx, y: sy, z: sz };
|
|
3355
3509
|
return this;
|
|
3356
3510
|
}
|
|
3357
3511
|
scaleX(scale) {
|
|
3358
|
-
this.rule.
|
|
3512
|
+
if (!this.rule.transform) {
|
|
3513
|
+
this.rule.transform = {};
|
|
3514
|
+
}
|
|
3515
|
+
this.rule.transform.Scale = { x: scale };
|
|
3359
3516
|
return this;
|
|
3360
3517
|
}
|
|
3361
3518
|
scaleY(scale) {
|
|
3362
|
-
this.rule.
|
|
3519
|
+
if (!this.rule.transform) {
|
|
3520
|
+
this.rule.transform = {};
|
|
3521
|
+
}
|
|
3522
|
+
this.rule.transform.Scale = { y: scale };
|
|
3363
3523
|
return this;
|
|
3364
3524
|
}
|
|
3365
3525
|
scaleZ(scale) {
|
|
3366
|
-
this.rule.
|
|
3526
|
+
if (!this.rule.transform) {
|
|
3527
|
+
this.rule.transform = {};
|
|
3528
|
+
}
|
|
3529
|
+
this.rule.transform.Scale = { z: scale };
|
|
3367
3530
|
return this;
|
|
3368
3531
|
}
|
|
3369
3532
|
skew(ax, ay) {
|
|
3370
|
-
|
|
3533
|
+
temporarilyNotSupport('animation.skew:' + `${ax}, ${ay}`)(ax, ay);
|
|
3371
3534
|
return this;
|
|
3372
3535
|
}
|
|
3373
3536
|
skewX(angle) {
|
|
3374
|
-
|
|
3537
|
+
temporarilyNotSupport('animation.skewX:' + angle)(angle);
|
|
3375
3538
|
return this;
|
|
3376
3539
|
}
|
|
3377
3540
|
skewY(angle) {
|
|
3378
|
-
|
|
3541
|
+
temporarilyNotSupport('animation.skewY:' + angle)(angle);
|
|
3379
3542
|
return this;
|
|
3380
3543
|
}
|
|
3381
3544
|
translate(tx, ty) {
|
|
3382
|
-
this.rule.
|
|
3545
|
+
if (!this.rule.transform) {
|
|
3546
|
+
this.rule.transform = {};
|
|
3547
|
+
}
|
|
3548
|
+
this.rule.transform.Translate = { x: tx, y: ty };
|
|
3383
3549
|
return this;
|
|
3384
3550
|
}
|
|
3385
3551
|
translate3d(tx, ty, tz) {
|
|
3386
|
-
this.rule.
|
|
3552
|
+
if (!this.rule.transform) {
|
|
3553
|
+
this.rule.transform = {};
|
|
3554
|
+
}
|
|
3555
|
+
this.rule.transform.Translate = { x: tx, y: ty, z: tz };
|
|
3387
3556
|
return this;
|
|
3388
3557
|
}
|
|
3389
3558
|
translateX(translation) {
|
|
3390
|
-
this.rule.
|
|
3559
|
+
if (!this.rule.transform) {
|
|
3560
|
+
this.rule.transform = {};
|
|
3561
|
+
}
|
|
3562
|
+
this.rule.transform.Translate = { x: translation };
|
|
3391
3563
|
return this;
|
|
3392
3564
|
}
|
|
3393
3565
|
translateY(translation) {
|
|
3394
|
-
this.rule.
|
|
3566
|
+
if (!this.rule.transform) {
|
|
3567
|
+
this.rule.transform = {};
|
|
3568
|
+
}
|
|
3569
|
+
this.rule.transform.Translate = { y: translation };
|
|
3395
3570
|
return this;
|
|
3396
3571
|
}
|
|
3397
3572
|
translateZ(translation) {
|
|
3398
|
-
this.rule.
|
|
3573
|
+
if (!this.rule.transform) {
|
|
3574
|
+
this.rule.transform = {};
|
|
3575
|
+
}
|
|
3576
|
+
this.rule.transform.Translate = { z: translation };
|
|
3399
3577
|
return this;
|
|
3400
3578
|
}
|
|
3401
3579
|
opacity(value) {
|
|
@@ -3407,15 +3585,15 @@ class Animation {
|
|
|
3407
3585
|
return this;
|
|
3408
3586
|
}
|
|
3409
3587
|
width(value) {
|
|
3410
|
-
this.rule.
|
|
3588
|
+
this.rule.width = value;
|
|
3411
3589
|
return this;
|
|
3412
3590
|
}
|
|
3413
3591
|
height(value) {
|
|
3414
|
-
this.rule.
|
|
3592
|
+
this.rule.height = value;
|
|
3415
3593
|
return this;
|
|
3416
3594
|
}
|
|
3417
3595
|
left(value) {
|
|
3418
|
-
|
|
3596
|
+
this.rule.left = value;
|
|
3419
3597
|
return this;
|
|
3420
3598
|
}
|
|
3421
3599
|
right(value) {
|
|
@@ -3423,7 +3601,7 @@ class Animation {
|
|
|
3423
3601
|
return this;
|
|
3424
3602
|
}
|
|
3425
3603
|
top(value) {
|
|
3426
|
-
|
|
3604
|
+
this.rule.top = value;
|
|
3427
3605
|
return this;
|
|
3428
3606
|
}
|
|
3429
3607
|
bottom(value) {
|
|
@@ -3442,7 +3620,8 @@ function setBackgroundColor(options) {
|
|
|
3442
3620
|
const handle = new MethodHandler({ name: 'setBackgroundColor', success, fail, complete });
|
|
3443
3621
|
return new Promise((resolve, reject) => {
|
|
3444
3622
|
eventCenter.trigger('__taroPageStyle', {
|
|
3445
|
-
backgroundColor: options.
|
|
3623
|
+
backgroundColor: options.backgroundColorBottom || options.backgroundColor,
|
|
3624
|
+
backgroundColorContext: options.backgroundColorTop || options.backgroundColor
|
|
3446
3625
|
});
|
|
3447
3626
|
return handle.success({}, { resolve, reject });
|
|
3448
3627
|
});
|
|
@@ -3481,10 +3660,11 @@ function showToast(options) {
|
|
|
3481
3660
|
const res = { errMsg: error.message };
|
|
3482
3661
|
return callAsyncFail(reject, res, options);
|
|
3483
3662
|
}
|
|
3484
|
-
|
|
3663
|
+
promptAction.showToast({
|
|
3485
3664
|
message: options.title,
|
|
3486
3665
|
duration: options.duration,
|
|
3487
|
-
bottom: options.bottom
|
|
3666
|
+
bottom: options.bottom,
|
|
3667
|
+
showMode: 1 // 设置弹窗显示模式,显示在应用之上。
|
|
3488
3668
|
});
|
|
3489
3669
|
callAsyncSuccess(resolve, resCallback('showToast'), options);
|
|
3490
3670
|
});
|
|
@@ -3514,25 +3694,24 @@ function showModal(options) {
|
|
|
3514
3694
|
color: confirmColor
|
|
3515
3695
|
});
|
|
3516
3696
|
}
|
|
3517
|
-
return new Promise(resolve => {
|
|
3697
|
+
return new Promise((resolve, reject) => {
|
|
3518
3698
|
const modalOptions = {
|
|
3519
3699
|
title,
|
|
3520
3700
|
message: content,
|
|
3521
3701
|
buttons: buttons,
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
}
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
},
|
|
3530
|
-
// 鸿蒙没有失败方法,只有取消
|
|
3531
|
-
cancel: (_) => {
|
|
3702
|
+
};
|
|
3703
|
+
promptAction.showDialog(modalOptions, (error, data) => {
|
|
3704
|
+
if (error) {
|
|
3705
|
+
const res = { errMsg: error };
|
|
3706
|
+
callAsyncFail(reject, res, options);
|
|
3707
|
+
}
|
|
3708
|
+
if (data.index === 0 && showCancel) {
|
|
3532
3709
|
callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: false, cancel: true }), options);
|
|
3533
3710
|
}
|
|
3534
|
-
|
|
3535
|
-
|
|
3711
|
+
else {
|
|
3712
|
+
callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: true, cancel: false, content: null }), options);
|
|
3713
|
+
}
|
|
3714
|
+
});
|
|
3536
3715
|
});
|
|
3537
3716
|
}
|
|
3538
3717
|
const showActionSheetSchema = {
|
|
@@ -3563,28 +3742,18 @@ function showActionSheet(options) {
|
|
|
3563
3742
|
});
|
|
3564
3743
|
const actionSheetOptions = {
|
|
3565
3744
|
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
|
-
}
|
|
3745
|
+
buttons
|
|
3574
3746
|
};
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
message: '关闭中',
|
|
3582
|
-
duration: 10,
|
|
3583
|
-
bottom: '9999px'
|
|
3747
|
+
promptAction.showActionMenu(actionSheetOptions, (error, data) => {
|
|
3748
|
+
var _a;
|
|
3749
|
+
if (error) {
|
|
3750
|
+
callAsyncFail(reject, Object.assign(Object.assign({}, data), { errMsg: (_a = data.errMsg) === null || _a === void 0 ? void 0 : _a.replace('showActionMenu', 'showActionSheet') }), options);
|
|
3751
|
+
}
|
|
3752
|
+
callAsyncSuccess(resolve, Object.assign(Object.assign({}, data), resCallback('showActionSheet')), options);
|
|
3584
3753
|
});
|
|
3585
|
-
callAsyncSuccess(resolve, resCallback('hideToast'), options);
|
|
3586
3754
|
});
|
|
3587
3755
|
}
|
|
3756
|
+
const hideToast = /* @__PURE__ */ temporarilyNotSupport('hideToast');
|
|
3588
3757
|
const showLoading = temporarilyNotSupport('showLoading');
|
|
3589
3758
|
const hideLoading = temporarilyNotSupport('hideLoading');
|
|
3590
3759
|
const enableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('enableAlertBeforeUnload');
|
|
@@ -3605,7 +3774,7 @@ const setNavigationBarTitle = function (options) {
|
|
|
3605
3774
|
};
|
|
3606
3775
|
const setNavigationBarColor = function (options) {
|
|
3607
3776
|
const { success, fail, complete } = options || {};
|
|
3608
|
-
const handle = new MethodHandler({ name: '
|
|
3777
|
+
const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete });
|
|
3609
3778
|
return new Promise((resolve, reject) => {
|
|
3610
3779
|
eventCenter.trigger('__taroNavigationStyle', {
|
|
3611
3780
|
animation: options.animation,
|
|
@@ -3700,7 +3869,7 @@ const pageScrollTo = (options) => {
|
|
|
3700
3869
|
const taro = Current.taro;
|
|
3701
3870
|
const page = taro.getCurrentInstance().page;
|
|
3702
3871
|
let scrollValue = -1;
|
|
3703
|
-
let scroller = page.scroller;
|
|
3872
|
+
let scroller = getPageScrollerOrNode(page.scroller, page);
|
|
3704
3873
|
const currentPageNode = getPageScrollerOrNode(page.node, page);
|
|
3705
3874
|
if (scrollTop || typeof scrollTop === 'number') {
|
|
3706
3875
|
scrollValue = scrollTop;
|
|
@@ -3723,7 +3892,7 @@ const pageScrollTo = (options) => {
|
|
|
3723
3892
|
scroller = getPageScrollerOrNode(scroller, page);
|
|
3724
3893
|
const { yOffset } = scroller.currentOffset();
|
|
3725
3894
|
if (areaInfo) {
|
|
3726
|
-
scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper(offsetTop, 'px', true);
|
|
3895
|
+
scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper$1(offsetTop, 'px', true);
|
|
3727
3896
|
}
|
|
3728
3897
|
}
|
|
3729
3898
|
const { xOffset } = scroller.currentOffset();
|
|
@@ -3908,19 +4077,16 @@ class IntersectionObserver {
|
|
|
3908
4077
|
};
|
|
3909
4078
|
const taro = Current.taro;
|
|
3910
4079
|
const page = taro.getCurrentInstance().page;
|
|
3911
|
-
|
|
3912
|
-
this._component = component || currentPage;
|
|
4080
|
+
this._component = component || getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
|
|
3913
4081
|
Object.assign(this._options, options);
|
|
3914
4082
|
}
|
|
3915
4083
|
disconnect() {
|
|
3916
|
-
|
|
3917
|
-
if (this._observerNodes) {
|
|
4084
|
+
if (this._observerNodes && this._component) {
|
|
3918
4085
|
if (this._observerNodes instanceof Array) {
|
|
3919
4086
|
this._observerNodes.forEach((n) => {
|
|
3920
|
-
var _a;
|
|
3921
4087
|
disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME);
|
|
3922
4088
|
// @ts-ignore
|
|
3923
|
-
|
|
4089
|
+
n._nodeInfo.thresholds = null;
|
|
3924
4090
|
});
|
|
3925
4091
|
}
|
|
3926
4092
|
else {
|
|
@@ -3928,35 +4094,40 @@ class IntersectionObserver {
|
|
|
3928
4094
|
// @ts-ignore
|
|
3929
4095
|
if (this._observerNodes._nodeInfo) {
|
|
3930
4096
|
// @ts-ignore
|
|
3931
|
-
|
|
4097
|
+
this._observerNodes._nodeInfo.thresholds = null;
|
|
3932
4098
|
}
|
|
3933
4099
|
}
|
|
3934
4100
|
}
|
|
3935
4101
|
}
|
|
3936
4102
|
observe(targetSelector, callback) {
|
|
3937
|
-
|
|
4103
|
+
if (!this._component)
|
|
4104
|
+
return;
|
|
3938
4105
|
const { observeAll, thresholds } = this._options;
|
|
3939
4106
|
const node = findChildNodeWithDFS(this._component, targetSelector, observeAll);
|
|
3940
4107
|
this._observerNodes = node;
|
|
3941
4108
|
if (node) {
|
|
3942
4109
|
if (node instanceof Array) {
|
|
3943
4110
|
node.forEach(n => {
|
|
3944
|
-
var _a;
|
|
3945
4111
|
// @ts-ignore
|
|
3946
|
-
|
|
4112
|
+
n._nodeInfo.thresholds = thresholds;
|
|
3947
4113
|
setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
|
|
3948
|
-
callback(this.handleResult(isVisible, currentRatio));
|
|
4114
|
+
callback(this.handleResult(isVisible, currentRatio, n));
|
|
3949
4115
|
});
|
|
3950
4116
|
});
|
|
3951
4117
|
}
|
|
3952
4118
|
else {
|
|
3953
4119
|
// @ts-ignore
|
|
3954
|
-
|
|
4120
|
+
node._nodeInfo.thresholds = thresholds;
|
|
3955
4121
|
setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
|
|
3956
|
-
callback(this.handleResult(isVisible, currentRatio));
|
|
4122
|
+
callback(this.handleResult(isVisible, currentRatio, node));
|
|
3957
4123
|
});
|
|
3958
4124
|
}
|
|
3959
4125
|
}
|
|
4126
|
+
else {
|
|
4127
|
+
callback({
|
|
4128
|
+
errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
|
|
4129
|
+
});
|
|
4130
|
+
}
|
|
3960
4131
|
}
|
|
3961
4132
|
relativeTo() {
|
|
3962
4133
|
temporarilyNotSupport('relativeTo')();
|
|
@@ -3967,8 +4138,10 @@ class IntersectionObserver {
|
|
|
3967
4138
|
return this;
|
|
3968
4139
|
}
|
|
3969
4140
|
// @ts-ignore
|
|
3970
|
-
handleResult(isVisible, currentRatio) {
|
|
4141
|
+
handleResult(isVisible, currentRatio, node) {
|
|
3971
4142
|
const result = {
|
|
4143
|
+
id: node.id,
|
|
4144
|
+
dataset: node.dataset,
|
|
3972
4145
|
intersectionRatio: currentRatio,
|
|
3973
4146
|
// TODO 未做,等待能拿到element的info信息
|
|
3974
4147
|
boundingClientRect: {
|
|
@@ -4176,9 +4349,12 @@ function filter(fields, dom) {
|
|
|
4176
4349
|
}
|
|
4177
4350
|
function querySelector(selector, selectAll) {
|
|
4178
4351
|
if (typeof selector === 'string') {
|
|
4179
|
-
return
|
|
4352
|
+
return selector.split(',').reduce((prev, current) => {
|
|
4353
|
+
const item = current.trim();
|
|
4354
|
+
return prev.concat(parseHandler(item, selectAll));
|
|
4355
|
+
}, []);
|
|
4180
4356
|
}
|
|
4181
|
-
return
|
|
4357
|
+
return [];
|
|
4182
4358
|
}
|
|
4183
4359
|
function queryBat(queue, cb) {
|
|
4184
4360
|
const result = [];
|
|
@@ -4189,19 +4365,29 @@ function queryBat(queue, cb) {
|
|
|
4189
4365
|
return null;
|
|
4190
4366
|
arr = [];
|
|
4191
4367
|
traversalDFSDom(element);
|
|
4192
|
-
queue.forEach(item => {
|
|
4368
|
+
queue.forEach((item) => {
|
|
4193
4369
|
const { selector, single, fields } = item;
|
|
4194
|
-
|
|
4195
|
-
|
|
4370
|
+
if (single) {
|
|
4371
|
+
const dom = querySelector(selector, !single)[0];
|
|
4196
4372
|
// eslint-disable-next-line no-async-promise-executor
|
|
4197
|
-
|
|
4373
|
+
result.push(new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
4198
4374
|
yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
|
|
4199
4375
|
resolve(filter(fields, dom));
|
|
4376
|
+
})));
|
|
4377
|
+
}
|
|
4378
|
+
else {
|
|
4379
|
+
const nodeList = querySelector(selector, !single);
|
|
4380
|
+
result.push(nodeList.map(dom => {
|
|
4381
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
4382
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
4383
|
+
yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
|
|
4384
|
+
resolve(filter(fields, dom));
|
|
4385
|
+
}));
|
|
4200
4386
|
}));
|
|
4201
|
-
}
|
|
4387
|
+
}
|
|
4202
4388
|
});
|
|
4203
4389
|
Promise.all(result.map(item => {
|
|
4204
|
-
return Promise.all(item);
|
|
4390
|
+
return item instanceof Array ? Promise.all(item) : item;
|
|
4205
4391
|
})).then(data => {
|
|
4206
4392
|
cb(data);
|
|
4207
4393
|
});
|
|
@@ -4280,6 +4466,7 @@ var apis = /*#__PURE__*/Object.freeze({
|
|
|
4280
4466
|
ENV_TYPE: ENV_TYPE,
|
|
4281
4467
|
Events: Events,
|
|
4282
4468
|
History: History,
|
|
4469
|
+
IntersectionObserver: IntersectionObserver,
|
|
4283
4470
|
addCard: addCard,
|
|
4284
4471
|
addFileToFavorites: addFileToFavorites,
|
|
4285
4472
|
addPhoneCalendar: addPhoneCalendar,
|
|
@@ -4669,7 +4856,7 @@ var apis = /*#__PURE__*/Object.freeze({
|
|
|
4669
4856
|
writeBLECharacteristicValue: writeBLECharacteristicValue
|
|
4670
4857
|
});
|
|
4671
4858
|
|
|
4672
|
-
Object.assign({}, apis);
|
|
4859
|
+
const taro = Object.assign({}, apis);
|
|
4673
4860
|
const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin');
|
|
4674
4861
|
function initNativeApi(taro) {
|
|
4675
4862
|
Current.taro = taro;
|
|
@@ -4693,7 +4880,7 @@ const defaultBaseFontSize = 20;
|
|
|
4693
4880
|
const defaultUnitPrecision = 5;
|
|
4694
4881
|
const defaultTargetUnit = 'vp';
|
|
4695
4882
|
function getApp$1() {
|
|
4696
|
-
return Current.app;
|
|
4883
|
+
return Current.app || {};
|
|
4697
4884
|
}
|
|
4698
4885
|
function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
|
|
4699
4886
|
const taro = Current.taro;
|
|
@@ -4707,19 +4894,56 @@ function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defau
|
|
|
4707
4894
|
config.unitPrecision = unitPrecision;
|
|
4708
4895
|
}
|
|
4709
4896
|
}
|
|
4710
|
-
_display.getDefaultDisplaySync();
|
|
4897
|
+
const display = _display.getDefaultDisplaySync();
|
|
4898
|
+
let displayWidth = display.width;
|
|
4899
|
+
let ratioCache = false;
|
|
4900
|
+
let designWidthFunc;
|
|
4901
|
+
let designWidth = defaultDesignWidth;
|
|
4902
|
+
function getRatio(value) {
|
|
4903
|
+
var _a;
|
|
4904
|
+
// Note: 提前调用 display 可能无法获取正确值
|
|
4905
|
+
if (ratioCache === false || displayWidth !== display.width) {
|
|
4906
|
+
const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
|
|
4907
|
+
if (!isFunction(designWidthFunc)) {
|
|
4908
|
+
designWidthFunc = isFunction(config.designWidth)
|
|
4909
|
+
? config.designWidth
|
|
4910
|
+
: () => config.designWidth;
|
|
4911
|
+
designWidth = designWidthFunc(value) || defaultDesignWidth;
|
|
4912
|
+
}
|
|
4913
|
+
displayWidth = display.width;
|
|
4914
|
+
ratioCache = Math.min(display.width, display.height) / designWidth;
|
|
4915
|
+
}
|
|
4916
|
+
return ratioCache;
|
|
4917
|
+
}
|
|
4918
|
+
// Note: 设置为 style 单位时会自动完成设计稿转换,设计开发者调用 API 时也许抹平差异,例如 pageScrollTo[option.offsetTop]
|
|
4919
|
+
function pxTransformHelper(size, unit, isNumber = false) {
|
|
4920
|
+
var _a;
|
|
4921
|
+
const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
|
|
4922
|
+
const targetUnit = unit || config.targetUnit || defaultTargetUnit;
|
|
4923
|
+
if (targetUnit === 'PX') {
|
|
4924
|
+
return px2vp(size * display.scaledDensity) + 'vp';
|
|
4925
|
+
}
|
|
4926
|
+
const ratio = getRatio(size);
|
|
4927
|
+
let val = size * ratio;
|
|
4928
|
+
switch (targetUnit) {
|
|
4929
|
+
case 'vp':
|
|
4930
|
+
// Note: 在应用创建前调用无效
|
|
4931
|
+
val = px2vp(val);
|
|
4932
|
+
break;
|
|
4933
|
+
}
|
|
4934
|
+
return isNumber ? val : val + targetUnit;
|
|
4935
|
+
}
|
|
4711
4936
|
function pxTransform(size) {
|
|
4712
4937
|
var _a;
|
|
4713
4938
|
const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
|
|
4714
4939
|
const targetUnit = config.targetUnit || defaultTargetUnit;
|
|
4715
|
-
|
|
4940
|
+
const val = size;
|
|
4716
4941
|
switch (targetUnit) {
|
|
4717
4942
|
case 'vp':
|
|
4718
|
-
|
|
4719
|
-
break;
|
|
4943
|
+
return pxTransformHelper(size, 'px');
|
|
4720
4944
|
// NOTE: 鸿蒙环境下 style 会自动完成设计稿转换,无需在方法内二次调整
|
|
4721
4945
|
}
|
|
4722
|
-
return val +
|
|
4946
|
+
return val + targetUnit;
|
|
4723
4947
|
}
|
|
4724
4948
|
function canIUseWebp() {
|
|
4725
4949
|
return true;
|
|
@@ -4733,6 +4957,7 @@ function getAppInfo() {
|
|
|
4733
4957
|
designWidth: config === null || config === void 0 ? void 0 : config.designWidth,
|
|
4734
4958
|
};
|
|
4735
4959
|
}
|
|
4960
|
+
initNativeApi(taro);
|
|
4736
4961
|
|
|
4737
4962
|
const components = {
|
|
4738
4963
|
Checkbox: {
|