react-router 0.0.0-experimental-e56aa53bc → 0.0.0-experimental-e6fb6e074

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 (65) hide show
  1. package/CHANGELOG.md +18 -734
  2. package/README.md +14 -5
  3. package/dist/index.d.ts +30 -0
  4. package/dist/index.js +1501 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/components.d.ts +157 -0
  7. package/dist/lib/context.d.ts +102 -0
  8. package/dist/lib/deprecations.d.ts +4 -0
  9. package/dist/lib/hooks.d.ts +181 -0
  10. package/dist/main.js +19 -0
  11. package/dist/react-router.development.js +1397 -0
  12. package/dist/react-router.development.js.map +1 -0
  13. package/dist/react-router.production.min.js +12 -0
  14. package/dist/react-router.production.min.js.map +1 -0
  15. package/dist/umd/react-router.development.js +1624 -0
  16. package/dist/umd/react-router.development.js.map +1 -0
  17. package/dist/umd/react-router.production.min.js +12 -0
  18. package/dist/umd/react-router.production.min.js.map +1 -0
  19. package/package.json +9 -111
  20. package/dist/development/chunk-RMWJZNG5.mjs +0 -11505
  21. package/dist/development/data-CQbyyGzl.d.mts +0 -11
  22. package/dist/development/data-CQbyyGzl.d.ts +0 -11
  23. package/dist/development/dom-export.d.mts +0 -23
  24. package/dist/development/dom-export.d.ts +0 -23
  25. package/dist/development/dom-export.js +0 -6341
  26. package/dist/development/dom-export.mjs +0 -222
  27. package/dist/development/fog-of-war-C5L_Yd5M.d.mts +0 -1778
  28. package/dist/development/fog-of-war-DrUCUQQ-.d.ts +0 -1778
  29. package/dist/development/index.d.mts +0 -855
  30. package/dist/development/index.d.ts +0 -855
  31. package/dist/development/index.js +0 -11664
  32. package/dist/development/index.mjs +0 -263
  33. package/dist/development/lib/types/route-module.d.mts +0 -209
  34. package/dist/development/lib/types/route-module.d.ts +0 -209
  35. package/dist/development/lib/types/route-module.js +0 -28
  36. package/dist/development/lib/types/route-module.mjs +0 -10
  37. package/dist/development/route-data-BIYebJr3.d.mts +0 -1749
  38. package/dist/development/route-data-BIYebJr3.d.ts +0 -1749
  39. package/dist/development/rsc-export.d.mts +0 -1788
  40. package/dist/development/rsc-export.d.ts +0 -1788
  41. package/dist/development/rsc-export.js +0 -2778
  42. package/dist/development/rsc-export.mjs +0 -2743
  43. package/dist/production/chunk-BXBFRMFA.mjs +0 -11505
  44. package/dist/production/data-CQbyyGzl.d.mts +0 -11
  45. package/dist/production/data-CQbyyGzl.d.ts +0 -11
  46. package/dist/production/dom-export.d.mts +0 -23
  47. package/dist/production/dom-export.d.ts +0 -23
  48. package/dist/production/dom-export.js +0 -6341
  49. package/dist/production/dom-export.mjs +0 -222
  50. package/dist/production/fog-of-war-C5L_Yd5M.d.mts +0 -1778
  51. package/dist/production/fog-of-war-DrUCUQQ-.d.ts +0 -1778
  52. package/dist/production/index.d.mts +0 -855
  53. package/dist/production/index.d.ts +0 -855
  54. package/dist/production/index.js +0 -11664
  55. package/dist/production/index.mjs +0 -263
  56. package/dist/production/lib/types/route-module.d.mts +0 -209
  57. package/dist/production/lib/types/route-module.d.ts +0 -209
  58. package/dist/production/lib/types/route-module.js +0 -28
  59. package/dist/production/lib/types/route-module.mjs +0 -10
  60. package/dist/production/route-data-BIYebJr3.d.mts +0 -1749
  61. package/dist/production/route-data-BIYebJr3.d.ts +0 -1749
  62. package/dist/production/rsc-export.d.mts +0 -1788
  63. package/dist/production/rsc-export.d.ts +0 -1788
  64. package/dist/production/rsc-export.js +0 -2778
  65. package/dist/production/rsc-export.mjs +0 -2743
