@farm.js/react 0.1.0-beta.20 → 0.1.0-beta.21
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.
|
@@ -2992,6 +2992,24 @@ var CompilerNestedConditionalRanges = class {
|
|
|
2992
2992
|
this.staticValues.length = 0;
|
|
2993
2993
|
}
|
|
2994
2994
|
};
|
|
2995
|
+
function reconcileStableNestedKeyedRows(range, previous, rows) {
|
|
2996
|
+
if (rows.keys.length !== previous.size) return void 0;
|
|
2997
|
+
let index = 0;
|
|
2998
|
+
for (const key of previous.keys()) {
|
|
2999
|
+
if (rows.keys[index++] !== key) return void 0;
|
|
3000
|
+
}
|
|
3001
|
+
index = 0;
|
|
3002
|
+
for (const existing of previous.values()) {
|
|
3003
|
+
const item = rows.items[index];
|
|
3004
|
+
const descriptor = range.create(item, index);
|
|
3005
|
+
if (!existing.scope?.update(descriptor)) return false;
|
|
3006
|
+
applyKeyedRowBindings(range, existing, item, index);
|
|
3007
|
+
existing.item = item;
|
|
3008
|
+
existing.index = index;
|
|
3009
|
+
index += 1;
|
|
3010
|
+
}
|
|
3011
|
+
return true;
|
|
3012
|
+
}
|
|
2995
3013
|
var CompilerNestedKeyedRanges = class {
|
|
2996
3014
|
constructor(owner, root, host, block, onFallback) {
|
|
2997
3015
|
this.owner = owner;
|
|
@@ -3165,6 +3183,8 @@ var CompilerNestedKeyedRanges = class {
|
|
|
3165
3183
|
reconcileRange(rangeIndex, rows) {
|
|
3166
3184
|
const range = this.block.ranges[rangeIndex];
|
|
3167
3185
|
const previous = this.instances[rangeIndex];
|
|
3186
|
+
const stable = reconcileStableNestedKeyedRows(range, previous, rows);
|
|
3187
|
+
if (stable !== void 0) return stable;
|
|
3168
3188
|
const oldIndices = /* @__PURE__ */ new Map();
|
|
3169
3189
|
[...previous.keys()].forEach((key, index) => oldIndices.set(key, index));
|
|
3170
3190
|
const nextKeys = new Set(rows.keys);
|
|
@@ -3523,6 +3543,8 @@ var CompilerNestedMixedRanges = class {
|
|
|
3523
3543
|
const instance = this.instances[rangeIndex];
|
|
3524
3544
|
if (instance.kind !== "keyed") return false;
|
|
3525
3545
|
const previous = instance.value;
|
|
3546
|
+
const stable = reconcileStableNestedKeyedRows(range, previous, rows);
|
|
3547
|
+
if (stable !== void 0) return stable;
|
|
3526
3548
|
const oldIndices = /* @__PURE__ */ new Map();
|
|
3527
3549
|
[...previous.keys()].forEach((key, index) => oldIndices.set(key, index));
|
|
3528
3550
|
const nextKeys = new Set(rows.keys);
|
|
@@ -6003,6 +6025,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6003
6025
|
this.currentProps = this.props;
|
|
6004
6026
|
this.definitionVersion = owner.getDefinitionVersion?.();
|
|
6005
6027
|
this.instances = /* @__PURE__ */ new Map();
|
|
6028
|
+
this.reactElements = [];
|
|
6006
6029
|
this.keyedTargets = options.keyedTargets?.(this.props);
|
|
6007
6030
|
this.renderVersion = 0;
|
|
6008
6031
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
@@ -6119,7 +6142,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6119
6142
|
);
|
|
6120
6143
|
if (positionedInstances) {
|
|
6121
6144
|
if (positionedInstances !== this.instances) {
|
|
6122
|
-
this.instances =
|
|
6145
|
+
this.instances = positionedInstances;
|
|
6123
6146
|
this.rebuildElementIndex(this.instances);
|
|
6124
6147
|
this.pruneEventHandlers();
|
|
6125
6148
|
this.pruneConditionalListeners();
|
|
@@ -6161,8 +6184,10 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6161
6184
|
this.instances = rollingWindowInstances instanceof Map ? rollingWindowInstances : new Map(rollingWindowInstances);
|
|
6162
6185
|
if (delta) {
|
|
6163
6186
|
COMPILER_KEYED_ROLLING_WINDOW_DELTAS.delete(rollingWindowInstances);
|
|
6164
|
-
|
|
6165
|
-
|
|
6187
|
+
if (this.usesDelegatedEvents()) {
|
|
6188
|
+
for (const instance of delta.added) {
|
|
6189
|
+
this.instancesByElement.set(instance.element, instance);
|
|
6190
|
+
}
|
|
6166
6191
|
}
|
|
6167
6192
|
for (const key of delta.removedKeys) {
|
|
6168
6193
|
this.eventHandlers.delete(key);
|
|
@@ -6202,7 +6227,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6202
6227
|
this.hasReactOwnedRows()
|
|
6203
6228
|
);
|
|
6204
6229
|
if (prependedInstances) {
|
|
6205
|
-
this.instances =
|
|
6230
|
+
this.instances = prependedInstances;
|
|
6206
6231
|
this.rebuildElementIndex(this.instances);
|
|
6207
6232
|
this.commitCurrentCollection(dirtyState);
|
|
6208
6233
|
afterCommit?.();
|
|
@@ -6226,6 +6251,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6226
6251
|
}
|
|
6227
6252
|
rebuildElementIndex(instances) {
|
|
6228
6253
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6254
|
+
if (!this.usesDelegatedEvents()) return;
|
|
6229
6255
|
for (const instance of instances.values()) {
|
|
6230
6256
|
this.instancesByElement.set(instance.element, instance);
|
|
6231
6257
|
}
|
|
@@ -6360,6 +6386,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6360
6386
|
}
|
|
6361
6387
|
this.cleanupHostScopes();
|
|
6362
6388
|
this.instances = instances;
|
|
6389
|
+
this.reactElements = elements;
|
|
6363
6390
|
this.rebuildElementIndex(instances);
|
|
6364
6391
|
this.pruneEventHandlers();
|
|
6365
6392
|
this.pruneConditionalListeners();
|
|
@@ -6781,6 +6808,10 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6781
6808
|
}
|
|
6782
6809
|
if (nextState.fallback || this.state.fallback) return true;
|
|
6783
6810
|
if (definitionChanged || wasReactOwned || willBeReactOwned) {
|
|
6811
|
+
const elements = this.root?.children;
|
|
6812
|
+
if (elements && (elements.length !== this.reactElements.length || this.reactElements.some((element, index) => element !== elements[index]))) {
|
|
6813
|
+
this.fallbackVersion += 1;
|
|
6814
|
+
}
|
|
6784
6815
|
this.eventHandlers.clear();
|
|
6785
6816
|
return true;
|
|
6786
6817
|
}
|
|
@@ -6809,6 +6840,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6809
6840
|
this.id = void 0;
|
|
6810
6841
|
this.cleanupHostScopes();
|
|
6811
6842
|
this.instances.clear();
|
|
6843
|
+
this.reactElements = [];
|
|
6812
6844
|
this.keyedTargets?.clear();
|
|
6813
6845
|
this.instancesByElement = /* @__PURE__ */ new WeakMap();
|
|
6814
6846
|
this.eventHandlers.clear();
|
|
@@ -6824,7 +6856,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6824
6856
|
}
|
|
6825
6857
|
return React.cloneElement(container, {
|
|
6826
6858
|
...this.delegatedContainerProps(container),
|
|
6827
|
-
key: this.state.fallback ?
|
|
6859
|
+
key: `${this.state.fallback ? "react" : "compiled"}-${this.fallbackVersion}`,
|
|
6828
6860
|
ref: this.captureRoot
|
|
6829
6861
|
});
|
|
6830
6862
|
}
|