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.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
|
*/
|
|
@@ -2835,7 +2835,8 @@
|
|
|
2835
2835
|
const propertyName = booleanPropertyNames[attrName] || attrName;
|
|
2836
2836
|
if (propertyName in element) {
|
|
2837
2837
|
try {
|
|
2838
|
-
element[propertyName]
|
|
2838
|
+
if (element[propertyName] !== value)
|
|
2839
|
+
element[propertyName] = value;
|
|
2839
2840
|
}
|
|
2840
2841
|
catch {
|
|
2841
2842
|
// Some reflected DOM properties are read-only in older engines.
|
|
@@ -2866,9 +2867,14 @@
|
|
|
2866
2867
|
}
|
|
2867
2868
|
const stringValue = String(value);
|
|
2868
2869
|
if (attrName === 'value' && 'value' in element) {
|
|
2869
|
-
|
|
2870
|
+
// Compare the live control, not a cached expression: user edits and
|
|
2871
|
+
// external DOM changes still need reconciliation on the next update.
|
|
2872
|
+
if (element.value !== stringValue) {
|
|
2873
|
+
element.value = stringValue;
|
|
2874
|
+
}
|
|
2870
2875
|
}
|
|
2871
|
-
element.
|
|
2876
|
+
if (element.getAttribute(attrName) !== stringValue)
|
|
2877
|
+
element.setAttribute(attrName, stringValue);
|
|
2872
2878
|
}
|
|
2873
2879
|
function boundAttributes(element) {
|
|
2874
2880
|
return Array.from(element.attributes).filter(attribute => attribute.name.startsWith(':'));
|
|
@@ -8176,7 +8182,6 @@
|
|
|
8176
8182
|
}
|
|
8177
8183
|
const snapshots = new Map();
|
|
8178
8184
|
const preloadCache = new Map();
|
|
8179
|
-
const preloadControllers = new Map();
|
|
8180
8185
|
const scrollPositions = new Map();
|
|
8181
8186
|
const historyFragments = new Map();
|
|
8182
8187
|
let routerStarted = false;
|
|
@@ -8496,6 +8501,15 @@
|
|
|
8496
8501
|
}
|
|
8497
8502
|
return { finalUrl: url.toString(), init };
|
|
8498
8503
|
}
|
|
8504
|
+
function discardPreload(key) {
|
|
8505
|
+
const entry = preloadCache.get(key);
|
|
8506
|
+
preloadCache.delete(key);
|
|
8507
|
+
entry?.controller.abort();
|
|
8508
|
+
}
|
|
8509
|
+
function clearPreloads() {
|
|
8510
|
+
for (const key of preloadCache.keys())
|
|
8511
|
+
discardPreload(key);
|
|
8512
|
+
}
|
|
8499
8513
|
function preload(url) {
|
|
8500
8514
|
const cacheKey = canonicalUrl(url, true);
|
|
8501
8515
|
if (preloadCache.has(cacheKey))
|
|
@@ -8510,11 +8524,11 @@
|
|
|
8510
8524
|
signal: controller.signal,
|
|
8511
8525
|
mode: 'same-origin'
|
|
8512
8526
|
});
|
|
8513
|
-
|
|
8514
|
-
|
|
8527
|
+
const entry = { request, controller };
|
|
8528
|
+
preloadCache.set(cacheKey, entry);
|
|
8515
8529
|
request.catch(() => {
|
|
8516
|
-
preloadCache.
|
|
8517
|
-
|
|
8530
|
+
if (preloadCache.get(cacheKey) === entry)
|
|
8531
|
+
preloadCache.delete(cacheKey);
|
|
8518
8532
|
});
|
|
8519
8533
|
}
|
|
8520
8534
|
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
@@ -8693,20 +8707,21 @@
|
|
|
8693
8707
|
else {
|
|
8694
8708
|
// Check preload cache if GET
|
|
8695
8709
|
const preloadKey = canonicalUrl(finalUrl, true);
|
|
8696
|
-
if (opts.fresh)
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
}
|
|
8701
|
-
if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
|
|
8710
|
+
if (opts.fresh)
|
|
8711
|
+
discardPreload(preloadKey);
|
|
8712
|
+
const entry = init.method === 'GET' ? preloadCache.get(preloadKey) : undefined;
|
|
8713
|
+
if (entry) {
|
|
8702
8714
|
log('[GyosRouter] using preload cache for', finalUrl);
|
|
8715
|
+
const signal = transaction.controller.signal;
|
|
8716
|
+
const discard = () => {
|
|
8717
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8718
|
+
discardPreload(preloadKey);
|
|
8719
|
+
};
|
|
8720
|
+
signal.addEventListener('abort', discard, { once: true });
|
|
8703
8721
|
try {
|
|
8704
|
-
response = await waitForNavigation(
|
|
8722
|
+
response = await waitForNavigation(entry.request, signal);
|
|
8705
8723
|
}
|
|
8706
8724
|
catch (error) {
|
|
8707
|
-
preloadCache.delete(preloadKey);
|
|
8708
|
-
preloadControllers.get(preloadKey)?.abort();
|
|
8709
|
-
preloadControllers.delete(preloadKey);
|
|
8710
8725
|
if (error.name === 'AbortError')
|
|
8711
8726
|
throw error;
|
|
8712
8727
|
assertActiveNavigation(transaction);
|
|
@@ -8714,8 +8729,11 @@
|
|
|
8714
8729
|
fallback(finalUrl, true);
|
|
8715
8730
|
return;
|
|
8716
8731
|
}
|
|
8717
|
-
|
|
8718
|
-
|
|
8732
|
+
finally {
|
|
8733
|
+
signal.removeEventListener('abort', discard);
|
|
8734
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8735
|
+
preloadCache.delete(preloadKey);
|
|
8736
|
+
}
|
|
8719
8737
|
}
|
|
8720
8738
|
else {
|
|
8721
8739
|
try {
|
|
@@ -8724,6 +8742,9 @@
|
|
|
8724
8742
|
transaction.interval = setInterval(setRand, 300);
|
|
8725
8743
|
response = await fetch(finalUrl, init);
|
|
8726
8744
|
assertActiveNavigation(transaction);
|
|
8745
|
+
// A successful write can change HTML at any URL, including after a redirect.
|
|
8746
|
+
if (response.ok && init.method !== 'GET')
|
|
8747
|
+
clearPreloads();
|
|
8727
8748
|
// Update progress to rand 70 - 80% after fetch
|
|
8728
8749
|
progressBar?.setProgress(Math.random() * 10 + 70);
|
|
8729
8750
|
if (transaction.interval)
|
|
@@ -8863,6 +8884,15 @@
|
|
|
8863
8884
|
// The global outlet is also the incoming layout root. Keep its node for
|
|
8864
8885
|
// inner swaps, but update attributes such as g-scope and layout classes.
|
|
8865
8886
|
try {
|
|
8887
|
+
if (syncDocumentAttributes && !document.querySelector('base[href]')) {
|
|
8888
|
+
document.head.querySelectorAll('base[target]').forEach(base => base.remove());
|
|
8889
|
+
const baseTarget = doc.head.querySelector('base[target]')?.getAttribute('target');
|
|
8890
|
+
if (baseTarget != null) {
|
|
8891
|
+
const base = document.createElement('base');
|
|
8892
|
+
base.target = baseTarget;
|
|
8893
|
+
document.head.prepend(base);
|
|
8894
|
+
}
|
|
8895
|
+
}
|
|
8866
8896
|
target = await performSwap(target, src, swapMode, {
|
|
8867
8897
|
syncRootAttributes: isFullOutletNavigation,
|
|
8868
8898
|
signal: transaction.controller.signal,
|
|
@@ -8988,10 +9018,39 @@
|
|
|
8988
9018
|
opts.onEnd?.({ ...context });
|
|
8989
9019
|
}
|
|
8990
9020
|
}
|
|
8991
|
-
function
|
|
8992
|
-
if (
|
|
8993
|
-
|
|
8994
|
-
|
|
9021
|
+
function eligibleAnchorUrl(link) {
|
|
9022
|
+
if (!(link instanceof HTMLAnchorElement) || !link.getAttribute('href')
|
|
9023
|
+
|| link.hasAttribute('download') || link.closest('[g-no-boost]'))
|
|
9024
|
+
return null;
|
|
9025
|
+
const target = link.getAttribute('target') ?? document.querySelector('base[target]')?.getAttribute('target');
|
|
9026
|
+
if (target && target.toLowerCase() !== '_self')
|
|
9027
|
+
return null;
|
|
9028
|
+
let url;
|
|
9029
|
+
try {
|
|
9030
|
+
url = new URL(link.href);
|
|
9031
|
+
}
|
|
9032
|
+
catch {
|
|
9033
|
+
return null;
|
|
9034
|
+
}
|
|
9035
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.origin !== location.origin
|
|
9036
|
+
|| url.username || url.password)
|
|
9037
|
+
return null;
|
|
9038
|
+
// URL.hash is empty for both an absent fragment and a trailing "#".
|
|
9039
|
+
if (url.href.includes('#') && canonicalUrl(url.href) === canonicalUrl(location.href))
|
|
9040
|
+
return null;
|
|
9041
|
+
// A page visit would need to remove the outgoing base before inserting
|
|
9042
|
+
// relative resources. Let the browser switch documents and enforce base-uri.
|
|
9043
|
+
if (document.querySelector('base[href]') && !link.hasAttribute('g-current-head')
|
|
9044
|
+
&& !['append', 'prepend'].includes(link.getAttribute('g-swap')?.toLowerCase() || '')) {
|
|
9045
|
+
try {
|
|
9046
|
+
if (resolveTarget(link) === findGlobalOutlet())
|
|
9047
|
+
return null;
|
|
9048
|
+
}
|
|
9049
|
+
catch {
|
|
9050
|
+
return null;
|
|
9051
|
+
}
|
|
9052
|
+
}
|
|
9053
|
+
return url;
|
|
8995
9054
|
}
|
|
8996
9055
|
function onClickRouter(element) {
|
|
8997
9056
|
log('[GyosRouter] g-router-link clicked');
|
|
@@ -9045,23 +9104,10 @@
|
|
|
9045
9104
|
return;
|
|
9046
9105
|
}
|
|
9047
9106
|
const link = target.closest('a');
|
|
9048
|
-
if (!link)
|
|
9107
|
+
if (!link || !(link.hasAttribute('g-boost') || hasGlobalBoost()))
|
|
9049
9108
|
return;
|
|
9050
|
-
const
|
|
9051
|
-
if (!
|
|
9052
|
-
return;
|
|
9053
|
-
const url = new URL(href, window.location.href);
|
|
9054
|
-
if (url.origin !== window.location.origin)
|
|
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))
|
|
9109
|
+
const url = eligibleAnchorUrl(link);
|
|
9110
|
+
if (!url)
|
|
9065
9111
|
return;
|
|
9066
9112
|
event.preventDefault();
|
|
9067
9113
|
// The default changeState is true, as this is commonly used for: navigation, etc.
|
|
@@ -9074,13 +9120,9 @@
|
|
|
9074
9120
|
const link = target.closest('a[g-preload]');
|
|
9075
9121
|
if (!link)
|
|
9076
9122
|
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());
|
|
9123
|
+
const url = eligibleAnchorUrl(link);
|
|
9124
|
+
if (url)
|
|
9125
|
+
preload(url.href);
|
|
9084
9126
|
}
|
|
9085
9127
|
function onSubmit(event) {
|
|
9086
9128
|
if (event.defaultPrevented)
|
|
@@ -9233,7 +9275,7 @@
|
|
|
9233
9275
|
portalCreate,
|
|
9234
9276
|
portalDestroy,
|
|
9235
9277
|
setCspNonce,
|
|
9236
|
-
version: '0.5.
|
|
9278
|
+
version: '0.5.7'
|
|
9237
9279
|
};
|
|
9238
9280
|
|
|
9239
9281
|
setExpressionRuntime(standardExpressionRuntime);
|