@farm.js/react 0.1.0-beta.26 → 0.1.0-beta.27

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.
@@ -5,7 +5,7 @@ import { flushSync } from 'react-dom';
5
5
 
6
6
  // src/iterable.ts
7
7
  var oneShotSnapshots = /* @__PURE__ */ new WeakMap();
8
- var arrayIterator = Array.prototype[Symbol.iterator];
8
+ var arrayIterator = /* @__PURE__ */ (() => Array.prototype[Symbol.iterator])();
9
9
  function materializeIterable(source) {
10
10
  if (source == null) return [];
11
11
  if (Array.isArray(source) && Object.getPrototypeOf(source) === Array.prototype && source[Symbol.iterator] === arrayIterator) {
@@ -42,16 +42,16 @@ var COMPILER_KEYED_COLLECTION_DRAFTS = /* @__PURE__ */ new WeakMap();
42
42
  var COMPILER_KEYED_COLLECTION_UPDATES = /* @__PURE__ */ new WeakMap();
43
43
  var COMPILER_KEYED_COMMITTED_COLLECTIONS = /* @__PURE__ */ new WeakSet();
44
44
  var COMPILER_KEYED_COMMITTED_ITEM_SNAPSHOTS = /* @__PURE__ */ new WeakMap();
45
- var NATIVE_ARRAY_PROTOTYPE = Array.prototype;
46
- var NATIVE_ARRAY_ITERATOR = Array.prototype[Symbol.iterator];
47
- var NATIVE_ARRAY_FILTER = Array.prototype.filter;
48
- var NATIVE_ARRAY_MAP = Array.prototype.map;
49
- var NATIVE_ARRAY_SLICE = Array.prototype.slice;
50
- var NATIVE_ARRAY_TO_SPLICED = Array.prototype.toSpliced;
51
- var NATIVE_ARRAY_WITH = Array.prototype.with;
52
- var NATIVE_ARRAY_TO_REVERSED = Array.prototype.toReversed;
53
- var NATIVE_ARRAY_TO_SORTED = Array.prototype.toSorted;
54
- var NATIVE_REFLECT_APPLY = Reflect.apply;
45
+ var NATIVE_ARRAY_PROTOTYPE = /* @__PURE__ */ (() => Array.prototype)();
46
+ var NATIVE_ARRAY_ITERATOR = /* @__PURE__ */ (() => Array.prototype[Symbol.iterator])();
47
+ var NATIVE_ARRAY_FILTER = /* @__PURE__ */ (() => Array.prototype.filter)();
48
+ var NATIVE_ARRAY_MAP = /* @__PURE__ */ (() => Array.prototype.map)();
49
+ var NATIVE_ARRAY_SLICE = /* @__PURE__ */ (() => Array.prototype.slice)();
50
+ var NATIVE_ARRAY_TO_SPLICED = /* @__PURE__ */ (() => Array.prototype.toSpliced)();
51
+ var NATIVE_ARRAY_WITH = /* @__PURE__ */ (() => Array.prototype.with)();
52
+ var NATIVE_ARRAY_TO_REVERSED = /* @__PURE__ */ (() => Array.prototype.toReversed)();
53
+ var NATIVE_ARRAY_TO_SORTED = /* @__PURE__ */ (() => Array.prototype.toSorted)();
54
+ var NATIVE_REFLECT_APPLY = /* @__PURE__ */ (() => Reflect.apply)();
55
55
  function compilerObject(value) {
56
56
  return typeof value === "object" && value !== null || typeof value === "function" ? value : void 0;
57
57
  }
@@ -2043,11 +2043,11 @@ function keyedIdentityTargetSnapshot(value) {
2043
2043
  const kind = typeof value;
2044
2044
  return value === null || value === void 0 || kind === "string" || kind === "number" || kind === "bigint" ? { eligible: true, key: keyedRowIdentity(value) } : { eligible: false };
2045
2045
  }
2046
- var NATIVE_SET_PROTOTYPE = Set.prototype;
2047
- var NATIVE_SET_ADD = Set.prototype.add;
2048
- var NATIVE_SET_DELETE = Set.prototype.delete;
2049
- var NATIVE_SET_HAS = Set.prototype.has;
2050
- var NATIVE_SET_VALUES = Set.prototype.values;
2046
+ var NATIVE_SET_PROTOTYPE = /* @__PURE__ */ (() => Set.prototype)();
2047
+ var NATIVE_SET_ADD = /* @__PURE__ */ (() => Set.prototype.add)();
2048
+ var NATIVE_SET_DELETE = /* @__PURE__ */ (() => Set.prototype.delete)();
2049
+ var NATIVE_SET_HAS = /* @__PURE__ */ (() => Set.prototype.has)();
2050
+ var NATIVE_SET_VALUES = /* @__PURE__ */ (() => Set.prototype.values)();
2051
2051
  var KEYED_COLLECTION_SNAPSHOT_MAX_DEPTH = 64;
2052
2052
  function materializeKeyedMembershipSnapshot(snapshot) {
2053
2053
  if (!snapshot.eligible) return void 0;
@@ -2148,12 +2148,12 @@ function keyedMembershipChangedKeys(previousSnapshot, nextSnapshot) {
2148
2148
  }
2149
2149
  return keys;
2150
2150
  }
2151
- var NATIVE_MAP_PROTOTYPE = Map.prototype;
2152
- var NATIVE_MAP_GET = Map.prototype.get;
2153
- var NATIVE_MAP_HAS = Map.prototype.has;
2154
- var NATIVE_MAP_SET = Map.prototype.set;
2155
- var NATIVE_MAP_DELETE = Map.prototype.delete;
2156
- var NATIVE_MAP_ENTRIES = Map.prototype.entries;
2151
+ var NATIVE_MAP_PROTOTYPE = /* @__PURE__ */ (() => Map.prototype)();
2152
+ var NATIVE_MAP_GET = /* @__PURE__ */ (() => Map.prototype.get)();
2153
+ var NATIVE_MAP_HAS = /* @__PURE__ */ (() => Map.prototype.has)();
2154
+ var NATIVE_MAP_SET = /* @__PURE__ */ (() => Map.prototype.set)();
2155
+ var NATIVE_MAP_DELETE = /* @__PURE__ */ (() => Map.prototype.delete)();
2156
+ var NATIVE_MAP_ENTRIES = /* @__PURE__ */ (() => Map.prototype.entries)();
2157
2157
  function isSafeKeyedMapLookupValue(value) {
2158
2158
  return value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "bigint" || typeof value === "boolean";
2159
2159
  }
@@ -4447,92 +4447,92 @@ var keyedAppendOnlyUpdateRuntime = {
4447
4447
  commit: commitCompilerKeyedCollection,
4448
4448
  reconcile: () => void 0
4449
4449
  };
4450
- var keyedFilterUpdateRuntime = {
4450
+ var keyedFilterUpdateRuntime = /* @__PURE__ */ (() => ({
4451
4451
  ...keyedUpdateRuntime,
4452
4452
  filter: reconcileCompilerKeyedArrayFilter
4453
- };
4453
+ }))();
4454
4454
  var keyedFilterOnlyUpdateRuntime = {
4455
4455
  append: () => void 0,
4456
4456
  commit: commitCompilerKeyedCollection,
4457
4457
  reconcile: () => void 0,
4458
4458
  filter: reconcileCompilerKeyedArrayFilter
4459
4459
  };
4460
- var keyedPrependUpdateRuntime = {
4460
+ var keyedPrependUpdateRuntime = /* @__PURE__ */ (() => ({
4461
4461
  ...keyedUpdateRuntime,
4462
4462
  prepend: reconcileCompilerKeyedArrayPrepend
4463
- };
4463
+ }))();
4464
4464
  var keyedPrependOnlyUpdateRuntime = {
4465
4465
  append: () => void 0,
4466
4466
  commit: commitCompilerKeyedCollection,
4467
4467
  reconcile: () => void 0,
4468
4468
  prepend: reconcileCompilerKeyedArrayPrepend
4469
4469
  };
4470
- var keyedFilterPrependUpdateRuntime = {
4470
+ var keyedFilterPrependUpdateRuntime = /* @__PURE__ */ (() => ({
4471
4471
  ...keyedFilterUpdateRuntime,
4472
4472
  prepend: reconcileCompilerKeyedArrayPrepend
4473
- };
4474
- var keyedStructuralPrependUpdateRuntime = {
4473
+ }))();
4474
+ var keyedStructuralPrependUpdateRuntime = /* @__PURE__ */ (() => ({
4475
4475
  ...keyedFilterPrependUpdateRuntime,
4476
4476
  prepend: reconcileCompilerKeyedArrayPrependWithStructural
4477
- };
4478
- var keyedPositionUpdateRuntime = {
4477
+ }))();
4478
+ var keyedPositionUpdateRuntime = /* @__PURE__ */ (() => ({
4479
4479
  ...keyedUpdateRuntime,
4480
4480
  position: reconcileCompilerKeyedArrayPosition
4481
- };
4482
- var keyedBatchPositionUpdateRuntime = {
4481
+ }))();
4482
+ var keyedBatchPositionUpdateRuntime = /* @__PURE__ */ (() => ({
4483
4483
  ...keyedUpdateRuntime,
4484
4484
  position: reconcileCompilerKeyedArrayPositionWithBatch
4485
- };
4486
- var keyedWindowPositionUpdateRuntime = {
4485
+ }))();
4486
+ var keyedWindowPositionUpdateRuntime = /* @__PURE__ */ (() => ({
4487
4487
  ...keyedUpdateRuntime,
4488
4488
  position: reconcileCompilerKeyedArrayPositionWithWindow
4489
- };
4490
- var keyedReorderUpdateRuntime = {
4489
+ }))();
4490
+ var keyedReorderUpdateRuntime = /* @__PURE__ */ (() => ({
4491
4491
  ...keyedUpdateRuntime,
4492
4492
  reorder: reconcileCompilerKeyedArrayReorder
4493
- };
4494
- var keyedMapReorderUpdateRuntime = {
4493
+ }))();
4494
+ var keyedMapReorderUpdateRuntime = /* @__PURE__ */ (() => ({
4495
4495
  ...keyedUpdateRuntime,
4496
4496
  reorder: reconcileCompilerKeyedArrayReorderWithMap
4497
- };
4498
- var keyedCompleteUpdateRuntime = {
4497
+ }))();
4498
+ var keyedCompleteUpdateRuntime = /* @__PURE__ */ (() => ({
4499
4499
  ...keyedFilterPrependUpdateRuntime,
4500
4500
  rollingWindow: reconcileCompilerKeyedArrayRollingWindow
4501
- };
4502
- var keyedEveryUpdateRuntime = {
4501
+ }))();
4502
+ var keyedEveryUpdateRuntime = /* @__PURE__ */ (() => ({
4503
4503
  ...keyedCompleteUpdateRuntime,
4504
4504
  position: reconcileCompilerKeyedArrayPosition,
4505
4505
  reorder: reconcileCompilerKeyedArrayReorderWithMapAndStructural
4506
- };
4507
- var keyedBatchEveryUpdateRuntime = {
4506
+ }))();
4507
+ var keyedBatchEveryUpdateRuntime = /* @__PURE__ */ (() => ({
4508
4508
  ...keyedEveryUpdateRuntime,
4509
4509
  position: reconcileCompilerKeyedArrayPositionWithBatch
4510
- };
4511
- var keyedWindowEveryUpdateRuntime = {
4510
+ }))();
4511
+ var keyedWindowEveryUpdateRuntime = /* @__PURE__ */ (() => ({
4512
4512
  ...keyedEveryUpdateRuntime,
4513
4513
  position: reconcileCompilerKeyedArrayPositionWithWindow
4514
- };
4515
- var keyedWindowEveryStructuralAppendUpdateRuntime = {
4514
+ }))();
4515
+ var keyedWindowEveryStructuralAppendUpdateRuntime = /* @__PURE__ */ (() => ({
4516
4516
  ...keyedWindowEveryUpdateRuntime,
4517
4517
  append: reconcileCompilerKeyedArrayAppendWithStructural
4518
- };
4519
- var keyedWindowEveryStructuralAppendMapUpdateRuntime = {
4518
+ }))();
4519
+ var keyedWindowEveryStructuralAppendMapUpdateRuntime = /* @__PURE__ */ (() => ({
4520
4520
  ...keyedWindowEveryStructuralAppendUpdateRuntime,
4521
4521
  append: reconcileCompilerKeyedArrayAppendMapWithStructural,
4522
4522
  commit: commitCompilerKeyedCollectionWithItemSnapshot
4523
- };
4524
- var keyedCompleteCompatibilityUpdateRuntime = {
4523
+ }))();
4524
+ var keyedCompleteCompatibilityUpdateRuntime = /* @__PURE__ */ (() => ({
4525
4525
  ...keyedWindowEveryStructuralAppendMapUpdateRuntime,
4526
4526
  prepend: reconcileCompilerKeyedArrayPrependWithStructural
4527
- };
4528
- var keyedCompleteStructuralPrependMapUpdateRuntime = {
4527
+ }))();
4528
+ var keyedCompleteStructuralPrependMapUpdateRuntime = /* @__PURE__ */ (() => ({
4529
4529
  ...keyedCompleteCompatibilityUpdateRuntime,
4530
4530
  prepend: reconcileCompilerKeyedArrayPrependMapWithStructural
4531
- };
4532
- var keyedMappedRollingWindowUpdateRuntime = {
4531
+ }))();
4532
+ var keyedMappedRollingWindowUpdateRuntime = /* @__PURE__ */ (() => ({
4533
4533
  ...keyedCompleteStructuralPrependMapUpdateRuntime,
4534
4534
  rollingWindow: reconcileCompilerKeyedArrayMappedRollingWindow
4535
- };
4535
+ }))();
4536
4536
  function reconcileCompilerKeyedMapUpdate(props, dirtyState, collectionToken, instances, conditionals) {
4537
4537
  const dependency = props.collectionDependency;
4538
4538
  if (dependency === void 0) return void 0;
@@ -8327,9 +8327,6 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
8327
8327
  this.blockRootElements = /* @__PURE__ */ new Set();
8328
8328
  this.bindingTargets = /* @__PURE__ */ new Map();
8329
8329
  this.bindingTargetRefs = /* @__PURE__ */ new Map();
8330
- this.captureRoot = (root) => {
8331
- this.root = root;
8332
- };
8333
8330
  this.refreshDefinition = () => {
8334
8331
  if (this.mounted) this.forceUpdate();
8335
8332
  };
@@ -8615,8 +8612,7 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
8615
8612
  componentDidMount() {
8616
8613
  this.mounted = true;
8617
8614
  refreshListeners.add(this.refreshDefinition);
8618
- this.ensureBindingIndex();
8619
- this.primeHybridBindings();
8615
+ this.componentDidUpdate();
8620
8616
  }
8621
8617
  getSnapshotBeforeUpdate() {
8622
8618
  const currentDefinition = definitionReference.current;
@@ -8630,7 +8626,7 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
8630
8626
  this.bindingValues.clear();
8631
8627
  return false;
8632
8628
  }
8633
- componentDidUpdate(_previousProps, _previousState, reusedRenderedElement) {
8629
+ componentDidUpdate(previousProps, _previousState, reusedRenderedElement) {
8634
8630
  const propValues = definitionReference.current.readProps?.(this.props) || null;
8635
8631
  if (propValues) {
8636
8632
  if (reusedRenderedElement) this.captureInputSelection();
@@ -8645,21 +8641,20 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
8645
8641
  cell.flush();
8646
8642
  }
8647
8643
  }
8648
- if (!reusedRenderedElement) {
8649
- this.ensureBindingIndex();
8650
- this.primeHybridBindings();
8651
- }
8652
- this.flushBindingUpdates();
8653
- return;
8654
8644
  }
8655
- this.ensureBindingIndex();
8656
- for (const binding of definitionReference.current.bindings) {
8657
- this.applyBinding(binding, true);
8645
+ if (!reusedRenderedElement) {
8646
+ this.ensureBindingIndex();
8647
+ this.primeHybridBindings();
8648
+ }
8649
+ if (!propValues && previousProps) {
8650
+ for (const binding of definitionReference.current.bindings) {
8651
+ this.applyBinding(binding, true);
8652
+ }
8658
8653
  }
8654
+ if (this.dirtyState.size) this.flushBindingUpdates();
8659
8655
  }
8660
8656
  componentWillUnmount() {
8661
8657
  this.mounted = false;
8662
- this.dirtyState.clear();
8663
8658
  this.inputSelection = null;
8664
8659
  this.blockRefreshListeners.clear();
8665
8660
  this.bindingTargetRefs.clear();
@@ -8670,7 +8665,6 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
8670
8665
  this.trackedBindingsByDependency = [];
8671
8666
  this.trackedDependenciesByBinding.clear();
8672
8667
  this.bindingValues.clear();
8673
- this.textNodes.clear();
8674
8668
  this.activeBinding = null;
8675
8669
  this.activeDependencies = null;
8676
8670
  refreshListeners.delete(this.refreshDefinition);
@@ -8691,31 +8685,18 @@ function createCompiledComponentWithFeatures(definition, runtimeFeatures) {
8691
8685
  }
8692
8686
  let renderedElement;
8693
8687
  const captureCommittedRoot = (root) => {
8694
- this.captureRoot(root);
8695
- if (!root) return;
8696
- renderCells.commit();
8697
- this.renderedDefinition = currentDefinition;
8698
- this.renderedElement = renderedElement;
8688
+ this.root = root;
8689
+ if (root) {
8690
+ renderCells.commit();
8691
+ this.renderedDefinition = currentDefinition;
8692
+ this.renderedElement = renderedElement;
8693
+ }
8699
8694
  };
8700
- if (element.type === this.blockRuntime.KeyedRanges) {
8701
- renderedElement = React.cloneElement(
8702
- element,
8703
- {
8704
- rootRef: captureCommittedRoot
8705
- }
8706
- );
8707
- } else if (element.type === this.blockRuntime.ConditionalRanges) {
8695
+ if (element.type === this.blockRuntime.KeyedRanges || element.type === this.blockRuntime.ConditionalRanges || element.type === this.blockRuntime.MixedRanges) {
8708
8696
  renderedElement = React.cloneElement(
8709
8697
  element,
8710
8698
  { rootRef: captureCommittedRoot }
8711
8699
  );
8712
- } else if (element.type === this.blockRuntime.MixedRanges) {
8713
- renderedElement = React.cloneElement(
8714
- element,
8715
- {
8716
- rootRef: captureCommittedRoot
8717
- }
8718
- );
8719
8700
  } else if (typeof element.type !== "string") {
8720
8701
  throw new TypeError(
8721
8702
  `Compiled component ${currentDefinition.displayName} must return one host element.`