@reckona/mreact-router 0.0.176 → 0.0.177

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reckona/mreact-router",
3
- "version": "0.0.176",
3
+ "version": "0.0.177",
4
4
  "description": "File-system app router, SSR, actions, and deployment adapters for mreact.",
5
5
  "keywords": [
6
6
  "jsx",
@@ -105,20 +105,20 @@
105
105
  },
106
106
  "dependencies": {
107
107
  "typescript": "^6.0.3",
108
- "@reckona/mreact": "0.0.176",
109
- "@reckona/mreact-compat": "0.0.176",
110
- "@reckona/mreact-query": "0.0.176",
111
- "@reckona/mreact-reactive-core": "0.0.176",
112
- "@reckona/mreact-devtools": "0.0.176",
113
- "@reckona/mreact-compiler": "0.0.176",
114
- "@reckona/mreact-reactive-dom": "0.0.176",
115
- "@reckona/mreact-server": "0.0.176",
116
- "@reckona/mreact-shared": "0.0.176"
108
+ "@reckona/mreact": "0.0.177",
109
+ "@reckona/mreact-compat": "0.0.177",
110
+ "@reckona/mreact-devtools": "0.0.177",
111
+ "@reckona/mreact-reactive-core": "0.0.177",
112
+ "@reckona/mreact-compiler": "0.0.177",
113
+ "@reckona/mreact-query": "0.0.177",
114
+ "@reckona/mreact-server": "0.0.177",
115
+ "@reckona/mreact-shared": "0.0.177",
116
+ "@reckona/mreact-reactive-dom": "0.0.177"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "vite": ">=8 <9"
120
120
  },
121
121
  "optionalDependencies": {
122
- "@reckona/mreact-router-native": "0.0.176"
122
+ "@reckona/mreact-router-native": "0.0.177"
123
123
  }
124
124
  }
package/src/client.ts CHANGED
@@ -2270,6 +2270,7 @@ export async function buildClientRouteEntrySource(
2270
2270
  },
2271
2271
  fetchRevalidationInstalled: false,
2272
2272
  installed: false,
2273
+ pendingHtmlFetches: new Map(),
2273
2274
  prefetchedUrls: new Set(),
2274
2275
  prefetchedScripts: new Set(),
2275
2276
  reloadNextNavigationFetch: false,
@@ -2673,14 +2674,9 @@ function __mreactPrefetchNavigationHtml(href) {
2673
2674
  return true;
2674
2675
  }
2675
2676
 
2676
- return __mreactFetchNavigationHtml(href).then((html) => {
2677
- if (typeof html !== "string") {
2678
- return false;
2679
- }
2680
-
2681
- __mreactRememberNavigationHtml(href, html);
2682
- return true;
2683
- }).catch(() => false);
2677
+ return __mreactFetchNavigationHtmlOnce(href)
2678
+ .then((html) => typeof html === "string")
2679
+ .catch(() => false);
2684
2680
  }
2685
2681
 
2686
2682
  const __mreactNavigationHtmlCacheMaxEntries = 64;
@@ -2788,7 +2784,7 @@ export async function __mreactNavigate(url, options = {}) {
2788
2784
  if (script !== undefined) {
2789
2785
  void __mreactPrefetchRouteScript(script);
2790
2786
  }
2791
- const html = cachedHtml ?? await __mreactFetchNavigationHtml(href);
2787
+ const html = cachedHtml ?? await __mreactFetchNavigationHtmlOnce(href);
2792
2788
 
2793
2789
  if (typeof html !== "string") {
2794
2790
  return false;
@@ -2937,10 +2933,16 @@ export function __mreactInvalidateNavigationCache(path) {
2937
2933
  return;
2938
2934
  }
2939
2935
 
2940
- for (const href of Array.from(__mreactNavigationState.cache.keys())) {
2936
+ const hrefs = new Set([
2937
+ ...Array.from(__mreactNavigationState.cache.keys()),
2938
+ ...Array.from(__mreactNavigationState.pendingHtmlFetches.keys()),
2939
+ ]);
2940
+
2941
+ for (const href of hrefs) {
2941
2942
  if (__mreactNormalizeNavigationPath(href) === normalizedPath) {
2942
2943
  __mreactNavigationState.cache.delete(href);
2943
2944
  __mreactNavigationState.prefetchedUrls.delete(href);
2945
+ __mreactNavigationState.pendingHtmlFetches.delete(href);
2944
2946
  }
2945
2947
  }
2946
2948
  }
@@ -2948,6 +2950,35 @@ export function __mreactInvalidateNavigationCache(path) {
2948
2950
  function __mreactInvalidateAllNavigationCache() {
2949
2951
  __mreactNavigationState.cache.clear();
2950
2952
  __mreactNavigationState.prefetchedUrls.clear();
2953
+ __mreactNavigationState.pendingHtmlFetches.clear();
2954
+ }
2955
+
2956
+ function __mreactFetchNavigationHtmlOnce(href) {
2957
+ const pending = __mreactNavigationState.pendingHtmlFetches.get(href);
2958
+
2959
+ if (pending !== undefined) {
2960
+ return pending;
2961
+ }
2962
+
2963
+ const request = __mreactFetchNavigationHtml(href)
2964
+ .then((html) => {
2965
+ if (
2966
+ typeof html === "string" &&
2967
+ __mreactNavigationState.pendingHtmlFetches.get(href) === request
2968
+ ) {
2969
+ __mreactRememberNavigationHtml(href, html);
2970
+ }
2971
+
2972
+ return html;
2973
+ })
2974
+ .finally(() => {
2975
+ if (__mreactNavigationState.pendingHtmlFetches.get(href) === request) {
2976
+ __mreactNavigationState.pendingHtmlFetches.delete(href);
2977
+ }
2978
+ });
2979
+
2980
+ __mreactNavigationState.pendingHtmlFetches.set(href, request);
2981
+ return request;
2951
2982
  }
2952
2983
 
2953
2984
  function __mreactFetchNavigationHtml(href) {
@@ -3523,6 +3554,13 @@ function __mreactInstallNavigation() {
3523
3554
  location.reload();
3524
3555
  }
3525
3556
  });
3557
+ document.addEventListener("pointerover", (event) => {
3558
+ const anchor = __mreactAnchorFromEvent(event);
3559
+
3560
+ if (anchor !== null && __mreactAnchorPrefetchMode(anchor) === "intent") {
3561
+ void __mreactPrefetch(anchor.href);
3562
+ }
3563
+ }, true);
3526
3564
  document.addEventListener("pointerenter", (event) => {
3527
3565
  const anchor = __mreactAnchorFromEvent(event);
3528
3566