@@ -1,222 +0,0 @@
1
- /**
2
- * react-router v0.0.0-experimental-e56aa53bc
3
- *
4
- * Copyright (c) Remix Software Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- import {
12
- FrameworkContext,
13
- RemixErrorBoundary,
14
- RouterProvider,
15
- createBrowserHistory,
16
- createClientRoutes,
17
- createClientRoutesWithHMRRevalidationOptOut,
18
- createRouter,
19
- decodeViaTurboStream,
20
- deserializeErrors,
21
- getHydrationData,
22
- getPatchRoutesOnNavigationFunction,
23
- getTurboStreamSingleFetchDataStrategy,
24
- hydrationRouteProperties,
25
- invariant,
26
- mapRouteProperties,
27
- useFogOFWarDiscovery
28
- } from "./chunk-RMWJZNG5.mjs";
29
-
30
- // lib/dom-export/dom-router-provider.tsx
31
- import * as React from "react";
32
- import * as ReactDOM from "react-dom";
33
- function RouterProvider2(props) {
34
- return /* @__PURE__ */ React.createElement(RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
35
- }
36
-
37
- // lib/dom-export/hydrated-router.tsx
38
- import * as React2 from "react";
39
- var ssrInfo = null;
40
- var router = null;
41
- function initSsrInfo() {
42
- if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
43
- if (window.__reactRouterManifest.sri === true) {
44
- const importMap = document.querySelector("script[rr-importmap]");
45
- if (importMap?.textContent) {
46
- try {
47
- window.__reactRouterManifest.sri = JSON.parse(
48
- importMap.textContent
49
- ).integrity;
50
- } catch (err) {
51
- console.error("Failed to parse import map", err);
52
- }
53
- }
54
- }
55
- ssrInfo = {
56
- context: window.__reactRouterContext,
57
- manifest: window.__reactRouterManifest,
58
- routeModules: window.__reactRouterRouteModules,
59
- stateDecodingPromise: void 0,
60
- router: void 0,
61
- routerInitialized: false
62
- };
63
- }
64
- }
65
- function createHydratedRouter({
66
- unstable_getContext
67
- }) {
68
- initSsrInfo();
69
- if (!ssrInfo) {
70
- throw new Error(
71
- "You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`"
72
- );
73
- }
74
- let localSsrInfo = ssrInfo;
75
- if (!ssrInfo.stateDecodingPromise) {
76
- let stream = ssrInfo.context.stream;
77
- invariant(stream, "No stream found for single fetch decoding");
78
- ssrInfo.context.stream = void 0;
79
- ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then((value) => {
80
- ssrInfo.context.state = value.value;
81
- localSsrInfo.stateDecodingPromise.value = true;
82
- }).catch((e) => {
83
- localSsrInfo.stateDecodingPromise.error = e;
84
- });
85
- }
86
- if (ssrInfo.stateDecodingPromise.error) {
87
- throw ssrInfo.stateDecodingPromise.error;
88
- }
89
- if (!ssrInfo.stateDecodingPromise.value) {
90
- throw ssrInfo.stateDecodingPromise;
91
- }
92
- let routes = createClientRoutes(
93
- ssrInfo.manifest.routes,
94
- ssrInfo.routeModules,
95
- ssrInfo.context.state,
96
- ssrInfo.context.ssr,
97
- ssrInfo.context.isSpaMode
98
- );
99
- let hydrationData = void 0;
100
- if (ssrInfo.context.isSpaMode) {
101
- let { loaderData } = ssrInfo.context.state;
102
- if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) {
103
- hydrationData = {
104
- loaderData: {
105
- root: loaderData.root
106
- }
107
- };
108
- }
109
- } else {
110
- hydrationData = getHydrationData(
111
- ssrInfo.context.state,
112
- routes,
113
- (routeId) => ({
114
- clientLoader: ssrInfo.routeModules[routeId]?.clientLoader,
115
- hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true,
116
- hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null
117
- }),
118
- window.location,
119
- window.__reactRouterContext?.basename,
120
- ssrInfo.context.isSpaMode
121
- );
122
- if (hydrationData && hydrationData.errors) {
123
- hydrationData.errors = deserializeErrors(hydrationData.errors);
124
- }
125
- }
126
- let router2 = createRouter({
127
- routes,
128
- history: createBrowserHistory(),
129
- basename: ssrInfo.context.basename,
130
- unstable_getContext,
131
- hydrationData,
132
- hydrationRouteProperties,
133
- mapRouteProperties,
134
- future: {
135
- unstable_middleware: ssrInfo.context.future.unstable_middleware
136
- },
137
- dataStrategy: getTurboStreamSingleFetchDataStrategy(
138
- () => router2,
139
- ssrInfo.manifest,
140
- ssrInfo.routeModules,
141
- ssrInfo.context.ssr,
142
- ssrInfo.context.basename
143
- ),
144
- patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(
145
- ssrInfo.manifest,
146
- ssrInfo.routeModules,
147
- ssrInfo.context.ssr,
148
- ssrInfo.context.isSpaMode,
149
- ssrInfo.context.basename
150
- )
151
- });
152
- ssrInfo.router = router2;
153
- if (router2.state.initialized) {
154
- ssrInfo.routerInitialized = true;
155
- router2.initialize();
156
- }
157
- router2.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
158
- createClientRoutesWithHMRRevalidationOptOut;
159
- window.__reactRouterDataRouter = router2;
160
- return router2;
161
- }
162
- function HydratedRouter(props) {
163
- if (!router) {
164
- router = createHydratedRouter({
165
- unstable_getContext: props.unstable_getContext
166
- });
167
- }
168
- let [criticalCss, setCriticalCss] = React2.useState(
169
- process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
170
- );
171
- if (process.env.NODE_ENV === "development") {
172
- if (ssrInfo) {
173
- window.__reactRouterClearCriticalCss = () => setCriticalCss(void 0);
174
- }
175
- }
176
- let [location, setLocation] = React2.useState(router.state.location);
177
- React2.useLayoutEffect(() => {
178
- if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
179
- ssrInfo.routerInitialized = true;
180
- ssrInfo.router.initialize();
181
- }
182
- }, []);
183
- React2.useLayoutEffect(() => {
184
- if (ssrInfo && ssrInfo.router) {
185
- return ssrInfo.router.subscribe((newState) => {
186
- if (newState.location !== location) {
187
- setLocation(newState.location);
188
- }
189
- });
190
- }
191
- }, [location]);
192
- invariant(ssrInfo, "ssrInfo unavailable for HydratedRouter");
193
- useFogOFWarDiscovery(
194
- router,
195
- ssrInfo.manifest,
196
- ssrInfo.routeModules,
197
- ssrInfo.context.ssr,
198
- ssrInfo.context.isSpaMode
199
- );
200
- return (
201
- // This fragment is important to ensure we match the <ServerRouter> JSX
202
- // structure so that useId values hydrate correctly
203
- /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
204
- FrameworkContext.Provider,
205
- {
206
- value: {
207
- manifest: ssrInfo.manifest,
208
- routeModules: ssrInfo.routeModules,
209
- future: ssrInfo.context.future,
210
- criticalCss,
211
- ssr: ssrInfo.context.ssr,
212
- isSpaMode: ssrInfo.context.isSpaMode
213
- }
214
- },
215
- /* @__PURE__ */ React2.createElement(RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(RouterProvider2, { router }))
216
- ), /* @__PURE__ */ React2.createElement(React2.Fragment, null))
217
- );
218
- }
219
- export {
220
- HydratedRouter,
221
- RouterProvider2 as RouterProvider
222
- };