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.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
|
*/
|
|
@@ -2829,7 +2829,8 @@ function syncBooleanProperty(element, attrName, value) {
|
|
|
2829
2829
|
const propertyName = booleanPropertyNames[attrName] || attrName;
|
|
2830
2830
|
if (propertyName in element) {
|
|
2831
2831
|
try {
|
|
2832
|
-
element[propertyName]
|
|
2832
|
+
if (element[propertyName] !== value)
|
|
2833
|
+
element[propertyName] = value;
|
|
2833
2834
|
}
|
|
2834
2835
|
catch {
|
|
2835
2836
|
// Some reflected DOM properties are read-only in older engines.
|
|
@@ -2860,9 +2861,14 @@ function applyAttributeBinding(element, rawAttrName, value) {
|
|
|
2860
2861
|
}
|
|
2861
2862
|
const stringValue = String(value);
|
|
2862
2863
|
if (attrName === 'value' && 'value' in element) {
|
|
2863
|
-
|
|
2864
|
+
// Compare the live control, not a cached expression: user edits and
|
|
2865
|
+
// external DOM changes still need reconciliation on the next update.
|
|
2866
|
+
if (element.value !== stringValue) {
|
|
2867
|
+
element.value = stringValue;
|
|
2868
|
+
}
|
|
2864
2869
|
}
|
|
2865
|
-
element.
|
|
2870
|
+
if (element.getAttribute(attrName) !== stringValue)
|
|
2871
|
+
element.setAttribute(attrName, stringValue);
|
|
2866
2872
|
}
|
|
2867
2873
|
function boundAttributes(element) {
|
|
2868
2874
|
return Array.from(element.attributes).filter(attribute => attribute.name.startsWith(':'));
|
|
@@ -8170,7 +8176,6 @@ function refresh(options = {}) {
|
|
|
8170
8176
|
}
|
|
8171
8177
|
const snapshots = new Map();
|
|
8172
8178
|
const preloadCache = new Map();
|
|
8173
|
-
const preloadControllers = new Map();
|
|
8174
8179
|
const scrollPositions = new Map();
|
|
8175
8180
|
const historyFragments = new Map();
|
|
8176
8181
|
let routerStarted = false;
|
|
@@ -8490,6 +8495,15 @@ function buildRequest(opts) {
|
|
|
8490
8495
|
}
|
|
8491
8496
|
return { finalUrl: url.toString(), init };
|
|
8492
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
|
+
}
|
|
8493
8507
|
function preload(url) {
|
|
8494
8508
|
const cacheKey = canonicalUrl(url, true);
|
|
8495
8509
|
if (preloadCache.has(cacheKey))
|
|
@@ -8504,11 +8518,11 @@ function preload(url) {
|
|
|
8504
8518
|
signal: controller.signal,
|
|
8505
8519
|
mode: 'same-origin'
|
|
8506
8520
|
});
|
|
8507
|
-
|
|
8508
|
-
|
|
8521
|
+
const entry = { request, controller };
|
|
8522
|
+
preloadCache.set(cacheKey, entry);
|
|
8509
8523
|
request.catch(() => {
|
|
8510
|
-
preloadCache.
|
|
8511
|
-
|
|
8524
|
+
if (preloadCache.get(cacheKey) === entry)
|
|
8525
|
+
preloadCache.delete(cacheKey);
|
|
8512
8526
|
});
|
|
8513
8527
|
}
|
|
8514
8528
|
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
@@ -8687,20 +8701,21 @@ async function navigateRequest(opts) {
|
|
|
8687
8701
|
else {
|
|
8688
8702
|
// Check preload cache if GET
|
|
8689
8703
|
const preloadKey = canonicalUrl(finalUrl, true);
|
|
8690
|
-
if (opts.fresh)
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
}
|
|
8695
|
-
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) {
|
|
8696
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 });
|
|
8697
8715
|
try {
|
|
8698
|
-
response = await waitForNavigation(
|
|
8716
|
+
response = await waitForNavigation(entry.request, signal);
|
|
8699
8717
|
}
|
|
8700
8718
|
catch (error) {
|
|
8701
|
-
preloadCache.delete(preloadKey);
|
|
8702
|
-
preloadControllers.get(preloadKey)?.abort();
|
|
8703
|
-
preloadControllers.delete(preloadKey);
|
|
8704
8719
|
if (error.name === 'AbortError')
|
|
8705
8720
|
throw error;
|
|
8706
8721
|
assertActiveNavigation(transaction);
|
|
@@ -8708,8 +8723,11 @@ async function navigateRequest(opts) {
|
|
|
8708
8723
|
fallback(finalUrl, true);
|
|
8709
8724
|
return;
|
|
8710
8725
|
}
|
|
8711
|
-
|
|
8712
|
-
|
|
8726
|
+
finally {
|
|
8727
|
+
signal.removeEventListener('abort', discard);
|
|
8728
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
8729
|
+
preloadCache.delete(preloadKey);
|
|
8730
|
+
}
|
|
8713
8731
|
}
|
|
8714
8732
|
else {
|
|
8715
8733
|
try {
|
|
@@ -8718,6 +8736,9 @@ async function navigateRequest(opts) {
|
|
|
8718
8736
|
transaction.interval = setInterval(setRand, 300);
|
|
8719
8737
|
response = await fetch(finalUrl, init);
|
|
8720
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();
|
|
8721
8742
|
// Update progress to rand 70 - 80% after fetch
|
|
8722
8743
|
progressBar?.setProgress(Math.random() * 10 + 70);
|
|
8723
8744
|
if (transaction.interval)
|
|
@@ -8857,6 +8878,15 @@ async function navigateRequest(opts) {
|
|
|
8857
8878
|
// The global outlet is also the incoming layout root. Keep its node for
|
|
8858
8879
|
// inner swaps, but update attributes such as g-scope and layout classes.
|
|
8859
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
|
+
}
|
|
8860
8890
|
target = await performSwap(target, src, swapMode, {
|
|
8861
8891
|
syncRootAttributes: isFullOutletNavigation,
|
|
8862
8892
|
signal: transaction.controller.signal,
|
|
@@ -8982,10 +9012,39 @@ async function navigateRequest(opts) {
|
|
|
8982
9012
|
opts.onEnd?.({ ...context });
|
|
8983
9013
|
}
|
|
8984
9014
|
}
|
|
8985
|
-
function
|
|
8986
|
-
if (
|
|
8987
|
-
|
|
8988
|
-
|
|
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;
|
|
8989
9048
|
}
|
|
8990
9049
|
function onClickRouter(element) {
|
|
8991
9050
|
log('[GyosRouter] g-router-link clicked');
|
|
@@ -9039,23 +9098,10 @@ function onClick(event) {
|
|
|
9039
9098
|
return;
|
|
9040
9099
|
}
|
|
9041
9100
|
const link = target.closest('a');
|
|
9042
|
-
if (!link)
|
|
9101
|
+
if (!link || !(link.hasAttribute('g-boost') || hasGlobalBoost()))
|
|
9043
9102
|
return;
|
|
9044
|
-
const
|
|
9045
|
-
if (!
|
|
9046
|
-
return;
|
|
9047
|
-
const url = new URL(href, window.location.href);
|
|
9048
|
-
if (url.origin !== window.location.origin)
|
|
9049
|
-
return;
|
|
9050
|
-
if (url.hash && canonicalUrl(url.href) === canonicalUrl(window.location.href))
|
|
9051
|
-
return;
|
|
9052
|
-
if (link.closest('[g-no-boost]'))
|
|
9053
|
-
return;
|
|
9054
|
-
if (link.hasAttribute('download'))
|
|
9055
|
-
return;
|
|
9056
|
-
if (link.getAttribute('target') && link.getAttribute('target') !== '_self')
|
|
9057
|
-
return;
|
|
9058
|
-
if (!shouldBoost(link))
|
|
9103
|
+
const url = eligibleAnchorUrl(link);
|
|
9104
|
+
if (!url)
|
|
9059
9105
|
return;
|
|
9060
9106
|
event.preventDefault();
|
|
9061
9107
|
// The default changeState is true, as this is commonly used for: navigation, etc.
|
|
@@ -9068,13 +9114,9 @@ function onMouseOverCapture(event) {
|
|
|
9068
9114
|
const link = target.closest('a[g-preload]');
|
|
9069
9115
|
if (!link)
|
|
9070
9116
|
return;
|
|
9071
|
-
const
|
|
9072
|
-
if (
|
|
9073
|
-
|
|
9074
|
-
const url = new URL(href, window.location.href);
|
|
9075
|
-
if (url.origin !== window.location.origin)
|
|
9076
|
-
return;
|
|
9077
|
-
preload(url.toString());
|
|
9117
|
+
const url = eligibleAnchorUrl(link);
|
|
9118
|
+
if (url)
|
|
9119
|
+
preload(url.href);
|
|
9078
9120
|
}
|
|
9079
9121
|
function onSubmit(event) {
|
|
9080
9122
|
if (event.defaultPrevented)
|
|
@@ -9227,7 +9269,7 @@ const Gyos = {
|
|
|
9227
9269
|
portalCreate,
|
|
9228
9270
|
portalDestroy,
|
|
9229
9271
|
setCspNonce,
|
|
9230
|
-
version: '0.5.
|
|
9272
|
+
version: '0.5.7'
|
|
9231
9273
|
};
|
|
9232
9274
|
|
|
9233
9275
|
setExpressionRuntime(standardExpressionRuntime);
|