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.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
|
*/
|
|
@@ -9446,7 +9446,8 @@ function syncBooleanProperty(element, attrName, value) {
|
|
|
9446
9446
|
const propertyName = booleanPropertyNames[attrName] || attrName;
|
|
9447
9447
|
if (propertyName in element) {
|
|
9448
9448
|
try {
|
|
9449
|
-
element[propertyName]
|
|
9449
|
+
if (element[propertyName] !== value)
|
|
9450
|
+
element[propertyName] = value;
|
|
9450
9451
|
}
|
|
9451
9452
|
catch {
|
|
9452
9453
|
// Some reflected DOM properties are read-only in older engines.
|
|
@@ -9477,9 +9478,14 @@ function applyAttributeBinding(element, rawAttrName, value) {
|
|
|
9477
9478
|
}
|
|
9478
9479
|
const stringValue = String(value);
|
|
9479
9480
|
if (attrName === 'value' && 'value' in element) {
|
|
9480
|
-
|
|
9481
|
+
// Compare the live control, not a cached expression: user edits and
|
|
9482
|
+
// external DOM changes still need reconciliation on the next update.
|
|
9483
|
+
if (element.value !== stringValue) {
|
|
9484
|
+
element.value = stringValue;
|
|
9485
|
+
}
|
|
9481
9486
|
}
|
|
9482
|
-
element.
|
|
9487
|
+
if (element.getAttribute(attrName) !== stringValue)
|
|
9488
|
+
element.setAttribute(attrName, stringValue);
|
|
9483
9489
|
}
|
|
9484
9490
|
function boundAttributes(element) {
|
|
9485
9491
|
return Array.from(element.attributes).filter(attribute => attribute.name.startsWith(':'));
|
|
@@ -14787,7 +14793,6 @@ function refresh(options = {}) {
|
|
|
14787
14793
|
}
|
|
14788
14794
|
const snapshots = new Map();
|
|
14789
14795
|
const preloadCache = new Map();
|
|
14790
|
-
const preloadControllers = new Map();
|
|
14791
14796
|
const scrollPositions = new Map();
|
|
14792
14797
|
const historyFragments = new Map();
|
|
14793
14798
|
let routerStarted = false;
|
|
@@ -15107,6 +15112,15 @@ function buildRequest(opts) {
|
|
|
15107
15112
|
}
|
|
15108
15113
|
return { finalUrl: url.toString(), init };
|
|
15109
15114
|
}
|
|
15115
|
+
function discardPreload(key) {
|
|
15116
|
+
const entry = preloadCache.get(key);
|
|
15117
|
+
preloadCache.delete(key);
|
|
15118
|
+
entry?.controller.abort();
|
|
15119
|
+
}
|
|
15120
|
+
function clearPreloads() {
|
|
15121
|
+
for (const key of preloadCache.keys())
|
|
15122
|
+
discardPreload(key);
|
|
15123
|
+
}
|
|
15110
15124
|
function preload(url) {
|
|
15111
15125
|
const cacheKey = canonicalUrl(url, true);
|
|
15112
15126
|
if (preloadCache.has(cacheKey))
|
|
@@ -15121,11 +15135,11 @@ function preload(url) {
|
|
|
15121
15135
|
signal: controller.signal,
|
|
15122
15136
|
mode: 'same-origin'
|
|
15123
15137
|
});
|
|
15124
|
-
|
|
15125
|
-
|
|
15138
|
+
const entry = { request, controller };
|
|
15139
|
+
preloadCache.set(cacheKey, entry);
|
|
15126
15140
|
request.catch(() => {
|
|
15127
|
-
preloadCache.
|
|
15128
|
-
|
|
15141
|
+
if (preloadCache.get(cacheKey) === entry)
|
|
15142
|
+
preloadCache.delete(cacheKey);
|
|
15129
15143
|
});
|
|
15130
15144
|
}
|
|
15131
15145
|
async function updateHead(fromDoc, signal, currentBaseUrl) {
|
|
@@ -15304,20 +15318,21 @@ async function navigateRequest(opts) {
|
|
|
15304
15318
|
else {
|
|
15305
15319
|
// Check preload cache if GET
|
|
15306
15320
|
const preloadKey = canonicalUrl(finalUrl, true);
|
|
15307
|
-
if (opts.fresh)
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
}
|
|
15312
|
-
if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
|
|
15321
|
+
if (opts.fresh)
|
|
15322
|
+
discardPreload(preloadKey);
|
|
15323
|
+
const entry = init.method === 'GET' ? preloadCache.get(preloadKey) : undefined;
|
|
15324
|
+
if (entry) {
|
|
15313
15325
|
log('[GyosRouter] using preload cache for', finalUrl);
|
|
15326
|
+
const signal = transaction.controller.signal;
|
|
15327
|
+
const discard = () => {
|
|
15328
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
15329
|
+
discardPreload(preloadKey);
|
|
15330
|
+
};
|
|
15331
|
+
signal.addEventListener('abort', discard, { once: true });
|
|
15314
15332
|
try {
|
|
15315
|
-
response = await waitForNavigation(
|
|
15333
|
+
response = await waitForNavigation(entry.request, signal);
|
|
15316
15334
|
}
|
|
15317
15335
|
catch (error) {
|
|
15318
|
-
preloadCache.delete(preloadKey);
|
|
15319
|
-
preloadControllers.get(preloadKey)?.abort();
|
|
15320
|
-
preloadControllers.delete(preloadKey);
|
|
15321
15336
|
if (error.name === 'AbortError')
|
|
15322
15337
|
throw error;
|
|
15323
15338
|
assertActiveNavigation(transaction);
|
|
@@ -15325,8 +15340,11 @@ async function navigateRequest(opts) {
|
|
|
15325
15340
|
fallback(finalUrl, true);
|
|
15326
15341
|
return;
|
|
15327
15342
|
}
|
|
15328
|
-
|
|
15329
|
-
|
|
15343
|
+
finally {
|
|
15344
|
+
signal.removeEventListener('abort', discard);
|
|
15345
|
+
if (preloadCache.get(preloadKey) === entry)
|
|
15346
|
+
preloadCache.delete(preloadKey);
|
|
15347
|
+
}
|
|
15330
15348
|
}
|
|
15331
15349
|
else {
|
|
15332
15350
|
try {
|
|
@@ -15335,6 +15353,9 @@ async function navigateRequest(opts) {
|
|
|
15335
15353
|
transaction.interval = setInterval(setRand, 300);
|
|
15336
15354
|
response = await fetch(finalUrl, init);
|
|
15337
15355
|
assertActiveNavigation(transaction);
|
|
15356
|
+
// A successful write can change HTML at any URL, including after a redirect.
|
|
15357
|
+
if (response.ok && init.method !== 'GET')
|
|
15358
|
+
clearPreloads();
|
|
15338
15359
|
// Update progress to rand 70 - 80% after fetch
|
|
15339
15360
|
progressBar?.setProgress(Math.random() * 10 + 70);
|
|
15340
15361
|
if (transaction.interval)
|
|
@@ -15474,6 +15495,15 @@ async function navigateRequest(opts) {
|
|
|
15474
15495
|
// The global outlet is also the incoming layout root. Keep its node for
|
|
15475
15496
|
// inner swaps, but update attributes such as g-scope and layout classes.
|
|
15476
15497
|
try {
|
|
15498
|
+
if (syncDocumentAttributes && !document.querySelector('base[href]')) {
|
|
15499
|
+
document.head.querySelectorAll('base[target]').forEach(base => base.remove());
|
|
15500
|
+
const baseTarget = doc.head.querySelector('base[target]')?.getAttribute('target');
|
|
15501
|
+
if (baseTarget != null) {
|
|
15502
|
+
const base = document.createElement('base');
|
|
15503
|
+
base.target = baseTarget;
|
|
15504
|
+
document.head.prepend(base);
|
|
15505
|
+
}
|
|
15506
|
+
}
|
|
15477
15507
|
target = await performSwap(target, src, swapMode, {
|
|
15478
15508
|
syncRootAttributes: isFullOutletNavigation,
|
|
15479
15509
|
signal: transaction.controller.signal,
|
|
@@ -15599,10 +15629,39 @@ async function navigateRequest(opts) {
|
|
|
15599
15629
|
opts.onEnd?.({ ...context });
|
|
15600
15630
|
}
|
|
15601
15631
|
}
|
|
15602
|
-
function
|
|
15603
|
-
if (
|
|
15604
|
-
|
|
15605
|
-
|
|
15632
|
+
function eligibleAnchorUrl(link) {
|
|
15633
|
+
if (!(link instanceof HTMLAnchorElement) || !link.getAttribute('href')
|
|
15634
|
+
|| link.hasAttribute('download') || link.closest('[g-no-boost]'))
|
|
15635
|
+
return null;
|
|
15636
|
+
const target = link.getAttribute('target') ?? document.querySelector('base[target]')?.getAttribute('target');
|
|
15637
|
+
if (target && target.toLowerCase() !== '_self')
|
|
15638
|
+
return null;
|
|
15639
|
+
let url;
|
|
15640
|
+
try {
|
|
15641
|
+
url = new URL(link.href);
|
|
15642
|
+
}
|
|
15643
|
+
catch {
|
|
15644
|
+
return null;
|
|
15645
|
+
}
|
|
15646
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.origin !== location.origin
|
|
15647
|
+
|| url.username || url.password)
|
|
15648
|
+
return null;
|
|
15649
|
+
// URL.hash is empty for both an absent fragment and a trailing "#".
|
|
15650
|
+
if (url.href.includes('#') && canonicalUrl(url.href) === canonicalUrl(location.href))
|
|
15651
|
+
return null;
|
|
15652
|
+
// A page visit would need to remove the outgoing base before inserting
|
|
15653
|
+
// relative resources. Let the browser switch documents and enforce base-uri.
|
|
15654
|
+
if (document.querySelector('base[href]') && !link.hasAttribute('g-current-head')
|
|
15655
|
+
&& !['append', 'prepend'].includes(link.getAttribute('g-swap')?.toLowerCase() || '')) {
|
|
15656
|
+
try {
|
|
15657
|
+
if (resolveTarget(link) === findGlobalOutlet())
|
|
15658
|
+
return null;
|
|
15659
|
+
}
|
|
15660
|
+
catch {
|
|
15661
|
+
return null;
|
|
15662
|
+
}
|
|
15663
|
+
}
|
|
15664
|
+
return url;
|
|
15606
15665
|
}
|
|
15607
15666
|
function onClickRouter(element) {
|
|
15608
15667
|
log('[GyosRouter] g-router-link clicked');
|
|
@@ -15656,23 +15715,10 @@ function onClick(event) {
|
|
|
15656
15715
|
return;
|
|
15657
15716
|
}
|
|
15658
15717
|
const link = target.closest('a');
|
|
15659
|
-
if (!link)
|
|
15718
|
+
if (!link || !(link.hasAttribute('g-boost') || hasGlobalBoost()))
|
|
15660
15719
|
return;
|
|
15661
|
-
const
|
|
15662
|
-
if (!
|
|
15663
|
-
return;
|
|
15664
|
-
const url = new URL(href, window.location.href);
|
|
15665
|
-
if (url.origin !== window.location.origin)
|
|
15666
|
-
return;
|
|
15667
|
-
if (url.hash && canonicalUrl(url.href) === canonicalUrl(window.location.href))
|
|
15668
|
-
return;
|
|
15669
|
-
if (link.closest('[g-no-boost]'))
|
|
15670
|
-
return;
|
|
15671
|
-
if (link.hasAttribute('download'))
|
|
15672
|
-
return;
|
|
15673
|
-
if (link.getAttribute('target') && link.getAttribute('target') !== '_self')
|
|
15674
|
-
return;
|
|
15675
|
-
if (!shouldBoost(link))
|
|
15720
|
+
const url = eligibleAnchorUrl(link);
|
|
15721
|
+
if (!url)
|
|
15676
15722
|
return;
|
|
15677
15723
|
event.preventDefault();
|
|
15678
15724
|
// The default changeState is true, as this is commonly used for: navigation, etc.
|
|
@@ -15685,13 +15731,9 @@ function onMouseOverCapture(event) {
|
|
|
15685
15731
|
const link = target.closest('a[g-preload]');
|
|
15686
15732
|
if (!link)
|
|
15687
15733
|
return;
|
|
15688
|
-
const
|
|
15689
|
-
if (
|
|
15690
|
-
|
|
15691
|
-
const url = new URL(href, window.location.href);
|
|
15692
|
-
if (url.origin !== window.location.origin)
|
|
15693
|
-
return;
|
|
15694
|
-
preload(url.toString());
|
|
15734
|
+
const url = eligibleAnchorUrl(link);
|
|
15735
|
+
if (url)
|
|
15736
|
+
preload(url.href);
|
|
15695
15737
|
}
|
|
15696
15738
|
function onSubmit(event) {
|
|
15697
15739
|
if (event.defaultPrevented)
|
|
@@ -15844,7 +15886,7 @@ const Gyos = {
|
|
|
15844
15886
|
portalCreate,
|
|
15845
15887
|
portalDestroy,
|
|
15846
15888
|
setCspNonce,
|
|
15847
|
-
version: '0.5.
|
|
15889
|
+
version: '0.5.7'
|
|
15848
15890
|
};
|
|
15849
15891
|
|
|
15850
15892
|
setExpressionRuntime(cspExpressionRuntime);
|