@tarojs/runtime 3.6.2 → 3.6.4
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/LICENSE +21 -0
- package/dist/dom/custom-wrapper.d.ts +4 -0
- package/dist/dom-external/element.d.ts +1 -1
- package/dist/dom-external/node.d.ts +1 -1
- package/dist/runtime.esm.js +38 -19
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +11 -3
package/LICENSE
CHANGED
|
@@ -137,3 +137,24 @@ MIT (miniprogram-render):
|
|
|
137
137
|
The following files embed [miniprogram-render](https://github.com/Tencent/kbone) MIT:
|
|
138
138
|
`/packages/taro-plugin-http/src/runtime/Cookie.ts`
|
|
139
139
|
See `/LICENSE` for details of the license.
|
|
140
|
+
|
|
141
|
+
==================
|
|
142
|
+
|
|
143
|
+
MIT (stencil-ds-output-targets):
|
|
144
|
+
The following files embed [stencil-ds-output-targets](https://github.com/ionic-team/stencil-ds-output-targets/) MIT:
|
|
145
|
+
`/packages/taro-components-library-react/src/react-component-lib/utils/attachProps.ts`
|
|
146
|
+
`/packages/taro-components-library-react/src/react-component-lib/utils/case.ts`
|
|
147
|
+
`/packages/taro-components-library-react/src/react-component-lib/utils/dev.ts`
|
|
148
|
+
`/packages/taro-components-library-react/src/react-component-lib/utils/index.tsx`
|
|
149
|
+
`/packages/taro-components-library-react/src/react-component-lib/createComponent.tsx`
|
|
150
|
+
`/packages/taro-components-library-react/src/react-component-lib/createOverlayComponent.tsx`
|
|
151
|
+
`/packages/taro-components-library-react/src/react-component-lib/interfaces.ts`
|
|
152
|
+
`/packages/taro-components-library-vue3/src/vue-component-lib/utils.ts`
|
|
153
|
+
See `/LICENSE` for details of the license.
|
|
154
|
+
|
|
155
|
+
==================
|
|
156
|
+
|
|
157
|
+
MIT (stencil-vue2-output-target):
|
|
158
|
+
The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
|
|
159
|
+
`/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
|
|
160
|
+
See `/LICENSE` for details of the license.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { TaroElement } from '
|
|
1
|
+
import type { TaroElement } from '../dom/element';
|
|
2
2
|
export declare function getBoundingClientRectImpl(this: TaroElement): Promise<null>;
|
|
3
3
|
export declare function getTemplateContent(ctx: TaroElement): TaroElement | undefined;
|
package/dist/runtime.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents, EMPTY_OBJ, hooks, toCamelCase, isObject, warn, isArray, ensure, isNull, isUndefined, toDashed, isString, controlledComponent, Events, isNumber } from '@tarojs/shared';
|
|
1
|
+
import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents, isWebPlatform, EMPTY_OBJ, hooks, toCamelCase, isObject, warn, isArray, ensure, isNull, isUndefined, toDashed, isString, controlledComponent, Events, isNumber } from '@tarojs/shared';
|
|
2
2
|
export { Events, hooks } from '@tarojs/shared';
|
|
3
3
|
|
|
4
4
|
const PROPERTY_THRESHOLD = 2046;
|
|
@@ -344,9 +344,10 @@ class EventSource extends Map {
|
|
|
344
344
|
}
|
|
345
345
|
const eventSource = new EventSource();
|
|
346
346
|
|
|
347
|
+
const isWeb$1 = isWebPlatform();
|
|
347
348
|
const env = {
|
|
348
|
-
window:
|
|
349
|
-
document:
|
|
349
|
+
window: isWeb$1 ? window : EMPTY_OBJ,
|
|
350
|
+
document: isWeb$1 ? document : EMPTY_OBJ
|
|
350
351
|
};
|
|
351
352
|
|
|
352
353
|
let SPECIAL_NODES;
|
|
@@ -2312,7 +2313,7 @@ function contains(node) {
|
|
|
2312
2313
|
return isContains;
|
|
2313
2314
|
}
|
|
2314
2315
|
|
|
2315
|
-
if (
|
|
2316
|
+
if (!isWebPlatform()) {
|
|
2316
2317
|
if (ENABLE_INNER_HTML) {
|
|
2317
2318
|
TaroNode.extend('innerHTML', {
|
|
2318
2319
|
set(html) {
|
|
@@ -2442,10 +2443,10 @@ function getEventCBResult(event) {
|
|
|
2442
2443
|
function eventHandler(event) {
|
|
2443
2444
|
var _a, _b;
|
|
2444
2445
|
// Note: ohos 上事件没有设置 type、detail 类型 setter 方法,且部分事件(例如 load 等)缺失 target 导致事件错误
|
|
2445
|
-
|
|
2446
|
+
event.type === undefined && Object.defineProperty(event, 'type', {
|
|
2446
2447
|
value: event._type // ohos only
|
|
2447
2448
|
});
|
|
2448
|
-
|
|
2449
|
+
event.detail === undefined && Object.defineProperty(event, 'detail', {
|
|
2449
2450
|
value: event._detail || Object.assign({}, event) // ohos only
|
|
2450
2451
|
});
|
|
2451
2452
|
event.currentTarget = event.currentTarget || event.target || Object.assign({}, event);
|
|
@@ -2549,6 +2550,9 @@ function findCustomWrapper(root, dataPathArr) {
|
|
|
2549
2550
|
// 'cn' => 'childNodes'
|
|
2550
2551
|
.replace(/\bcn\b/g, 'childNodes');
|
|
2551
2552
|
currentData = currentData[key];
|
|
2553
|
+
if (isArray(currentData)) {
|
|
2554
|
+
currentData = currentData.filter(el => !isComment(el));
|
|
2555
|
+
}
|
|
2552
2556
|
if (isUndefined(currentData))
|
|
2553
2557
|
return true;
|
|
2554
2558
|
if (currentData.nodeName === CUSTOM_WRAPPER) {
|
|
@@ -3138,6 +3142,9 @@ class AnchorElement extends TaroElement {
|
|
|
3138
3142
|
}
|
|
3139
3143
|
}
|
|
3140
3144
|
|
|
3145
|
+
class CustomWrapperElement extends TaroElement {
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3141
3148
|
class TaroDocument extends TaroElement {
|
|
3142
3149
|
constructor() {
|
|
3143
3150
|
super();
|
|
@@ -3158,6 +3165,9 @@ class TaroDocument extends TaroElement {
|
|
|
3158
3165
|
case nodeName === A:
|
|
3159
3166
|
element = new AnchorElement();
|
|
3160
3167
|
break;
|
|
3168
|
+
case nodeName === CUSTOM_WRAPPER:
|
|
3169
|
+
element = new CustomWrapperElement();
|
|
3170
|
+
break;
|
|
3161
3171
|
default:
|
|
3162
3172
|
element = new TaroElement();
|
|
3163
3173
|
break;
|
|
@@ -3201,7 +3211,7 @@ class TaroDocument extends TaroElement {
|
|
|
3201
3211
|
}
|
|
3202
3212
|
|
|
3203
3213
|
let document$1;
|
|
3204
|
-
if (process.env.TARO_ENV &&
|
|
3214
|
+
if (process.env.TARO_ENV && !isWebPlatform()) {
|
|
3205
3215
|
/* eslint-disable no-inner-declarations */
|
|
3206
3216
|
function createDocument() {
|
|
3207
3217
|
/**
|
|
@@ -3621,7 +3631,7 @@ const machine = 'Macintosh';
|
|
|
3621
3631
|
const arch = 'Intel Mac OS X 10_14_5';
|
|
3622
3632
|
const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36';
|
|
3623
3633
|
const msg = '(' + machine + '; ' + arch + ') ' + engine;
|
|
3624
|
-
const nav =
|
|
3634
|
+
const nav = isWebPlatform() ? env.window.navigator : {
|
|
3625
3635
|
appCodeName: 'Mozilla',
|
|
3626
3636
|
appName: 'Netscape',
|
|
3627
3637
|
appVersion: '5.0 ' + msg,
|
|
@@ -3669,7 +3679,7 @@ const _caf = typeof cancelAnimationFrame !== 'undefined' && cancelAnimationFrame
|
|
|
3669
3679
|
};
|
|
3670
3680
|
|
|
3671
3681
|
let window$1;
|
|
3672
|
-
if (process.env.TARO_ENV &&
|
|
3682
|
+
if (process.env.TARO_ENV && !isWebPlatform()) {
|
|
3673
3683
|
class Window extends Events {
|
|
3674
3684
|
constructor() {
|
|
3675
3685
|
super();
|
|
@@ -3752,6 +3762,7 @@ class SVGElement extends TaroElement {
|
|
|
3752
3762
|
/* eslint-disable dot-notation */
|
|
3753
3763
|
const instances = new Map();
|
|
3754
3764
|
const pageId = incrementId();
|
|
3765
|
+
const isWeb = isWebPlatform();
|
|
3755
3766
|
function injectPageInstance(inst, id) {
|
|
3756
3767
|
hooks.call('mergePageInstance', instances.get(id), inst);
|
|
3757
3768
|
instances.set(id, inst);
|
|
@@ -3794,7 +3805,7 @@ function stringify(obj) {
|
|
|
3794
3805
|
}
|
|
3795
3806
|
function getPath(id, options) {
|
|
3796
3807
|
const idx = id.indexOf('?');
|
|
3797
|
-
if (
|
|
3808
|
+
if (isWeb) {
|
|
3798
3809
|
return `${idx > -1 ? id.substring(0, idx) : id}${stringify((options === null || options === void 0 ? void 0 : options.stamp) ? { stamp: options.stamp } : {})}`;
|
|
3799
3810
|
}
|
|
3800
3811
|
else {
|
|
@@ -3818,7 +3829,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3818
3829
|
let unmounting = false;
|
|
3819
3830
|
let prepareMountList = [];
|
|
3820
3831
|
function setCurrentRouter(page) {
|
|
3821
|
-
const router =
|
|
3832
|
+
const router = isWeb ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
|
|
3822
3833
|
Current.router = {
|
|
3823
3834
|
params: page.$taroParams,
|
|
3824
3835
|
path: addLeadingSlash(router),
|
|
@@ -3842,7 +3853,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3842
3853
|
// this.$taroPath 是页面唯一标识
|
|
3843
3854
|
const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() });
|
|
3844
3855
|
const $taroPath = this.$taroPath = getPath(id, uniqueOptions);
|
|
3845
|
-
if (
|
|
3856
|
+
if (isWeb) {
|
|
3846
3857
|
config.path = $taroPath;
|
|
3847
3858
|
}
|
|
3848
3859
|
// this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
|
|
@@ -3851,7 +3862,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3851
3862
|
}
|
|
3852
3863
|
setCurrentRouter(this);
|
|
3853
3864
|
// 初始化当前页面的上下文信息
|
|
3854
|
-
if (
|
|
3865
|
+
if (!isWeb) {
|
|
3855
3866
|
window$1.trigger(CONTEXT_ACTIONS.INIT, $taroPath);
|
|
3856
3867
|
}
|
|
3857
3868
|
const mount = () => {
|
|
@@ -3860,7 +3871,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3860
3871
|
ensure(pageElement !== null, '没有找到页面实例。');
|
|
3861
3872
|
safeExecute($taroPath, ON_LOAD, this.$taroParams);
|
|
3862
3873
|
loadResolver();
|
|
3863
|
-
if (
|
|
3874
|
+
if (!isWeb) {
|
|
3864
3875
|
pageElement.ctx = this;
|
|
3865
3876
|
pageElement.performUpdate(true, cb);
|
|
3866
3877
|
}
|
|
@@ -3879,7 +3890,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3879
3890
|
[ONUNLOAD]() {
|
|
3880
3891
|
const $taroPath = this.$taroPath;
|
|
3881
3892
|
// 销毁当前页面的上下文信息
|
|
3882
|
-
if (
|
|
3893
|
+
if (!isWeb) {
|
|
3883
3894
|
window$1.trigger(CONTEXT_ACTIONS.DESTORY, $taroPath);
|
|
3884
3895
|
}
|
|
3885
3896
|
// 触发onUnload生命周期
|
|
@@ -3913,7 +3924,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3913
3924
|
Current.page = this;
|
|
3914
3925
|
setCurrentRouter(this);
|
|
3915
3926
|
// 恢复上下文信息
|
|
3916
|
-
if (
|
|
3927
|
+
if (!isWeb) {
|
|
3917
3928
|
window$1.trigger(CONTEXT_ACTIONS.RECOVER, this.$taroPath);
|
|
3918
3929
|
}
|
|
3919
3930
|
// 触发生命周期
|
|
@@ -3924,7 +3935,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3924
3935
|
},
|
|
3925
3936
|
[ONHIDE]() {
|
|
3926
3937
|
// 缓存当前页面上下文信息
|
|
3927
|
-
if (
|
|
3938
|
+
if (!isWeb) {
|
|
3928
3939
|
window$1.trigger(CONTEXT_ACTIONS.RESTORE, this.$taroPath);
|
|
3929
3940
|
}
|
|
3930
3941
|
// 设置 Current 的 page 和 router
|
|
@@ -3984,7 +3995,7 @@ function createComponentConfig(component, componentName, data) {
|
|
|
3984
3995
|
ensure(componentElement !== null, '没有找到组件实例。');
|
|
3985
3996
|
this.$taroInstances = instances.get(path);
|
|
3986
3997
|
safeExecute(path, ON_LOAD);
|
|
3987
|
-
if (
|
|
3998
|
+
if (!isWeb) {
|
|
3988
3999
|
componentElement.ctx = this;
|
|
3989
4000
|
componentElement.performUpdate(true);
|
|
3990
4001
|
}
|
|
@@ -4022,6 +4033,10 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4022
4033
|
const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
|
|
4023
4034
|
if (isString(componentId)) {
|
|
4024
4035
|
customWrapperCache.set(componentId, this);
|
|
4036
|
+
const el = env.document.getElementById(componentId);
|
|
4037
|
+
if (el) {
|
|
4038
|
+
el.ctx = this;
|
|
4039
|
+
}
|
|
4025
4040
|
}
|
|
4026
4041
|
},
|
|
4027
4042
|
[DETACHED]() {
|
|
@@ -4029,6 +4044,10 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4029
4044
|
const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
|
|
4030
4045
|
if (isString(componentId)) {
|
|
4031
4046
|
customWrapperCache.delete(componentId);
|
|
4047
|
+
const el = env.document.getElementById(componentId);
|
|
4048
|
+
if (el) {
|
|
4049
|
+
el.ctx = null;
|
|
4050
|
+
}
|
|
4032
4051
|
}
|
|
4033
4052
|
}
|
|
4034
4053
|
}
|
|
@@ -4065,7 +4084,7 @@ const nextTick = (cb, ctx) => {
|
|
|
4065
4084
|
const path = router.$taroPath;
|
|
4066
4085
|
pageElement = env.document.getElementById(path);
|
|
4067
4086
|
if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
|
|
4068
|
-
if (
|
|
4087
|
+
if (isWebPlatform()) {
|
|
4069
4088
|
// eslint-disable-next-line dot-notation
|
|
4070
4089
|
(_c = (_b = (_a = pageElement.firstChild) === null || _a === void 0 ? void 0 : _a['componentOnReady']) === null || _b === void 0 ? void 0 : _b.call(_a).then(() => {
|
|
4071
4090
|
timerFunc();
|