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/README.md CHANGED
@@ -34,7 +34,7 @@ GyosJS is not trying to replace a full SPA framework. If your app is primarily c
34
34
  Use the browser auto-init build when you want HTML-first usage with minimal setup.
35
35
 
36
36
  ```html
37
- <script src="https://cdn.jsdelivr.net/npm/gyosjs@0.5.0/dist/gyos.auto.min.js"></script>
37
+ <script src="https://cdn.jsdelivr.net/npm/gyosjs@0.5.2/dist/gyos.auto.min.js"></script>
38
38
  ```
39
39
 
40
40
  That build attaches `window.Gyos`, starts the router when `g-boost` exists, injects transition styles, and mounts scopes when the page is ready.
@@ -1 +1 @@
1
- {"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../../src/core/reactive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAUlC,eAAO,MAAM,aAAa,eAAmC,CAAC;AA0D9D,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAOrD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAE/C;AAKD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAOnD;AASD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAOnD;AAiCD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAsMpD;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAgB3D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,CAEvE"}
1
+ {"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../../src/core/reactive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAUlC,eAAO,MAAM,aAAa,eAAmC,CAAC;AA0D9D,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAOrD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAE/C;AAKD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAOnD;AASD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAOnD;AAiCD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CA+MpD;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAgB3D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,CAEvE"}
@@ -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
  */
