@tarojs/runtime 4.2.2-alpha.1 → 4.2.2-alpha.2
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/dom/node.d.ts +1 -3
- package/dist/dom/node.js +0 -10
- package/dist/dom/node.js.map +1 -1
- package/dist/dom/root.d.ts +0 -2
- package/dist/dom/root.js +0 -4
- package/dist/dom/root.js.map +1 -1
- package/dist/dsl/common.d.ts +1 -1
- package/dist/dsl/common.js +9 -18
- package/dist/dsl/common.js.map +1 -1
- package/dist/index.cjs.d.ts +2 -9
- package/dist/index.cjs.js +9 -80
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.esm.d.ts +2 -9
- package/dist/runtime.esm.js +10 -78
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/dom/nearest-ctx.d.ts +0 -9
- package/dist/dom/nearest-ctx.js +0 -49
- package/dist/dom/nearest-ctx.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1473,53 +1473,6 @@ class TaroEventTarget {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
}
|
|
1475
1475
|
|
|
1476
|
-
const nearestCtxCache = new WeakMap();
|
|
1477
|
-
function isNearestCtxEnv() {
|
|
1478
|
-
return process.env.TARO_ENV === 'weapp' || process.env.TARO_ENV === 'jd';
|
|
1479
|
-
}
|
|
1480
|
-
function getNearestCtx(node) {
|
|
1481
|
-
if (!isNearestCtxEnv()) {
|
|
1482
|
-
return undefined;
|
|
1483
|
-
}
|
|
1484
|
-
const root = node._root;
|
|
1485
|
-
if (root == null) {
|
|
1486
|
-
return null;
|
|
1487
|
-
}
|
|
1488
|
-
const cached = nearestCtxCache.get(node);
|
|
1489
|
-
if (cached && cached.nearestCtxEpoch === root.nearestCtxEpoch) {
|
|
1490
|
-
return cached.value;
|
|
1491
|
-
}
|
|
1492
|
-
const value = resolveNearestCtxValue(node, root);
|
|
1493
|
-
nearestCtxCache.set(node, { value, nearestCtxEpoch: root.nearestCtxEpoch });
|
|
1494
|
-
return value;
|
|
1495
|
-
}
|
|
1496
|
-
function resolveNearestCtxValue(node, root) {
|
|
1497
|
-
var _a;
|
|
1498
|
-
if (node.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
|
|
1499
|
-
const ctx = node.ctx;
|
|
1500
|
-
if (ctx != null)
|
|
1501
|
-
return ctx;
|
|
1502
|
-
}
|
|
1503
|
-
let current = node.parentNode;
|
|
1504
|
-
while (current) {
|
|
1505
|
-
if (current.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
|
|
1506
|
-
const ctx = current.ctx;
|
|
1507
|
-
if (ctx != null)
|
|
1508
|
-
return ctx;
|
|
1509
|
-
}
|
|
1510
|
-
current = current.parentNode;
|
|
1511
|
-
}
|
|
1512
|
-
return (_a = root.ctx) !== null && _a !== void 0 ? _a : null;
|
|
1513
|
-
}
|
|
1514
|
-
function bumpNearestCtxEpochForRoot(root) {
|
|
1515
|
-
if (!isNearestCtxEnv() || root == null) {
|
|
1516
|
-
return;
|
|
1517
|
-
}
|
|
1518
|
-
if (typeof root.bumpNearestCtxEpoch === 'function') {
|
|
1519
|
-
root.bumpNearestCtxEpoch();
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
1476
|
const CHILDNODES = "cn" /* Shortcuts.Childnodes */;
|
|
1524
1477
|
const nodeId = incrementId();
|
|
1525
1478
|
class TaroNode extends TaroEventTarget {
|
|
@@ -1559,9 +1512,6 @@ class TaroNode extends TaroEventTarget {
|
|
|
1559
1512
|
var _a;
|
|
1560
1513
|
return ((_a = this.parentNode) === null || _a === void 0 ? void 0 : _a._root) || null;
|
|
1561
1514
|
}
|
|
1562
|
-
get _scope() {
|
|
1563
|
-
return getNearestCtx(this);
|
|
1564
|
-
}
|
|
1565
1515
|
findIndex(refChild) {
|
|
1566
1516
|
const index = this.childNodes.indexOf(refChild);
|
|
1567
1517
|
shared.ensure(index !== -1, 'The node to be replaced is not a child of this node.');
|
|
@@ -1707,9 +1657,6 @@ class TaroNode extends TaroEventTarget {
|
|
|
1707
1657
|
}
|
|
1708
1658
|
}
|
|
1709
1659
|
}
|
|
1710
|
-
if (this._root) {
|
|
1711
|
-
bumpNearestCtxEpochForRoot(this._root);
|
|
1712
|
-
}
|
|
1713
1660
|
MutationObserver$1.record({
|
|
1714
1661
|
type: "childList" /* MutationRecordType.CHILD_LIST */,
|
|
1715
1662
|
target: this,
|
|
@@ -1786,9 +1733,6 @@ class TaroNode extends TaroEventTarget {
|
|
|
1786
1733
|
if (this._root && doUpdate !== false) {
|
|
1787
1734
|
this.updateChildNodes();
|
|
1788
1735
|
}
|
|
1789
|
-
if (this._root) {
|
|
1790
|
-
bumpNearestCtxEpochForRoot(this._root);
|
|
1791
|
-
}
|
|
1792
1736
|
return child;
|
|
1793
1737
|
}
|
|
1794
1738
|
remove(options) {
|
|
@@ -3700,7 +3644,6 @@ class TaroRootElement extends TaroElement {
|
|
|
3700
3644
|
this.updateCallbacks = [];
|
|
3701
3645
|
this.pendingUpdate = false;
|
|
3702
3646
|
this.ctx = null;
|
|
3703
|
-
this.nearestCtxEpoch = 0;
|
|
3704
3647
|
this.nodeName = ROOT_STR;
|
|
3705
3648
|
this.tagName = ROOT_STR.toUpperCase();
|
|
3706
3649
|
}
|
|
@@ -3710,9 +3653,6 @@ class TaroRootElement extends TaroElement {
|
|
|
3710
3653
|
get _root() {
|
|
3711
3654
|
return this;
|
|
3712
3655
|
}
|
|
3713
|
-
bumpNearestCtxEpoch() {
|
|
3714
|
-
this.nearestCtxEpoch++;
|
|
3715
|
-
}
|
|
3716
3656
|
scheduleTask(fn) {
|
|
3717
3657
|
// 这里若使用微任务可略微提前setData的执行时机,但在部分场景下可能会出现连续setData两次,造成更大的性能问题
|
|
3718
3658
|
setTimeout(fn);
|
|
@@ -4277,7 +4217,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4277
4217
|
loadResolver();
|
|
4278
4218
|
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4279
4219
|
pageElement.ctx = this;
|
|
4280
|
-
bumpNearestCtxEpochForRoot(pageElement);
|
|
4281
4220
|
if (process.env.TARO_ENV === 'tt' && shared.isEnableTTDom()) {
|
|
4282
4221
|
pageElement.sync();
|
|
4283
4222
|
}
|
|
@@ -4310,7 +4249,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4310
4249
|
unmounting = false;
|
|
4311
4250
|
instances.delete($taroPath);
|
|
4312
4251
|
if (pageElement) {
|
|
4313
|
-
bumpNearestCtxEpochForRoot(pageElement);
|
|
4314
4252
|
pageElement.ctx = null;
|
|
4315
4253
|
pageElement = null;
|
|
4316
4254
|
}
|
|
@@ -4473,42 +4411,36 @@ function createComponentConfig(component, componentName, data) {
|
|
|
4473
4411
|
});
|
|
4474
4412
|
return config;
|
|
4475
4413
|
}
|
|
4476
|
-
function createRecursiveComponentConfig(componentName
|
|
4414
|
+
function createRecursiveComponentConfig(componentName) {
|
|
4477
4415
|
const isCustomWrapper = componentName === CUSTOM_WRAPPER;
|
|
4478
4416
|
const [ATTACHED, DETACHED] = shared.hooks.call('getMiniLifecycleImpl').component;
|
|
4479
|
-
const lifeCycles = isCustomWrapper
|
|
4417
|
+
const lifeCycles = isCustomWrapper
|
|
4480
4418
|
? {
|
|
4481
4419
|
[ATTACHED]() {
|
|
4482
|
-
var _a, _b
|
|
4420
|
+
var _a, _b;
|
|
4483
4421
|
if (process.env.TARO_ENV === 'tt' && shared.isEnableTTDom()) {
|
|
4484
4422
|
return;
|
|
4485
4423
|
}
|
|
4486
|
-
const componentId = ((
|
|
4424
|
+
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);
|
|
4487
4425
|
if (shared.isString(componentId)) {
|
|
4488
|
-
|
|
4489
|
-
customWrapperCache.set(componentId, this);
|
|
4490
|
-
}
|
|
4426
|
+
customWrapperCache.set(componentId, this);
|
|
4491
4427
|
const el = env.document.getElementById(componentId);
|
|
4492
4428
|
if (el) {
|
|
4493
4429
|
el.ctx = this;
|
|
4494
|
-
bumpNearestCtxEpochForRoot(el._root);
|
|
4495
4430
|
}
|
|
4496
4431
|
}
|
|
4497
4432
|
},
|
|
4498
4433
|
[DETACHED]() {
|
|
4499
|
-
var _a, _b
|
|
4434
|
+
var _a, _b;
|
|
4500
4435
|
if (process.env.TARO_ENV === 'tt' && shared.isEnableTTDom()) {
|
|
4501
4436
|
return;
|
|
4502
4437
|
}
|
|
4503
|
-
const componentId = ((
|
|
4438
|
+
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);
|
|
4504
4439
|
if (shared.isString(componentId)) {
|
|
4505
|
-
|
|
4506
|
-
customWrapperCache.delete(componentId);
|
|
4507
|
-
}
|
|
4440
|
+
customWrapperCache.delete(componentId);
|
|
4508
4441
|
const el = env.document.getElementById(componentId);
|
|
4509
4442
|
if (el) {
|
|
4510
4443
|
el.ctx = null;
|
|
4511
|
-
bumpNearestCtxEpochForRoot(el._root);
|
|
4512
4444
|
}
|
|
4513
4445
|
}
|
|
4514
4446
|
}
|
|
@@ -4532,7 +4464,7 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
|
|
|
4532
4464
|
}
|
|
4533
4465
|
}, options: Object.assign(Object.assign({}, extraOptions), { virtualHost: !isCustomWrapper }), methods: {
|
|
4534
4466
|
eh: eventHandler
|
|
4535
|
-
} }, lifeCycles), { isCustomWrapper
|
|
4467
|
+
} }, lifeCycles), { isCustomWrapper });
|
|
4536
4468
|
}
|
|
4537
4469
|
|
|
4538
4470
|
const TIMEOUT = 100;
|
|
@@ -5418,7 +5350,6 @@ exports.URLSearchParams = URLSearchParams;
|
|
|
5418
5350
|
exports.VALUE = VALUE;
|
|
5419
5351
|
exports.VIEW = VIEW;
|
|
5420
5352
|
exports.addLeadingSlash = addLeadingSlash;
|
|
5421
|
-
exports.bumpNearestCtxEpochForRoot = bumpNearestCtxEpochForRoot;
|
|
5422
5353
|
exports.cancelAnimationFrame = _caf;
|
|
5423
5354
|
exports.convertNumber2PX = convertNumber2PX;
|
|
5424
5355
|
exports.createComponentConfig = createComponentConfig;
|
|
@@ -5439,7 +5370,6 @@ exports.getComputedStyle = taroGetComputedStyleProvider;
|
|
|
5439
5370
|
exports.getCurrentInstance = getCurrentInstance;
|
|
5440
5371
|
exports.getCurrentPage = getCurrentPage;
|
|
5441
5372
|
exports.getHomePage = getHomePage;
|
|
5442
|
-
exports.getNearestCtx = getNearestCtx;
|
|
5443
5373
|
exports.getOnHideEventKey = getOnHideEventKey;
|
|
5444
5374
|
exports.getOnReadyEventKey = getOnReadyEventKey;
|
|
5445
5375
|
exports.getOnShowEventKey = getOnShowEventKey;
|
|
@@ -5454,7 +5384,6 @@ exports.injectPageInstance = injectPageInstance;
|
|
|
5454
5384
|
exports.isComment = isComment;
|
|
5455
5385
|
exports.isElement = isElement;
|
|
5456
5386
|
exports.isHasExtractProp = isHasExtractProp;
|
|
5457
|
-
exports.isNearestCtxEnv = isNearestCtxEnv;
|
|
5458
5387
|
exports.isParentBound = isParentBound;
|
|
5459
5388
|
exports.isText = isText;
|
|
5460
5389
|
exports.location = taroLocationProvider;
|