gyosjs 0.5.5 → 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 +5 -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 +91 -49
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +91 -49
- package/dist/gyos.auto.js.map +1 -1
- package/dist/gyos.auto.min.js +2 -2
- package/dist/gyos.csp.auto.esm.js +91 -49
- package/dist/gyos.csp.auto.esm.js.map +1 -1
- package/dist/gyos.csp.auto.js +91 -49
- package/dist/gyos.csp.auto.js.map +1 -1
- package/dist/gyos.csp.auto.min.js +2 -2
- package/dist/gyos.csp.esm.js +91 -49
- package/dist/gyos.csp.esm.js.map +1 -1
- package/dist/gyos.csp.js +91 -49
- package/dist/gyos.csp.js.map +1 -1
- package/dist/gyos.csp.min.js +2 -2
- package/dist/gyos.esm.js +91 -49
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +91 -49
- package/dist/gyos.js.map +1 -1
- package/dist/gyos.min.js +2 -2
- package/dist/template/bindings.d.ts.map +1 -1
- 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
|
*/
|
|
@@ -2803,7 +2803,8 @@
|
|
|
2803
2803
|
const propertyName = booleanPropertyNames[attrName] || attrName;
|
|
2804
2804
|
if (propertyName in element) {
|
|
2805
2805
|
try {
|
|
2806
|
-
element[propertyName]
|
|
2806
|
+
if (element[propertyName] !== value)
|
|
2807
|
+
element[propertyName] = value;
|
|
2807
2808
|
}
|
|
2808
2809
|
catch {
|
|
2809
2810
|
// Some reflected DOM properties are read-only in older engines.
|
|
@@ -2834,9 +2835,14 @@
|
|
|
2834
2835
|
}
|
|
2835
2836
|
const stringValue = String(value);
|
|
2836
2837
|
if (attrName === 'value' && 'value' in element) {
|
|
2837
|
-
|
|
2838
|
+
// Compare the live control, not a cached expression: user edits and
|
|
2839
|
+
// external DOM changes still need reconciliation on the next update.
|
|
2840
|
+
if (element.value !== stringValue) {
|
|
2841
|
+
element.value = stringValue;
|
|
2842
|
+
}
|
|
2838
2843
|
}
|
|
2839
|
-
element.
|
|
2844
|
+
if (element.getAttribute(attrName) !== stringValue)
|
|
2845
|
+
element.setAttribute(attrName, stringValue);
|
|
2840
2846
|
}
|
|
2841
2847
|
function boundAttributes(element) {
|
|
2842
2848
|
return Array.from(element.attributes).filter(attribute => attribute.name.startsWith(':'));
|
|
@@ -8144,7 +8150,6 @@
|
|
|
8144
8150
|
}
|
|
8145
8151
|
const snapshots = new Map();
|
|
8146
8152
|
const preloadCache = new Map();
|
|
8147
|
-
const preloadControllers = new Map();
|
|
8148
8153
|
const scrollPositions = new Map();
|
|
8149
8154
|
const historyFragments = new Map();
|
|
8150
8155
|
let routerStarted = false;
|
|
@@ -8464,6 +8469,15 @@
|
|
|
8464
8469
|
}
|
|
8465
8470
|
return { finalUrl: url.toString(), init };
|
|
8466
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
|
+
}
|
|
8467
8481
|
function preload(url) {
|
|
8468
8482
|
const cacheKey = canonicalUrl(url, true);
|
|
8469
8483
|
if (preloadCache.has(cacheKey))
|
|
@@ -8478,11 +8492,11 @@
|
|
|
8478
8492
|
signal: controller.signal,
|
|
8479
8493
|
mode: 'same-origin'
|
|
8480
8494
|
});
|
|
8481
|
-
|
|
8482
|
-
|
|
8495
|
+
const entry = { request, controller };
|
|
8496
|
+
preloadCache.set(cacheKey, entry);
|
|
8483
8497
|
request.catch(() => {
|
|
8484
|
-
preloadCache.
|
|
8485
|
-
|
|
8498
|
+
if (preloadCache.get(cacheKey) === entry)
|
|
8499
|
+
preloadCache.delete(cacheKey);
|
|
8486
8500
|
});
|
|
8487
8501
|
}
|
|
8488
8502
|
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
@@ -8661,20 +8675,21 @@
|
|
|
8661
8675
|
else {
|
|
8662
8676
|
// Check preload cache if GET
|
|
8663
8677
|
const preloadKey = canonicalUrl(finalUrl, true);
|
|
8664
|
-
if (opts.fresh)
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
}
|
|
8669
|
-
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) {
|
|
8670
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 });
|
|
8671
8689
|
try {
|
|
8672
|
-
response = await waitForNavigation(
|
|
8690
|
+
response = await waitForNavigation(entry.request, signal);
|
|
8673
8691
|
}
|
|
8674
8692
|
catch (error) {
|
|
8675
|
-
preloadCache.delete(preloadKey);
|
|
8676
|
-
preloadControllers.get(preloadKey)?.abort();
|
|
8677
|
-
preloadControllers.delete(preloadKey);
|
|
8678
8693
|
if (error.name === 'AbortError')
|
|
8679
8694
|
throw error;
|
|
8680
8695
|
assertActiveNavigation(transaction);
|
|
@@ -8682,8 +8697,11 @@
|
|
|
8682
8697
|
fallback(finalUrl, true);
|
|
8683
8698
|
return;
|
|
8684
8699
|
}
|
|
8685
|
-
|
|
8686
|
-
|
|
8700
|
+
finally {
|
|
8701
|
+
signal.removeEventListener('abort', discard);
|
|
8702
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8703
|
+
preloadCache.delete(preloadKey);
|
|
8704
|
+
}
|
|
8687
8705
|
}
|
|
8688
8706
|
else {
|
|
8689
8707
|
try {
|
|
@@ -8692,6 +8710,9 @@
|
|
|
8692
8710
|
transaction.interval = setInterval(setRand, 300);
|
|
8693
8711
|
response = await fetch(finalUrl, init);
|
|
8694
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();
|
|
8695
8716
|
// Update progress to rand 70 - 80% after fetch
|
|
8696
8717
|
progressBar?.setProgress(Math.random() * 10 + 70);
|
|
8697
8718
|
if (transaction.interval)
|
|
@@ -8831,6 +8852,15 @@
|
|
|
8831
8852
|
// The global outlet is also the incoming layout root. Keep its node for
|
|
8832
8853
|
// inner swaps, but update attributes such as g-scope and layout classes.
|
|
8833
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
|
+
}
|
|
8834
8864
|
target = await performSwap(target, src, swapMode, {
|
|
8835
8865
|
syncRootAttributes: isFullOutletNavigation,
|
|
8836
8866
|
signal: transaction.controller.signal,
|
|
@@ -8956,10 +8986,39 @@
|
|
|
8956
8986
|
opts.onEnd?.({ ...context });
|
|
8957
8987
|
}
|
|
8958
8988
|
}
|
|
8959
|
-
function
|
|
8960
|
-
if (
|
|
8961
|
-
|
|
8962
|
-
|
|
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;
|
|
8963
9022
|
}
|
|
8964
9023
|
function onClickRouter(element) {
|
|
8965
9024
|
log('[GyosRouter] g-router-link clicked');
|
|
@@ -9013,23 +9072,10 @@
|
|
|
9013
9072
|
return;
|
|
9014
9073
|
}
|
|
9015
9074
|
const link = target.closest('a');
|
|
9016
|
-
if (!link)
|
|
9075
|
+
if (!link || !(link.hasAttribute('g-boost') || hasGlobalBoost()))
|
|
9017
9076
|
return;
|
|
9018
|
-
const
|
|
9019
|
-
if (!
|
|
9020
|
-
return;
|
|
9021
|
-
const url = new URL(href, window.location.href);
|
|
9022
|
-
if (url.origin !== window.location.origin)
|
|
9023
|
-
return;
|
|
9024
|
-
if (url.hash && canonicalUrl(url.href) === canonicalUrl(window.location.href))
|
|
9025
|
-
return;
|
|
9026
|
-
if (link.closest('[g-no-boost]'))
|
|
9027
|
-
return;
|
|
9028
|
-
if (link.hasAttribute('download'))
|
|
9029
|
-
return;
|
|
9030
|
-
if (link.getAttribute('target') && link.getAttribute('target') !== '_self')
|
|
9031
|
-
return;
|
|
9032
|
-
if (!shouldBoost(link))
|
|
9077
|
+
const url = eligibleAnchorUrl(link);
|
|
9078
|
+
if (!url)
|
|
9033
9079
|
return;
|
|
9034
9080
|
event.preventDefault();
|
|
9035
9081
|
// The default changeState is true, as this is commonly used for: navigation, etc.
|
|
@@ -9042,13 +9088,9 @@
|
|
|
9042
9088
|
const link = target.closest('a[g-preload]');
|
|
9043
9089
|
if (!link)
|
|
9044
9090
|
return;
|
|
9045
|
-
const
|
|
9046
|
-
if (
|
|
9047
|
-
|
|
9048
|
-
const url = new URL(href, window.location.href);
|
|
9049
|
-
if (url.origin !== window.location.origin)
|
|
9050
|
-
return;
|
|
9051
|
-
preload(url.toString());
|
|
9091
|
+
const url = eligibleAnchorUrl(link);
|
|
9092
|
+
if (url)
|
|
9093
|
+
preload(url.href);
|
|
9052
9094
|
}
|
|
9053
9095
|
function onSubmit(event) {
|
|
9054
9096
|
if (event.defaultPrevented)
|
|
@@ -9201,7 +9243,7 @@
|
|
|
9201
9243
|
portalCreate,
|
|
9202
9244
|
portalDestroy,
|
|
9203
9245
|
setCspNonce,
|
|
9204
|
-
version: '0.5.
|
|
9246
|
+
version: '0.5.7'
|
|
9205
9247
|
};
|
|
9206
9248
|
|
|
9207
9249
|
const standardExpressionRuntime = {
|