@real-router/solid 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cjs/index.d.ts +12 -1
- package/dist/cjs/index.js +70 -18
- package/dist/esm/index.d.mts +12 -1
- package/dist/esm/index.mjs +70 -18
- package/dist/types/components/RouteView/RouteView.d.ts +3 -2
- package/dist/types/components/RouteView/RouteView.d.ts.map +1 -1
- package/dist/types/components/RouteView/components.d.ts +12 -2
- package/dist/types/components/RouteView/components.d.ts.map +1 -1
- package/dist/types/components/RouteView/helpers.d.ts.map +1 -1
- package/dist/types/components/RouteView/index.d.ts +1 -1
- package/dist/types/components/RouteView/index.d.ts.map +1 -1
- package/dist/types/components/RouteView/types.d.ts +6 -0
- package/dist/types/components/RouteView/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/RouteView/RouteView.tsx +7 -2
- package/src/components/RouteView/components.tsx +25 -2
- package/src/components/RouteView/helpers.tsx +67 -21
- package/src/components/RouteView/index.ts +1 -0
- package/src/components/RouteView/types.ts +7 -0
- package/src/index.tsx +1 -0
package/README.md
CHANGED
|
@@ -341,9 +341,9 @@ Full documentation: [Wiki](https://github.com/greydragon888/real-router/wiki)
|
|
|
341
341
|
|
|
342
342
|
## Examples
|
|
343
343
|
|
|
344
|
-
14 runnable examples — each is a standalone Vite app. Run: `cd examples/solid/basic && pnpm dev`
|
|
344
|
+
14 runnable examples — each is a standalone Vite app. Run: `cd examples/web/solid/basic && pnpm dev`
|
|
345
345
|
|
|
346
|
-
[basic](../../examples/solid/basic) · [nested-routes](../../examples/solid/nested-routes) · [auth-guards](../../examples/solid/auth-guards) · [data-loading](../../examples/solid/data-loading) · [lazy-loading](../../examples/solid/lazy-loading) · [async-guards](../../examples/solid/async-guards) · [hash-routing](../../examples/solid/hash-routing) · [persistent-params](../../examples/solid/persistent-params) · [error-handling](../../examples/solid/error-handling) · [dynamic-routes](../../examples/solid/dynamic-routes) · [store-based-state](../../examples/solid/store-based-state) · [use-link-directive](../../examples/solid/use-link-directive) · [signal-primitives](../../examples/solid/signal-primitives) · [combined](../../examples/solid/combined)
|
|
346
|
+
[basic](../../examples/web/solid/basic) · [nested-routes](../../examples/web/solid/nested-routes) · [auth-guards](../../examples/web/solid/auth-guards) · [data-loading](../../examples/web/solid/data-loading) · [lazy-loading](../../examples/web/solid/lazy-loading) · [async-guards](../../examples/web/solid/async-guards) · [hash-routing](../../examples/web/solid/hash-routing) · [persistent-params](../../examples/web/solid/persistent-params) · [error-handling](../../examples/web/solid/error-handling) · [dynamic-routes](../../examples/web/solid/dynamic-routes) · [store-based-state](../../examples/web/solid/store-based-state) · [use-link-directive](../../examples/web/solid/use-link-directive) · [signal-primitives](../../examples/web/solid/signal-primitives) · [combined](../../examples/web/solid/combined)
|
|
347
347
|
|
|
348
348
|
## Related Packages
|
|
349
349
|
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ interface MatchProps {
|
|
|
17
17
|
readonly fallback?: JSX.Element;
|
|
18
18
|
readonly children: JSX.Element;
|
|
19
19
|
}
|
|
20
|
+
interface SelfProps {
|
|
21
|
+
/** Fallback content while children are suspended. */
|
|
22
|
+
readonly fallback?: JSX.Element;
|
|
23
|
+
/** Content to render when the active route name equals the parent RouteView's nodeName. */
|
|
24
|
+
readonly children: JSX.Element;
|
|
25
|
+
}
|
|
20
26
|
interface NotFoundProps {
|
|
21
27
|
readonly children: JSX.Element;
|
|
22
28
|
}
|
|
@@ -25,6 +31,10 @@ declare function Match(props: MatchProps): JSX.Element;
|
|
|
25
31
|
declare namespace Match {
|
|
26
32
|
var displayName: string;
|
|
27
33
|
}
|
|
34
|
+
declare function Self(props: SelfProps): JSX.Element;
|
|
35
|
+
declare namespace Self {
|
|
36
|
+
var displayName: string;
|
|
37
|
+
}
|
|
28
38
|
declare function NotFound(props: NotFoundProps): JSX.Element;
|
|
29
39
|
declare namespace NotFound {
|
|
30
40
|
var displayName: string;
|
|
@@ -36,6 +46,7 @@ declare namespace RouteViewRoot {
|
|
|
36
46
|
}
|
|
37
47
|
declare const RouteView: typeof RouteViewRoot & {
|
|
38
48
|
Match: typeof Match;
|
|
49
|
+
Self: typeof Self;
|
|
39
50
|
NotFound: typeof NotFound;
|
|
40
51
|
};
|
|
41
52
|
|
|
@@ -116,4 +127,4 @@ declare function createSignalFromSource<T>(source: RouterSource<T>): Accessor<T>
|
|
|
116
127
|
declare function createStoreFromSource<T extends object>(source: RouterSource<T>): T;
|
|
117
128
|
|
|
118
129
|
export { Link, RouteContext, RouteView, RouterContext, RouterErrorBoundary, RouterProvider, createSignalFromSource, createStoreFromSource, link, useNavigator, useRoute, useRouteNode, useRouteNodeStore, useRouteStore, useRouteUtils, useRouter, useRouterTransition };
|
|
119
|
-
export type { LinkDirectiveOptions, LinkProps, RouteState, MatchProps as RouteViewMatchProps, NotFoundProps as RouteViewNotFoundProps, RouteViewProps, RouterErrorBoundaryProps };
|
|
130
|
+
export type { LinkDirectiveOptions, LinkProps, RouteState, MatchProps as RouteViewMatchProps, NotFoundProps as RouteViewNotFoundProps, RouteViewProps, SelfProps as RouteViewSelfProps, RouterErrorBoundaryProps };
|
package/dist/cjs/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var core = require('@real-router/core');
|
|
|
11
11
|
// Local (non-global) Symbols — Symbol.for() would expose markers to spoofing
|
|
12
12
|
// via the global Symbol registry. See Gotchas section "RouteView Marker Objects".
|
|
13
13
|
const MATCH_MARKER = Symbol("RouteView.Match");
|
|
14
|
+
const SELF_MARKER = Symbol("RouteView.Self");
|
|
14
15
|
const NOT_FOUND_MARKER = Symbol("RouteView.NotFound");
|
|
15
16
|
function Match(props) {
|
|
16
17
|
const result = {
|
|
@@ -29,6 +30,19 @@ function Match(props) {
|
|
|
29
30
|
return result;
|
|
30
31
|
}
|
|
31
32
|
Match.displayName = "RouteView.Match";
|
|
33
|
+
function Self(props) {
|
|
34
|
+
const result = {
|
|
35
|
+
$$type: SELF_MARKER,
|
|
36
|
+
fallback: props.fallback,
|
|
37
|
+
get children() {
|
|
38
|
+
return props.children;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// See Match for the marker-pattern rationale.
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
Self.displayName = "RouteView.Self";
|
|
32
46
|
function NotFound(props) {
|
|
33
47
|
const result = {
|
|
34
48
|
$$type: NOT_FOUND_MARKER,
|
|
@@ -51,6 +65,9 @@ function isSegmentMatch(routeName, fullSegmentName, exact) {
|
|
|
51
65
|
function isMatchMarker(value) {
|
|
52
66
|
return value != null && typeof value === "object" && "$$type" in value && value.$$type === MATCH_MARKER;
|
|
53
67
|
}
|
|
68
|
+
function isSelfMarker(value) {
|
|
69
|
+
return value != null && typeof value === "object" && "$$type" in value && value.$$type === SELF_MARKER;
|
|
70
|
+
}
|
|
54
71
|
function isNotFoundMarker(value) {
|
|
55
72
|
return value != null && typeof value === "object" && "$$type" in value && value.$$type === NOT_FOUND_MARKER;
|
|
56
73
|
}
|
|
@@ -64,11 +81,48 @@ function collectElements(children, result) {
|
|
|
64
81
|
}
|
|
65
82
|
return;
|
|
66
83
|
}
|
|
67
|
-
if (isMatchMarker(children) || isNotFoundMarker(children)) {
|
|
84
|
+
if (isMatchMarker(children) || isSelfMarker(children) || isNotFoundMarker(children)) {
|
|
68
85
|
result.push(children);
|
|
69
86
|
}
|
|
70
87
|
}
|
|
88
|
+
|
|
89
|
+
// child.children is a getter — read it INSIDE the JSX expression so Solid
|
|
90
|
+
// creates a reactive dependency. Pulling it into a variable freezes the
|
|
91
|
+
// value at template-build time and breaks Suspense fallback transitions
|
|
92
|
+
// (lazy() resolution).
|
|
93
|
+
function renderMatch(child) {
|
|
94
|
+
return child.fallback === undefined ? child.children : web.createComponent(solidJs.Suspense, {
|
|
95
|
+
get fallback() {
|
|
96
|
+
return child.fallback;
|
|
97
|
+
},
|
|
98
|
+
get children() {
|
|
99
|
+
return child.children;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function renderSelf(self) {
|
|
104
|
+
return self.fallback === undefined ? self.children : web.createComponent(solidJs.Suspense, {
|
|
105
|
+
get fallback() {
|
|
106
|
+
return self.fallback;
|
|
107
|
+
},
|
|
108
|
+
get children() {
|
|
109
|
+
return self.children;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function processMatchChild(child, routeName, nodeName) {
|
|
114
|
+
const {
|
|
115
|
+
segment,
|
|
116
|
+
exact
|
|
117
|
+
} = child;
|
|
118
|
+
const fullSegmentName = nodeName ? `${nodeName}.${segment}` : segment;
|
|
119
|
+
if (!isSegmentMatch(routeName, fullSegmentName, exact)) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
return renderMatch(child);
|
|
123
|
+
}
|
|
71
124
|
function buildRenderList(elements, routeName, nodeName) {
|
|
125
|
+
let selfMarker = null;
|
|
72
126
|
let notFoundChildren = null;
|
|
73
127
|
let activeMatchFound = false;
|
|
74
128
|
const rendered = [];
|
|
@@ -77,28 +131,25 @@ function buildRenderList(elements, routeName, nodeName) {
|
|
|
77
131
|
notFoundChildren = child.children;
|
|
78
132
|
continue;
|
|
79
133
|
}
|
|
80
|
-
if (
|
|
134
|
+
if (isSelfMarker(child)) {
|
|
135
|
+
selfMarker ??= child;
|
|
81
136
|
continue;
|
|
82
137
|
}
|
|
83
|
-
|
|
84
|
-
segment,
|
|
85
|
-
exact,
|
|
86
|
-
fallback
|
|
87
|
-
} = child;
|
|
88
|
-
const fullSegmentName = nodeName ? `${nodeName}.${segment}` : segment;
|
|
89
|
-
if (!isSegmentMatch(routeName, fullSegmentName, exact)) {
|
|
138
|
+
if (activeMatchFound) {
|
|
90
139
|
continue;
|
|
91
140
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
}));
|
|
141
|
+
const matchRendered = processMatchChild(child, routeName, nodeName);
|
|
142
|
+
if (matchRendered !== null) {
|
|
143
|
+
activeMatchFound = true;
|
|
144
|
+
rendered.push(matchRendered);
|
|
145
|
+
}
|
|
99
146
|
}
|
|
100
|
-
if (!activeMatchFound
|
|
101
|
-
|
|
147
|
+
if (!activeMatchFound) {
|
|
148
|
+
if (selfMarker !== null && routeName === nodeName) {
|
|
149
|
+
rendered.push(renderSelf(selfMarker));
|
|
150
|
+
} else if (routeName === core.UNKNOWN_ROUTE && notFoundChildren !== null) {
|
|
151
|
+
rendered.push(notFoundChildren);
|
|
152
|
+
}
|
|
102
153
|
}
|
|
103
154
|
return rendered;
|
|
104
155
|
}
|
|
@@ -157,6 +208,7 @@ function RouteViewRoot(props) {
|
|
|
157
208
|
RouteViewRoot.displayName = "RouteView";
|
|
158
209
|
const RouteView = Object.assign(RouteViewRoot, {
|
|
159
210
|
Match,
|
|
211
|
+
Self,
|
|
160
212
|
NotFound
|
|
161
213
|
});
|
|
162
214
|
|
package/dist/esm/index.d.mts
CHANGED
|
@@ -17,6 +17,12 @@ interface MatchProps {
|
|
|
17
17
|
readonly fallback?: JSX.Element;
|
|
18
18
|
readonly children: JSX.Element;
|
|
19
19
|
}
|
|
20
|
+
interface SelfProps {
|
|
21
|
+
/** Fallback content while children are suspended. */
|
|
22
|
+
readonly fallback?: JSX.Element;
|
|
23
|
+
/** Content to render when the active route name equals the parent RouteView's nodeName. */
|
|
24
|
+
readonly children: JSX.Element;
|
|
25
|
+
}
|
|
20
26
|
interface NotFoundProps {
|
|
21
27
|
readonly children: JSX.Element;
|
|
22
28
|
}
|
|
@@ -25,6 +31,10 @@ declare function Match(props: MatchProps): JSX.Element;
|
|
|
25
31
|
declare namespace Match {
|
|
26
32
|
var displayName: string;
|
|
27
33
|
}
|
|
34
|
+
declare function Self(props: SelfProps): JSX.Element;
|
|
35
|
+
declare namespace Self {
|
|
36
|
+
var displayName: string;
|
|
37
|
+
}
|
|
28
38
|
declare function NotFound(props: NotFoundProps): JSX.Element;
|
|
29
39
|
declare namespace NotFound {
|
|
30
40
|
var displayName: string;
|
|
@@ -36,6 +46,7 @@ declare namespace RouteViewRoot {
|
|
|
36
46
|
}
|
|
37
47
|
declare const RouteView: typeof RouteViewRoot & {
|
|
38
48
|
Match: typeof Match;
|
|
49
|
+
Self: typeof Self;
|
|
39
50
|
NotFound: typeof NotFound;
|
|
40
51
|
};
|
|
41
52
|
|
|
@@ -116,4 +127,4 @@ declare function createSignalFromSource<T>(source: RouterSource<T>): Accessor<T>
|
|
|
116
127
|
declare function createStoreFromSource<T extends object>(source: RouterSource<T>): T;
|
|
117
128
|
|
|
118
129
|
export { Link, RouteContext, RouteView, RouterContext, RouterErrorBoundary, RouterProvider, createSignalFromSource, createStoreFromSource, link, useNavigator, useRoute, useRouteNode, useRouteNodeStore, useRouteStore, useRouteUtils, useRouter, useRouterTransition };
|
|
119
|
-
export type { LinkDirectiveOptions, LinkProps, RouteState, MatchProps as RouteViewMatchProps, NotFoundProps as RouteViewNotFoundProps, RouteViewProps, RouterErrorBoundaryProps };
|
|
130
|
+
export type { LinkDirectiveOptions, LinkProps, RouteState, MatchProps as RouteViewMatchProps, NotFoundProps as RouteViewNotFoundProps, RouteViewProps, SelfProps as RouteViewSelfProps, RouterErrorBoundaryProps };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { UNKNOWN_ROUTE, getNavigator } from '@real-router/core';
|
|
|
9
9
|
// Local (non-global) Symbols — Symbol.for() would expose markers to spoofing
|
|
10
10
|
// via the global Symbol registry. See Gotchas section "RouteView Marker Objects".
|
|
11
11
|
const MATCH_MARKER = Symbol("RouteView.Match");
|
|
12
|
+
const SELF_MARKER = Symbol("RouteView.Self");
|
|
12
13
|
const NOT_FOUND_MARKER = Symbol("RouteView.NotFound");
|
|
13
14
|
function Match(props) {
|
|
14
15
|
const result = {
|
|
@@ -27,6 +28,19 @@ function Match(props) {
|
|
|
27
28
|
return result;
|
|
28
29
|
}
|
|
29
30
|
Match.displayName = "RouteView.Match";
|
|
31
|
+
function Self(props) {
|
|
32
|
+
const result = {
|
|
33
|
+
$$type: SELF_MARKER,
|
|
34
|
+
fallback: props.fallback,
|
|
35
|
+
get children() {
|
|
36
|
+
return props.children;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// See Match for the marker-pattern rationale.
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
Self.displayName = "RouteView.Self";
|
|
30
44
|
function NotFound(props) {
|
|
31
45
|
const result = {
|
|
32
46
|
$$type: NOT_FOUND_MARKER,
|
|
@@ -49,6 +63,9 @@ function isSegmentMatch(routeName, fullSegmentName, exact) {
|
|
|
49
63
|
function isMatchMarker(value) {
|
|
50
64
|
return value != null && typeof value === "object" && "$$type" in value && value.$$type === MATCH_MARKER;
|
|
51
65
|
}
|
|
66
|
+
function isSelfMarker(value) {
|
|
67
|
+
return value != null && typeof value === "object" && "$$type" in value && value.$$type === SELF_MARKER;
|
|
68
|
+
}
|
|
52
69
|
function isNotFoundMarker(value) {
|
|
53
70
|
return value != null && typeof value === "object" && "$$type" in value && value.$$type === NOT_FOUND_MARKER;
|
|
54
71
|
}
|
|
@@ -62,11 +79,48 @@ function collectElements(children, result) {
|
|
|
62
79
|
}
|
|
63
80
|
return;
|
|
64
81
|
}
|
|
65
|
-
if (isMatchMarker(children) || isNotFoundMarker(children)) {
|
|
82
|
+
if (isMatchMarker(children) || isSelfMarker(children) || isNotFoundMarker(children)) {
|
|
66
83
|
result.push(children);
|
|
67
84
|
}
|
|
68
85
|
}
|
|
86
|
+
|
|
87
|
+
// child.children is a getter — read it INSIDE the JSX expression so Solid
|
|
88
|
+
// creates a reactive dependency. Pulling it into a variable freezes the
|
|
89
|
+
// value at template-build time and breaks Suspense fallback transitions
|
|
90
|
+
// (lazy() resolution).
|
|
91
|
+
function renderMatch(child) {
|
|
92
|
+
return child.fallback === undefined ? child.children : createComponent(Suspense, {
|
|
93
|
+
get fallback() {
|
|
94
|
+
return child.fallback;
|
|
95
|
+
},
|
|
96
|
+
get children() {
|
|
97
|
+
return child.children;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function renderSelf(self) {
|
|
102
|
+
return self.fallback === undefined ? self.children : createComponent(Suspense, {
|
|
103
|
+
get fallback() {
|
|
104
|
+
return self.fallback;
|
|
105
|
+
},
|
|
106
|
+
get children() {
|
|
107
|
+
return self.children;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function processMatchChild(child, routeName, nodeName) {
|
|
112
|
+
const {
|
|
113
|
+
segment,
|
|
114
|
+
exact
|
|
115
|
+
} = child;
|
|
116
|
+
const fullSegmentName = nodeName ? `${nodeName}.${segment}` : segment;
|
|
117
|
+
if (!isSegmentMatch(routeName, fullSegmentName, exact)) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return renderMatch(child);
|
|
121
|
+
}
|
|
69
122
|
function buildRenderList(elements, routeName, nodeName) {
|
|
123
|
+
let selfMarker = null;
|
|
70
124
|
let notFoundChildren = null;
|
|
71
125
|
let activeMatchFound = false;
|
|
72
126
|
const rendered = [];
|
|
@@ -75,28 +129,25 @@ function buildRenderList(elements, routeName, nodeName) {
|
|
|
75
129
|
notFoundChildren = child.children;
|
|
76
130
|
continue;
|
|
77
131
|
}
|
|
78
|
-
if (
|
|
132
|
+
if (isSelfMarker(child)) {
|
|
133
|
+
selfMarker ??= child;
|
|
79
134
|
continue;
|
|
80
135
|
}
|
|
81
|
-
|
|
82
|
-
segment,
|
|
83
|
-
exact,
|
|
84
|
-
fallback
|
|
85
|
-
} = child;
|
|
86
|
-
const fullSegmentName = nodeName ? `${nodeName}.${segment}` : segment;
|
|
87
|
-
if (!isSegmentMatch(routeName, fullSegmentName, exact)) {
|
|
136
|
+
if (activeMatchFound) {
|
|
88
137
|
continue;
|
|
89
138
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
}));
|
|
139
|
+
const matchRendered = processMatchChild(child, routeName, nodeName);
|
|
140
|
+
if (matchRendered !== null) {
|
|
141
|
+
activeMatchFound = true;
|
|
142
|
+
rendered.push(matchRendered);
|
|
143
|
+
}
|
|
97
144
|
}
|
|
98
|
-
if (!activeMatchFound
|
|
99
|
-
|
|
145
|
+
if (!activeMatchFound) {
|
|
146
|
+
if (selfMarker !== null && routeName === nodeName) {
|
|
147
|
+
rendered.push(renderSelf(selfMarker));
|
|
148
|
+
} else if (routeName === UNKNOWN_ROUTE && notFoundChildren !== null) {
|
|
149
|
+
rendered.push(notFoundChildren);
|
|
150
|
+
}
|
|
100
151
|
}
|
|
101
152
|
return rendered;
|
|
102
153
|
}
|
|
@@ -155,6 +206,7 @@ function RouteViewRoot(props) {
|
|
|
155
206
|
RouteViewRoot.displayName = "RouteView";
|
|
156
207
|
const RouteView = Object.assign(RouteViewRoot, {
|
|
157
208
|
Match,
|
|
209
|
+
Self,
|
|
158
210
|
NotFound
|
|
159
211
|
});
|
|
160
212
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Match, NotFound } from "./components";
|
|
1
|
+
import { Match, NotFound, Self } from "./components";
|
|
2
2
|
import type { RouteViewProps } from "./types";
|
|
3
3
|
import type { JSX } from "solid-js";
|
|
4
4
|
declare function RouteViewRoot(props: Readonly<RouteViewProps>): JSX.Element;
|
|
@@ -7,7 +7,8 @@ declare namespace RouteViewRoot {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const RouteView: typeof RouteViewRoot & {
|
|
9
9
|
Match: typeof Match;
|
|
10
|
+
Self: typeof Self;
|
|
10
11
|
NotFound: typeof NotFound;
|
|
11
12
|
};
|
|
12
|
-
export type { RouteViewProps, MatchProps as RouteViewMatchProps, NotFoundProps as RouteViewNotFoundProps, } from "./types";
|
|
13
|
+
export type { RouteViewProps, MatchProps as RouteViewMatchProps, SelfProps as RouteViewSelfProps, NotFoundProps as RouteViewNotFoundProps, } from "./types";
|
|
13
14
|
//# sourceMappingURL=RouteView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteView.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/RouteView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"RouteView.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/RouteView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAKrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,iBAAS,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC,OAAO,CAgCnE;kBAhCQ,aAAa;;;AAoCtB,eAAO,MAAM,SAAS;;;;CAIpB,CAAC;AAEH,YAAY,EACV,cAAc,EACd,UAAU,IAAI,mBAAmB,EACjC,SAAS,IAAI,kBAAkB,EAC/B,aAAa,IAAI,sBAAsB,GACxC,MAAM,SAAS,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { MatchProps, NotFoundProps } from "./types";
|
|
1
|
+
import type { MatchProps, NotFoundProps, SelfProps } from "./types";
|
|
2
2
|
import type { JSX } from "solid-js";
|
|
3
3
|
export declare const MATCH_MARKER: unique symbol;
|
|
4
|
+
export declare const SELF_MARKER: unique symbol;
|
|
4
5
|
export declare const NOT_FOUND_MARKER: unique symbol;
|
|
5
6
|
export interface MatchMarker {
|
|
6
7
|
$$type: typeof MATCH_MARKER;
|
|
@@ -9,15 +10,24 @@ export interface MatchMarker {
|
|
|
9
10
|
fallback?: JSX.Element;
|
|
10
11
|
children: JSX.Element;
|
|
11
12
|
}
|
|
13
|
+
export interface SelfMarker {
|
|
14
|
+
$$type: typeof SELF_MARKER;
|
|
15
|
+
fallback?: JSX.Element;
|
|
16
|
+
children: JSX.Element;
|
|
17
|
+
}
|
|
12
18
|
export interface NotFoundMarker {
|
|
13
19
|
$$type: typeof NOT_FOUND_MARKER;
|
|
14
20
|
children: JSX.Element;
|
|
15
21
|
}
|
|
16
|
-
export type RouteViewMarker = MatchMarker | NotFoundMarker;
|
|
22
|
+
export type RouteViewMarker = MatchMarker | SelfMarker | NotFoundMarker;
|
|
17
23
|
export declare function Match(props: MatchProps): JSX.Element;
|
|
18
24
|
export declare namespace Match {
|
|
19
25
|
var displayName: string;
|
|
20
26
|
}
|
|
27
|
+
export declare function Self(props: SelfProps): JSX.Element;
|
|
28
|
+
export declare namespace Self {
|
|
29
|
+
var displayName: string;
|
|
30
|
+
}
|
|
21
31
|
export declare function NotFound(props: NotFoundProps): JSX.Element;
|
|
22
32
|
export declare namespace NotFound {
|
|
23
33
|
var displayName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC,eAAO,MAAM,YAAY,eAA4B,CAAC;AAEtD,eAAO,MAAM,WAAW,eAA2B,CAAC;AAEpD,eAAO,MAAM,gBAAgB,eAA+B,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,YAAY,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,OAAO,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,gBAAgB,CAAC;IAChC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,GAAG,cAAc,CAAC;AAExE,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAAC,OAAO,CAepD;yBAfe,KAAK;;;AAmBrB,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,CAWlD;yBAXe,IAAI;;;AAepB,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,GAAG,CAAC,OAAO,CAU1D;yBAVe,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/helpers.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,eAAe,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/helpers.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,eAAe,EAEhB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,KAAK,EAAE,OAAO,GACb,OAAO,CAMT;AA6BD,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,eAAe,EAAE,GACxB,IAAI,CAoBN;AAqCD,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,eAAe,EAAE,EAC3B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,GAAG,CAAC,OAAO,EAAE,CAsCf"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { RouteView } from "./RouteView";
|
|
2
|
-
export type { RouteViewProps, RouteViewMatchProps, RouteViewNotFoundProps, } from "./RouteView";
|
|
2
|
+
export type { RouteViewProps, RouteViewMatchProps, RouteViewSelfProps, RouteViewNotFoundProps, } from "./RouteView";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,aAAa,CAAC"}
|
|
@@ -9,6 +9,12 @@ export interface MatchProps {
|
|
|
9
9
|
readonly fallback?: JSX.Element;
|
|
10
10
|
readonly children: JSX.Element;
|
|
11
11
|
}
|
|
12
|
+
export interface SelfProps {
|
|
13
|
+
/** Fallback content while children are suspended. */
|
|
14
|
+
readonly fallback?: JSX.Element;
|
|
15
|
+
/** Content to render when the active route name equals the parent RouteView's nodeName. */
|
|
16
|
+
readonly children: JSX.Element;
|
|
17
|
+
}
|
|
12
18
|
export interface NotFoundProps {
|
|
13
19
|
readonly children: JSX.Element;
|
|
14
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CAChC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/RouteView/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAChC,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;CAChC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { createStoreFromSource } from "./createStoreFromSource";
|
|
|
17
17
|
export type { LinkProps, RouteState } from "./types";
|
|
18
18
|
export type { RouterErrorBoundaryProps } from "./components/RouterErrorBoundary";
|
|
19
19
|
export type { LinkDirectiveOptions } from "./directives/link";
|
|
20
|
-
export type { RouteViewProps, RouteViewMatchProps, RouteViewNotFoundProps, } from "./components/RouteView";
|
|
20
|
+
export type { RouteViewProps, RouteViewMatchProps, RouteViewSelfProps, RouteViewNotFoundProps, } from "./components/RouteView";
|
|
21
21
|
export type { Navigator } from "@real-router/core";
|
|
22
22
|
export type { RouterTransitionSnapshot } from "@real-router/sources";
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErD,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEjF,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErD,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEjF,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/solid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "Solid.js integration for Real-Router",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"sideEffects": false,
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@real-router/core": "^0.50.
|
|
54
|
+
"@real-router/core": "^0.50.1",
|
|
55
55
|
"@real-router/route-utils": "^0.2.1",
|
|
56
56
|
"@real-router/sources": "^0.7.2"
|
|
57
57
|
},
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"solid-js": "1.9.12",
|
|
72
72
|
"vite-plugin-solid": "2.11.11",
|
|
73
73
|
"vitest": "4.1.0",
|
|
74
|
-
"@real-router/browser-plugin": "^0.
|
|
74
|
+
"@real-router/browser-plugin": "^0.15.1"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"solid-js": ">=1.7.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { children as resolveChildren, createMemo } from "solid-js";
|
|
2
2
|
|
|
3
|
-
import { Match, NotFound } from "./components";
|
|
3
|
+
import { Match, NotFound, Self } from "./components";
|
|
4
4
|
import { buildRenderList, collectElements } from "./helpers";
|
|
5
5
|
import { useRouteNode } from "../../hooks/useRouteNode";
|
|
6
6
|
|
|
@@ -44,10 +44,15 @@ function RouteViewRoot(props: Readonly<RouteViewProps>): JSX.Element {
|
|
|
44
44
|
|
|
45
45
|
RouteViewRoot.displayName = "RouteView";
|
|
46
46
|
|
|
47
|
-
export const RouteView = Object.assign(RouteViewRoot, {
|
|
47
|
+
export const RouteView = Object.assign(RouteViewRoot, {
|
|
48
|
+
Match,
|
|
49
|
+
Self,
|
|
50
|
+
NotFound,
|
|
51
|
+
});
|
|
48
52
|
|
|
49
53
|
export type {
|
|
50
54
|
RouteViewProps,
|
|
51
55
|
MatchProps as RouteViewMatchProps,
|
|
56
|
+
SelfProps as RouteViewSelfProps,
|
|
52
57
|
NotFoundProps as RouteViewNotFoundProps,
|
|
53
58
|
} from "./types";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { MatchProps, NotFoundProps } from "./types";
|
|
1
|
+
import type { MatchProps, NotFoundProps, SelfProps } from "./types";
|
|
2
2
|
import type { JSX } from "solid-js";
|
|
3
3
|
|
|
4
4
|
// Local (non-global) Symbols — Symbol.for() would expose markers to spoofing
|
|
5
5
|
// via the global Symbol registry. See Gotchas section "RouteView Marker Objects".
|
|
6
6
|
export const MATCH_MARKER = Symbol("RouteView.Match");
|
|
7
7
|
|
|
8
|
+
export const SELF_MARKER = Symbol("RouteView.Self");
|
|
9
|
+
|
|
8
10
|
export const NOT_FOUND_MARKER = Symbol("RouteView.NotFound");
|
|
9
11
|
|
|
10
12
|
export interface MatchMarker {
|
|
@@ -15,12 +17,18 @@ export interface MatchMarker {
|
|
|
15
17
|
children: JSX.Element;
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
export interface SelfMarker {
|
|
21
|
+
$$type: typeof SELF_MARKER;
|
|
22
|
+
fallback?: JSX.Element;
|
|
23
|
+
children: JSX.Element;
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
export interface NotFoundMarker {
|
|
19
27
|
$$type: typeof NOT_FOUND_MARKER;
|
|
20
28
|
children: JSX.Element;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
export type RouteViewMarker = MatchMarker | NotFoundMarker;
|
|
31
|
+
export type RouteViewMarker = MatchMarker | SelfMarker | NotFoundMarker;
|
|
24
32
|
|
|
25
33
|
export function Match(props: MatchProps): JSX.Element {
|
|
26
34
|
const result: MatchMarker = {
|
|
@@ -41,6 +49,21 @@ export function Match(props: MatchProps): JSX.Element {
|
|
|
41
49
|
|
|
42
50
|
Match.displayName = "RouteView.Match";
|
|
43
51
|
|
|
52
|
+
export function Self(props: SelfProps): JSX.Element {
|
|
53
|
+
const result: SelfMarker = {
|
|
54
|
+
$$type: SELF_MARKER,
|
|
55
|
+
fallback: props.fallback,
|
|
56
|
+
get children(): JSX.Element {
|
|
57
|
+
return props.children;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// See Match for the marker-pattern rationale.
|
|
62
|
+
return result as unknown as JSX.Element;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Self.displayName = "RouteView.Self";
|
|
66
|
+
|
|
44
67
|
export function NotFound(props: NotFoundProps): JSX.Element {
|
|
45
68
|
const result: NotFoundMarker = {
|
|
46
69
|
$$type: NOT_FOUND_MARKER,
|
|
@@ -2,12 +2,13 @@ import { UNKNOWN_ROUTE } from "@real-router/core";
|
|
|
2
2
|
import { startsWithSegment } from "@real-router/route-utils";
|
|
3
3
|
import { Suspense } from "solid-js";
|
|
4
4
|
|
|
5
|
-
import { MATCH_MARKER, NOT_FOUND_MARKER } from "./components";
|
|
5
|
+
import { MATCH_MARKER, NOT_FOUND_MARKER, SELF_MARKER } from "./components";
|
|
6
6
|
|
|
7
7
|
import type {
|
|
8
8
|
MatchMarker,
|
|
9
9
|
NotFoundMarker,
|
|
10
10
|
RouteViewMarker,
|
|
11
|
+
SelfMarker,
|
|
11
12
|
} from "./components";
|
|
12
13
|
import type { JSX } from "solid-js";
|
|
13
14
|
|
|
@@ -32,6 +33,15 @@ function isMatchMarker(value: unknown): value is MatchMarker {
|
|
|
32
33
|
);
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
function isSelfMarker(value: unknown): value is SelfMarker {
|
|
37
|
+
return (
|
|
38
|
+
value != null &&
|
|
39
|
+
typeof value === "object" &&
|
|
40
|
+
"$$type" in value &&
|
|
41
|
+
value.$$type === SELF_MARKER
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
function isNotFoundMarker(value: unknown): value is NotFoundMarker {
|
|
36
46
|
return (
|
|
37
47
|
value != null &&
|
|
@@ -57,16 +67,56 @@ export function collectElements(
|
|
|
57
67
|
return;
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
if (
|
|
70
|
+
if (
|
|
71
|
+
isMatchMarker(children) ||
|
|
72
|
+
isSelfMarker(children) ||
|
|
73
|
+
isNotFoundMarker(children)
|
|
74
|
+
) {
|
|
61
75
|
result.push(children);
|
|
62
76
|
}
|
|
63
77
|
}
|
|
64
78
|
|
|
79
|
+
// child.children is a getter — read it INSIDE the JSX expression so Solid
|
|
80
|
+
// creates a reactive dependency. Pulling it into a variable freezes the
|
|
81
|
+
// value at template-build time and breaks Suspense fallback transitions
|
|
82
|
+
// (lazy() resolution).
|
|
83
|
+
function renderMatch(child: MatchMarker): JSX.Element {
|
|
84
|
+
return child.fallback === undefined ? (
|
|
85
|
+
child.children
|
|
86
|
+
) : (
|
|
87
|
+
<Suspense fallback={child.fallback}>{child.children}</Suspense>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function renderSelf(self: SelfMarker): JSX.Element {
|
|
92
|
+
return self.fallback === undefined ? (
|
|
93
|
+
self.children
|
|
94
|
+
) : (
|
|
95
|
+
<Suspense fallback={self.fallback}>{self.children}</Suspense>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function processMatchChild(
|
|
100
|
+
child: MatchMarker,
|
|
101
|
+
routeName: string,
|
|
102
|
+
nodeName: string,
|
|
103
|
+
): JSX.Element | null {
|
|
104
|
+
const { segment, exact } = child;
|
|
105
|
+
const fullSegmentName = nodeName ? `${nodeName}.${segment}` : segment;
|
|
106
|
+
|
|
107
|
+
if (!isSegmentMatch(routeName, fullSegmentName, exact)) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return renderMatch(child);
|
|
112
|
+
}
|
|
113
|
+
|
|
65
114
|
export function buildRenderList(
|
|
66
115
|
elements: RouteViewMarker[],
|
|
67
116
|
routeName: string,
|
|
68
117
|
nodeName: string,
|
|
69
118
|
): JSX.Element[] {
|
|
119
|
+
let selfMarker: SelfMarker | null = null;
|
|
70
120
|
let notFoundChildren: JSX.Element | null = null;
|
|
71
121
|
let activeMatchFound = false;
|
|
72
122
|
const rendered: JSX.Element[] = [];
|
|
@@ -77,33 +127,29 @@ export function buildRenderList(
|
|
|
77
127
|
continue;
|
|
78
128
|
}
|
|
79
129
|
|
|
80
|
-
if (
|
|
130
|
+
if (isSelfMarker(child)) {
|
|
131
|
+
selfMarker ??= child;
|
|
81
132
|
continue;
|
|
82
133
|
}
|
|
83
134
|
|
|
84
|
-
|
|
85
|
-
const fullSegmentName = nodeName ? `${nodeName}.${segment}` : segment;
|
|
86
|
-
|
|
87
|
-
if (!isSegmentMatch(routeName, fullSegmentName, exact)) {
|
|
135
|
+
if (activeMatchFound) {
|
|
88
136
|
continue;
|
|
89
137
|
}
|
|
90
138
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
),
|
|
98
|
-
);
|
|
139
|
+
const matchRendered = processMatchChild(child, routeName, nodeName);
|
|
140
|
+
|
|
141
|
+
if (matchRendered !== null) {
|
|
142
|
+
activeMatchFound = true;
|
|
143
|
+
rendered.push(matchRendered);
|
|
144
|
+
}
|
|
99
145
|
}
|
|
100
146
|
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
notFoundChildren !== null
|
|
105
|
-
|
|
106
|
-
|
|
147
|
+
if (!activeMatchFound) {
|
|
148
|
+
if (selfMarker !== null && routeName === nodeName) {
|
|
149
|
+
rendered.push(renderSelf(selfMarker));
|
|
150
|
+
} else if (routeName === UNKNOWN_ROUTE && notFoundChildren !== null) {
|
|
151
|
+
rendered.push(notFoundChildren);
|
|
152
|
+
}
|
|
107
153
|
}
|
|
108
154
|
|
|
109
155
|
return rendered;
|
|
@@ -12,6 +12,13 @@ export interface MatchProps {
|
|
|
12
12
|
readonly children: JSX.Element;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export interface SelfProps {
|
|
16
|
+
/** Fallback content while children are suspended. */
|
|
17
|
+
readonly fallback?: JSX.Element;
|
|
18
|
+
/** Content to render when the active route name equals the parent RouteView's nodeName. */
|
|
19
|
+
readonly children: JSX.Element;
|
|
20
|
+
}
|
|
21
|
+
|
|
15
22
|
export interface NotFoundProps {
|
|
16
23
|
readonly children: JSX.Element;
|
|
17
24
|
}
|