gyosjs 0.5.8 → 0.6.0
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/router/router.d.ts +9 -1
- package/dist/core/router/router.d.ts.map +1 -1
- package/dist/gyos.auto.esm.js +51 -22
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +51 -22
- package/dist/gyos.auto.js.map +1 -1
- package/dist/gyos.auto.min.js +2 -2
- package/dist/gyos.csp.auto.esm.js +51 -22
- package/dist/gyos.csp.auto.esm.js.map +1 -1
- package/dist/gyos.csp.auto.js +51 -22
- package/dist/gyos.csp.auto.js.map +1 -1
- package/dist/gyos.csp.auto.min.js +2 -2
- package/dist/gyos.csp.esm.js +51 -22
- package/dist/gyos.csp.esm.js.map +1 -1
- package/dist/gyos.csp.js +51 -22
- package/dist/gyos.csp.js.map +1 -1
- package/dist/gyos.csp.min.js +2 -2
- package/dist/gyos.esm.js +51 -22
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +51 -22
- package/dist/gyos.js.map +1 -1
- package/dist/gyos.min.js +2 -2
- package/dist/public-api.d.ts +1 -1
- package/dist/public-api.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.6.0/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.
|
|
@@ -47,7 +47,9 @@ interface NavigateOptions {
|
|
|
47
47
|
signal?: AbortSignal;
|
|
48
48
|
scroll?: boolean;
|
|
49
49
|
fresh?: boolean;
|
|
50
|
+
background?: boolean;
|
|
50
51
|
strictTarget?: boolean;
|
|
52
|
+
strictSource?: boolean;
|
|
51
53
|
onEnd?: (context: NavigationContext) => void;
|
|
52
54
|
historyFragment?: HTMLElement;
|
|
53
55
|
historyEntryId?: string | null;
|
|
@@ -62,10 +64,16 @@ export interface NavigationOptions {
|
|
|
62
64
|
currentHead?: boolean;
|
|
63
65
|
signal?: AbortSignal;
|
|
64
66
|
}
|
|
67
|
+
export interface RefreshOptions extends NavigationOptions {
|
|
68
|
+
/** Skip when another router transaction is in progress. */
|
|
69
|
+
background?: boolean;
|
|
70
|
+
/** Require the target selector in a complete HTML response. Fragments may omit it. */
|
|
71
|
+
strictSource?: boolean;
|
|
72
|
+
}
|
|
65
73
|
/** Navigate through the boost pipeline. Resolves after navigation-end hooks. */
|
|
66
74
|
export declare function navigate(url: string | URL, options?: NavigationOptions): Promise<NavigationContext>;
|
|
67
75
|
/** Fetch the current URL again, preserving history and scroll by default. */
|
|
68
|
-
export declare function refresh(options?:
|
|
76
|
+
export declare function refresh({ background, strictSource, ...options }?: RefreshOptions): Promise<NavigationContext>;
|
|
69
77
|
interface Snapshot {
|
|
70
78
|
html: string;
|
|
71
79
|
fullDocument: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/core/router/router.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,aAAa;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,eAAe,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,MAAM,iBAAiB,GAAG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,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,OAAO,EAAE,GAAE,cAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAOjH;AAgBD,UAAU,QAAQ;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,OAAO,CAAC;CACtB;AA8CD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI,CAErE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI,CAEpE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,IAAI,CAEjE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,MAAM,IAAI,CAE1F;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CA8BzD;AAiED,iBAAS,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAcrD;AAySD,iBAAe,eAAe,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA2bnE;AAmMD,iBAAS,gBAAgB,IAAI,IAAI,CAwBhC;AAGD,eAAO,MAAM,YAAY;;;;;iBA1mCuB,OAAO,CAAC,QAAQ,CAAC;oBAAc,eAAe;;;CAgnC7F,CAAC"}
|
package/dist/gyos.auto.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GyosJS v0.
|
|
2
|
+
* GyosJS v0.6.0
|
|
3
3
|
* (c) 2026
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -8113,7 +8113,7 @@ function prepareNavigationHtml(html) {
|
|
|
8113
8113
|
* Implements attribute-driven routing, snapshot caching, and persistent islands.
|
|
8114
8114
|
*/
|
|
8115
8115
|
const submittingForms = new WeakSet();
|
|
8116
|
-
async function visit(url, options,
|
|
8116
|
+
async function visit(url, options, refreshPolicy) {
|
|
8117
8117
|
const destination = new URL(url, document.baseURI);
|
|
8118
8118
|
if (!['http:', 'https:'].includes(destination.protocol) || destination.origin !== location.origin || destination.username || destination.password) {
|
|
8119
8119
|
throw new TypeError('Gyos.navigate requires a same-origin HTTP(S) URL without credentials.');
|
|
@@ -8130,18 +8130,23 @@ async function visit(url, options, fresh) {
|
|
|
8130
8130
|
url: destination.href, method: 'GET',
|
|
8131
8131
|
changeState: options.history !== 'none', replace: options.history === 'replace',
|
|
8132
8132
|
targetSelector: options.target, strictTarget: options.target !== undefined, swapMode: options.swap,
|
|
8133
|
-
currentHead: options.currentHead, scroll: options.scroll, signal: options.signal,
|
|
8133
|
+
currentHead: options.currentHead, scroll: options.scroll, signal: options.signal, ...refreshPolicy,
|
|
8134
8134
|
onEnd: context => { result = context; }
|
|
8135
8135
|
});
|
|
8136
8136
|
return result;
|
|
8137
8137
|
}
|
|
8138
8138
|
/** Navigate through the boost pipeline. Resolves after navigation-end hooks. */
|
|
8139
8139
|
function navigate(url, options = {}) {
|
|
8140
|
-
return visit(url, options
|
|
8140
|
+
return visit(url, options);
|
|
8141
8141
|
}
|
|
8142
8142
|
/** Fetch the current URL again, preserving history and scroll by default. */
|
|
8143
|
-
function refresh(options = {}) {
|
|
8144
|
-
|
|
8143
|
+
function refresh({ background, strictSource, ...options } = {}) {
|
|
8144
|
+
if (strictSource === true && options.target === undefined) {
|
|
8145
|
+
return Promise.reject(new TypeError('Gyos.refresh with strictSource requires a target selector.'));
|
|
8146
|
+
}
|
|
8147
|
+
return visit(location.href, { history: 'none', scroll: false, ...options }, {
|
|
8148
|
+
fresh: true, background: background === true, strictSource: strictSource === true
|
|
8149
|
+
});
|
|
8145
8150
|
}
|
|
8146
8151
|
const snapshots = new Map();
|
|
8147
8152
|
const preloadCache = new Map();
|
|
@@ -8155,6 +8160,7 @@ let progressBarEnabled = true;
|
|
|
8155
8160
|
let currentUrl = canonicalUrl(window.location.href, true);
|
|
8156
8161
|
let currentHistoryEntryId = history.state?.gyosEntryId || null;
|
|
8157
8162
|
let activeNavigation = null;
|
|
8163
|
+
let waitingNavigations = 0;
|
|
8158
8164
|
// Global progress bar instance
|
|
8159
8165
|
let progressBar = null;
|
|
8160
8166
|
const beforeNavigate = [];
|
|
@@ -8548,19 +8554,27 @@ function fallbackFromBoost(opts, url, requestSent) {
|
|
|
8548
8554
|
console.error(`[GyosRouter] ${method} navigation could not be boosted; the request will not be replayed.`);
|
|
8549
8555
|
}
|
|
8550
8556
|
async function navigateRequest(opts) {
|
|
8551
|
-
const finishUnstarted = () => {
|
|
8557
|
+
const finishUnstarted = (signal = opts.signal) => {
|
|
8552
8558
|
opts.onEnd?.({ from: currentUrl, url: opts.url, method: opts.method,
|
|
8553
8559
|
trigger: opts.trigger || null, target: null, form: null, popstate: false,
|
|
8554
|
-
signal
|
|
8560
|
+
signal, status: null, committed: false, fallback: false, outcome: 'aborted' });
|
|
8555
8561
|
};
|
|
8556
8562
|
if (opts.signal?.aborted) {
|
|
8557
8563
|
finishUnstarted();
|
|
8558
8564
|
return;
|
|
8559
8565
|
}
|
|
8566
|
+
if (opts.background && (activeNavigation || waitingNavigations > 0)) {
|
|
8567
|
+
const skipped = new AbortController();
|
|
8568
|
+
skipped.abort();
|
|
8569
|
+
finishUnstarted(skipped.signal);
|
|
8570
|
+
return;
|
|
8571
|
+
}
|
|
8560
8572
|
while (activeNavigation) {
|
|
8561
8573
|
const previous = activeNavigation;
|
|
8562
8574
|
if (previous.committing) {
|
|
8563
8575
|
log('[GyosRouter] Waiting for previous DOM commit');
|
|
8576
|
+
// End hooks can request a refresh before this waiter resumes.
|
|
8577
|
+
waitingNavigations++;
|
|
8564
8578
|
try {
|
|
8565
8579
|
await (opts.signal ? waitForNavigation(previous.done, opts.signal) : previous.done);
|
|
8566
8580
|
}
|
|
@@ -8568,6 +8582,9 @@ async function navigateRequest(opts) {
|
|
|
8568
8582
|
finishUnstarted();
|
|
8569
8583
|
return;
|
|
8570
8584
|
}
|
|
8585
|
+
finally {
|
|
8586
|
+
waitingNavigations--;
|
|
8587
|
+
}
|
|
8571
8588
|
continue;
|
|
8572
8589
|
}
|
|
8573
8590
|
log('[GyosRouter] Cancelling previous navigation');
|
|
@@ -8602,14 +8619,16 @@ async function navigateRequest(opts) {
|
|
|
8602
8619
|
? { form: opts.form, url: opts.url, status: null, outcome: null, committed: false, fallback: false }
|
|
8603
8620
|
: null;
|
|
8604
8621
|
const fallback = (url, requestSent) => {
|
|
8605
|
-
context.fallback = context.method === 'GET' || (!requestSent && !!opts.form);
|
|
8622
|
+
context.fallback = !opts.background && (context.method === 'GET' || (!requestSent && !!opts.form));
|
|
8606
8623
|
context.outcome ?? (context.outcome = context.fallback ? 'fallback' : 'invalid-response');
|
|
8607
|
-
|
|
8624
|
+
if (!opts.background)
|
|
8625
|
+
fallbackFromBoost(opts, url, requestSent);
|
|
8608
8626
|
};
|
|
8627
|
+
const navigationProgress = opts.background ? null : progressBar;
|
|
8609
8628
|
const hasTargetSpinner = opts.trigger?.hasAttribute('g-router-spin');
|
|
8610
8629
|
const setRand = () => {
|
|
8611
|
-
if (isActiveNavigation(transaction) &&
|
|
8612
|
-
|
|
8630
|
+
if (isActiveNavigation(transaction) && navigationProgress && navigationProgress.getCurrentProgress() < 70) {
|
|
8631
|
+
navigationProgress.setProgress(navigationProgress.getCurrentProgress() + Math.random() * 8);
|
|
8613
8632
|
}
|
|
8614
8633
|
};
|
|
8615
8634
|
try {
|
|
@@ -8618,7 +8637,7 @@ async function navigateRequest(opts) {
|
|
|
8618
8637
|
document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
|
|
8619
8638
|
runNavigationHooks(beforeNavigate, opts.url, context);
|
|
8620
8639
|
assertActiveNavigation(transaction);
|
|
8621
|
-
|
|
8640
|
+
navigationProgress?.start();
|
|
8622
8641
|
// popstate already points history at the destination entry. Keep the visible
|
|
8623
8642
|
// page's position under currentUrl without overwriting that destination state.
|
|
8624
8643
|
rememberScrollPosition(opts.scrollSourceEntryId ?? currentHistoryEntryId);
|
|
@@ -8707,15 +8726,16 @@ async function navigateRequest(opts) {
|
|
|
8707
8726
|
else {
|
|
8708
8727
|
try {
|
|
8709
8728
|
// Update progress to rand 20 - 30%
|
|
8710
|
-
|
|
8711
|
-
|
|
8729
|
+
navigationProgress?.setProgress(Math.random() * 10 + 20);
|
|
8730
|
+
if (navigationProgress)
|
|
8731
|
+
transaction.interval = setInterval(setRand, 300);
|
|
8712
8732
|
response = await fetch(finalUrl, init);
|
|
8713
8733
|
assertActiveNavigation(transaction);
|
|
8714
8734
|
// A successful write can change HTML at any URL, including after a redirect.
|
|
8715
8735
|
if (response.ok && init.method !== 'GET')
|
|
8716
8736
|
clearPreloads();
|
|
8717
8737
|
// Update progress to rand 70 - 80% after fetch
|
|
8718
|
-
|
|
8738
|
+
navigationProgress?.setProgress(Math.random() * 10 + 70);
|
|
8719
8739
|
if (transaction.interval)
|
|
8720
8740
|
clearInterval(transaction.interval);
|
|
8721
8741
|
transaction.interval = null;
|
|
@@ -8753,6 +8773,13 @@ async function navigateRequest(opts) {
|
|
|
8753
8773
|
const doc = html
|
|
8754
8774
|
? parseNavigationDocument(html)
|
|
8755
8775
|
: document.implementation.createHTMLDocument();
|
|
8776
|
+
const matchedSource = opts.strictSource && opts.targetSelector
|
|
8777
|
+
? doc.querySelector(opts.targetSelector)
|
|
8778
|
+
: null;
|
|
8779
|
+
if (opts.strictSource && !(matchedSource instanceof HTMLElement) && isFullDocument(html || '')) {
|
|
8780
|
+
context.outcome = 'invalid-response';
|
|
8781
|
+
return; // A complete response must identify the requested region before any swap or snapshot.
|
|
8782
|
+
}
|
|
8756
8783
|
// Detached parsing cannot tell whether the live CSP permits an incoming base.
|
|
8757
8784
|
// Let native navigation enforce base-uri instead of authorizing its URLs ourselves.
|
|
8758
8785
|
if (doc.querySelector('base[href]') || opts.historyFragment?.querySelector('base[href]')) {
|
|
@@ -8767,7 +8794,9 @@ async function navigateRequest(opts) {
|
|
|
8767
8794
|
&& !opts.historyFragment && (opts.popstate && snapshots.has(urlWithoutHash)
|
|
8768
8795
|
? snapshots.get(urlWithoutHash).fullDocument : isFullDocument(html || ''));
|
|
8769
8796
|
// Pick source fragment
|
|
8770
|
-
const src = opts.historyFragment ||
|
|
8797
|
+
const src = opts.historyFragment || (matchedSource instanceof HTMLElement
|
|
8798
|
+
? matchedSource
|
|
8799
|
+
: pickSourceFragment(doc, target, targetOutletIndex));
|
|
8771
8800
|
stripInertFallbackContent(src);
|
|
8772
8801
|
assertActiveNavigation(transaction);
|
|
8773
8802
|
// Final URL is response.url because in headers there could be redirects
|
|
@@ -8790,7 +8819,7 @@ async function navigateRequest(opts) {
|
|
|
8790
8819
|
runNavigationHooks(beforeSwap, targetUrl, context);
|
|
8791
8820
|
assertActiveNavigation(transaction);
|
|
8792
8821
|
// Update progress to rand 80 - 90% before swap
|
|
8793
|
-
|
|
8822
|
+
navigationProgress?.setProgress(Math.random() * 10 + 80);
|
|
8794
8823
|
const outgoingHistoryFragment = changesState && !opts.replace && !isFullOutletNavigation
|
|
8795
8824
|
? cloneHistoryTarget(target)
|
|
8796
8825
|
: null;
|
|
@@ -8888,7 +8917,7 @@ async function navigateRequest(opts) {
|
|
|
8888
8917
|
target = committedTarget;
|
|
8889
8918
|
context.target = committedTarget;
|
|
8890
8919
|
context.committed = true;
|
|
8891
|
-
|
|
8920
|
+
navigationProgress?.reconnect();
|
|
8892
8921
|
committedRoots = roots;
|
|
8893
8922
|
}
|
|
8894
8923
|
});
|
|
@@ -8920,7 +8949,7 @@ async function navigateRequest(opts) {
|
|
|
8920
8949
|
}
|
|
8921
8950
|
};
|
|
8922
8951
|
// Apply view transition if available
|
|
8923
|
-
if (document.startViewTransition) {
|
|
8952
|
+
if (!opts.background && document.startViewTransition) {
|
|
8924
8953
|
const transition = document.startViewTransition(() => performUpdate());
|
|
8925
8954
|
consumeViewTransitionRejection(transition?.ready);
|
|
8926
8955
|
consumeViewTransitionRejection(transition?.finished);
|
|
@@ -8971,7 +9000,7 @@ async function navigateRequest(opts) {
|
|
|
8971
9000
|
hideTargetSpinner(transaction.spinner);
|
|
8972
9001
|
if (activeNavigation?.id === transaction.id) {
|
|
8973
9002
|
activeNavigation = null;
|
|
8974
|
-
|
|
9003
|
+
navigationProgress?.complete();
|
|
8975
9004
|
}
|
|
8976
9005
|
opts.signal?.removeEventListener('abort', abort);
|
|
8977
9006
|
transaction.resolveDone();
|
|
@@ -9263,7 +9292,7 @@ const Gyos = {
|
|
|
9263
9292
|
portalCreate,
|
|
9264
9293
|
portalDestroy,
|
|
9265
9294
|
setCspNonce,
|
|
9266
|
-
version: '0.
|
|
9295
|
+
version: '0.6.0'
|
|
9267
9296
|
};
|
|
9268
9297
|
|
|
9269
9298
|
const standardExpressionRuntime = {
|