@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/index.cjs.js
CHANGED
|
@@ -24,6 +24,7 @@ const FOCUS = 'focus';
|
|
|
24
24
|
const VIEW = 'view';
|
|
25
25
|
const STATIC_VIEW = 'static-view';
|
|
26
26
|
const PURE_VIEW = 'pure-view';
|
|
27
|
+
const CLICK_VIEW = 'click-view';
|
|
27
28
|
const PROPS = 'props';
|
|
28
29
|
const DATASET = 'dataset';
|
|
29
30
|
const OBJECT = 'object';
|
|
@@ -43,7 +44,6 @@ const SET_TIMEOUT = 'setTimeout';
|
|
|
43
44
|
const COMPILE_MODE = 'compileMode';
|
|
44
45
|
const CATCHMOVE = 'catchMove';
|
|
45
46
|
const CATCH_VIEW = 'catch-view';
|
|
46
|
-
const CLICK_VIEW = 'click-view';
|
|
47
47
|
const COMMENT = 'comment';
|
|
48
48
|
const ON_LOAD = 'onLoad';
|
|
49
49
|
const ON_READY = 'onReady';
|
|
@@ -690,7 +690,7 @@ function parseUrl(url = '') {
|
|
|
690
690
|
result.search = matches[10] || '';
|
|
691
691
|
result.hash = matches[12] || '';
|
|
692
692
|
result.href = url;
|
|
693
|
-
result.origin = result.protocol + '//' + result.hostname;
|
|
693
|
+
result.origin = result.protocol + '//' + result.hostname + (result.port ? `:${result.port}` : '');
|
|
694
694
|
result.host = result.hostname + (result.port ? `:${result.port}` : '');
|
|
695
695
|
return result;
|
|
696
696
|
}
|
|
@@ -1336,14 +1336,16 @@ function hydrate(node) {
|
|
|
1336
1336
|
if (node.uid !== node.sid) {
|
|
1337
1337
|
data.uid = node.uid;
|
|
1338
1338
|
}
|
|
1339
|
-
if (
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1339
|
+
if (SPECIAL_NODES.indexOf(nodeName) > -1) {
|
|
1340
|
+
if (!node.isAnyEventBinded()) {
|
|
1341
|
+
data["nn" /* Shortcuts.NodeName */] = `static-${nodeName}`;
|
|
1342
|
+
if (nodeName === VIEW && !isHasExtractProp(node)) {
|
|
1343
|
+
data["nn" /* Shortcuts.NodeName */] = PURE_VIEW;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
if (nodeName === VIEW && node.isOnlyClickBinded() && !isHasExtractProp(node)) {
|
|
1347
|
+
data["nn" /* Shortcuts.NodeName */] = CLICK_VIEW;
|
|
1343
1348
|
}
|
|
1344
|
-
}
|
|
1345
|
-
if (nodeName === VIEW && node.isOnlyClickBinded()) {
|
|
1346
|
-
data["nn" /* Shortcuts.NodeName */] = CLICK_VIEW;
|
|
1347
1349
|
}
|
|
1348
1350
|
const { props } = node;
|
|
1349
1351
|
for (const prop in props) {
|
|
@@ -1762,6 +1764,7 @@ const WEBKIT = 'webkit';
|
|
|
1762
1764
|
const styleProperties = [
|
|
1763
1765
|
'all',
|
|
1764
1766
|
'appearance',
|
|
1767
|
+
'backdropFilter',
|
|
1765
1768
|
'blockOverflow',
|
|
1766
1769
|
'blockSize',
|
|
1767
1770
|
'bottom',
|
|
@@ -2257,6 +2260,7 @@ class TaroElement extends TaroNode {
|
|
|
2257
2260
|
const componentsAlias = getComponentsAlias();
|
|
2258
2261
|
const _alias = componentsAlias[this.nodeName];
|
|
2259
2262
|
const viewAlias = componentsAlias[VIEW]._num;
|
|
2263
|
+
const clickViewAlias = componentsAlias[CLICK_VIEW]._num;
|
|
2260
2264
|
const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
|
|
2261
2265
|
const catchViewAlias = componentsAlias[CATCH_VIEW]._num;
|
|
2262
2266
|
const _path = this._path;
|
|
@@ -2275,10 +2279,10 @@ class TaroElement extends TaroNode {
|
|
|
2275
2279
|
if (this.nodeName === VIEW) {
|
|
2276
2280
|
if (qualifiedNameInCamelCase === CATCHMOVE) {
|
|
2277
2281
|
// catchMove = true: catch-view
|
|
2278
|
-
// catchMove = false: view or static-view
|
|
2282
|
+
// catchMove = false: view or click-view or static-view
|
|
2279
2283
|
this.enqueueUpdate({
|
|
2280
2284
|
path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
|
|
2281
|
-
value: value ? catchViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias)
|
|
2285
|
+
value: value ? catchViewAlias : (this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias))
|
|
2282
2286
|
});
|
|
2283
2287
|
}
|
|
2284
2288
|
else if (isPureView && isHasExtractProp(this)) {
|
|
@@ -2319,6 +2323,7 @@ class TaroElement extends TaroNode {
|
|
|
2319
2323
|
const viewAlias = componentsAlias[VIEW]._num;
|
|
2320
2324
|
const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
|
|
2321
2325
|
const pureViewAlias = componentsAlias[PURE_VIEW]._num;
|
|
2326
|
+
const clickViewAlias = componentsAlias[CLICK_VIEW]._num;
|
|
2322
2327
|
const _path = this._path;
|
|
2323
2328
|
qualifiedName = shortcutAttr(qualifiedName);
|
|
2324
2329
|
const qualifiedNameInCamelCase = shared.toCamelCase(qualifiedName);
|
|
@@ -2334,10 +2339,10 @@ class TaroElement extends TaroNode {
|
|
|
2334
2339
|
this.enqueueUpdate(payload);
|
|
2335
2340
|
if (this.nodeName === VIEW) {
|
|
2336
2341
|
if (qualifiedNameInCamelCase === CATCHMOVE) {
|
|
2337
|
-
// catch-view => view or static-view or pure-view
|
|
2342
|
+
// catch-view => view or click-view or static-view or pure-view
|
|
2338
2343
|
this.enqueueUpdate({
|
|
2339
2344
|
path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
|
|
2340
|
-
value: this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias)
|
|
2345
|
+
value: this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias))
|
|
2341
2346
|
});
|
|
2342
2347
|
}
|
|
2343
2348
|
else if (isStaticView && !isHasExtractProp(this)) {
|
|
@@ -3121,7 +3126,7 @@ function parser(html, document) {
|
|
|
3121
3126
|
html = styleTagParser.extractStyle(html);
|
|
3122
3127
|
const tokens = new Scaner(html).scan();
|
|
3123
3128
|
const root = { tagName: '', children: [], type: 'element', attributes: [] };
|
|
3124
|
-
const state = { tokens,
|
|
3129
|
+
const state = { tokens, cursor: 0, stack: [root] };
|
|
3125
3130
|
parse(state);
|
|
3126
3131
|
return format(root.children, document, {
|
|
3127
3132
|
styleTagParser,
|
|
@@ -3241,6 +3246,13 @@ function getBoundingClientRectImpl() {
|
|
|
3241
3246
|
return Promise.resolve(null);
|
|
3242
3247
|
return new Promise(resolve => {
|
|
3243
3248
|
const query = options.miniGlobal.createSelectorQuery();
|
|
3249
|
+
// ref: https://opendocs.alipay.com/mini/api/na4yun
|
|
3250
|
+
if (process.env.TARO_ENV === 'alipay') {
|
|
3251
|
+
query.select(`#${this.uid}`).boundingClientRect().exec(res => {
|
|
3252
|
+
resolve(res);
|
|
3253
|
+
});
|
|
3254
|
+
return;
|
|
3255
|
+
}
|
|
3244
3256
|
query.select(`#${this.uid}`).boundingClientRect(res => {
|
|
3245
3257
|
resolve(res);
|
|
3246
3258
|
}).exec();
|
|
@@ -3630,18 +3642,8 @@ class TaroRootElement extends TaroElement {
|
|
|
3630
3642
|
return this;
|
|
3631
3643
|
}
|
|
3632
3644
|
scheduleTask(fn) {
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
.then(fn)
|
|
3636
|
-
.catch((error) => {
|
|
3637
|
-
setTimeout(() => {
|
|
3638
|
-
throw error;
|
|
3639
|
-
});
|
|
3640
|
-
});
|
|
3641
|
-
}
|
|
3642
|
-
else {
|
|
3643
|
-
setTimeout(fn);
|
|
3644
|
-
}
|
|
3645
|
+
// 这里若使用微任务可略微提前setData的执行时机,但在部分场景下可能会出现连续setData两次,造成更大的性能问题
|
|
3646
|
+
setTimeout(fn);
|
|
3645
3647
|
}
|
|
3646
3648
|
enqueueUpdate(payload) {
|
|
3647
3649
|
this.updatePayloads.push(payload);
|
|
@@ -4144,19 +4146,34 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4144
4146
|
}
|
|
4145
4147
|
LIFECYCLES.forEach((lifecycle) => {
|
|
4146
4148
|
let isDefer = false;
|
|
4149
|
+
let isEvent = false;
|
|
4147
4150
|
lifecycle = lifecycle.replace(/^defer:/, () => {
|
|
4148
4151
|
isDefer = true;
|
|
4149
4152
|
return '';
|
|
4150
4153
|
});
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4154
|
+
lifecycle = lifecycle.replace(/^events:/, () => {
|
|
4155
|
+
isEvent = true;
|
|
4156
|
+
return '';
|
|
4157
|
+
});
|
|
4158
|
+
if (isEvent && process.env.TARO_ENV === 'alipay') {
|
|
4159
|
+
// 初始化 config.events 对象
|
|
4160
|
+
if (!config.events)
|
|
4161
|
+
config.events = {};
|
|
4162
|
+
config.events[lifecycle] = function () {
|
|
4163
|
+
return safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
4164
|
+
};
|
|
4165
|
+
}
|
|
4166
|
+
else {
|
|
4167
|
+
config[lifecycle] = function () {
|
|
4168
|
+
const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
|
|
4169
|
+
if (isDefer) {
|
|
4170
|
+
hasLoaded.then(exec);
|
|
4171
|
+
}
|
|
4172
|
+
else {
|
|
4173
|
+
return exec();
|
|
4174
|
+
}
|
|
4175
|
+
};
|
|
4176
|
+
}
|
|
4160
4177
|
});
|
|
4161
4178
|
// onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
|
|
4162
4179
|
SIDE_EFFECT_LIFECYCLES.forEach(lifecycle => {
|
|
@@ -4258,6 +4275,11 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4258
4275
|
}
|
|
4259
4276
|
}
|
|
4260
4277
|
: shared.EMPTY_OBJ;
|
|
4278
|
+
// 不同平台的个性化配置
|
|
4279
|
+
const extraOptions = {};
|
|
4280
|
+
if (process.env.TARO_ENV === 'jd') {
|
|
4281
|
+
extraOptions.addGlobalClass = true;
|
|
4282
|
+
}
|
|
4261
4283
|
return shared.hooks.call('modifyRecursiveComponentConfig', Object.assign({ properties: {
|
|
4262
4284
|
i: {
|
|
4263
4285
|
type: Object,
|
|
@@ -4269,10 +4291,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4269
4291
|
type: String,
|
|
4270
4292
|
value: ''
|
|
4271
4293
|
}
|
|
4272
|
-
}, options: {
|
|
4273
|
-
addGlobalClass: true,
|
|
4274
|
-
virtualHost: !isCustomWrapper
|
|
4275
|
-
}, methods: {
|
|
4294
|
+
}, options: Object.assign(Object.assign({}, extraOptions), { virtualHost: !isCustomWrapper }), methods: {
|
|
4276
4295
|
eh: eventHandler
|
|
4277
4296
|
} }, lifeCycles), { isCustomWrapper });
|
|
4278
4297
|
}
|
|
@@ -4633,10 +4652,7 @@ function handleIntersectionObserverObjectPolyfill() {
|
|
|
4633
4652
|
target: target,
|
|
4634
4653
|
boundingClientRect: targetRect,
|
|
4635
4654
|
rootBounds: rootRect,
|
|
4636
|
-
intersectionRect: intersectionRect
|
|
4637
|
-
intersectionRatio: -1,
|
|
4638
|
-
isIntersecting: false,
|
|
4639
|
-
});
|
|
4655
|
+
intersectionRect: intersectionRect});
|
|
4640
4656
|
if (!oldEntry) {
|
|
4641
4657
|
this._queuedEntries.push(newEntry);
|
|
4642
4658
|
}
|
|
@@ -4836,7 +4852,7 @@ function handleIntersectionObserverObjectPolyfill() {
|
|
|
4836
4852
|
*/
|
|
4837
4853
|
function addEvent(node, event, fn, opt_useCapture) {
|
|
4838
4854
|
if (shared.isFunction(node.addEventListener)) {
|
|
4839
|
-
node.addEventListener(event, fn, opt_useCapture
|
|
4855
|
+
node.addEventListener(event, fn, opt_useCapture);
|
|
4840
4856
|
}
|
|
4841
4857
|
else if (shared.isFunction(node.attachEvent)) {
|
|
4842
4858
|
node.attachEvent('on' + event, fn);
|
|
@@ -4852,7 +4868,7 @@ function handleIntersectionObserverObjectPolyfill() {
|
|
|
4852
4868
|
*/
|
|
4853
4869
|
function removeEvent(node, event, fn, opt_useCapture) {
|
|
4854
4870
|
if (shared.isFunction(node.removeEventListener)) {
|
|
4855
|
-
node.removeEventListener(event, fn, opt_useCapture
|
|
4871
|
+
node.removeEventListener(event, fn, opt_useCapture);
|
|
4856
4872
|
}
|
|
4857
4873
|
else if (shared.isFunction(node.detatchEvent)) {
|
|
4858
4874
|
node.detatchEvent('on' + event, fn);
|
|
@@ -5090,12 +5106,12 @@ if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFOR
|
|
|
5090
5106
|
}
|
|
5091
5107
|
|
|
5092
5108
|
Object.defineProperty(exports, "Events", {
|
|
5093
|
-
|
|
5094
|
-
|
|
5109
|
+
enumerable: true,
|
|
5110
|
+
get: function () { return shared.Events; }
|
|
5095
5111
|
});
|
|
5096
5112
|
Object.defineProperty(exports, "hooks", {
|
|
5097
|
-
|
|
5098
|
-
|
|
5113
|
+
enumerable: true,
|
|
5114
|
+
get: function () { return shared.hooks; }
|
|
5099
5115
|
});
|
|
5100
5116
|
exports.A = A;
|
|
5101
5117
|
exports.APP = APP;
|