@@ -4089,7 +4089,7 @@ function processModel(element, scope, root) {
4089
4089
  // Set initial value (no pipes in v-model)
4090
4090
  const initialValue = evaluateExpression(expr, currentScope, false);
4091
4091
  if (inputElement.type === 'checkbox') {
4092
- inputElement.checked = !!initialValue;
4092
+ inputElement.checked = !!unref(initialValue);
4093
4093
  }
4094
4094
  else if (inputElement.type === 'radio') {
4095
4095
  inputElement.checked = String(unref(initialValue)) === inputElement.value;
@@ -4135,7 +4135,7 @@ function processModel(element, scope, root) {
4135
4135
  // No pipes in v-model reactive updates
4136
4136
  const newValue = evaluateExpression(expr, currentScope, false);
4137
4137
  if (inputElement.type === 'checkbox') {
4138
- inputElement.checked = !!newValue;
4138
+ inputElement.checked = !!unref(newValue);
4139
4139
  }
4140
4140
  else if (inputElement.type === 'radio') {
4141
4141
  inputElement.checked = String(unref(newValue)) === inputElement.value;
@@ -4366,6 +4366,15 @@ function reactive(raw) {
4366
4366
  // It's a getter - just return value, getter will track its own dependencies
4367
4367
  return value;
4368
4368
  }
4369
+ // Callable reactive values are data, not methods. Binding would drop
4370
+ // their identity and metadata used by g-model and the public APIs.
4371
+ if (isSignal(value) || isComputed(value)) {
4372
+ // Track the field as well as reads of its value so replacing the
4373
+ // signal/computed switches effects away from the old source.
4374
+ if (hasCurrentEffect())
4375
+ getFieldSignal(target, key, value).value;
4376
+ return value;
4377
+ }
4369
4378
  // function -> bind this = proxy
4370
4379
  if (typeof value === "function") {
4371
4380
  return value.bind(proxy);
@@ -4515,6 +4524,79 @@ function getScopeVersion(target) {
4515
4524
  return scopeVersionMap.get(target);
4516
4525
  }
4517
4526
 
4527
+ /** Keep the longest already-ordered run of rows connected; move only the rest. */
4528
+ function placeKeyedRows(placeholder, rows) {
4529
+ const parent = placeholder.parentNode;
4530
+ if (!parent || rows.length === 0)
4531
+ return;
4532
+ const managed = new Set(rows);
4533
+ const positions = new Map();
4534
+ let boundary = placeholder.nextSibling;
4535
+ while (boundary && managed.has(boundary)) {
4536
+ positions.set(boundary, positions.size);
4537
+ boundary = boundary.nextSibling;
4538
+ }
4539
+ const active = placeholder.ownerDocument.activeElement;
4540
+ const ownsFocus = !!active && rows.some((row) => row === active || row.contains(active));
4541
+ const selection = ownsFocus && (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement)
4542
+ ? { start: active.selectionStart, end: active.selectionEnd, direction: active.selectionDirection }
4543
+ : null;
4544
+ if (positions.size !== rows.length) {
4545
+ // Leaving transition nodes, foreign siblings or externally detached rows:
4546
+ // preserve the established contiguous-after-placeholder placement contract.
4547
+ let previous = placeholder;
4548
+ for (const row of rows) {
4549
+ if (row !== previous.nextSibling)
4550
+ parent.insertBefore(row, previous.nextSibling);
4551
+ previous = row;
4552
+ }
4553
+ }
4554
+ else {
4555
+ const order = rows.map((row) => positions.get(row));
4556
+ let sorted = true;
4557
+ for (let i = 1; i < order.length; i++)
4558
+ if (order[i] < order[i - 1]) {
4559
+ sorted = false;
4560
+ break;
4561
+ }
4562
+ if (sorted)
4563
+ return;
4564
+ // Patience sorting: indices of a longest increasing subsequence, O(n log n).
4565
+ const tails = [], predecessors = new Array(order.length).fill(-1);
4566
+ for (let i = 0; i < order.length; i++) {
4567
+ let low = 0, high = tails.length;
4568
+ while (low < high) {
4569
+ const middle = (low + high) >>> 1;
4570
+ if (order[tails[middle]] < order[i])
4571
+ low = middle + 1;
4572
+ else
4573
+ high = middle;
4574
+ }
4575
+ if (low > 0)
4576
+ predecessors[i] = tails[low - 1];
4577
+ tails[low] = i;
4578
+ }
4579
+ const retained = new Set();
4580
+ for (let i = tails[tails.length - 1]; i >= 0; i = predecessors[i])
4581
+ retained.add(i);
4582
+ for (let i = rows.length - 1; i >= 0; i--) {
4583
+ const row = rows[i];
4584
+ if (!retained.has(i) && row.nextSibling !== boundary)
4585
+ parent.insertBefore(row, boundary);
4586
+ boundary = row;
4587
+ }
4588
+ }
4589
+ // insertBefore can blur a moved input. Restore only a surviving owned focus,
4590
+ // and never steal focus assigned to another control by application callbacks.
4591
+ const document = placeholder.ownerDocument;
4592
+ if (ownsFocus && active.isConnected && document.activeElement === document.body) {
4593
+ active.focus({ preventScroll: true });
4594
+ if (selection?.start != null && selection.end != null) {
4595
+ active.setSelectionRange(selection.start, selection.end, selection.direction || undefined);
4596
+ }
4597
+ }
4598
+ }
4599
+
4518
4600
  /**
4519
4601
  * Structural Directives (*if, *for)
4520
4602
  * Single-pass parser for conditional and list rendering with transitions
@@ -4695,6 +4777,7 @@ function processForWithKeys(placeholder, template, list, itemVar, keyExpr, curre
4695
4777
  });
4696
4778
  // Add/reorder items immediately (parallel with remove animations)
4697
4779
  let lastPlacedNode = placeholder;
4780
+ const rows = [];
4698
4781
  orderedKeys.forEach((key) => {
4699
4782
  const newItemData = newItemsMap.get(key);
4700
4783
  const { index } = newItemData;
@@ -4746,13 +4829,10 @@ function processForWithKeys(placeholder, template, list, itemVar, keyExpr, curre
4746
4829
  });
4747
4830
  }
4748
4831
  }
4749
- // Place each managed row directly after the previous row. This does not
4750
- // depend on formatting whitespace or unrelated sibling nodes.
4751
- if (itemElement !== lastPlacedNode.nextSibling) {
4752
- placeholder.parentNode?.insertBefore(itemElement, lastPlacedNode.nextSibling);
4753
- }
4832
+ rows.push(itemElement);
4754
4833
  lastPlacedNode = itemElement;
4755
4834
  });
4835
+ placeKeyedRows(placeholder, rows);
4756
4836
  }
4757
4837
  /**
4758
4838
  * Process *for without keys (simple re-render)
@@ -8854,7 +8934,7 @@ const Gyos = {
8854
8934
  portalCreate,
8855
8935
  portalDestroy,
8856
8936
  setCspNonce,
8857
- version: '0.5.0'
8937
+ version: '0.5.2'
8858
8938
  };
8859
8939
 
8860
8940
  const standardExpressionRuntime = {