gyosjs 0.5.0 → 0.5.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/gyos.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GyosJS v0.5.0
2
+ * GyosJS v0.5.2
3
3
  * (c) 2026
4
4
  * @license MIT
5
5
  */
@@ -4121,7 +4121,7 @@ function processModel(element, scope, root) {
4121
4121
  // Set initial value (no pipes in v-model)
4122
4122
  const initialValue = evaluateExpression(expr, currentScope, false);
4123
4123
  if (inputElement.type === 'checkbox') {
4124
- inputElement.checked = !!initialValue;
4124
+ inputElement.checked = !!unref(initialValue);
4125
4125
  }
4126
4126
  else if (inputElement.type === 'radio') {
4127
4127
  inputElement.checked = String(unref(initialValue)) === inputElement.value;
@@ -4167,7 +4167,7 @@ function processModel(element, scope, root) {
4167
4167
  // No pipes in v-model reactive updates
4168
4168
  const newValue = evaluateExpression(expr, currentScope, false);
4169
4169
  if (inputElement.type === 'checkbox') {
4170
- inputElement.checked = !!newValue;
4170
+ inputElement.checked = !!unref(newValue);
4171
4171
  }
4172
4172
  else if (inputElement.type === 'radio') {
4173
4173
  inputElement.checked = String(unref(newValue)) === inputElement.value;
@@ -4398,6 +4398,15 @@ function reactive(raw) {
4398
4398
  // It's a getter - just return value, getter will track its own dependencies
4399
4399
  return value;
4400
4400
  }
4401
+ // Callable reactive values are data, not methods. Binding would drop
4402
+ // their identity and metadata used by g-model and the public APIs.
4403
+ if (isSignal(value) || isComputed(value)) {
4404
+ // Track the field as well as reads of its value so replacing the
4405
+ // signal/computed switches effects away from the old source.
4406
+ if (hasCurrentEffect())
4407
+ getFieldSignal(target, key, value).value;
4408
+ return value;
4409
+ }
4401
4410
  // function -> bind this = proxy
4402
4411
  if (typeof value === "function") {
4403
4412
  return value.bind(proxy);
@@ -4547,6 +4556,79 @@ function getScopeVersion(target) {
4547
4556
  return scopeVersionMap.get(target);
4548
4557
  }
4549
4558
 
4559
+ /** Keep the longest already-ordered run of rows connected; move only the rest. */
4560
+ function placeKeyedRows(placeholder, rows) {
4561
+ const parent = placeholder.parentNode;
4562
+ if (!parent || rows.length === 0)
4563
+ return;
4564
+ const managed = new Set(rows);
4565
+ const positions = new Map();
4566
+ let boundary = placeholder.nextSibling;
4567
+ while (boundary && managed.has(boundary)) {
4568
+ positions.set(boundary, positions.size);
4569
+ boundary = boundary.nextSibling;
4570
+ }
4571
+ const active = placeholder.ownerDocument.activeElement;
4572
+ const ownsFocus = !!active && rows.some((row) => row === active || row.contains(active));
4573
+ const selection = ownsFocus && (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement)
4574
+ ? { start: active.selectionStart, end: active.selectionEnd, direction: active.selectionDirection }
4575
+ : null;
4576
+ if (positions.size !== rows.length) {
4577
+ // Leaving transition nodes, foreign siblings or externally detached rows:
4578
+ // preserve the established contiguous-after-placeholder placement contract.
4579
+ let previous = placeholder;
4580
+ for (const row of rows) {
4581
+ if (row !== previous.nextSibling)
4582
+ parent.insertBefore(row, previous.nextSibling);
4583
+ previous = row;
4584
+ }
4585
+ }
4586
+ else {
4587
+ const order = rows.map((row) => positions.get(row));
4588
+ let sorted = true;
4589
+ for (let i = 1; i < order.length; i++)
4590
+ if (order[i] < order[i - 1]) {
4591
+ sorted = false;
4592
+ break;
4593
+ }
4594
+ if (sorted)
4595
+ return;
4596
+ // Patience sorting: indices of a longest increasing subsequence, O(n log n).
4597
+ const tails = [], predecessors = new Array(order.length).fill(-1);
4598
+ for (let i = 0; i < order.length; i++) {
4599
+ let low = 0, high = tails.length;
4600
+ while (low < high) {
4601
+ const middle = (low + high) >>> 1;
4602
+ if (order[tails[middle]] < order[i])
4603
+ low = middle + 1;
4604
+ else
4605
+ high = middle;
4606
+ }
4607
+ if (low > 0)
4608
+ predecessors[i] = tails[low - 1];
4609
+ tails[low] = i;
4610
+ }
4611
+ const retained = new Set();
4612
+ for (let i = tails[tails.length - 1]; i >= 0; i = predecessors[i])
4613
+ retained.add(i);
4614
+ for (let i = rows.length - 1; i >= 0; i--) {
4615
+ const row = rows[i];
4616
+ if (!retained.has(i) && row.nextSibling !== boundary)
4617
+ parent.insertBefore(row, boundary);
4618
+ boundary = row;
4619
+ }
4620
+ }
4621
+ // insertBefore can blur a moved input. Restore only a surviving owned focus,
4622
+ // and never steal focus assigned to another control by application callbacks.
4623
+ const document = placeholder.ownerDocument;
4624
+ if (ownsFocus && active.isConnected && document.activeElement === document.body) {
4625
+ active.focus({ preventScroll: true });
4626
+ if (selection?.start != null && selection.end != null) {
4627
+ active.setSelectionRange(selection.start, selection.end, selection.direction || undefined);
4628
+ }
4629
+ }
4630
+ }
4631
+
4550
4632
  /**
4551
4633
  * Structural Directives (*if, *for)
4552
4634
  * Single-pass parser for conditional and list rendering with transitions
@@ -4727,6 +4809,7 @@ function processForWithKeys(placeholder, template, list, itemVar, keyExpr, curre
4727
4809
  });
4728
4810
  // Add/reorder items immediately (parallel with remove animations)
4729
4811
  let lastPlacedNode = placeholder;
4812
+ const rows = [];
4730
4813
  orderedKeys.forEach((key) => {
4731
4814
  const newItemData = newItemsMap.get(key);
4732
4815
  const { index } = newItemData;
@@ -4778,13 +4861,10 @@ function processForWithKeys(placeholder, template, list, itemVar, keyExpr, curre
4778
4861
  });
4779
4862
  }
4780
4863
  }
4781
- // Place each managed row directly after the previous row. This does not
4782
- // depend on formatting whitespace or unrelated sibling nodes.
4783
- if (itemElement !== lastPlacedNode.nextSibling) {
4784
- placeholder.parentNode?.insertBefore(itemElement, lastPlacedNode.nextSibling);
4785
- }
4864
+ rows.push(itemElement);
4786
4865
  lastPlacedNode = itemElement;
4787
4866
  });
4867
+ placeKeyedRows(placeholder, rows);
4788
4868
  }
4789
4869
  /**
4790
4870
  * Process *for without keys (simple re-render)
@@ -8886,7 +8966,7 @@ const Gyos = {
8886
8966
  portalCreate,
8887
8967
  portalDestroy,
8888
8968
  setCspNonce,
8889
- version: '0.5.0'
8969
+ version: '0.5.2'
8890
8970
  };
8891
8971
 
8892
8972
  setExpressionRuntime(standardExpressionRuntime);