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