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/dist/gyos.csp.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
|
*/
|
|
@@ -14768,7 +14768,7 @@
|
|
|
14768
14768
|
* Implements attribute-driven routing, snapshot caching, and persistent islands.
|
|
14769
14769
|
*/
|
|
14770
14770
|
const submittingForms = new WeakSet();
|
|
14771
|
-
async function visit(url, options,
|
|
14771
|
+
async function visit(url, options, refreshPolicy) {
|
|
14772
14772
|
const destination = new URL(url, document.baseURI);
|
|
14773
14773
|
if (!['http:', 'https:'].includes(destination.protocol) || destination.origin !== location.origin || destination.username || destination.password) {
|
|
14774
14774
|
throw new TypeError('Gyos.navigate requires a same-origin HTTP(S) URL without credentials.');
|
|
@@ -14785,18 +14785,23 @@
|
|
|
14785
14785
|
url: destination.href, method: 'GET',
|
|
14786
14786
|
changeState: options.history !== 'none', replace: options.history === 'replace',
|
|
14787
14787
|
targetSelector: options.target, strictTarget: options.target !== undefined, swapMode: options.swap,
|
|
14788
|
-
currentHead: options.currentHead, scroll: options.scroll, signal: options.signal,
|
|
14788
|
+
currentHead: options.currentHead, scroll: options.scroll, signal: options.signal, ...refreshPolicy,
|
|
14789
14789
|
onEnd: context => { result = context; }
|
|
14790
14790
|
});
|
|
14791
14791
|
return result;
|
|
14792
14792
|
}
|
|
14793
14793
|
/** Navigate through the boost pipeline. Resolves after navigation-end hooks. */
|
|
14794
14794
|
function navigate(url, options = {}) {
|
|
14795
|
-
return visit(url, options
|
|
14795
|
+
return visit(url, options);
|
|
14796
14796
|
}
|
|
14797
14797
|
/** Fetch the current URL again, preserving history and scroll by default. */
|
|
14798
|
-
function refresh(options = {}) {
|
|
14799
|
-
|
|
14798
|
+
function refresh({ background, strictSource, ...options } = {}) {
|
|
14799
|
+
if (strictSource === true && options.target === undefined) {
|
|
14800
|
+
return Promise.reject(new TypeError('Gyos.refresh with strictSource requires a target selector.'));
|
|
14801
|
+
}
|
|
14802
|
+
return visit(location.href, { history: 'none', scroll: false, ...options }, {
|
|
14803
|
+
fresh: true, background: background === true, strictSource: strictSource === true
|
|
14804
|
+
});
|
|
14800
14805
|
}
|
|
14801
14806
|
const snapshots = new Map();
|
|
14802
14807
|
const preloadCache = new Map();
|
|
@@ -14810,6 +14815,7 @@
|
|
|
14810
14815
|
let currentUrl = canonicalUrl(window.location.href, true);
|
|
14811
14816
|
let currentHistoryEntryId = history.state?.gyosEntryId || null;
|
|
14812
14817
|
let activeNavigation = null;
|
|
14818
|
+
let waitingNavigations = 0;
|
|
14813
14819
|
// Global progress bar instance
|
|
14814
14820
|
let progressBar = null;
|
|
14815
14821
|
const beforeNavigate = [];
|
|
@@ -15203,19 +15209,27 @@
|
|
|
15203
15209
|
console.error(`[GyosRouter] ${method} navigation could not be boosted; the request will not be replayed.`);
|
|
15204
15210
|
}
|
|
15205
15211
|
async function navigateRequest(opts) {
|
|
15206
|
-
const finishUnstarted = () => {
|
|
15212
|
+
const finishUnstarted = (signal = opts.signal) => {
|
|
15207
15213
|
opts.onEnd?.({ from: currentUrl, url: opts.url, method: opts.method,
|
|
15208
15214
|
trigger: opts.trigger || null, target: null, form: null, popstate: false,
|
|
15209
|
-
signal
|
|
15215
|
+
signal, status: null, committed: false, fallback: false, outcome: 'aborted' });
|
|
15210
15216
|
};
|
|
15211
15217
|
if (opts.signal?.aborted) {
|
|
15212
15218
|
finishUnstarted();
|
|
15213
15219
|
return;
|
|
15214
15220
|
}
|
|
15221
|
+
if (opts.background && (activeNavigation || waitingNavigations > 0)) {
|
|
15222
|
+
const skipped = new AbortController();
|
|
15223
|
+
skipped.abort();
|
|
15224
|
+
finishUnstarted(skipped.signal);
|
|
15225
|
+
return;
|
|
15226
|
+
}
|
|
15215
15227
|
while (activeNavigation) {
|
|
15216
15228
|
const previous = activeNavigation;
|
|
15217
15229
|
if (previous.committing) {
|
|
15218
15230
|
log('[GyosRouter] Waiting for previous DOM commit');
|
|
15231
|
+
// End hooks can request a refresh before this waiter resumes.
|
|
15232
|
+
waitingNavigations++;
|
|
15219
15233
|
try {
|
|
15220
15234
|
await (opts.signal ? waitForNavigation(previous.done, opts.signal) : previous.done);
|
|
15221
15235
|
}
|
|
@@ -15223,6 +15237,9 @@
|
|
|
15223
15237
|
finishUnstarted();
|
|
15224
15238
|
return;
|
|
15225
15239
|
}
|
|
15240
|
+
finally {
|
|
15241
|
+
waitingNavigations--;
|
|
15242
|
+
}
|
|
15226
15243
|
continue;
|
|
15227
15244
|
}
|
|
15228
15245
|
log('[GyosRouter] Cancelling previous navigation');
|
|
@@ -15257,14 +15274,16 @@
|
|
|
15257
15274
|
? { form: opts.form, url: opts.url, status: null, outcome: null, committed: false, fallback: false }
|
|
15258
15275
|
: null;
|
|
15259
15276
|
const fallback = (url, requestSent) => {
|
|
15260
|
-
context.fallback = context.method === 'GET' || (!requestSent && !!opts.form);
|
|
15277
|
+
context.fallback = !opts.background && (context.method === 'GET' || (!requestSent && !!opts.form));
|
|
15261
15278
|
context.outcome ?? (context.outcome = context.fallback ? 'fallback' : 'invalid-response');
|
|
15262
|
-
|
|
15279
|
+
if (!opts.background)
|
|
15280
|
+
fallbackFromBoost(opts, url, requestSent);
|
|
15263
15281
|
};
|
|
15282
|
+
const navigationProgress = opts.background ? null : progressBar;
|
|
15264
15283
|
const hasTargetSpinner = opts.trigger?.hasAttribute('g-router-spin');
|
|
15265
15284
|
const setRand = () => {
|
|
15266
|
-
if (isActiveNavigation(transaction) &&
|
|
15267
|
-
|
|
15285
|
+
if (isActiveNavigation(transaction) && navigationProgress && navigationProgress.getCurrentProgress() < 70) {
|
|
15286
|
+
navigationProgress.setProgress(navigationProgress.getCurrentProgress() + Math.random() * 8);
|
|
15268
15287
|
}
|
|
15269
15288
|
};
|
|
15270
15289
|
try {
|
|
@@ -15273,7 +15292,7 @@
|
|
|
15273
15292
|
document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
|
|
15274
15293
|
runNavigationHooks(beforeNavigate, opts.url, context);
|
|
15275
15294
|
assertActiveNavigation(transaction);
|
|
15276
|
-
|
|
15295
|
+
navigationProgress?.start();
|
|
15277
15296
|
// popstate already points history at the destination entry. Keep the visible
|
|
15278
15297
|
// page's position under currentUrl without overwriting that destination state.
|
|
15279
15298
|
rememberScrollPosition(opts.scrollSourceEntryId ?? currentHistoryEntryId);
|
|
@@ -15362,15 +15381,16 @@
|
|
|
15362
15381
|
else {
|
|
15363
15382
|
try {
|
|
15364
15383
|
// Update progress to rand 20 - 30%
|
|
15365
|
-
|
|
15366
|
-
|
|
15384
|
+
navigationProgress?.setProgress(Math.random() * 10 + 20);
|
|
15385
|
+
if (navigationProgress)
|
|
15386
|
+
transaction.interval = setInterval(setRand, 300);
|
|
15367
15387
|
response = await fetch(finalUrl, init);
|
|
15368
15388
|
assertActiveNavigation(transaction);
|
|
15369
15389
|
// A successful write can change HTML at any URL, including after a redirect.
|
|
15370
15390
|
if (response.ok && init.method !== 'GET')
|
|
15371
15391
|
clearPreloads();
|
|
15372
15392
|
// Update progress to rand 70 - 80% after fetch
|
|
15373
|
-
|
|
15393
|
+
navigationProgress?.setProgress(Math.random() * 10 + 70);
|
|
15374
15394
|
if (transaction.interval)
|
|
15375
15395
|
clearInterval(transaction.interval);
|
|
15376
15396
|
transaction.interval = null;
|
|
@@ -15408,6 +15428,13 @@
|
|
|
15408
15428
|
const doc = html
|
|
15409
15429
|
? parseNavigationDocument(html)
|
|
15410
15430
|
: document.implementation.createHTMLDocument();
|
|
15431
|
+
const matchedSource = opts.strictSource && opts.targetSelector
|
|
15432
|
+
? doc.querySelector(opts.targetSelector)
|
|
15433
|
+
: null;
|
|
15434
|
+
if (opts.strictSource && !(matchedSource instanceof HTMLElement) && isFullDocument(html || '')) {
|
|
15435
|
+
context.outcome = 'invalid-response';
|
|
15436
|
+
return; // A complete response must identify the requested region before any swap or snapshot.
|
|
15437
|
+
}
|
|
15411
15438
|
// Detached parsing cannot tell whether the live CSP permits an incoming base.
|
|
15412
15439
|
// Let native navigation enforce base-uri instead of authorizing its URLs ourselves.
|
|
15413
15440
|
if (doc.querySelector('base[href]') || opts.historyFragment?.querySelector('base[href]')) {
|
|
@@ -15422,7 +15449,9 @@
|
|
|
15422
15449
|
&& !opts.historyFragment && (opts.popstate && snapshots.has(urlWithoutHash)
|
|
15423
15450
|
? snapshots.get(urlWithoutHash).fullDocument : isFullDocument(html || ''));
|
|
15424
15451
|
// Pick source fragment
|
|
15425
|
-
const src = opts.historyFragment ||
|
|
15452
|
+
const src = opts.historyFragment || (matchedSource instanceof HTMLElement
|
|
15453
|
+
? matchedSource
|
|
15454
|
+
: pickSourceFragment(doc, target, targetOutletIndex));
|
|
15426
15455
|
stripInertFallbackContent(src);
|
|
15427
15456
|
assertActiveNavigation(transaction);
|
|
15428
15457
|
// Final URL is response.url because in headers there could be redirects
|
|
@@ -15445,7 +15474,7 @@
|
|
|
15445
15474
|
runNavigationHooks(beforeSwap, targetUrl, context);
|
|
15446
15475
|
assertActiveNavigation(transaction);
|
|
15447
15476
|
// Update progress to rand 80 - 90% before swap
|
|
15448
|
-
|
|
15477
|
+
navigationProgress?.setProgress(Math.random() * 10 + 80);
|
|
15449
15478
|
const outgoingHistoryFragment = changesState && !opts.replace && !isFullOutletNavigation
|
|
15450
15479
|
? cloneHistoryTarget(target)
|
|
15451
15480
|
: null;
|
|
@@ -15543,7 +15572,7 @@
|
|
|
15543
15572
|
target = committedTarget;
|
|
15544
15573
|
context.target = committedTarget;
|
|
15545
15574
|
context.committed = true;
|
|
15546
|
-
|
|
15575
|
+
navigationProgress?.reconnect();
|
|
15547
15576
|
committedRoots = roots;
|
|
15548
15577
|
}
|
|
15549
15578
|
});
|
|
@@ -15575,7 +15604,7 @@
|
|
|
15575
15604
|
}
|
|
15576
15605
|
};
|
|
15577
15606
|
// Apply view transition if available
|
|
15578
|
-
if (document.startViewTransition) {
|
|
15607
|
+
if (!opts.background && document.startViewTransition) {
|
|
15579
15608
|
const transition = document.startViewTransition(() => performUpdate());
|
|
15580
15609
|
consumeViewTransitionRejection(transition?.ready);
|
|
15581
15610
|
consumeViewTransitionRejection(transition?.finished);
|
|
@@ -15626,7 +15655,7 @@
|
|
|
15626
15655
|
hideTargetSpinner(transaction.spinner);
|
|
15627
15656
|
if (activeNavigation?.id === transaction.id) {
|
|
15628
15657
|
activeNavigation = null;
|
|
15629
|
-
|
|
15658
|
+
navigationProgress?.complete();
|
|
15630
15659
|
}
|
|
15631
15660
|
opts.signal?.removeEventListener('abort', abort);
|
|
15632
15661
|
transaction.resolveDone();
|
|
@@ -15918,7 +15947,7 @@
|
|
|
15918
15947
|
portalCreate,
|
|
15919
15948
|
portalDestroy,
|
|
15920
15949
|
setCspNonce,
|
|
15921
|
-
version: '0.
|
|
15950
|
+
version: '0.6.0'
|
|
15922
15951
|
};
|
|
15923
15952
|
|
|
15924
15953
|
setExpressionRuntime(cspExpressionRuntime);
|