gyosjs 0.5.6 → 0.5.7
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 +4 -1
- package/dist/core/router/router.d.ts.map +1 -1
- package/dist/gyos.auto.esm.js +82 -46
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +82 -46
- package/dist/gyos.auto.js.map +1 -1
- package/dist/gyos.auto.min.js +2 -2
- package/dist/gyos.csp.auto.esm.js +82 -46
- package/dist/gyos.csp.auto.esm.js.map +1 -1
- package/dist/gyos.csp.auto.js +82 -46
- package/dist/gyos.csp.auto.js.map +1 -1
- package/dist/gyos.csp.auto.min.js +2 -2
- package/dist/gyos.csp.esm.js +82 -46
- package/dist/gyos.csp.esm.js.map +1 -1
- package/dist/gyos.csp.js +82 -46
- package/dist/gyos.csp.js.map +1 -1
- package/dist/gyos.csp.min.js +2 -2
- package/dist/gyos.esm.js +82 -46
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +82 -46
- package/dist/gyos.js.map +1 -1
- package/dist/gyos.min.js +2 -2
- package/package.json +3 -3
package/dist/gyos.csp.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GyosJS v0.5.
|
|
2
|
+
* GyosJS v0.5.7
|
|
3
3
|
* (c) 2026
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -14793,7 +14793,6 @@ function refresh(options = {}) {
|
|
|
14793
14793
|
}
|
|
14794
14794
|
const snapshots = new Map();
|
|
14795
14795
|
const preloadCache = new Map();
|
|
14796
|
-
const preloadControllers = new Map();
|
|
14797
14796
|
const scrollPositions = new Map();
|
|
14798
14797
|
const historyFragments = new Map();
|
|
14799
14798
|
let routerStarted = false;
|
|
@@ -15113,6 +15112,15 @@ function buildRequest(opts) {
|
|
|
15113
15112
|
}
|
|
15114
15113
|
return { finalUrl: url.toString(), init };
|
|
15115
15114
|
}
|
|
15115
|
+
function discardPreload(key) {
|
|
15116
|
+
const entry = preloadCache.get(key);
|
|
15117
|
+
preloadCache.delete(key);
|
|
15118
|
+
entry?.controller.abort();
|
|
15119
|
+
}
|
|
15120
|
+
function clearPreloads() {
|
|
15121
|
+
for (const key of preloadCache.keys())
|
|
15122
|
+
discardPreload(key);
|
|
15123
|
+
}
|
|
15116
15124
|
function preload(url) {
|
|
15117
15125
|
const cacheKey = canonicalUrl(url, true);
|
|
15118
15126
|
if (preloadCache.has(cacheKey))
|
|
@@ -15127,11 +15135,11 @@ function preload(url) {
|
|
|
15127
15135
|
signal: controller.signal,
|
|
15128
15136
|
mode: 'same-origin'
|
|
15129
15137
|
});
|
|
15130
|
-
|
|
15131
|
-
|
|
15138
|
+
const entry = { request, controller };
|
|
15139
|
+
preloadCache.set(cacheKey, entry);
|
|
15132
15140
|
request.catch(() => {
|
|
15133
|
-
preloadCache.
|
|
15134
|
-
|
|
15141
|
+
if (preloadCache.get(cacheKey) === entry)
|
|
15142
|
+
preloadCache.delete(cacheKey);
|
|
15135
15143
|
});
|
|
15136
15144
|
}
|
|
15137
15145
|
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
@@ -15310,20 +15318,21 @@ async function navigateRequest(opts) {
|
|
|
15310
15318
|
else {
|
|
15311
15319
|
// Check preload cache if GET
|
|
15312
15320
|
const preloadKey = canonicalUrl(finalUrl, true);
|
|
15313
|
-
if (opts.fresh)
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
}
|
|
15318
|
-
if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
|
|
15321
|
+
if (opts.fresh)
|
|
15322
|
+
discardPreload(preloadKey);
|
|
15323
|
+
const entry = init.method === 'GET' ? preloadCache.get(preloadKey) : undefined;
|
|
15324
|
+
if (entry) {
|
|
15319
15325
|
log('[GyosRouter] using preload cache for', finalUrl);
|
|
15326
|
+
const signal = transaction.controller.signal;
|
|
15327
|
+
const discard = () => {
|
|
15328
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
15329
|
+
discardPreload(preloadKey);
|
|
15330
|
+
};
|
|
15331
|
+
signal.addEventListener('abort', discard, { once: true });
|
|
15320
15332
|
try {
|
|
15321
|
-
response = await waitForNavigation(
|
|
15333
|
+
response = await waitForNavigation(entry.request, signal);
|
|
15322
15334
|
}
|
|
15323
15335
|
catch (error) {
|
|
15324
|
-
preloadCache.delete(preloadKey);
|
|
15325
|
-
preloadControllers.get(preloadKey)?.abort();
|
|
15326
|
-
preloadControllers.delete(preloadKey);
|
|
15327
15336
|
if (error.name === 'AbortError')
|
|
15328
15337
|
throw error;
|
|
15329
15338
|
assertActiveNavigation(transaction);
|
|
@@ -15331,8 +15340,11 @@ async function navigateRequest(opts) {
|
|
|
15331
15340
|
fallback(finalUrl, true);
|
|
15332
15341
|
return;
|
|
15333
15342
|
}
|
|
15334
|
-
|
|
15335
|
-
|
|
15343
|
+
finally {
|
|
15344
|
+
signal.removeEventListener('abort', discard);
|
|
15345
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
15346
|
+
preloadCache.delete(preloadKey);
|
|
15347
|
+
}
|
|
15336
15348
|
}
|
|
15337
15349
|
else {
|
|
15338
15350
|
try {
|
|
@@ -15341,6 +15353,9 @@ async function navigateRequest(opts) {
|
|
|
15341
15353
|
transaction.interval = setInterval(setRand, 300);
|
|
15342
15354
|
response = await fetch(finalUrl, init);
|
|
15343
15355
|
assertActiveNavigation(transaction);
|
|
15356
|
+
// A successful write can change HTML at any URL, including after a redirect.
|
|
15357
|
+
if (response.ok && init.method !== 'GET')
|
|
15358
|
+
clearPreloads();
|
|
15344
15359
|
// Update progress to rand 70 - 80% after fetch
|
|
15345
15360
|
progressBar?.setProgress(Math.random() * 10 + 70);
|
|
15346
15361
|
if (transaction.interval)
|
|
@@ -15480,6 +15495,15 @@ async function navigateRequest(opts) {
|
|
|
15480
15495
|
// The global outlet is also the incoming layout root. Keep its node for
|
|
15481
15496
|
// inner swaps, but update attributes such as g-scope and layout classes.
|
|
15482
15497
|
try {
|
|
15498
|
+
if (syncDocumentAttributes && !document.querySelector('base[href]')) {
|
|
15499
|
+
document.head.querySelectorAll('base[target]').forEach(base => base.remove());
|
|
15500
|
+
const baseTarget = doc.head.querySelector('base[target]')?.getAttribute('target');
|
|
15501
|
+
if (baseTarget != null) {
|
|
15502
|
+
const base = document.createElement('base');
|
|
15503
|
+
base.target = baseTarget;
|
|
15504
|
+
document.head.prepend(base);
|
|
15505
|
+
}
|
|
15506
|
+
}
|
|
15483
15507
|
target = await performSwap(target, src, swapMode, {
|
|
15484
15508
|
syncRootAttributes: isFullOutletNavigation,
|
|
15485
15509
|
signal: transaction.controller.signal,
|
|
@@ -15605,10 +15629,39 @@ async function navigateRequest(opts) {
|
|
|
15605
15629
|
opts.onEnd?.({ ...context });
|
|
15606
15630
|
}
|
|
15607
15631
|
}
|
|
15608
|
-
function
|
|
15609
|
-
if (
|
|
15610
|
-
|
|
15611
|
-
|
|
15632
|
+
function eligibleAnchorUrl(link) {
|
|
15633
|
+
if (!(link instanceof HTMLAnchorElement) || !link.getAttribute('href')
|
|
15634
|
+
|| link.hasAttribute('download') || link.closest('[g-no-boost]'))
|
|
15635
|
+
return null;
|
|
15636
|
+
const target = link.getAttribute('target') ?? document.querySelector('base[target]')?.getAttribute('target');
|
|
15637
|
+
if (target && target.toLowerCase() !== '_self')
|
|
15638
|
+
return null;
|
|
15639
|
+
let url;
|
|
15640
|
+
try {
|
|
15641
|
+
url = new URL(link.href);
|
|
15642
|
+
}
|
|
15643
|
+
catch {
|
|
15644
|
+
return null;
|
|
15645
|
+
}
|
|
15646
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.origin !== location.origin
|
|
15647
|
+
|| url.username || url.password)
|
|
15648
|
+
return null;
|
|
15649
|
+
// URL.hash is empty for both an absent fragment and a trailing "#".
|
|
15650
|
+
if (url.href.includes('#') && canonicalUrl(url.href) === canonicalUrl(location.href))
|
|
15651
|
+
return null;
|
|
15652
|
+
// A page visit would need to remove the outgoing base before inserting
|
|
15653
|
+
// relative resources. Let the browser switch documents and enforce base-uri.
|
|
15654
|
+
if (document.querySelector('base[href]') && !link.hasAttribute('g-current-head')
|
|
15655
|
+
&& !['append', 'prepend'].includes(link.getAttribute('g-swap')?.toLowerCase() || '')) {
|
|
15656
|
+
try {
|
|
15657
|
+
if (resolveTarget(link) === findGlobalOutlet())
|
|
15658
|
+
return null;
|
|
15659
|
+
}
|
|
15660
|
+
catch {
|
|
15661
|
+
return null;
|
|
15662
|
+
}
|
|
15663
|
+
}
|
|
15664
|
+
return url;
|
|
15612
15665
|
}
|
|
15613
15666
|
function onClickRouter(element) {
|
|
15614
15667
|
log('[GyosRouter] g-router-link clicked');
|
|
@@ -15662,23 +15715,10 @@ function onClick(event) {
|
|
|
15662
15715
|
return;
|
|
15663
15716
|
}
|
|
15664
15717
|
const link = target.closest('a');
|
|
15665
|
-
if (!link)
|
|
15666
|
-
return;
|
|
15667
|
-
const href = link.getAttribute('href');
|
|
15668
|
-
if (!href)
|
|
15718
|
+
if (!link || !(link.hasAttribute('g-boost') || hasGlobalBoost()))
|
|
15669
15719
|
return;
|
|
15670
|
-
const url =
|
|
15671
|
-
if (url
|
|
15672
|
-
return;
|
|
15673
|
-
if (url.hash && canonicalUrl(url.href) === canonicalUrl(window.location.href))
|
|
15674
|
-
return;
|
|
15675
|
-
if (link.closest('[g-no-boost]'))
|
|
15676
|
-
return;
|
|
15677
|
-
if (link.hasAttribute('download'))
|
|
15678
|
-
return;
|
|
15679
|
-
if (link.getAttribute('target') && link.getAttribute('target') !== '_self')
|
|
15680
|
-
return;
|
|
15681
|
-
if (!shouldBoost(link))
|
|
15720
|
+
const url = eligibleAnchorUrl(link);
|
|
15721
|
+
if (!url)
|
|
15682
15722
|
return;
|
|
15683
15723
|
event.preventDefault();
|
|
15684
15724
|
// The default changeState is true, as this is commonly used for: navigation, etc.
|
|
@@ -15691,13 +15731,9 @@ function onMouseOverCapture(event) {
|
|
|
15691
15731
|
const link = target.closest('a[g-preload]');
|
|
15692
15732
|
if (!link)
|
|
15693
15733
|
return;
|
|
15694
|
-
const
|
|
15695
|
-
if (
|
|
15696
|
-
|
|
15697
|
-
const url = new URL(href, window.location.href);
|
|
15698
|
-
if (url.origin !== window.location.origin)
|
|
15699
|
-
return;
|
|
15700
|
-
preload(url.toString());
|
|
15734
|
+
const url = eligibleAnchorUrl(link);
|
|
15735
|
+
if (url)
|
|
15736
|
+
preload(url.href);
|
|
15701
15737
|
}
|
|
15702
15738
|
function onSubmit(event) {
|
|
15703
15739
|
if (event.defaultPrevented)
|
|
@@ -15850,7 +15886,7 @@ const Gyos = {
|
|
|
15850
15886
|
portalCreate,
|
|
15851
15887
|
portalDestroy,
|
|
15852
15888
|
setCspNonce,
|
|
15853
|
-
version: '0.5.
|
|
15889
|
+
version: '0.5.7'
|
|
15854
15890
|
};
|
|
15855
15891
|
|
|
15856
15892
|
setExpressionRuntime(cspExpressionRuntime);
|