@farm.js/react 0.1.0-beta.10 → 0.1.0-beta.11

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.
@@ -3375,7 +3375,6 @@ function createHostConditionalBlockComponent(owner) {
3375
3375
  for (const unsubscribe of this.fallbackUnsubscribers) unsubscribe();
3376
3376
  this.fallbackUnsubscribers = [];
3377
3377
  this.instance?.scope?.cleanup();
3378
- this.root = null;
3379
3378
  this.activeBranch = null;
3380
3379
  this.instance = null;
3381
3380
  }
@@ -3647,7 +3646,6 @@ function createConditionalRangesBlockComponent(owner) {
3647
3646
  for (const unsubscribe of this.fallbackUnsubscribers) unsubscribe();
3648
3647
  this.fallbackUnsubscribers = [];
3649
3648
  for (const instance of this.rangeInstances) instance?.host.scope?.cleanup();
3650
- this.root = null;
3651
3649
  this.rangeInstances = [];
3652
3650
  this.staticSegments = [];
3653
3651
  this.staticValues.length = 0;
@@ -4489,15 +4487,15 @@ function reconcileCompilerKeyedArrayBatchInsert(props, dirtyState, collectionTok
4489
4487
  return void 0;
4490
4488
  }
4491
4489
  }
4492
- const knownKeys = new Set(instances.keys());
4490
+ const incomingKeys = /* @__PURE__ */ new Set();
4493
4491
  const incoming = [];
