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
package/dist/gyos.js
CHANGED
|
@@ -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
|
*/
|
|
@@ -4553,6 +4553,79 @@
|
|
|
4553
4553
|
return scopeVersionMap.get(target);
|
|
4554
4554
|
}
|
|
4555
4555
|
|
|
4556
|
+
/** Keep the longest already-ordered run of rows connected; move only the rest. */
|
|
4557
|
+
function placeKeyedRows(placeholder, rows) {
|
|
4558
|
+
const parent = placeholder.parentNode;
|
|
4559
|
+
if (!parent || rows.length === 0)
|
|
4560
|
+
return;
|
|
4561
|
+
const managed = new Set(rows);
|
|
4562
|
+
const positions = new Map();
|
|
4563
|
+
let boundary = placeholder.nextSibling;
|
|
4564
|
+
while (boundary && managed.has(boundary)) {
|
|
4565
|
+
positions.set(boundary, positions.size);
|
|
4566
|
+
boundary = boundary.nextSibling;
|
|
4567
|
+
}
|
|
4568
|
+
const active = placeholder.ownerDocument.activeElement;
|
|
4569
|
+
const ownsFocus = !!active && rows.some((row) => row === active || row.contains(active));
|
|
4570
|
+
const selection = ownsFocus && (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement)
|
|
4571
|
+
? { start: active.selectionStart, end: active.selectionEnd, direction: active.selectionDirection }
|
|
4572
|
+
: null;
|
|
4573
|
+
if (positions.size !== rows.length) {
|
|
4574
|
+
// Leaving transition nodes, foreign siblings or externally detached rows:
|
|
4575
|
+
// preserve the established contiguous-after-placeholder placement contract.
|
|
4576
|
+
let previous = placeholder;
|
|
4577
|
+
for (const row of rows) {
|
|
4578
|
+
if (row !== previous.nextSibling)
|
|
4579
|
+
parent.insertBefore(row, previous.nextSibling);
|
|
4580
|
+
previous = row;
|
|
4581
|
+
}
|
|
4582
|
+
}
|
|
4583
|
+
else {
|
|
4584
|
+
const order = rows.map((row) => positions.get(row));
|
|
4585
|
+
let sorted = true;
|
|
4586
|
+
for (let i = 1; i < order.length; i++)
|
|
4587
|
+
if (order[i] < order[i - 1]) {
|
|
4588
|
+
sorted = false;
|
|
4589
|
+
break;
|
|
4590
|
+
}
|
|
4591
|
+
if (sorted)
|
|
4592
|
+
return;
|
|
4593
|
+
// Patience sorting: indices of a longest increasing subsequence, O(n log n).
|
|
4594
|
+
const tails = [], predecessors = new Array(order.length).fill(-1);
|
|
4595
|
+
for (let i = 0; i < order.length; i++) {
|
|
4596
|
+
let low = 0, high = tails.length;
|
|
4597
|
+
while (low < high) {
|
|
4598
|
+
const middle = (low + high) >>> 1;
|
|
4599
|
+
if (order[tails[middle]] < order[i])
|
|
4600
|
+
low = middle + 1;
|
|
4601
|
+
else
|
|
4602
|
+
high = middle;
|
|
4603
|
+
}
|
|
4604
|
+
if (low > 0)
|
|
4605
|
+
predecessors[i] = tails[low - 1];
|
|
4606
|
+
tails[low] = i;
|
|
4607
|
+
}
|
|
4608
|
+
const retained = new Set();
|
|
4609
|
+
for (let i = tails[tails.length - 1]; i >= 0; i = predecessors[i])
|
|
4610
|
+
retained.add(i);
|
|
4611
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
4612
|
+
const row = rows[i];
|
|
4613
|
+
if (!retained.has(i) && row.nextSibling !== boundary)
|
|
4614
|
+
parent.insertBefore(row, boundary);
|
|
4615
|
+
boundary = row;
|
|
4616
|
+
}
|
|
4617
|
+
}
|
|
4618
|
+
// insertBefore can blur a moved input. Restore only a surviving owned focus,
|
|
4619
|
+
// and never steal focus assigned to another control by application callbacks.
|
|
4620
|
+
const document = placeholder.ownerDocument;
|
|
4621
|
+
if (ownsFocus && active.isConnected && document.activeElement === document.body) {
|
|
4622
|
+
active.focus({ preventScroll: true });
|
|
4623
|
+
if (selection?.start != null && selection.end != null) {
|
|
4624
|
+
active.setSelectionRange(selection.start, selection.end, selection.direction || undefined);
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4627
|
+
}
|
|
4628
|
+
|
|
4556
4629
|
/**
|
|
4557
4630
|
* Structural Directives (*if, *for)
|
|
4558
4631
|
* Single-pass parser for conditional and list rendering with transitions
|
|
@@ -4733,6 +4806,7 @@
|
|
|
4733
4806
|
});
|
|
4734
4807
|
// Add/reorder items immediately (parallel with remove animations)
|
|
4735
4808
|
let lastPlacedNode = placeholder;
|
|
4809
|
+
const rows = [];
|
|
4736
4810
|
orderedKeys.forEach((key) => {
|
|
4737
4811
|
const newItemData = newItemsMap.get(key);
|
|
4738
4812
|
const { index } = newItemData;
|
|
@@ -4784,13 +4858,10 @@
|
|
|
4784
4858
|
});
|
|
4785
4859
|
}
|
|
4786
4860
|
}
|
|
4787
|
-
|
|
4788
|
-
// depend on formatting whitespace or unrelated sibling nodes.
|
|
4789
|
-
if (itemElement !== lastPlacedNode.nextSibling) {
|
|
4790
|
-
placeholder.parentNode?.insertBefore(itemElement, lastPlacedNode.nextSibling);
|
|
4791
|
-
}
|
|
4861
|
+
rows.push(itemElement);
|
|
4792
4862
|
lastPlacedNode = itemElement;
|
|
4793
4863
|
});
|
|
4864
|
+
placeKeyedRows(placeholder, rows);
|
|
4794
4865
|
}
|
|
4795
4866
|
/**
|
|
4796
4867
|
* Process *for without keys (simple re-render)
|
|
@@ -8892,7 +8963,7 @@
|
|
|
8892
8963
|
portalCreate,
|
|
8893
8964
|
portalDestroy,
|
|
8894
8965
|
setCspNonce,
|
|
8895
|
-
version: '0.5.
|
|
8966
|
+
version: '0.5.1'
|
|
8896
8967
|
};
|
|
8897
8968
|
|
|
8898
8969
|
setExpressionRuntime(standardExpressionRuntime);
|