@farm.js/react 0.1.0-beta.12 → 0.1.0-beta.13
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/README.md +3 -3
- package/dist/compiler-runtime.cjs +160 -36
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +3 -1
- package/dist/compiler-runtime.d.ts +3 -1
- package/dist/compiler-runtime.mjs +160 -36
- package/dist/compiler-runtime.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,9 +41,9 @@ automatic and does not add a configuration option or asynchronous runtime loadin
|
|
|
41
41
|
definitions, while generated code uses the tree-shakable feature entry.
|
|
42
42
|
|
|
43
43
|
The persisted production-size fixtures and regression gate live in
|
|
44
|
-
[`RUNTIME_SIZE_RESULTS.md`](./RUNTIME_SIZE_RESULTS.md). The recorded
|
|
45
|
-
|
|
46
|
-
application removes 6,185 gzip bytes from its previous compiler-on build.
|
|
44
|
+
[`RUNTIME_SIZE_RESULTS.md`](./RUNTIME_SIZE_RESULTS.md). The recorded compiler-selected core runtime
|
|
45
|
+
premium is 85.4% smaller than the complete compatibility runtime premium; the feature-heavy keyed
|
|
46
|
+
benchmark application removes 6,185 gzip bytes from its previous compiler-on build.
|
|
47
47
|
|
|
48
48
|
For selective adoption, use annotation mode:
|
|
49
49
|
|
|
@@ -1748,8 +1748,18 @@ function createConditionalBlockComponent(owner) {
|
|
|
1748
1748
|
class FarmConditionalBlock extends React__default.default.Component {
|
|
1749
1749
|
constructor() {
|
|
1750
1750
|
super(...arguments);
|
|
1751
|
+
this.root = null;
|
|
1751
1752
|
this.captureRoot = (root) => {
|
|
1753
|
+
const previousRoot = this.root;
|
|
1754
|
+
const previousId = this.rootId;
|
|
1755
|
+
this.root = root;
|
|
1756
|
+
if (!root) {
|
|
1757
|
+
if (previousId !== void 0) owner.setRoot(previousId, null, previousRoot);
|
|
1758
|
+
this.rootId = void 0;
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1752
1761
|
owner.setRoot(this.props.id, root);
|
|
1762
|
+
this.rootId = this.props.id;
|
|
1753
1763
|
};
|
|
1754
1764
|
this.refresh = (afterCommit) => {
|
|
1755
1765
|
this.forceUpdate(afterCommit);
|
|
@@ -1764,7 +1774,11 @@ function createConditionalBlockComponent(owner) {
|
|
|
1764
1774
|
componentDidUpdate(previous) {
|
|
1765
1775
|
if (previous.id === this.props.id) return;
|
|
1766
1776
|
this.unsubscribe?.();
|
|
1767
|
-
|
|
1777
|
+
if (this.root && this.rootId !== this.props.id) {
|
|
1778
|
+
if (this.rootId !== void 0) owner.setRoot(this.rootId, null, this.root);
|
|
1779
|
+
owner.setRoot(this.props.id, this.root);
|
|
1780
|
+
this.rootId = this.props.id;
|
|
1781
|
+
}
|
|
1768
1782
|
this.subscribe();
|
|
1769
1783
|
}
|
|
1770
1784
|
componentWillUnmount() {
|
|
@@ -3257,6 +3271,7 @@ function createHostConditionalBlockComponent(owner) {
|
|
|
3257
3271
|
this.fallbackKeysWereUnsafe = false;
|
|
3258
3272
|
this.activeBranch = null;
|
|
3259
3273
|
this.instance = null;
|
|
3274
|
+
this.definitionVersion = owner.getDefinitionVersion?.();
|
|
3260
3275
|
this.requestNestedFallback = () => {
|
|
3261
3276
|
this.instance?.scope?.cleanup();
|
|
3262
3277
|
this.activateFallback();
|
|
@@ -3305,6 +3320,7 @@ function createHostConditionalBlockComponent(owner) {
|
|
|
3305
3320
|
if (selection.kind === "fallback") return false;
|
|
3306
3321
|
if (selection.kind === "empty") {
|
|
3307
3322
|
if (this.root.childNodes.length !== 0) return false;
|
|
3323
|
+
this.instance?.scope?.cleanup();
|
|
3308
3324
|
this.activeBranch = null;
|
|
3309
3325
|
this.instance = null;
|
|
3310
3326
|
return true;
|
|
@@ -3323,6 +3339,7 @@ function createHostConditionalBlockComponent(owner) {
|
|
|
3323
3339
|
this.requestNestedFallback
|
|
3324
3340
|
);
|
|
3325
3341
|
if (!instance) return false;
|
|
3342
|
+
this.instance?.scope?.cleanup();
|
|
3326
3343
|
this.activeBranch = selection.key;
|
|
3327
3344
|
this.instance = instance;
|
|
3328
3345
|
return true;
|
|
@@ -3401,35 +3418,58 @@ function createHostConditionalBlockComponent(owner) {
|
|
|
3401
3418
|
this.instance = instance;
|
|
3402
3419
|
afterCommit?.();
|
|
3403
3420
|
}
|
|
3421
|
+
listen() {
|
|
3422
|
+
const id = this.currentProps.id;
|
|
3423
|
+
const stop = this.stop;
|
|
3424
|
+
if (this.id === id) return;
|
|
3425
|
+
stop?.();
|
|
3426
|
+
this.stop = owner.subscribe(id, this.refresh);
|
|
3427
|
+
this.id = id;
|
|
3428
|
+
}
|
|
3404
3429
|
schedulePropSync() {
|
|
3405
3430
|
if (this.propSyncQueued) return;
|
|
3406
3431
|
this.propSyncQueued = true;
|
|
3407
3432
|
queueMicrotask(() => {
|
|
3408
3433
|
this.propSyncQueued = false;
|
|
3409
|
-
if (this.mounted && !this.state.fallback)
|
|
3434
|
+
if (this.mounted && !this.state.fallback) {
|
|
3435
|
+
this.listen();
|
|
3436
|
+
this.reconcile();
|
|
3437
|
+
}
|
|
3410
3438
|
});
|
|
3411
3439
|
}
|
|
3412
3440
|
shouldComponentUpdate(nextProps, nextState) {
|
|
3441
|
+
const definitionChanged = this.definitionVersion !== owner.getDefinitionVersion?.();
|
|
3413
3442
|
this.currentProps = nextProps;
|
|
3414
3443
|
if (this.state.fallback && nextState.fallback) this.prepareFallbackUpdate();
|
|
3415
3444
|
if (nextState.fallback || this.state.fallback) return true;
|
|
3445
|
+
if (definitionChanged) return true;
|
|
3416
3446
|
this.schedulePropSync();
|
|
3417
3447
|
return false;
|
|
3418
3448
|
}
|
|
3419
3449
|
componentDidMount() {
|
|
3420
3450
|
this.mounted = true;
|
|
3421
|
-
this.
|
|
3451
|
+
this.listen();
|
|
3422
3452
|
if (this.state.fallback || this.fallbackRequested) {
|
|
3423
3453
|
this.subscribeFallbackDescendants();
|
|
3424
3454
|
this.fallbackKeysWereUnsafe = this.hasUnsafeFallbackKeys();
|
|
3425
3455
|
} else if (!this.adopt()) this.activateFallback();
|
|
3426
3456
|
}
|
|
3427
3457
|
componentDidUpdate() {
|
|
3428
|
-
|
|
3458
|
+
this.listen();
|
|
3459
|
+
const nextDefinitionVersion = owner.getDefinitionVersion?.();
|
|
3460
|
+
const definitionChanged = this.definitionVersion !== nextDefinitionVersion;
|
|
3461
|
+
this.definitionVersion = nextDefinitionVersion;
|
|
3462
|
+
if (this.state.fallback) {
|
|
3463
|
+
this.subscribeFallbackDescendants();
|
|
3464
|
+
} else if (definitionChanged && !this.adopt()) {
|
|
3465
|
+
this.activateFallback();
|
|
3466
|
+
}
|
|
3429
3467
|
}
|
|
3430
3468
|
componentWillUnmount() {
|
|
3431
3469
|
this.mounted = false;
|
|
3432
|
-
this.
|
|
3470
|
+
const stop = this.stop;
|
|
3471
|
+
stop?.();
|
|
3472
|
+
this.id = void 0;
|
|
3433
3473
|
clearCompilerFallbackSubscriptions(this.fallbackUnsubscribers);
|
|
3434
3474
|
this.fallbackKeysWereUnsafe = false;
|
|
3435
3475
|
this.instance?.scope?.cleanup();
|
|
@@ -3468,6 +3508,7 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3468
3508
|
this.rangeInstances = [];
|
|
3469
3509
|
this.staticSegments = [];
|
|
3470
3510
|
this.staticValues = [];
|
|
3511
|
+
this.definitionVersion = owner.getDefinitionVersion?.();
|
|
3471
3512
|
this.requestNestedFallback = () => {
|
|
3472
3513
|
for (const instance of this.rangeInstances) instance?.host.scope?.cleanup();
|
|
3473
3514
|
this.activateFallback();
|
|
@@ -3534,6 +3575,7 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3534
3575
|
const elements = [...this.root.children];
|
|
3535
3576
|
const staticSegments = [];
|
|
3536
3577
|
const instances = [];
|
|
3578
|
+
const staticValues = this.staticValues.slice();
|
|
3537
3579
|
const cleanupInstances = () => {
|
|
3538
3580
|
for (const instance of instances) instance?.host.scope?.cleanup();
|
|
3539
3581
|
};
|
|
@@ -3588,14 +3630,15 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3588
3630
|
return false;
|
|
3589
3631
|
}
|
|
3590
3632
|
staticSegments.push(elements.slice(cursor));
|
|
3591
|
-
|
|
3592
|
-
this.rangeInstances = instances;
|
|
3593
|
-
if (!applyStaticRangeBindings(props.bindings, this.staticSegments, this.staticValues)) {
|
|
3633
|
+
if (!applyStaticRangeBindings(props.bindings, staticSegments, staticValues)) {
|
|
3594
3634
|
cleanupInstances();
|
|
3595
|
-
this.rangeInstances = [];
|
|
3596
|
-
this.staticSegments = [];
|
|
3597
3635
|
return false;
|
|
3598
3636
|
}
|
|
3637
|
+
for (const instance of this.rangeInstances) instance?.host.scope?.cleanup();
|
|
3638
|
+
this.staticSegments = staticSegments;
|
|
3639
|
+
this.rangeInstances = instances;
|
|
3640
|
+
this.staticValues.length = 0;
|
|
3641
|
+
this.staticValues.push(...staticValues);
|
|
3599
3642
|
return true;
|
|
3600
3643
|
}
|
|
3601
3644
|
anchorAfter(rangeIndex) {
|
|
@@ -3690,6 +3733,14 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3690
3733
|
}
|
|
3691
3734
|
afterCommit?.();
|
|
3692
3735
|
}
|
|
3736
|
+
listen() {
|
|
3737
|
+
const id = this.currentProps.id;
|
|
3738
|
+
const stop = this.stop;
|
|
3739
|
+
if (this.id === id) return;
|
|
3740
|
+
stop?.();
|
|
3741
|
+
this.stop = owner.subscribe(id, this.refresh);
|
|
3742
|
+
this.id = id;
|
|
3743
|
+
}
|
|
3693
3744
|
activateFallback(afterCommit) {
|
|
3694
3745
|
if (!this.mounted || this.state.fallback || this.fallbackRequested) {
|
|
3695
3746
|
afterCommit?.();
|
|
@@ -3706,30 +3757,45 @@ function createConditionalRangesBlockComponent(owner) {
|
|
|
3706
3757
|
this.propFallbackQueued = true;
|
|
3707
3758
|
queueMicrotask(() => {
|
|
3708
3759
|
this.propFallbackQueued = false;
|
|
3709
|
-
if (this.mounted && !this.state.fallback)
|
|
3760
|
+
if (this.mounted && !this.state.fallback) {
|
|
3761
|
+
this.listen();
|
|
3762
|
+
this.activateFallback();
|
|
3763
|
+
}
|
|
3710
3764
|
});
|
|
3711
3765
|
}
|
|
3712
3766
|
shouldComponentUpdate(nextProps, nextState) {
|
|
3767
|
+
const definitionChanged = this.definitionVersion !== owner.getDefinitionVersion?.();
|
|
3713
3768
|
this.currentProps = nextProps;
|
|
3714
3769
|
if (this.state.fallback && nextState.fallback) this.prepareFallbackUpdate();
|
|
3715
3770
|
if (nextState.fallback || this.state.fallback) return true;
|
|
3771
|
+
if (definitionChanged) return true;
|
|
3716
3772
|
this.schedulePropFallback();
|
|
3717
3773
|
return false;
|
|
3718
3774
|
}
|
|
3719
3775
|
componentDidMount() {
|
|
3720
3776
|
this.mounted = true;
|
|
3721
|
-
this.
|
|
3777
|
+
this.listen();
|
|
3722
3778
|
if (this.state.fallback || this.fallbackRequested) {
|
|
3723
3779
|
this.subscribeFallbackDescendants();
|
|
3724
3780
|
this.fallbackKeysWereUnsafe = this.hasUnsafeFallbackKeys();
|
|
3725
3781
|
} else if (!this.adopt()) this.activateFallback();
|
|
3726
3782
|
}
|
|
3727
3783
|
componentDidUpdate() {
|
|
3728
|
-
|
|
3784
|
+
this.listen();
|
|
3785
|
+
const nextDefinitionVersion = owner.getDefinitionVersion?.();
|
|
3786
|
+
const definitionChanged = this.definitionVersion !== nextDefinitionVersion;
|
|
3787
|
+
this.definitionVersion = nextDefinitionVersion;
|
|
3788
|
+
if (this.state.fallback) {
|
|
3789
|
+
this.subscribeFallbackDescendants();
|
|
3790
|
+
} else if (definitionChanged && !this.adopt()) {
|
|
3791
|
+
this.activateFallback();
|
|
3792
|
+
}
|
|
3729
3793
|
}
|
|
3730
3794
|
componentWillUnmount() {
|
|
3731
3795
|
this.mounted = false;
|
|
3732
|
-
this.
|
|
3796
|
+
const stop = this.stop;
|
|
3797
|
+
stop?.();
|
|
3798
|
+
this.id = void 0;
|
|
3733
3799
|
clearCompilerFallbackSubscriptions(this.fallbackUnsubscribers);
|
|
3734
3800
|
this.fallbackKeysWereUnsafe = false;
|
|
3735
3801
|
for (const instance of this.rangeInstances) instance?.host.scope?.cleanup();
|
|
@@ -5518,6 +5584,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
5518
5584
|
this.fallbackKeysWereUnsafe = false;
|
|
5519
5585
|
this.propSyncQueued = false;
|
|
5520
5586
|
this.currentProps = this.props;
|
|
5587
|
+
this.definitionVersion = owner.getDefinitionVersion?.();
|
|
5521
5588
|
this.instances = /* @__PURE__ */ new Map();
|
|
5522
5589
|
this.identityTargets = /* @__PURE__ */ new Map();
|
|
5523
5590
|
this.membershipTargets = /* @__PURE__ */ new Map();
|
|
@@ -5896,13 +5963,14 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
5896
5963
|
const rows = this.readRows(this.currentProps);
|
|
5897
5964
|
const elements = [...this.root.children];
|
|
5898
5965
|
if (!rows || rows.items.length !== elements.length) return false;
|
|
5966
|
+
const reactOwnedRows = this.hasReactOwnedRows();
|
|
5899
5967
|
const opaqueConditionalPaths = new Set(
|
|
5900
5968
|
(this.currentProps.conditionals || []).map((conditional) => conditional.path.join("."))
|
|
5901
5969
|
);
|
|
5902
5970
|
const instances = /* @__PURE__ */ new Map();
|
|
5903
5971
|
for (let index = 0; index < rows.items.length; index += 1) {
|
|
5904
5972
|
const descriptor = this.currentProps.create(rows.items[index], index);
|
|
5905
|
-
if (
|
|
5973
|
+
if (reactOwnedRows && !matchesCompilerHostElement(elements[index], descriptor, opaqueConditionalPaths)) {
|
|
5906
5974
|
this.cleanupHostScopes(instances);
|
|
5907
5975
|
return false;
|
|
5908
5976
|
}
|
|
@@ -5915,7 +5983,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
5915
5983
|
key: rows.keys[index],
|
|
5916
5984
|
element: elements[index],
|
|
5917
5985
|
scope: scope || void 0,
|
|
5918
|
-
values:
|
|
5986
|
+
values: reactOwnedRows ? this.currentProps.bindings.map(() => UNSET_KEYED_ROW_BINDING) : readKeyedRowBindingValues(this.currentProps, rows.items[index], index),
|
|
5919
5987
|
item: rows.items[index],
|
|
5920
5988
|
index,
|
|
5921
5989
|
conditionalValues: this.readConditionalValues(
|
|
@@ -5924,11 +5992,13 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
5924
5992
|
index
|
|
5925
5993
|
)
|
|
5926
5994
|
};
|
|
5927
|
-
if (this.hasReactOwnedRows()) {
|
|
5928
|
-
applyKeyedRowBindings(this.currentProps, instance, rows.items[index], index);
|
|
5929
|
-
}
|
|
5930
5995
|
instances.set(rows.keys[index], instance);
|
|
5931
5996
|
}
|
|
5997
|
+
if (reactOwnedRows) {
|
|
5998
|
+
for (const instance of instances.values()) {
|
|
5999
|
+
applyKeyedRowBindings(this.currentProps, instance, instance.item, instance.index);
|
|
6000
|
+
}
|
|
6001
|
+
}
|
|
5932
6002
|
this.cleanupHostScopes();
|
|
5933
6003
|
this.instances = instances;
|
|
5934
6004
|
this.rebuildElementIndex(instances);
|
|
@@ -6350,17 +6420,29 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6350
6420
|
this.commitCurrentCollection(dirtyState);
|
|
6351
6421
|
this.notifyConditionalChanges(conditionalChanges, afterCommit);
|
|
6352
6422
|
}
|
|
6423
|
+
listen() {
|
|
6424
|
+
const id = this.currentProps.id;
|
|
6425
|
+
const stop = this.stop;
|
|
6426
|
+
if (this.id === id) return;
|
|
6427
|
+
stop?.();
|
|
6428
|
+
this.stop = owner.subscribe(id, this.refresh);
|
|
6429
|
+
this.id = id;
|
|
6430
|
+
}
|
|
6353
6431
|
schedulePropSync() {
|
|
6354
6432
|
if (this.propSyncQueued) return;
|
|
6355
6433
|
this.propSyncQueued = true;
|
|
6356
6434
|
queueMicrotask(() => {
|
|
6357
6435
|
this.propSyncQueued = false;
|
|
6358
|
-
if (this.mounted && !this.state.fallback)
|
|
6436
|
+
if (this.mounted && !this.state.fallback) {
|
|
6437
|
+
this.listen();
|
|
6438
|
+
this.reconcile();
|
|
6439
|
+
}
|
|
6359
6440
|
});
|
|
6360
6441
|
}
|
|
6361
6442
|
shouldComponentUpdate(nextProps, nextState) {
|
|
6362
6443
|
const wasReactOwned = this.hasReactOwnedRows(this.currentProps);
|
|
6363
6444
|
const willBeReactOwned = this.hasReactOwnedRows(nextProps);
|
|
6445
|
+
const definitionChanged = this.definitionVersion !== owner.getDefinitionVersion?.();
|
|
6364
6446
|
this.currentProps = nextProps;
|
|
6365
6447
|
if (this.state.fallback && nextState.fallback) {
|
|
6366
6448
|
const unsafeKeys = this.hasUnsafeFallbackKeys();
|
|
@@ -6368,7 +6450,7 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6368
6450
|
this.fallbackKeysWereUnsafe = unsafeKeys;
|
|
6369
6451
|
}
|
|
6370
6452
|
if (nextState.fallback || this.state.fallback) return true;
|
|
6371
|
-
if (wasReactOwned || willBeReactOwned) {
|
|
6453
|
+
if (definitionChanged || wasReactOwned || willBeReactOwned) {
|
|
6372
6454
|
this.eventHandlers.clear();
|
|
6373
6455
|
return true;
|
|
6374
6456
|
}
|
|
@@ -6376,19 +6458,25 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
6376
6458
|
return false;
|
|
6377
6459
|
}
|
|
6378
6460
|
componentDidUpdate(previousProps) {
|
|
6379
|
-
|
|
6461
|
+
this.listen();
|
|
6462
|
+
const nextDefinitionVersion = owner.getDefinitionVersion?.();
|
|
6463
|
+
const definitionChanged = this.definitionVersion !== nextDefinitionVersion;
|
|
6464
|
+
this.definitionVersion = nextDefinitionVersion;
|
|
6465
|
+
if (this.state.fallback || previousProps === this.props || !definitionChanged && !this.hasReactOwnedRows(previousProps) && !this.hasReactOwnedRows(this.props) || this.adopt()) {
|
|
6380
6466
|
return;
|
|
6381
6467
|
}
|
|
6382
6468
|
this.activateFallback();
|
|
6383
6469
|
}
|
|
6384
6470
|
componentDidMount() {
|
|
6385
6471
|
this.mounted = true;
|
|
6386
|
-
this.
|
|
6472
|
+
this.listen();
|
|
6387
6473
|
if (!this.adopt()) this.activateFallback();
|
|
6388
6474
|
}
|
|
6389
6475
|
componentWillUnmount() {
|
|
6390
6476
|
this.mounted = false;
|
|
6391
|
-
this.
|
|
6477
|
+
const stop = this.stop;
|
|
6478
|
+
stop?.();
|
|
6479
|
+
this.id = void 0;
|
|
6392
6480
|
this.cleanupHostScopes();
|
|
6393
6481
|
this.instances.clear();
|
|
6394
6482
|
this.identityTargets.clear();
|
|
@@ -6431,6 +6519,7 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
6431
6519
|
this.rangeInstances = [];
|
|
6432
6520
|
this.staticSegments = [];
|
|
6433
6521
|
this.staticValues = [];
|
|
6522
|
+
this.definitionVersion = owner.getDefinitionVersion?.();
|
|
6434
6523
|
this.captureRoot = (root) => {
|
|
6435
6524
|
this.root = root;
|
|
6436
6525
|
this.currentProps.rootRef?.(root);
|
|
@@ -6468,6 +6557,7 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
6468
6557
|
const elements = [...this.root.children];
|
|
6469
6558
|
const staticSegments = [];
|
|
6470
6559
|
const instancesByRange = [];
|
|
6560
|
+
const staticValues = this.staticValues.slice();
|
|
6471
6561
|
let cursor = 0;
|
|
6472
6562
|
for (let rangeIndex = 0; rangeIndex < props.ranges.length; rangeIndex += 1) {
|
|
6473
6563
|
const range = props.ranges[rangeIndex];
|
|
@@ -6499,13 +6589,11 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
6499
6589
|
}
|
|
6500
6590
|
if (cursor + props.trailing !== elements.length) return false;
|
|
6501
6591
|
staticSegments.push(elements.slice(cursor));
|
|
6592
|
+
if (!applyStaticRangeBindings(props.bindings, staticSegments, staticValues)) return false;
|
|
6502
6593
|
this.staticSegments = staticSegments;
|
|
6503
6594
|
this.rangeInstances = instancesByRange;
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
this.staticSegments = [];
|
|
6507
|
-
return false;
|
|
6508
|
-
}
|
|
6595
|
+
this.staticValues.length = 0;
|
|
6596
|
+
this.staticValues.push(...staticValues);
|
|
6509
6597
|
return true;
|
|
6510
6598
|
}
|
|
6511
6599
|
anchorAfter(rangeIndex) {
|
|
@@ -6602,6 +6690,14 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
6602
6690
|
}
|
|
6603
6691
|
afterCommit?.();
|
|
6604
6692
|
}
|
|
6693
|
+
listen() {
|
|
6694
|
+
const id = this.currentProps.id;
|
|
6695
|
+
const stop = this.stop;
|
|
6696
|
+
if (this.id === id) return;
|
|
6697
|
+
stop?.();
|
|
6698
|
+
this.stop = owner.subscribe(id, this.refresh);
|
|
6699
|
+
this.id = id;
|
|
6700
|
+
}
|
|
6605
6701
|
activateFallback(afterCommit) {
|
|
6606
6702
|
if (!this.mounted || this.state.fallback || this.fallbackRequested) {
|
|
6607
6703
|
afterCommit?.();
|
|
@@ -6616,10 +6712,14 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
6616
6712
|
this.propFallbackQueued = true;
|
|
6617
6713
|
queueMicrotask(() => {
|
|
6618
6714
|
this.propFallbackQueued = false;
|
|
6619
|
-
if (this.mounted && !this.state.fallback)
|
|
6715
|
+
if (this.mounted && !this.state.fallback) {
|
|
6716
|
+
this.listen();
|
|
6717
|
+
this.activateFallback();
|
|
6718
|
+
}
|
|
6620
6719
|
});
|
|
6621
6720
|
}
|
|
6622
6721
|
shouldComponentUpdate(nextProps, nextState) {
|
|
6722
|
+
const definitionChanged = this.definitionVersion !== owner.getDefinitionVersion?.();
|
|
6623
6723
|
this.currentProps = nextProps;
|
|
6624
6724
|
if (this.state.fallback && nextState.fallback) {
|
|
6625
6725
|
const unsafeKeys = this.hasUnsafeFallbackKeys();
|
|
@@ -6627,17 +6727,27 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
6627
6727
|
this.fallbackKeysWereUnsafe = unsafeKeys;
|
|
6628
6728
|
}
|
|
6629
6729
|
if (nextState.fallback || this.state.fallback) return true;
|
|
6730
|
+
if (definitionChanged) return true;
|
|
6630
6731
|
this.schedulePropFallback();
|
|
6631
6732
|
return false;
|
|
6632
6733
|
}
|
|
6633
6734
|
componentDidMount() {
|
|
6634
6735
|
this.mounted = true;
|
|
6635
|
-
this.
|
|
6736
|
+
this.listen();
|
|
6636
6737
|
if (!this.adopt()) this.activateFallback();
|
|
6637
6738
|
}
|
|
6739
|
+
componentDidUpdate() {
|
|
6740
|
+
this.listen();
|
|
6741
|
+
const nextDefinitionVersion = owner.getDefinitionVersion?.();
|
|
6742
|
+
const definitionChanged = this.definitionVersion !== nextDefinitionVersion;
|
|
6743
|
+
this.definitionVersion = nextDefinitionVersion;
|
|
6744
|
+
if (!this.state.fallback && definitionChanged && !this.adopt()) this.activateFallback();
|
|
6745
|
+
}
|
|
6638
6746
|
componentWillUnmount() {
|
|
6639
6747
|
this.mounted = false;
|
|
6640
|
-
this.
|
|
6748
|
+
const stop = this.stop;
|
|
6749
|
+
stop?.();
|
|
6750
|
+
this.id = void 0;
|
|
6641
6751
|
this.rangeInstances = [];
|
|
6642
6752
|
this.staticSegments = [];
|
|
6643
6753
|
this.staticValues.length = 0;
|
|
@@ -6672,6 +6782,7 @@ function createMixedRangesBlockComponent(owner) {
|
|
|
6672
6782
|
this.currentProps = this.props;
|
|
6673
6783
|
this.controller = null;
|
|
6674
6784
|
this.fallbackUnsubscribers = /* @__PURE__ */ new Map();
|
|
6785
|
+
this.definitionVersion = owner.getDefinitionVersion?.();
|
|
6675
6786
|
this.captureRoot = (root) => {
|
|
6676
6787
|
this.root = root;
|
|
6677
6788
|
this.currentProps.rootRef?.(root);
|
|
@@ -6745,7 +6856,9 @@ function createMixedRangesBlockComponent(owner) {
|
|
|
6745
6856
|
controller.cleanup();
|
|
6746
6857
|
throw error;
|
|
6747
6858
|
}
|
|
6859
|
+
const previous = this.controller;
|
|
6748
6860
|
this.controller = controller;
|
|
6861
|
+
previous?.cleanup();
|
|
6749
6862
|
return true;
|
|
6750
6863
|
}
|
|
6751
6864
|
schedulePropFallback() {
|
|
@@ -6757,11 +6870,13 @@ function createMixedRangesBlockComponent(owner) {
|
|
|
6757
6870
|
});
|
|
6758
6871
|
}
|
|
6759
6872
|
shouldComponentUpdate(nextProps, nextState) {
|
|
6873
|
+
const definitionChanged = this.definitionVersion !== owner.getDefinitionVersion?.();
|
|
6760
6874
|
this.currentProps = nextProps;
|
|
6761
6875
|
if (this.state.fallback && nextState.fallback) {
|
|
6762
6876
|
this.prepareFallbackUpdate(this.currentProps.create());
|
|
6763
6877
|
}
|
|
6764
6878
|
if (nextState.fallback || this.state.fallback) return true;
|
|
6879
|
+
if (definitionChanged) return true;
|
|
6765
6880
|
this.schedulePropFallback();
|
|
6766
6881
|
return false;
|
|
6767
6882
|
}
|
|
@@ -6773,7 +6888,14 @@ function createMixedRangesBlockComponent(owner) {
|
|
|
6773
6888
|
} else if (!this.adopt()) this.activateFallback();
|
|
6774
6889
|
}
|
|
6775
6890
|
componentDidUpdate() {
|
|
6776
|
-
|
|
6891
|
+
const nextDefinitionVersion = owner.getDefinitionVersion?.();
|
|
6892
|
+
const definitionChanged = this.definitionVersion !== nextDefinitionVersion;
|
|
6893
|
+
this.definitionVersion = nextDefinitionVersion;
|
|
6894
|
+
if (this.state.fallback) {
|
|
6895
|
+
this.subscribeFallbackBlocks();
|
|
6896
|
+
} else if (definitionChanged && !this.adopt()) {
|
|
6897
|
+
this.activateFallback();
|
|
6898
|
+
}
|
|
6777
6899
|
}
|
|
6778
6900
|
componentWillUnmount() {
|
|
6779
6901
|
this.mounted = false;
|
|
@@ -7613,8 +7735,9 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
7613
7735
|
};
|
|
7614
7736
|
});
|
|
7615
7737
|
const featureOwner = {
|
|
7616
|
-
setRoot: (id, root) => this.setBlockRoot(id, root),
|
|
7617
|
-
subscribe: (id, refresh) => this.subscribeToBlock(id, refresh)
|
|
7738
|
+
setRoot: (id, root, expectedRoot) => this.setBlockRoot(id, root, expectedRoot),
|
|
7739
|
+
subscribe: (id, refresh) => this.subscribeToBlock(id, refresh),
|
|
7740
|
+
getDefinitionVersion: () => definitionReference.current
|
|
7618
7741
|
};
|
|
7619
7742
|
const blockRuntime = {
|
|
7620
7743
|
target: (id) => this.bindingTarget(id)
|
|
@@ -7753,8 +7876,9 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
|
|
|
7753
7876
|
}
|
|
7754
7877
|
snapshot.element.setSelectionRange(snapshot.start, snapshot.end, snapshot.direction);
|
|
7755
7878
|
}
|
|
7756
|
-
setBlockRoot(id, root) {
|
|
7879
|
+
setBlockRoot(id, root, expectedRoot) {
|
|
7757
7880
|
const previous = this.blockRoots.get(id);
|
|
7881
|
+
if (!root && expectedRoot !== void 0 && previous !== expectedRoot) return;
|
|
7758
7882
|
if (previous) this.blockRootElements.delete(previous);
|
|
7759
7883
|
if (root) {
|
|
7760
7884
|
this.blockRoots.set(id, root);
|