gyosjs 0.5.0 → 0.5.1
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 +1 -1
- package/dist/gyos.auto.esm.js +78 -7
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +78 -7
- package/dist/gyos.auto.js.map +1 -1
- package/dist/gyos.auto.min.js +2 -2
- package/dist/gyos.csp.auto.esm.js +78 -7
- package/dist/gyos.csp.auto.esm.js.map +1 -1
- package/dist/gyos.csp.auto.js +78 -7
- package/dist/gyos.csp.auto.js.map +1 -1
- package/dist/gyos.csp.auto.min.js +2 -2
- package/dist/gyos.csp.esm.js +78 -7
- package/dist/gyos.csp.esm.js.map +1 -1
- package/dist/gyos.csp.js +78 -7
- package/dist/gyos.csp.js.map +1 -1
- package/dist/gyos.csp.min.js +2 -2
- package/dist/gyos.esm.js +78 -7
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +78 -7
- package/dist/gyos.js.map +1 -1
- package/dist/gyos.min.js +2 -2
- package/dist/template/structurals/keyed-placement.d.ts +3 -0
- package/dist/template/structurals/keyed-placement.d.ts.map +1 -0
- package/dist/template/structurals/structural.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GyosJS v0.5.
|
|
2
|
+
* GyosJS v0.5.1
|
|
3
3
|
* (c) 2026
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -4515,6 +4515,79 @@ function getScopeVersion(target) {
|
|
|
4515
4515
|
return scopeVersionMap.get(target);
|
|
4516
4516
|
}
|
|
4517
4517
|
|
|
4518
|
+
/** Keep the longest already-ordered run of rows connected; move only the rest. */
|
|
4519
|
+
function placeKeyedRows(placeholder, rows) {
|
|
4520
|
+
const parent = placeholder.parentNode;
|
|
4521
|
+
if (!parent || rows.length === 0)
|
|
4522
|
+
return;
|
|
4523
|
+
const managed = new Set(rows);
|
|
4524
|
+
const positions = new Map();
|
|
4525
|
+
let boundary = placeholder.nextSibling;
|
|
4526
|
+
while (boundary && managed.has(boundary)) {
|
|
4527
|
+
positions.set(boundary, positions.size);
|
|
4528
|
+
boundary = boundary.nextSibling;
|
|
4529
|
+
}
|
|
4530
|
+
const active = placeholder.ownerDocument.activeElement;
|
|
4531
|
+
const ownsFocus = !!active && rows.some((row) => row === active || row.contains(active));
|
|
4532
|
+
const selection = ownsFocus && (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement)
|
|
4533
|
+
? { start: active.selectionStart, end: active.selectionEnd, direction: active.selectionDirection }
|
|
4534
|
+
: null;
|
|
4535
|
+
if (positions.size !== rows.length) {
|
|
4536
|
+
// Leaving transition nodes, foreign siblings or externally detached rows:
|
|
4537
|
+
// preserve the established contiguous-after-placeholder placement contract.
|
|
4538
|
+
let previous = placeholder;
|
|
4539
|
+
for (const row of rows) {
|
|
4540
|
+
if (row !== previous.nextSibling)
|
|
4541
|
+
parent.insertBefore(row, previous.nextSibling);
|
|
4542
|
+
previous = row;
|
|
4543
|
+
}
|
|
4544
|
+
}
|
|
4545
|
+
else {
|
|
4546
|
+
const order = rows.map((row) => positions.get(row));
|
|
4547
|
+
let sorted = true;
|
|
4548
|
+
for (let i = 1; i < order.length; i++)
|
|
4549
|
+
if (order[i] < order[i - 1]) {
|
|
4550
|
+
sorted = false;
|
|
4551
|
+
break;
|
|
4552
|
+
}
|
|
4553
|
+
if (sorted)
|
|
4554
|
+
return;
|
|
4555
|
+
// Patience sorting: indices of a longest increasing subsequence, O(n log n).
|
|
4556
|
+
const tails = [], predecessors = new Array(order.length).fill(-1);
|
|
4557
|
+
for (let i = 0; i < order.length; i++) {
|
|
4558
|
+
let low = 0, high = tails.length;
|
|
4559
|
+
while (low < high) {
|
|
4560
|
+
const middle = (low + high) >>> 1;
|
|
4561
|
+
if (order[tails[middle]] < order[i])
|
|
4562
|
+
low = middle + 1;
|
|
4563
|
+
else
|
|
4564
|
+
high = middle;
|
|
4565
|
+
}
|
|
4566
|
+
if (low > 0)
|
|
4567
|
+
predecessors[i] = tails[low - 1];
|
|
4568
|
+
tails[low] = i;
|
|
4569
|
+
}
|
|
4570
|
+
const retained = new Set();
|
|
4571
|
+
for (let i = tails[tails.length - 1]; i >= 0; i = predecessors[i])
|
|
4572
|
+
retained.add(i);
|
|
4573
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
4574
|
+
const row = rows[i];
|
|
4575
|
+
if (!retained.has(i) && row.nextSibling !== boundary)
|
|
4576
|
+
parent.insertBefore(row, boundary);
|
|
4577
|
+
boundary = row;
|
|
4578
|
+
}
|
|
4579
|
+
}
|
|
4580
|
+
// insertBefore can blur a moved input. Restore only a surviving owned focus,
|
|
4581
|
+
// and never steal focus assigned to another control by application callbacks.
|
|
4582
|
+
const document = placeholder.ownerDocument;
|
|
4583
|
+
if (ownsFocus && active.isConnected && document.activeElement === document.body) {
|
|
4584
|
+
active.focus({ preventScroll: true });
|
|
4585
|
+
if (selection?.start != null && selection.end != null) {
|
|
4586
|
+
active.setSelectionRange(selection.start, selection.end, selection.direction || undefined);
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
}
|
|
4590
|
+
|
|
4518
4591
|
/**
|
|
4519
4592
|
* Structural Directives (*if, *for)
|
|
4520
4593
|
* Single-pass parser for conditional and list rendering with transitions
|
|
@@ -4695,6 +4768,7 @@ function processForWithKeys(placeholder, template, list, itemVar, keyExpr, curre
|
|
|
4695
4768
|
});
|
|
4696
4769
|
// Add/reorder items immediately (parallel with remove animations)
|
|
4697
4770
|
let lastPlacedNode = placeholder;
|
|
4771
|
+
const rows = [];
|
|
4698
4772
|
orderedKeys.forEach((key) => {
|
|
4699
4773
|
const newItemData = newItemsMap.get(key);
|
|
4700
4774
|
const { index } = newItemData;
|
|
@@ -4746,13 +4820,10 @@ function processForWithKeys(placeholder, template, list, itemVar, keyExpr, curre
|
|
|
4746
4820
|
});
|
|
4747
4821
|
}
|
|
4748
4822
|
}
|
|
4749
|
-
|
|
4750
|
-
// depend on formatting whitespace or unrelated sibling nodes.
|
|
4751
|
-
if (itemElement !== lastPlacedNode.nextSibling) {
|
|
4752
|
-
placeholder.parentNode?.insertBefore(itemElement, lastPlacedNode.nextSibling);
|
|
4753
|
-
}
|
|
4823
|
+
rows.push(itemElement);
|
|
4754
4824
|
lastPlacedNode = itemElement;
|
|
4755
4825
|
});
|
|
4826
|
+
placeKeyedRows(placeholder, rows);
|
|
4756
4827
|
}
|
|
4757
4828
|
/**
|
|
4758
4829
|
* Process *for without keys (simple re-render)
|
|
@@ -8868,7 +8939,7 @@ const Gyos = {
|
|
|
8868
8939
|
portalCreate,
|
|
8869
8940
|
portalDestroy,
|
|
8870
8941
|
setCspNonce,
|
|
8871
|
-
version: '0.5.
|
|
8942
|
+
version: '0.5.1'
|
|
8872
8943
|
};
|
|
8873
8944
|
|
|
8874
8945
|
// This file was generated. Do not modify manually!
|