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.csp.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
  */
@@ -10744,7 +10744,7 @@
10744
10744
  // Set initial value (no pipes in v-model)
10745
10745
  const initialValue = evaluateExpression(expr, currentScope, false);
10746
10746
  if (inputElement.type === 'checkbox') {
10747
- inputElement.checked = !!initialValue;
10747
+ inputElement.checked = !!unref(initialValue);
10748
10748
  }
10749
10749
  else if (inputElement.type === 'radio') {
10750
10750
  inputElement.checked = String(unref(initialValue)) === inputElement.value;
@@ -10790,7 +10790,7 @@
10790
10790
  // No pipes in v-model reactive updates
10791
10791
  const newValue = evaluateExpression(expr, currentScope, false);
10792
10792
  if (inputElement.type === 'checkbox') {
10793
- inputElement.checked = !!newValue;
10793
+ inputElement.checked = !!unref(newValue);
10794
10794
  }
10795
10795
  else if (inputElement.type === 'radio') {
10796
10796
  inputElement.checked = String(unref(newValue)) === inputElement.value;
@@ -11021,6 +11021,15 @@
11021
11021
  // It's a getter - just return value, getter will track its own dependencies
11022
11022
  return value;
11023
11023
  }
11024
+ // Callable reactive values are data, not methods. Binding would drop
11025
+ // their identity and metadata used by g-model and the public APIs.
11026
+ if (isSignal(value) || isComputed(value)) {
11027
+ // Track the field as well as reads of its value so replacing the
11028
+ // signal/computed switches effects away from the old source.
11029
+ if (hasCurrentEffect())
11030
+ getFieldSignal(target, key, value).value;
11031
+ return value;
11032
+ }
11024
11033
  // function -> bind this = proxy
11025
11034
  if (typeof value === "function") {
11026
11035
  return value.bind(proxy);
@@ -11170,6 +11179,79 @@
11170
11179
  return scopeVersionMap.get(target);
11171
11180
  }
11172
11181
 
11182
+ /** Keep the longest already-ordered run of rows connected; move only the rest. */
11183
+ function placeKeyedRows(placeholder, rows) {
11184
+ const parent = placeholder.parentNode;
11185
+ if (!parent || rows.length === 0)
11186
+ return;
11187
+ const managed = new Set(rows);
11188
+ const positions = new Map();
11189
+ let boundary = placeholder.nextSibling;
11190
+ while (boundary && managed.has(boundary)) {
11191
+ positions.set(boundary, positions.size);
11192
+ boundary = boundary.nextSibling;
11193
+ }
11194
+ const active = placeholder.ownerDocument.activeElement;
11195
+ const ownsFocus = !!active && rows.some((row) => row === active || row.contains(active));
11196
+ const selection = ownsFocus && (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement)
11197
+ ? { start: active.selectionStart, end: active.selectionEnd, direction: active.selectionDirection }
11198
+ : null;
11199
+ if (positions.size !== rows.length) {
11200
+ // Leaving transition nodes, foreign siblings or externally detached rows:
11201
+ // preserve the established contiguous-after-placeholder placement contract.
11202
+ let previous = placeholder;
11203
+ for (const row of rows) {
11204
+ if (row !== previous.nextSibling)
11205
+ parent.insertBefore(row, previous.nextSibling);
11206
+ previous = row;
11207
+ }
11208
+ }
11209
+ else {
11210
+ const order = rows.map((row) => positions.get(row));
11211
+ let sorted = true;
11212
+ for (let i = 1; i < order.length; i++)
11213
+ if (order[i] < order[i - 1]) {
11214
+ sorted = false;
11215
+ break;
11216
+ }
11217
+ if (sorted)
11218
+ return;
11219
+ // Patience sorting: indices of a longest increasing subsequence, O(n log n).
11220
+ const tails = [], predecessors = new Array(order.length).fill(-1);
11221
+ for (let i = 0; i < order.length; i++) {
11222
+ let low = 0, high = tails.length;
11223
+ while (low < high) {
11224
+ const middle = (low + high) >>> 1;
11225
+ if (order[tails[middle]] < order[i])
11226
+ low = middle + 1;
11227
+ else
11228
+ high = middle;
11229
+ }
11230
+ if (low > 0)
11231
+ predecessors[i] = tails[low - 1];
11232
+ tails[low] = i;
11233
+ }
11234
+ const retained = new Set();
11235
+ for (let i = tails[tails.length - 1]; i >= 0; i = predecessors[i])
11236
+ retained.add(i);
11237
+ for (let i = rows.length - 1; i >= 0; i--) {
11238
+ const row = rows[i];
11239
+ if (!retained.has(i) && row.nextSibling !== boundary)
11240
+ parent.insertBefore(row, boundary);
11241
+ boundary = row;
11242
+ }
11243
+ }
11244
+ // insertBefore can blur a moved input. Restore only a surviving owned focus,
11245
+ // and never steal focus assigned to another control by application callbacks.
11246
+ const document = placeholder.ownerDocument;
11247
+ if (ownsFocus && active.isConnected && document.activeElement === document.body) {
11248
+ active.focus({ preventScroll: true });
11249
+ if (selection?.start != null && selection.end != null) {
11250
+ active.setSelectionRange(selection.start, selection.end, selection.direction || undefined);
11251
+ }
11252
+ }
11253
+ }
11254
+
11173
11255
  /**
11174
11256
  * Structural Directives (*if, *for)
11175
11257
  * Single-pass parser for conditional and list rendering with transitions
@@ -11350,6 +11432,7 @@
11350
11432
  });
11351
11433
  // Add/reorder items immediately (parallel with remove animations)
11352
11434
  let lastPlacedNode = placeholder;
11435
+ const rows = [];
11353
11436
  orderedKeys.forEach((key) => {
11354
11437
  const newItemData = newItemsMap.get(key);
11355
11438
  const { index } = newItemData;
@@ -11401,13 +11484,10 @@
11401
11484
  });
11402
11485
  }
11403
11486
  }
11404
- // Place each managed row directly after the previous row. This does not
11405
- // depend on formatting whitespace or unrelated sibling nodes.
11406
- if (itemElement !== lastPlacedNode.nextSibling) {
11407
- placeholder.parentNode?.insertBefore(itemElement, lastPlacedNode.nextSibling);
11408
- }
11487
+ rows.push(itemElement);
11409
11488
  lastPlacedNode = itemElement;
11410
11489
  });
11490
+ placeKeyedRows(placeholder, rows);
11411
11491
  }
11412
11492
  /**
11413
11493
  * Process *for without keys (simple re-render)
@@ -15509,7 +15589,7 @@
15509
15589
  portalCreate,
15510
15590
  portalDestroy,
15511
15591
  setCspNonce,
15512
- version: '0.5.0'
15592
+ version: '0.5.2'
15513
15593
  };
15514
15594
 
15515
15595
  setExpressionRuntime(cspExpressionRuntime);