@cedarjs/router 5.0.6 → 5.0.7-next.219

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 (142) hide show
  1. package/dist/Set.d.ts +8 -0
  2. package/dist/Set.d.ts.map +1 -1
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +14 -1
  6. package/package.json +26 -68
  7. package/dist/cjs/ActivePageContext.d.ts +0 -15
  8. package/dist/cjs/ActivePageContext.d.ts.map +0 -1
  9. package/dist/cjs/ActivePageContext.js +0 -42
  10. package/dist/cjs/AuthenticatedRoute.d.ts +0 -11
  11. package/dist/cjs/AuthenticatedRoute.d.ts.map +0 -1
  12. package/dist/cjs/AuthenticatedRoute.js +0 -83
  13. package/dist/cjs/PageLoadingContext.d.ts +0 -14
  14. package/dist/cjs/PageLoadingContext.d.ts.map +0 -1
  15. package/dist/cjs/PageLoadingContext.js +0 -64
  16. package/dist/cjs/Route.d.ts +0 -32
  17. package/dist/cjs/Route.d.ts.map +0 -1
  18. package/dist/cjs/Route.js +0 -41
  19. package/dist/cjs/Set.d.ts +0 -58
  20. package/dist/cjs/Set.d.ts.map +0 -1
  21. package/dist/cjs/Set.js +0 -67
  22. package/dist/cjs/a11yUtils.d.ts +0 -14
  23. package/dist/cjs/a11yUtils.d.ts.map +0 -1
  24. package/dist/cjs/a11yUtils.js +0 -61
  25. package/dist/cjs/active-route-loader.d.ts +0 -12
  26. package/dist/cjs/active-route-loader.d.ts.map +0 -1
  27. package/dist/cjs/active-route-loader.js +0 -116
  28. package/dist/cjs/analyzeRoutes.d.ts +0 -44
  29. package/dist/cjs/analyzeRoutes.d.ts.map +0 -1
  30. package/dist/cjs/analyzeRoutes.js +0 -143
  31. package/dist/cjs/createNamedContext.d.ts +0 -3
  32. package/dist/cjs/createNamedContext.d.ts.map +0 -1
  33. package/dist/cjs/createNamedContext.js +0 -33
  34. package/dist/cjs/dummyComponent.d.ts +0 -3
  35. package/dist/cjs/dummyComponent.d.ts.map +0 -1
  36. package/dist/cjs/dummyComponent.js +0 -24
  37. package/dist/cjs/history.d.ts +0 -24
  38. package/dist/cjs/history.d.ts.map +0 -1
  39. package/dist/cjs/history.js +0 -145
  40. package/dist/cjs/index.d.ts +0 -35
  41. package/dist/cjs/index.d.ts.map +0 -1
  42. package/dist/cjs/index.js +0 -110
  43. package/dist/cjs/link.d.ts +0 -9
  44. package/dist/cjs/link.d.ts.map +0 -1
  45. package/dist/cjs/link.js +0 -62
  46. package/dist/cjs/location.d.ts +0 -28
  47. package/dist/cjs/location.d.ts.map +0 -1
  48. package/dist/cjs/location.js +0 -110
  49. package/dist/cjs/namedRoutes.d.ts +0 -3
  50. package/dist/cjs/namedRoutes.d.ts.map +0 -1
  51. package/dist/cjs/namedRoutes.js +0 -28
  52. package/dist/cjs/navLink.d.ts +0 -11
  53. package/dist/cjs/navLink.d.ts.map +0 -1
  54. package/dist/cjs/navLink.js +0 -70
  55. package/dist/cjs/package.json +0 -1
  56. package/dist/cjs/page.d.ts +0 -28
  57. package/dist/cjs/page.d.ts.map +0 -1
  58. package/dist/cjs/page.js +0 -42
  59. package/dist/cjs/params.d.ts +0 -13
  60. package/dist/cjs/params.d.ts.map +0 -1
  61. package/dist/cjs/params.js +0 -64
  62. package/dist/cjs/react-util.d.ts +0 -3
  63. package/dist/cjs/react-util.d.ts.map +0 -1
  64. package/dist/cjs/react-util.js +0 -37
  65. package/dist/cjs/redirect.d.ts +0 -12
  66. package/dist/cjs/redirect.d.ts.map +0 -1
  67. package/dist/cjs/redirect.js +0 -35
  68. package/dist/cjs/route-announcement.d.ts +0 -13
  69. package/dist/cjs/route-announcement.d.ts.map +0 -1
  70. package/dist/cjs/route-announcement.js +0 -61
  71. package/dist/cjs/route-focus.d.ts +0 -12
  72. package/dist/cjs/route-focus.d.ts.map +0 -1
  73. package/dist/cjs/route-focus.js +0 -36
  74. package/dist/cjs/route-validators.d.ts +0 -21
  75. package/dist/cjs/route-validators.d.ts.map +0 -1
  76. package/dist/cjs/route-validators.js +0 -71
  77. package/dist/cjs/routeParamsTypes.d.ts +0 -49
  78. package/dist/cjs/routeParamsTypes.d.ts.map +0 -1
  79. package/dist/cjs/routeParamsTypes.js +0 -16
  80. package/dist/cjs/router-context.d.ts +0 -23
  81. package/dist/cjs/router-context.d.ts.map +0 -1
  82. package/dist/cjs/router-context.js +0 -69
  83. package/dist/cjs/router.d.ts +0 -11
  84. package/dist/cjs/router.d.ts.map +0 -1
  85. package/dist/cjs/router.js +0 -207
  86. package/dist/cjs/rsc/ClientRouter.d.ts +0 -4
  87. package/dist/cjs/rsc/ClientRouter.d.ts.map +0 -1
  88. package/dist/cjs/rsc/ClientRouter.js +0 -90
  89. package/dist/cjs/rsc/RscCache.d.ts +0 -23
  90. package/dist/cjs/rsc/RscCache.d.ts.map +0 -1
  91. package/dist/cjs/rsc/RscCache.js +0 -110
  92. package/dist/cjs/rsc/RscRoutes.d.ts +0 -7
  93. package/dist/cjs/rsc/RscRoutes.d.ts.map +0 -1
  94. package/dist/cjs/rsc/RscRoutes.js +0 -124
  95. package/dist/cjs/rsc/ServerRouteLoader.d.ts +0 -12
  96. package/dist/cjs/rsc/ServerRouteLoader.d.ts.map +0 -1
  97. package/dist/cjs/rsc/ServerRouteLoader.js +0 -65
  98. package/dist/cjs/rsc/ServerRouter.d.ts +0 -11
  99. package/dist/cjs/rsc/ServerRouter.d.ts.map +0 -1
  100. package/dist/cjs/rsc/ServerRouter.js +0 -170
  101. package/dist/cjs/rsc/SsrRouter.d.ts +0 -4
  102. package/dist/cjs/rsc/SsrRouter.d.ts.map +0 -1
  103. package/dist/cjs/rsc/SsrRouter.js +0 -56
  104. package/dist/cjs/rsc/clientSsr.d.ts +0 -2
  105. package/dist/cjs/rsc/clientSsr.d.ts.map +0 -1
  106. package/dist/cjs/rsc/clientSsr.js +0 -114
  107. package/dist/cjs/rsc/rscCss.d.ts +0 -2
  108. package/dist/cjs/rsc/rscCss.d.ts.map +0 -1
  109. package/dist/cjs/rsc/rscCss.js +0 -94
  110. package/dist/cjs/rsc/ssrModuleMap.d.ts +0 -14
  111. package/dist/cjs/rsc/ssrModuleMap.d.ts.map +0 -1
  112. package/dist/cjs/rsc/ssrModuleMap.js +0 -49
  113. package/dist/cjs/rsc/utils.d.ts +0 -22
  114. package/dist/cjs/rsc/utils.d.ts.map +0 -1
  115. package/dist/cjs/rsc/utils.js +0 -68
  116. package/dist/cjs/rsc-link.d.ts +0 -6
  117. package/dist/cjs/rsc-link.d.ts.map +0 -1
  118. package/dist/cjs/rsc-link.js +0 -41
  119. package/dist/cjs/skipNav.d.ts +0 -81
  120. package/dist/cjs/skipNav.d.ts.map +0 -1
  121. package/dist/cjs/skipNav.js +0 -69
  122. package/dist/cjs/splash-page.d.ts +0 -12
  123. package/dist/cjs/splash-page.d.ts.map +0 -1
  124. package/dist/cjs/splash-page.js +0 -503
  125. package/dist/cjs/useBlocker.d.ts +0 -11
  126. package/dist/cjs/useBlocker.d.ts.map +0 -1
  127. package/dist/cjs/useBlocker.js +0 -65
  128. package/dist/cjs/useIsMounted.d.ts +0 -2
  129. package/dist/cjs/useIsMounted.d.ts.map +0 -1
  130. package/dist/cjs/useIsMounted.js +0 -37
  131. package/dist/cjs/useMatch.d.ts +0 -43
  132. package/dist/cjs/useMatch.d.ts.map +0 -1
  133. package/dist/cjs/useMatch.js +0 -72
  134. package/dist/cjs/useRouteName.d.ts +0 -3
  135. package/dist/cjs/useRouteName.d.ts.map +0 -1
  136. package/dist/cjs/useRouteName.js +0 -40
  137. package/dist/cjs/useRoutePaths.d.ts +0 -4
  138. package/dist/cjs/useRoutePaths.d.ts.map +0 -1
  139. package/dist/cjs/useRoutePaths.js +0 -50
  140. package/dist/cjs/util.d.ts +0 -121
  141. package/dist/cjs/util.d.ts.map +0 -1
  142. package/dist/cjs/util.js +0 -214
