@uniflowed/router 0.0.0-alpha.9 → 0.2.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 (51) hide show
  1. package/action.js +344 -0
  2. package/client.js +263 -7
  3. package/handler.js +113 -99
  4. package/http-client.js +104 -0
  5. package/index.js +49 -6
  6. package/instrumentation.js +92 -0
  7. package/internal/action-endpoint.js +646 -0
  8. package/internal/action-wire.js +608 -0
  9. package/internal/base-path.js +175 -0
  10. package/internal/boundaries.js +481 -0
  11. package/internal/boundary-data.js +88 -0
  12. package/internal/compose.js +490 -0
  13. package/internal/deployment.js +160 -0
  14. package/internal/devtools.js +131 -0
  15. package/internal/diagnostics.js +169 -0
  16. package/internal/error-view.js +193 -0
  17. package/internal/flight-browser.js +242 -0
  18. package/internal/flight-chunks.js +205 -0
  19. package/internal/flight-rows.js +135 -0
  20. package/internal/flight-ssr.js +91 -0
  21. package/internal/flight.js +192 -0
  22. package/internal/form-action.js +243 -0
  23. package/internal/head.js +219 -0
  24. package/internal/hydrate-options.js +38 -0
  25. package/internal/hydration.js +1085 -0
  26. package/internal/inspector.js +626 -0
  27. package/internal/native-links.js +67 -0
  28. package/internal/native-tree.js +89 -0
  29. package/internal/navigation-cache.js +181 -0
  30. package/internal/payload-rows.js +270 -0
  31. package/internal/payload.js +685 -0
  32. package/internal/prepare-document.js +54 -0
  33. package/internal/react-version.js +77 -0
  34. package/internal/resolve.js +1617 -0
  35. package/internal/resolved-summary.js +199 -0
  36. package/internal/routing.js +478 -0
  37. package/internal/runtime.js +1593 -1341
  38. package/internal/server-instrumentation.js +12 -0
  39. package/internal/server-route.js +58 -0
  40. package/internal/shell.js +132 -0
  41. package/internal/stream.js +766 -21
  42. package/middleware.js +274 -22
  43. package/native-navigation.js +217 -0
  44. package/native.js +416 -0
  45. package/package.json +48 -7
  46. package/routing.js +51 -0
  47. package/rsc-client.js +122 -0
  48. package/rsc-ssr.js +641 -0
  49. package/rsc.js +402 -0
  50. package/server-components.js +159 -0
  51. package/server.js +263 -106
@@ -0,0 +1,38 @@
1
+ // @flow
2
+ //
3
+ // Internal to `@uniflowed/router`: what both hydrating entries hand
4
+ // `hydrateRoot` besides the tree.
5
+
6
+ import type { FormState } from "./form-action.js";
7
+
8
+ /** React's `onRecoverableError`, as the development report builds one. */
9
+ type Recovery = (error: mixed, info: { componentStack?: ?string, ... }) => void;
10
+
11
+ /** What this hands `hydrateRoot`. */
12
+ type HydrationOptions = {| onRecoverableError?: Recovery, formState?: FormState |};
13
+
14
+ /**
15
+ * `hydrateRoot`'s options: the development recovery handler, and a postback's
16
+ * form state.
17
+ *
18
+ * `formState` is React's own option. A page rendered in answer to a form posted
19
+ * before hydration was rendered with it, React marked the `useActionState` that
20
+ * submitted, and passing the same value here is how the browser's copy of that
21
+ * hook starts from the action's result instead of its initial state.
22
+ */
23
+ export function hydrationOptions(
24
+ recovery: ?Recovery,
25
+ formState: FormState | void,
26
+ ): HydrationOptions | void {
27
+ if (recovery == null && formState == null) {
28
+ return undefined;
29
+ }
30
+ const options: HydrationOptions = {};
31
+ if (recovery != null) {
32
+ options.onRecoverableError = recovery;
33
+ }
34
+ if (formState != null) {
35
+ options.formState = formState;
36
+ }
37
+ return options;
38
+ }