gyosjs 0.4.1 → 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/core/component.d.ts.map +1 -1
- package/dist/core/router/persist.d.ts.map +1 -1
- package/dist/core/router/router.d.ts +20 -2
- package/dist/core/router/router.d.ts.map +1 -1
- package/dist/gyos.auto.esm.js +186 -26
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +186 -26
- package/dist/gyos.auto.js.map +1 -1
- package/dist/gyos.auto.min.js +2 -2
- package/dist/gyos.csp.auto.esm.js +186 -26
- package/dist/gyos.csp.auto.esm.js.map +1 -1
- package/dist/gyos.csp.auto.js +186 -26
- package/dist/gyos.csp.auto.js.map +1 -1
- package/dist/gyos.csp.auto.min.js +2 -2
- package/dist/gyos.csp.esm.js +187 -27
- package/dist/gyos.csp.esm.js.map +1 -1
- package/dist/gyos.csp.js +188 -26
- package/dist/gyos.csp.js.map +1 -1
- package/dist/gyos.csp.min.js +2 -2
- package/dist/gyos.esm.js +187 -27
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +188 -26
- package/dist/gyos.js.map +1 -1
- package/dist/gyos.min.js +2 -2
- package/dist/public-api.d.ts +5 -3
- package/dist/public-api.d.ts.map +1 -1
- 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/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.
|
|
37
|
+
<script src="https://cdn.jsdelivr.net/npm/gyosjs@0.5.1/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":"component.d.ts","sourceRoot":"","sources":["../../src/core/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,eAAe,EAAkC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/core/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,eAAe,EAAkC,MAAM,UAAU,CAAC;AAkCvF;;GAEG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,UAAU,EAAE,eAAe,GAAG,IAAI,CAWnF;AAWD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CA0BzE;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAe/C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,CAe3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../../src/core/router/persist.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"persist.d.ts","sourceRoot":"","sources":["../../../src/core/router/persist.ts"],"names":[],"mappings":"AAgDA,wBAAgB,aAAa,CAAC,IAAI,GAAE,UAAqB,GAAG,IAAI,CAU/D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAkD3D;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC"}
|
|
@@ -44,10 +44,28 @@ interface NavigateOptions {
|
|
|
44
44
|
targetOutletIndex?: number | null;
|
|
45
45
|
swapMode?: string;
|
|
46
46
|
currentHead?: boolean;
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
scroll?: boolean;
|
|
49
|
+
fresh?: boolean;
|
|
50
|
+
strictTarget?: boolean;
|
|
51
|
+
onEnd?: (context: NavigationContext) => void;
|
|
47
52
|
historyFragment?: HTMLElement;
|
|
48
53
|
historyEntryId?: string | null;
|
|
49
54
|
scrollSourceEntryId?: string | null;
|
|
50
55
|
}
|
|
56
|
+
/** Options for an explicit same-origin GET navigation. */
|
|
57
|
+
export interface NavigationOptions {
|
|
58
|
+
history?: 'push' | 'replace' | 'none';
|
|
59
|
+
target?: string;
|
|
60
|
+
swap?: 'inner' | 'replace' | 'morph' | 'append' | 'prepend';
|
|
61
|
+
scroll?: boolean;
|
|
62
|
+
currentHead?: boolean;
|
|
63
|
+
signal?: AbortSignal;
|
|
64
|
+
}
|
|
65
|
+
/** Navigate through the boost pipeline. Resolves after navigation-end hooks. */
|
|
66
|
+
export declare function navigate(url: string | URL, options?: NavigationOptions): Promise<NavigationContext>;
|
|
67
|
+
/** Fetch the current URL again, preserving history and scroll by default. */
|
|
68
|
+
export declare function refresh(options?: NavigationOptions): Promise<NavigationContext>;
|
|
51
69
|
interface Snapshot {
|
|
52
70
|
html: string;
|
|
53
71
|
fullDocument: boolean;
|
|
@@ -58,10 +76,10 @@ export declare function onBeforeSwap(callback: NavigationHook): () => void;
|
|
|
58
76
|
export declare function onNavigationEnd(callback: (context: NavigationContext) => void): () => void;
|
|
59
77
|
export declare function startRouter(options?: RouterOptions): void;
|
|
60
78
|
declare function saveSnapshot(url: string, html: string): void;
|
|
61
|
-
declare function
|
|
79
|
+
declare function navigateRequest(opts: NavigateOptions): Promise<void>;
|
|
62
80
|
declare function resetRouterState(): void;
|
|
63
81
|
export declare const __routerTest: {
|
|
64
|
-
navigate: typeof
|
|
82
|
+
navigate: typeof navigateRequest;
|
|
65
83
|
saveSnapshot: typeof saveSnapshot;
|
|
66
84
|
snapshots: Map<string, Snapshot>;
|
|
67
85
|
preloadCache: Map<string, Promise<Response>>;
|
|
@@ -1 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eVersion(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)
|
|
@@ -5630,6 +5701,21 @@ setMountFunction(mount);
|
|
|
5630
5701
|
* Registry of all scopes
|
|
5631
5702
|
*/
|
|
5632
5703
|
const scopeRegistry = new Map();
|
|
5704
|
+
const warnedReveals = new WeakSet();
|
|
5705
|
+
function diagnoseUnscopedReveals(root) {
|
|
5706
|
+
if (!DEBUG())
|
|
5707
|
+
return;
|
|
5708
|
+
const elements = [...root.querySelectorAll('[g-reveal]')];
|
|
5709
|
+
if (root instanceof Element && root.hasAttribute('g-reveal'))
|
|
5710
|
+
elements.unshift(root);
|
|
5711
|
+
for (const element of elements) {
|
|
5712
|
+
if (warnedReveals.has(element) || isInIgnoredTree(element)
|
|
5713
|
+
|| element.closest('[g-scope]') || getScopeFromElement(element))
|
|
5714
|
+
continue;
|
|
5715
|
+
warnedReveals.add(element);
|
|
5716
|
+
console.warn('[Gyos] g-reveal has no owning scope. Add g-scope to its container; global reveal CSS may otherwise hide this content.', element);
|
|
5717
|
+
}
|
|
5718
|
+
}
|
|
5633
5719
|
/**
|
|
5634
5720
|
* Register a scope
|
|
5635
5721
|
*/
|
|
@@ -5677,6 +5763,7 @@ function mountAll(root) {
|
|
|
5677
5763
|
allElements.sort((a, b) => getDepth(b) - getDepth(a));
|
|
5678
5764
|
// Filter out elements inside structural directives - they will be mounted by structural processor
|
|
5679
5765
|
allElements.forEach(el => !hasStructuralParent(el) && mount(el));
|
|
5766
|
+
diagnoseUnscopedReveals(document.body);
|
|
5680
5767
|
}
|
|
5681
5768
|
function mountTree(el) {
|
|
5682
5769
|
if (isInIgnoredTree(el) || !document.body.contains(el))
|
|
@@ -5687,6 +5774,7 @@ function mountTree(el) {
|
|
|
5687
5774
|
// Child scopes own their subtree before an existing parent scope parses the insertion.
|
|
5688
5775
|
candidates.sort((a, b) => getDepth(b) - getDepth(a));
|
|
5689
5776
|
candidates.forEach(element => !hasStructuralParent(element) && mount(element));
|
|
5777
|
+
diagnoseUnscopedReveals(el);
|
|
5690
5778
|
if (getMountedScope(el))
|
|
5691
5779
|
return;
|
|
5692
5780
|
const ownerScope = getScopeFromElement(el);
|
|
@@ -5705,7 +5793,7 @@ function mount(el) {
|
|
|
5705
5793
|
return;
|
|
5706
5794
|
// Check if element removed but still has g-scope (possible in some edge cases)
|
|
5707
5795
|
getAllMountedScopes().forEach((_, mountedEl) => {
|
|
5708
|
-
if (!
|
|
5796
|
+
if (!mountedEl.isConnected) {
|
|
5709
5797
|
disposeEffects(mountedEl);
|
|
5710
5798
|
}
|
|
5711
5799
|
});
|
|
@@ -7017,7 +7105,8 @@ function getPersistKey(el, generateIfMissing = false) {
|
|
|
7017
7105
|
el.dataset.gyosPersistId = key;
|
|
7018
7106
|
return key;
|
|
7019
7107
|
}
|
|
7020
|
-
//
|
|
7108
|
+
// Keep the parking host outside body: body itself may be the swap target.
|
|
7109
|
+
// A disconnected parking host makes browsers pause otherwise persisted media.
|
|
7021
7110
|
const persistParking = typeof document !== 'undefined'
|
|
7022
7111
|
? (() => {
|
|
7023
7112
|
const park = document.createElement('div');
|
|
@@ -7026,12 +7115,7 @@ const persistParking = typeof document !== 'undefined'
|
|
|
7026
7115
|
park.style.top = '-99999px';
|
|
7027
7116
|
park.style.width = '0';
|
|
7028
7117
|
park.style.height = '0';
|
|
7029
|
-
|
|
7030
|
-
document.addEventListener('DOMContentLoaded', () => document.body.appendChild(park));
|
|
7031
|
-
}
|
|
7032
|
-
else {
|
|
7033
|
-
document.body.appendChild(park);
|
|
7034
|
-
}
|
|
7118
|
+
document.documentElement.appendChild(park);
|
|
7035
7119
|
return park;
|
|
7036
7120
|
})()
|
|
7037
7121
|
: null;
|
|
@@ -7042,8 +7126,8 @@ function elementsIn(root) {
|
|
|
7042
7126
|
return elements;
|
|
7043
7127
|
}
|
|
7044
7128
|
function ensureParkingIsConnected() {
|
|
7045
|
-
if (persistParking &&
|
|
7046
|
-
document.
|
|
7129
|
+
if (persistParking && persistParking.parentElement !== document.documentElement) {
|
|
7130
|
+
document.documentElement.appendChild(persistParking);
|
|
7047
7131
|
}
|
|
7048
7132
|
}
|
|
7049
7133
|
function detachPersist(root = document) {
|
|
@@ -7061,12 +7145,18 @@ function detachPersist(root = document) {
|
|
|
7061
7145
|
});
|
|
7062
7146
|
}
|
|
7063
7147
|
function mergePersistIntoLive(root) {
|
|
7148
|
+
// Return the host to the current body before scope mounting/cleanup inspects it.
|
|
7149
|
+
if (persistParking && persistParking.parentElement !== document.body) {
|
|
7150
|
+
document.body.appendChild(persistParking);
|
|
7151
|
+
}
|
|
7064
7152
|
if (!persistEntries.size)
|
|
7065
7153
|
return;
|
|
7066
7154
|
// If placeholders lack ids but we only have one persist entry, assign its key for convenience
|
|
7067
7155
|
if (persistEntries.size === 1) {
|
|
7068
7156
|
const loneKey = Array.from(persistEntries.keys())[0];
|
|
7069
7157
|
elementsIn(root).forEach(el => {
|
|
7158
|
+
if (persistParking?.contains(el))
|
|
7159
|
+
return;
|
|
7070
7160
|
if (!getPersistKey(el, false)) {
|
|
7071
7161
|
el.dataset.gyosPersistId = loneKey;
|
|
7072
7162
|
}
|
|
@@ -7074,6 +7164,8 @@ function mergePersistIntoLive(root) {
|
|
|
7074
7164
|
}
|
|
7075
7165
|
// Element placeholders
|
|
7076
7166
|
elementsIn(root).forEach(placeholder => {
|
|
7167
|
+
if (persistParking?.contains(placeholder))
|
|
7168
|
+
return;
|
|
7077
7169
|
const key = getPersistKey(placeholder, false);
|
|
7078
7170
|
if (!key)
|
|
7079
7171
|
return;
|
|
@@ -7091,6 +7183,8 @@ function mergePersistIntoLive(root) {
|
|
|
7091
7183
|
const toReplace = [];
|
|
7092
7184
|
while (walker.nextNode()) {
|
|
7093
7185
|
const comment = walker.currentNode;
|
|
7186
|
+
if (persistParking?.contains(comment))
|
|
7187
|
+
continue;
|
|
7094
7188
|
const match = comment.data.match(/g-persist[:=]\s*([A-Za-z0-9_\-:.]+)/);
|
|
7095
7189
|
if (match) {
|
|
7096
7190
|
toReplace.push({ node: comment, key: match[1] });
|
|
@@ -7748,6 +7842,36 @@ function prepareNavigationHtml(html) {
|
|
|
7748
7842
|
* Implements attribute-driven routing, snapshot caching, and persistent islands.
|
|
7749
7843
|
*/
|
|
7750
7844
|
const submittingForms = new WeakSet();
|
|
7845
|
+
async function visit(url, options, fresh) {
|
|
7846
|
+
const destination = new URL(url, document.baseURI);
|
|
7847
|
+
if (!['http:', 'https:'].includes(destination.protocol) || destination.origin !== location.origin || destination.username || destination.password) {
|
|
7848
|
+
throw new TypeError('Gyos.navigate requires a same-origin HTTP(S) URL without credentials.');
|
|
7849
|
+
}
|
|
7850
|
+
if (options.target !== undefined && !(document.querySelector(options.target) instanceof HTMLElement)) {
|
|
7851
|
+
throw new TypeError('Gyos.navigate target does not exist.');
|
|
7852
|
+
}
|
|
7853
|
+
if (!document.querySelector('[g-boost]')) {
|
|
7854
|
+
throw new TypeError('Gyos.navigate requires a g-boost layout.');
|
|
7855
|
+
}
|
|
7856
|
+
startRouter();
|
|
7857
|
+
let result;
|
|
7858
|
+
await navigateRequest({
|
|
7859
|
+
url: destination.href, method: 'GET',
|
|
7860
|
+
changeState: options.history !== 'none', replace: options.history === 'replace',
|
|
7861
|
+
targetSelector: options.target, strictTarget: options.target !== undefined, swapMode: options.swap,
|
|
7862
|
+
currentHead: options.currentHead, scroll: options.scroll, signal: options.signal, fresh,
|
|
7863
|
+
onEnd: context => { result = context; }
|
|
7864
|
+
});
|
|
7865
|
+
return result;
|
|
7866
|
+
}
|
|
7867
|
+
/** Navigate through the boost pipeline. Resolves after navigation-end hooks. */
|
|
7868
|
+
function navigate(url, options = {}) {
|
|
7869
|
+
return visit(url, options, false);
|
|
7870
|
+
}
|
|
7871
|
+
/** Fetch the current URL again, preserving history and scroll by default. */
|
|
7872
|
+
function refresh(options = {}) {
|
|
7873
|
+
return visit(location.href, { history: 'none', scroll: false, ...options }, true);
|
|
7874
|
+
}
|
|
7751
7875
|
const snapshots = new Map();
|
|
7752
7876
|
const preloadCache = new Map();
|
|
7753
7877
|
const preloadControllers = new Map();
|
|
@@ -8134,12 +8258,27 @@ function fallbackFromBoost(opts, url, requestSent) {
|
|
|
8134
8258
|
}
|
|
8135
8259
|
console.error(`[GyosRouter] ${method} navigation could not be boosted; the request will not be replayed.`);
|
|
8136
8260
|
}
|
|
8137
|
-
async function
|
|
8261
|
+
async function navigateRequest(opts) {
|
|
8262
|
+
const finishUnstarted = () => {
|
|
8263
|
+
opts.onEnd?.({ from: currentUrl, url: opts.url, method: opts.method,
|
|
8264
|
+
trigger: opts.trigger || null, target: null, form: null, popstate: false,
|
|
8265
|
+
signal: opts.signal, status: null, committed: false, fallback: false, outcome: 'aborted' });
|
|
8266
|
+
};
|
|
8267
|
+
if (opts.signal?.aborted) {
|
|
8268
|
+
finishUnstarted();
|
|
8269
|
+
return;
|
|
8270
|
+
}
|
|
8138
8271
|
while (activeNavigation) {
|
|
8139
8272
|
const previous = activeNavigation;
|
|
8140
8273
|
if (previous.committing) {
|
|
8141
8274
|
log('[GyosRouter] Waiting for previous DOM commit');
|
|
8142
|
-
|
|
8275
|
+
try {
|
|
8276
|
+
await (opts.signal ? waitForNavigation(previous.done, opts.signal) : previous.done);
|
|
8277
|
+
}
|
|
8278
|
+
catch {
|
|
8279
|
+
finishUnstarted();
|
|
8280
|
+
return;
|
|
8281
|
+
}
|
|
8143
8282
|
continue;
|
|
8144
8283
|
}
|
|
8145
8284
|
log('[GyosRouter] Cancelling previous navigation');
|
|
@@ -8158,6 +8297,10 @@ async function navigate(opts) {
|
|
|
8158
8297
|
resolveDone
|
|
8159
8298
|
};
|
|
8160
8299
|
activeNavigation = transaction;
|
|
8300
|
+
const abort = () => cancelNavigation(transaction);
|
|
8301
|
+
opts.signal?.addEventListener('abort', abort, { once: true });
|
|
8302
|
+
if (opts.signal?.aborted)
|
|
8303
|
+
abort();
|
|
8161
8304
|
const currentBaseUrl = document.baseURI;
|
|
8162
8305
|
rememberResourceUrls(document, currentBaseUrl);
|
|
8163
8306
|
const context = {
|
|
@@ -8181,6 +8324,7 @@ async function navigate(opts) {
|
|
|
8181
8324
|
}
|
|
8182
8325
|
};
|
|
8183
8326
|
try {
|
|
8327
|
+
assertActiveNavigation(transaction);
|
|
8184
8328
|
if (formEvent)
|
|
8185
8329
|
document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
|
|
8186
8330
|
runNavigationHooks(beforeNavigate, opts.url, context);
|
|
@@ -8193,6 +8337,10 @@ async function navigate(opts) {
|
|
|
8193
8337
|
saveScrollPosition();
|
|
8194
8338
|
// Pick target element to swap
|
|
8195
8339
|
let target = resolveTarget(opts.trigger, opts.targetSelector, opts.targetOutletIndex);
|
|
8340
|
+
if (opts.strictTarget && (!opts.targetSelector || !target?.matches(opts.targetSelector))) {
|
|
8341
|
+
context.outcome = 'invalid-response';
|
|
8342
|
+
return; // A queued explicit target disappeared; never broaden the swap.
|
|
8343
|
+
}
|
|
8196
8344
|
context.target = target;
|
|
8197
8345
|
if (!target) {
|
|
8198
8346
|
if (isActiveNavigation(transaction))
|
|
@@ -8237,7 +8385,12 @@ async function navigate(opts) {
|
|
|
8237
8385
|
else {
|
|
8238
8386
|
// Check preload cache if GET
|
|
8239
8387
|
const preloadKey = canonicalUrl(finalUrl, true);
|
|
8240
|
-
if (opts.
|
|
8388
|
+
if (opts.fresh) {
|
|
8389
|
+
preloadControllers.get(preloadKey)?.abort();
|
|
8390
|
+
preloadControllers.delete(preloadKey);
|
|
8391
|
+
preloadCache.delete(preloadKey);
|
|
8392
|
+
}
|
|
8393
|
+
if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
|
|
8241
8394
|
log('[GyosRouter] using preload cache for', finalUrl);
|
|
8242
8395
|
try {
|
|
8243
8396
|
response = await waitForNavigation(preloadCache.get(preloadKey), transaction.controller.signal);
|
|
@@ -8445,7 +8598,10 @@ async function navigate(opts) {
|
|
|
8445
8598
|
finalizeCommit();
|
|
8446
8599
|
}
|
|
8447
8600
|
// Handle scroll after mount scopes
|
|
8448
|
-
if (
|
|
8601
|
+
if (opts.scroll === false) {
|
|
8602
|
+
// Explicit refresh/navigation policy keeps the current viewport.
|
|
8603
|
+
}
|
|
8604
|
+
else if (changesState) {
|
|
8449
8605
|
handleScroll(targetUrl, opts.trigger);
|
|
8450
8606
|
}
|
|
8451
8607
|
else if (opts.popstate) {
|
|
@@ -8510,6 +8666,7 @@ async function navigate(opts) {
|
|
|
8510
8666
|
activeNavigation = null;
|
|
8511
8667
|
progressBar?.complete();
|
|
8512
8668
|
}
|
|
8669
|
+
opts.signal?.removeEventListener('abort', abort);
|
|
8513
8670
|
transaction.resolveDone();
|
|
8514
8671
|
if (formEvent)
|
|
8515
8672
|
submittingForms.delete(formEvent.form);
|
|
@@ -8520,6 +8677,7 @@ async function navigate(opts) {
|
|
|
8520
8677
|
detail: { ...formEvent, url, status, outcome, committed, fallback }
|
|
8521
8678
|
}));
|
|
8522
8679
|
}
|
|
8680
|
+
opts.onEnd?.({ ...context });
|
|
8523
8681
|
}
|
|
8524
8682
|
}
|
|
8525
8683
|
function shouldBoost(el) {
|
|
@@ -8550,7 +8708,7 @@ function onClickRouter(element) {
|
|
|
8550
8708
|
const scope = getScopeFromElement(element);
|
|
8551
8709
|
const jsonData = evaluateExpression(decodeURIComponent(element.getAttribute(paramsAttr) || ''), scope, false);
|
|
8552
8710
|
// The default changeState is false, as this is commonly used for: load more, infinite scroll, etc.
|
|
8553
|
-
|
|
8711
|
+
navigateRequest({
|
|
8554
8712
|
url: parsedUrl.toString(), method, trigger: element, jsonData, changeState: false
|
|
8555
8713
|
});
|
|
8556
8714
|
}
|
|
@@ -8599,7 +8757,7 @@ function onClick(event) {
|
|
|
8599
8757
|
return;
|
|
8600
8758
|
event.preventDefault();
|
|
8601
8759
|
// The default changeState is true, as this is commonly used for: navigation, etc.
|
|
8602
|
-
|
|
8760
|
+
navigateRequest({ url: url.toString(), method: 'GET', trigger: link, changeState: true });
|
|
8603
8761
|
}
|
|
8604
8762
|
function onMouseOverCapture(event) {
|
|
8605
8763
|
const target = event.target;
|
|
@@ -8655,7 +8813,7 @@ function onSubmit(event) {
|
|
|
8655
8813
|
return;
|
|
8656
8814
|
const formData = new FormData(form, submitter);
|
|
8657
8815
|
submittingForms.add(form);
|
|
8658
|
-
void
|
|
8816
|
+
void navigateRequest({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
|
|
8659
8817
|
}
|
|
8660
8818
|
function onPopState(event) {
|
|
8661
8819
|
const url = window.location.href;
|
|
@@ -8673,14 +8831,14 @@ function onPopState(event) {
|
|
|
8673
8831
|
}
|
|
8674
8832
|
event.preventDefault();
|
|
8675
8833
|
// The browser changes location before popstate fires. Stop any pending page
|
|
8676
|
-
// script immediately, then let
|
|
8834
|
+
// script immediately, then let navigateRequest() wait for its DOM finalizer.
|
|
8677
8835
|
if (activeNavigation?.committing)
|
|
8678
8836
|
cancelNavigation(activeNavigation);
|
|
8679
8837
|
// The browser has already moved to the destination history entry. Keep the
|
|
8680
8838
|
// router's entry pointer aligned before any restored page script can navigate.
|
|
8681
8839
|
currentHistoryEntryId = destinationEntryId;
|
|
8682
8840
|
// No snapshot, do a normal navigation without changing history (changeState: false)
|
|
8683
|
-
|
|
8841
|
+
navigateRequest({
|
|
8684
8842
|
url,
|
|
8685
8843
|
method: 'GET',
|
|
8686
8844
|
replace: true,
|
|
@@ -8762,10 +8920,12 @@ const Gyos = {
|
|
|
8762
8920
|
onAfterNavigate,
|
|
8763
8921
|
onBeforeSwap,
|
|
8764
8922
|
onNavigationEnd,
|
|
8923
|
+
navigate,
|
|
8924
|
+
refresh,
|
|
8765
8925
|
portalCreate,
|
|
8766
8926
|
portalDestroy,
|
|
8767
8927
|
setCspNonce,
|
|
8768
|
-
version: '0.
|
|
8928
|
+
version: '0.5.1'
|
|
8769
8929
|
};
|
|
8770
8930
|
|
|
8771
8931
|
const standardExpressionRuntime = {
|