@tarojs/runtime 4.0.8-beta.0 → 4.0.8-beta.3
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/bom/URL.d.ts +3 -4
- package/dist/bom/URL.js +1 -1
- package/dist/bom/URL.js.map +1 -1
- package/dist/bom/URLSearchParams.d.ts +1 -0
- package/dist/bom/URLSearchParams.js.map +1 -1
- package/dist/bom/document.d.ts +3 -1
- package/dist/bom/document.js.map +1 -1
- package/dist/bom/getComputedStyle.d.ts +6 -3
- package/dist/bom/getComputedStyle.js.map +1 -1
- package/dist/bom/history.d.ts +8 -6
- package/dist/bom/history.js.map +1 -1
- package/dist/bom/location.d.ts +6 -5
- package/dist/bom/location.js.map +1 -1
- package/dist/bom/navigator.d.ts +1 -0
- package/dist/bom/navigator.js.map +1 -1
- package/dist/bom/raf.d.ts +2 -2
- package/dist/bom/raf.js.map +1 -1
- package/dist/bom/window.d.ts +11 -8
- package/dist/bom/window.js.map +1 -1
- package/dist/constants/index.d.ts +3 -2
- package/dist/constants/index.js +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/current.d.ts +5 -2
- package/dist/current.js.map +1 -1
- package/dist/dom/anchor-element.js.map +1 -1
- package/dist/dom/class-list.d.ts +3 -1
- package/dist/dom/class-list.js.map +1 -1
- package/dist/dom/document.d.ts +7 -8
- package/dist/dom/document.js.map +1 -1
- package/dist/dom/element.d.ts +8 -5
- package/dist/dom/element.js +7 -5
- package/dist/dom/element.js.map +1 -1
- package/dist/dom/event-source.d.ts +3 -1
- package/dist/dom/event-source.js.map +1 -1
- package/dist/dom/event-target.d.ts +3 -1
- package/dist/dom/event-target.js.map +1 -1
- package/dist/dom/event.d.ts +4 -2
- package/dist/dom/event.js.map +1 -1
- package/dist/dom/form.d.ts +4 -2
- package/dist/dom/form.js.map +1 -1
- package/dist/dom/node.d.ts +9 -37
- package/dist/dom/node.js.map +1 -1
- package/dist/{node_types-9ac5b4dd.d.ts → dom/node_types.d.ts} +1 -0
- package/dist/dom/root.d.ts +6 -2
- package/dist/dom/root.js +4 -14
- package/dist/dom/root.js.map +1 -1
- package/dist/dom/style.d.ts +3 -1
- package/dist/dom/style.js.map +1 -1
- package/dist/dom/style_properties.js +1 -0
- package/dist/dom/style_properties.js.map +1 -1
- package/dist/dom/svg.d.ts +3 -1
- package/dist/dom/svg.js.map +1 -1
- package/dist/dom/text.d.ts +4 -2
- package/dist/dom/text.js.map +1 -1
- package/dist/dom/transfer.js.map +1 -1
- package/dist/dom/tree.js.map +1 -1
- package/dist/dom-external/element.js +7 -0
- package/dist/dom-external/element.js.map +1 -1
- package/dist/dom-external/index.js.map +1 -1
- package/dist/dom-external/inner-html/html.js.map +1 -1
- package/dist/dom-external/inner-html/parser.d.ts +2 -7
- package/dist/dom-external/inner-html/parser.js +1 -1
- package/dist/dom-external/inner-html/parser.js.map +1 -1
- package/dist/dom-external/inner-html/scaner.js.map +1 -1
- package/dist/dom-external/inner-html/style.js.map +1 -1
- package/dist/dom-external/inner-html/tags.js.map +1 -1
- package/dist/dom-external/inner-html/utils.js.map +1 -1
- package/dist/dom-external/mutation-observer/implements.d.ts +6 -22
- package/dist/dom-external/mutation-observer/implements.js.map +1 -1
- package/dist/dom-external/mutation-observer/index.d.ts +7 -4
- package/dist/dom-external/mutation-observer/index.js.map +1 -1
- package/dist/{record-32b054d8.d.ts → dom-external/mutation-observer/record.d.ts} +5 -2
- package/dist/dom-external/node.js.map +1 -1
- package/dist/dsl/common.d.ts +5 -4
- package/dist/dsl/common.js +32 -15
- package/dist/dsl/common.js.map +1 -1
- package/dist/{instance-4c64b022.d.ts → dsl/instance.d.ts} +23 -11
- package/dist/emitter/emitter.d.ts +5 -1
- package/dist/emitter/emitter.js.map +1 -1
- package/dist/env.d.ts +3 -1
- package/dist/env.js.map +1 -1
- package/dist/hydrate.d.ts +5 -3
- package/dist/hydrate.js +9 -7
- package/dist/hydrate.js.map +1 -1
- package/dist/index.cjs.d.ts +179 -71
- package/dist/index.cjs.js +65 -49
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +42 -34
- package/dist/interface/animate.d.ts +83 -0
- package/dist/interface/element.d.ts +6 -0
- package/dist/interface/event-target.d.ts +13 -0
- package/dist/interface/event.d.ts +16 -0
- package/dist/interface/hydrate.d.ts +32 -0
- package/dist/interface/node.d.ts +10 -0
- package/dist/{options-4c64b022.d.ts → interface/options.d.ts} +6 -4
- package/dist/interface/utils.d.ts +4 -0
- package/dist/next-tick.d.ts +3 -1
- package/dist/next-tick.js.map +1 -1
- package/dist/options.d.ts +3 -1
- package/dist/options.js.map +1 -1
- package/dist/perf.d.ts +1 -0
- package/dist/perf.js.map +1 -1
- package/dist/polyfill/array.js.map +1 -1
- package/dist/polyfill/index.d.ts +1 -0
- package/dist/polyfill/index.js.map +1 -1
- package/dist/polyfill/intersection-observer.js +3 -6
- package/dist/polyfill/intersection-observer.js.map +1 -1
- package/dist/polyfill/object.js.map +1 -1
- package/dist/runtime.esm.d.ts +179 -71
- package/dist/runtime.esm.js +61 -45
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/cache.d.ts +1 -0
- package/dist/utils/cache.js.map +1 -1
- package/dist/utils/index.d.ts +7 -7
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lodash.d.ts +2 -1
- package/dist/utils/lodash.js.map +1 -1
- package/dist/utils/router.d.ts +2 -1
- package/dist/utils/router.js.map +1 -1
- package/package.json +11 -8
- package/dist/dom/anchor-element.d.ts +0 -14
- package/dist/dom/style_properties.d.ts +0 -3
- package/dist/dom/transfer.d.ts +0 -8
- package/dist/dom/tree.d.ts +0 -4
- package/dist/dom-external/element.d.ts +0 -4
- package/dist/dom-external/index.d.ts +0 -1
- package/dist/dom-external/inner-html/html.d.ts +0 -3
- package/dist/dom-external/inner-html/scaner.d.ts +0 -30
- package/dist/dom-external/inner-html/style.d.ts +0 -27
- package/dist/dom-external/inner-html/tags.d.ts +0 -9
- package/dist/dom-external/inner-html/utils.d.ts +0 -2
- package/dist/dom-external/node.d.ts +0 -12
- package/dist/index-26658829.d.ts +0 -23
- package/dist/polyfill/array.d.ts +0 -3
- package/dist/polyfill/intersection-observer.d.ts +0 -2
- package/dist/polyfill/object.d.ts +0 -4
package/dist/runtime.esm.js
CHANGED
|
@@ -23,6 +23,7 @@ const FOCUS = 'focus';
|
|
|
23
23
|
const VIEW = 'view';
|
|
24
24
|
const STATIC_VIEW = 'static-view';
|
|
25
25
|
const PURE_VIEW = 'pure-view';
|
|
26
|
+
const CLICK_VIEW = 'click-view';
|
|
26
27
|
const PROPS = 'props';
|
|
27
28
|
const DATASET = 'dataset';
|
|
28
29
|
const OBJECT = 'object';
|
|
@@ -42,7 +43,6 @@ const SET_TIMEOUT = 'setTimeout';
|
|
|
42
43
|
const COMPILE_MODE = 'compileMode';
|
|
43
44
|
const CATCHMOVE = 'catchMove';
|
|
44
45
|
const CATCH_VIEW = 'catch-view';
|
|
45
|
-
const CLICK_VIEW = 'click-view';
|
|
46
46
|
const COMMENT = 'comment';
|
|
47
47
|
const ON_LOAD = 'onLoad';
|
|
48
48
|
const ON_READY = 'onReady';
|
|
@@ -689,7 +689,7 @@ function parseUrl(url = '') {
|
|
|
689
689
|
result.search = matches[10] || '';
|
|
690
690
|
result.hash = matches[12] || '';
|
|
691
691
|
result.href = url;
|
|
692
|
-
result.origin = result.protocol + '//' + result.hostname;
|
|
692
|
+
result.origin = result.protocol + '//' + result.hostname + (result.port ? `:${result.port}` : '');
|
|
693
693
|
result.host = result.hostname + (result.port ? `:${result.port}` : '');
|
|
694
694
|
return result;
|
|
695
695
|
}
|
|
@@ -1335,14 +1335,16 @@ function hydrate(node) {
|
|
|
1335
1335
|
if (node.uid !== node.sid) {
|
|
1336
1336
|
data.uid = node.uid;
|
|
1337
1337
|
}
|
|
1338
|
-
if (
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1338
|
+
if (SPECIAL_NODES.indexOf(nodeName) > -1) {
|
|
1339
|
+
if (!node.isAnyEventBinded()) {
|
|
1340
|
+
data["nn" /* Shortcuts.NodeName */] = `static-${nodeName}`;
|
|
1341
|
+
if (nodeName === VIEW && !isHasExtractProp(node)) {
|
|
1342
|
+
data["nn" /* Shortcuts.NodeName */] = PURE_VIEW;
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
if (nodeName === VIEW && node.isOnlyClickBinded() && !isHasExtractProp(node)) {
|
|
1346
|
+
data["nn" /* Shortcuts.NodeName */] = CLICK_VIEW;
|
|
1342
1347
|
}
|
|
1343
|
-
}
|
|
1344
|
-
if (nodeName === VIEW && node.isOnlyClickBinded()) {
|
|
1345
|
-
data["nn" /* Shortcuts.NodeName */] = CLICK_VIEW;
|
|
1346
1348
|
}
|
|
1347
1349
|
const { props } = node;
|
|
1348
1350
|
for (const prop in props) {
|
|
@@ -1761,6 +1763,7 @@ const WEBKIT = 'webkit';
|
|
|
1761
1763
|
const styleProperties = [
|
|
1762
1764
|
'all',
|
|
1763
1765
|
'appearance',
|
|
1766
|
+
'backdropFilter',
|
|
1764
1767
|
'blockOverflow',
|
|
1765
1768
|
'blockSize',
|
|
1766
1769
|
'bottom',
|
|
@@ -2256,6 +2259,7 @@ class TaroElement extends TaroNode {
|
|
|
2256
2259
|
const componentsAlias = getComponentsAlias();
|
|
2257
2260
|
const _alias = componentsAlias[this.nodeName];
|
|
2258
2261
|
const viewAlias = componentsAlias[VIEW]._num;
|
|
2262
|
+
const clickViewAlias = componentsAlias[CLICK_VIEW]._num;
|
|
2259
2263
|
const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
|
|
2260
2264
|
const catchViewAlias = componentsAlias[CATCH_VIEW]._num;
|
|
2261
2265
|
const _path = this._path;
|
|
@@ -2274,10 +2278,10 @@ class TaroElement extends TaroNode {
|
|
|
2274
2278
|
if (this.nodeName === VIEW) {
|
|
2275
2279
|
if (qualifiedNameInCamelCase === CATCHMOVE) {
|
|
2276
2280
|
// catchMove = true: catch-view
|
|
2277
|
-
// catchMove = false: view or static-view
|
|
2281
|
+
// catchMove = false: view or click-view or static-view
|
|
2278
2282
|
this.enqueueUpdate({
|
|
2279
2283
|
path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
|
|
2280
|
-
value: value ? catchViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias)
|
|
2284
|
+
value: value ? catchViewAlias : (this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias))
|
|
2281
2285
|
});
|
|
2282
2286
|
}
|
|
2283
2287
|
else if (isPureView && isHasExtractProp(this)) {
|
|
@@ -2318,6 +2322,7 @@ class TaroElement extends TaroNode {
|
|
|
2318
2322
|
const viewAlias = componentsAlias[VIEW]._num;
|
|
2319
2323
|
const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
|
|
2320
2324
|
const pureViewAlias = componentsAlias[PURE_VIEW]._num;
|
|
2325
|
+
const clickViewAlias = componentsAlias[CLICK_VIEW]._num;
|
|
2321
2326
|
const _path = this._path;
|
|
2322
2327
|
qualifiedName = shortcutAttr(qualifiedName);
|
|
2323
2328
|
const qualifiedNameInCamelCase = toCamelCase(qualifiedName);
|
|
@@ -2333,10 +2338,10 @@ class TaroElement extends TaroNode {
|
|
|
2333
2338
|
this.enqueueUpdate(payload);
|
|
2334
2339
|
if (this.nodeName === VIEW) {
|
|
2335
2340
|
if (qualifiedNameInCamelCase === CATCHMOVE) {
|
|
2336
|
-
// catch-view => view or static-view or pure-view
|
|
2341
|
+
// catch-view => view or click-view or static-view or pure-view
|
|
2337
2342
|
this.enqueueUpdate({
|
|
2338
2343
|
path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
|
|
2339
|
-
value: this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias)
|
|
2344
|
+
value: this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias))
|
|
2340
2345
|
});
|
|
2341
2346
|
}
|
|
2342
2347
|
else if (isStaticView && !isHasExtractProp(this)) {
|
|
@@ -3120,7 +3125,7 @@ function parser(html, document) {
|
|
|
3120
3125
|
html = styleTagParser.extractStyle(html);
|
|
3121
3126
|
const tokens = new Scaner(html).scan();
|
|
3122
3127
|
const root = { tagName: '', children: [], type: 'element', attributes: [] };
|
|
3123
|
-
const state = { tokens,
|
|
3128
|
+
const state = { tokens, cursor: 0, stack: [root] };
|
|
3124
3129
|
parse(state);
|
|
3125
3130
|
return format(root.children, document, {
|
|
3126
3131
|
styleTagParser,
|
|
@@ -3240,6 +3245,13 @@ function getBoundingClientRectImpl() {
|
|
|
3240
3245
|
return Promise.resolve(null);
|
|
3241
3246
|
return new Promise(resolve => {
|
|
3242
3247
|
const query = options.miniGlobal.createSelectorQuery();
|
|
3248
|
+
// ref: https://opendocs.alipay.com/mini/api/na4yun
|
|
3249
|
+
if (process.env.TARO_ENV === 'alipay') {
|
|
3250
|
+
query.select(`#${this.uid}`).boundingClientRect().exec(res => {
|
|
3251
|
+
resolve(res);
|
|
3252
|
+
});
|
|
3253
|
+
return;
|
|
3254
|
+
}
|
|
3243
3255
|
query.select(`#${this.uid}`).boundingClientRect(res => {
|
|
3244
3256
|
resolve(res);
|
|
3245
3257
|
}).exec();
|
|
@@ -3629,18 +3641,8 @@ class TaroRootElement extends TaroElement {
|
|
|
3629
3641
|
return this;
|
|
3630
3642
|
}
|
|
3631
3643
|
scheduleTask(fn) {
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
.then(fn)
|
|
3635
|
-
.catch((error) => {
|
|
3636
|
-
setTimeout(() => {
|
|
3637
|
-
throw error;
|
|
3638
|
-
});
|
|
3639
|
-
});
|
|
3640
|
-
}
|
|
3641
|
-
else {
|
|
3642
|
-
setTimeout(fn);
|
|
3643
|
-
}
|
|
3644
|
+
// 这里若使用微任务可略微提前setData的执行时机,但在部分场景下可能会出现连续setData两次,造成更大的性能问题
|
|
3645
|
+
setTimeout(fn);
|
|
3644
3646
|
}
|
|
3645
3647
|
enqueueUpdate(payload) {
|
|
3646
3648
|
this.updatePayloads.push(payload);
|
|
@@ -4143,19 +4145,34 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4143
4145
|
}
|
|
4144
4146
|
LIFECYCLES.forEach((lifecycle) => {
|
|
4145
4147
|
let isDefer = false;
|
|
4148
|
+
let isEvent = false;
|
|
4146
4149
|
lifecycle = lifecycle.replace(/^defer:/, () => {
|
|
4147
4150
|
isDefer = true;
|
|
4148
4151
|
return '';
|
|
4149
4152
|
});
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4153
|
+
lifecycle = lifecycle.replace(/^events:/, () => {
|
|
4154
|
+
isEvent = true;
|
|
4155
|
+
return '';
|
|
4156
|
+
});
|
|
4157
|
+
if (isEvent && process.env.TARO_ENV === 'alipay') {
|
|
4158
|
+
// 初始化 config.events 对象
|
|
4159
|
+
if (!config.events)
|
|
4160
|
+
config.events = {};
|
|
4161
|
+
config.events[lifecycle] = function () {
|
|
4162
|
+
return safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
4163
|
+
};
|
|
4164
|
+
}
|
|
4165
|
+
else {
|
|
4166
|
+
config[lifecycle] = function () {
|
|
4167
|
+
const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
4168
|
+
if (isDefer) {
|
|
4169
|
+
hasLoaded.then(exec);
|
|
4170
|
+
}
|
|
4171
|
+
else {
|
|
4172
|
+
return exec();
|
|
4173
|
+
}
|
|
4174
|
+
};
|
|
4175
|
+
}
|
|
4159
4176
|
});
|
|
4160
4177
|
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
|
|
4161
4178
|
SIDE_EFFECT_LIFECYCLES.forEach(lifecycle => {
|
|
@@ -4257,6 +4274,11 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4257
4274
|
}
|
|
4258
4275
|
}
|
|
4259
4276
|
: EMPTY_OBJ;
|
|
4277
|
+
// 不同平台的个性化配置
|
|
4278
|
+
const extraOptions = {};
|
|
4279
|
+
if (process.env.TARO_ENV === 'jd') {
|
|
4280
|
+
extraOptions.addGlobalClass = true;
|
|
4281
|
+
}
|
|
4260
4282
|
return hooks.call('modifyRecursiveComponentConfig', Object.assign({ properties: {
|
|
4261
4283
|
i: {
|
|
4262
4284
|
type: Object,
|
|
@@ -4268,10 +4290,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4268
4290
|
type: String,
|
|
4269
4291
|
value: ''
|
|
4270
4292
|
}
|
|
4271
|
-
}, options: {
|
|
4272
|
-
addGlobalClass: true,
|
|
4273
|
-
virtualHost: !isCustomWrapper
|
|
4274
|
-
}, methods: {
|
|
4293
|
+
}, options: Object.assign(Object.assign({}, extraOptions), { virtualHost: !isCustomWrapper }), methods: {
|
|
4275
4294
|
eh: eventHandler
|
|
4276
4295
|
} }, lifeCycles), { isCustomWrapper });
|
|
4277
4296
|
}
|
|
@@ -4632,10 +4651,7 @@ function handleIntersectionObserverObjectPolyfill() {
|
|
|
4632
4651
|
target: target,
|
|
4633
4652
|
boundingClientRect: targetRect,
|
|
4634
4653
|
rootBounds: rootRect,
|
|
4635
|
-
intersectionRect: intersectionRect
|
|
4636
|
-
intersectionRatio: -1,
|
|
4637
|
-
isIntersecting: false,
|
|
4638
|
-
});
|
|
4654
|
+
intersectionRect: intersectionRect});
|
|
4639
4655
|
if (!oldEntry) {
|
|
4640
4656
|
this._queuedEntries.push(newEntry);
|
|
4641
4657
|
}
|
|
@@ -4835,7 +4851,7 @@ function handleIntersectionObserverObjectPolyfill() {
|
|
|
4835
4851
|
*/
|
|
4836
4852
|
function addEvent(node, event, fn, opt_useCapture) {
|
|
4837
4853
|
if (isFunction(node.addEventListener)) {
|
|
4838
|
-
node.addEventListener(event, fn, opt_useCapture
|
|
4854
|
+
node.addEventListener(event, fn, opt_useCapture);
|
|
4839
4855
|
}
|
|
4840
4856
|
else if (isFunction(node.attachEvent)) {
|
|
4841
4857
|
node.attachEvent('on' + event, fn);
|
|
@@ -4851,7 +4867,7 @@ function handleIntersectionObserverObjectPolyfill() {
|
|
|
4851
4867
|
*/
|
|
4852
4868
|
function removeEvent(node, event, fn, opt_useCapture) {
|
|
4853
4869
|
if (isFunction(node.removeEventListener)) {
|
|
4854
|
-
node.removeEventListener(event, fn, opt_useCapture
|
|
4870
|
+
node.removeEventListener(event, fn, opt_useCapture);
|
|
4855
4871
|
}
|
|
4856
4872
|
else if (isFunction(node.detatchEvent)) {
|
|
4857
4873
|
node.detatchEvent('on' + event, fn);
|