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
  */
@@ -6846,10 +6846,35 @@ function hasStructuralParent(el) {
6846
6846
  * count.value++; // Triggers effect
6847
6847
  * ```
6848
6848
  */
6849
- /**
6850
- * Current effect being tracked
6851
- */
6852
6849
  let currentEffect = null;
6850
+ function track(source) {
6851
+ if (!currentEffect)
6852
+ return;
6853
+ source.subscribers.add(currentEffect);
6854
+ currentEffect.__dependencies?.add(source.subscribers);
6855
+ currentEffect.__versions?.set(source, source.version);
6856
+ }
6857
+ function dependenciesChanged(versions) {
6858
+ return untrack(() => {
6859
+ for (const [source, version] of versions) {
6860
+ source.refresh?.();
6861
+ if (source.version !== version)
6862
+ return true;
6863
+ }
6864
+ return false;
6865
+ });
6866
+ }
6867
+ // Invalidate derived caches synchronously; only user effects are deferred.
6868
+ function notifySubscribers(subscribers) {
6869
+ for (const sub of Array.from(subscribers)) {
6870
+ if (sub.__invalidate)
6871
+ sub();
6872
+ else if (isBatching)
6873
+ batchedEffects.add(sub);
6874
+ else
6875
+ queueEffect(sub);
6876
+ }
6877
+ }
6853
6878
  // Simple counter for debug-friendly IDs
6854
6879
  let signalIdCounter = 0;
6855
6880
  const WARN_SUBSCRIBERS = () => typeof window !== 'undefined' && window.GYOS_DEBUG_WARN_SUBSCRIBERS;
@@ -6887,6 +6912,9 @@ function flushEffectQueue() {
6887
6912
  }
6888
6913
  });
6889
6914
  isFlushingQueue = false;
6915
+ // A plain subscribe callback can enqueue more work without entering effect().
6916
+ if (effectQueue.size > 0)
6917
+ queueMicrotask(flushEffectQueue);
6890
6918
  }
6891
6919
  /**
6892
6920
  * Queue an effect for execution in next microtask
@@ -6945,17 +6973,14 @@ function signal(initialValue, debugOrOptions) {
6945
6973
  const debugId = ++signalIdCounter;
6946
6974
  let value = initialValue;
6947
6975
  const subscribers = new Set();
6976
+ const source = { subscribers, version: 0 };
6948
6977
  let warnedSubscribers = false;
6949
6978
  const read = () => {
6950
6979
  // Track dependency
6951
6980
  if (currentEffect) {
6952
- // IMPORTANT: Only add if not already subscribed (prevent duplicates)
6953
- if (!subscribers.has(currentEffect)) {
6954
- subscribers.add(currentEffect);
6955
- // Store the subscribers Set in the effect's dependencies for cleanup
6956
- if (currentEffect.__dependencies) {
6957
- currentEffect.__dependencies.add(subscribers);
6958
- }
6981
+ const wasSubscribed = subscribers.has(currentEffect);
6982
+ track(source);
6983
+ if (!wasSubscribed) {
6959
6984
  if (DEBUG_VERBOSE()) {
6960
6985
  console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Added subscriber, total:', subscribers.size);
6961
6986
  }
@@ -6974,18 +6999,13 @@ function signal(initialValue, debugOrOptions) {
6974
6999
  // For objects/arrays, check if it's actually the same reference
6975
7000
  // Deep equality is expensive, let user handle it
6976
7001
  value = newValue;
7002
+ source.version++;
6977
7003
  DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Value changed to:', newValue);
6978
7004
  notify();
6979
7005
  };
6980
7006
  const notify = () => {
6981
7007
  DEBUG_VERBOSE() && console.log('[Signal]', formatDebugLabel(debugId, debugLabel), 'Notifying', subscribers.size, 'subscribers');
6982
- if (isBatching) {
6983
- subscribers.forEach(sub => batchedEffects.add(sub));
6984
- }
6985
- else {
6986
- // Always queue effects to prevent cascading updates
6987
- subscribers.forEach(sub => queueEffect(sub));
6988
- }
7008
+ notifySubscribers(subscribers);
6989
7009
  };
6990
7010
  // Create callable signal (like Angular/SolidJS)
6991
7011
  // Call without args = read, call with arg = write
@@ -7020,8 +7040,16 @@ function signal(initialValue, debugOrOptions) {
7020
7040
  },
7021
7041
  subscribe: {
7022
7042
  value: function (fn) {
7023
- subscribers.add(fn);
7024
- return () => subscribers.delete(fn);
7043
+ let active = true;
7044
+ const callback = () => { if (active)
7045
+ untrack(fn); };
7046
+ subscribers.add(callback);
7047
+ return () => {
7048
+ active = false;
7049
+ subscribers.delete(callback);
7050
+ effectQueue.delete(callback);
7051
+ batchedEffects.delete(callback);
7052
+ };
7025
7053
  },
7026
7054
  enumerable: true,
7027
7055
  configurable: true
@@ -7081,49 +7109,60 @@ function computed(fn) {
7081
7109
  let value;
7082
7110
  let isDirty = true;
7083
7111
  let isFirstRun = true;
7112
+ let computing = false;
7084
7113
  const subscribers = new Set();
7085
- let cleanup;
7114
+ const dependencies = new Set();
7115
+ const versions = new Map();
7116
+ const source = { subscribers, version: 0, refresh: () => compute() };
7117
+ const invalidate = () => {
7118
+ // A later batched write must also move already queued consumers into
7119
+ // the batch, even when an earlier ordinary write dirtied this cache.
7120
+ if (isDirty && !isBatching)
7121
+ return;
7122
+ isDirty = true;
7123
+ notifySubscribers(subscribers);
7124
+ };
7125
+ invalidate.__invalidate = true;
7126
+ invalidate.__dependencies = dependencies;
7127
+ invalidate.__versions = versions;
7086
7128
  const compute = () => {
7087
7129
  if (!isDirty && !isFirstRun)
7088
7130
  return;
7089
- // Cleanup previous dependencies
7090
- if (cleanup)
7091
- cleanup();
7092
- // Track dependencies in an effect
7093
- cleanup = effect(() => {
7094
- try {
7095
- const newValue = fn();
7096
- // Only update if changed
7097
- if (isFirstRun || value !== newValue) {
7098
- value = newValue;
7099
- isFirstRun = false;
7100
- isDirty = false;
7101
- // Notify subscribers
7102
- if (!isBatching) {
7103
- subscribers.forEach(sub => queueEffect(sub));
7104
- }
7105
- else {
7106
- subscribers.forEach(sub => batchedEffects.add(sub));
7107
- }
7108
- }
7131
+ if (computing)
7132
+ throw new Error('[Computed] Circular dependency');
7133
+ computing = true;
7134
+ const previousEffect = currentEffect;
7135
+ try {
7136
+ // A dirty upstream computed may still resolve to its previous value.
7137
+ if (!isFirstRun && !dependenciesChanged(versions)) {
7138
+ isDirty = false;
7139
+ return;
7109
7140
  }
7110
- catch (error) {
7111
- console.error('[Computed] Error in computation:', error);
7112
- throw error;
7141
+ dependencies.forEach(dependency => dependency.delete(invalidate));
7142
+ dependencies.clear();
7143
+ versions.clear();
7144
+ currentEffect = invalidate;
7145
+ const nextValue = fn();
7146
+ if (isFirstRun || !Object.is(value, nextValue)) {
7147
+ value = nextValue;
7148
+ source.version++;
7113
7149
  }
7114
- });
7115
- isDirty = false;
7150
+ isFirstRun = false;
7151
+ isDirty = false;
7152
+ }
7153
+ catch (error) {
7154
+ // Preserve error isolation and the last successful value.
7155
+ console.error('[Computed] Error in computation:', error);
7156
+ isDirty = false;
7157
+ }
7158
+ finally {
7159
+ currentEffect = previousEffect;
7160
+ computing = false;
7161
+ }
7116
7162
  };
7117
7163
  const read = () => {
7118
- if (isDirty || isFirstRun)
7119
- compute();
7120
- // Track dependency
7121
- if (currentEffect && !subscribers.has(currentEffect)) {
7122
- subscribers.add(currentEffect);
7123
- if (currentEffect.__dependencies) {
7124
- currentEffect.__dependencies.add(subscribers);
7125
- }
7126
- }
7164
+ compute();
7165
+ track(source);
7127
7166
  return value;
7128
7167
  };
7129
7168
  // Create callable computed (read-only)
@@ -7148,8 +7187,14 @@ function computed(fn) {
7148
7187
  },
7149
7188
  subscribe: {
7150
7189
  value: function (fn) {
7151
- subscribers.add(fn);
7152
- return () => subscribers.delete(fn);
7190
+ // Establish dependencies even if subscribe() is the first access.
7191
+ let first = true;
7192
+ return effect(() => {
7193
+ read();
7194
+ if (!first)
7195
+ untrack(fn);
7196
+ first = false;
7197
+ });
7153
7198
  },
7154
7199
  enumerable: true,
7155
7200
  configurable: true
@@ -7200,11 +7245,15 @@ function computed(fn) {
7200
7245
  */
7201
7246
  function effect(fn) {
7202
7247
  let cleanup;
7203
- let dependencies = new Set();
7248
+ const dependencies = new Set();
7249
+ const versions = new Map();
7204
7250
  let active = true;
7251
+ let initialized = false;
7205
7252
  const execute = () => {
7206
7253
  if (!active)
7207
7254
  return;
7255
+ if (initialized && !dependenciesChanged(versions))
7256
+ return;
7208
7257
  // Prevent recursive execution - if already running, skip
7209
7258
  if (runningEffects.has(execute)) {
7210
7259
  DEBUG() && console.warn('[Effect] Skipped recursive execution');
@@ -7219,10 +7268,13 @@ function effect(fn) {
7219
7268
  });
7220
7269
  DEBUG() && console.log('[Effect] Cleaned up dependencies, count:', dependencies.size);
7221
7270
  dependencies.clear();
7271
+ versions.clear();
7222
7272
  // Clean up previous run
7223
7273
  if (cleanup) {
7274
+ const previousCleanup = cleanup;
7275
+ cleanup = undefined;
7224
7276
  try {
7225
- cleanup();
7277
+ untrack(previousCleanup);
7226
7278
  }
7227
7279
  catch (error) {
7228
7280
  console.error('[Effect] Error in cleanup:', error);
@@ -7233,6 +7285,7 @@ function effect(fn) {
7233
7285
  currentEffect = execute;
7234
7286
  // Store dependencies for cleanup
7235
7287
  execute.__dependencies = dependencies;
7288
+ execute.__versions = versions;
7236
7289
  try {
7237
7290
  const nextCleanup = fn();
7238
7291
  cleanup = typeof nextCleanup === 'function' ? nextCleanup : undefined;
@@ -7242,6 +7295,7 @@ function effect(fn) {
7242
7295
  // Don't throw - allow other effects to continue
7243
7296
  }
7244
7297
  finally {
7298
+ initialized = true;
7245
7299
  currentEffect = prevEffect;
7246
7300
  effectDepth--;
7247
7301
  runningEffects.delete(execute);
@@ -7258,14 +7312,17 @@ function effect(fn) {
7258
7312
  if (!active)
7259
7313
  return;
7260
7314
  active = false;
7315
+ effectQueue.delete(execute);
7316
+ batchedEffects.delete(execute);
7261
7317
  // Remove from all dependencies
7262
7318
  dependencies.forEach(depSet => {
7263
7319
  depSet.delete(execute);
7264
7320
  });
7265
7321
  dependencies.clear();
7322
+ versions.clear();
7266
7323
  if (cleanup) {
7267
7324
  try {
7268
- cleanup();
7325
+ untrack(cleanup);
7269
7326
  }
7270
7327
  catch (error) {
7271
7328
  console.error('[Effect] Error in final cleanup:', error);
@@ -7325,6 +7382,8 @@ function batch(fn) {
7325
7382
  const effects = Array.from(batchedEffects);
7326
7383
  batchedEffects.clear();
7327
7384
  effects.forEach(effect => {
7385
+ // This batch also settles any earlier queued write to this observer.
7386
+ effectQueue.delete(effect);
7328
7387
  try {
7329
7388
  effect();
7330
7389
  }
@@ -12220,6 +12279,21 @@ setMountFunction(mount);
12220
12279
  * Registry of all scopes
12221
12280
  */
12222
12281
  const scopeRegistry = new Map();
12282
+ const warnedReveals = new WeakSet();
12283
+ function diagnoseUnscopedReveals(root) {
12284
+ if (!DEBUG())
12285
+ return;
12286
+ const elements = [...root.querySelectorAll('[g-reveal]')];
12287
+ if (root instanceof Element && root.hasAttribute('g-reveal'))
12288
+ elements.unshift(root);
12289
+ for (const element of elements) {
12290
+ if (warnedReveals.has(element) || isInIgnoredTree(element)
12291
+ || element.closest('[g-scope]') || getScopeFromElement(element))
12292
+ continue;
12293
+ warnedReveals.add(element);
12294
+ console.warn('[Gyos] g-reveal has no owning scope. Add g-scope to its container; global reveal CSS may otherwise hide this content.', element);
12295
+ }
12296
+ }
12223
12297
  /**
12224
12298
  * Register a scope
12225
12299
  */
@@ -12267,6 +12341,7 @@ function mountAll(root) {
12267
12341
  allElements.sort((a, b) => getDepth(b) - getDepth(a));
12268
12342
  // Filter out elements inside structural directives - they will be mounted by structural processor
12269
12343
  allElements.forEach(el => !hasStructuralParent(el) && mount(el));
12344
+ diagnoseUnscopedReveals(document.body);
12270
12345
  }
12271
12346
  function mountTree(el) {
12272
12347
  if (isInIgnoredTree(el) || !document.body.contains(el))
@@ -12277,6 +12352,7 @@ function mountTree(el) {
12277
12352
  // Child scopes own their subtree before an existing parent scope parses the insertion.
12278
12353
  candidates.sort((a, b) => getDepth(b) - getDepth(a));
12279
12354
  candidates.forEach(element => !hasStructuralParent(element) && mount(element));
12355
+ diagnoseUnscopedReveals(el);
12280
12356
  if (getMountedScope(el))
12281
12357
  return;
12282
12358
  const ownerScope = getScopeFromElement(el);
@@ -12295,7 +12371,7 @@ function mount(el) {
12295
12371
  return;
12296
12372
  // Check if element removed but still has g-scope (possible in some edge cases)
12297
12373
  getAllMountedScopes().forEach((_, mountedEl) => {
12298
- if (!document.body.contains(mountedEl)) {
12374
+ if (!mountedEl.isConnected) {
12299
12375
  disposeEffects(mountedEl);
12300
12376
  }
12301
12377
  });
@@ -13607,7 +13683,8 @@ function getPersistKey(el, generateIfMissing = false) {
13607
13683
  el.dataset.gyosPersistId = key;
13608
13684
  return key;
13609
13685
  }
13610
- // Hidden parking lot keeps persisted nodes alive (e.g. audio keeps playing)
13686
+ // Keep the parking host outside body: body itself may be the swap target.
13687
+ // A disconnected parking host makes browsers pause otherwise persisted media.
13611
13688
  const persistParking = typeof document !== 'undefined'
13612
13689
  ? (() => {
13613
13690
  const park = document.createElement('div');
@@ -13616,12 +13693,7 @@ const persistParking = typeof document !== 'undefined'
13616
13693
  park.style.top = '-99999px';
13617
13694
  park.style.width = '0';
13618
13695
  park.style.height = '0';
13619
- if (document.readyState === 'loading') {
13620
- document.addEventListener('DOMContentLoaded', () => document.body.appendChild(park));
13621
- }
13622
- else {
13623
- document.body.appendChild(park);
13624
- }
13696
+ document.documentElement.appendChild(park);
13625
13697
  return park;
13626
13698
  })()
13627
13699
  : null;
@@ -13632,8 +13704,8 @@ function elementsIn(root) {
13632
13704
  return elements;
13633
13705
  }
13634
13706
  function ensureParkingIsConnected() {
13635
- if (persistParking && document.body && !persistParking.isConnected) {
13636
- document.body.appendChild(persistParking);
13707
+ if (persistParking && persistParking.parentElement !== document.documentElement) {
13708
+ document.documentElement.appendChild(persistParking);
13637
13709
  }
13638
13710
  }
13639
13711
  function detachPersist(root = document) {
@@ -13651,12 +13723,18 @@ function detachPersist(root = document) {
13651
13723
  });
13652
13724
  }
13653
13725
  function mergePersistIntoLive(root) {
13726
+ // Return the host to the current body before scope mounting/cleanup inspects it.
13727
+ if (persistParking && persistParking.parentElement !== document.body) {
13728
+ document.body.appendChild(persistParking);
13729
+ }
13654
13730
  if (!persistEntries.size)
13655
13731
  return;
13656
13732
  // If placeholders lack ids but we only have one persist entry, assign its key for convenience
13657
13733
  if (persistEntries.size === 1) {
13658
13734
  const loneKey = Array.from(persistEntries.keys())[0];
13659
13735
  elementsIn(root).forEach(el => {
13736
+ if (persistParking?.contains(el))
13737
+ return;
13660
13738
  if (!getPersistKey(el, false)) {
13661
13739
  el.dataset.gyosPersistId = loneKey;
13662
13740
  }
@@ -13664,6 +13742,8 @@ function mergePersistIntoLive(root) {
13664
13742
  }
13665
13743
  // Element placeholders
13666
13744
  elementsIn(root).forEach(placeholder => {
13745
+ if (persistParking?.contains(placeholder))
13746
+ return;
13667
13747
  const key = getPersistKey(placeholder, false);
13668
13748
  if (!key)
13669
13749
  return;
@@ -13681,6 +13761,8 @@ function mergePersistIntoLive(root) {
13681
13761
  const toReplace = [];
13682
13762
  while (walker.nextNode()) {
13683
13763
  const comment = walker.currentNode;
13764
+ if (persistParking?.contains(comment))
13765
+ continue;
13684
13766
  const match = comment.data.match(/g-persist[:=]\s*([A-Za-z0-9_\-:.]+)/);
13685
13767
  if (match) {
13686
13768
  toReplace.push({ node: comment, key: match[1] });
@@ -14338,6 +14420,36 @@ function prepareNavigationHtml(html) {
14338
14420
  * Implements attribute-driven routing, snapshot caching, and persistent islands.
14339
14421
  */
14340
14422
  const submittingForms = new WeakSet();
14423
+ async function visit(url, options, fresh) {
14424
+ const destination = new URL(url, document.baseURI);
14425
+ if (!['http:', 'https:'].includes(destination.protocol) || destination.origin !== location.origin || destination.username || destination.password) {
14426
+ throw new TypeError('Gyos.navigate requires a same-origin HTTP(S) URL without credentials.');
14427
+ }
14428
+ if (options.target !== undefined && !(document.querySelector(options.target) instanceof HTMLElement)) {
14429
+ throw new TypeError('Gyos.navigate target does not exist.');
14430
+ }
14431
+ if (!document.querySelector('[g-boost]')) {
14432
+ throw new TypeError('Gyos.navigate requires a g-boost layout.');
14433
+ }
14434
+ startRouter();
14435
+ let result;
14436
+ await navigateRequest({
14437
+ url: destination.href, method: 'GET',
14438
+ changeState: options.history !== 'none', replace: options.history === 'replace',
14439
+ targetSelector: options.target, strictTarget: options.target !== undefined, swapMode: options.swap,
14440
+ currentHead: options.currentHead, scroll: options.scroll, signal: options.signal, fresh,
14441
+ onEnd: context => { result = context; }
14442
+ });
14443
+ return result;
14444
+ }
14445
+ /** Navigate through the boost pipeline. Resolves after navigation-end hooks. */
14446
+ function navigate(url, options = {}) {
14447
+ return visit(url, options, false);
14448
+ }
14449
+ /** Fetch the current URL again, preserving history and scroll by default. */
14450
+ function refresh(options = {}) {
14451
+ return visit(location.href, { history: 'none', scroll: false, ...options }, true);
14452
+ }
14341
14453
  const snapshots = new Map();
14342
14454
  const preloadCache = new Map();
14343
14455
  const preloadControllers = new Map();
@@ -14724,12 +14836,27 @@ function fallbackFromBoost(opts, url, requestSent) {
14724
14836
  }
14725
14837
  console.error(`[GyosRouter] ${method} navigation could not be boosted; the request will not be replayed.`);
14726
14838
  }
14727
- async function navigate(opts) {
14839
+ async function navigateRequest(opts) {
14840
+ const finishUnstarted = () => {
14841
+ opts.onEnd?.({ from: currentUrl, url: opts.url, method: opts.method,
14842
+ trigger: opts.trigger || null, target: null, form: null, popstate: false,
14843
+ signal: opts.signal, status: null, committed: false, fallback: false, outcome: 'aborted' });
14844
+ };
14845
+ if (opts.signal?.aborted) {
14846
+ finishUnstarted();
14847
+ return;
14848
+ }
14728
14849
  while (activeNavigation) {
14729
14850
  const previous = activeNavigation;
14730
14851
  if (previous.committing) {
14731
14852
  log('[GyosRouter] Waiting for previous DOM commit');
14732
- await previous.done;
14853
+ try {
14854
+ await (opts.signal ? waitForNavigation(previous.done, opts.signal) : previous.done);
14855
+ }
14856
+ catch {
14857
+ finishUnstarted();
14858
+ return;
14859
+ }
14733
14860
  continue;
14734
14861
  }
14735
14862
  log('[GyosRouter] Cancelling previous navigation');
@@ -14748,6 +14875,10 @@ async function navigate(opts) {
14748
14875
  resolveDone
14749
14876
  };
14750
14877
  activeNavigation = transaction;
14878
+ const abort = () => cancelNavigation(transaction);
14879
+ opts.signal?.addEventListener('abort', abort, { once: true });
14880
+ if (opts.signal?.aborted)
14881
+ abort();
14751
14882
  const currentBaseUrl = document.baseURI;
14752
14883
  rememberResourceUrls(document, currentBaseUrl);
14753
14884
  const context = {
@@ -14771,6 +14902,7 @@ async function navigate(opts) {
14771
14902
  }
14772
14903
  };
14773
14904
  try {
14905
+ assertActiveNavigation(transaction);
14774
14906
  if (formEvent)
14775
14907
  document.dispatchEvent(new CustomEvent('gyos:form-start', { detail: { ...formEvent } }));
14776
14908
  runNavigationHooks(beforeNavigate, opts.url, context);
@@ -14783,6 +14915,10 @@ async function navigate(opts) {
14783
14915
  saveScrollPosition();
14784
14916
  // Pick target element to swap
14785
14917
  let target = resolveTarget(opts.trigger, opts.targetSelector, opts.targetOutletIndex);
14918
+ if (opts.strictTarget && (!opts.targetSelector || !target?.matches(opts.targetSelector))) {
14919
+ context.outcome = 'invalid-response';
14920
+ return; // A queued explicit target disappeared; never broaden the swap.
14921
+ }
14786
14922
  context.target = target;
14787
14923
  if (!target) {
14788
14924
  if (isActiveNavigation(transaction))
@@ -14827,7 +14963,12 @@ async function navigate(opts) {
14827
14963
  else {
14828
14964
  // Check preload cache if GET
14829
14965
  const preloadKey = canonicalUrl(finalUrl, true);
14830
- if (opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
14966
+ if (opts.fresh) {
14967
+ preloadControllers.get(preloadKey)?.abort();
14968
+ preloadControllers.delete(preloadKey);
14969
+ preloadCache.delete(preloadKey);
14970
+ }
14971
+ if (!opts.fresh && opts.method.toUpperCase() === 'GET' && preloadCache.has(preloadKey)) {
14831
14972
  log('[GyosRouter] using preload cache for', finalUrl);
14832
14973
  try {
14833
14974
  response = await waitForNavigation(preloadCache.get(preloadKey), transaction.controller.signal);
@@ -15035,7 +15176,10 @@ async function navigate(opts) {
15035
15176
  finalizeCommit();
15036
15177
  }
15037
15178
  // Handle scroll after mount scopes
15038
- if (changesState) {
15179
+ if (opts.scroll === false) {
15180
+ // Explicit refresh/navigation policy keeps the current viewport.
15181
+ }
15182
+ else if (changesState) {
15039
15183
  handleScroll(targetUrl, opts.trigger);
15040
15184
  }
15041
15185
  else if (opts.popstate) {
@@ -15100,6 +15244,7 @@ async function navigate(opts) {
15100
15244
  activeNavigation = null;
15101
15245
  progressBar?.complete();
15102
15246
  }
15247
+ opts.signal?.removeEventListener('abort', abort);
15103
15248
  transaction.resolveDone();
15104
15249
  if (formEvent)
15105
15250
  submittingForms.delete(formEvent.form);
@@ -15110,6 +15255,7 @@ async function navigate(opts) {
15110
15255
  detail: { ...formEvent, url, status, outcome, committed, fallback }
15111
15256
  }));
15112
15257
  }
15258
+ opts.onEnd?.({ ...context });
15113
15259
  }
15114
15260
  }
15115
15261
  function shouldBoost(el) {
@@ -15140,7 +15286,7 @@ function onClickRouter(element) {
15140
15286
  const scope = getScopeFromElement(element);
15141
15287
  const jsonData = evaluateExpression(decodeURIComponent(element.getAttribute(paramsAttr) || ''), scope, false);
15142
15288
  // The default changeState is false, as this is commonly used for: load more, infinite scroll, etc.
15143
- navigate({
15289
+ navigateRequest({
15144
15290
  url: parsedUrl.toString(), method, trigger: element, jsonData, changeState: false
15145
15291
  });
15146
15292
  }
@@ -15189,7 +15335,7 @@ function onClick(event) {
15189
15335
  return;
15190
15336
  event.preventDefault();
15191
15337
  // The default changeState is true, as this is commonly used for: navigation, etc.
15192
- navigate({ url: url.toString(), method: 'GET', trigger: link, changeState: true });
15338
+ navigateRequest({ url: url.toString(), method: 'GET', trigger: link, changeState: true });
15193
15339
  }
15194
15340
  function onMouseOverCapture(event) {
15195
15341
  const target = event.target;
@@ -15245,7 +15391,7 @@ function onSubmit(event) {
15245
15391
  return;
15246
15392
  const formData = new FormData(form, submitter);
15247
15393
  submittingForms.add(form);
15248
- void navigate({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
15394
+ void navigateRequest({ url: url.toString(), method, trigger: form, form, formData, formEncoding, changeState: method === 'GET' });
15249
15395
  }
15250
15396
  function onPopState(event) {
15251
15397
  const url = window.location.href;
@@ -15263,14 +15409,14 @@ function onPopState(event) {
15263
15409
  }
15264
15410
  event.preventDefault();
15265
15411
  // The browser changes location before popstate fires. Stop any pending page
15266
- // script immediately, then let navigate() wait for its DOM finalizer.
15412
+ // script immediately, then let navigateRequest() wait for its DOM finalizer.
15267
15413
  if (activeNavigation?.committing)
15268
15414
  cancelNavigation(activeNavigation);
15269
15415
  // The browser has already moved to the destination history entry. Keep the
15270
15416
  // router's entry pointer aligned before any restored page script can navigate.
15271
15417
  currentHistoryEntryId = destinationEntryId;
15272
15418
  // No snapshot, do a normal navigation without changing history (changeState: false)
15273
- navigate({
15419
+ navigateRequest({
15274
15420
  url,
15275
15421
  method: 'GET',
15276
15422
  replace: true,
@@ -15352,13 +15498,15 @@ const Gyos = {
15352
15498
  onAfterNavigate,
15353
15499
  onBeforeSwap,
15354
15500
  onNavigationEnd,
15501
+ navigate,
15502
+ refresh,
15355
15503
  portalCreate,
15356
15504
  portalDestroy,
15357
15505
  setCspNonce,
15358
- version: '0.4.0'
15506
+ version: '0.5.0'
15359
15507
  };
15360
15508
 
15361
15509
  setExpressionRuntime(cspExpressionRuntime);
15362
15510
 
15363
- export { applyDirective, applyTransitionStyles, batch, disposeEffects as cleanup, clearAllEvents, computed, debounce, Gyos as default, directive, effect, emit, getEventListeners, getGlobalContainer, getStoreNames, getTransitionConfig, getValidator, getValidatorNames, hasStore, inject, isComputed, isSignal, markRaw, mount, mountAll, mountTree, getAllMountedScopes as mountedScopes, nextTick, off, on, onAfterNavigate, onBeforeNavigate, onBeforeSwap, onNavigationEnd, once, pipe, portalCreate, portalDestroy, provide, ready, registerTransition, removeStore, scope, setCspNonce, shallow, signal, startRouter, store, throttle, unref, untrack, useAsync, useCounter, useDebounce, useFetch, useInterval, useLocalStorage, useMediaQuery, useMouse, useThrottle, useTimeout, useToggle, useWindowSize, validate, validator };
15511
+ export { applyDirective, applyTransitionStyles, batch, disposeEffects as cleanup, clearAllEvents, computed, debounce, Gyos as default, directive, effect, emit, getEventListeners, getGlobalContainer, getStoreNames, getTransitionConfig, getValidator, getValidatorNames, hasStore, inject, isComputed, isSignal, markRaw, mount, mountAll, mountTree, getAllMountedScopes as mountedScopes, navigate, nextTick, off, on, onAfterNavigate, onBeforeNavigate, onBeforeSwap, onNavigationEnd, once, pipe, portalCreate, portalDestroy, provide, ready, refresh, registerTransition, removeStore, scope, setCspNonce, shallow, signal, startRouter, store, throttle, unref, untrack, useAsync, useCounter, useDebounce, useFetch, useInterval, useLocalStorage, useMediaQuery, useMouse, useThrottle, useTimeout, useToggle, useWindowSize, validate, validator };
15364
15512
  //# sourceMappingURL=gyos.csp.esm.js.map