gyosjs 0.4.0 → 0.5.0

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * GyosJS v0.4.0
2
+ * GyosJS v0.5.0
3
3
  * (c) 2026
4
4
  * @license MIT
5
5
  */
@@ -183,10 +183,35 @@ function hasStructuralParent(el) {
183
183
  * count.value++; // Triggers effect
184
184
  * ```
185
185
  */
186
- /**
187
- * Current effect being tracked
188
- */
189
186
  let currentEffect = null;
187
+ function track(source) {
188
+ if (!currentEffect)
189
+ return;
190
+ source.subscribers.add(currentEffect);
191
+ currentEffect.__dependencies?.add(source.subscribers);
192
+ currentEffect.__versions?.set(source, source.version);
193
+ }
194
+ function dependenciesChanged(versions) {
195
+ return untrack(() => {
196
+ for (const [source, version] of versions) {
197
+ source.refresh?.();
198
+ if (source.version !== version)
199
+ return true;
200
+ }
201
+ return false;
202
+ });
203
+ }
204
+ // Invalidate derived caches synchronously; only user effects are deferred.
205
+ function notifySubscribers(subscribers) {
206
+ for (const sub of Array.from(subscribers)) {
207
+ if (sub.__invalidate)
208
+ sub();
209
+ else if (isBatching)
210
+ batchedEffects.add(sub);
211
+ else
212
+ queueEffect(sub);
213
+ }
214
+ }
190
215
  // Simple counter for debug-friendly IDs
191
216
  let signalIdCounter = 0;
192
217
  const WARN_SUBSCRIBERS = () => typeof window !== 'undefined' && window.GYOS_DEBUG_WARN_SUBSCRIBERS;
@@ -224,6 +249,9 @@ function flushEffectQueue() {
224
249
  }
225
250
  });
226
251
  isFlushingQueue = false;
252
+ // A plain subscribe callback can enqueue more work without entering effect().
253
+ if (effectQueue.size > 0)
254
+ queueMicrotask(flushEffectQueue);
227
255
  }
228
256
  /**
229
257
  * Queue an effect for execution in next microtask
@@ -282,17 +310,14 @@ function signal(initialValue, debugOrOptions) {
282
310
  const debugId = ++signalIdCounter;
283
311
  let value = initialValue;
284
312
  const subscribers = new Set();
313
+ const source = { subscribers, version: 0 };
285
314
  let warnedSubscribers = false;
286
315
  const read = () => {
287
316
  // Track dependency
288
317
  if (currentEffect) {
289
- // IMPORTANT: Only add if not already subscribed (prevent duplicates)
290
- if (!subscribers.has(currentEffect)) {
291
- subscribers.add(currentEffect);
292
- // Store the subscribers Set in the effect's dependencies for cleanup
293
- if (currentEffect.__dependencies) {
294
- currentEffect.__dependencies.add(subscribers);
295
- }
318
+ const wasSubscribed = subscribers.has(currentEffect);
319
+ track(source);
320
+ if (!wasSubscribed) {
296
321
  if (DEBUG_VERBOSE()) {
297
322
  console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Added subscriber, total:', subscribers.size);
298
323
  }
@@ -311,18 +336,13 @@ function signal(initialValue, debugOrOptions) {
311
336
  // For objects/arrays, check if it's actually the same reference
312
337
  // Deep equality is expensive, let user handle it
313
338
  value = newValue;
339
+ source.version++;
314
340
  DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Value changed to:', newValue);
315
341
  notify();
316
342
  };
317
343
  const notify = () => {
318
344
  DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Notifying', subscribers.size, 'subscribers');
319
- if (isBatching) {
320
- subscribers.forEach(sub => batchedEffects.add(sub));
321
- }
322
- else {
323
- // Always queue effects to prevent cascading updates
324
- subscribers.forEach(sub => queueEffect(sub));
325
- }
345
+ notifySubscribers(subscribers);
326
346
  };
327
347
  // Create callable signal (like Angular/SolidJS)
328
348
  // Call without args = read, call with arg = write
@@ -357,8 +377,16 @@ function signal(initialValue, debugOrOptions) {
357
377
  },
358
378
  subscribe: {
359
379
  value: function (fn) {
360
- subscribers.add(fn);
361
- return () => subscribers.delete(fn);
380
+ let active = true;
381
+ const callback = () => { if (active)
382
+ untrack(fn); };
383
+ subscribers.add(callback);
384
+ return () => {
385
+ active = false;
386
+ subscribers.delete(callback);
387
+ effectQueue.delete(callback);
388
+ batchedEffects.delete(callback);
389
+ };
362
390
  },
363
391
  enumerable: true,
364
392
  configurable: true
@@ -418,49 +446,60 @@ function computed(fn) {
418
446
  let value;
419
447
  let isDirty = true;
420
448
  let isFirstRun = true;
449
+ let computing = false;
421
450
  const subscribers = new Set();
422
- let cleanup;
451
+ const dependencies = new Set();
452
+ const versions = new Map();
453
+ const source = { subscribers, version: 0, refresh: () => compute() };
454
+ const invalidate = () => {
455
+ // A later batched write must also move already queued consumers into
456
+ // the batch, even when an earlier ordinary write dirtied this cache.
457
+ if (isDirty && !isBatching)
458
+ return;
459
+ isDirty = true;
460
+ notifySubscribers(subscribers);
461
+ };
462
+ invalidate.__invalidate = true;
463
+ invalidate.__dependencies = dependencies;
464
+ invalidate.__versions = versions;
423
465
  const compute = () => {
424
466
  if (!isDirty && !isFirstRun)
425
467
  return;
426
- // Cleanup previous dependencies
427
- if (cleanup)
428
- cleanup();
429
- // Track dependencies in an effect
430
- cleanup = effect(() => {
431
- try {
432
- const newValue = fn();
433
- // Only update if changed
434
- if (isFirstRun || value !== newValue) {
435
- value = newValue;
436
- isFirstRun = false;
437
- isDirty = false;
438
- // Notify subscribers
439
- if (!isBatching) {
440
- subscribers.forEach(sub => queueEffect(sub));
441
- }
442
- else {
443
- subscribers.forEach(sub => batchedEffects.add(sub));
444
- }
445
- }
468
+ if (computing)
469
+ throw new Error('[Computed] Circular dependency');
470
+ computing = true;
471
+ const previousEffect = currentEffect;
472
+ try {
473
+ // A dirty upstream computed may still resolve to its previous value.
474
+ if (!isFirstRun && !dependenciesChanged(versions)) {
475
+ isDirty = false;
476
+ return;
446
477
  }
447
- catch (error) {
448
- console.error('[Computed] Error in computation:', error);
449
- throw error;
478
+ dependencies.forEach(dependency => dependency.delete(invalidate));
479
+ dependencies.clear();
480
+ versions.clear();
481
+ currentEffect = invalidate;
482
+ const nextValue = fn();
483
+ if (isFirstRun || !Object.is(value, nextValue)) {
484
+ value = nextValue;
485
+ source.version++;
450
486
  }
451
- });
452
- isDirty = false;
487
+ isFirstRun = false;
488
+ isDirty = false;
489
+ }
490
+ catch (error) {
491
+ // Preserve error isolation and the last successful value.
492
+ console.error('[Computed] Error in computation:', error);
493
+ isDirty = false;
494
+ }
495
+ finally {
496
+ currentEffect = previousEffect;
497
+ computing = false;
498
+ }
453
499
  };
454
500
  const read = () => {
455
- if (isDirty || isFirstRun)
456
- compute();
457
- // Track dependency
458
- if (currentEffect && !subscribers.has(currentEffect)) {
459
- subscribers.add(currentEffect);
460
- if (currentEffect.__dependencies) {
461
- currentEffect.__dependencies.add(subscribers);
462
- }
463
- }
501
+ compute();
502
+ track(source);
464
503
  return value;
465
504
  };
466
505
  // Create callable computed (read-only)
@@ -485,8 +524,14 @@ function computed(fn) {
485
524
  },
486
525
  subscribe: {
487
526
  value: function (fn) {
488
- subscribers.add(fn);
489
- return () => subscribers.delete(fn);
527
+ // Establish dependencies even if subscribe() is the first access.
528
+ let first = true;
529
+ return effect(() => {
530
+ read();
531
+ if (!first)
532
+ untrack(fn);
533
+ first = false;
534
+ });
490
535
  },
491
536
  enumerable: true,
492
537
  configurable: true
@@ -537,11 +582,15 @@ function computed(fn) {
537
582
  */
538
583
  function effect(fn) {
539
584
  let cleanup;
540
- let dependencies = new Set();
585
+ const dependencies = new Set();
586
+ const versions = new Map();
541
587
  let active = true;
588
+ let initialized = false;
542
589
  const execute = () => {
543
590
  if (!active)
544
591
  return;
592
+ if (initialized && !dependenciesChanged(versions))
593
+ return;
545
594
  // Prevent recursive execution - if already running, skip
546
595
  if (runningEffects.has(execute)) {
547
596
  DEBUG() && console.warn('[Effect] Skipped recursive execution');
@@ -556,10 +605,13 @@ function effect(fn) {
556
605
  });
557
606
  DEBUG() && console.log('[Effect] Cleaned up dependencies, count:', dependencies.size);
558
607
  dependencies.clear();
608
+ versions.clear();
559
609
  // Clean up previous run
560
610
  if (cleanup) {
611
+ const previousCleanup = cleanup;
612
+ cleanup = undefined;
561
613
  try {
562
- cleanup();
614
+ untrack(previousCleanup);
563
615
  }
564
616
  catch (error) {
565
617
  console.error('[Effect] Error in cleanup:', error);
@@ -570,6 +622,7 @@ function effect(fn) {
570
622
  currentEffect = execute;
571
623
  // Store dependencies for cleanup
572
624
  execute.__dependencies = dependencies;
625
+ execute.__versions = versions;
573
626
  try {
574
627
  const nextCleanup = fn();
575
628
  cleanup = typeof nextCleanup === 'function' ? nextCleanup : undefined;
@@ -579,6 +632,7 @@ function effect(fn) {
579
632
  // Don't throw - allow other effects to continue
580
633
  }
581
634
  finally {
635
+ initialized = true;
582
636
  currentEffect = prevEffect;
583
637
  effectDepth--;
584
638
  runningEffects.delete(execute);
@@ -595,14 +649,17 @@ function effect(fn) {
595
649
  if (!active)
596
650
  return;
597
651
  active = false;
652
+ effectQueue.delete(execute);
653
+ batchedEffects.delete(execute);
598
654
  // Remove from all dependencies
599
655
  dependencies.forEach(depSet => {
600
656
  depSet.delete(execute);
601
657
  });
602
658
  dependencies.clear();
659
+ versions.clear();
603
660
  if (cleanup) {
604
661
  try {
605
- cleanup();
662
+ untrack(cleanup);
606
663
  }
607
664
  catch (error) {
608
665
  console.error('[Effect] Error in final cleanup:', error);
@@ -662,6 +719,8 @@ function batch(fn) {
662
719
  const effects = Array.from(batchedEffects);
663
720
  batchedEffects.clear();
664
721
  effects.forEach(effect => {
722
+ // This batch also settles any earlier queued write to this observer.
723
+ effectQueue.delete(effect);
665
724
  try {
666
725
  effect();
667
726
  }
@@ -5571,6 +5630,21 @@ setMountFunction(mount);
5571
5630
  * Registry of all scopes
5572
5631
  */
5573
5632
  const scopeRegistry = new Map();
5633
+ const warnedReveals = new WeakSet();
5634
+ function diagnoseUnscopedReveals(root) {
5635
+ if (!DEBUG())
5636
+ return;
5637
+ const elements = [...root.querySelectorAll('[g-reveal]')];
5638
+ if (root instanceof Element && root.hasAttribute('g-reveal'))
5639
+ elements.unshift(root);
5640
+ for (const element of elements) {
5641
+ if (warnedReveals.has(element) || isInIgnoredTree(element)
5642
+ || element.closest('[g-scope]') || getScopeFromElement(element))
5643
+ continue;
5644
+ warnedReveals.add(element);
5645
+ console.warn('[Gyos] g-reveal has no owning scope. Add g-scope to its container; global reveal CSS may otherwise hide this content.', element);
5646
+ }
5647
+ }
5574
5648
  /**
5575
5649
  * Register a scope
5576
5650
  */
@@ -5618,6 +5692,7 @@ function mountAll(root) {
5618
5692
  allElements.sort((a, b) => getDepth(b) - getDepth(a));
5619
5693
  // Filter out elements inside structural directives - they will be mounted by structural processor
5620
5694
  allElements.forEach(el => !hasStructuralParent(el) && mount(el));
5695
+ diagnoseUnscopedReveals(document.body);
5621
5696
  }
5622
5697
  function mountTree(el) {
5623
5698
  if (isInIgnoredTree(el) || !document.body.contains(el))
@@ -5628,6 +5703,7 @@ function mountTree(el) {
5628
5703
  // Child scopes own their subtree before an existing parent scope parses the insertion.
5629
5704
  candidates.sort((a, b) => getDepth(b) - getDepth(a));
5630
5705
  candidates.forEach(element => !hasStructuralParent(element) && mount(element));
5706
+ diagnoseUnscopedReveals(el);
5631
5707
  if (getMountedScope(el))
5632
5708
  return;
5633
5709
  const ownerScope = getScopeFromElement(el);
@@ -5646,7 +5722,7 @@ function mount(el) {
5646
5722
  return;
5647
5723
  // Check if element removed but still has g-scope (possible in some edge cases)
5648
5724
  getAllMountedScopes().forEach((_, mountedEl) => {
5649
- if (!document.body.contains(mountedEl)) {
5725
+ if (!mountedEl.isConnected) {
5650
5726
  disposeEffects(mountedEl);
5651
5727
  }
5652
5728
  });
@@ -6972,7 +7048,8 @@ function getPersistKey(el, generateIfMissing = false) {
6972
7048
  el.dataset.gyosPersistId = key;
6973
7049
  return key;
6974
7050
  }
6975
- // Hidden parking lot keeps persisted nodes alive (e.g. audio keeps playing)
7051
+ // Keep the parking host outside body: body itself may be the swap target.
7052
+ // A disconnected parking host makes browsers pause otherwise persisted media.
6976
7053
  const persistParking = typeof document !== 'undefined'
6977
7054
  ? (() => {
6978
7055
  const park = document.createElement('div');
@@ -6981,12 +7058,7 @@ const persistParking = typeof document !== 'undefined'
6981
7058
  park.style.top = '-99999px';
6982
7059
  park.style.width = '0';
6983
7060
  park.style.height = '0';
6984
- if (document.readyState === 'loading') {
6985
- document.addEventListener('DOMContentLoaded', () => document.body.appendChild(park));
6986
- }
6987
- else {
6988
- document.body.appendChild(park);
6989
- }
7061
+ document.documentElement.appendChild(park);
6990
7062
  return park;
6991
7063
  })()
6992
7064
  : null;
@@ -6997,8 +7069,8 @@ function elementsIn(root) {
6997
7069
  return elements;
6998
7070
  }
6999
7071
  function ensureParkingIsConnected() {
7000
- if (persistParking && document.body && !persistParking.isConnected) {
7001
- document.body.appendChild(persistParking);
7072
+ if (persistParking && persistParking.parentElement !== document.documentElement) {
7073
+ document.documentElement.appendChild(persistParking);
7002
7074
  }
7003
7075
  }
7004
7076
  function detachPersist(root = document) {
@@ -7016,12 +7088,18 @@ function detachPersist(root = document) {
7016
7088
  });
7017
7089
  }
7018
7090
  function mergePersistIntoLive(root) {
7091
+ // Return the host to the current body before scope mounting/cleanup inspects it.
7092
+ if (persistParking && persistParking.parentElement !== document.body) {
7093
+ document.body.appendChild(persistParking);
7094
+ }
7019
7095
  if (!persistEntries.size)
7020
7096
  return;
7021
7097
  // If placeholders lack ids but we only have one persist entry, assign its key for convenience
7022
7098
  if (persistEntries.size === 1) {
7023
7099
  const loneKey = Array.from(persistEntries.keys())[0];
7024
7100
  elementsIn(root).forEach(el => {
7101
+ if (persistParking?.contains(el))
7102
+ return;
7025
7103
  if (!getPersistKey(el, false)) {
7026
7104
  el.dataset.gyosPersistId = loneKey;
7027
7105
  }
@@ -7029,6 +7107,8 @@ function mergePersistIntoLive(root) {
7029
7107
  }
7030
7108
  // Element placeholders
7031
7109
  elementsIn(root).forEach(placeholder => {
7110
+ if (persistParking?.contains(placeholder))
7111
+ return;
7032
7112
  const key = getPersistKey(placeholder, false);
7033
7113
  if (!key)
7034
7114
  return;
@@ -7046,6 +7126,8 @@ function mergePersistIntoLive(root) {
7046
7126
  const toReplace = [];
7047
7127
  while (walker.nextNode()) {
7048
7128
  const comment = walker.currentNode;
7129
+ if (persistParking?.contains(comment))
7130
+ continue;
7049
7131
  const match = comment.data.match(/g-persist[:=]\s*([A-Za-z0-9_\-:.]+)/);
7050
7132
  if (match) {
7051
7133
  toReplace.push({ node: comment, key: match[1] });
@@ -7703,6 +7785,36 @@ function prepareNavigationHtml(html) {
7703
7785
  * Implements attribute-driven routing, snapshot caching, and persistent islands.
7704
7786
  */
7705
7787
  const submittingForms = new WeakSet();
7788
+ async function visit(url, options, fresh) {
7789
+ const destination = new URL(url, document.baseURI);
7790
+ if (!['http:', 'https:'].includes(destination.protocol) || destination.origin !== location.origin || destination.username || destination.password) {
7791
+ throw new TypeError('Gyos.navigate requires a same-origin HTTP(S) URL without credentials.');
7792
+ }
7793
+ if (options.target !== undefined && !(document.querySelector(options.target) instanceof HTMLElement)) {
7794
+ throw new TypeError('Gyos.navigate target does not exist.');
7795
+ }
7796
+ if (!document.querySelector('[g-boost]')) {
7797
+ throw new TypeError('Gyos.navigate requires a g-boost layout.');
7798
+ }
7799
+ startRouter();
7800
+ let result;
7801
+ await navigateRequest({
7802
+ url: destination.href, method: 'GET',
7803
+ changeState: options.history !== 'none', replace: options.history === 'replace',
7804
+ targetSelector: options.target, strictTarget: options.target !== undefined, swapMode: options.swap,
7805
+ currentHead: options.currentHead, scroll: options.scroll, signal: options.signal, fresh,
7806
+ onEnd: context => { result = context; }
7807
+ });
7808
+ return result;
7809
+ }
7810
+ /** Navigate through the boost pipeline. Resolves after navigation-end hooks. */
7811
+ function navigate(url, options = {}) {
7812
+ return visit(url, options, false);
7813
+ }
7814
+ /** Fetch the current URL again, preserving history and scroll by default. */
7815
+ function refresh(options = {}) {
7816
+ return visit(location.href, { history: 'none', scroll: false, ...options }, true);
7817
+ }
7706
7818
  const snapshots = new Map();
7707
7819
  const preloadCache = new Map();
7708
7820
  const preloadControllers = new Map();
@@ -8089,12 +8201,27 @@ function fallbackFromBoost(opts, url, requestSent) {
8089
8201
  }
8090
8202
  console.error(`[GyosRouter] ${method} navigation could not be boosted; the request will not be replayed.`);
8091
8203
  }
8092
- async function navigate(opts) {
8204
+ async function navigateRequest(opts) {
8205
+ const finishUnstarted = () => {
8206
+ opts.onEnd?.({ from: currentUrl, url: opts.url, method: opts.method,
8207
+ trigger: opts.trigger || null, target: null, form: null, popstate: false,
8208
+ signal: opts.signal, status: null, committed: false, fallback: false, outcome: 'aborted' });
8209
+ };
8210
+ if (opts.signal?.aborted) {
8211
+ finishUnstarted();
8212
+ return;
8213
+ }
8093
8214
  while (activeNavigation) {
8094
8215
  const previous = activeNavigation;
8095
8216
  if (previous.committing) {
8096
8217
  log('[GyosRouter] Waiting for previous DOM commit');
8097
- await previous.done;
8218
+ try {
8219
+ await (opts.signal ? waitForNavigation(previous.done, opts.signal) : previous.done);
8220
+ }
8221
+ catch {
8222
+ finishUnstarted();
8223
+ return;
8224
+ }
8098
8225
  continue;
8099
8226
  }
8100
8227
  log('[GyosRouter] Cancelling previous navigation');
@@ -8113,6 +8240,10 @@ async function navigate(opts) {
8113
8240
  resolveDone
8114
8241
  };
8115
8242
  activeNavigation = transaction;
8243
+ const abort = () => cancelNavigation(transaction);
8244
+ opts.signal?.addEventListener('abort', abort, { once: true });
8245
+ if (opts.signal?.aborted)
8246
+ abort();
8116
8247
  const currentBaseUrl = document.baseURI;
8117
8248
  rememberResourceUrls(document, currentBaseUrl);
8118
8249
  const context = {
@@ -8136,6 +8267,7 @@ async function navigate(opts) {
8136
8267
  }
8137
8268
  };
8138
8269
  try {
8270
+ assertActiveNavigation(transaction);
8139
8271
  if (formEvent)
8140
8272
  document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
8141
8273
  runNavigationHooks(beforeNavigate, opts.url, context);
@@ -8148,6 +8280,10 @@ async function navigate(opts) {
8148
8280
  saveScrollPosition();
8149
8281
  // Pick target element to swap
8150
8282
  let target = resolveTarget(opts.trigger, opts.targetSelector, opts.targetOutletIndex);
8283
+ if (opts.strictTarget && (!opts.targetSelector || !target?.matches(opts.targetSelector))) {
8284
+ context.outcome = 'invalid-response';
8285
+ return; // A queued explicit target disappeared; never broaden the swap.
8286
+ }
8151
8287
  context.target = target;
8152
8288
  if (!target) {
8153
8289
  if (isActiveNavigation(transaction))
@@ -8192,7 +8328,12 @@ async function navigate(opts) {
8192
8328
  else {
8193
8329
  // Check preload cache if GET
8194
8330
  const preloadKey = canonicalUrl(finalUrl, true);
8195
- if (opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
8331
+ if (opts.fresh) {
8332
+ preloadControllers.get(preloadKey)?.abort();
8333
+ preloadControllers.delete(preloadKey);
8334
+ preloadCache.delete(preloadKey);
8335
+ }
8336
+ if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
8196
8337
  log('[GyosRouter] using preload cache for', finalUrl);
8197
8338
  try {
8198
8339
  response = await waitForNavigation(preloadCache.get(preloadKey), transaction.controller.signal);
@@ -8400,7 +8541,10 @@ async function navigate(opts) {
8400
8541
  finalizeCommit();
8401
8542
  }
8402
8543
  // Handle scroll after mount scopes
8403
- if (changesState) {
8544
+ if (opts.scroll === false) {
8545
+ // Explicit refresh/navigation policy keeps the current viewport.
8546
+ }
8547
+ else if (changesState) {
8404
8548
  handleScroll(targetUrl, opts.trigger);
8405
8549
  }
8406
8550
  else if (opts.popstate) {
@@ -8465,6 +8609,7 @@ async function navigate(opts) {
8465
8609
  activeNavigation = null;
8466
8610
  progressBar?.complete();
8467
8611
  }
8612
+ opts.signal?.removeEventListener('abort', abort);
8468
8613
  transaction.resolveDone();
8469
8614
  if (formEvent)
8470
8615
  submittingForms.delete(formEvent.form);
@@ -8475,6 +8620,7 @@ async function navigate(opts) {
8475
8620
  detail: { ...formEvent, url, status, outcome, committed, fallback }
8476
8621
  }));
8477
8622
  }
8623
+ opts.onEnd?.({ ...context });
8478
8624
  }
8479
8625
  }
8480
8626
  function shouldBoost(el) {
@@ -8505,7 +8651,7 @@ function onClickRouter(element) {
8505
8651
  const scope = getScopeFromElement(element);
8506
8652
  const jsonData = evaluateExpression(decodeURIComponent(element.getAttribute(paramsAttr) || ''), scope, false);
8507
8653
  // The default changeState is false, as this is commonly used for: load more, infinite scroll, etc.
8508
- navigate({
8654
+ navigateRequest({
8509
8655
  url: parsedUrl.toString(), method, trigger: element, jsonData, changeState: false
8510
8656
  });
8511
8657
  }
@@ -8554,7 +8700,7 @@ function onClick(event) {
8554
8700
  return;
8555
8701
  event.preventDefault();
8556
8702
  // The default changeState is true, as this is commonly used for: navigation, etc.
8557
- navigate({ url: url.toString(), method: 'GET', trigger: link, changeState: true });
8703
+ navigateRequest({ url: url.toString(), method: 'GET', trigger: link, changeState: true });
8558
8704
  }
8559
8705
  function onMouseOverCapture(event) {
8560
8706
  const target = event.target;
@@ -8610,7 +8756,7 @@ function onSubmit(event) {
8610
8756
  return;
8611
8757
  const formData = new FormData(form, submitter);
8612
8758
  submittingForms.add(form);
8613
- void navigate({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
8759
+ void navigateRequest({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
8614
8760
  }
8615
8761
  function onPopState(event) {
8616
8762
  const url = window.location.href;
@@ -8628,14 +8774,14 @@ function onPopState(event) {
8628
8774
  }
8629
8775
  event.preventDefault();
8630
8776
  // The browser changes location before popstate fires. Stop any pending page
8631
- // script immediately, then let navigate() wait for its DOM finalizer.
8777
+ // script immediately, then let navigateRequest() wait for its DOM finalizer.
8632
8778
  if (activeNavigation?.committing)
8633
8779
  cancelNavigation(activeNavigation);
8634
8780
  // The browser has already moved to the destination history entry. Keep the
8635
8781
  // router's entry pointer aligned before any restored page script can navigate.
8636
8782
  currentHistoryEntryId = destinationEntryId;
8637
8783
  // No snapshot, do a normal navigation without changing history (changeState: false)
8638
- navigate({
8784
+ navigateRequest({
8639
8785
  url,
8640
8786
  method: 'GET',
8641
8787
  replace: true,
@@ -8717,10 +8863,12 @@ const Gyos = {
8717
8863
  onAfterNavigate,
8718
8864
  onBeforeSwap,
8719
8865
  onNavigationEnd,
8866
+ navigate,
8867
+ refresh,
8720
8868
  portalCreate,
8721
8869
  portalDestroy,
8722
8870
  setCspNonce,
8723
- version: '0.4.0'
8871
+ version: '0.5.0'
8724
8872
  };
8725
8873
 
8726
8874
  // This file was generated. Do not modify manually!