@tarojs/plugin-platform-harmony-ets 4.0.0-beta.5 → 4.0.0-beta.50
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/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +4 -0
- 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 +148 -80
- package/dist/apis/ui/animation/animation.ts +71 -28
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +40 -49
- package/dist/apis/ui/navigation-bar/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 +18 -9
- 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 +27 -14
- package/dist/components-harmony-ets/index.ets +85 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +41 -40
- package/dist/components-harmony-ets/label.ets +69 -42
- package/dist/components-harmony-ets/movableArea.ets +126 -0
- package/dist/components-harmony-ets/movableView.ets +73 -0
- package/dist/components-harmony-ets/navigationBar.ets +25 -0
- package/dist/components-harmony-ets/pageMeta.ets +28 -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/scrollView.ets +61 -57
- package/dist/components-harmony-ets/slider.ets +15 -14
- package/dist/components-harmony-ets/style.ets +390 -130
- package/dist/components-harmony-ets/swiper.ets +38 -20
- package/dist/components-harmony-ets/switch.ets +30 -28
- package/dist/components-harmony-ets/{index.ts → tag.ts} +2 -0
- package/dist/components-harmony-ets/text.ets +121 -51
- package/dist/components-harmony-ets/textArea.ets +35 -34
- 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 +17 -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 +50 -51
- package/dist/components-harmony-ets/utils/styles.ets +170 -93
- package/dist/components-harmony-ets/video.ets +34 -20
- 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 +82 -39
- 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 +31 -13
- package/dist/runtime-ets/dom/cssNesting.ts +393 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +25 -39
- 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 +317 -51
- package/dist/runtime-ets/dom/element/form.ts +23 -26
- package/dist/runtime-ets/dom/element/index.ts +24 -2
- 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 +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +12 -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 -3
- package/dist/runtime-ets/dom/element/webView.ts +11 -3
- 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 +46 -28
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +334 -230
- package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
- package/dist/runtime-ets/dom/stylesheet/type.ts +40 -9
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +66 -11
- package/dist/runtime-ets/utils/info.ts +1 -1
- package/dist/runtime-framework/react/app.ts +7 -2
- 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 +65 -20
- 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 +399 -188
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +399 -188
- 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,49 @@ 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
|
+
// @ts-ignore
|
|
283
|
+
display$1.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} } = {}) => {
|
|
284
|
+
var _a, _b, _c, _d, _e, _f;
|
|
285
|
+
if (err === null || err === void 0 ? void 0 : err.code) {
|
|
286
|
+
console.error('Failed to get cutout info', JSON.stringify(err));
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const top = Math.max(...boundingRects.map(rect => rect.top + rect.height), ((_a = waterfallDisplayAreaRects.top) === null || _a === void 0 ? void 0 : _a.top) + ((_b = waterfallDisplayAreaRects.top) === null || _b === void 0 ? void 0 : _b.height), statusBarHeight);
|
|
290
|
+
const bottom = Math.min(display$1.height - ((_c = waterfallDisplayAreaRects.bottom) === null || _c === void 0 ? void 0 : _c.top), navigationIndicatorRect === null || navigationIndicatorRect === void 0 ? void 0 : navigationIndicatorRect.top);
|
|
291
|
+
const left = ((_d = waterfallDisplayAreaRects.left) === null || _d === void 0 ? void 0 : _d.left) + ((_e = waterfallDisplayAreaRects.left) === null || _e === void 0 ? void 0 : _e.width);
|
|
292
|
+
const right = display$1.width - ((_f = waterfallDisplayAreaRects.right) === null || _f === void 0 ? void 0 : _f.left);
|
|
293
|
+
safeArea = {
|
|
294
|
+
top,
|
|
295
|
+
bottom,
|
|
296
|
+
left,
|
|
297
|
+
right,
|
|
298
|
+
height: bottom - top,
|
|
299
|
+
width: right - left,
|
|
300
|
+
};
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
catch (e) {
|
|
304
|
+
console.error('Failed to get display', e);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
276
307
|
});
|
|
277
308
|
/* 同步版本 */
|
|
278
309
|
const getSystemInfoSync = function () {
|
|
310
|
+
var _a, _b;
|
|
279
311
|
const res = {};
|
|
280
312
|
res.SDKVersion = deviceInfo && deviceInfo.sdkApiVersion; // 客户端基础库版本 string
|
|
281
313
|
res.albumAuthorized = false; // 允许使用相册的开关(仅 iOS 有效) boolean
|
|
@@ -285,7 +317,7 @@ const getSystemInfoSync = function () {
|
|
|
285
317
|
res.cameraAuthorized = null; // 允许使用摄像头的开关 boolean
|
|
286
318
|
res.enableDebug = null; // 是否已打开调试 boolean
|
|
287
319
|
res.fontSizeSetting = null; // 用户字体大小(单位px) number
|
|
288
|
-
res.language = i18n
|
|
320
|
+
res.language = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.getSystemLanguage) === null || _a === void 0 ? void 0 : _a.call(i18n); // string
|
|
289
321
|
res.locationAuthorized = null; // 定位的开关 boolean
|
|
290
322
|
res.locationEnabled = null; // 地理位置的系统开关 boolean
|
|
291
323
|
res.microphoneAuthorized = null; // 麦克风的开关 boolean
|
|
@@ -296,17 +328,18 @@ const getSystemInfoSync = function () {
|
|
|
296
328
|
res.notificationSoundAuthorized = false; // 通知带有声音的开关(仅 iOS 有效)boolean
|
|
297
329
|
res.phoneCalendarAuthorized = null; // 使用日历的开关 boolean
|
|
298
330
|
res.wifiEnabled = false; // Wi-Fi 的系统开关 boolean
|
|
299
|
-
res.pixelRatio =
|
|
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.
|
|
331
|
+
res.pixelRatio = display$1 && display$1.densityPixels; // 设备像素比,number
|
|
332
|
+
res.platform = 'harmony'; // 客户端平台 string
|
|
333
|
+
res.safeArea = safeArea; // 在竖屏正方向下的安全区域 General.SafeAreaResult
|
|
334
|
+
res.screenHeight = display$1 === null || display$1 === void 0 ? void 0 : display$1.height; // 屏幕高度,单位px number
|
|
335
|
+
res.screenWidth = display$1 === null || display$1 === void 0 ? void 0 : display$1.width; // 屏幕宽度,单位px number
|
|
336
|
+
res.statusBarHeight = statusBarHeight; // 状态栏的高度,单位px number
|
|
337
|
+
res.system = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.osFullName; // 操作系统及版本 string
|
|
338
|
+
// Note: 更新配置时才能记录
|
|
339
|
+
res.theme = ((_b = AppStorage.get('__TARO_APP_CONFIG')) === null || _b === void 0 ? void 0 : _b.colorMode) === ConfigurationConstant.ColorMode.COLOR_MODE_DARK ? 'dark' : 'light'; // 系统当前主题,取值为light或dark 'light' | 'dark'
|
|
340
|
+
res.windowHeight = windowRect === null || windowRect === void 0 ? void 0 : windowRect.height; // 可使用窗口高度,单位px number
|
|
341
|
+
res.windowWidth = windowRect === null || windowRect === void 0 ? void 0 : windowRect.width; // 可使用窗口宽度,单位px number
|
|
342
|
+
res.version = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.displayVersion; // 版本号 string
|
|
310
343
|
return res;
|
|
311
344
|
};
|
|
312
345
|
/* 异步版本 */
|
|
@@ -412,7 +445,13 @@ const base64ToArrayBuffer = /* @__PURE__ */ temporarilyNotSupport('base64ToArray
|
|
|
412
445
|
/** 创建离屏 canvas 实例 */
|
|
413
446
|
const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
|
|
414
447
|
/** 创建 canvas 的绘图上下文 CanvasContext 对象 */
|
|
415
|
-
|
|
448
|
+
|
|
449
|
+
const createCanvasContext = (canvasId) => {
|
|
450
|
+
const dom = eventSource.get(`canvasId-${canvasId}`);
|
|
451
|
+
// return dom as TaroCanvasElement
|
|
452
|
+
if (dom)
|
|
453
|
+
return dom.context;
|
|
454
|
+
};
|
|
416
455
|
/** 把当前画布指定区域的内容导出生成指定大小的图片 */
|
|
417
456
|
const canvasToTempFilePath = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
|
|
418
457
|
/** 将像素数据绘制到画布 */
|
|
@@ -617,6 +656,7 @@ const setClipboardData = function (options) {
|
|
|
617
656
|
callAsyncFail(reject, res, options);
|
|
618
657
|
}
|
|
619
658
|
else {
|
|
659
|
+
promptAction.showToast({ message: '内容已复制' });
|
|
620
660
|
return handle.success({
|
|
621
661
|
data,
|
|
622
662
|
}, { resolve, reject });
|
|
@@ -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
|
-
|
|
2616
|
-
|
|
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,113 +3229,172 @@ const getBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('getBackgro
|
|
|
3177
3229
|
// 周期性更新
|
|
3178
3230
|
const createCacheManager = /* @__PURE__ */ temporarilyNotSupport('createCacheManager');
|
|
3179
3231
|
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
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 kvManager;
|
|
3238
|
+
let kvStore;
|
|
3239
|
+
let kvStorePromise;
|
|
3240
|
+
Current.contextPromise.then((ctx) => {
|
|
3241
|
+
context = ctx;
|
|
3242
|
+
const kvManagerConfig = {
|
|
3243
|
+
context: context,
|
|
3244
|
+
bundleName: 'com.example.taro'
|
|
3245
|
+
};
|
|
3246
|
+
try {
|
|
3247
|
+
// 创建KVManager实例
|
|
3248
|
+
kvManager = distributedKVStore.createKVManager(kvManagerConfig);
|
|
3249
|
+
// 继续创建获取数据库
|
|
3250
|
+
const options = {
|
|
3251
|
+
createIfMissing: true,
|
|
3252
|
+
encrypt: false,
|
|
3253
|
+
backup: false,
|
|
3254
|
+
autoSync: false,
|
|
3255
|
+
// kvStoreType不填时,默认创建多设备协同数据库
|
|
3256
|
+
kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
|
|
3257
|
+
// 多设备协同数据库:kvStoreType: distributedKVStore.KVStoreType.DEVICE_COLLABORATION,
|
|
3258
|
+
securityLevel: distributedKVStore.SecurityLevel.S1
|
|
3259
|
+
};
|
|
3260
|
+
const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
|
|
3261
|
+
kvStorePromise = new Promise(resolve => {
|
|
3262
|
+
kvManager.getKVStore(`${data.appInfo.uid}Store`, options, (err, store) => {
|
|
3263
|
+
if (err) {
|
|
3264
|
+
console.error(`Failed to get KVStore: Code:${err.code},message:${err.message}`);
|
|
3265
|
+
return;
|
|
3266
|
+
}
|
|
3267
|
+
kvStore = store;
|
|
3268
|
+
// 请确保获取到键值数据库实例后,再进行相关数据操作
|
|
3269
|
+
resolve();
|
|
3270
|
+
});
|
|
3271
|
+
});
|
|
3272
|
+
}
|
|
3273
|
+
catch (e) {
|
|
3274
|
+
console.error(`Failed to create KVManager. Code:${e.code},message:${e.message}`);
|
|
3275
|
+
}
|
|
3276
|
+
return context;
|
|
3191
3277
|
});
|
|
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
3278
|
const storageSchema = {
|
|
3205
3279
|
key: 'String'
|
|
3206
3280
|
};
|
|
3207
|
-
function
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3281
|
+
function checkContextExist(api, isAsync = false) {
|
|
3282
|
+
if (!context) {
|
|
3283
|
+
const message = `${api} 调用失败,Taro 不支持过早地调用 ${api},请确保页面已经渲染完成再调用此 API`;
|
|
3284
|
+
if (isAsync) {
|
|
3285
|
+
return {
|
|
3286
|
+
isExist: false,
|
|
3287
|
+
error: Promise.reject(new Error(message))
|
|
3288
|
+
};
|
|
3211
3289
|
}
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
return
|
|
3290
|
+
else {
|
|
3291
|
+
console.warn(message);
|
|
3292
|
+
return {
|
|
3293
|
+
isExist: false,
|
|
3294
|
+
};
|
|
3215
3295
|
}
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3296
|
+
}
|
|
3297
|
+
return {
|
|
3298
|
+
isExist: true,
|
|
3299
|
+
};
|
|
3300
|
+
}
|
|
3301
|
+
function getStorage(options) {
|
|
3302
|
+
const name = 'getStorage';
|
|
3303
|
+
const { isExist, error } = checkContextExist(name, true);
|
|
3304
|
+
if (!isExist) {
|
|
3305
|
+
return error;
|
|
3306
|
+
}
|
|
3307
|
+
const { key, success, fail, complete } = options || {};
|
|
3308
|
+
const handle = new MethodHandler({ name, success, fail, complete });
|
|
3309
|
+
return new Promise((resolve, reject) => {
|
|
3310
|
+
kvStorePromise.then(() => {
|
|
3311
|
+
try {
|
|
3312
|
+
validateParams(name, options, storageSchema);
|
|
3221
3313
|
}
|
|
3222
|
-
|
|
3223
|
-
res
|
|
3224
|
-
|
|
3314
|
+
catch (error) {
|
|
3315
|
+
const res = { errMsg: error.message };
|
|
3316
|
+
return handle.fail(res, { resolve, reject });
|
|
3225
3317
|
}
|
|
3318
|
+
kvStore = kvStore;
|
|
3319
|
+
kvStore.get(key, (err, data) => {
|
|
3320
|
+
if (err) {
|
|
3321
|
+
handle.fail({ errMsg: `Failed to get data. Code:${err.code},message:${err.message}` }, { resolve, reject });
|
|
3322
|
+
return;
|
|
3323
|
+
}
|
|
3324
|
+
handle.success({ data }, { resolve, reject });
|
|
3325
|
+
});
|
|
3226
3326
|
});
|
|
3227
3327
|
});
|
|
3228
3328
|
}
|
|
3229
3329
|
function setStorage(options) {
|
|
3330
|
+
const name = 'setStorage';
|
|
3331
|
+
const { isExist, error } = checkContextExist(name, true);
|
|
3332
|
+
if (!isExist) {
|
|
3333
|
+
return error;
|
|
3334
|
+
}
|
|
3335
|
+
const { key, data, success, fail, complete } = options || {};
|
|
3336
|
+
const handle = new MethodHandler({ name, success, fail, complete });
|
|
3230
3337
|
return new Promise((resolve, reject) => {
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3338
|
+
kvStorePromise.then(() => {
|
|
3339
|
+
try {
|
|
3340
|
+
validateParams(name, options, storageSchema);
|
|
3341
|
+
}
|
|
3342
|
+
catch (error) {
|
|
3343
|
+
const res = { errMsg: error.message };
|
|
3344
|
+
return handle.fail(res, { resolve, reject });
|
|
3345
|
+
}
|
|
3346
|
+
kvStore = kvStore;
|
|
3347
|
+
kvStore.put(key, data, (err) => {
|
|
3348
|
+
if (err) {
|
|
3349
|
+
handle.fail({ errMsg: `Failed to put data. Code:${err.code},message:${err.message}` }, { resolve, reject });
|
|
3350
|
+
return;
|
|
3351
|
+
}
|
|
3352
|
+
handle.success({}, { resolve, reject });
|
|
3353
|
+
});
|
|
3354
|
+
});
|
|
3245
3355
|
});
|
|
3246
3356
|
}
|
|
3247
3357
|
function removeStorage(options) {
|
|
3358
|
+
const name = 'removeStorage';
|
|
3359
|
+
const { isExist, error } = checkContextExist(name, true);
|
|
3360
|
+
if (!isExist) {
|
|
3361
|
+
return error;
|
|
3362
|
+
}
|
|
3363
|
+
const { key, success, fail, complete } = options || {};
|
|
3364
|
+
const handle = new MethodHandler({ name, success, fail, complete });
|
|
3248
3365
|
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
|
-
}));
|
|
3366
|
+
kvStorePromise.then(() => {
|
|
3367
|
+
try {
|
|
3368
|
+
validateParams(name, options, storageSchema);
|
|
3369
|
+
}
|
|
3370
|
+
catch (error) {
|
|
3371
|
+
const res = { errMsg: error.message };
|
|
3372
|
+
return handle.fail(res, { resolve, reject });
|
|
3373
|
+
}
|
|
3374
|
+
kvStore = kvStore;
|
|
3375
|
+
kvStore.delete(key, (err) => {
|
|
3376
|
+
if (err) {
|
|
3377
|
+
handle.fail({ errMsg: `Failed to delete data. Code:${err.code},message:${err.message}` }, { resolve, reject });
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
handle.success({}, { resolve, reject });
|
|
3381
|
+
});
|
|
3382
|
+
});
|
|
3273
3383
|
});
|
|
3274
3384
|
}
|
|
3275
3385
|
const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync');
|
|
3276
3386
|
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
3387
|
const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL');
|
|
3282
3388
|
const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL');
|
|
3283
3389
|
const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStorageSync');
|
|
3284
3390
|
const batchSetStorage = /* @__PURE__ */ temporarilyNotSupport('batchSetStorage');
|
|
3285
3391
|
const batchGetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchGetStorageSync');
|
|
3286
3392
|
const batchGetStorage = /* @__PURE__ */ temporarilyNotSupport('batchGetStorage');
|
|
3393
|
+
const clearStorage = temporarilyNotSupport('clearStorage');
|
|
3394
|
+
const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage');
|
|
3395
|
+
const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage');
|
|
3396
|
+
const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage');
|
|
3397
|
+
const removeStorageSync = temporarilyNotSupport('removeStorageSync', 'removeStorage');
|
|
3287
3398
|
|
|
3288
3399
|
class Animation {
|
|
3289
3400
|
constructor({ duration = 400, delay = 0, timingFunction = 'linear', transformOrigin = '50% 50% 0', unit = 'px' } = {}) {
|
|
@@ -3316,6 +3427,9 @@ class Animation {
|
|
|
3316
3427
|
transformOrigin,
|
|
3317
3428
|
rule: Object.assign({}, this.rule)
|
|
3318
3429
|
});
|
|
3430
|
+
if (this.rule.transform) {
|
|
3431
|
+
this.rule.transform = Object.assign({}, this.rule.transform);
|
|
3432
|
+
}
|
|
3319
3433
|
return this;
|
|
3320
3434
|
}
|
|
3321
3435
|
matrix(a, b, c, d, tx, ty) {
|
|
@@ -3327,75 +3441,120 @@ class Animation {
|
|
|
3327
3441
|
return this;
|
|
3328
3442
|
}
|
|
3329
3443
|
rotate(angle) {
|
|
3330
|
-
this.rule.
|
|
3444
|
+
if (!this.rule.transform) {
|
|
3445
|
+
this.rule.transform = {};
|
|
3446
|
+
}
|
|
3447
|
+
this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
|
|
3331
3448
|
return this;
|
|
3332
3449
|
}
|
|
3333
3450
|
rotate3d(x, y, z, angle) {
|
|
3334
|
-
this.rule.
|
|
3451
|
+
if (!this.rule.transform) {
|
|
3452
|
+
this.rule.transform = {};
|
|
3453
|
+
}
|
|
3454
|
+
this.rule.transform.Rotate = { x, y, z, angle };
|
|
3335
3455
|
return this;
|
|
3336
3456
|
}
|
|
3337
3457
|
rotateX(angle) {
|
|
3338
|
-
this.rule.
|
|
3458
|
+
if (!this.rule.transform) {
|
|
3459
|
+
this.rule.transform = {};
|
|
3460
|
+
}
|
|
3461
|
+
this.rule.transform.Rotate = { x: 1, y: 0, z: 0, angle };
|
|
3339
3462
|
return this;
|
|
3340
3463
|
}
|
|
3341
3464
|
rotateY(angle) {
|
|
3342
|
-
this.rule.
|
|
3465
|
+
if (!this.rule.transform) {
|
|
3466
|
+
this.rule.transform = {};
|
|
3467
|
+
}
|
|
3468
|
+
this.rule.transform.Rotate = { x: 0, y: 1, z: 0, angle };
|
|
3343
3469
|
return this;
|
|
3344
3470
|
}
|
|
3345
3471
|
rotateZ(angle) {
|
|
3346
|
-
this.rule.
|
|
3472
|
+
if (!this.rule.transform) {
|
|
3473
|
+
this.rule.transform = {};
|
|
3474
|
+
}
|
|
3475
|
+
this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle };
|
|
3347
3476
|
return this;
|
|
3348
3477
|
}
|
|
3349
3478
|
scale(sx, sy) {
|
|
3350
|
-
this.rule.
|
|
3479
|
+
if (!this.rule.transform) {
|
|
3480
|
+
this.rule.transform = {};
|
|
3481
|
+
}
|
|
3482
|
+
this.rule.transform.Scale = { x: sx, y: isUndefined(sy) ? sx : sy };
|
|
3351
3483
|
return this;
|
|
3352
3484
|
}
|
|
3353
3485
|
scale3d(sx, sy, sz) {
|
|
3354
|
-
this.rule.
|
|
3486
|
+
if (!this.rule.transform) {
|
|
3487
|
+
this.rule.transform = {};
|
|
3488
|
+
}
|
|
3489
|
+
this.rule.transform.Scale = { x: sx, y: sy, z: sz };
|
|
3355
3490
|
return this;
|
|
3356
3491
|
}
|
|
3357
3492
|
scaleX(scale) {
|
|
3358
|
-
this.rule.
|
|
3493
|
+
if (!this.rule.transform) {
|
|
3494
|
+
this.rule.transform = {};
|
|
3495
|
+
}
|
|
3496
|
+
this.rule.transform.Scale = { x: scale };
|
|
3359
3497
|
return this;
|
|
3360
3498
|
}
|
|
3361
3499
|
scaleY(scale) {
|
|
3362
|
-
this.rule.
|
|
3500
|
+
if (!this.rule.transform) {
|
|
3501
|
+
this.rule.transform = {};
|
|
3502
|
+
}
|
|
3503
|
+
this.rule.transform.Scale = { y: scale };
|
|
3363
3504
|
return this;
|
|
3364
3505
|
}
|
|
3365
3506
|
scaleZ(scale) {
|
|
3366
|
-
this.rule.
|
|
3507
|
+
if (!this.rule.transform) {
|
|
3508
|
+
this.rule.transform = {};
|
|
3509
|
+
}
|
|
3510
|
+
this.rule.transform.Scale = { z: scale };
|
|
3367
3511
|
return this;
|
|
3368
3512
|
}
|
|
3369
3513
|
skew(ax, ay) {
|
|
3370
|
-
|
|
3514
|
+
temporarilyNotSupport('animation.skew:' + `${ax}, ${ay}`)(ax, ay);
|
|
3371
3515
|
return this;
|
|
3372
3516
|
}
|
|
3373
3517
|
skewX(angle) {
|
|
3374
|
-
|
|
3518
|
+
temporarilyNotSupport('animation.skewX:' + angle)(angle);
|
|
3375
3519
|
return this;
|
|
3376
3520
|
}
|
|
3377
3521
|
skewY(angle) {
|
|
3378
|
-
|
|
3522
|
+
temporarilyNotSupport('animation.skewY:' + angle)(angle);
|
|
3379
3523
|
return this;
|
|
3380
3524
|
}
|
|
3381
3525
|
translate(tx, ty) {
|
|
3382
|
-
this.rule.
|
|
3526
|
+
if (!this.rule.transform) {
|
|
3527
|
+
this.rule.transform = {};
|
|
3528
|
+
}
|
|
3529
|
+
this.rule.transform.Translate = { x: tx, y: ty };
|
|
3383
3530
|
return this;
|
|
3384
3531
|
}
|
|
3385
3532
|
translate3d(tx, ty, tz) {
|
|
3386
|
-
this.rule.
|
|
3533
|
+
if (!this.rule.transform) {
|
|
3534
|
+
this.rule.transform = {};
|
|
3535
|
+
}
|
|
3536
|
+
this.rule.transform.Translate = { x: tx, y: ty, z: tz };
|
|
3387
3537
|
return this;
|
|
3388
3538
|
}
|
|
3389
3539
|
translateX(translation) {
|
|
3390
|
-
this.rule.
|
|
3540
|
+
if (!this.rule.transform) {
|
|
3541
|
+
this.rule.transform = {};
|
|
3542
|
+
}
|
|
3543
|
+
this.rule.transform.Translate = { x: translation };
|
|
3391
3544
|
return this;
|
|
3392
3545
|
}
|
|
3393
3546
|
translateY(translation) {
|
|
3394
|
-
this.rule.
|
|
3547
|
+
if (!this.rule.transform) {
|
|
3548
|
+
this.rule.transform = {};
|
|
3549
|
+
}
|
|
3550
|
+
this.rule.transform.Translate = { y: translation };
|
|
3395
3551
|
return this;
|
|
3396
3552
|
}
|
|
3397
3553
|
translateZ(translation) {
|
|
3398
|
-
this.rule.
|
|
3554
|
+
if (!this.rule.transform) {
|
|
3555
|
+
this.rule.transform = {};
|
|
3556
|
+
}
|
|
3557
|
+
this.rule.transform.Translate = { z: translation };
|
|
3399
3558
|
return this;
|
|
3400
3559
|
}
|
|
3401
3560
|
opacity(value) {
|
|
@@ -3407,15 +3566,15 @@ class Animation {
|
|
|
3407
3566
|
return this;
|
|
3408
3567
|
}
|
|
3409
3568
|
width(value) {
|
|
3410
|
-
this.rule.
|
|
3569
|
+
this.rule.width = value;
|
|
3411
3570
|
return this;
|
|
3412
3571
|
}
|
|
3413
3572
|
height(value) {
|
|
3414
|
-
this.rule.
|
|
3573
|
+
this.rule.height = value;
|
|
3415
3574
|
return this;
|
|
3416
3575
|
}
|
|
3417
3576
|
left(value) {
|
|
3418
|
-
|
|
3577
|
+
this.rule.left = value;
|
|
3419
3578
|
return this;
|
|
3420
3579
|
}
|
|
3421
3580
|
right(value) {
|
|
@@ -3423,7 +3582,7 @@ class Animation {
|
|
|
3423
3582
|
return this;
|
|
3424
3583
|
}
|
|
3425
3584
|
top(value) {
|
|
3426
|
-
|
|
3585
|
+
this.rule.top = value;
|
|
3427
3586
|
return this;
|
|
3428
3587
|
}
|
|
3429
3588
|
bottom(value) {
|
|
@@ -3442,7 +3601,8 @@ function setBackgroundColor(options) {
|
|
|
3442
3601
|
const handle = new MethodHandler({ name: 'setBackgroundColor', success, fail, complete });
|
|
3443
3602
|
return new Promise((resolve, reject) => {
|
|
3444
3603
|
eventCenter.trigger('__taroPageStyle', {
|
|
3445
|
-
backgroundColor: options.
|
|
3604
|
+
backgroundColor: options.backgroundColorBottom || options.backgroundColor,
|
|
3605
|
+
backgroundColorContext: options.backgroundColorTop || options.backgroundColor
|
|
3446
3606
|
});
|
|
3447
3607
|
return handle.success({}, { resolve, reject });
|
|
3448
3608
|
});
|
|
@@ -3481,7 +3641,7 @@ function showToast(options) {
|
|
|
3481
3641
|
const res = { errMsg: error.message };
|
|
3482
3642
|
return callAsyncFail(reject, res, options);
|
|
3483
3643
|
}
|
|
3484
|
-
|
|
3644
|
+
promptAction.showToast({
|
|
3485
3645
|
message: options.title,
|
|
3486
3646
|
duration: options.duration,
|
|
3487
3647
|
bottom: options.bottom
|
|
@@ -3514,25 +3674,24 @@ function showModal(options) {
|
|
|
3514
3674
|
color: confirmColor
|
|
3515
3675
|
});
|
|
3516
3676
|
}
|
|
3517
|
-
return new Promise(resolve => {
|
|
3677
|
+
return new Promise((resolve, reject) => {
|
|
3518
3678
|
const modalOptions = {
|
|
3519
3679
|
title,
|
|
3520
3680
|
message: content,
|
|
3521
3681
|
buttons: buttons,
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
}
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
},
|
|
3530
|
-
// 鸿蒙没有失败方法,只有取消
|
|
3531
|
-
cancel: (_) => {
|
|
3682
|
+
};
|
|
3683
|
+
promptAction.showDialog(modalOptions, (error, data) => {
|
|
3684
|
+
if (error) {
|
|
3685
|
+
const res = { errMsg: error };
|
|
3686
|
+
callAsyncFail(reject, res, options);
|
|
3687
|
+
}
|
|
3688
|
+
if (data.index === 0 && showCancel) {
|
|
3532
3689
|
callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: false, cancel: true }), options);
|
|
3533
3690
|
}
|
|
3534
|
-
|
|
3535
|
-
|
|
3691
|
+
else {
|
|
3692
|
+
callAsyncSuccess(resolve, Object.assign(Object.assign({}, resCallback('showModal')), { confirm: true, cancel: false, content: null }), options);
|
|
3693
|
+
}
|
|
3694
|
+
});
|
|
3536
3695
|
});
|
|
3537
3696
|
}
|
|
3538
3697
|
const showActionSheetSchema = {
|
|
@@ -3563,21 +3722,20 @@ function showActionSheet(options) {
|
|
|
3563
3722
|
});
|
|
3564
3723
|
const actionSheetOptions = {
|
|
3565
3724
|
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
|
-
}
|
|
3725
|
+
buttons
|
|
3574
3726
|
};
|
|
3575
|
-
|
|
3727
|
+
promptAction.showActionMenu(actionSheetOptions, (error, data) => {
|
|
3728
|
+
var _a;
|
|
3729
|
+
if (error) {
|
|
3730
|
+
callAsyncFail(reject, Object.assign(Object.assign({}, data), { errMsg: (_a = data.errMsg) === null || _a === void 0 ? void 0 : _a.replace('showActionMenu', 'showActionSheet') }), options);
|
|
3731
|
+
}
|
|
3732
|
+
callAsyncSuccess(resolve, Object.assign(Object.assign({}, data), resCallback('showActionSheet')), options);
|
|
3733
|
+
});
|
|
3576
3734
|
});
|
|
3577
3735
|
}
|
|
3578
3736
|
function hideToast(options) {
|
|
3579
3737
|
return new Promise(resolve => {
|
|
3580
|
-
|
|
3738
|
+
promptAction.showToast({
|
|
3581
3739
|
message: '关闭中',
|
|
3582
3740
|
duration: 10,
|
|
3583
3741
|
bottom: '9999px'
|
|
@@ -3605,7 +3763,7 @@ const setNavigationBarTitle = function (options) {
|
|
|
3605
3763
|
};
|
|
3606
3764
|
const setNavigationBarColor = function (options) {
|
|
3607
3765
|
const { success, fail, complete } = options || {};
|
|
3608
|
-
const handle = new MethodHandler({ name: '
|
|
3766
|
+
const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete });
|
|
3609
3767
|
return new Promise((resolve, reject) => {
|
|
3610
3768
|
eventCenter.trigger('__taroNavigationStyle', {
|
|
3611
3769
|
animation: options.animation,
|
|
@@ -3723,7 +3881,7 @@ const pageScrollTo = (options) => {
|
|
|
3723
3881
|
scroller = getPageScrollerOrNode(scroller, page);
|
|
3724
3882
|
const { yOffset } = scroller.currentOffset();
|
|
3725
3883
|
if (areaInfo) {
|
|
3726
|
-
scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper(offsetTop, 'px', true);
|
|
3884
|
+
scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper$1(offsetTop, 'px', true);
|
|
3727
3885
|
}
|
|
3728
3886
|
}
|
|
3729
3887
|
const { xOffset } = scroller.currentOffset();
|
|
@@ -3908,19 +4066,16 @@ class IntersectionObserver {
|
|
|
3908
4066
|
};
|
|
3909
4067
|
const taro = Current.taro;
|
|
3910
4068
|
const page = taro.getCurrentInstance().page;
|
|
3911
|
-
|
|
3912
|
-
this._component = component || currentPage;
|
|
4069
|
+
this._component = component || getPageScrollerOrNode(page === null || page === void 0 ? void 0 : page.node, page);
|
|
3913
4070
|
Object.assign(this._options, options);
|
|
3914
4071
|
}
|
|
3915
4072
|
disconnect() {
|
|
3916
|
-
|
|
3917
|
-
if (this._observerNodes) {
|
|
4073
|
+
if (this._observerNodes && this._component) {
|
|
3918
4074
|
if (this._observerNodes instanceof Array) {
|
|
3919
4075
|
this._observerNodes.forEach((n) => {
|
|
3920
|
-
var _a;
|
|
3921
4076
|
disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME);
|
|
3922
4077
|
// @ts-ignore
|
|
3923
|
-
|
|
4078
|
+
n._nodeInfo.thresholds = null;
|
|
3924
4079
|
});
|
|
3925
4080
|
}
|
|
3926
4081
|
else {
|
|
@@ -3928,35 +4083,40 @@ class IntersectionObserver {
|
|
|
3928
4083
|
// @ts-ignore
|
|
3929
4084
|
if (this._observerNodes._nodeInfo) {
|
|
3930
4085
|
// @ts-ignore
|
|
3931
|
-
|
|
4086
|
+
this._observerNodes._nodeInfo.thresholds = null;
|
|
3932
4087
|
}
|
|
3933
4088
|
}
|
|
3934
4089
|
}
|
|
3935
4090
|
}
|
|
3936
4091
|
observe(targetSelector, callback) {
|
|
3937
|
-
|
|
4092
|
+
if (!this._component)
|
|
4093
|
+
return;
|
|
3938
4094
|
const { observeAll, thresholds } = this._options;
|
|
3939
4095
|
const node = findChildNodeWithDFS(this._component, targetSelector, observeAll);
|
|
3940
4096
|
this._observerNodes = node;
|
|
3941
4097
|
if (node) {
|
|
3942
4098
|
if (node instanceof Array) {
|
|
3943
4099
|
node.forEach(n => {
|
|
3944
|
-
var _a;
|
|
3945
4100
|
// @ts-ignore
|
|
3946
|
-
|
|
4101
|
+
n._nodeInfo.thresholds = thresholds;
|
|
3947
4102
|
setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
|
|
3948
|
-
callback(this.handleResult(isVisible, currentRatio));
|
|
4103
|
+
callback(this.handleResult(isVisible, currentRatio, n));
|
|
3949
4104
|
});
|
|
3950
4105
|
});
|
|
3951
4106
|
}
|
|
3952
4107
|
else {
|
|
3953
4108
|
// @ts-ignore
|
|
3954
|
-
|
|
4109
|
+
node._nodeInfo.thresholds = thresholds;
|
|
3955
4110
|
setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible, currentRatio) => {
|
|
3956
|
-
callback(this.handleResult(isVisible, currentRatio));
|
|
4111
|
+
callback(this.handleResult(isVisible, currentRatio, node));
|
|
3957
4112
|
});
|
|
3958
4113
|
}
|
|
3959
4114
|
}
|
|
4115
|
+
else {
|
|
4116
|
+
callback({
|
|
4117
|
+
errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
|
|
4118
|
+
});
|
|
4119
|
+
}
|
|
3960
4120
|
}
|
|
3961
4121
|
relativeTo() {
|
|
3962
4122
|
temporarilyNotSupport('relativeTo')();
|
|
@@ -3967,8 +4127,10 @@ class IntersectionObserver {
|
|
|
3967
4127
|
return this;
|
|
3968
4128
|
}
|
|
3969
4129
|
// @ts-ignore
|
|
3970
|
-
handleResult(isVisible, currentRatio) {
|
|
4130
|
+
handleResult(isVisible, currentRatio, node) {
|
|
3971
4131
|
const result = {
|
|
4132
|
+
id: node.id,
|
|
4133
|
+
dataset: node.dataset,
|
|
3972
4134
|
intersectionRatio: currentRatio,
|
|
3973
4135
|
// TODO 未做,等待能拿到element的info信息
|
|
3974
4136
|
boundingClientRect: {
|
|
@@ -4189,19 +4351,29 @@ function queryBat(queue, cb) {
|
|
|
4189
4351
|
return null;
|
|
4190
4352
|
arr = [];
|
|
4191
4353
|
traversalDFSDom(element);
|
|
4192
|
-
queue.forEach(item => {
|
|
4354
|
+
queue.forEach((item) => {
|
|
4193
4355
|
const { selector, single, fields } = item;
|
|
4194
|
-
|
|
4195
|
-
|
|
4356
|
+
if (single) {
|
|
4357
|
+
const dom = querySelector(selector, !single)[0];
|
|
4196
4358
|
// eslint-disable-next-line no-async-promise-executor
|
|
4197
|
-
|
|
4359
|
+
result.push(new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
4198
4360
|
yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
|
|
4199
4361
|
resolve(filter(fields, dom));
|
|
4362
|
+
})));
|
|
4363
|
+
}
|
|
4364
|
+
else {
|
|
4365
|
+
const nodeList = querySelector(selector, !single);
|
|
4366
|
+
result.push(nodeList.map(dom => {
|
|
4367
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
4368
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
4369
|
+
yield setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true);
|
|
4370
|
+
resolve(filter(fields, dom));
|
|
4371
|
+
}));
|
|
4200
4372
|
}));
|
|
4201
|
-
}
|
|
4373
|
+
}
|
|
4202
4374
|
});
|
|
4203
4375
|
Promise.all(result.map(item => {
|
|
4204
|
-
return Promise.all(item);
|
|
4376
|
+
return item instanceof Array ? Promise.all(item) : item;
|
|
4205
4377
|
})).then(data => {
|
|
4206
4378
|
cb(data);
|
|
4207
4379
|
});
|
|
@@ -4280,6 +4452,7 @@ var apis = /*#__PURE__*/Object.freeze({
|
|
|
4280
4452
|
ENV_TYPE: ENV_TYPE,
|
|
4281
4453
|
Events: Events,
|
|
4282
4454
|
History: History,
|
|
4455
|
+
IntersectionObserver: IntersectionObserver,
|
|
4283
4456
|
addCard: addCard,
|
|
4284
4457
|
addFileToFavorites: addFileToFavorites,
|
|
4285
4458
|
addPhoneCalendar: addPhoneCalendar,
|
|
@@ -4669,7 +4842,7 @@ var apis = /*#__PURE__*/Object.freeze({
|
|
|
4669
4842
|
writeBLECharacteristicValue: writeBLECharacteristicValue
|
|
4670
4843
|
});
|
|
4671
4844
|
|
|
4672
|
-
Object.assign({}, apis);
|
|
4845
|
+
const taro = Object.assign({}, apis);
|
|
4673
4846
|
const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin');
|
|
4674
4847
|
function initNativeApi(taro) {
|
|
4675
4848
|
Current.taro = taro;
|
|
@@ -4693,7 +4866,7 @@ const defaultBaseFontSize = 20;
|
|
|
4693
4866
|
const defaultUnitPrecision = 5;
|
|
4694
4867
|
const defaultTargetUnit = 'vp';
|
|
4695
4868
|
function getApp$1() {
|
|
4696
|
-
return Current.app;
|
|
4869
|
+
return Current.app || {};
|
|
4697
4870
|
}
|
|
4698
4871
|
function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
|
|
4699
4872
|
const taro = Current.taro;
|
|
@@ -4707,19 +4880,56 @@ function initPxTransform({ designWidth = defaultDesignWidth, deviceRatio = defau
|
|
|
4707
4880
|
config.unitPrecision = unitPrecision;
|
|
4708
4881
|
}
|
|
4709
4882
|
}
|
|
4710
|
-
_display.getDefaultDisplaySync();
|
|
4883
|
+
const display = _display.getDefaultDisplaySync();
|
|
4884
|
+
let displayWidth = display.width;
|
|
4885
|
+
let ratioCache = false;
|
|
4886
|
+
let designWidthFunc;
|
|
4887
|
+
let designWidth = defaultDesignWidth;
|
|
4888
|
+
function getRatio(value) {
|
|
4889
|
+
var _a;
|
|
4890
|
+
// Note: 提前调用 display 可能无法获取正确值
|
|
4891
|
+
if (ratioCache === false || displayWidth !== display.width) {
|
|
4892
|
+
const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
|
|
4893
|
+
if (!isFunction(designWidthFunc)) {
|
|
4894
|
+
designWidthFunc = isFunction(config.designWidth)
|
|
4895
|
+
? config.designWidth
|
|
4896
|
+
: () => config.designWidth;
|
|
4897
|
+
designWidth = designWidthFunc(value) || defaultDesignWidth;
|
|
4898
|
+
}
|
|
4899
|
+
displayWidth = display.width;
|
|
4900
|
+
ratioCache = Math.min(display.width, display.height) / designWidth;
|
|
4901
|
+
}
|
|
4902
|
+
return ratioCache;
|
|
4903
|
+
}
|
|
4904
|
+
// Note: 设置为 style 单位时会自动完成设计稿转换,设计开发者调用 API 时也许抹平差异,例如 pageScrollTo[option.offsetTop]
|
|
4905
|
+
function pxTransformHelper(size, unit, isNumber = false) {
|
|
4906
|
+
var _a;
|
|
4907
|
+
const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
|
|
4908
|
+
const targetUnit = unit || config.targetUnit || defaultTargetUnit;
|
|
4909
|
+
if (targetUnit === 'PX') {
|
|
4910
|
+
return px2vp(size * display.scaledDensity) + 'vp';
|
|
4911
|
+
}
|
|
4912
|
+
const ratio = getRatio(size);
|
|
4913
|
+
let val = size * ratio;
|
|
4914
|
+
switch (targetUnit) {
|
|
4915
|
+
case 'vp':
|
|
4916
|
+
// Note: 在应用创建前调用无效
|
|
4917
|
+
val = px2vp(val);
|
|
4918
|
+
break;
|
|
4919
|
+
}
|
|
4920
|
+
return isNumber ? val : val + targetUnit;
|
|
4921
|
+
}
|
|
4711
4922
|
function pxTransform(size) {
|
|
4712
4923
|
var _a;
|
|
4713
4924
|
const config = ((_a = Current.taro) === null || _a === void 0 ? void 0 : _a.config) || {};
|
|
4714
4925
|
const targetUnit = config.targetUnit || defaultTargetUnit;
|
|
4715
|
-
|
|
4926
|
+
const val = size;
|
|
4716
4927
|
switch (targetUnit) {
|
|
4717
4928
|
case 'vp':
|
|
4718
|
-
|
|
4719
|
-
break;
|
|
4929
|
+
return pxTransformHelper(size, 'px');
|
|
4720
4930
|
// NOTE: 鸿蒙环境下 style 会自动完成设计稿转换,无需在方法内二次调整
|
|
4721
4931
|
}
|
|
4722
|
-
return val +
|
|
4932
|
+
return val + targetUnit;
|
|
4723
4933
|
}
|
|
4724
4934
|
function canIUseWebp() {
|
|
4725
4935
|
return true;
|
|
@@ -4733,6 +4943,7 @@ function getAppInfo() {
|
|
|
4733
4943
|
designWidth: config === null || config === void 0 ? void 0 : config.designWidth,
|
|
4734
4944
|
};
|
|
4735
4945
|
}
|
|
4946
|
+
initNativeApi(taro);
|
|
4736
4947
|
|
|
4737
4948
|
const components = {
|
|
4738
4949
|
Checkbox: {
|