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.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
|
*/
|
|
@@ -8176,7 +8176,6 @@ function refresh(options = {}) {
|
|
|
8176
8176
|
}
|
|
8177
8177
|
const snapshots = new Map();
|
|
8178
8178
|
const preloadCache = new Map();
|
|
8179
|
-
const preloadControllers = new Map();
|
|
8180
8179
|
const scrollPositions = new Map();
|
|
8181
8180
|
const historyFragments = new Map();
|
|
8182
8181
|
let routerStarted = false;
|
|
@@ -8496,6 +8495,15 @@ function buildRequest(opts) {
|
|
|
8496
8495
|
}
|
|
8497
8496
|
return { finalUrl: url.toString(), init };
|
|
8498
8497
|
}
|
|
8498
|
+
function discardPreload(key) {
|
|
8499
|
+
const entry = preloadCache.get(key);
|
|
8500
|
+
preloadCache.delete(key);
|
|
8501
|
+
entry?.controller.abort();
|
|
8502
|
+
}
|
|
8503
|
+
function clearPreloads() {
|
|
8504
|
+
for (const key of preloadCache.keys())
|
|
8505
|
+
discardPreload(key);
|
|
8506
|
+
}
|
|
8499
8507
|
function preload(url) {
|
|
8500
8508
|
const cacheKey = canonicalUrl(url, true);
|
|
8501
8509
|
if (preloadCache.has(cacheKey))
|
|
@@ -8510,11 +8518,11 @@ function preload(url) {
|
|
|
8510
8518
|
signal: controller.signal,
|
|
8511
8519
|
mode: 'same-origin'
|
|
8512
8520
|
});
|
|
8513
|
-
|
|
8514
|
-
|
|
8521
|
+
const entry = { request, controller };
|
|
8522
|
+
preloadCache.set(cacheKey, entry);
|
|
8515
8523
|
request.catch(() => {
|
|
8516
|
-
preloadCache.
|
|
8517
|
-
|
|
8524
|
+
if (preloadCache.get(cacheKey) === entry)
|
|
8525
|
+
preloadCache.delete(cacheKey);
|
|
8518
8526
|
});
|
|
8519
8527
|
}
|
|
8520
8528
|
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
@@ -8693,20 +8701,21 @@ async function navigateRequest(opts) {
|
|
|
8693
8701
|
else {
|
|
8694
8702
|
// Check preload cache if GET
|
|
8695
8703
|
const preloadKey = canonicalUrl(finalUrl, true);
|
|
8696
|
-
if (opts.fresh)
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
}
|
|
8701
|
-
if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
|
|
8704
|
+
if (opts.fresh)
|
|
8705
|
+
discardPreload(preloadKey);
|
|
8706
|
+
const entry = init.method === 'GET' ? preloadCache.get(preloadKey) : undefined;
|
|
8707
|
+
if (entry) {
|
|
8702
8708
|
log('[GyosRouter] using preload cache for', finalUrl);
|
|
8709
|
+
const signal = transaction.controller.signal;
|
|
8710
|
+
const discard = () => {
|
|
8711
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8712
|
+
discardPreload(preloadKey);
|
|
8713
|
+
};
|
|
8714
|
+
signal.addEventListener('abort', discard, { once: true });
|
|
8703
8715
|
try {
|
|
8704
|
-
response = await waitForNavigation(
|
|
8716
|
+
response = await waitForNavigation(entry.request, signal);
|
|
8705
8717
|
}
|
|
8706
8718
|
catch (error) {
|
|
8707
|
-
preloadCache.delete(preloadKey);
|
|
8708
|
-
preloadControllers.get(preloadKey)?.abort();
|
|
8709
|
-
preloadControllers.delete(preloadKey);
|
|
8710
8719
|
if (error.name === 'AbortError')
|
|
8711
8720
|
throw error;
|
|
8712
8721
|
assertActiveNavigation(transaction);
|
|
@@ -8714,8 +8723,11 @@ async function navigateRequest(opts) {
|
|
|
8714
8723
|
fallback(finalUrl, true);
|
|
8715
8724
|
return;
|
|
8716
8725
|
}
|
|
8717
|
-
|
|
8718
|
-
|
|
8726
|
+
finally {
|
|
8727
|
+
signal.removeEventListener('abort', discard);
|
|
8728
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8729
|
+
preloadCache.delete(preloadKey);
|
|
8730
|
+
}
|
|
8719
8731
|
}
|
|
8720
8732
|
else {
|
|
8721
8733
|
try {
|
|
@@ -8724,6 +8736,9 @@ async function navigateRequest(opts) {
|
|
|
8724
8736
|
transaction.interval = setInterval(setRand, 300);
|
|
8725
8737
|
response = await fetch(finalUrl, init);
|
|
8726
8738
|
assertActiveNavigation(transaction);
|
|
8739
|
+
// A successful write can change HTML at any URL, including after a redirect.
|
|
8740
|
+
if (response.ok && init.method !== 'GET')
|
|
8741
|
+
clearPreloads();
|
|
8727
8742
|
// Update progress to rand 70 - 80% after fetch
|
|
8728
8743
|
progressBar?.setProgress(Math.random() * 10 + 70);
|
|
8729
8744
|
if (transaction.interval)
|
|
@@ -8863,6 +8878,15 @@ async function navigateRequest(opts) {
|
|
|
8863
8878
|
// The global outlet is also the incoming layout root. Keep its node for
|
|
8864
8879
|
// inner swaps, but update attributes such as g-scope and layout classes.
|
|
8865
8880
|
try {
|
|
8881
|
+
if (syncDocumentAttributes && !document.querySelector('base[href]')) {
|
|
8882
|
+
document.head.querySelectorAll('base[target]').forEach(base => base.remove());
|
|
8883
|
+
const baseTarget = doc.head.querySelector('base[target]')?.getAttribute('target');
|
|
8884
|
+
if (baseTarget != null) {
|
|
8885
|
+
const base = document.createElement('base');
|
|
8886
|
+
base.target = baseTarget;
|
|
8887
|
+
document.head.prepend(base);
|
|
8888
|
+
}
|
|
8889
|
+
}
|
|
8866
8890
|
target = await performSwap(target, src, swapMode, {
|
|
8867
8891
|
syncRootAttributes: isFullOutletNavigation,
|
|
8868
8892
|
signal: transaction.controller.signal,
|
|
@@ -8988,10 +9012,39 @@ async function navigateRequest(opts) {
|
|
|
8988
9012
|
opts.onEnd?.({ ...context });
|
|
8989
9013
|
}
|
|
8990
9014
|
}
|
|
8991
|
-
function
|
|
8992
|
-
if (
|
|
8993
|
-
|
|
8994
|
-
|
|
9015
|
+
function eligibleAnchorUrl(link) {
|
|
9016
|
+
if (!(link instanceof HTMLAnchorElement) || !link.getAttribute('href')
|
|
9017
|
+
|| link.hasAttribute('download') || link.closest('[g-no-boost]'))
|
|
9018
|
+
return null;
|
|
9019
|
+
const target = link.getAttribute('target') ?? document.querySelector('base[target]')?.getAttribute('target');
|
|
9020
|
+
if (target && target.toLowerCase() !== '_self')
|
|
9021
|
+
return null;
|
|
9022
|
+
let url;
|
|
9023
|
+
try {
|
|
9024
|
+
url = new URL(link.href);
|
|
9025
|
+
}
|
|
9026
|
+
catch {
|
|
9027
|
+
return null;
|
|
9028
|
+
}
|
|
9029
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.origin !== location.origin
|
|
9030
|
+
|| url.username || url.password)
|
|
9031
|
+
return null;
|
|
9032
|
+
// URL.hash is empty for both an absent fragment and a trailing "#".
|
|
9033
|
+
if (url.href.includes('#') && canonicalUrl(url.href) === canonicalUrl(location.href))
|
|
9034
|
+
return null;
|
|
9035
|
+
// A page visit would need to remove the outgoing base before inserting
|
|
9036
|
+
// relative resources. Let the browser switch documents and enforce base-uri.
|
|
9037
|
+
if (document.querySelector('base[href]') && !link.hasAttribute('g-current-head')
|
|
9038
|
+
&& !['append', 'prepend'].includes(link.getAttribute('g-swap')?.toLowerCase() || '')) {
|
|
9039
|
+
try {
|
|
9040
|
+
if (resolveTarget(link) === findGlobalOutlet())
|
|
9041
|
+
return null;
|
|
9042
|
+
}
|
|
9043
|
+
catch {
|
|
9044
|
+
return null;
|
|
9045
|
+
}
|
|
9046
|
+
}
|
|
9047
|
+
return url;
|
|
8995
9048
|
}
|
|
8996
9049
|
function onClickRouter(element) {
|
|
8997
9050
|
log('[GyosRouter] g-router-link clicked');
|
|
@@ -9045,23 +9098,10 @@ function onClick(event) {
|
|
|
9045
9098
|
return;
|
|
9046
9099
|
}
|
|
9047
9100
|
const link = target.closest('a');
|
|
9048
|
-
if (!link)
|
|
9049
|
-
return;
|
|
9050
|
-
const href = link.getAttribute('href');
|
|
9051
|
-
if (!href)
|
|
9101
|
+
if (!link || !(link.hasAttribute('g-boost') || hasGlobalBoost()))
|
|
9052
9102
|
return;
|
|
9053
|
-
const url =
|
|
9054
|
-
if (url
|
|
9055
|
-
return;
|
|
9056
|
-
if (url.hash && canonicalUrl(url.href) === canonicalUrl(window.location.href))
|
|
9057
|
-
return;
|
|
9058
|
-
if (link.closest('[g-no-boost]'))
|
|
9059
|
-
return;
|
|
9060
|
-
if (link.hasAttribute('download'))
|
|
9061
|
-
return;
|
|
9062
|
-
if (link.getAttribute('target') && link.getAttribute('target') !== '_self')
|
|
9063
|
-
return;
|
|
9064
|
-
if (!shouldBoost(link))
|
|
9103
|
+
const url = eligibleAnchorUrl(link);
|
|
9104
|
+
if (!url)
|
|
9065
9105
|
return;
|
|
9066
9106
|
event.preventDefault();
|
|
9067
9107
|
// The default changeState is true, as this is commonly used for: navigation, etc.
|
|
@@ -9074,13 +9114,9 @@ function onMouseOverCapture(event) {
|
|
|
9074
9114
|
const link = target.closest('a[g-preload]');
|
|
9075
9115
|
if (!link)
|
|
9076
9116
|
return;
|
|
9077
|
-
const
|
|
9078
|
-
if (
|
|
9079
|
-
|
|
9080
|
-
const url = new URL(href, window.location.href);
|
|
9081
|
-
if (url.origin !== window.location.origin)
|
|
9082
|
-
return;
|
|
9083
|
-
preload(url.toString());
|
|
9117
|
+
const url = eligibleAnchorUrl(link);
|
|
9118
|
+
if (url)
|
|
9119
|
+
preload(url.href);
|
|
9084
9120
|
}
|
|
9085
9121
|
function onSubmit(event) {
|
|
9086
9122
|
if (event.defaultPrevented)
|
|
@@ -9233,7 +9269,7 @@ const Gyos = {
|
|
|
9233
9269
|
portalCreate,
|
|
9234
9270
|
portalDestroy,
|
|
9235
9271
|
setCspNonce,
|
|
9236
|
-
version: '0.5.
|
|
9272
|
+
version: '0.5.7'
|
|
9237
9273
|
};
|
|
9238
9274
|
|
|
9239
9275
|
setExpressionRuntime(standardExpressionRuntime);
|