@cedarjs/router 0.0.4

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 (275) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/dist/ActivePageContext.d.ts +15 -0
  4. package/dist/ActivePageContext.d.ts.map +1 -0
  5. package/dist/ActivePageContext.js +17 -0
  6. package/dist/AuthenticatedRoute.d.ts +11 -0
  7. package/dist/AuthenticatedRoute.d.ts.map +1 -0
  8. package/dist/AuthenticatedRoute.js +49 -0
  9. package/dist/PageLoadingContext.d.ts +14 -0
  10. package/dist/PageLoadingContext.d.ts.map +1 -0
  11. package/dist/PageLoadingContext.js +29 -0
  12. package/dist/Route.d.ts +32 -0
  13. package/dist/Route.d.ts.map +1 -0
  14. package/dist/Route.js +7 -0
  15. package/dist/Set.d.ts +58 -0
  16. package/dist/Set.d.ts.map +1 -0
  17. package/dist/Set.js +28 -0
  18. package/dist/a11yUtils.d.ts +14 -0
  19. package/dist/a11yUtils.d.ts.map +1 -0
  20. package/dist/a11yUtils.js +35 -0
  21. package/dist/active-route-loader.d.ts +12 -0
  22. package/dist/active-route-loader.d.ts.map +1 -0
  23. package/dist/active-route-loader.js +82 -0
  24. package/dist/analyzeRoutes.d.ts +44 -0
  25. package/dist/analyzeRoutes.d.ts.map +1 -0
  26. package/dist/analyzeRoutes.js +128 -0
  27. package/dist/cjs/ActivePageContext.d.ts +15 -0
  28. package/dist/cjs/ActivePageContext.d.ts.map +1 -0
  29. package/dist/cjs/ActivePageContext.js +42 -0
  30. package/dist/cjs/AuthenticatedRoute.d.ts +11 -0
  31. package/dist/cjs/AuthenticatedRoute.d.ts.map +1 -0
  32. package/dist/cjs/AuthenticatedRoute.js +83 -0
  33. package/dist/cjs/PageLoadingContext.d.ts +14 -0
  34. package/dist/cjs/PageLoadingContext.d.ts.map +1 -0
  35. package/dist/cjs/PageLoadingContext.js +64 -0
  36. package/dist/cjs/Route.d.ts +32 -0
  37. package/dist/cjs/Route.d.ts.map +1 -0
  38. package/dist/cjs/Route.js +41 -0
  39. package/dist/cjs/Set.d.ts +58 -0
  40. package/dist/cjs/Set.d.ts.map +1 -0
  41. package/dist/cjs/Set.js +67 -0
  42. package/dist/cjs/a11yUtils.d.ts +14 -0
  43. package/dist/cjs/a11yUtils.d.ts.map +1 -0
  44. package/dist/cjs/a11yUtils.js +61 -0
  45. package/dist/cjs/active-route-loader.d.ts +12 -0
  46. package/dist/cjs/active-route-loader.d.ts.map +1 -0
  47. package/dist/cjs/active-route-loader.js +116 -0
  48. package/dist/cjs/analyzeRoutes.d.ts +44 -0
  49. package/dist/cjs/analyzeRoutes.d.ts.map +1 -0
  50. package/dist/cjs/analyzeRoutes.js +143 -0
  51. package/dist/cjs/createNamedContext.d.ts +3 -0
  52. package/dist/cjs/createNamedContext.d.ts.map +1 -0
  53. package/dist/cjs/createNamedContext.js +33 -0
  54. package/dist/cjs/dummyComponent.d.ts +3 -0
  55. package/dist/cjs/dummyComponent.d.ts.map +1 -0
  56. package/dist/cjs/dummyComponent.js +24 -0
  57. package/dist/cjs/history.d.ts +24 -0
  58. package/dist/cjs/history.d.ts.map +1 -0
  59. package/dist/cjs/history.js +146 -0
  60. package/dist/cjs/index.d.ts +35 -0
  61. package/dist/cjs/index.d.ts.map +1 -0
  62. package/dist/cjs/index.js +110 -0
  63. package/dist/cjs/link.d.ts +9 -0
  64. package/dist/cjs/link.d.ts.map +1 -0
  65. package/dist/cjs/link.js +62 -0
  66. package/dist/cjs/location.d.ts +28 -0
  67. package/dist/cjs/location.d.ts.map +1 -0
  68. package/dist/cjs/location.js +110 -0
  69. package/dist/cjs/namedRoutes.d.ts +3 -0
  70. package/dist/cjs/namedRoutes.d.ts.map +1 -0
  71. package/dist/cjs/namedRoutes.js +28 -0
  72. package/dist/cjs/navLink.d.ts +11 -0
  73. package/dist/cjs/navLink.d.ts.map +1 -0
  74. package/dist/cjs/navLink.js +70 -0
  75. package/dist/cjs/package.json +1 -0
  76. package/dist/cjs/page.d.ts +28 -0
  77. package/dist/cjs/page.d.ts.map +1 -0
  78. package/dist/cjs/page.js +42 -0
  79. package/dist/cjs/params.d.ts +13 -0
  80. package/dist/cjs/params.d.ts.map +1 -0
  81. package/dist/cjs/params.js +64 -0
  82. package/dist/cjs/react-util.d.ts +3 -0
  83. package/dist/cjs/react-util.d.ts.map +1 -0
  84. package/dist/cjs/react-util.js +37 -0
  85. package/dist/cjs/redirect.d.ts +12 -0
  86. package/dist/cjs/redirect.d.ts.map +1 -0
  87. package/dist/cjs/redirect.js +35 -0
  88. package/dist/cjs/route-announcement.d.ts +13 -0
  89. package/dist/cjs/route-announcement.d.ts.map +1 -0
  90. package/dist/cjs/route-announcement.js +61 -0
  91. package/dist/cjs/route-focus.d.ts +12 -0
  92. package/dist/cjs/route-focus.d.ts.map +1 -0
  93. package/dist/cjs/route-focus.js +36 -0
  94. package/dist/cjs/route-validators.d.ts +21 -0
  95. package/dist/cjs/route-validators.d.ts.map +1 -0
  96. package/dist/cjs/route-validators.js +71 -0
  97. package/dist/cjs/routeParamsTypes.d.ts +49 -0
  98. package/dist/cjs/routeParamsTypes.d.ts.map +1 -0
  99. package/dist/cjs/routeParamsTypes.js +16 -0
  100. package/dist/cjs/router-context.d.ts +21 -0
  101. package/dist/cjs/router-context.d.ts.map +1 -0
  102. package/dist/cjs/router-context.js +69 -0
  103. package/dist/cjs/router.d.ts +11 -0
  104. package/dist/cjs/router.d.ts.map +1 -0
  105. package/dist/cjs/router.js +207 -0
  106. package/dist/cjs/rsc/ClientRouter.d.ts +4 -0
  107. package/dist/cjs/rsc/ClientRouter.d.ts.map +1 -0
  108. package/dist/cjs/rsc/ClientRouter.js +90 -0
  109. package/dist/cjs/rsc/RscCache.d.ts +23 -0
  110. package/dist/cjs/rsc/RscCache.d.ts.map +1 -0
  111. package/dist/cjs/rsc/RscCache.js +110 -0
  112. package/dist/cjs/rsc/RscRoutes.d.ts +7 -0
  113. package/dist/cjs/rsc/RscRoutes.d.ts.map +1 -0
  114. package/dist/cjs/rsc/RscRoutes.js +124 -0
  115. package/dist/cjs/rsc/ServerRouteLoader.d.ts +12 -0
  116. package/dist/cjs/rsc/ServerRouteLoader.d.ts.map +1 -0
  117. package/dist/cjs/rsc/ServerRouteLoader.js +65 -0
  118. package/dist/cjs/rsc/ServerRouter.d.ts +11 -0
  119. package/dist/cjs/rsc/ServerRouter.d.ts.map +1 -0
  120. package/dist/cjs/rsc/ServerRouter.js +170 -0
  121. package/dist/cjs/rsc/SsrRouter.d.ts +4 -0
  122. package/dist/cjs/rsc/SsrRouter.d.ts.map +1 -0
  123. package/dist/cjs/rsc/SsrRouter.js +56 -0
  124. package/dist/cjs/rsc/clientSsr.d.ts +2 -0
  125. package/dist/cjs/rsc/clientSsr.d.ts.map +1 -0
  126. package/dist/cjs/rsc/clientSsr.js +114 -0
  127. package/dist/cjs/rsc/rscCss.d.ts +2 -0
  128. package/dist/cjs/rsc/rscCss.d.ts.map +1 -0
  129. package/dist/cjs/rsc/rscCss.js +94 -0
  130. package/dist/cjs/rsc/ssrModuleMap.d.ts +14 -0
  131. package/dist/cjs/rsc/ssrModuleMap.d.ts.map +1 -0
  132. package/dist/cjs/rsc/ssrModuleMap.js +49 -0
  133. package/dist/cjs/rsc/utils.d.ts +20 -0
  134. package/dist/cjs/rsc/utils.d.ts.map +1 -0
  135. package/dist/cjs/rsc/utils.js +68 -0
  136. package/dist/cjs/rsc-link.d.ts +6 -0
  137. package/dist/cjs/rsc-link.d.ts.map +1 -0
  138. package/dist/cjs/rsc-link.js +41 -0
  139. package/dist/cjs/skipNav.d.ts +81 -0
  140. package/dist/cjs/skipNav.d.ts.map +1 -0
  141. package/dist/cjs/skipNav.js +69 -0
  142. package/dist/cjs/splash-page.d.ts +12 -0
  143. package/dist/cjs/splash-page.d.ts.map +1 -0
  144. package/dist/cjs/splash-page.js +515 -0
  145. package/dist/cjs/useBlocker.d.ts +11 -0
  146. package/dist/cjs/useBlocker.d.ts.map +1 -0
  147. package/dist/cjs/useBlocker.js +65 -0
  148. package/dist/cjs/useIsMounted.d.ts +2 -0
  149. package/dist/cjs/useIsMounted.d.ts.map +1 -0
  150. package/dist/cjs/useIsMounted.js +37 -0
  151. package/dist/cjs/useMatch.d.ts +43 -0
  152. package/dist/cjs/useMatch.d.ts.map +1 -0
  153. package/dist/cjs/useMatch.js +72 -0
  154. package/dist/cjs/useRouteName.d.ts +3 -0
  155. package/dist/cjs/useRouteName.d.ts.map +1 -0
  156. package/dist/cjs/useRouteName.js +40 -0
  157. package/dist/cjs/useRoutePaths.d.ts +4 -0
  158. package/dist/cjs/useRoutePaths.d.ts.map +1 -0
  159. package/dist/cjs/useRoutePaths.js +50 -0
  160. package/dist/cjs/util.d.ts +121 -0
  161. package/dist/cjs/util.d.ts.map +1 -0
  162. package/dist/cjs/util.js +214 -0
  163. package/dist/createNamedContext.d.ts +3 -0
  164. package/dist/createNamedContext.d.ts.map +1 -0
  165. package/dist/createNamedContext.js +9 -0
  166. package/dist/dummyComponent.d.ts +3 -0
  167. package/dist/dummyComponent.d.ts.map +1 -0
  168. package/dist/dummyComponent.js +4 -0
  169. package/dist/history.d.ts +24 -0
  170. package/dist/history.d.ts.map +1 -0
  171. package/dist/history.js +118 -0
  172. package/dist/index.d.ts +35 -0
  173. package/dist/index.d.ts.map +1 -0
  174. package/dist/index.js +49 -0
  175. package/dist/link.d.ts +9 -0
  176. package/dist/link.d.ts.map +1 -0
  177. package/dist/link.js +28 -0
  178. package/dist/location.d.ts +28 -0
  179. package/dist/location.d.ts.map +1 -0
  180. package/dist/location.js +74 -0
  181. package/dist/namedRoutes.d.ts +3 -0
  182. package/dist/namedRoutes.d.ts.map +1 -0
  183. package/dist/namedRoutes.js +4 -0
  184. package/dist/navLink.d.ts +11 -0
  185. package/dist/navLink.d.ts.map +1 -0
  186. package/dist/navLink.js +36 -0
  187. package/dist/page.d.ts +28 -0
  188. package/dist/page.d.ts.map +1 -0
  189. package/dist/page.js +17 -0
  190. package/dist/params.d.ts +13 -0
  191. package/dist/params.d.ts.map +1 -0
  192. package/dist/params.js +28 -0
  193. package/dist/react-util.d.ts +3 -0
  194. package/dist/react-util.d.ts.map +1 -0
  195. package/dist/react-util.js +13 -0
  196. package/dist/redirect.d.ts +12 -0
  197. package/dist/redirect.d.ts.map +1 -0
  198. package/dist/redirect.js +11 -0
  199. package/dist/route-announcement.d.ts +13 -0
  200. package/dist/route-announcement.d.ts.map +1 -0
  201. package/dist/route-announcement.js +31 -0
  202. package/dist/route-focus.d.ts +12 -0
  203. package/dist/route-focus.d.ts.map +1 -0
  204. package/dist/route-focus.js +6 -0
  205. package/dist/route-validators.d.ts +21 -0
  206. package/dist/route-validators.d.ts.map +1 -0
  207. package/dist/route-validators.js +44 -0
  208. package/dist/routeParamsTypes.d.ts +49 -0
  209. package/dist/routeParamsTypes.d.ts.map +1 -0
  210. package/dist/routeParamsTypes.js +0 -0
  211. package/dist/router-context.d.ts +21 -0
  212. package/dist/router-context.d.ts.map +1 -0
  213. package/dist/router-context.js +34 -0
  214. package/dist/router.d.ts +11 -0
  215. package/dist/router.d.ts.map +1 -0
  216. package/dist/router.js +173 -0
  217. package/dist/rsc/ClientRouter.d.ts +4 -0
  218. package/dist/rsc/ClientRouter.d.ts.map +1 -0
  219. package/dist/rsc/ClientRouter.js +56 -0
  220. package/dist/rsc/RscCache.d.ts +23 -0
  221. package/dist/rsc/RscCache.d.ts.map +1 -0
  222. package/dist/rsc/RscCache.js +86 -0
  223. package/dist/rsc/RscRoutes.d.ts +7 -0
  224. package/dist/rsc/RscRoutes.d.ts.map +1 -0
  225. package/dist/rsc/RscRoutes.js +100 -0
  226. package/dist/rsc/ServerRouteLoader.d.ts +12 -0
  227. package/dist/rsc/ServerRouteLoader.d.ts.map +1 -0
  228. package/dist/rsc/ServerRouteLoader.js +31 -0
  229. package/dist/rsc/ServerRouter.d.ts +11 -0
  230. package/dist/rsc/ServerRouter.d.ts.map +1 -0
  231. package/dist/rsc/ServerRouter.js +136 -0
  232. package/dist/rsc/SsrRouter.d.ts +4 -0
  233. package/dist/rsc/SsrRouter.d.ts.map +1 -0
  234. package/dist/rsc/SsrRouter.js +22 -0
  235. package/dist/rsc/clientSsr.d.ts +2 -0
  236. package/dist/rsc/clientSsr.d.ts.map +1 -0
  237. package/dist/rsc/clientSsr.js +80 -0
  238. package/dist/rsc/rscCss.d.ts +2 -0
  239. package/dist/rsc/rscCss.d.ts.map +1 -0
  240. package/dist/rsc/rscCss.js +60 -0
  241. package/dist/rsc/ssrModuleMap.d.ts +14 -0
  242. package/dist/rsc/ssrModuleMap.d.ts.map +1 -0
  243. package/dist/rsc/ssrModuleMap.js +25 -0
  244. package/dist/rsc/utils.d.ts +20 -0
  245. package/dist/rsc/utils.d.ts.map +1 -0
  246. package/dist/rsc/utils.js +31 -0
  247. package/dist/rsc-link.d.ts +6 -0
  248. package/dist/rsc-link.d.ts.map +1 -0
  249. package/dist/rsc-link.js +7 -0
  250. package/dist/skipNav.d.ts +81 -0
  251. package/dist/skipNav.d.ts.map +1 -0
  252. package/dist/skipNav.js +34 -0
  253. package/dist/splash-page.d.ts +12 -0
  254. package/dist/splash-page.d.ts.map +1 -0
  255. package/dist/splash-page.js +481 -0
  256. package/dist/useBlocker.d.ts +11 -0
  257. package/dist/useBlocker.d.ts.map +1 -0
  258. package/dist/useBlocker.js +41 -0
  259. package/dist/useIsMounted.d.ts +2 -0
  260. package/dist/useIsMounted.d.ts.map +1 -0
  261. package/dist/useIsMounted.js +13 -0
  262. package/dist/useMatch.d.ts +43 -0
  263. package/dist/useMatch.d.ts.map +1 -0
  264. package/dist/useMatch.js +48 -0
  265. package/dist/useRouteName.d.ts +3 -0
  266. package/dist/useRouteName.d.ts.map +1 -0
  267. package/dist/useRouteName.js +16 -0
  268. package/dist/useRoutePaths.d.ts +4 -0
  269. package/dist/useRoutePaths.d.ts.map +1 -0
  270. package/dist/useRoutePaths.js +25 -0
  271. package/dist/util.d.ts +121 -0
  272. package/dist/util.d.ts.map +1 -0
  273. package/dist/util.js +183 -0
  274. package/package.json +127 -0
  275. package/skip-nav.css +31 -0
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var router_exports = {};
30
+ __export(router_exports, {
31
+ Router: () => Router
32
+ });
33
+ module.exports = __toCommonJS(router_exports);
34
+ var import_react = __toESM(require("react"), 1);
35
+ var import_active_route_loader = require("./active-route-loader.js");
36
+ var import_analyzeRoutes = require("./analyzeRoutes.js");
37
+ var import_AuthenticatedRoute = require("./AuthenticatedRoute.js");
38
+ var import_location = require("./location.js");
39
+ var import_namedRoutes = require("./namedRoutes.js");
40
+ var import_page = require("./page.js");
41
+ var import_PageLoadingContext = require("./PageLoadingContext.js");
42
+ var import_params = require("./params.js");
43
+ var import_redirect = require("./redirect.js");
44
+ var import_router_context = require("./router-context.js");
45
+ var import_splash_page = require("./splash-page.js");
46
+ var import_util = require("./util.js");
47
+ const Router = ({
48
+ useAuth,
49
+ paramTypes,
50
+ pageLoadingDelay,
51
+ trailingSlashes = "never",
52
+ children
53
+ }) => {
54
+ return (
55
+ // Level 1/3 (outer-most)
56
+ // Wrap it in the provider so that useLocation can be used
57
+ /* @__PURE__ */ import_react.default.createElement(import_location.LocationProvider, { trailingSlashes }, /* @__PURE__ */ import_react.default.createElement(
58
+ LocationAwareRouter,
59
+ {
60
+ useAuth,
61
+ paramTypes,
62
+ pageLoadingDelay
63
+ },
64
+ children
65
+ ))
66
+ );
67
+ };
68
+ const LocationAwareRouter = ({
69
+ useAuth,
70
+ paramTypes,
71
+ pageLoadingDelay,
72
+ children
73
+ }) => {
74
+ const location = (0, import_location.useLocation)();
75
+ const analyzeRoutesResult = (0, import_react.useMemo)(() => {
76
+ return (0, import_analyzeRoutes.analyzeRoutes)(children, {
77
+ currentPathName: location.pathname,
78
+ // @TODO We haven't handled this with SSR/Streaming yet.
79
+ // May need a babel plugin to extract userParamTypes from Routes.tsx
80
+ userParamTypes: paramTypes
81
+ });
82
+ }, [location.pathname, children, paramTypes]);
83
+ const {
84
+ pathRouteMap,
85
+ hasRootRoute,
86
+ namedRoutesMap,
87
+ NotFoundPage,
88
+ activeRoutePath
89
+ } = analyzeRoutesResult;
90
+ const hasGeneratedRoutes = hasCustomRoutes(namedRoutesMap);
91
+ const splashPageExists = typeof import_splash_page.SplashPage !== "undefined";
92
+ const isOnNonExistentRootRoute = !hasRootRoute && location.pathname === "/";
93
+ if (!hasRootRoute && splashPageExists) {
94
+ namedRoutesMap["home"] = () => "/";
95
+ }
96
+ Object.assign(import_namedRoutes.namedRoutes, namedRoutesMap);
97
+ const shouldShowSplash = (isOnNonExistentRootRoute || !hasGeneratedRoutes) && splashPageExists;
98
+ if (shouldShowSplash) {
99
+ return /* @__PURE__ */ import_react.default.createElement(
100
+ import_splash_page.SplashPage,
101
+ {
102
+ hasGeneratedRoutes,
103
+ allStandardRoutes: pathRouteMap
104
+ }
105
+ );
106
+ }
107
+ if (!activeRoutePath) {
108
+ if (NotFoundPage) {
109
+ return /* @__PURE__ */ import_react.default.createElement(
110
+ import_router_context.RouterContextProvider,
111
+ {
112
+ useAuth,
113
+ paramTypes,
114
+ routes: analyzeRoutesResult
115
+ },
116
+ /* @__PURE__ */ import_react.default.createElement(import_params.ParamsProvider, null, /* @__PURE__ */ import_react.default.createElement(import_PageLoadingContext.PageLoadingContextProvider, { delay: pageLoadingDelay }, /* @__PURE__ */ import_react.default.createElement(
117
+ import_active_route_loader.ActiveRouteLoader,
118
+ {
119
+ spec: (0, import_page.normalizePage)(NotFoundPage),
120
+ path: location.pathname
121
+ }
122
+ )))
123
+ );
124
+ }
125
+ return null;
126
+ }
127
+ const { path, page, name, redirect, whileLoadingPage, sets } = pathRouteMap[activeRoutePath];
128
+ if (!path) {
129
+ throw new Error(`Route "${name}" needs to specify a path`);
130
+ }
131
+ (0, import_util.validatePath)(path, name || path);
132
+ const { params: pathParams } = (0, import_util.matchPath)(path, location.pathname, {
133
+ userParamTypes: paramTypes
134
+ });
135
+ const searchParams = (0, import_util.parseSearch)(location.search);
136
+ const allParams = { ...searchParams, ...pathParams };
137
+ let redirectPath = void 0;
138
+ if (redirect) {
139
+ if (redirect.startsWith("/")) {
140
+ redirectPath = (0, import_util.replaceParams)(redirect, allParams);
141
+ } else {
142
+ const redirectRouteObject = Object.values(pathRouteMap).find(
143
+ (route) => route.name === redirect
144
+ );
145
+ if (!redirectRouteObject) {
146
+ throw new Error(
147
+ `Redirect target route "${redirect}" does not exist for route "${name}"`
148
+ );
149
+ }
150
+ redirectPath = (0, import_util.replaceParams)(redirectRouteObject.path, allParams);
151
+ }
152
+ }
153
+ return /* @__PURE__ */ import_react.default.createElement(
154
+ import_router_context.RouterContextProvider,
155
+ {
156
+ useAuth,
157
+ paramTypes,
158
+ routes: analyzeRoutesResult,
159
+ activeRouteName: name
160
+ },
161
+ /* @__PURE__ */ import_react.default.createElement(import_params.ParamsProvider, { allParams }, /* @__PURE__ */ import_react.default.createElement(import_PageLoadingContext.PageLoadingContextProvider, { delay: pageLoadingDelay }, redirectPath && /* @__PURE__ */ import_react.default.createElement(import_redirect.Redirect, { to: redirectPath }), !redirectPath && page && /* @__PURE__ */ import_react.default.createElement(WrappedPage, { sets }, /* @__PURE__ */ import_react.default.createElement(
162
+ import_active_route_loader.ActiveRouteLoader,
163
+ {
164
+ path,
165
+ spec: (0, import_page.normalizePage)(page),
166
+ params: allParams,
167
+ whileLoadingPage
168
+ }
169
+ ))))
170
+ );
171
+ };
172
+ const WrappedPage = (0, import_react.memo)(({ sets, children }) => {
173
+ if (!sets || sets.length === 0) {
174
+ return children;
175
+ }
176
+ return sets.reduceRight((acc, set) => {
177
+ let wrapped = set.wrappers.reduceRight((acc2, Wrapper, index) => {
178
+ return import_react.default.createElement(
179
+ Wrapper,
180
+ { ...set.props, key: set.id + "-" + index },
181
+ acc2
182
+ );
183
+ }, acc);
184
+ if (set.isPrivate) {
185
+ const unauthenticated = set.props.unauthenticated;
186
+ if (!unauthenticated || typeof unauthenticated !== "string") {
187
+ throw new Error(
188
+ "You must specify an `unauthenticated` route when using PrivateSet"
189
+ );
190
+ }
191
+ wrapped = /* @__PURE__ */ import_react.default.createElement(import_AuthenticatedRoute.AuthenticatedRoute, { ...set.props, unauthenticated }, wrapped);
192
+ }
193
+ return wrapped;
194
+ }, children);
195
+ });
196
+ function hasCustomRoutes(obj) {
197
+ for (const prop in obj) {
198
+ if (Object.hasOwn(obj, prop)) {
199
+ return true;
200
+ }
201
+ }
202
+ return false;
203
+ }
204
+ // Annotate the CommonJS export names for ESM import in node:
205
+ 0 && (module.exports = {
206
+ Router
207
+ });
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { RouterProps } from '../router.js';
3
+ export declare const Router: ({ useAuth, paramTypes, children }: RouterProps) => React.JSX.Element;
4
+ //# sourceMappingURL=ClientRouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClientRouter.d.ts","sourceRoot":"","sources":["../../../src/rsc/ClientRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAA;AAOtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI/C,eAAO,MAAM,MAAM,sCAAuC,WAAW,sBASpE,CAAA"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ClientRouter_exports = {};
30
+ __export(ClientRouter_exports, {
31
+ Router: () => Router
32
+ });
33
+ module.exports = __toCommonJS(ClientRouter_exports);
34
+ var import_react = __toESM(require("react"), 1);
35
+ var import_analyzeRoutes = require("../analyzeRoutes.js");
36
+ var import_AuthenticatedRoute = require("../AuthenticatedRoute.js");
37
+ var import_location = require("../location.js");
38
+ var import_namedRoutes = require("../namedRoutes.js");
39
+ var import_router_context = require("../router-context.js");
40
+ var import_RscRoutes = require("./RscRoutes.js");
41
+ const Router = ({ useAuth, paramTypes, children }) => {
42
+ return (
43
+ // Wrap it in the provider so that useLocation can be used
44
+ /* @__PURE__ */ import_react.default.createElement(import_location.LocationProvider, null, /* @__PURE__ */ import_react.default.createElement(LocationAwareRouter, { paramTypes, useAuth }, children))
45
+ );
46
+ };
47
+ const LocationAwareRouter = ({
48
+ useAuth,
49
+ paramTypes,
50
+ children
51
+ }) => {
52
+ const { pathname, search } = (0, import_location.useLocation)();
53
+ const analyzeRoutesResult = (0, import_react.useMemo)(() => {
54
+ return (0, import_analyzeRoutes.analyzeRoutes)(children, {
55
+ currentPathName: pathname,
56
+ userParamTypes: paramTypes
57
+ });
58
+ }, [pathname, children, paramTypes]);
59
+ const { namedRoutesMap, pathRouteMap, activeRoutePath } = analyzeRoutesResult;
60
+ Object.assign(import_namedRoutes.namedRoutes, namedRoutesMap);
61
+ if (!activeRoutePath) {
62
+ return /* @__PURE__ */ import_react.default.createElement(import_RscRoutes.RscRoutes, { pathname, search });
63
+ }
64
+ const requestedRoute = pathRouteMap[activeRoutePath];
65
+ const reversedSets = requestedRoute.sets.toReversed();
66
+ const privateSet = reversedSets.find((set) => set.isPrivate);
67
+ if (privateSet) {
68
+ const unauthenticated = privateSet.props.unauthenticated;
69
+ if (!unauthenticated || typeof unauthenticated !== "string") {
70
+ throw new Error(
71
+ "You must specify an `unauthenticated` route when using PrivateSet"
72
+ );
73
+ }
74
+ return /* @__PURE__ */ import_react.default.createElement(
75
+ import_router_context.RouterContextProvider,
76
+ {
77
+ useAuth,
78
+ paramTypes,
79
+ routes: analyzeRoutesResult,
80
+ activeRouteName: requestedRoute.name
81
+ },
82
+ /* @__PURE__ */ import_react.default.createElement(import_AuthenticatedRoute.AuthenticatedRoute, { unauthenticated }, /* @__PURE__ */ import_react.default.createElement(import_RscRoutes.RscRoutes, { pathname, search }))
83
+ );
84
+ }
85
+ return /* @__PURE__ */ import_react.default.createElement(import_RscRoutes.RscRoutes, { pathname, search });
86
+ };
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ Router
90
+ });
@@ -0,0 +1,23 @@
1
+ export interface RscModel {
2
+ __rwjs__Routes: [React.ReactElement];
3
+ __rwjs__rsa_data?: unknown;
4
+ }
5
+ /**
6
+ * This cache is used for RSC fetches, so that we don't re-fetch the same
7
+ * component (i.e. page) multiple times and get stuck in a loop.
8
+ *
9
+ * `key`: A stringified location-like object.
10
+ * `value`: A Promise that resolves to a React element.
11
+ */
12
+ export declare class RscCache {
13
+ private cache;
14
+ private socket;
15
+ private sendRetries;
16
+ private isEnabled;
17
+ constructor();
18
+ get(key: string): Thenable<RscModel> | undefined;
19
+ set(key: string, value: Thenable<RscModel>): void;
20
+ private sendToWebSocket;
21
+ private sendUpdateToWebSocket;
22
+ }
23
+ //# sourceMappingURL=RscCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RscCache.d.ts","sourceRoot":"","sources":["../../../src/rsc/RscCache.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,cAAc,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;IACpC,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED;;;;;;GAMG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAwC;IACrD,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,WAAW,CAAI;IAEvB,OAAO,CAAC,SAAS,CAAQ;;IAgDzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,SAAS;IAMhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC;IA2B1C,OAAO,CAAC,eAAe;IAsBvB,OAAO,CAAC,qBAAqB;CAW9B"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var RscCache_exports = {};
20
+ __export(RscCache_exports, {
21
+ RscCache: () => RscCache
22
+ });
23
+ module.exports = __toCommonJS(RscCache_exports);
24
+ class RscCache {
25
+ cache = /* @__PURE__ */ new Map();
26
+ socket;
27
+ sendRetries = 0;
28
+ // Turn the cache off for now. We can turn it on later if we decide we need it
29
+ isEnabled = false;
30
+ constructor() {
31
+ this.socket = new WebSocket("ws://localhost:18998");
32
+ this.socket.addEventListener("open", () => {
33
+ });
34
+ this.socket.addEventListener("message", (event) => {
35
+ if (event.data.startsWith("{")) {
36
+ const data = JSON.parse(event.data);
37
+ if (data.id === "rsc-cache-delete") {
38
+ if (!this.cache.has(data.key)) {
39
+ }
40
+ this.cache.delete(data.key);
41
+ this.sendUpdateToWebSocket();
42
+ } else if (data.id === "rsc-cache-clear") {
43
+ this.cache.clear();
44
+ this.sendToWebSocket("update", { fullCache: {} });
45
+ } else if (data.id === "rsc-cache-enable") {
46
+ this.isEnabled = true;
47
+ this.sendUpdateToWebSocket();
48
+ } else if (data.id === "rsc-cache-disable") {
49
+ this.isEnabled = false;
50
+ } else if (data.id === "rsc-cache-read") {
51
+ this.sendUpdateToWebSocket();
52
+ }
53
+ }
54
+ });
55
+ }
56
+ get(key) {
57
+ const value = this.cache.get(key);
58
+ console.log("RscCache.get", key, value);
59
+ return value;
60
+ }
61
+ set(key, value) {
62
+ console.log("RscCache.set", key, value);
63
+ if (!this.isEnabled) {
64
+ this.cache.clear();
65
+ }
66
+ this.cache.set(key, value);
67
+ value.then((_resolvedValue) => {
68
+ this.sendToWebSocket("set", {
69
+ updatedKey: key,
70
+ fullCache: Object.fromEntries(
71
+ Array.from(this.cache.entries()).map(
72
+ // @ts-expect-error hack to get the value of a Thenable
73
+ ([location, elementThenable]) => [location, elementThenable.value]
74
+ )
75
+ )
76
+ });
77
+ });
78
+ }
79
+ sendToWebSocket(action, payload) {
80
+ if (this.socket.readyState === WebSocket?.OPEN) {
81
+ this.sendRetries = 0;
82
+ this.socket.send(JSON.stringify({ id: "rsc-cache-" + action, payload }));
83
+ } else if (this.socket.readyState === WebSocket?.CONNECTING && this.sendRetries < 10) {
84
+ const backoff = 300 + this.sendRetries * 100;
85
+ setTimeout(() => {
86
+ this.sendRetries++;
87
+ this.sendToWebSocket(action, payload);
88
+ }, backoff);
89
+ } else if (this.sendRetries >= 10) {
90
+ console.error("Exhausted retries to send message to WebSocket server.");
91
+ } else {
92
+ console.error("WebSocket connection is closed.");
93
+ }
94
+ }
95
+ sendUpdateToWebSocket() {
96
+ this.sendToWebSocket("update", {
97
+ fullCache: Object.fromEntries(
98
+ Array.from(this.cache.entries()).map(([location, elementThenable]) => [
99
+ location,
100
+ // @ts-expect-error hack to get the value of a Thenable
101
+ elementThenable.value
102
+ ])
103
+ )
104
+ });
105
+ }
106
+ }
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ RscCache
110
+ });
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ pathname: string;
3
+ search: string;
4
+ }
5
+ export declare const RscRoutes: ({ pathname, search }: Props) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
6
+ export {};
7
+ //# sourceMappingURL=RscRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RscRoutes.d.ts","sourceRoot":"","sources":["../../../src/rsc/RscRoutes.tsx"],"names":[],"mappings":"AAiIA,UAAU,KAAK;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,SAAS,yBAA0B,KAAK,2FAkCpD,CAAA"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var RscRoutes_exports = {};
20
+ __export(RscRoutes_exports, {
21
+ RscRoutes: () => RscRoutes
22
+ });
23
+ module.exports = __toCommonJS(RscRoutes_exports);
24
+ var import_react = require("react");
25
+ var import_client = require("react-server-dom-webpack/client");
26
+ var import_RscCache = require("./RscCache.js");
27
+ const BASE_PATH = "/rw-rsc/";
28
+ const rscCache = new import_RscCache.RscCache();
29
+ let updateCurrentRscCacheKey = (key) => {
30
+ console.error("updateCurrentRscCacheKey called before it was set");
31
+ console.error("updateCurrentRscCacheKey key", key);
32
+ };
33
+ function onStreamFinished(fetchPromise, onFinished) {
34
+ return fetchPromise.then((response) => response.clone().text()).then(onFinished);
35
+ }
36
+ async function rsaFetch(serializedLocation, rsaId, rsaArgs) {
37
+ const rscId = "_";
38
+ const searchParams = new URLSearchParams();
39
+ searchParams.set("action_id", rsaId);
40
+ const url = BASE_PATH + rscId + "?" + searchParams + "&" + serializedLocation;
41
+ let body = "";
42
+ try {
43
+ body = await (0, import_client.encodeReply)(rsaArgs);
44
+ } catch (e) {
45
+ console.error("Error encoding Server Action arguments", e);
46
+ }
47
+ return fetch(url, {
48
+ method: "POST",
49
+ body,
50
+ headers: { "rw-rsc": "1" }
51
+ });
52
+ }
53
+ function rscFetch(serializedLocation) {
54
+ const rscId = "__rwjs__Routes";
55
+ return fetch(BASE_PATH + rscId + "?" + serializedLocation, {
56
+ headers: { "rw-rsc": "1" }
57
+ });
58
+ }
59
+ function rscFetchRoutes(serializedLocation) {
60
+ console.log(
61
+ "rscFetchRoutes :: args:\n serializedProps: " + serializedLocation
62
+ );
63
+ const rscCacheKey = serializedLocation;
64
+ const cached = rscCache.get(rscCacheKey);
65
+ if (cached) {
66
+ console.log("rscFetchRoutes :: cache hit for", rscCacheKey);
67
+ return cached;
68
+ } else {
69
+ console.log("rscFetchRoutes :: cache miss for", rscCacheKey);
70
+ }
71
+ const options = {
72
+ // React will hold on to `callServer` and use that when it detects a server
73
+ // action is invoked (like `action={onSubmit}` in a <form> element). So for
74
+ // now at least we need to send it with every RSC request, so React knows
75
+ // what `callServer` method to use for server actions inside the RSC.
76
+ // TODO (RSC): Need to figure out the types for callServer
77
+ // @ts-expect-error types
78
+ callServer: async function(rsaId, args) {
79
+ console.log("RscRoutes :: callServer rsaId", rsaId, "args", args);
80
+ const rscCacheKey2 = `${serializedLocation}::${rsaId}::${Date.now()}`;
81
+ const responsePromise = rsaFetch(serializedLocation, rsaId, args);
82
+ onStreamFinished(responsePromise, () => {
83
+ updateCurrentRscCacheKey(rscCacheKey2);
84
+ });
85
+ const modelPromise2 = (0, import_client.createFromFetch)(responsePromise, options);
86
+ rscCache.set(rscCacheKey2, modelPromise2);
87
+ const model = await modelPromise2;
88
+ return model.__rwjs__rsa_data;
89
+ }
90
+ };
91
+ const modelPromise = (0, import_client.createFromFetch)(rscFetch(serializedLocation), options);
92
+ rscCache.set(rscCacheKey, modelPromise);
93
+ return modelPromise;
94
+ }
95
+ const RscRoutes = ({ pathname, search }) => {
96
+ const serializedLocation = `__rwjs__pathname=${pathname}&__rwjs__search=${search}`;
97
+ const [currentRscCacheKey, setCurrentRscCacheKey] = (0, import_react.useState)(() => {
98
+ console.log("RscRoutes :: useState initial value");
99
+ rscFetchRoutes(serializedLocation);
100
+ return serializedLocation;
101
+ });
102
+ (0, import_react.useEffect)(() => {
103
+ console.log("RscRoutes :: useEffect set updateCurrentRscCacheKey");
104
+ updateCurrentRscCacheKey = (key) => {
105
+ console.log("RscRoutes inside updateCurrentRscCacheKey", key);
106
+ setCurrentRscCacheKey(key);
107
+ };
108
+ }, []);
109
+ (0, import_react.useEffect)(() => {
110
+ console.log("RscRoutes :: useEffect about to call rscFetchRoutes");
111
+ rscFetchRoutes(serializedLocation);
112
+ setCurrentRscCacheKey(serializedLocation);
113
+ }, [serializedLocation]);
114
+ console.log("RscRoutes :: rendering cache entry for\n" + currentRscCacheKey);
115
+ const rscModelPromise = rscCache.get(currentRscCacheKey);
116
+ if (!rscModelPromise) {
117
+ throw new Error("Missing RSC cache entry for " + currentRscCacheKey);
118
+ }
119
+ return (0, import_react.use)(rscModelPromise).__rwjs__Routes[0];
120
+ };
121
+ // Annotate the CommonJS export names for ESM import in node:
122
+ 0 && (module.exports = {
123
+ RscRoutes
124
+ });
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { Spec } from '../page.js';
3
+ interface Props {
4
+ path: string;
5
+ spec: Spec;
6
+ params?: Record<string, string>;
7
+ whileLoadingPage?: () => React.ReactNode | null;
8
+ children?: React.ReactNode;
9
+ }
10
+ export declare const ServerRouteLoader: ({ spec, params }: Props) => React.JSX.Element;
11
+ export {};
12
+ //# sourceMappingURL=ServerRouteLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerRouteLoader.d.ts","sourceRoot":"","sources":["../../../src/rsc/ServerRouteLoader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,gBAAgB,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,GAAG,IAAI,CAAA;IAC/C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,eAAO,MAAM,iBAAiB,qBAAsB,KAAK,sBA+BxD,CAAA"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var ServerRouteLoader_exports = {};
30
+ __export(ServerRouteLoader_exports, {
31
+ ServerRouteLoader: () => ServerRouteLoader
32
+ });
33
+ module.exports = __toCommonJS(ServerRouteLoader_exports);
34
+ var import_react = __toESM(require("react"), 1);
35
+ const ServerRouteLoader = ({ spec, params }) => {
36
+ const LazyRouteComponent = spec.LazyComponent;
37
+ if (params) {
38
+ delete params["ref"];
39
+ delete params["key"];
40
+ }
41
+ return /* @__PURE__ */ import_react.default.createElement(import_react.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement("div", null, "Loading...") }, /* @__PURE__ */ import_react.default.createElement(LazyRouteComponent, { ...params }), /* @__PURE__ */ import_react.default.createElement(
42
+ "div",
43
+ {
44
+ id: "redwood-announcer",
45
+ style: {
46
+ position: "absolute",
47
+ top: 0,
48
+ width: 1,
49
+ height: 1,
50
+ padding: 0,
51
+ overflow: "hidden",
52
+ clip: "rect(0, 0, 0, 0)",
53
+ whiteSpace: "nowrap",
54
+ border: 0
55
+ },
56
+ role: "alert",
57
+ "aria-live": "assertive",
58
+ "aria-atomic": "true"
59
+ }
60
+ ));
61
+ };
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ ServerRouteLoader
65
+ });
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from 'react';
2
+ import React from 'react';
3
+ import type { RouterContextProviderProps } from '../router-context.js';
4
+ import type { TrailingSlashesTypes } from '../util.js';
5
+ export interface RouterProps extends Omit<RouterContextProviderProps, 'routes' | 'activeRouteName'> {
6
+ trailingSlashes?: TrailingSlashesTypes;
7
+ pageLoadingDelay?: number;
8
+ children: ReactNode;
9
+ }
10
+ export declare const Router: React.FC<RouterProps>;
11
+ //# sourceMappingURL=ServerRouter.d.ts.map