4494
4492
  try {
4495
4493
  for (let offset = 0; offset < insertCount; offset += 1) {
4496
4494
  const index = update.position + offset;
4497
4495
  const item = finalValue[index];
4498
4496
  const key = keyedRowIdentity(props.rowKey(item, index));
4499
- if (knownKeys.has(key)) return void 0;
4500
- knownKeys.add(key);
4497
+ if (instances.has(key) || incomingKeys.has(key)) return void 0;
4498
+ incomingKeys.add(key);
4501
4499
  const descriptor = props.create(item, index);
4502
4500
  incoming.push({
4503
4501
  key,
@@ -4650,9 +4648,9 @@ function reconcileCompilerKeyedArrayWindowReplace(props, dirtyState, collectionT
4650
4648
  const preparedIncomingKeys = /* @__PURE__ */ new Set();
4651
4649
  const preparedWindows = [];
4652
4650
  const nextInstances = [];
4653
- for (const window of windows) {
4654
- if (window[0] < sourceCursor) return void 0;
4655
- while (sourceCursor < window[0]) {
4651
+ for (const window2 of windows) {
4652
+ if (window2[0] < sourceCursor) return void 0;
4653
+ while (sourceCursor < window2[0]) {
4656
4654
  const instance = previousInstances[sourceCursor];
4657
4655
  if (!instance || instance.index !== sourceCursor || !Object.is(instance.item, finalValue[resultCursor])) {
4658
4656
  return void 0;
@@ -4665,24 +4663,24 @@ function reconcileCompilerKeyedArrayWindowReplace(props, dirtyState, collectionT
4665
4663
  props,
4666
4664
  finalValue,
4667
4665
  resultCursor,
4668
- window[3]
4666
+ window2[3]
4669
4667
  );
4670
4668
  if (!incoming2) return void 0;
4671
- window[1] = resultCursor;
4669
+ window2[1] = resultCursor;
4672
4670
  const prepared3 = prepareCompilerKeyedArrayWindow(
4673
4671
  props,
4674
4672
  instances,
4675
4673
  previousInstances,
4676
4674
  root,
4677
- window,
4675
+ window2,
4678
4676
  incoming2,
4679
4677
  preparedIncomingKeys
4680
4678
  );
4681
4679
  if (!prepared3) return void 0;
4682
4680
  preparedWindows.push(prepared3);
4683
4681
  nextInstances.push(...prepared3[4]);
4684
- sourceCursor += window[2];
4685
- resultCursor += window[3];
4682
+ sourceCursor += window2[2];
4683
+ resultCursor += window2[3];
4686
4684
  }
4687
4685
  while (sourceCursor < previousInstances.length) {
4688
4686
  const instance = previousInstances[sourceCursor];
@@ -4702,30 +4700,32 @@ function reconcileCompilerKeyedArrayWindowReplace(props, dirtyState, collectionT
4702
4700
  }
4703
4701
  return keyedRowInstancesByKey(nextInstances);
4704
4702
  }
4705
- const touchedIndices = /* @__PURE__ */ new Set();
4706
- for (const update2 of updates) {
4707
- for (let index = update2.position; index < update2.position + update2.removedCount; index += 1) {
4708
- touchedIndices.add(index);
4709
- }
4710
- }
4703
+ updates.sort((left, right) => right.position - left.position);
4704
+ let window = updates.pop();
4705
+ const touchedInstances = [];
4711
4706
  for (let index = 0; index < previousInstances.length; index += 1) {
4707
+ while (window && index >= window.position + window.removedCount) {
4708
+ window = updates.pop();
4709
+ }
4712
4710
  const instance = previousInstances[index];
4713
- const touched = touchedIndices.has(index);
4714
- if (!instance || instance.index !== index || (touched ? instance.element.parentNode !== root : !Object.is(instance.item, finalValue[index]))) {
4711
+ if (!instance || instance.index !== index) return void 0;
4712
+ if (window && index >= window.position) {
4713
+ if (instance.element.parentNode !== root) return void 0;
4714
+ touchedInstances.push(instance);
4715
+ } else if (!Object.is(instance.item, finalValue[index])) {
4715
4716
  return void 0;
4716
4717
  }
4717
4718
  }
4718
- const knownKeys = new Set(instances.keys());
4719
4719
  const incomingKeys2 = /* @__PURE__ */ new Set();
4720
4720
  let replacesRows = false;
4721
4721
  const prepared2 = [];
4722
4722
  try {
4723
- for (const index of [...touchedIndices].sort((left, right) => left - right)) {
4724
- const instance = previousInstances[index];
4723
+ for (const instance of touchedInstances) {
4724
+ const index = instance.index;
4725
4725
  const item = finalValue[index];
4726
4726
  const key = keyedRowIdentity(props.rowKey(item, index));
4727
4727
  if (key !== instance.key) {
4728
- if (knownKeys.has(key) || incomingKeys2.has(key)) return void 0;
4728
+ if (instances.has(key) || incomingKeys2.has(key)) return void 0;
4729
4729
  incomingKeys2.add(key);
4730
4730
  replacesRows = true;
4731
4731
  const descriptor = props.create(item, index);
@@ -5549,11 +5549,13 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
5549
5549
  this.hasReactOwnedRows()
5550
5550
  );
5551
5551
  if (positionedInstances) {
5552
- this.instances = new Map(positionedInstances);
5553
- this.rebuildElementIndex(this.instances);
5554
- const keys = [...this.instances.keys()];
5555
- this.pruneEventHandlers(keys);
5556
- this.pruneConditionalListeners(keys);
5552
+ if (positionedInstances !== this.instances) {
5553
+ this.instances = new Map(positionedInstances);
5554
+ this.rebuildElementIndex(this.instances);
5555
+ const keys = [...this.instances.keys()];
5556
+ this.pruneEventHandlers(keys);
5557
+ this.pruneConditionalListeners(keys);
5558
+ }
5557
5559
  this.commitCurrentCollection(dirtyState);
5558
5560
  afterCommit?.();
5559
5561
  return;
@@ -5568,9 +5570,9 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
5568
5570
  );
5569
5571
  if (reorderedInstances) {
5570
5572
  const removedRows = reorderedInstances.size < this.instances.size;
5571
- this.instances = new Map(reorderedInstances);
5572
- this.rebuildElementIndex(this.instances);
5573
+ this.instances = reorderedInstances;
5573
5574
  if (removedRows) {
5575
+ this.rebuildElementIndex(this.instances);
5574
5576
  const keys = [...this.instances.keys()];
5575
5577
  this.pruneEventHandlers(keys);
5576
5578
  this.pruneConditionalListeners(keys);
@@ -6297,7 +6299,6 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
6297
6299
  componentWillUnmount() {
6298
6300
  this.mounted = false;
6299
6301
  this.unsubscribe?.();
6300
- this.root = null;
6301
6302
  this.cleanupHostScopes();
6302
6303
  this.instances.clear();
6303
6304
  this.identityTargets.clear();
@@ -6531,7 +6532,6 @@ function createKeyedRangesBlockComponent(owner) {
6531
6532
  componentWillUnmount() {
6532
6533
  this.mounted = false;
6533
6534
  this.unsubscribe?.();
6534
- this.root = null;
6535
6535
  this.rangeInstances = [];
6536
6536
  this.staticSegments = [];
6537
6537
  this.staticValues.length = 0;
@@ -6656,7 +6656,6 @@ function createMixedRangesBlockComponent(owner) {
6656
6656
  this.controller?.cleanup();
6657
6657
  this.controller = null;
6658
6658
  this.clearFallbackSubscriptions();
6659
- this.root = null;
6660
6659
  }
6661
6660
  render() {
6662
6661
  const container = this.currentProps.render();
@@ -7770,13 +7769,11 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
7770
7769
  }
7771
7770
  componentWillUnmount() {
7772
7771
  this.mounted = false;
7773
- this.root = null;
7774
7772
  this.dirtyState.clear();
7775
7773
  this.inputSelection = null;
7776
7774
  this.blockRefreshListeners.clear();
7777
7775
  this.blockRoots.clear();
7778
7776
  this.blockRootElements.clear();
7779
- this.bindingTargets.clear();
7780
7777
  this.bindingTargetRefs.clear();
7781
7778
  this.indexedDefinition = null;
7782
7779
  this.staticBindingsByDependency = [];