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
|
@@ -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
|
*/
|
|
@@ -8158,7 +8158,6 @@ function refresh(options = {}) {
|
|
|
8158
8158
|
}
|
|
8159
8159
|
const snapshots = new Map();
|
|
8160
8160
|
const preloadCache = new Map();
|
|
8161
|
-
const preloadControllers = new Map();
|
|
8162
8161
|
const scrollPositions = new Map();
|
|
8163
8162
|
const historyFragments = new Map();
|
|
8164
8163
|
let routerStarted = false;
|
|
@@ -8478,6 +8477,15 @@ function buildRequest(opts) {
|
|
|
8478
8477
|
}
|
|
8479
8478
|
return { finalUrl: url.toString(), init };
|
|
8480
8479
|
}
|
|
8480
|
+
function discardPreload(key) {
|
|
8481
|
+
const entry = preloadCache.get(key);
|
|
8482
|
+
preloadCache.delete(key);
|
|
8483
|
+
entry?.controller.abort();
|
|
8484
|
+
}
|
|
8485
|
+
function clearPreloads() {
|
|
8486
|
+
for (const key of preloadCache.keys())
|
|
8487
|
+
discardPreload(key);
|
|
8488
|
+
}
|
|
8481
8489
|
function preload(url) {
|
|
8482
8490
|
const cacheKey = canonicalUrl(url, true);
|
|
8483
8491
|
if (preloadCache.has(cacheKey))
|
|
@@ -8492,11 +8500,11 @@ function preload(url) {
|
|
|
8492
8500
|
signal: controller.signal,
|
|
8493
8501
|
mode: 'same-origin'
|
|
8494
8502
|
});
|
|
8495
|
-
|
|
8496
|
-
|
|
8503
|
+
const entry = { request, controller };
|
|
8504
|
+
preloadCache.set(cacheKey, entry);
|
|
8497
8505
|
request.catch(() => {
|
|
8498
|
-
preloadCache.
|
|
8499
|
-
|
|
8506
|
+
if (preloadCache.get(cacheKey) === entry)
|
|
8507
|
+
preloadCache.delete(cacheKey);
|
|
8500
8508
|
});
|
|
8501
8509
|
}
|
|
8502
8510
|
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
@@ -8675,20 +8683,21 @@ async function navigateRequest(opts) {
|
|
|
8675
8683
|
else {
|
|
8676
8684
|
// Check preload cache if GET
|
|
8677
8685
|
const preloadKey = canonicalUrl(finalUrl, true);
|
|
8678
|
-
if (opts.fresh)
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
}
|
|
8683
|
-
if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
|
|
8686
|
+
if (opts.fresh)
|
|
8687
|
+
discardPreload(preloadKey);
|
|
8688
|
+
const entry = init.method === 'GET' ? preloadCache.get(preloadKey) : undefined;
|
|
8689
|
+
if (entry) {
|
|
8684
8690
|
log('[GyosRouter] using preload cache for', finalUrl);
|
|
8691
|
+
const signal = transaction.controller.signal;
|
|
8692
|
+
const discard = () => {
|
|
8693
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8694
|
+
discardPreload(preloadKey);
|
|
8695
|
+
};
|
|
8696
|
+
signal.addEventListener('abort', discard, { once: true });
|
|
8685
8697
|
try {
|
|
8686
|
-
response = await waitForNavigation(
|
|
8698
|
+
response = await waitForNavigation(entry.request, signal);
|
|
8687
8699
|
}
|
|
8688
8700
|
catch (error) {
|
|
8689
|
-
preloadCache.delete(preloadKey);
|
|
8690
|
-
preloadControllers.get(preloadKey)?.abort();
|
|
8691
|
-
preloadControllers.delete(preloadKey);
|
|
8692
8701
|
if (error.name === 'AbortError')
|
|
8693
8702
|
throw error;
|
|
8694
8703
|
assertActiveNavigation(transaction);
|
|
@@ -8696,8 +8705,11 @@ async function navigateRequest(opts) {
|
|
|
8696
8705
|
fallback(finalUrl, true);
|
|
8697
8706
|
return;
|
|
8698
8707
|
}
|
|
8699
|
-
|
|
8700
|
-
|
|
8708
|
+
finally {
|
|
8709
|
+
signal.removeEventListener('abort', discard);
|
|
8710
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8711
|
+
preloadCache.delete(preloadKey);
|
|
8712
|
+
}
|
|
8701
8713
|
}
|
|
8702
8714
|
else {
|
|
8703
8715
|
try {
|
|
@@ -8706,6 +8718,9 @@ async function navigateRequest(opts) {
|
|
|
8706
8718
|
transaction.interval = setInterval(setRand, 300);
|
|
8707
8719
|
response = await fetch(finalUrl, init);
|
|
8708
8720
|
assertActiveNavigation(transaction);
|
|
8721
|
+
// A successful write can change HTML at any URL, including after a redirect.
|
|
8722
|
+
if (response.ok && init.method !== 'GET')
|
|
8723
|
+
clearPreloads();
|
|
8709
8724
|
// Update progress to rand 70 - 80% after fetch
|
|
8710
8725
|
progressBar?.setProgress(Math.random() * 10 + 70);
|
|
8711
8726
|
if (transaction.interval)
|
|
@@ -8845,6 +8860,15 @@ async function navigateRequest(opts) {
|
|
|
8845
8860
|
// The global outlet is also the incoming layout root. Keep its node for
|
|
8846
8861
|
// inner swaps, but update attributes such as g-scope and layout classes.
|
|
8847
8862
|
try {
|
|
8863
|
+
if (syncDocumentAttributes && !document.querySelector('base[href]')) {
|
|
8864
|
+
document.head.querySelectorAll('base[target]').forEach(base => base.remove());
|
|
8865
|
+
const baseTarget = doc.head.querySelector('base[target]')?.getAttribute('target');
|
|
8866
|
+
if (baseTarget != null) {
|
|
8867
|
+
const base = document.createElement('base');
|
|
8868
|
+
base.target = baseTarget;
|
|
8869
|
+
document.head.prepend(base);
|
|
8870
|
+
}
|
|
8871
|
+
}
|
|
8848
8872
|
target = await performSwap(target, src, swapMode, {
|
|
8849
8873
|
syncRootAttributes: isFullOutletNavigation,
|
|
8850
8874
|
signal: transaction.controller.signal,
|
|
@@ -8970,10 +8994,39 @@ async function navigateRequest(opts) {
|
|
|
8970
8994
|
opts.onEnd?.({ ...context });
|
|
8971
8995
|
}
|
|
8972
8996
|
}
|
|
8973
|
-
function
|
|
8974
|
-
if (
|
|
8975
|
-
|
|
8976
|
-
|
|
8997
|
+
function eligibleAnchorUrl(link) {
|
|
8998
|
+
if (!(link instanceof HTMLAnchorElement) || !link.getAttribute('href')
|
|
8999
|
+
|| link.hasAttribute('download') || link.closest('[g-no-boost]'))
|
|
9000
|
+
return null;
|
|
9001
|
+
const target = link.getAttribute('target') ?? document.querySelector('base[target]')?.getAttribute('target');
|
|
9002
|
+
if (target && target.toLowerCase() !== '_self')
|
|
9003
|
+
return null;
|
|
9004
|
+
let url;
|
|
9005
|
+
try {
|
|
9006
|
+
url = new URL(link.href);
|
|
9007
|
+
}
|
|
9008
|
+
catch {
|
|
9009
|
+
return null;
|
|
9010
|
+
}
|
|
9011
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.origin !== location.origin
|
|
9012
|
+
|| url.username || url.password)
|
|
9013
|
+
return null;
|
|
9014
|
+
// URL.hash is empty for both an absent fragment and a trailing "#".
|
|
9015
|
+
if (url.href.includes('#') && canonicalUrl(url.href) === canonicalUrl(location.href))
|
|
9016
|
+
return null;
|
|
9017
|
+
// A page visit would need to remove the outgoing base before inserting
|
|
9018
|
+
// relative resources. Let the browser switch documents and enforce base-uri.
|
|
9019
|
+
if (document.querySelector('base[href]') && !link.hasAttribute('g-current-head')
|
|
9020
|
+
&& !['append', 'prepend'].includes(link.getAttribute('g-swap')?.toLowerCase() || '')) {
|
|
9021
|
+
try {
|
|
9022
|
+
if (resolveTarget(link) === findGlobalOutlet())
|
|
9023
|
+
return null;
|
|
9024
|
+
}
|
|
9025
|
+
catch {
|
|
9026
|
+
return null;
|
|
9027
|
+
}
|
|
9028
|
+
}
|
|
9029
|
+
return url;
|
|
8977
9030
|
}
|
|
8978
9031
|
function onClickRouter(element) {
|
|
8979
9032
|
log('[GyosRouter] g-router-link clicked');
|
|
@@ -9027,23 +9080,10 @@ function onClick(event) {
|
|
|
9027
9080
|
return;
|
|
9028
9081
|
}
|
|
9029
9082
|
const link = target.closest('a');
|
|
9030
|
-
if (!link)
|
|
9031
|
-
return;
|
|
9032
|
-
const href = link.getAttribute('href');
|
|
9033
|
-
if (!href)
|
|
9083
|
+
if (!link || !(link.hasAttribute('g-boost') || hasGlobalBoost()))
|
|
9034
9084
|
return;
|
|
9035
|
-
const url =
|
|
9036
|
-
if (url
|
|
9037
|
-
return;
|
|
9038
|
-
if (url.hash && canonicalUrl(url.href) === canonicalUrl(window.location.href))
|
|
9039
|
-
return;
|
|
9040
|
-
if (link.closest('[g-no-boost]'))
|
|
9041
|
-
return;
|
|
9042
|
-
if (link.hasAttribute('download'))
|
|
9043
|
-
return;
|
|
9044
|
-
if (link.getAttribute('target') && link.getAttribute('target') !== '_self')
|
|
9045
|
-
return;
|
|
9046
|
-
if (!shouldBoost(link))
|
|
9085
|
+
const url = eligibleAnchorUrl(link);
|
|
9086
|
+
if (!url)
|
|
9047
9087
|
return;
|
|
9048
9088
|
event.preventDefault();
|
|
9049
9089
|
// The default changeState is true, as this is commonly used for: navigation, etc.
|
|
@@ -9056,13 +9096,9 @@ function onMouseOverCapture(event) {
|
|
|
9056
9096
|
const link = target.closest('a[g-preload]');
|
|
9057
9097
|
if (!link)
|
|
9058
9098
|
return;
|
|
9059
|
-
const
|
|
9060
|
-
if (
|
|
9061
|
-
|
|
9062
|
-
const url = new URL(href, window.location.href);
|
|
9063
|
-
if (url.origin !== window.location.origin)
|
|
9064
|
-
return;
|
|
9065
|
-
preload(url.toString());
|
|
9099
|
+
const url = eligibleAnchorUrl(link);
|
|
9100
|
+
if (url)
|
|
9101
|
+
preload(url.href);
|
|
9066
9102
|
}
|
|
9067
9103
|
function onSubmit(event) {
|
|
9068
9104
|
if (event.defaultPrevented)
|
|
@@ -9215,7 +9251,7 @@ const Gyos = {
|
|
|
9215
9251
|
portalCreate,
|
|
9216
9252
|
portalDestroy,
|
|
9217
9253
|
setCspNonce,
|
|
9218
|
-
version: '0.5.
|
|
9254
|
+
version: '0.5.7'
|
|
9219
9255
|
};
|
|
9220
9256
|
|
|
9221
9257
|
// This file was generated. Do not modify manually!
|