@rangojs/router 0.36.1 → 0.37.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.
Files changed (69) hide show
  1. package/dist/bin/{chunk-THW7E5A2.js → chunk-A64EG6MI.js} +22 -19
  2. package/dist/bin/{client-urls-projection-DHUUOJZM.js → client-urls-projection-RLDSA3BL.js} +1 -1
  3. package/dist/bin/rango.js +1 -1
  4. package/dist/bin/{runtime-discovery-OPRGB3DF.js → runtime-discovery-T7ZLA6E3.js} +2 -2
  5. package/dist/bin/{temp-rsc-server-FV4ERMAS.js → temp-rsc-server-FGGXPKVQ.js} +2 -2
  6. package/dist/types/browser/event-controller.d.ts +53 -2
  7. package/dist/types/browser/fetched-loader-handles.d.ts +57 -14
  8. package/dist/types/browser/navigation-store.d.ts +3 -2
  9. package/dist/types/browser/react/use-handle.d.ts +18 -5
  10. package/dist/types/browser/react/use-push-handle.d.ts +44 -0
  11. package/dist/types/browser/types.d.ts +44 -0
  12. package/dist/types/client.d.ts +1 -0
  13. package/dist/types/client.rsc.d.ts +1 -0
  14. package/dist/types/handle.d.ts +13 -5
  15. package/dist/types/handles/client-pushes.d.ts +51 -0
  16. package/dist/types/handles/deferred-resolution.d.ts +7 -0
  17. package/dist/types/handles/pushed-by.d.ts +11 -0
  18. package/dist/types/loader-store.d.ts +13 -0
  19. package/dist/types/rsc/prefetch-render-error.d.ts +2 -1
  20. package/dist/types/server/handle-store.d.ts +8 -0
  21. package/dist/types/testing/dom.entry.d.ts +1 -1
  22. package/dist/types/testing/render-route.d.ts +74 -14
  23. package/dist/vite/index.js +23 -20
  24. package/package.json +1 -1
  25. package/skills/breadcrumbs/SKILL.md +68 -6
  26. package/skills/caching/SKILL.md +4 -2
  27. package/skills/catalog.json +3 -3
  28. package/skills/client-urls/SKILL.md +13 -1
  29. package/skills/document-cache/SKILL.md +31 -1
  30. package/skills/hooks/SKILL.md +8 -4
  31. package/skills/hooks/data.md +10 -1
  32. package/skills/hooks/handle-and-actions.md +402 -26
  33. package/skills/hooks/navigation.md +4 -0
  34. package/skills/hooks/urls.md +3 -0
  35. package/skills/links/SKILL.md +5 -3
  36. package/skills/loader/SKILL.md +28 -9
  37. package/skills/migrate-nextjs/SKILL.md +5 -0
  38. package/skills/migrate-react-router/component-migration.md +4 -1
  39. package/skills/parallel/SKILL.md +8 -0
  40. package/skills/ppr/SKILL.md +1 -0
  41. package/skills/rango/SKILL.md +6 -3
  42. package/skills/testing/client-components.md +35 -32
  43. package/skills/testing/handles.md +58 -6
  44. package/skills/ux-architecture/SKILL.md +4 -0
  45. package/src/browser/event-controller.ts +265 -4
  46. package/src/browser/fetched-loader-handles.ts +227 -54
  47. package/src/browser/navigation-store.ts +261 -2
  48. package/src/browser/partial-update.ts +3 -2
  49. package/src/browser/react/use-handle.ts +74 -27
  50. package/src/browser/react/use-push-handle.ts +113 -0
  51. package/src/browser/rsc-router.tsx +11 -14
  52. package/src/browser/types.ts +48 -0
  53. package/src/cache/document-cache-policy.ts +6 -5
  54. package/src/client.rsc.tsx +1 -0
  55. package/src/client.tsx +31 -1
  56. package/src/handle.ts +13 -5
  57. package/src/handles/client-pushes.ts +120 -0
  58. package/src/handles/deferred-resolution.ts +12 -0
  59. package/src/handles/pushed-by.ts +55 -1
  60. package/src/loader-store.ts +26 -0
  61. package/src/rsc/loader-fetch.ts +17 -0
  62. package/src/rsc/prefetch-render-error.ts +2 -1
  63. package/src/rsc/request-stages.ts +7 -6
  64. package/src/rsc/rsc-rendering.ts +32 -14
  65. package/src/server/handle-store.ts +23 -0
  66. package/src/ssr/ssr-root.tsx +5 -0
  67. package/src/testing/dom.entry.ts +2 -0
  68. package/src/testing/render-route.tsx +317 -72
  69. package/src/use-loader.tsx +16 -5
@@ -303,7 +303,10 @@ function useLoaderInternal<T>(
303
303
  try {
304
304
  const url = new URL(window.location.href);
305
305
  url.searchParams.set("_rsc_loader", loaderId);
306
- const applyHandles = startFetchedLoaderRead(loaderId, page);
306
+ const landRead = startFetchedLoaderRead(loaderId, page, {
307
+ bucketKey,
308
+ requestId,
309
+ });
307
310
  const response = fetch(url.toString(), {
308
311
  method: "GET",
309
312
  headers: { Accept: "text/x-component" },
@@ -314,7 +317,7 @@ function useLoaderInternal<T>(
314
317
  throw new Error(payload.loaderError.message);
315
318
  }
316
319
  loaders.finishData(bucketKey, requestId, payload.loaderResult);
317
- applyHandles(payload.handles, payload.pushedBy);
320
+ landRead(payload.loaderResult, payload.handles, payload.pushedBy);
318
321
  } catch (e) {
319
322
  const err = e instanceof Error ? e : new Error(String(e));
320
323
  loaders.finishError(bucketKey, requestId, err);
@@ -570,8 +573,16 @@ function useLoaderInternal<T>(
570
573
  // Only a refetch of the page's own read (the page's params, no body)
571
574
  // applies its handle values: a read with other params or a body is
572
575
  // data the page does not show, and its pushes would retitle the page.
573
- const applyHandles = isPlainRefetch(loadOptions)
574
- ? startFetchedLoaderRead(id, page)
576
+ // A read that keeps its data local keeps its values local too
577
+ // (fetched-loader-handles.ts).
578
+ const landRead = isPlainRefetch(loadOptions)
579
+ ? startFetchedLoaderRead(
580
+ id,
581
+ page,
582
+ shared
583
+ ? { bucketKey: bucket, requestId: sharedRequestId }
584
+ : undefined,
585
+ )
575
586
  : undefined;
576
587
  const response = fetch(url.toString(), fetchOptions);
577
588
 
@@ -591,7 +602,7 @@ function useLoaderInternal<T>(
591
602
  setLocalIsLoading(false);
592
603
  });
593
604
  }
594
- applyHandles?.(payload.handles, payload.pushedBy);
605
+ landRead?.(result, payload.handles, payload.pushedBy);
595
606
  return result;
596
607
  } catch (e) {
597
608
  const err = e instanceof Error ? e : new Error(String(e));