@cedarjs/router 7.0.1-next.333 → 7.0.1-next.467
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.
- package/dist/Set.d.ts +50 -21
- package/dist/Set.d.ts.map +1 -1
- package/dist/Set.js +7 -1
- package/dist/analyzeRoutes.d.ts +13 -5
- package/dist/analyzeRoutes.d.ts.map +1 -1
- package/dist/analyzeRoutes.js +29 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +11 -8
- package/dist/rsc/ServerRouter.d.ts.map +1 -1
- package/dist/rsc/ServerRouter.js +11 -8
- package/package.json +9 -9
package/dist/Set.d.ts
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
-
import type { ReactElement, ReactNode } from 'react';
|
|
1
|
+
import type { ComponentType, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The props `<Set>` gives each component in its `wrap` prop: the wrapped
|
|
5
|
+
* routes as `children`, and nothing else
|
|
6
|
+
*/
|
|
7
|
+
export interface WrapperProps {
|
|
4
8
|
children: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A component in a `<Set wrap>` prop, like a layout. The router renders it
|
|
12
|
+
* with {@link WrapperProps}, so it can't have any other required props.
|
|
13
|
+
* Optional props are fine.
|
|
14
|
+
*
|
|
15
|
+
* To render a layout with props, create a component that renders it with
|
|
16
|
+
* those props, and use that component in `wrap`:
|
|
17
|
+
*
|
|
18
|
+
* function PostsScaffoldLayout({ children }: WrapperProps) {
|
|
19
|
+
* return <ScaffoldLayout title="Posts" titleTo="posts">{children}</ScaffoldLayout>
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* <Set wrap={PostsScaffoldLayout}>
|
|
23
|
+
*/
|
|
24
|
+
export type WrapperType = ComponentType<WrapperProps>;
|
|
25
|
+
interface SetProps {
|
|
7
26
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* <Set
|
|
27
|
+
* Components to wrap all routes in this set with, like layouts. The first
|
|
28
|
+
* one in an array is the outermost one.
|
|
29
|
+
*
|
|
30
|
+
* <Set wrap={[MainLayout, DarkThemeLayout]}>
|
|
12
31
|
*/
|
|
13
|
-
wrap?: WrapperType
|
|
32
|
+
wrap?: WrapperType | readonly WrapperType[];
|
|
14
33
|
/**
|
|
15
34
|
*`Routes` nested in a `<Set>` with `private` specified require
|
|
16
35
|
* authentication. When a user is not authenticated and attempts to visit
|
|
@@ -36,20 +55,22 @@ type SetProps<P> = P & {
|
|
|
36
55
|
/** Loading state for auth to distinguish with whileLoading */
|
|
37
56
|
whileLoadingAuth?: () => ReactElement | null;
|
|
38
57
|
whileLoadingPage?: () => ReactElement | null;
|
|
39
|
-
}
|
|
58
|
+
}
|
|
40
59
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* <Set
|
|
60
|
+
* Groups routes, to wrap them all in the same layouts or other components, or
|
|
61
|
+
* to give them all the same `whileLoadingPage` or `prerender` setting.
|
|
62
|
+
*
|
|
63
|
+
* <Set wrap={MainLayout}>
|
|
64
|
+
* <Route path="/" page={HomePage} name="home" />
|
|
65
|
+
* </Set>
|
|
45
66
|
*/
|
|
46
|
-
export declare function Set
|
|
47
|
-
type PrivateSetProps
|
|
67
|
+
export declare function Set(props: SetProps): React.JSX.Element;
|
|
68
|
+
type PrivateSetProps = Omit<SetProps, 'private' | 'unauthenticated'> & {
|
|
48
69
|
/** The page name where a user will be redirected when not authenticated */
|
|
49
70
|
unauthenticated: string;
|
|
50
71
|
};
|
|
51
72
|
/** @deprecated Please use `<PrivateSet>` instead */
|
|
52
|
-
export declare function Private
|
|
73
|
+
export declare function Private(props: PrivateSetProps): React.JSX.Element;
|
|
53
74
|
/**
|
|
54
75
|
* Wraps a set of routes that require the user to be authenticated before
|
|
55
76
|
* rendering. Unauthenticated users are redirected to the route named by
|
|
@@ -58,9 +79,17 @@ export declare function Private<WrapperProps>(props: PrivateSetProps<WrapperProp
|
|
|
58
79
|
* Coming from React Router or a similar library and looking for something
|
|
59
80
|
* like `RequireAuth` or `ProtectedRoute`? This is the Cedar equivalent.
|
|
60
81
|
*/
|
|
61
|
-
export declare function PrivateSet
|
|
62
|
-
export declare const isSetNode: (node: ReactNode) => node is ReactElement<SetProps
|
|
63
|
-
export declare const isPrivateSetNode: (node: ReactNode) => node is ReactElement<PrivateSetProps
|
|
64
|
-
export declare const isPrivateNode: (node: ReactNode) => node is ReactElement<
|
|
82
|
+
export declare function PrivateSet(props: PrivateSetProps): React.JSX.Element;
|
|
83
|
+
export declare const isSetNode: (node: ReactNode) => node is ReactElement<SetProps>;
|
|
84
|
+
export declare const isPrivateSetNode: (node: ReactNode) => node is ReactElement<PrivateSetProps>;
|
|
85
|
+
export declare const isPrivateNode: (node: ReactNode) => node is ReactElement<PrivateSetProps>;
|
|
86
|
+
/**
|
|
87
|
+
* Wraps `children` in all `wrappers`, with the first wrapper as the outermost
|
|
88
|
+
* one. Every wrapper gets `children` as its only prop.
|
|
89
|
+
*
|
|
90
|
+
* wrapWithSetWrappers([A, B], '1', <Page />)
|
|
91
|
+
* // => <A><B><Page /></B></A>
|
|
92
|
+
*/
|
|
93
|
+
export declare function wrapWithSetWrappers(wrappers: readonly WrapperType[], setId: string, children: ReactNode): ReactNode;
|
|
65
94
|
export {};
|
|
66
95
|
//# sourceMappingURL=Set.d.ts.map
|
package/dist/Set.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Set.d.ts","sourceRoot":"","sources":["../src/Set.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Set.d.ts","sourceRoot":"","s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,eAAO,MAAM,gBAAgB,GAC3B,MAAM,SAAS,KACd,IAAI,IAAI,YAAY,CAAC,eAAe,CAEtC,CAAA;AAGD,eAAO,MAAM,aAAa,GACxB,MAAM,SAAS,KACd,IAAI,IAAI,YAAY,CAAC,eAAe,CAEtC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,SAAS,WAAW,EAAE,EAChC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,SAAS,aAKpB"}
|
package/dist/Set.js
CHANGED
|
@@ -18,11 +18,17 @@ const isPrivateSetNode = (node) => {
|
|
|
18
18
|
const isPrivateNode = (node) => {
|
|
19
19
|
return React.isValidElement(node) && node.type === Private;
|
|
20
20
|
};
|
|
21
|
+
function wrapWithSetWrappers(wrappers, setId, children) {
|
|
22
|
+
return wrappers.reduceRight((acc, Wrapper, index) => {
|
|
23
|
+
return /* @__PURE__ */ React.createElement(Wrapper, { key: setId + "-" + index }, acc);
|
|
24
|
+
}, children);
|
|
25
|
+
}
|
|
21
26
|
export {
|
|
22
27
|
Private,
|
|
23
28
|
PrivateSet,
|
|
24
29
|
Set,
|
|
25
30
|
isPrivateNode,
|
|
26
31
|
isPrivateSetNode,
|
|
27
|
-
isSetNode
|
|
32
|
+
isSetNode,
|
|
33
|
+
wrapWithSetWrappers
|
|
28
34
|
};
|
package/dist/analyzeRoutes.d.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import type { PageType } from './page.js';
|
|
3
|
+
import type { WrapperType } from './Set.js';
|
|
3
4
|
import { type ParamType } from './util.js';
|
|
4
5
|
type WhileLoadingPage = () => ReactElement | null;
|
|
5
6
|
export type GeneratedRoutesMap = {
|
|
6
7
|
[key: string]: (args?: Record<string | number, string | number | boolean>) => string;
|
|
7
8
|
};
|
|
8
|
-
export type Wrappers =
|
|
9
|
+
export type Wrappers = readonly WrapperType[];
|
|
10
|
+
/**
|
|
11
|
+
* The props of a `<Set>`, `<PrivateSet>` or `<Private>` that the router needs
|
|
12
|
+
* when rendering a route in it
|
|
13
|
+
*/
|
|
14
|
+
interface SetRenderProps {
|
|
15
|
+
private?: boolean;
|
|
16
|
+
unauthenticated?: string;
|
|
17
|
+
roles?: string | string[];
|
|
18
|
+
whileLoadingAuth?: () => ReactElement | null;
|
|
19
|
+
}
|
|
9
20
|
interface Set {
|
|
10
21
|
id: string;
|
|
11
22
|
wrappers: Wrappers;
|
|
12
23
|
isPrivate: boolean;
|
|
13
|
-
props:
|
|
14
|
-
private?: boolean;
|
|
15
|
-
[key: string]: unknown;
|
|
16
|
-
};
|
|
24
|
+
props: SetRenderProps;
|
|
17
25
|
}
|
|
18
26
|
type RoutePath = string;
|
|
19
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"analyzeRoutes.d.ts","sourceRoot":"","sources":["../src/analyzeRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,O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AE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAC3C;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,SAAS,EACnB,EAAE,eAAe,EAAE,cAAc,EAAE,EAAE,oBAAoB;;;;;;EAqK1D"}
|
package/dist/analyzeRoutes.js
CHANGED
|
@@ -11,6 +11,31 @@ import {
|
|
|
11
11
|
replaceParams,
|
|
12
12
|
validatePath
|
|
13
13
|
} from "./util.js";
|
|
14
|
+
function pickSetRenderProps(props) {
|
|
15
|
+
const picked = {};
|
|
16
|
+
if (props.private !== void 0) {
|
|
17
|
+
picked.private = props.private;
|
|
18
|
+
}
|
|
19
|
+
if (props.unauthenticated !== void 0) {
|
|
20
|
+
picked.unauthenticated = props.unauthenticated;
|
|
21
|
+
}
|
|
22
|
+
if (props.roles !== void 0) {
|
|
23
|
+
picked.roles = props.roles;
|
|
24
|
+
}
|
|
25
|
+
if (props.whileLoadingAuth !== void 0) {
|
|
26
|
+
picked.whileLoadingAuth = props.whileLoadingAuth;
|
|
27
|
+
}
|
|
28
|
+
return picked;
|
|
29
|
+
}
|
|
30
|
+
function toWrappersArray(wrap) {
|
|
31
|
+
if (!wrap) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
return isSingleWrapper(wrap) ? [wrap] : wrap;
|
|
35
|
+
}
|
|
36
|
+
function isSingleWrapper(wrap) {
|
|
37
|
+
return !Array.isArray(wrap);
|
|
38
|
+
}
|
|
14
39
|
function analyzeRoutes(children, { currentPathName, userParamTypes }) {
|
|
15
40
|
const pathRouteMap = {};
|
|
16
41
|
const namedRoutesMap = {};
|
|
@@ -78,13 +103,8 @@ function analyzeRoutes(children, { currentPathName, userParamTypes }) {
|
|
|
78
103
|
const {
|
|
79
104
|
children: children2,
|
|
80
105
|
whileLoadingPage: whileLoadingPageFromCurrentSet,
|
|
81
|
-
wrap: wrapFromCurrentSet
|
|
82
|
-
...otherPropsFromCurrentSet
|
|
106
|
+
wrap: wrapFromCurrentSet
|
|
83
107
|
} = node.props;
|
|
84
|
-
let wrapperComponentsArray = [];
|
|
85
|
-
if (wrapFromCurrentSet) {
|
|
86
|
-
wrapperComponentsArray = Array.isArray(wrapFromCurrentSet) ? wrapFromCurrentSet : [wrapFromCurrentSet];
|
|
87
|
-
}
|
|
88
108
|
nextSetId = nextSetId + 1;
|
|
89
109
|
recurseThroughRouter({
|
|
90
110
|
nodes: Children.toArray(children2),
|
|
@@ -96,11 +116,11 @@ function analyzeRoutes(children, { currentPathName, userParamTypes }) {
|
|
|
96
116
|
...previousSets,
|
|
97
117
|
{
|
|
98
118
|
id: createSetId(nextSetId, previousSets),
|
|
99
|
-
wrappers:
|
|
119
|
+
wrappers: toWrappersArray(wrapFromCurrentSet),
|
|
100
120
|
isPrivate: isPrivateSetNode(node) || // The following two conditions can be removed when we remove
|
|
101
121
|
// the deprecated private prop
|
|
102
|
-
isPrivateNode(node) || !!
|
|
103
|
-
props:
|
|
122
|
+
isPrivateNode(node) || !!node.props.private,
|
|
123
|
+
props: pickSetRenderProps(node.props)
|
|
104
124
|
}
|
|
105
125
|
]
|
|
106
126
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { Router } from './router.js';
|
|
|
9
9
|
export { Route } from './Route.js';
|
|
10
10
|
export { namedRoutes as routes } from './namedRoutes.js';
|
|
11
11
|
export { Set, Private, PrivateSet, isSetNode, isPrivateSetNode, isPrivateNode, } from './Set.js';
|
|
12
|
-
export type { WrapperType } from './Set.js';
|
|
12
|
+
export type { WrapperProps, WrapperType } from './Set.js';
|
|
13
13
|
export { default as RouteAnnouncement } from './route-announcement.js';
|
|
14
14
|
export * from './route-announcement.js';
|
|
15
15
|
export { default as RouteFocus } from './route-focus.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,IAAI,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AE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,WAAW,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAExD,OAAO,EACL,GAAG,EACH,OAAO,EACP,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,aAAa,GACd,MAAM,UAAU,CAAA;AACjB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEzD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AACtE,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACxD,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAE/B,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1E,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE1D;;;;;;;;;GASG;AAGH,MAAM,WAAW,eAAe;CAAG;AAGnC,cAAc,uBAAuB,CAAA"}
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAwB,MAAM,OAAO,CAAA;AAY5C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAA;AAKrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAErD,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,0BAA0B,EAC1B,QAAQ,GAAG,iBAAiB,CAC7B;IACC,eAAe,CAAC,EAAE,oBAAoB,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAoBxC,CAAA"}
|
package/dist/router.js
CHANGED
|
@@ -9,6 +9,7 @@ import { PageLoadingContextProvider } from "./PageLoadingContext.js";
|
|
|
9
9
|
import { ParamsProvider } from "./params.js";
|
|
10
10
|
import { Redirect } from "./redirect.js";
|
|
11
11
|
import { RouterContextProvider } from "./router-context.js";
|
|
12
|
+
import { wrapWithSetWrappers } from "./Set.js";
|
|
12
13
|
import { SplashPage } from "./splash-page.js";
|
|
13
14
|
import { matchPath, parseSearch, replaceParams, validatePath } from "./util.js";
|
|
14
15
|
const Router = ({
|
|
@@ -141,13 +142,7 @@ const WrappedPage = memo(({ sets, children }) => {
|
|
|
141
142
|
return children;
|
|
142
143
|
}
|
|
143
144
|
return sets.reduceRight((acc, set) => {
|
|
144
|
-
let wrapped = set.wrappers
|
|
145
|
-
return React.createElement(
|
|
146
|
-
Wrapper,
|
|
147
|
-
{ ...set.props, key: set.id + "-" + index },
|
|
148
|
-
acc2
|
|
149
|
-
);
|
|
150
|
-
}, acc);
|
|
145
|
+
let wrapped = wrapWithSetWrappers(set.wrappers, set.id, acc);
|
|
151
146
|
if (set.isPrivate) {
|
|
152
147
|
const unauthenticated = set.props.unauthenticated;
|
|
153
148
|
if (!unauthenticated || typeof unauthenticated !== "string") {
|
|
@@ -155,7 +150,15 @@ const WrappedPage = memo(({ sets, children }) => {
|
|
|
155
150
|
"You must specify an `unauthenticated` route when using PrivateSet"
|
|
156
151
|
);
|
|
157
152
|
}
|
|
158
|
-
wrapped = /* @__PURE__ */ React.createElement(
|
|
153
|
+
wrapped = /* @__PURE__ */ React.createElement(
|
|
154
|
+
AuthenticatedRoute,
|
|
155
|
+
{
|
|
156
|
+
unauthenticated,
|
|
157
|
+
roles: set.props.roles,
|
|
158
|
+
whileLoadingAuth: set.props.whileLoadingAuth
|
|
159
|
+
},
|
|
160
|
+
wrapped
|
|
161
|
+
);
|
|
159
162
|
}
|
|
160
163
|
return wrapped;
|
|
161
164
|
}, children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerRouter.d.ts","sourceRoot":"","sources":["../../src/rsc/ServerRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ServerRouter.d.ts","sourceRoot":"","sources":["../../src/rsc/ServerRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AAGtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKtD,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,0BAA0B,EAC1B,QAAQ,GAAG,iBAAiB,CAC7B;IACC,eAAe,CAAC,EAAE,oBAAoB,CAAA;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA4GxC,CAAA"}
|
package/dist/rsc/ServerRouter.js
CHANGED
|
@@ -3,6 +3,7 @@ import { getAuthState, getLocation } from "@cedarjs/server-store";
|
|
|
3
3
|
import { analyzeRoutes } from "../analyzeRoutes.js";
|
|
4
4
|
import { namedRoutes } from "../namedRoutes.js";
|
|
5
5
|
import { normalizePage } from "../page.js";
|
|
6
|
+
import { wrapWithSetWrappers } from "../Set.js";
|
|
6
7
|
import { SplashPage } from "../splash-page.js";
|
|
7
8
|
import { matchPath, parseSearch, replaceParams, validatePath } from "../util.js";
|
|
8
9
|
import { ServerRouteLoader } from "./ServerRouteLoader.js";
|
|
@@ -112,13 +113,7 @@ const WrappedPage = ({ routeLoaderElement, sets }) => {
|
|
|
112
113
|
return routeLoaderElement;
|
|
113
114
|
}
|
|
114
115
|
return sets.reduceRight((acc, set) => {
|
|
115
|
-
let wrapped = set.wrappers
|
|
116
|
-
return React.createElement(
|
|
117
|
-
Wrapper,
|
|
118
|
-
{ ...set.props, key: set.id + "-" + index },
|
|
119
|
-
acc2
|
|
120
|
-
);
|
|
121
|
-
}, acc);
|
|
116
|
+
let wrapped = wrapWithSetWrappers(set.wrappers, set.id, acc);
|
|
122
117
|
if (set.isPrivate) {
|
|
123
118
|
const unauthenticated = set.props.unauthenticated;
|
|
124
119
|
if (!unauthenticated || typeof unauthenticated !== "string") {
|
|
@@ -126,7 +121,15 @@ const WrappedPage = ({ routeLoaderElement, sets }) => {
|
|
|
126
121
|
"You must specify an `unauthenticated` route when using PrivateSet"
|
|
127
122
|
);
|
|
128
123
|
}
|
|
129
|
-
wrapped = /* @__PURE__ */ React.createElement(
|
|
124
|
+
wrapped = /* @__PURE__ */ React.createElement(
|
|
125
|
+
AuthenticatedRoute,
|
|
126
|
+
{
|
|
127
|
+
unauthenticated,
|
|
128
|
+
roles: set.props.roles,
|
|
129
|
+
whileLoadingAuth: set.props.whileLoadingAuth
|
|
130
|
+
},
|
|
131
|
+
wrapped
|
|
132
|
+
);
|
|
130
133
|
}
|
|
131
134
|
return wrapped;
|
|
132
135
|
}, routeLoaderElement);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/router",
|
|
3
|
-
"version": "7.0.1-next.
|
|
3
|
+
"version": "7.0.1-next.467",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -52,29 +52,29 @@
|
|
|
52
52
|
"test:watch": "vitest watch"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@cedarjs/project-config": "7.0.1-next.
|
|
56
|
-
"@cedarjs/server-store": "7.0.1-next.
|
|
55
|
+
"@cedarjs/project-config": "7.0.1-next.467",
|
|
56
|
+
"@cedarjs/server-store": "7.0.1-next.467",
|
|
57
57
|
"react-server-dom-webpack": "19.3.0",
|
|
58
58
|
"ts-toolbelt": "9.6.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@arethetypeswrong/cli": "0.18.5",
|
|
62
|
-
"@cedarjs/auth": "7.0.1-next.
|
|
63
|
-
"@cedarjs/framework-tools": "7.0.1-next.
|
|
62
|
+
"@cedarjs/auth": "7.0.1-next.467",
|
|
63
|
+
"@cedarjs/framework-tools": "7.0.1-next.467",
|
|
64
64
|
"@testing-library/jest-dom": "6.9.1",
|
|
65
65
|
"@types/react": "^19.2.0",
|
|
66
66
|
"@types/react-dom": "^19.2.0",
|
|
67
|
-
"concurrently": "9.2.
|
|
68
|
-
"publint": "0.3.
|
|
67
|
+
"concurrently": "9.2.5",
|
|
68
|
+
"publint": "0.3.25",
|
|
69
69
|
"react": "19.3.0",
|
|
70
70
|
"react-dom": "19.3.0",
|
|
71
71
|
"tstyche": "5.0.2",
|
|
72
72
|
"typescript": "5.9.3",
|
|
73
|
-
"vite": "7.3.
|
|
73
|
+
"vite": "7.3.7",
|
|
74
74
|
"vitest": "4.1.11"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@cedarjs/auth": "7.0.1-next.
|
|
77
|
+
"@cedarjs/auth": "7.0.1-next.467",
|
|
78
78
|
"react": "19.3.0",
|
|
79
79
|
"react-dom": "19.3.0"
|
|
80
80
|
},
|