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.auto.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
|
*/
|
|
@@ -8150,7 +8150,6 @@
|
|
|
8150
8150
|
}
|
|
8151
8151
|
const snapshots = new Map();
|
|
8152
8152
|
const preloadCache = new Map();
|
|
8153
|
-
const preloadControllers = new Map();
|
|
8154
8153
|
const scrollPositions = new Map();
|
|
8155
8154
|
const historyFragments = new Map();
|
|
8156
8155
|
let routerStarted = false;
|
|
@@ -8470,6 +8469,15 @@
|
|
|
8470
8469
|
}
|
|
8471
8470
|
return { finalUrl: url.toString(), init };
|
|
8472
8471
|
}
|
|
8472
|
+
function discardPreload(key) {
|
|
8473
|
+
const entry = preloadCache.get(key);
|
|
8474
|
+
preloadCache.delete(key);
|
|
8475
|
+
entry?.controller.abort();
|
|
8476
|
+
}
|
|
8477
|
+
function clearPreloads() {
|
|
8478
|
+
for (const key of preloadCache.keys())
|
|
8479
|
+
discardPreload(key);
|
|
8480
|
+
}
|
|
8473
8481
|
function preload(url) {
|
|
8474
8482
|
const cacheKey = canonicalUrl(url, true);
|
|
8475
8483
|
if (preloadCache.has(cacheKey))
|
|
@@ -8484,11 +8492,11 @@
|
|
|
8484
8492
|
signal: controller.signal,
|
|
8485
8493
|
mode: 'same-origin'
|
|
8486
8494
|
});
|
|
8487
|
-
|
|
8488
|
-
|
|
8495
|
+
const entry = { request, controller };
|
|
8496
|
+
preloadCache.set(cacheKey, entry);
|
|
8489
8497
|
request.catch(() => {
|
|
8490
|
-
preloadCache.
|
|
8491
|
-
|
|
8498
|
+
if (preloadCache.get(cacheKey) === entry)
|
|
8499
|
+
preloadCache.delete(cacheKey);
|
|
8492
8500
|
});
|
|
8493
8501
|
}
|
|
8494
8502
|
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
@@ -8667,20 +8675,21 @@
|
|
|
8667
8675
|
else {
|
|
8668
8676
|
// Check preload cache if GET
|
|
8669
8677
|
const preloadKey = canonicalUrl(finalUrl, true);
|
|
8670
|
-
if (opts.fresh)
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
}
|
|
8675
|
-
if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
|
|
8678
|
+
if (opts.fresh)
|
|
8679
|
+
discardPreload(preloadKey);
|
|
8680
|
+
const entry = init.method === 'GET' ? preloadCache.get(preloadKey) : undefined;
|
|
8681
|
+
if (entry) {
|
|
8676
8682
|
log('[GyosRouter] using preload cache for', finalUrl);
|
|
8683
|
+
const signal = transaction.controller.signal;
|
|
8684
|
+
const discard = () => {
|
|
8685
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8686
|
+
discardPreload(preloadKey);
|
|
8687
|
+
};
|
|
8688
|
+
signal.addEventListener('abort', discard, { once: true });
|
|
8677
8689
|
try {
|
|
8678
|
-
response = await waitForNavigation(
|
|
8690
|
+
response = await waitForNavigation(entry.request, signal);
|
|
8679
8691
|
}
|
|
8680
8692
|
catch (error) {
|
|
8681
|
-
preloadCache.delete(preloadKey);
|
|
8682
|
-
preloadControllers.get(preloadKey)?.abort();
|
|
8683
|
-
preloadControllers.delete(preloadKey);
|
|
8684
8693
|
if (error.name === 'AbortError')
|
|
8685
8694
|
throw error;
|
|
8686
8695
|
assertActiveNavigation(transaction);
|
|
@@ -8688,8 +8697,11 @@
|
|
|
8688
8697
|
fallback(finalUrl, true);
|
|
8689
8698
|
return;
|
|
8690
8699
|
}
|
|
8691
|
-
|
|
8692
|
-
|
|
8700
|
+
finally {
|
|
8701
|
+
signal.removeEventListener('abort', discard);
|
|
8702
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8703
|
+
preloadCache.delete(preloadKey);
|
|
8704
|
+
}
|
|
8693
8705
|
}
|
|
8694
8706
|
else {
|
|
8695
8707
|
try {
|
|
@@ -8698,6 +8710,9 @@
|
|
|
8698
8710
|
transaction.interval = setInterval(setRand, 300);
|
|
8699
8711
|
response = await fetch(finalUrl, init);
|
|
8700
8712
|
assertActiveNavigation(transaction);
|
|
8713
|
+
// A successful write can change HTML at any URL, including after a redirect.
|
|
8714
|
+
if (response.ok && init.method !== 'GET')
|
|
8715
|
+
clearPreloads();
|
|
8701
8716
|
// Update progress to rand 70 - 80% after fetch
|
|
8702
8717
|
progressBar?.setProgress(Math.random() * 10 + 70);
|
|
8703
8718
|
if (transaction.interval)
|
|
@@ -8837,6 +8852,15 @@
|
|
|
8837
8852
|
// The global outlet is also the incoming layout root. Keep its node for
|
|
8838
8853
|
// inner swaps, but update attributes such as g-scope and layout classes.
|
|
8839
8854
|
try {
|
|
8855
|
+
if (syncDocumentAttributes && !document.querySelector('base[href]')) {
|
|
8856
|
+
document.head.querySelectorAll('base[target]').forEach(base => base.remove());
|
|
8857
|
+
const baseTarget = doc.head.querySelector('base[target]')?.getAttribute('target');
|
|
8858
|
+
if (baseTarget != null) {
|
|
8859
|
+
const base = document.createElement('base');
|
|
8860
|
+
base.target = baseTarget;
|
|
8861
|
+
document.head.prepend(base);
|
|
8862
|
+
}
|
|
8863
|
+
}
|
|
8840
8864
|
target = await performSwap(target, src, swapMode, {
|
|
8841
8865
|
syncRootAttributes: isFullOutletNavigation,
|
|
8842
8866
|
signal: transaction.controller.signal,
|
|
@@ -8962,10 +8986,39 @@
|
|
|
8962
8986
|
opts.onEnd?.({ ...context });
|
|
8963
8987
|
}
|
|
8964
8988
|
}
|
|
8965
|
-
function
|
|
8966
|
-
if (
|
|
8967
|
-
|
|
8968
|
-
|
|
8989
|
+
function eligibleAnchorUrl(link) {
|
|
8990
|
+
if (!(link instanceof HTMLAnchorElement) || !link.getAttribute('href')
|
|
8991
|
+
|| link.hasAttribute('download') || link.closest('[g-no-boost]'))
|
|
8992
|
+
return null;
|
|
8993
|
+
const target = link.getAttribute('target') ?? document.querySelector('base[target]')?.getAttribute('target');
|
|
8994
|
+
if (target && target.toLowerCase() !== '_self')
|
|
8995
|
+
return null;
|
|
8996
|
+
let url;
|
|
8997
|
+
try {
|
|
8998
|
+
url = new URL(link.href);
|
|
8999
|
+
}
|
|
9000
|
+
catch {
|
|
9001
|
+
return null;
|
|
9002
|
+
}
|
|
9003
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.origin !== location.origin
|
|
9004
|
+
|| url.username || url.password)
|
|
9005
|
+
return null;
|
|
9006
|
+
// URL.hash is empty for both an absent fragment and a trailing "#".
|
|
9007
|
+
if (url.href.includes('#') && canonicalUrl(url.href) === canonicalUrl(location.href))
|
|
9008
|
+
return null;
|
|
9009
|
+
// A page visit would need to remove the outgoing base before inserting
|
|
9010
|
+
// relative resources. Let the browser switch documents and enforce base-uri.
|
|
9011
|
+
if (document.querySelector('base[href]') && !link.hasAttribute('g-current-head')
|
|
9012
|
+
&& !['append', 'prepend'].includes(link.getAttribute('g-swap')?.toLowerCase() || '')) {
|
|
9013
|
+
try {
|
|
9014
|
+
if (resolveTarget(link) === findGlobalOutlet())
|
|
9015
|
+
return null;
|
|
9016
|
+
}
|
|
9017
|
+
catch {
|
|
9018
|
+
return null;
|
|
9019
|
+
}
|
|
9020
|
+
}
|
|
9021
|
+
return url;
|
|
8969
9022
|
}
|
|
8970
9023
|
function onClickRouter(element) {
|
|
8971
9024
|
log('[GyosRouter] g-router-link clicked');
|
|
@@ -9019,23 +9072,10 @@
|
|
|
9019
9072
|
return;
|
|
9020
9073
|
}
|
|
9021
9074
|
const link = target.closest('a');
|
|
9022
|
-
if (!link)
|
|
9023
|
-
return;
|
|
9024
|
-
const href = link.getAttribute('href');
|
|
9025
|
-
if (!href)
|
|
9075
|
+
if (!link || !(link.hasAttribute('g-boost') || hasGlobalBoost()))
|
|
9026
9076
|
return;
|
|
9027
|
-
const url =
|
|
9028
|
-
if (url
|
|
9029
|
-
return;
|
|
9030
|
-
if (url.hash && canonicalUrl(url.href) === canonicalUrl(window.location.href))
|
|
9031
|
-
return;
|
|
9032
|
-
if (link.closest('[g-no-boost]'))
|
|
9033
|
-
return;
|
|
9034
|
-
if (link.hasAttribute('download'))
|
|
9035
|
-
return;
|
|
9036
|
-
if (link.getAttribute('target') && link.getAttribute('target') !== '_self')
|
|
9037
|
-
return;
|
|
9038
|
-
if (!shouldBoost(link))
|
|
9077
|
+
const url = eligibleAnchorUrl(link);
|
|
9078
|
+
if (!url)
|
|
9039
9079
|
return;
|
|
9040
9080
|
event.preventDefault();
|
|
9041
9081
|
// The default changeState is true, as this is commonly used for: navigation, etc.
|
|
@@ -9048,13 +9088,9 @@
|
|
|
9048
9088
|
const link = target.closest('a[g-preload]');
|
|
9049
9089
|
if (!link)
|
|
9050
9090
|
return;
|
|
9051
|
-
const
|
|
9052
|
-
if (
|
|
9053
|
-
|
|
9054
|
-
const url = new URL(href, window.location.href);
|
|
9055
|
-
if (url.origin !== window.location.origin)
|
|
9056
|
-
return;
|
|
9057
|
-
preload(url.toString());
|
|
9091
|
+
const url = eligibleAnchorUrl(link);
|
|
9092
|
+
if (url)
|
|
9093
|
+
preload(url.href);
|
|
9058
9094
|
}
|
|
9059
9095
|
function onSubmit(event) {
|
|
9060
9096
|
if (event.defaultPrevented)
|
|
@@ -9207,7 +9243,7 @@
|
|
|
9207
9243
|
portalCreate,
|
|
9208
9244
|
portalDestroy,
|
|
9209
9245
|
setCspNonce,
|
|
9210
|
-
version: '0.5.
|
|
9246
|
+
version: '0.5.7'
|
|
9211
9247
|
};
|
|
9212
9248
|
|
|
9213
9249
|
const standardExpressionRuntime = {
|