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.auto.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
  */
@@ -189,10 +189,35 @@
189
189
  * count.value++; // Triggers effect
190
190
  * ```
191
191
  */
192
- /**
193
- * Current effect being tracked
194
- */
195
192
  let currentEffect = null;
193
+ function track(source) {
194
+ if (!currentEffect)
195
+ return;
196
+ source.subscribers.add(currentEffect);
197
+ currentEffect.__dependencies?.add(source.subscribers);
198
+ currentEffect.__versions?.set(source, source.version);
199
+ }
200
+ function dependenciesChanged(versions) {
201
+ return untrack(() => {
202
+ for (const [source, version] of versions) {
203
+ source.refresh?.();
204
+ if (source.version !== version)
205
+ return true;
206
+ }
207
+ return false;
208
+ });
209
+ }
210
+ // Invalidate derived caches synchronously; only user effects are deferred.
211
+ function notifySubscribers(subscribers) {
212
+ for (const sub of Array.from(subscribers)) {
213
+ if (sub.__invalidate)
214
+ sub();
215
+ else if (isBatching)
216
+ batchedEffects.add(sub);
217
+ else
218
+ queueEffect(sub);
219
+ }
220
+ }
196
221
  // Simple counter for debug-friendly IDs
197
222
  let signalIdCounter = 0;
198
223
  const WARN_SUBSCRIBERS = () => typeof window !== 'undefined' && window.GYOS_DEBUG_WARN_SUBSCRIBERS;
@@ -230,6 +255,9 @@
230
255
  }
231
256
  });
232
257
  isFlushingQueue = false;
258
+ // A plain subscribe callback can enqueue more work without entering effect().
259
+ if (effectQueue.size > 0)
260
+ queueMicrotask(flushEffectQueue);
233
261
  }
234
262
  /**
235
263
  * Queue an effect for execution in next microtask
@@ -288,17 +316,14 @@
288
316
  const debugId = ++signalIdCounter;
289
317
  let value = initialValue;
290
318
  const subscribers = new Set();
319
+ const source = { subscribers, version: 0 };
291
320
  let warnedSubscribers = false;
292
321
  const read = () => {
293
322
  // Track dependency
294
323
  if (currentEffect) {
295
- // IMPORTANT: Only add if not already subscribed (prevent duplicates)
296
- if (!subscribers.has(currentEffect)) {
297
- subscribers.add(currentEffect);
298
- // Store the subscribers Set in the effect's dependencies for cleanup
299
- if (currentEffect.__dependencies) {
300
- currentEffect.__dependencies.add(subscribers);
301
- }
324
+ const wasSubscribed = subscribers.has(currentEffect);
325
+ track(source);
326
+ if (!wasSubscribed) {
302
327
  if (DEBUG_VERBOSE()) {
303
328
  console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Added subscriber, total:', subscribers.size);
304
329
  }
@@ -317,18 +342,13 @@
317
342
  // For objects/arrays, check if it's actually the same reference
318
343
  // Deep equality is expensive, let user handle it
319
344
  value = newValue;
345
+ source.version++;
320
346
  DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Value changed to:', newValue);
321
347
  notify();
322
348
  };
323
349
  const notify = () => {
324
350
  DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Notifying', subscribers.size, 'subscribers');
325
- if (isBatching) {
326
- subscribers.forEach(sub => batchedEffects.add(sub));
327
- }
328
- else {
329
- // Always queue effects to prevent cascading updates
330
- subscribers.forEach(sub => queueEffect(sub));
331
- }
351
+ notifySubscribers(subscribers);
332
352
  };
333
353
  // Create callable signal (like Angular/SolidJS)
334
354
  // Call without args = read, call with arg = write
@@ -363,8 +383,16 @@
363
383
  },
364
384
  subscribe: {
365
385
  value: function (fn) {
366
- subscribers.add(fn);
367
- return () => subscribers.delete(fn);
386
+ let active = true;
387
+ const callback = () => { if (active)
388
+ untrack(fn); };
389
+ subscribers.add(callback);
390
+ return () => {
391
+ active = false;
392
+ subscribers.delete(callback);
393
+ effectQueue.delete(callback);
394
+ batchedEffects.delete(callback);
395
+ };
368
396
  },
369
397
  enumerable: true,
370
398
  configurable: true
@@ -424,49 +452,60 @@
424
452
  let value;
425
453
  let isDirty = true;
426
454
  let isFirstRun = true;
455
+ let computing = false;
427
456
  const subscribers = new Set();
428
- let cleanup;
457
+ const dependencies = new Set();
458
+ const versions = new Map();
459
+ const source = { subscribers, version: 0, refresh: () => compute() };
460
+ const invalidate = () => {
461
+ // A later batched write must also move already queued consumers into
462
+ // the batch, even when an earlier ordinary write dirtied this cache.
463
+ if (isDirty && !isBatching)
464
+ return;
465
+ isDirty = true;
466
+ notifySubscribers(subscribers);
467
+ };
468
+ invalidate.__invalidate = true;
469
+ invalidate.__dependencies = dependencies;
470
+ invalidate.__versions = versions;
429
471
  const compute = () => {
430
472
  if (!isDirty && !isFirstRun)
431
473
  return;
432
- // Cleanup previous dependencies
433
- if (cleanup)
434
- cleanup();
435
- // Track dependencies in an effect
436
- cleanup = effect(() => {
437
- try {
438
- const newValue = fn();
439
- // Only update if changed
440
- if (isFirstRun || value !== newValue) {
441
- value = newValue;
442
- isFirstRun = false;
443
- isDirty = false;
444
- // Notify subscribers
445
- if (!isBatching) {
446
- subscribers.forEach(sub => queueEffect(sub));
447
- }
448
- else {
449
- subscribers.forEach(sub => batchedEffects.add(sub));
450
- }
451
- }
474
+ if (computing)
475
+ throw new Error('[Computed] Circular dependency');
476
+ computing = true;
477
+ const previousEffect = currentEffect;
478
+ try {
479
+ // A dirty upstream computed may still resolve to its previous value.
480
+ if (!isFirstRun && !dependenciesChanged(versions)) {
481
+ isDirty = false;
482
+ return;
452
483
  }
453
- catch (error) {
454
- console.error('[Computed] Error in computation:', error);
455
- throw error;
484
+ dependencies.forEach(dependency => dependency.delete(invalidate));
485
+ dependencies.clear();
486
+ versions.clear();
487
+ currentEffect = invalidate;
488
+ const nextValue = fn();
489
+ if (isFirstRun || !Object.is(value, nextValue)) {
490
+ value = nextValue;
491
+ source.version++;
456
492
  }
457
- });
458
- isDirty = false;
493
+ isFirstRun = false;
494
+ isDirty = false;
495
+ }
496
+ catch (error) {
497
+ // Preserve error isolation and the last successful value.
498
+ console.error('[Computed] Error in computation:', error);
499
+ isDirty = false;
500
+ }
501
+ finally {
502
+ currentEffect = previousEffect;
503
+ computing = false;
504
+ }
459
505
  };
460
506
  const read = () => {
461
- if (isDirty || isFirstRun)
462
- compute();
463
- // Track dependency
464
- if (currentEffect && !subscribers.has(currentEffect)) {
465
- subscribers.add(currentEffect);
466
- if (currentEffect.__dependencies) {
467
- currentEffect.__dependencies.add(subscribers);
468
- }
469
- }
507
+ compute();
508
+ track(source);
470
509
  return value;
471
510
  };
472
511
  // Create callable computed (read-only)
@@ -491,8 +530,14 @@
491
530
  },
492
531
  subscribe: {
493
532
  value: function (fn) {
494
- subscribers.add(fn);
495
- return () => subscribers.delete(fn);
533
+ // Establish dependencies even if subscribe() is the first access.
534
+ let first = true;
535
+ return effect(() => {
536
+ read();
537
+ if (!first)
538
+ untrack(fn);
539
+ first = false;
540
+ });
496
541
  },
497
542
  enumerable: true,
498
543
  configurable: true
@@ -543,11 +588,15 @@
543
588
  */
544
589
  function effect(fn) {
545
590
  let cleanup;
546
- let dependencies = new Set();
591
+ const dependencies = new Set();
592
+ const versions = new Map();
547
593
  let active = true;
594
+ let initialized = false;
548
595
  const execute = () => {
549
596
  if (!active)
550
597
  return;
598
+ if (initialized && !dependenciesChanged(versions))
599
+ return;
551
600
  // Prevent recursive execution - if already running, skip
552
601
  if (runningEffects.has(execute)) {
553
602
  DEBUG() && console.warn('[Effect] Skipped recursive execution');
@@ -562,10 +611,13 @@
562
611
  });
563
612
  DEBUG() && console.log('[Effect] Cleaned up dependencies, count:', dependencies.size);
564
613
  dependencies.clear();
614
+ versions.clear();
565
615
  // Clean up previous run
566
616
  if (cleanup) {
617
+ const previousCleanup = cleanup;
618
+ cleanup = undefined;
567
619
  try {
568
- cleanup();
620
+ untrack(previousCleanup);
569
621
  }
570
622
  catch (error) {
571
623
  console.error('[Effect] Error in cleanup:', error);
@@ -576,6 +628,7 @@
576
628
  currentEffect = execute;
577
629
  // Store dependencies for cleanup
578
630
  execute.__dependencies = dependencies;
631
+ execute.__versions = versions;
579
632
  try {
580
633
  const nextCleanup = fn();
581
634
  cleanup = typeof nextCleanup === 'function' ? nextCleanup : undefined;
@@ -585,6 +638,7 @@
585
638
  // Don't throw - allow other effects to continue
586
639
  }
587
640
  finally {
641
+ initialized = true;
588
642
  currentEffect = prevEffect;
589
643
  effectDepth--;
590
644
  runningEffects.delete(execute);
@@ -601,14 +655,17 @@
601
655
  if (!active)
602
656
  return;
603
657
  active = false;
658
+ effectQueue.delete(execute);
659
+ batchedEffects.delete(execute);
604
660
  // Remove from all dependencies
605
661
  dependencies.forEach(depSet => {
606
662
  depSet.delete(execute);
607
663
  });
608
664
  dependencies.clear();
665
+ versions.clear();
609
666
  if (cleanup) {
610
667
  try {
611
- cleanup();
668
+ untrack(cleanup);
612
669
  }
613
670
  catch (error) {
614
671
  console.error('[Effect] Error in final cleanup:', error);
@@ -668,6 +725,8 @@
668
725
  const effects = Array.from(batchedEffects);
669
726
  batchedEffects.clear();
670
727
  effects.forEach(effect => {
728
+ // This batch also settles any earlier queued write to this observer.
729
+ effectQueue.delete(effect);
671
730
  try {
672
731
  effect();
673
732
  }
@@ -5577,6 +5636,21 @@
5577
5636
  * Registry of all scopes
5578
5637
  */
5579
5638
  const scopeRegistry = new Map();
5639
+ const warnedReveals = new WeakSet();
5640
+ function diagnoseUnscopedReveals(root) {
5641
+ if (!DEBUG())
5642
+ return;
5643
+ const elements = [...root.querySelectorAll('[g-reveal]')];
5644
+ if (root instanceof Element && root.hasAttribute('g-reveal'))
5645
+ elements.unshift(root);
5646
+ for (const element of elements) {
5647
+ if (warnedReveals.has(element) || isInIgnoredTree(element)
5648
+ || element.closest('[g-scope]') || getScopeFromElement(element))
5649
+ continue;
5650
+ warnedReveals.add(element);
5651
+ console.warn('[Gyos] g-reveal has no owning scope. Add g-scope to its container; global reveal CSS may otherwise hide this content.', element);
5652
+ }
5653
+ }
5580
5654
  /**
5581
5655
  * Register a scope
5582
5656
  */
@@ -5624,6 +5698,7 @@
5624
5698
  allElements.sort((a, b) => getDepth(b) - getDepth(a));
5625
5699
  // Filter out elements inside structural directives - they will be mounted by structural processor
5626
5700
  allElements.forEach(el => !hasStructuralParent(el) && mount(el));
5701
+ diagnoseUnscopedReveals(document.body);
5627
5702
  }
5628
5703
  function mountTree(el) {
5629
5704
  if (isInIgnoredTree(el) || !document.body.contains(el))
@@ -5634,6 +5709,7 @@
5634
5709
  // Child scopes own their subtree before an existing parent scope parses the insertion.
5635
5710
  candidates.sort((a, b) => getDepth(b) - getDepth(a));
5636
5711
  candidates.forEach(element => !hasStructuralParent(element) && mount(element));
5712
+ diagnoseUnscopedReveals(el);
5637
5713
  if (getMountedScope(el))
5638
5714
  return;
5639
5715
  const ownerScope = getScopeFromElement(el);
@@ -5652,7 +5728,7 @@
5652
5728
  return;
5653
5729
  // Check if element removed but still has g-scope (possible in some edge cases)
5654
5730
  getAllMountedScopes().forEach((_, mountedEl) => {
5655
- if (!document.body.contains(mountedEl)) {
5731
+ if (!mountedEl.isConnected) {
5656
5732
  disposeEffects(mountedEl);
5657
5733
  }
5658
5734
  });
@@ -6964,7 +7040,8 @@
6964
7040
  el.dataset.gyosPersistId = key;
6965
7041
  return key;
6966
7042
  }
6967
- // Hidden parking lot keeps persisted nodes alive (e.g. audio keeps playing)
7043
+ // Keep the parking host outside body: body itself may be the swap target.
7044
+ // A disconnected parking host makes browsers pause otherwise persisted media.
6968
7045
  const persistParking = typeof document !== 'undefined'
6969
7046
  ? (() => {
6970
7047
  const park = document.createElement('div');
@@ -6973,12 +7050,7 @@
6973
7050
  park.style.top = '-99999px';
6974
7051
  park.style.width = '0';
6975
7052
  park.style.height = '0';
6976
- if (document.readyState === 'loading') {
6977
- document.addEventListener('DOMContentLoaded', () => document.body.appendChild(park));
6978
- }
6979
- else {
6980
- document.body.appendChild(park);
6981
- }
7053
+ document.documentElement.appendChild(park);
6982
7054
  return park;
6983
7055
  })()
6984
7056
  : null;
@@ -6989,8 +7061,8 @@
6989
7061
  return elements;
6990
7062
  }
6991
7063
  function ensureParkingIsConnected() {
6992
- if (persistParking && document.body && !persistParking.isConnected) {
6993
- document.body.appendChild(persistParking);
7064
+ if (persistParking && persistParking.parentElement !== document.documentElement) {
7065
+ document.documentElement.appendChild(persistParking);
6994
7066
  }
6995
7067
  }
6996
7068
  function detachPersist(root = document) {
@@ -7008,12 +7080,18 @@
7008
7080
  });
7009
7081
  }
7010
7082
  function mergePersistIntoLive(root) {
7083
+ // Return the host to the current body before scope mounting/cleanup inspects it.
7084
+ if (persistParking && persistParking.parentElement !== document.body) {
7085
+ document.body.appendChild(persistParking);
7086
+ }
7011
7087
  if (!persistEntries.size)
7012
7088
  return;
7013
7089
  // If placeholders lack ids but we only have one persist entry, assign its key for convenience
7014
7090
  if (persistEntries.size === 1) {
7015
7091
  const loneKey = Array.from(persistEntries.keys())[0];
7016
7092
  elementsIn(root).forEach(el => {
7093
+ if (persistParking?.contains(el))
7094
+ return;
7017
7095
  if (!getPersistKey(el, false)) {
7018
7096
  el.dataset.gyosPersistId = loneKey;
7019
7097
  }
@@ -7021,6 +7099,8 @@
7021
7099
  }
7022
7100
  // Element placeholders
7023
7101
  elementsIn(root).forEach(placeholder => {
7102
+ if (persistParking?.contains(placeholder))
7103
+ return;
7024
7104
  const key = getPersistKey(placeholder, false);
7025
7105
  if (!key)
7026
7106
  return;
@@ -7038,6 +7118,8 @@
7038
7118
  const toReplace = [];
7039
7119
  while (walker.nextNode()) {
7040
7120
  const comment = walker.currentNode;
7121
+ if (persistParking?.contains(comment))
7122
+ continue;
7041
7123
  const match = comment.data.match(/g-persist[:=]\s*([A-Za-z0-9_\-:.]+)/);
7042
7124
  if (match) {
7043
7125
  toReplace.push({ node: comment, key: match[1] });
@@ -7695,6 +7777,36 @@
7695
7777
  * Implements attribute-driven routing, snapshot caching, and persistent islands.
7696
7778
  */
7697
7779
  const submittingForms = new WeakSet();
7780
+ async function visit(url, options, fresh) {
7781
+ const destination = new URL(url, document.baseURI);
7782
+ if (!['http:', 'https:'].includes(destination.protocol) || destination.origin !== location.origin || destination.username || destination.password) {
7783
+ throw new TypeError('Gyos.navigate requires a same-origin HTTP(S) URL without credentials.');
7784
+ }
7785
+ if (options.target !== undefined && !(document.querySelector(options.target) instanceof HTMLElement)) {
7786
+ throw new TypeError('Gyos.navigate target does not exist.');
7787
+ }
7788
+ if (!document.querySelector('[g-boost]')) {
7789
+ throw new TypeError('Gyos.navigate requires a g-boost layout.');
7790
+ }
7791
+ startRouter();
7792
+ let result;
7793
+ await navigateRequest({
7794
+ url: destination.href, method: 'GET',
7795
+ changeState: options.history !== 'none', replace: options.history === 'replace',
7796
+ targetSelector: options.target, strictTarget: options.target !== undefined, swapMode: options.swap,
7797
+ currentHead: options.currentHead, scroll: options.scroll, signal: options.signal, fresh,
7798
+ onEnd: context => { result = context; }
7799
+ });
7800
+ return result;
7801
+ }
7802
+ /** Navigate through the boost pipeline. Resolves after navigation-end hooks. */
7803
+ function navigate(url, options = {}) {
7804
+ return visit(url, options, false);
7805
+ }
7806
+ /** Fetch the current URL again, preserving history and scroll by default. */
7807
+ function refresh(options = {}) {
7808
+ return visit(location.href, { history: 'none', scroll: false, ...options }, true);
7809
+ }
7698
7810
  const snapshots = new Map();
7699
7811
  const preloadCache = new Map();
7700
7812
  const preloadControllers = new Map();
@@ -8081,12 +8193,27 @@
8081
8193
  }
8082
8194
  console.error(`[GyosRouter] ${method} navigation could not be boosted; the request will not be replayed.`);
8083
8195
  }
8084
- async function navigate(opts) {
8196
+ async function navigateRequest(opts) {
8197
+ const finishUnstarted = () => {
8198
+ opts.onEnd?.({ from: currentUrl, url: opts.url, method: opts.method,
8199
+ trigger: opts.trigger || null, target: null, form: null, popstate: false,
8200
+ signal: opts.signal, status: null, committed: false, fallback: false, outcome: 'aborted' });
8201
+ };
8202
+ if (opts.signal?.aborted) {
8203
+ finishUnstarted();
8204
+ return;
8205
+ }
8085
8206
  while (activeNavigation) {
8086
8207
  const previous = activeNavigation;
8087
8208
  if (previous.committing) {
8088
8209
  log('[GyosRouter] Waiting for previous DOM commit');
8089
- await previous.done;
8210
+ try {
8211
+ await (opts.signal ? waitForNavigation(previous.done, opts.signal) : previous.done);
8212
+ }
8213
+ catch {
8214
+ finishUnstarted();
8215
+ return;
8216
+ }
8090
8217
  continue;
8091
8218
  }
8092
8219
  log('[GyosRouter] Cancelling previous navigation');
@@ -8105,6 +8232,10 @@
8105
8232
  resolveDone
8106
8233
  };
8107
8234
  activeNavigation = transaction;
8235
+ const abort = () => cancelNavigation(transaction);
8236
+ opts.signal?.addEventListener('abort', abort, { once: true });
8237
+ if (opts.signal?.aborted)
8238
+ abort();
8108
8239
  const currentBaseUrl = document.baseURI;
8109
8240
  rememberResourceUrls(document, currentBaseUrl);
8110
8241
  const context = {
@@ -8128,6 +8259,7 @@
8128
8259
  }
8129
8260
  };
8130
8261
  try {
8262
+ assertActiveNavigation(transaction);
8131
8263
  if (formEvent)
8132
8264
  document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
8133
8265
  runNavigationHooks(beforeNavigate, opts.url, context);
@@ -8140,6 +8272,10 @@
8140
8272
  saveScrollPosition();
8141
8273
  // Pick target element to swap
8142
8274
  let target = resolveTarget(opts.trigger, opts.targetSelector, opts.targetOutletIndex);
8275
+ if (opts.strictTarget && (!opts.targetSelector || !target?.matches(opts.targetSelector))) {
8276
+ context.outcome = 'invalid-response';
8277
+ return; // A queued explicit target disappeared; never broaden the swap.
8278
+ }
8143
8279
  context.target = target;
8144
8280
  if (!target) {
8145
8281
  if (isActiveNavigation(transaction))
@@ -8184,7 +8320,12 @@
8184
8320
  else {
8185
8321
  // Check preload cache if GET
8186
8322
  const preloadKey = canonicalUrl(finalUrl, true);
8187
- if (opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
8323
+ if (opts.fresh) {
8324
+ preloadControllers.get(preloadKey)?.abort();
8325
+ preloadControllers.delete(preloadKey);
8326
+ preloadCache.delete(preloadKey);
8327
+ }
8328
+ if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
8188
8329
  log('[GyosRouter] using preload cache for', finalUrl);
8189
8330
  try {
8190
8331
  response = await waitForNavigation(preloadCache.get(preloadKey), transaction.controller.signal);
@@ -8392,7 +8533,10 @@
8392
8533
  finalizeCommit();
8393
8534
  }
8394
8535
  // Handle scroll after mount scopes
8395
- if (changesState) {
8536
+ if (opts.scroll === false) {
8537
+ // Explicit refresh/navigation policy keeps the current viewport.
8538
+ }
8539
+ else if (changesState) {
8396
8540
  handleScroll(targetUrl, opts.trigger);
8397
8541
  }
8398
8542
  else if (opts.popstate) {
@@ -8457,6 +8601,7 @@
8457
8601
  activeNavigation = null;
8458
8602
  progressBar?.complete();
8459
8603
  }
8604
+ opts.signal?.removeEventListener('abort', abort);
8460
8605
  transaction.resolveDone();
8461
8606
  if (formEvent)
8462
8607
  submittingForms.delete(formEvent.form);
@@ -8467,6 +8612,7 @@
8467
8612
  detail: { ...formEvent, url, status, outcome, committed, fallback }
8468
8613
  }));
8469
8614
  }
8615
+ opts.onEnd?.({ ...context });
8470
8616
  }
8471
8617
  }
8472
8618
  function shouldBoost(el) {
@@ -8497,7 +8643,7 @@
8497
8643
  const scope = getScopeFromElement(element);
8498
8644
  const jsonData = evaluateExpression(decodeURIComponent(element.getAttribute(paramsAttr) || ''), scope, false);
8499
8645
  // The default changeState is false, as this is commonly used for: load more, infinite scroll, etc.
8500
- navigate({
8646
+ navigateRequest({
8501
8647
  url: parsedUrl.toString(), method, trigger: element, jsonData, changeState: false
8502
8648
  });
8503
8649
  }
@@ -8546,7 +8692,7 @@
8546
8692
  return;
8547
8693
  event.preventDefault();
8548
8694
  // The default changeState is true, as this is commonly used for: navigation, etc.
8549
- navigate({ url: url.toString(), method: 'GET', trigger: link, changeState: true });
8695
+ navigateRequest({ url: url.toString(), method: 'GET', trigger: link, changeState: true });
8550
8696
  }
8551
8697
  function onMouseOverCapture(event) {
8552
8698
  const target = event.target;
@@ -8602,7 +8748,7 @@
8602
8748
  return;
8603
8749
  const formData = new FormData(form, submitter);
8604
8750
  submittingForms.add(form);
8605
- void navigate({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
8751
+ void navigateRequest({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
8606
8752
  }
8607
8753
  function onPopState(event) {
8608
8754
  const url = window.location.href;
@@ -8620,14 +8766,14 @@
8620
8766
  }
8621
8767
  event.preventDefault();
8622
8768
  // The browser changes location before popstate fires. Stop any pending page
8623
- // script immediately, then let navigate() wait for its DOM finalizer.
8769
+ // script immediately, then let navigateRequest() wait for its DOM finalizer.
8624
8770
  if (activeNavigation?.committing)
8625
8771
  cancelNavigation(activeNavigation);
8626
8772
  // The browser has already moved to the destination history entry. Keep the
8627
8773
  // router's entry pointer aligned before any restored page script can navigate.
8628
8774
  currentHistoryEntryId = destinationEntryId;
8629
8775
  // No snapshot, do a normal navigation without changing history (changeState: false)
8630
- navigate({
8776
+ navigateRequest({
8631
8777
  url,
8632
8778
  method: 'GET',
8633
8779
  replace: true,
@@ -8709,10 +8855,12 @@
8709
8855
  onAfterNavigate,
8710
8856
  onBeforeSwap,
8711
8857
  onNavigationEnd,
8858
+ navigate,
8859
+ refresh,
8712
8860
  portalCreate,
8713
8861
  portalDestroy,
8714
8862
  setCspNonce,
8715
- version: '0.4.0'
8863
+ version: '0.5.0'
8716
8864
  };
8717
8865
 
8718
8866
  const standardExpressionRuntime = {