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.
package/dist/gyos.js CHANGED
@@ -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
  */
@@ -235,10 +235,35 @@
235
235
  * count.value++; // Triggers effect
236
236
  * ```
237
237
  */
238
- /**
239
- * Current effect being tracked
240
- */
241
238
  let currentEffect = null;
239
+ function track(source) {
240
+ if (!currentEffect)
241
+ return;
242
+ source.subscribers.add(currentEffect);
243
+ currentEffect.__dependencies?.add(source.subscribers);
244
+ currentEffect.__versions?.set(source, source.version);
245
+ }
246
+ function dependenciesChanged(versions) {
247
+ return untrack(() => {
248
+ for (const [source, version] of versions) {
249
+ source.refresh?.();
250
+ if (source.version !== version)
251
+ return true;
252
+ }
253
+ return false;
254
+ });
255
+ }
256
+ // Invalidate derived caches synchronously; only user effects are deferred.
257
+ function notifySubscribers(subscribers) {
258
+ for (const sub of Array.from(subscribers)) {
259
+ if (sub.__invalidate)
260
+ sub();
261
+ else if (isBatching)
262
+ batchedEffects.add(sub);
263
+ else
264
+ queueEffect(sub);
265
+ }
266
+ }
242
267
  // Simple counter for debug-friendly IDs
243
268
  let signalIdCounter = 0;
244
269
  const WARN_SUBSCRIBERS = () => typeof window !== 'undefined' && window.GYOS_DEBUG_WARN_SUBSCRIBERS;
@@ -276,6 +301,9 @@
276
301
  }
277
302
  });
278
303
  isFlushingQueue = false;
304
+ // A plain subscribe callback can enqueue more work without entering effect().
305
+ if (effectQueue.size > 0)
306
+ queueMicrotask(flushEffectQueue);
279
307
  }
280
308
  /**
281
309
  * Queue an effect for execution in next microtask
@@ -334,17 +362,14 @@
334
362
  const debugId = ++signalIdCounter;
335
363
  let value = initialValue;
336
364
  const subscribers = new Set();
365
+ const source = { subscribers, version: 0 };
337
366
  let warnedSubscribers = false;
338
367
  const read = () => {
339
368
  // Track dependency
340
369
  if (currentEffect) {
341
- // IMPORTANT: Only add if not already subscribed (prevent duplicates)
342
- if (!subscribers.has(currentEffect)) {
343
- subscribers.add(currentEffect);
344
- // Store the subscribers Set in the effect's dependencies for cleanup
345
- if (currentEffect.__dependencies) {
346
- currentEffect.__dependencies.add(subscribers);
347
- }
370
+ const wasSubscribed = subscribers.has(currentEffect);
371
+ track(source);
372
+ if (!wasSubscribed) {
348
373
  if (DEBUG_VERBOSE()) {
349
374
  console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Added subscriber, total:', subscribers.size);
350
375
  }
@@ -363,18 +388,13 @@
363
388
  // For objects/arrays, check if it's actually the same reference
364
389
  // Deep equality is expensive, let user handle it
365
390
  value = newValue;
391
+ source.version++;
366
392
  DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Value changed to:', newValue);
367
393
  notify();
368
394
  };
369
395
  const notify = () => {
370
396
  DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Notifying', subscribers.size, 'subscribers');
371
- if (isBatching) {
372
- subscribers.forEach(sub => batchedEffects.add(sub));
373
- }
374
- else {
375
- // Always queue effects to prevent cascading updates
376
- subscribers.forEach(sub => queueEffect(sub));
377
- }
397
+ notifySubscribers(subscribers);
378
398
  };
379
399
  // Create callable signal (like Angular/SolidJS)
380
400
  // Call without args = read, call with arg = write
@@ -409,8 +429,16 @@
409
429
  },
410
430
  subscribe: {
411
431
  value: function (fn) {
412
- subscribers.add(fn);
413
- return () => subscribers.delete(fn);
432
+ let active = true;
433
+ const callback = () => { if (active)
434
+ untrack(fn); };
435
+ subscribers.add(callback);
436
+ return () => {
437
+ active = false;
438
+ subscribers.delete(callback);
439
+ effectQueue.delete(callback);
440
+ batchedEffects.delete(callback);
441
+ };
414
442
  },
415
443
  enumerable: true,
416
444
  configurable: true
@@ -470,49 +498,60 @@
470
498
  let value;
471
499
  let isDirty = true;
472
500
  let isFirstRun = true;
501
+ let computing = false;
473
502
  const subscribers = new Set();
474
- let cleanup;
503
+ const dependencies = new Set();
504
+ const versions = new Map();
505
+ const source = { subscribers, version: 0, refresh: () => compute() };
506
+ const invalidate = () => {
507
+ // A later batched write must also move already queued consumers into
508
+ // the batch, even when an earlier ordinary write dirtied this cache.
509
+ if (isDirty && !isBatching)
510
+ return;
511
+ isDirty = true;
512
+ notifySubscribers(subscribers);
513
+ };
514
+ invalidate.__invalidate = true;
515
+ invalidate.__dependencies = dependencies;
516
+ invalidate.__versions = versions;
475
517
  const compute = () => {
476
518
  if (!isDirty && !isFirstRun)
477
519
  return;
478
- // Cleanup previous dependencies
479
- if (cleanup)
480
- cleanup();
481
- // Track dependencies in an effect
482
- cleanup = effect(() => {
483
- try {
484
- const newValue = fn();
485
- // Only update if changed
486
- if (isFirstRun || value !== newValue) {
487
- value = newValue;
488
- isFirstRun = false;
489
- isDirty = false;
490
- // Notify subscribers
491
- if (!isBatching) {
492
- subscribers.forEach(sub => queueEffect(sub));
493
- }
494
- else {
495
- subscribers.forEach(sub => batchedEffects.add(sub));
496
- }
497
- }
520
+ if (computing)
521
+ throw new Error('[Computed] Circular dependency');
522
+ computing = true;
523
+ const previousEffect = currentEffect;
524
+ try {
525
+ // A dirty upstream computed may still resolve to its previous value.
526
+ if (!isFirstRun && !dependenciesChanged(versions)) {
527
+ isDirty = false;
528
+ return;
498
529
  }
499
- catch (error) {
500
- console.error('[Computed] Error in computation:', error);
501
- throw error;
530
+ dependencies.forEach(dependency => dependency.delete(invalidate));
531
+ dependencies.clear();
532
+ versions.clear();
533
+ currentEffect = invalidate;
534
+ const nextValue = fn();
535
+ if (isFirstRun || !Object.is(value, nextValue)) {
536
+ value = nextValue;
537
+ source.version++;
502
538
  }
503
- });
504
- isDirty = false;
539
+ isFirstRun = false;
540
+ isDirty = false;
541
+ }
542
+ catch (error) {
543
+ // Preserve error isolation and the last successful value.
544
+ console.error('[Computed] Error in computation:', error);
545
+ isDirty = false;
546
+ }
547
+ finally {
548
+ currentEffect = previousEffect;
549
+ computing = false;
550
+ }
505
551
  };
506
552
  const read = () => {
507
- if (isDirty || isFirstRun)
508
- compute();
509
- // Track dependency
510
- if (currentEffect && !subscribers.has(currentEffect)) {
511
- subscribers.add(currentEffect);
512
- if (currentEffect.__dependencies) {
513
- currentEffect.__dependencies.add(subscribers);
514
- }
515
- }
553
+ compute();
554
+ track(source);
516
555
  return value;
517
556
  };
518
557
  // Create callable computed (read-only)
@@ -537,8 +576,14 @@
537
576
  },
538
577
  subscribe: {
539
578
  value: function (fn) {
540
- subscribers.add(fn);
541
- return () => subscribers.delete(fn);
579
+ // Establish dependencies even if subscribe() is the first access.
580
+ let first = true;
581
+ return effect(() => {
582
+ read();
583
+ if (!first)
584
+ untrack(fn);
585
+ first = false;
586
+ });
542
587
  },
543
588
  enumerable: true,
544
589
  configurable: true
@@ -589,11 +634,15 @@
589
634
  */
590
635
  function effect(fn) {
591
636
  let cleanup;
592
- let dependencies = new Set();
637
+ const dependencies = new Set();
638
+ const versions = new Map();
593
639
  let active = true;
640
+ let initialized = false;
594
641
  const execute = () => {
595
642
  if (!active)
596
643
  return;
644
+ if (initialized && !dependenciesChanged(versions))
645
+ return;
597
646
  // Prevent recursive execution - if already running, skip
598
647
  if (runningEffects.has(execute)) {
599
648
  DEBUG() && console.warn('[Effect] Skipped recursive execution');
@@ -608,10 +657,13 @@
608
657
  });
609
658
  DEBUG() && console.log('[Effect] Cleaned up dependencies, count:', dependencies.size);
610
659
  dependencies.clear();
660
+ versions.clear();
611
661
  // Clean up previous run
612
662
  if (cleanup) {
663
+ const previousCleanup = cleanup;
664
+ cleanup = undefined;
613
665
  try {
614
- cleanup();
666
+ untrack(previousCleanup);
615
667
  }
616
668
  catch (error) {
617
669
  console.error('[Effect] Error in cleanup:', error);
@@ -622,6 +674,7 @@
622
674
  currentEffect = execute;
623
675
  // Store dependencies for cleanup
624
676
  execute.__dependencies = dependencies;
677
+ execute.__versions = versions;
625
678
  try {
626
679
  const nextCleanup = fn();
627
680
  cleanup = typeof nextCleanup === 'function' ? nextCleanup : undefined;
@@ -631,6 +684,7 @@
631
684
  // Don't throw - allow other effects to continue
632
685
  }
633
686
  finally {
687
+ initialized = true;
634
688
  currentEffect = prevEffect;
635
689
  effectDepth--;
636
690
  runningEffects.delete(execute);
@@ -647,14 +701,17 @@
647
701
  if (!active)
648
702
  return;
649
703
  active = false;
704
+ effectQueue.delete(execute);
705
+ batchedEffects.delete(execute);
650
706
  // Remove from all dependencies
651
707
  dependencies.forEach(depSet => {
652
708
  depSet.delete(execute);
653
709
  });
654
710
  dependencies.clear();
711
+ versions.clear();
655
712
  if (cleanup) {
656
713
  try {
657
- cleanup();
714
+ untrack(cleanup);
658
715
  }
659
716
  catch (error) {
660
717
  console.error('[Effect] Error in final cleanup:', error);
@@ -714,6 +771,8 @@
714
771
  const effects = Array.from(batchedEffects);
715
772
  batchedEffects.clear();
716
773
  effects.forEach(effect => {
774
+ // This batch also settles any earlier queued write to this observer.
775
+ effectQueue.delete(effect);
717
776
  try {
718
777
  effect();
719
778
  }
@@ -5609,6 +5668,21 @@
5609
5668
  * Registry of all scopes
5610
5669
  */
5611
5670
  const scopeRegistry = new Map();
5671
+ const warnedReveals = new WeakSet();
5672
+ function diagnoseUnscopedReveals(root) {
5673
+ if (!DEBUG())
5674
+ return;
5675
+ const elements = [...root.querySelectorAll('[g-reveal]')];
5676
+ if (root instanceof Element && root.hasAttribute('g-reveal'))
5677
+ elements.unshift(root);
5678
+ for (const element of elements) {
5679
+ if (warnedReveals.has(element) || isInIgnoredTree(element)
5680
+ || element.closest('[g-scope]') || getScopeFromElement(element))
5681
+ continue;
5682
+ warnedReveals.add(element);
5683
+ console.warn('[Gyos] g-reveal has no owning scope. Add g-scope to its container; global reveal CSS may otherwise hide this content.', element);
5684
+ }
5685
+ }
5612
5686
  /**
5613
5687
  * Register a scope
5614
5688
  */
@@ -5656,6 +5730,7 @@
5656
5730
  allElements.sort((a, b) => getDepth(b) - getDepth(a));
5657
5731
  // Filter out elements inside structural directives - they will be mounted by structural processor
5658
5732
  allElements.forEach(el => !hasStructuralParent(el) && mount(el));
5733
+ diagnoseUnscopedReveals(document.body);
5659
5734
  }
5660
5735
  function mountTree(el) {
5661
5736
  if (isInIgnoredTree(el) || !document.body.contains(el))
@@ -5666,6 +5741,7 @@
5666
5741
  // Child scopes own their subtree before an existing parent scope parses the insertion.
5667
5742
  candidates.sort((a, b) => getDepth(b) - getDepth(a));
5668
5743
  candidates.forEach(element => !hasStructuralParent(element) && mount(element));
5744
+ diagnoseUnscopedReveals(el);
5669
5745
  if (getMountedScope(el))
5670
5746
  return;
5671
5747
  const ownerScope = getScopeFromElement(el);
@@ -5684,7 +5760,7 @@
5684
5760
  return;
5685
5761
  // Check if element removed but still has g-scope (possible in some edge cases)
5686
5762
  getAllMountedScopes().forEach((_, mountedEl) => {
5687
- if (!document.body.contains(mountedEl)) {
5763
+ if (!mountedEl.isConnected) {
5688
5764
  disposeEffects(mountedEl);
5689
5765
  }
5690
5766
  });
@@ -6996,7 +7072,8 @@
6996
7072
  el.dataset.gyosPersistId = key;
6997
7073
  return key;
6998
7074
  }
6999
- // Hidden parking lot keeps persisted nodes alive (e.g. audio keeps playing)
7075
+ // Keep the parking host outside body: body itself may be the swap target.
7076
+ // A disconnected parking host makes browsers pause otherwise persisted media.
7000
7077
  const persistParking = typeof document !== 'undefined'
7001
7078
  ? (() => {
7002
7079
  const park = document.createElement('div');
@@ -7005,12 +7082,7 @@
7005
7082
  park.style.top = '-99999px';
7006
7083
  park.style.width = '0';
7007
7084
  park.style.height = '0';
7008
- if (document.readyState === 'loading') {
7009
- document.addEventListener('DOMContentLoaded', () => document.body.appendChild(park));
7010
- }
7011
- else {
7012
- document.body.appendChild(park);
7013
- }
7085
+ document.documentElement.appendChild(park);
7014
7086
  return park;
7015
7087
  })()
7016
7088
  : null;
@@ -7021,8 +7093,8 @@
7021
7093
  return elements;
7022
7094
  }
7023
7095
  function ensureParkingIsConnected() {
7024
- if (persistParking && document.body && !persistParking.isConnected) {
7025
- document.body.appendChild(persistParking);
7096
+ if (persistParking && persistParking.parentElement !== document.documentElement) {
7097
+ document.documentElement.appendChild(persistParking);
7026
7098
  }
7027
7099
  }
7028
7100
  function detachPersist(root = document) {
@@ -7040,12 +7112,18 @@
7040
7112
  });
7041
7113
  }
7042
7114
  function mergePersistIntoLive(root) {
7115
+ // Return the host to the current body before scope mounting/cleanup inspects it.
7116
+ if (persistParking && persistParking.parentElement !== document.body) {
7117
+ document.body.appendChild(persistParking);
7118
+ }
7043
7119
  if (!persistEntries.size)
7044
7120
  return;
7045
7121
  // If placeholders lack ids but we only have one persist entry, assign its key for convenience
7046
7122
  if (persistEntries.size === 1) {
7047
7123
  const loneKey = Array.from(persistEntries.keys())[0];
7048
7124
  elementsIn(root).forEach(el => {
7125
+ if (persistParking?.contains(el))
7126
+ return;
7049
7127
  if (!getPersistKey(el, false)) {
7050
7128
  el.dataset.gyosPersistId = loneKey;
7051
7129
  }
@@ -7053,6 +7131,8 @@
7053
7131
  }
7054
7132
  // Element placeholders
7055
7133
  elementsIn(root).forEach(placeholder => {
7134
+ if (persistParking?.contains(placeholder))
7135
+ return;
7056
7136
  const key = getPersistKey(placeholder, false);
7057
7137
  if (!key)
7058
7138
  return;
@@ -7070,6 +7150,8 @@
7070
7150
  const toReplace = [];
7071
7151
  while (walker.nextNode()) {
7072
7152
  const comment = walker.currentNode;
7153
+ if (persistParking?.contains(comment))
7154
+ continue;
7073
7155
  const match = comment.data.match(/g-persist[:=]\s*([A-Za-z0-9_\-:.]+)/);
7074
7156
  if (match) {
7075
7157
  toReplace.push({ node: comment, key: match[1] });
@@ -7727,6 +7809,36 @@
7727
7809
  * Implements attribute-driven routing, snapshot caching, and persistent islands.
7728
7810
  */
7729
7811
  const submittingForms = new WeakSet();
7812
+ async function visit(url, options, fresh) {
7813
+ const destination = new URL(url, document.baseURI);
7814
+ if (!['http:', 'https:'].includes(destination.protocol) || destination.origin !== location.origin || destination.username || destination.password) {
7815
+ throw new TypeError('Gyos.navigate requires a same-origin HTTP(S) URL without credentials.');
7816
+ }
7817
+ if (options.target !== undefined && !(document.querySelector(options.target) instanceof HTMLElement)) {
7818
+ throw new TypeError('Gyos.navigate target does not exist.');
7819
+ }
7820
+ if (!document.querySelector('[g-boost]')) {
7821
+ throw new TypeError('Gyos.navigate requires a g-boost layout.');
7822
+ }
7823
+ startRouter();
7824
+ let result;
7825
+ await navigateRequest({
7826
+ url: destination.href, method: 'GET',
7827
+ changeState: options.history !== 'none', replace: options.history === 'replace',
7828
+ targetSelector: options.target, strictTarget: options.target !== undefined, swapMode: options.swap,
7829
+ currentHead: options.currentHead, scroll: options.scroll, signal: options.signal, fresh,
7830
+ onEnd: context => { result = context; }
7831
+ });
7832
+ return result;
7833
+ }
7834
+ /** Navigate through the boost pipeline. Resolves after navigation-end hooks. */
7835
+ function navigate(url, options = {}) {
7836
+ return visit(url, options, false);
7837
+ }
7838
+ /** Fetch the current URL again, preserving history and scroll by default. */
7839
+ function refresh(options = {}) {
7840
+ return visit(location.href, { history: 'none', scroll: false, ...options }, true);
7841
+ }
7730
7842
  const snapshots = new Map();
7731
7843
  const preloadCache = new Map();
7732
7844
  const preloadControllers = new Map();
@@ -8113,12 +8225,27 @@
8113
8225
  }
8114
8226
  console.error(`[GyosRouter] ${method} navigation could not be boosted; the request will not be replayed.`);
8115
8227
  }
8116
- async function navigate(opts) {
8228
+ async function navigateRequest(opts) {
8229
+ const finishUnstarted = () => {
8230
+ opts.onEnd?.({ from: currentUrl, url: opts.url, method: opts.method,
8231
+ trigger: opts.trigger || null, target: null, form: null, popstate: false,
8232
+ signal: opts.signal, status: null, committed: false, fallback: false, outcome: 'aborted' });
8233
+ };
8234
+ if (opts.signal?.aborted) {
8235
+ finishUnstarted();
8236
+ return;
8237
+ }
8117
8238
  while (activeNavigation) {
8118
8239
  const previous = activeNavigation;
8119
8240
  if (previous.committing) {
8120
8241
  log('[GyosRouter] Waiting for previous DOM commit');
8121
- await previous.done;
8242
+ try {
8243
+ await (opts.signal ? waitForNavigation(previous.done, opts.signal) : previous.done);
8244
+ }
8245
+ catch {
8246
+ finishUnstarted();
8247
+ return;
8248
+ }
8122
8249
  continue;
8123
8250
  }
8124
8251
  log('[GyosRouter] Cancelling previous navigation');
@@ -8137,6 +8264,10 @@
8137
8264
  resolveDone
8138
8265
  };
8139
8266
  activeNavigation = transaction;
8267
+ const abort = () => cancelNavigation(transaction);
8268
+ opts.signal?.addEventListener('abort', abort, { once: true });
8269
+ if (opts.signal?.aborted)
8270
+ abort();
8140
8271
  const currentBaseUrl = document.baseURI;
8141
8272
  rememberResourceUrls(document, currentBaseUrl);
8142
8273
  const context = {
@@ -8160,6 +8291,7 @@
8160
8291
  }
8161
8292
  };
8162
8293
  try {
8294
+ assertActiveNavigation(transaction);
8163
8295
  if (formEvent)
8164
8296
  document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
8165
8297
  runNavigationHooks(beforeNavigate, opts.url, context);
@@ -8172,6 +8304,10 @@
8172
8304
  saveScrollPosition();
8173
8305
  // Pick target element to swap
8174
8306
  let target = resolveTarget(opts.trigger, opts.targetSelector, opts.targetOutletIndex);
8307
+ if (opts.strictTarget && (!opts.targetSelector || !target?.matches(opts.targetSelector))) {
8308
+ context.outcome = 'invalid-response';
8309
+ return; // A queued explicit target disappeared; never broaden the swap.
8310
+ }
8175
8311
  context.target = target;
8176
8312
  if (!target) {
8177
8313
  if (isActiveNavigation(transaction))
@@ -8216,7 +8352,12 @@
8216
8352
  else {
8217
8353
  // Check preload cache if GET
8218
8354
  const preloadKey = canonicalUrl(finalUrl, true);
8219
- if (opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
8355
+ if (opts.fresh) {
8356
+ preloadControllers.get(preloadKey)?.abort();
8357
+ preloadControllers.delete(preloadKey);
8358
+ preloadCache.delete(preloadKey);
8359
+ }
8360
+ if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
8220
8361
  log('[GyosRouter] using preload cache for', finalUrl);
8221
8362
  try {
8222
8363
  response = await waitForNavigation(preloadCache.get(preloadKey), transaction.controller.signal);
@@ -8424,7 +8565,10 @@
8424
8565
  finalizeCommit();
8425
8566
  }
8426
8567
  // Handle scroll after mount scopes
8427
- if (changesState) {
8568
+ if (opts.scroll === false) {
8569
+ // Explicit refresh/navigation policy keeps the current viewport.
8570
+ }
8571
+ else if (changesState) {
8428
8572
  handleScroll(targetUrl, opts.trigger);
8429
8573
  }
8430
8574
  else if (opts.popstate) {
@@ -8489,6 +8633,7 @@
8489
8633
  activeNavigation = null;
8490
8634
  progressBar?.complete();
8491
8635
  }
8636
+ opts.signal?.removeEventListener('abort', abort);
8492
8637
  transaction.resolveDone();
8493
8638
  if (formEvent)
8494
8639
  submittingForms.delete(formEvent.form);
@@ -8499,6 +8644,7 @@
8499
8644
  detail: { ...formEvent, url, status, outcome, committed, fallback }
8500
8645
  }));
8501
8646
  }
8647
+ opts.onEnd?.({ ...context });
8502
8648
  }
8503
8649
  }
8504
8650
  function shouldBoost(el) {
@@ -8529,7 +8675,7 @@
8529
8675
  const scope = getScopeFromElement(element);
8530
8676
  const jsonData = evaluateExpression(decodeURIComponent(element.getAttribute(paramsAttr) || ''), scope, false);
8531
8677
  // The default changeState is false, as this is commonly used for: load more, infinite scroll, etc.
8532
- navigate({
8678
+ navigateRequest({
8533
8679
  url: parsedUrl.toString(), method, trigger: element, jsonData, changeState: false
8534
8680
  });
8535
8681
  }
@@ -8578,7 +8724,7 @@
8578
8724
  return;
8579
8725
  event.preventDefault();
8580
8726
  // The default changeState is true, as this is commonly used for: navigation, etc.
8581
- navigate({ url: url.toString(), method: 'GET', trigger: link, changeState: true });
8727
+ navigateRequest({ url: url.toString(), method: 'GET', trigger: link, changeState: true });
8582
8728
  }
8583
8729
  function onMouseOverCapture(event) {
8584
8730
  const target = event.target;
@@ -8634,7 +8780,7 @@
8634
8780
  return;
8635
8781
  const formData = new FormData(form, submitter);
8636
8782
  submittingForms.add(form);
8637
- void navigate({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
8783
+ void navigateRequest({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
8638
8784
  }
8639
8785
  function onPopState(event) {
8640
8786
  const url = window.location.href;
@@ -8652,14 +8798,14 @@
8652
8798
  }
8653
8799
  event.preventDefault();
8654
8800
  // The browser changes location before popstate fires. Stop any pending page
8655
- // script immediately, then let navigate() wait for its DOM finalizer.
8801
+ // script immediately, then let navigateRequest() wait for its DOM finalizer.
8656
8802
  if (activeNavigation?.committing)
8657
8803
  cancelNavigation(activeNavigation);
8658
8804
  // The browser has already moved to the destination history entry. Keep the
8659
8805
  // router's entry pointer aligned before any restored page script can navigate.
8660
8806
  currentHistoryEntryId = destinationEntryId;
8661
8807
  // No snapshot, do a normal navigation without changing history (changeState: false)
8662
- navigate({
8808
+ navigateRequest({
8663
8809
  url,
8664
8810
  method: 'GET',
8665
8811
  replace: true,
@@ -8741,10 +8887,12 @@
8741
8887
  onAfterNavigate,
8742
8888
  onBeforeSwap,
8743
8889
  onNavigationEnd,
8890
+ navigate,
8891
+ refresh,
8744
8892
  portalCreate,
8745
8893
  portalDestroy,
8746
8894
  setCspNonce,
8747
- version: '0.4.0'
8895
+ version: '0.5.0'
8748
8896
  };
8749
8897
 
8750
8898
  setExpressionRuntime(standardExpressionRuntime);
@@ -8775,6 +8923,7 @@
8775
8923
  exports.mountAll = mountAll;
8776
8924
  exports.mountTree = mountTree;
8777
8925
  exports.mountedScopes = getAllMountedScopes;
8926
+ exports.navigate = navigate;
8778
8927
  exports.nextTick = nextTick;
8779
8928
  exports.off = off;
8780
8929
  exports.on = on;
@@ -8788,6 +8937,7 @@
8788
8937
  exports.portalDestroy = portalDestroy;
8789
8938
  exports.provide = provide;
8790
8939
  exports.ready = ready;
8940
+ exports.refresh = refresh;
8791
8941
  exports.registerTransition = registerTransition;
8792
8942
  exports.removeStore = removeStore;
8793
8943
  exports.scope = scope;