package/dist/cjs/Set.js DELETED
@@ -1,67 +0,0 @@
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 Set_exports = {};
30
- __export(Set_exports, {
31
- Private: () => Private,
32
- PrivateSet: () => PrivateSet,
33
- Set: () => Set,
34
- isPrivateNode: () => isPrivateNode,
35
- isPrivateSetNode: () => isPrivateSetNode,
36
- isSetNode: () => isSetNode
37
- });
38
- module.exports = __toCommonJS(Set_exports);
39
- var import_react = __toESM(require("react"), 1);
40
- function Set(props) {
41
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, props.children);
42
- }
43
- function Private(props) {
44
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, props.children);
45
- }
46
- function PrivateSet(props) {
47
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, props.children);
48
- }
49
- const isSetNode = (node) => {
50
- return import_react.default.isValidElement(node) && (node.type === Set || node.type === PrivateSet || node.type === Private) && // Don't even bother including Sets without children. They're useless.
51
- node.props.children;
52
- };
53
- const isPrivateSetNode = (node) => {
54
- return import_react.default.isValidElement(node) && node.type === PrivateSet;
55
- };
56
- const isPrivateNode = (node) => {
57
- return import_react.default.isValidElement(node) && node.type === Private;
58
- };
59
- // Annotate the CommonJS export names for ESM import in node:
60
- 0 && (module.exports = {
61
- Private,
62
- PrivateSet,
63
- Set,
64
- isPrivateNode,
65
- isPrivateSetNode,
66
- isSetNode
67
- });
@@ -1,14 +0,0 @@
1
- /**
2
- * gets the announcement for the new page.
3
- * called in one of active-route-loader's `useEffect`.
4
- *
5
- * the order of priority is:
6
- * 1. RouteAnnouncement (the most specific one)
7
- * 2. h1
8
- * 3. document.title
9
- * 4. location.pathname
10
- */
11
- export declare const getAnnouncement: () => string;
12
- export declare const getFocus: () => HTMLElement | null;
13
- export declare const resetFocus: () => void;
14
- //# sourceMappingURL=a11yUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"a11yUtils.d.ts","sourceRoot":"","sources":["../../src/a11yUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,cAkB3B,CAAA;AAED,eAAO,MAAM,QAAQ,0BAapB,CAAA;AAGD,eAAO,MAAM,UAAU,YAItB,CAAA"}
@@ -1,61 +0,0 @@
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 a11yUtils_exports = {};
20
- __export(a11yUtils_exports, {
21
- getAnnouncement: () => getAnnouncement,
22
- getFocus: () => getFocus,
23
- resetFocus: () => resetFocus
24
- });
25
- module.exports = __toCommonJS(a11yUtils_exports);
26
- const getAnnouncement = () => {
27
- const routeAnnouncement = globalThis?.document.querySelectorAll(
28
- "[data-redwood-route-announcement]"
29
- )?.[0];
30
- if (routeAnnouncement?.textContent) {
31
- return routeAnnouncement.textContent;
32
- }
33
- const pageHeading = globalThis?.document.querySelector(`h1`);
34
- if (pageHeading?.textContent) {
35
- return pageHeading.textContent;
36
- }
37
- if (globalThis?.document.title) {
38
- return document.title;
39
- }
40
- return `new page at ${globalThis?.location.pathname}`;
41
- };
42
- const getFocus = () => {
43
- const routeFocus = globalThis?.document.querySelectorAll(
44
- "[data-redwood-route-focus]"
45
- )?.[0];
46
- if (!routeFocus?.children.length || routeFocus.children[0].tabIndex < 0) {
47
- return null;
48
- }
49
- return routeFocus.children[0];
50
- };
51
- const resetFocus = () => {
52
- globalThis?.document.body.setAttribute("tabindex", "-1");
53
- globalThis?.document.body.focus();
54
- globalThis?.document.body.removeAttribute("tabindex");
55
- };
56
- // Annotate the CommonJS export names for ESM import in node:
57
- 0 && (module.exports = {
58
- getAnnouncement,
59
- getFocus,
60
- resetFocus
61
- });
@@ -1,12 +0,0 @@
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 ActiveRouteLoader: ({ spec, params, whileLoadingPage, }: Props) => React.JSX.Element;
11
- export {};
12
- //# sourceMappingURL=active-route-loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"active-route-loader.d.ts","sourceRoot":"","sources":["../../src/active-route-loader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAG1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIrC,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;AAmCD,eAAO,MAAM,iBAAiB,GAAI,qCAI/B,KAAK,sBAmEP,CAAA"}
@@ -1,116 +0,0 @@
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 active_route_loader_exports = {};
30
- __export(active_route_loader_exports, {
31
- ActiveRouteLoader: () => ActiveRouteLoader
32
- });
33
- module.exports = __toCommonJS(active_route_loader_exports);
34
- var import_react = __toESM(require("react"), 1);
35
- var import_a11yUtils = require("./a11yUtils.js");
36
- var import_PageLoadingContext = require("./PageLoadingContext.js");
37
- var import_util = require("./util.js");
38
- let isPrerendered = false;
39
- if (typeof window !== "undefined") {
40
- const cedarAppElement = document.getElementById("cedar-app") ?? document.getElementById("redwood-app");
41
- if (cedarAppElement && cedarAppElement.children.length > 0) {
42
- isPrerendered = true;
43
- }
44
- }
45
- let firstLoad = true;
46
- const Fallback = ({ children }) => {
47
- const { loading, setPageLoadingContext, delay } = (0, import_PageLoadingContext.usePageLoadingContext)();
48
- (0, import_react.useEffect)(() => {
49
- const timer = setTimeout(() => {
50
- setPageLoadingContext(true);
51
- }, delay);
52
- return () => {
53
- clearTimeout(timer);
54
- setPageLoadingContext(false);
55
- };
56
- }, [delay, setPageLoadingContext]);
57
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, loading ? children : null);
58
- };
59
- const ActiveRouteLoader = ({
60
- spec,
61
- params,
62
- whileLoadingPage
63
- }) => {
64
- const announcementRef = (0, import_react.useRef)(null);
65
- const usePrerenderLoader = (
66
- // Prerendering doesn't work with Streaming/SSR yet. So we disable it.
67
- !globalThis.RWJS_EXP_STREAMING_SSR && (globalThis.__REDWOOD__PRERENDERING || isPrerendered && firstLoad)
68
- );
69
- const LazyRouteComponent = usePrerenderLoader ? spec.prerenderLoader(spec.name).default : spec.LazyComponent;
70
- if (firstLoad) {
71
- firstLoad = false;
72
- }
73
- (0, import_react.useEffect)(() => {
74
- if ((0, import_util.inIframe)()) {
75
- return;
76
- }
77
- if (announcementRef.current) {
78
- announcementRef.current.innerText = (0, import_a11yUtils.getAnnouncement)();
79
- }
80
- const routeFocus = (0, import_a11yUtils.getFocus)();
81
- if (!routeFocus) {
82
- (0, import_a11yUtils.resetFocus)();
83
- } else {
84
- routeFocus.focus();
85
- }
86
- }, [spec, params]);
87
- if (params) {
88
- delete params["ref"];
89
- delete params["key"];
90
- }
91
- return /* @__PURE__ */ import_react.default.createElement(import_react.Suspense, { fallback: /* @__PURE__ */ import_react.default.createElement(Fallback, null, whileLoadingPage?.()) }, /* @__PURE__ */ import_react.default.createElement(LazyRouteComponent, { ...params }), /* @__PURE__ */ import_react.default.createElement(
92
- "div",
93
- {
94
- id: "redwood-announcer",
95
- style: {
96
- position: "absolute",
97
- top: 0,
98
- width: 1,
99
- height: 1,
100
- padding: 0,
101
- overflow: "hidden",
102
- clip: "rect(0, 0, 0, 0)",
103
- whiteSpace: "nowrap",
104
- border: 0
105
- },
106
- role: "alert",
107
- "aria-live": "assertive",
108
- "aria-atomic": "true",
109
- ref: announcementRef
110
- }
111
- ));
112
- };
113
- // Annotate the CommonJS export names for ESM import in node:
114
- 0 && (module.exports = {
115
- ActiveRouteLoader
116
- });
@@ -1,44 +0,0 @@
1
- import type { ReactElement, ReactNode } from 'react';
2
- import type { PageType } from './page.js';
3
- import { type ParamType } from './util.js';
4
- type WhileLoadingPage = () => ReactElement | null;
5
- export type GeneratedRoutesMap = {
6
- [key: string]: (args?: Record<string | number, string | number | boolean>) => string;
7
- };
8
- export type Wrappers = ((props: any) => ReactNode)[];
9
- interface Set {
10
- id: string;
11
- wrappers: Wrappers;
12
- isPrivate: boolean;
13
- props: {
14
- private?: boolean;
15
- [key: string]: unknown;
16
- };
17
- }
18
- type RoutePath = string;
19
- /**
20
- * This is essentially the same as RouteProps
21
- * but it allows for page and redirect to be null or undefined
22
- * Keeping the shape consistent makes it easier to use
23
- */
24
- interface AnalyzedRoute {
25
- path: RoutePath;
26
- name: string | null;
27
- whileLoadingPage?: WhileLoadingPage;
28
- page: PageType | null;
29
- redirect: string | null;
30
- sets: Set[];
31
- }
32
- interface AnalyzeRoutesOptions {
33
- currentPathName: string;
34
- userParamTypes?: Record<string, ParamType>;
35
- }
36
- export declare function analyzeRoutes(children: ReactNode, { currentPathName, userParamTypes }: AnalyzeRoutesOptions): {
37
- pathRouteMap: Record<string, AnalyzedRoute>;
38
- namedRoutesMap: GeneratedRoutesMap;
39
- hasRootRoute: boolean;
40
- NotFoundPage: PageType | undefined;
41
- activeRoutePath: string | undefined;
42
- };
43
- export {};
44
- //# sourceMappingURL=analyzeRoutes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analyzeRoutes.d.ts","sourceRoot":"","sources":["../../src/analyzeRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAQzC,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,WAAW,CAAA;AAElB,KAAK,gBAAgB,GAAG,MAAM,YAAY,GAAG,IAAI,CAAA;AAIjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,CACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,KACtD,MAAM,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,SAAS,CAAC,EAAE,CAAA;AAEpD,UAAU,GAAG;IACX,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE;QACL,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,CAAA;CACF;AAED,KAAK,SAAS,GAAG,MAAM,CAAA;AAEvB;;;;GAIG;AACH,UAAU,aAAa;IACrB,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,IAAI,EAAE,GAAG,EAAE,CAAA;CACZ;AAED,UAAU,oBAAoB;IAC5B,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAC3C;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,EACnB,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,oBAAoB;;;;;;EA6K1D"}
@@ -1,143 +0,0 @@
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 analyzeRoutes_exports = {};
20
- __export(analyzeRoutes_exports, {
21
- analyzeRoutes: () => analyzeRoutes
22
- });
23
- module.exports = __toCommonJS(analyzeRoutes_exports);
24
- var import_react = require("react");
25
- var import_route_validators = require("./route-validators.js");
26
- var import_Set = require("./Set.js");
27
- var import_util = require("./util.js");
28
- function analyzeRoutes(children, { currentPathName, userParamTypes }) {
29
- const pathRouteMap = {};
30
- const namedRoutesMap = {};
31
- let hasRootRoute = false;
32
- let NotFoundPage;
33
- let activeRoutePath;
34
- const recurseThroughRouter = ({
35
- nodes,
36
- whileLoadingPageFromSet,
37
- sets: previousSets = []
38
- }) => {
39
- let nextSetId = 0;
40
- nodes.forEach((node) => {
41
- if ((0, import_route_validators.isValidRoute)(node)) {
42
- const route = node;
43
- if ((0, import_route_validators.isNotFoundRoute)(route)) {
44
- NotFoundPage = route.props.page;
45
- return;
46
- }
47
- if (route.props.path === "/") {
48
- hasRootRoute = true;
49
- }
50
- if ((0, import_route_validators.isRedirectRoute)(route)) {
51
- const { name, redirect, path } = route.props;
52
- (0, import_util.validatePath)(path, name || path);
53
- const { match } = (0, import_util.matchPath)(path, currentPathName, {
54
- userParamTypes
55
- });
56
- if (match && !activeRoutePath) {
57
- activeRoutePath = path;
58
- }
59
- pathRouteMap[path] = {
60
- redirect,
61
- name: name || null,
62
- path,
63
- page: null,
64
- // Redirects don't need pages. We set this to null for consistency
65
- sets: previousSets
66
- };
67
- if (name) {
68
- namedRoutesMap[name] = (args = {}) => (0, import_util.replaceParams)(path, args);
69
- }
70
- }
71
- if ((0, import_route_validators.isStandardRoute)(route)) {
72
- const { name, path, page } = route.props;
73
- (0, import_util.validatePath)(path, name);
74
- const { match } = (0, import_util.matchPath)(path, currentPathName, {
75
- userParamTypes
76
- });
77
- if (match && !activeRoutePath) {
78
- activeRoutePath = path;
79
- }
80
- pathRouteMap[path] = {
81
- redirect: null,
82
- name,
83
- path,
84
- whileLoadingPage: route.props.whileLoadingPage || whileLoadingPageFromSet,
85
- page,
86
- sets: previousSets
87
- };
88
- namedRoutesMap[name] = (args = {}) => (0, import_util.replaceParams)(path, args);
89
- }
90
- }
91
- if ((0, import_Set.isSetNode)(node)) {
92
- const {
93
- children: children2,
94
- whileLoadingPage: whileLoadingPageFromCurrentSet,
95
- wrap: wrapFromCurrentSet,
96
- ...otherPropsFromCurrentSet
97
- } = node.props;
98
- let wrapperComponentsArray = [];
99
- if (wrapFromCurrentSet) {
100
- wrapperComponentsArray = Array.isArray(wrapFromCurrentSet) ? wrapFromCurrentSet : [wrapFromCurrentSet];
101
- }
102
- nextSetId = nextSetId + 1;
103
- recurseThroughRouter({
104
- nodes: import_react.Children.toArray(children2),
105
- // When there's a whileLoadingPage prop on a Set, we pass it down to all its children
106
- // If the parent node was also a Set with whileLoadingPage, we pass it down. The child's whileLoadingPage
107
- // will always take precedence over the parent's
108
- whileLoadingPageFromSet: whileLoadingPageFromCurrentSet || whileLoadingPageFromSet,
109
- sets: [
110
- ...previousSets,
111
- {
112
- id: createSetId(nextSetId, previousSets),
113
- wrappers: wrapperComponentsArray,
114
- isPrivate: (0, import_Set.isPrivateSetNode)(node) || // The following two conditions can be removed when we remove
115
- // the deprecated private prop
116
- (0, import_Set.isPrivateNode)(node) || !!otherPropsFromCurrentSet.private,
117
- props: otherPropsFromCurrentSet
118
- }
119
- ]
120
- });
121
- }
122
- });
123
- };
124
- recurseThroughRouter({ nodes: import_react.Children.toArray(children) });
125
- return {
126
- pathRouteMap,
127
- namedRoutesMap,
128
- hasRootRoute,
129
- NotFoundPage,
130
- activeRoutePath
131
- };
132
- }
133
- function createSetId(nextSetId, previousSets) {
134
- const firstLevel = previousSets.length === 0;
135
- if (firstLevel) {
136
- return nextSetId.toString();
137
- }
138
- return previousSets.at(-1)?.id + "." + nextSetId;
139
- }
140
- // Annotate the CommonJS export names for ESM import in node:
141
- 0 && (module.exports = {
142
- analyzeRoutes
143
- });
@@ -1,3 +0,0 @@
1
- /** Create a React Context with the given name. */
2
- export declare function createNamedContext<T>(name: string, defaultValue?: T): import("react").Context<T | undefined>;
3
- //# sourceMappingURL=createNamedContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createNamedContext.d.ts","sourceRoot":"","sources":["../../src/createNamedContext.ts"],"names":[],"mappings":"AAEA,kDAAkD;AAClD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,0CAInE"}
@@ -1,33 +0,0 @@
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 createNamedContext_exports = {};
20
- __export(createNamedContext_exports, {
21
- createNamedContext: () => createNamedContext
22
- });
23
- module.exports = __toCommonJS(createNamedContext_exports);
24
- var import_react = require("react");
25
- function createNamedContext(name, defaultValue) {
26
- const Ctx = (0, import_react.createContext)(defaultValue);
27
- Ctx.displayName = name;
28
- return Ctx;
29
- }
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- createNamedContext
33
- });
@@ -1,3 +0,0 @@
1
- declare const _default: () => null;
2
- export default _default;
3
- //# sourceMappingURL=dummyComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dummyComponent.d.ts","sourceRoot":"","sources":["../../src/dummyComponent.ts"],"names":[],"mappings":";AAEA,wBAAyB"}
@@ -1,24 +0,0 @@
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 dummyComponent_exports = {};
20
- __export(dummyComponent_exports, {
21
- default: () => dummyComponent_default
22
- });
23
- module.exports = __toCommonJS(dummyComponent_exports);
24
- var dummyComponent_default = () => null;
@@ -1,24 +0,0 @@
1
- export interface NavigateOptions {
2
- replace?: boolean;
3
- scroll?: boolean;
4
- }
5
- export type Listener = (ev?: PopStateEvent, options?: NavigateOptions) => any;
6
- export type BeforeUnloadListener = (ev: BeforeUnloadEvent) => any;
7
- export type BlockerCallback = (tx: {
8
- retry: () => void;
9
- }) => void;
10
- export type Blocker = {
11
- id: string;
12
- callback: BlockerCallback;
13
- };
14
- declare const gHistory: {
15
- listen: (listener: Listener) => string;
16
- navigate: (to: string, options?: NavigateOptions) => void;
17
- back: () => void;
18
- remove: (listenerId: string) => void;
19
- block: (id: string, callback: BlockerCallback) => void;
20
- unblock: (id: string) => void;
21
- };
22
- declare const navigate: (to: string, options?: NavigateOptions) => void, back: () => void, block: (id: string, callback: BlockerCallback) => void, unblock: (id: string) => void;
23
- export { gHistory, navigate, back, block, unblock };
24
- //# sourceMappingURL=history.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/history.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,GAAG,CAAA;AAC7E,MAAM,MAAM,oBAAoB,GAAG,CAAC,EAAE,EAAE,iBAAiB,KAAK,GAAG,CAAA;AACjE,MAAM,MAAM,eAAe,GAAG,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,KAAK,IAAI,CAAA;AACjE,MAAM,MAAM,OAAO,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAA;AAkI/D,QAAA,MAAM,QAAQ;uBA1HS,QAAQ;mBASrB,MAAM,YACD,eAAe;;yBA8CL,MAAM;gBASf,MAAM,YAAY,eAAe;kBAc/B,MAAM;CA2CQ,CAAA;AAEhC,QAAA,MAAQ,QAAQ,OAnHN,MAAM,YACD,eAAe,WAkHZ,IAAI,cAAE,KAAK,OA3Db,MAAM,YAAY,eAAe,WA2DlB,OAAO,OA7CpB,MAAM,SA6C2B,CAAA;AAEnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA"}