@tonyclaw/agent-inspector 3.0.17 → 3.0.19
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/.output/cli.js +1255 -504
- package/.output/nitro.json +3 -3
- package/.output/public/assets/CompareDrawer-DR3WgrId.js +1 -0
- package/.output/public/assets/ProxyViewerContainer-B7PZaz5j.js +127 -0
- package/.output/public/assets/ReplayDialog-Bt9jgdvJ.js +1 -0
- package/.output/public/assets/RequestAnatomy-C-4630lw.js +1 -0
- package/.output/public/assets/ResponseView-f_JrN1iQ.js +3 -0
- package/.output/public/assets/StreamingChunkSequence-D8dBm1d8.js +1 -0
- package/.output/public/assets/_sessionId-CtoSDXDC.js +1 -0
- package/.output/public/assets/index-B-rVc2xu.js +12 -0
- package/.output/public/assets/index-B3YOj8-_.css +1 -0
- package/.output/public/assets/{index-DPc2wzgW.js → index-BNCySZM-.js} +1 -1
- package/.output/public/assets/index-BtCnkWve.js +1 -0
- package/.output/public/assets/json-viewer-DT6QQY81.js +1 -0
- package/.output/server/_chunks/ssr-renderer.mjs +18 -2
- package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +165 -31
- package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +1 -1
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +2 -2
- package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +28 -1
- package/.output/server/_libs/mistralai__mistralai.mjs +1 -1
- package/.output/server/_libs/modelcontextprotocol__server.mjs +11571 -8127
- package/.output/server/_libs/radix-ui__primitive.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-collapsible.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-collection.mjs +8 -8
- package/.output/server/_libs/radix-ui__react-compose-refs.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-context.mjs +4 -18
- package/.output/server/_libs/radix-ui__react-dialog.mjs +41 -88
- package/.output/server/_libs/radix-ui__react-focus-guards.mjs +15 -5
- package/.output/server/_libs/radix-ui__react-focus-scope.mjs +6 -2
- package/.output/server/_libs/radix-ui__react-id.mjs +3 -3
- package/.output/server/_libs/radix-ui__react-popper.mjs +62 -8
- package/.output/server/_libs/radix-ui__react-portal.mjs +2 -2
- package/.output/server/_libs/radix-ui__react-presence.mjs +50 -5
- package/.output/server/_libs/radix-ui__react-roving-focus.mjs +15 -4
- package/.output/server/_libs/radix-ui__react-scroll-area.mjs +30 -20
- package/.output/server/_libs/radix-ui__react-select.mjs +167 -123
- package/.output/server/_libs/radix-ui__react-slot.mjs +74 -41
- package/.output/server/_libs/radix-ui__react-tabs.mjs +6 -1
- package/.output/server/_libs/radix-ui__react-tooltip.mjs +6 -3
- package/.output/server/_libs/react-dom.mjs +13 -15
- package/.output/server/_libs/react.mjs +45 -45
- package/.output/server/_libs/srvx.mjs +409 -53
- package/.output/server/_libs/swr.mjs +10 -2
- package/.output/server/_libs/tailwind-merge.mjs +286 -41
- package/.output/server/_libs/tanstack__history.mjs +9 -13
- package/.output/server/_libs/tanstack__react-router.mjs +788 -1092
- package/.output/server/_libs/tanstack__react-store.mjs +1 -1
- package/.output/server/_libs/tanstack__react-virtual.mjs +82 -7
- package/.output/server/_libs/tanstack__router-core.mjs +1841 -2060
- package/.output/server/_libs/tanstack__virtual-core.mjs +116 -45
- package/.output/server/_libs/use-sync-external-store.mjs +1 -1
- package/.output/server/_libs/zod-to-json-schema.mjs +1 -1
- package/.output/server/_libs/zod.mjs +5085 -200
- package/.output/server/{_sessionId-DL2JQJwR.mjs → _sessionId-DbRqqzqz.mjs} +30 -32
- package/.output/server/_ssr/{CompareDrawer-hPTOTmyU.mjs → CompareDrawer-CVhUSZu1.mjs} +29 -31
- package/.output/server/_ssr/{ProxyViewerContainer-k0mFaufl.mjs → ProxyViewerContainer-BNnDYtc5.mjs} +106 -71
- package/.output/server/_ssr/{ReplayDialog-t6QdwnZh.mjs → ReplayDialog-DVkGajZU.mjs} +30 -32
- package/.output/server/_ssr/{RequestAnatomy-BnvWxyac.mjs → RequestAnatomy-_FIfVjDR.mjs} +29 -31
- package/.output/server/_ssr/{ResponseView-BhhozRRl.mjs → ResponseView-Bnv5ejVA.mjs} +29 -31
- package/.output/server/_ssr/{StreamingChunkSequence-Dl_laTbX.mjs → StreamingChunkSequence-vtwzxw7A.mjs} +29 -31
- package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +6 -0
- package/.output/server/_ssr/{index-D1-t1D8F.mjs → index-DFJbRoyq.mjs} +31 -33
- package/.output/server/_ssr/index.mjs +1102 -784
- package/.output/server/_ssr/{json-viewer-D5Lh2yBU.mjs → json-viewer-BkweASh3.mjs} +29 -31
- package/.output/server/_ssr/{router-DaLFEeWW.mjs → router-gFd3g7WM.mjs} +10 -7
- package/.output/server/_tanstack-start-manifest_v-DeLutIlq.mjs +4 -0
- package/.output/server/index.mjs +85 -103
- package/package.json +17 -8
- package/src/components/clients/ClientLogo.tsx +5 -1
- package/src/components/proxy-viewer/LogEntry.tsx +54 -19
- package/src/components/proxy-viewer/RequestToolsPanel.tsx +1 -0
- package/src/components/proxy-viewer/ResponseView.tsx +1 -0
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +1 -0
- package/src/components/proxy-viewer/TurnGroup.tsx +1 -0
- package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +1 -0
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +4 -0
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +1 -0
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +2 -0
- package/src/components/proxy-viewer/logEntryVisibility.ts +22 -0
- package/src/components/ui/dialog.tsx +1 -1
- package/src/components/ui/json-viewer.tsx +2 -0
- package/src/components/ui/select.tsx +1 -1
- package/src/router.tsx +9 -0
- package/.output/public/assets/CompareDrawer-Lx-WeJNC.js +0 -1
- package/.output/public/assets/ProxyViewerContainer-BNehwMI0.js +0 -106
- package/.output/public/assets/ReplayDialog-CADaXFPE.js +0 -1
- package/.output/public/assets/RequestAnatomy-CGoL8ACh.js +0 -1
- package/.output/public/assets/ResponseView-BSwM1dCH.js +0 -3
- package/.output/public/assets/StreamingChunkSequence-qhWtSx3D.js +0 -1
- package/.output/public/assets/_sessionId-2uq_HB8p.js +0 -1
- package/.output/public/assets/index-BHXN1Fsx.css +0 -1
- package/.output/public/assets/index-T0u1foYL.js +0 -1
- package/.output/public/assets/json-viewer-uIwLntt-.js +0 -1
- package/.output/public/assets/main-DuFBHsus.js +0 -18
- package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +0 -17
- package/.output/server/_libs/cfworker__json-schema.mjs +0 -1
- package/.output/server/_libs/tiny-invariant.mjs +0 -12
- package/.output/server/_libs/tiny-warning.mjs +0 -5
- package/.output/server/_tanstack-start-manifest_v-DsSiD2gY.mjs +0 -4
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { w as
|
|
3
|
-
import { i as isNotFound, d as defaultGetScrollRestorationKey, r as restoreScroll, e as escapeHtml, s as storageKey, a as rootRouteId, b as isRedirect, g as getLocationChangeInfo, t as transformReadableStreamWithRouter, c as transformPipeableStreamWithRouter, f as isDangerousProtocol, h as exactPathTest, j as removeTrailingSlash, k as deepEqual, l as functionalUpdate, B as BaseRootRoute, m as BaseRoute, n as isModuleNotFoundError, R as RouterCore } from "./tanstack__router-core.mjs";
|
|
4
|
-
import { i as invariant } from "./tiny-invariant.mjs";
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports, R as React } from "./react.mjs";
|
|
2
|
+
import { i as invariant, a as isDangerousProtocol, e as exactPathTest, r as removeTrailingSlash, h as hasKeys, d as deepEqual, f as functionalUpdate, B as BaseRootRoute, b as BaseRoute, c as isModuleNotFoundError, g as isNotFound, j as getScrollRestorationScriptForRouter, k as rootRouteId, l as isServer, m as isRedirect, n as createNonReactiveReadonlyStore, o as createNonReactiveMutableStore, R as RouterCore, p as escapeHtml, q as getAssetCrossOrigin, s as getScriptPreloadAttrs, t as appendUniqueUserTags, u as resolveManifestCssLink, v as transformReadableStreamWithRouter, w as createSsrStreamResponse, x as transformPipeableStreamWithRouter } from "./tanstack__router-core.mjs";
|
|
5
3
|
import { R as ReactDOMServer } from "./react-dom.mjs";
|
|
6
4
|
import { PassThrough } from "node:stream";
|
|
7
5
|
import { i as isbot } from "./isbot.mjs";
|
|
6
|
+
var reactUse = reactExports.use;
|
|
7
|
+
function useForwardedRef(ref) {
|
|
8
|
+
const innerRef = reactExports.useRef(null);
|
|
9
|
+
reactExports.useImperativeHandle(ref, () => innerRef.current, []);
|
|
10
|
+
return innerRef;
|
|
11
|
+
}
|
|
8
12
|
function CatchBoundary(props) {
|
|
9
13
|
const errorComponent = props.errorComponent ?? ErrorComponent;
|
|
10
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
reset
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return props.children;
|
|
23
|
-
}
|
|
14
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CatchBoundaryImpl, {
|
|
15
|
+
getResetKey: props.getResetKey,
|
|
16
|
+
onCatch: props.onCatch,
|
|
17
|
+
children: ({ error, reset }) => {
|
|
18
|
+
if (error) return reactExports.createElement(errorComponent, {
|
|
19
|
+
error,
|
|
20
|
+
reset
|
|
21
|
+
});
|
|
22
|
+
return props.children;
|
|
24
23
|
}
|
|
25
|
-
);
|
|
24
|
+
});
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
constructor() {
|
|
29
|
-
super(...
|
|
26
|
+
var CatchBoundaryImpl = class extends reactExports.Component {
|
|
27
|
+
constructor(..._args) {
|
|
28
|
+
super(..._args);
|
|
30
29
|
this.state = { error: null };
|
|
31
30
|
}
|
|
32
|
-
static getDerivedStateFromProps(props) {
|
|
33
|
-
|
|
31
|
+
static getDerivedStateFromProps(props, state) {
|
|
32
|
+
const resetKey = props.getResetKey();
|
|
33
|
+
if (state.error && state.resetKey !== resetKey) return {
|
|
34
|
+
resetKey,
|
|
35
|
+
error: null
|
|
36
|
+
};
|
|
37
|
+
return { resetKey };
|
|
34
38
|
}
|
|
35
39
|
static getDerivedStateFromError(error) {
|
|
36
40
|
return { error };
|
|
@@ -38,33 +42,36 @@ class CatchBoundaryImpl extends reactExports.Component {
|
|
|
38
42
|
reset() {
|
|
39
43
|
this.setState({ error: null });
|
|
40
44
|
}
|
|
41
|
-
componentDidUpdate(prevProps, prevState) {
|
|
42
|
-
if (prevState.error && prevState.resetKey !== this.state.resetKey) {
|
|
43
|
-
this.reset();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
45
|
componentDidCatch(error, errorInfo) {
|
|
47
|
-
if (this.props.onCatch)
|
|
48
|
-
this.props.onCatch(error, errorInfo);
|
|
49
|
-
}
|
|
46
|
+
if (this.props.onCatch) this.props.onCatch(error, errorInfo);
|
|
50
47
|
}
|
|
51
48
|
render() {
|
|
52
49
|
return this.props.children({
|
|
53
|
-
error: this.state.
|
|
50
|
+
error: this.state.error,
|
|
54
51
|
reset: () => {
|
|
55
52
|
this.reset();
|
|
56
53
|
}
|
|
57
54
|
});
|
|
58
55
|
}
|
|
59
|
-
}
|
|
56
|
+
};
|
|
60
57
|
function ErrorComponent({ error }) {
|
|
61
58
|
const [show, setShow] = reactExports.useState(false);
|
|
62
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
|
|
60
|
+
style: {
|
|
61
|
+
padding: ".5rem",
|
|
62
|
+
maxWidth: "100%"
|
|
63
|
+
},
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
|
|
66
|
+
style: {
|
|
67
|
+
display: "flex",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
gap: ".5rem"
|
|
70
|
+
},
|
|
71
|
+
children: [/* @__PURE__ */ jsxRuntimeExports.jsx("strong", {
|
|
72
|
+
style: { fontSize: "1rem" },
|
|
73
|
+
children: "Something went wrong!"
|
|
74
|
+
}), /* @__PURE__ */ jsxRuntimeExports.jsx("button", {
|
|
68
75
|
style: {
|
|
69
76
|
appearance: "none",
|
|
70
77
|
fontSize: ".6em",
|
|
@@ -75,13 +82,10 @@ function ErrorComponent({ error }) {
|
|
|
75
82
|
},
|
|
76
83
|
onClick: () => setShow((d) => !d),
|
|
77
84
|
children: show ? "Hide Error" : "Show Error"
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
show ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
83
|
-
"pre",
|
|
84
|
-
{
|
|
85
|
+
})]
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { height: ".25rem" } }),
|
|
88
|
+
show ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("pre", {
|
|
85
89
|
style: {
|
|
86
90
|
fontSize: ".7em",
|
|
87
91
|
border: "1px solid red",
|
|
@@ -91,504 +95,49 @@ function ErrorComponent({ error }) {
|
|
|
91
95
|
overflow: "auto"
|
|
92
96
|
},
|
|
93
97
|
children: error.message ? /* @__PURE__ */ jsxRuntimeExports.jsx("code", { children: error.message }) : null
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
] });
|
|
97
|
-
}
|
|
98
|
-
const routerContext = reactExports.createContext(null);
|
|
99
|
-
function getRouterContext() {
|
|
100
|
-
if (typeof document === "undefined") {
|
|
101
|
-
return routerContext;
|
|
102
|
-
}
|
|
103
|
-
if (window.__TSR_ROUTER_CONTEXT__) {
|
|
104
|
-
return window.__TSR_ROUTER_CONTEXT__;
|
|
105
|
-
}
|
|
106
|
-
window.__TSR_ROUTER_CONTEXT__ = routerContext;
|
|
107
|
-
return routerContext;
|
|
108
|
-
}
|
|
109
|
-
function useRouter(opts) {
|
|
110
|
-
const value = reactExports.useContext(getRouterContext());
|
|
111
|
-
warning(
|
|
112
|
-
!((opts?.warn ?? true) && !value)
|
|
113
|
-
);
|
|
114
|
-
return value;
|
|
115
|
-
}
|
|
116
|
-
function useRouterState(opts) {
|
|
117
|
-
const contextRouter = useRouter({
|
|
118
|
-
warn: opts?.router === void 0
|
|
119
|
-
});
|
|
120
|
-
const router = opts?.router || contextRouter;
|
|
121
|
-
{
|
|
122
|
-
const state = router.state;
|
|
123
|
-
return opts?.select ? opts.select(state) : state;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const REACT_USE = "use";
|
|
127
|
-
const reactUse = React[REACT_USE];
|
|
128
|
-
function useForwardedRef(ref) {
|
|
129
|
-
const innerRef = reactExports.useRef(null);
|
|
130
|
-
reactExports.useImperativeHandle(ref, () => innerRef.current, []);
|
|
131
|
-
return innerRef;
|
|
132
|
-
}
|
|
133
|
-
const matchContext = reactExports.createContext(void 0);
|
|
134
|
-
const dummyMatchContext = reactExports.createContext(
|
|
135
|
-
void 0
|
|
136
|
-
);
|
|
137
|
-
function CatchNotFound(props) {
|
|
138
|
-
const resetKey = useRouterState({
|
|
139
|
-
select: (s) => `not-found-${s.location.pathname}-${s.status}`
|
|
98
|
+
}) }) : null
|
|
99
|
+
]
|
|
140
100
|
});
|
|
141
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
142
|
-
CatchBoundary,
|
|
143
|
-
{
|
|
144
|
-
getResetKey: () => resetKey,
|
|
145
|
-
onCatch: (error, errorInfo) => {
|
|
146
|
-
if (isNotFound(error)) {
|
|
147
|
-
props.onCatch?.(error, errorInfo);
|
|
148
|
-
} else {
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
errorComponent: ({ error }) => {
|
|
153
|
-
if (isNotFound(error)) {
|
|
154
|
-
return props.fallback?.(error);
|
|
155
|
-
} else {
|
|
156
|
-
throw error;
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
children: props.children
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
function DefaultGlobalNotFound() {
|
|
164
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Not Found" });
|
|
165
|
-
}
|
|
166
|
-
function SafeFragment(props) {
|
|
167
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: props.children });
|
|
168
|
-
}
|
|
169
|
-
function renderRouteNotFound(router, route, data) {
|
|
170
|
-
if (!route.options.notFoundComponent) {
|
|
171
|
-
if (router.options.defaultNotFoundComponent) {
|
|
172
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.defaultNotFoundComponent, { ...data });
|
|
173
|
-
}
|
|
174
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultGlobalNotFound, {});
|
|
175
|
-
}
|
|
176
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(route.options.notFoundComponent, { ...data });
|
|
177
|
-
}
|
|
178
|
-
function ScriptOnce({ children }) {
|
|
179
|
-
const router = useRouter();
|
|
180
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
181
|
-
"script",
|
|
182
|
-
{
|
|
183
|
-
nonce: router.options.ssr?.nonce,
|
|
184
|
-
dangerouslySetInnerHTML: {
|
|
185
|
-
__html: children + ";document.currentScript.remove()"
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
function ScrollRestoration() {
|
|
191
|
-
const router = useRouter();
|
|
192
|
-
if (!router.isScrollRestoring || false) {
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
if (typeof router.options.scrollRestoration === "function") {
|
|
196
|
-
const shouldRestore = router.options.scrollRestoration({
|
|
197
|
-
location: router.latestLocation
|
|
198
|
-
});
|
|
199
|
-
if (!shouldRestore) {
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
|
|
204
|
-
const userKey = getKey(router.latestLocation);
|
|
205
|
-
const resolvedKey = userKey !== defaultGetScrollRestorationKey(router.latestLocation) ? userKey : void 0;
|
|
206
|
-
const restoreScrollOptions = {
|
|
207
|
-
storageKey,
|
|
208
|
-
shouldScrollRestoration: true
|
|
209
|
-
};
|
|
210
|
-
if (resolvedKey) {
|
|
211
|
-
restoreScrollOptions.key = resolvedKey;
|
|
212
|
-
}
|
|
213
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
214
|
-
ScriptOnce,
|
|
215
|
-
{
|
|
216
|
-
children: `(${restoreScroll.toString()})(${escapeHtml(JSON.stringify(restoreScrollOptions))})`
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
101
|
}
|
|
220
102
|
function ClientOnly({ children, fallback = null }) {
|
|
221
|
-
return useHydrated() ? /* @__PURE__ */ jsxRuntimeExports.jsx(React
|
|
103
|
+
return useHydrated() ? /* @__PURE__ */ jsxRuntimeExports.jsx(React.Fragment, { children }) : /* @__PURE__ */ jsxRuntimeExports.jsx(React.Fragment, { children: fallback });
|
|
222
104
|
}
|
|
223
105
|
function useHydrated() {
|
|
224
|
-
return React
|
|
225
|
-
subscribe,
|
|
226
|
-
() => true,
|
|
227
|
-
() => false
|
|
228
|
-
);
|
|
106
|
+
return React.useSyncExternalStore(subscribe, () => true, () => false);
|
|
229
107
|
}
|
|
230
108
|
function subscribe() {
|
|
231
109
|
return () => {
|
|
232
110
|
};
|
|
233
111
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const matchState = useRouterState({
|
|
239
|
-
select: (s) => {
|
|
240
|
-
const matchIndex = s.matches.findIndex((d) => d.id === matchId);
|
|
241
|
-
const match = s.matches[matchIndex];
|
|
242
|
-
invariant(
|
|
243
|
-
match
|
|
244
|
-
);
|
|
245
|
-
return {
|
|
246
|
-
routeId: match.routeId,
|
|
247
|
-
ssr: match.ssr,
|
|
248
|
-
_displayPending: match._displayPending,
|
|
249
|
-
resetKey: s.loadedAt,
|
|
250
|
-
parentRouteId: s.matches[matchIndex - 1]?.routeId
|
|
251
|
-
};
|
|
252
|
-
},
|
|
253
|
-
structuralSharing: true
|
|
254
|
-
});
|
|
255
|
-
const route = router.routesById[matchState.routeId];
|
|
256
|
-
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
257
|
-
const pendingElement = PendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(PendingComponent, {}) : null;
|
|
258
|
-
const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
|
|
259
|
-
const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
|
|
260
|
-
const routeNotFoundComponent = route.isRoot ? (
|
|
261
|
-
// If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
|
|
262
|
-
route.options.notFoundComponent ?? router.options.notFoundRoute?.options.component
|
|
263
|
-
) : route.options.notFoundComponent;
|
|
264
|
-
const resolvedNoSsr = matchState.ssr === false || matchState.ssr === "data-only";
|
|
265
|
-
const ResolvedSuspenseBoundary = (
|
|
266
|
-
// If we're on the root route, allow forcefully wrapping in suspense
|
|
267
|
-
(!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) && (route.options.wrapInSuspense ?? PendingComponent ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? reactExports.Suspense : SafeFragment
|
|
268
|
-
);
|
|
269
|
-
const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
|
|
270
|
-
const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
|
|
271
|
-
const ShellComponent = route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment;
|
|
272
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(ShellComponent, { children: [
|
|
273
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(matchContext.Provider, { value: matchId, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResolvedSuspenseBoundary, { fallback: pendingElement, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
274
|
-
ResolvedCatchBoundary,
|
|
275
|
-
{
|
|
276
|
-
getResetKey: () => matchState.resetKey,
|
|
277
|
-
errorComponent: routeErrorComponent || ErrorComponent,
|
|
278
|
-
onCatch: (error, errorInfo) => {
|
|
279
|
-
if (isNotFound(error)) throw error;
|
|
280
|
-
routeOnCatch?.(error, errorInfo);
|
|
281
|
-
},
|
|
282
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
283
|
-
ResolvedNotFoundBoundary,
|
|
284
|
-
{
|
|
285
|
-
fallback: (error) => {
|
|
286
|
-
if (!routeNotFoundComponent || error.routeId && error.routeId !== matchState.routeId || !error.routeId && !route.isRoot)
|
|
287
|
-
throw error;
|
|
288
|
-
return reactExports.createElement(routeNotFoundComponent, error);
|
|
289
|
-
},
|
|
290
|
-
children: resolvedNoSsr || matchState._displayPending ? /* @__PURE__ */ jsxRuntimeExports.jsx(ClientOnly, { fallback: pendingElement, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MatchInner, { matchId }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(MatchInner, { matchId })
|
|
291
|
-
}
|
|
292
|
-
)
|
|
293
|
-
}
|
|
294
|
-
) }) }),
|
|
295
|
-
matchState.parentRouteId === rootRouteId && router.options.scrollRestoration ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
296
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(OnRendered, {}),
|
|
297
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(ScrollRestoration, {})
|
|
298
|
-
] }) : null
|
|
299
|
-
] });
|
|
300
|
-
});
|
|
301
|
-
function OnRendered() {
|
|
302
|
-
const router = useRouter();
|
|
303
|
-
const prevLocationRef = reactExports.useRef(
|
|
304
|
-
void 0
|
|
305
|
-
);
|
|
306
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
307
|
-
"script",
|
|
308
|
-
{
|
|
309
|
-
suppressHydrationWarning: true,
|
|
310
|
-
ref: (el) => {
|
|
311
|
-
if (el && (prevLocationRef.current === void 0 || prevLocationRef.current.href !== router.latestLocation.href)) {
|
|
312
|
-
router.emit({
|
|
313
|
-
type: "onRendered",
|
|
314
|
-
...getLocationChangeInfo(router.state)
|
|
315
|
-
});
|
|
316
|
-
prevLocationRef.current = router.latestLocation;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
router.latestLocation.state.__TSR_key
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
const MatchInner = reactExports.memo(function MatchInnerImpl({
|
|
324
|
-
matchId
|
|
325
|
-
}) {
|
|
326
|
-
const router = useRouter();
|
|
327
|
-
const { match, key, routeId } = useRouterState({
|
|
328
|
-
select: (s) => {
|
|
329
|
-
const match2 = s.matches.find((d) => d.id === matchId);
|
|
330
|
-
const routeId2 = match2.routeId;
|
|
331
|
-
const remountFn = router.routesById[routeId2].options.remountDeps ?? router.options.defaultRemountDeps;
|
|
332
|
-
const remountDeps = remountFn?.({
|
|
333
|
-
routeId: routeId2,
|
|
334
|
-
loaderDeps: match2.loaderDeps,
|
|
335
|
-
params: match2._strictParams,
|
|
336
|
-
search: match2._strictSearch
|
|
337
|
-
});
|
|
338
|
-
const key2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
|
|
339
|
-
return {
|
|
340
|
-
key: key2,
|
|
341
|
-
routeId: routeId2,
|
|
342
|
-
match: {
|
|
343
|
-
id: match2.id,
|
|
344
|
-
status: match2.status,
|
|
345
|
-
error: match2.error,
|
|
346
|
-
invalid: match2.invalid,
|
|
347
|
-
_forcePending: match2._forcePending,
|
|
348
|
-
_displayPending: match2._displayPending
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
},
|
|
352
|
-
structuralSharing: true
|
|
353
|
-
});
|
|
354
|
-
const route = router.routesById[routeId];
|
|
355
|
-
const out = reactExports.useMemo(() => {
|
|
356
|
-
const Comp = route.options.component ?? router.options.defaultComponent;
|
|
357
|
-
if (Comp) {
|
|
358
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(Comp, {}, key);
|
|
359
|
-
}
|
|
360
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(Outlet, {});
|
|
361
|
-
}, [key, route.options.component, router.options.defaultComponent]);
|
|
362
|
-
if (match._displayPending) {
|
|
363
|
-
throw router.getMatch(match.id)?._nonReactive.displayPendingPromise;
|
|
364
|
-
}
|
|
365
|
-
if (match._forcePending) {
|
|
366
|
-
throw router.getMatch(match.id)?._nonReactive.minPendingPromise;
|
|
367
|
-
}
|
|
368
|
-
if (match.status === "pending") {
|
|
369
|
-
const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
|
|
370
|
-
if (pendingMinMs) {
|
|
371
|
-
const routerMatch = router.getMatch(match.id);
|
|
372
|
-
if (routerMatch && !routerMatch._nonReactive.minPendingPromise) ;
|
|
373
|
-
}
|
|
374
|
-
throw router.getMatch(match.id)?._nonReactive.loadPromise;
|
|
375
|
-
}
|
|
376
|
-
if (match.status === "notFound") {
|
|
377
|
-
invariant(isNotFound(match.error));
|
|
378
|
-
return renderRouteNotFound(router, route, match.error);
|
|
379
|
-
}
|
|
380
|
-
if (match.status === "redirected") {
|
|
381
|
-
invariant(isRedirect(match.error));
|
|
382
|
-
throw router.getMatch(match.id)?._nonReactive.loadPromise;
|
|
383
|
-
}
|
|
384
|
-
if (match.status === "error") {
|
|
385
|
-
{
|
|
386
|
-
const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent;
|
|
387
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
388
|
-
RouteErrorComponent,
|
|
389
|
-
{
|
|
390
|
-
error: match.error,
|
|
391
|
-
reset: void 0,
|
|
392
|
-
info: {
|
|
393
|
-
componentStack: ""
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return out;
|
|
400
|
-
});
|
|
401
|
-
const Outlet = reactExports.memo(function OutletImpl() {
|
|
402
|
-
const router = useRouter();
|
|
403
|
-
const matchId = reactExports.useContext(matchContext);
|
|
404
|
-
const routeId = useRouterState({
|
|
405
|
-
select: (s) => s.matches.find((d) => d.id === matchId)?.routeId
|
|
406
|
-
});
|
|
407
|
-
const route = router.routesById[routeId];
|
|
408
|
-
const parentGlobalNotFound = useRouterState({
|
|
409
|
-
select: (s) => {
|
|
410
|
-
const matches = s.matches;
|
|
411
|
-
const parentMatch = matches.find((d) => d.id === matchId);
|
|
412
|
-
invariant(
|
|
413
|
-
parentMatch
|
|
414
|
-
);
|
|
415
|
-
return parentMatch.globalNotFound;
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
const childMatchId = useRouterState({
|
|
419
|
-
select: (s) => {
|
|
420
|
-
const matches = s.matches;
|
|
421
|
-
const index = matches.findIndex((d) => d.id === matchId);
|
|
422
|
-
return matches[index + 1]?.id;
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
const pendingElement = router.options.defaultPendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.defaultPendingComponent, {}) : null;
|
|
426
|
-
if (parentGlobalNotFound) {
|
|
427
|
-
return renderRouteNotFound(router, route, void 0);
|
|
428
|
-
}
|
|
429
|
-
if (!childMatchId) {
|
|
430
|
-
return null;
|
|
431
|
-
}
|
|
432
|
-
const nextMatch = /* @__PURE__ */ jsxRuntimeExports.jsx(Match, { matchId: childMatchId });
|
|
433
|
-
if (routeId === rootRouteId) {
|
|
434
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: pendingElement, children: nextMatch });
|
|
435
|
-
}
|
|
436
|
-
return nextMatch;
|
|
437
|
-
});
|
|
438
|
-
function Matches() {
|
|
439
|
-
const router = useRouter();
|
|
440
|
-
const rootRoute = router.routesById[rootRouteId];
|
|
441
|
-
const PendingComponent = rootRoute.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
442
|
-
const pendingElement = PendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(PendingComponent, {}) : null;
|
|
443
|
-
const ResolvedSuspense = SafeFragment;
|
|
444
|
-
const inner = /* @__PURE__ */ jsxRuntimeExports.jsxs(ResolvedSuspense, { fallback: pendingElement, children: [
|
|
445
|
-
false,
|
|
446
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(MatchesInner, {})
|
|
447
|
-
] });
|
|
448
|
-
return router.options.InnerWrap ? /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.InnerWrap, { children: inner }) : inner;
|
|
112
|
+
var routerContext = reactExports.createContext(null);
|
|
113
|
+
function useRouter(opts) {
|
|
114
|
+
const value = reactExports.useContext(routerContext);
|
|
115
|
+
return value;
|
|
449
116
|
}
|
|
450
|
-
|
|
117
|
+
var matchContext = reactExports.createContext(void 0);
|
|
118
|
+
var dummyMatchContext = reactExports.createContext(void 0);
|
|
119
|
+
function useMatch(opts) {
|
|
451
120
|
const router = useRouter();
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
});
|
|
460
|
-
const matchComponent = matchId ? /* @__PURE__ */ jsxRuntimeExports.jsx(Match, { matchId }) : null;
|
|
461
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(matchContext.Provider, { value: matchId, children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
462
|
-
CatchBoundary,
|
|
463
|
-
{
|
|
464
|
-
getResetKey: () => resetKey,
|
|
465
|
-
errorComponent: ErrorComponent,
|
|
466
|
-
onCatch: (error) => {
|
|
467
|
-
warning(false, error.message || error.toString());
|
|
468
|
-
},
|
|
469
|
-
children: matchComponent
|
|
470
|
-
}
|
|
471
|
-
) });
|
|
472
|
-
}
|
|
473
|
-
function RouterContextProvider({
|
|
474
|
-
router,
|
|
475
|
-
children,
|
|
476
|
-
...rest
|
|
477
|
-
}) {
|
|
478
|
-
if (Object.keys(rest).length > 0) {
|
|
479
|
-
router.update({
|
|
480
|
-
...router.options,
|
|
481
|
-
...rest,
|
|
482
|
-
context: {
|
|
483
|
-
...router.options.context,
|
|
484
|
-
...rest.context
|
|
121
|
+
const nearestMatchId = reactExports.useContext(opts.from ? dummyMatchContext : matchContext);
|
|
122
|
+
const matchStore = opts.from ? router.stores.getRouteMatchStore(opts.from) : router.stores.matchStores.get(nearestMatchId);
|
|
123
|
+
{
|
|
124
|
+
const match = matchStore?.get();
|
|
125
|
+
if (!match) {
|
|
126
|
+
if (opts.shouldThrow ?? true) {
|
|
127
|
+
invariant();
|
|
485
128
|
}
|
|
486
|
-
|
|
487
|
-
}
|
|
488
|
-
const routerContext2 = getRouterContext();
|
|
489
|
-
const provider = /* @__PURE__ */ jsxRuntimeExports.jsx(routerContext2.Provider, { value: router, children });
|
|
490
|
-
if (router.options.Wrap) {
|
|
491
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.Wrap, { children: provider });
|
|
492
|
-
}
|
|
493
|
-
return provider;
|
|
494
|
-
}
|
|
495
|
-
function RouterProvider({ router, ...rest }) {
|
|
496
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(RouterContextProvider, { router, ...rest, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Matches, {}) });
|
|
497
|
-
}
|
|
498
|
-
const renderRouterToStream = async ({
|
|
499
|
-
request,
|
|
500
|
-
router,
|
|
501
|
-
responseHeaders,
|
|
502
|
-
children
|
|
503
|
-
}) => {
|
|
504
|
-
if (typeof ReactDOMServer.renderToReadableStream === "function") {
|
|
505
|
-
const stream = await ReactDOMServer.renderToReadableStream(children, {
|
|
506
|
-
signal: request.signal,
|
|
507
|
-
nonce: router.options.ssr?.nonce,
|
|
508
|
-
progressiveChunkSize: Number.POSITIVE_INFINITY
|
|
509
|
-
});
|
|
510
|
-
if (isbot(request.headers.get("User-Agent"))) {
|
|
511
|
-
await stream.allReady;
|
|
512
|
-
}
|
|
513
|
-
const responseStream = transformReadableStreamWithRouter(
|
|
514
|
-
router,
|
|
515
|
-
stream
|
|
516
|
-
);
|
|
517
|
-
return new Response(responseStream, {
|
|
518
|
-
status: router.state.statusCode,
|
|
519
|
-
headers: responseHeaders
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
if (typeof ReactDOMServer.renderToPipeableStream === "function") {
|
|
523
|
-
const reactAppPassthrough = new PassThrough();
|
|
524
|
-
try {
|
|
525
|
-
const pipeable = ReactDOMServer.renderToPipeableStream(children, {
|
|
526
|
-
nonce: router.options.ssr?.nonce,
|
|
527
|
-
progressiveChunkSize: Number.POSITIVE_INFINITY,
|
|
528
|
-
...isbot(request.headers.get("User-Agent")) ? {
|
|
529
|
-
onAllReady() {
|
|
530
|
-
pipeable.pipe(reactAppPassthrough);
|
|
531
|
-
}
|
|
532
|
-
} : {
|
|
533
|
-
onShellReady() {
|
|
534
|
-
pipeable.pipe(reactAppPassthrough);
|
|
535
|
-
}
|
|
536
|
-
},
|
|
537
|
-
onError: (error, info) => {
|
|
538
|
-
console.error("Error in renderToPipeableStream:", error, info);
|
|
539
|
-
if (!reactAppPassthrough.destroyed) {
|
|
540
|
-
reactAppPassthrough.destroy(
|
|
541
|
-
error instanceof Error ? error : new Error(String(error))
|
|
542
|
-
);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
} catch (e) {
|
|
547
|
-
console.error("Error in renderToPipeableStream:", e);
|
|
548
|
-
reactAppPassthrough.destroy(e instanceof Error ? e : new Error(String(e)));
|
|
129
|
+
return;
|
|
549
130
|
}
|
|
550
|
-
|
|
551
|
-
router,
|
|
552
|
-
reactAppPassthrough
|
|
553
|
-
);
|
|
554
|
-
return new Response(responseStream, {
|
|
555
|
-
status: router.state.statusCode,
|
|
556
|
-
headers: responseHeaders
|
|
557
|
-
});
|
|
131
|
+
return opts.select ? opts.select(match) : match;
|
|
558
132
|
}
|
|
559
|
-
throw new Error(
|
|
560
|
-
"No renderToReadableStream or renderToPipeableStream found in react-dom/server. Ensure you are using a version of react-dom that supports streaming."
|
|
561
|
-
);
|
|
562
|
-
};
|
|
563
|
-
function useMatch(opts) {
|
|
564
|
-
const nearestMatchId = reactExports.useContext(
|
|
565
|
-
opts.from ? dummyMatchContext : matchContext
|
|
566
|
-
);
|
|
567
|
-
const matchSelection = useRouterState({
|
|
568
|
-
select: (state) => {
|
|
569
|
-
const match = state.matches.find(
|
|
570
|
-
(d) => opts.from ? opts.from === d.routeId : d.id === nearestMatchId
|
|
571
|
-
);
|
|
572
|
-
invariant(
|
|
573
|
-
!((opts.shouldThrow ?? true) && !match),
|
|
574
|
-
`Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`
|
|
575
|
-
);
|
|
576
|
-
if (match === void 0) {
|
|
577
|
-
return void 0;
|
|
578
|
-
}
|
|
579
|
-
return opts.select ? opts.select(match) : match;
|
|
580
|
-
},
|
|
581
|
-
structuralSharing: opts.structuralSharing
|
|
582
|
-
});
|
|
583
|
-
return matchSelection;
|
|
584
133
|
}
|
|
585
134
|
function useLoaderData(opts) {
|
|
586
135
|
return useMatch({
|
|
587
136
|
from: opts.from,
|
|
588
137
|
strict: opts.strict,
|
|
589
138
|
structuralSharing: opts.structuralSharing,
|
|
590
|
-
select: (
|
|
591
|
-
return opts.select ? opts.select(
|
|
139
|
+
select: (match) => {
|
|
140
|
+
return opts.select ? opts.select(match.loaderData) : match.loaderData;
|
|
592
141
|
}
|
|
593
142
|
});
|
|
594
143
|
}
|
|
@@ -596,8 +145,8 @@ function useLoaderDeps(opts) {
|
|
|
596
145
|
const { select, ...rest } = opts;
|
|
597
146
|
return useMatch({
|
|
598
147
|
...rest,
|
|
599
|
-
select: (
|
|
600
|
-
return select ? select(
|
|
148
|
+
select: (match) => {
|
|
149
|
+
return select ? select(match.loaderDeps) : match.loaderDeps;
|
|
601
150
|
}
|
|
602
151
|
});
|
|
603
152
|
}
|
|
@@ -626,196 +175,121 @@ function useSearch(opts) {
|
|
|
626
175
|
}
|
|
627
176
|
function useNavigate(_defaultOpts) {
|
|
628
177
|
const router = useRouter();
|
|
629
|
-
return reactExports.useCallback(
|
|
630
|
-
(
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
178
|
+
return reactExports.useCallback((options) => {
|
|
179
|
+
return router.navigate({
|
|
180
|
+
...options,
|
|
181
|
+
from: options.from ?? _defaultOpts?.from
|
|
182
|
+
});
|
|
183
|
+
}, [_defaultOpts?.from, router]);
|
|
184
|
+
}
|
|
185
|
+
function useRouteContext(opts) {
|
|
186
|
+
return useMatch({
|
|
187
|
+
...opts,
|
|
188
|
+
select: (match) => opts.select ? opts.select(match.context) : match.context
|
|
189
|
+
});
|
|
638
190
|
}
|
|
639
191
|
function useLinkProps(options, forwardedRef) {
|
|
640
192
|
const router = useRouter();
|
|
641
193
|
const innerRef = useForwardedRef(forwardedRef);
|
|
642
|
-
const {
|
|
643
|
-
// custom props
|
|
644
|
-
activeProps,
|
|
645
|
-
inactiveProps,
|
|
646
|
-
activeOptions,
|
|
647
|
-
to,
|
|
648
|
-
preload: userPreload,
|
|
649
|
-
preloadDelay: userPreloadDelay,
|
|
650
|
-
hashScrollIntoView,
|
|
651
|
-
replace,
|
|
652
|
-
startTransition,
|
|
653
|
-
resetScroll,
|
|
654
|
-
viewTransition,
|
|
655
|
-
// element props
|
|
656
|
-
children,
|
|
657
|
-
target,
|
|
658
|
-
disabled,
|
|
659
|
-
style,
|
|
660
|
-
className,
|
|
661
|
-
onClick,
|
|
662
|
-
onFocus,
|
|
663
|
-
onMouseEnter,
|
|
664
|
-
onMouseLeave,
|
|
665
|
-
onTouchStart,
|
|
666
|
-
ignoreBlocker,
|
|
667
|
-
// prevent these from being returned
|
|
668
|
-
params: _params,
|
|
669
|
-
search: _search,
|
|
670
|
-
hash: _hash,
|
|
671
|
-
state: _state,
|
|
672
|
-
mask: _mask,
|
|
673
|
-
reloadDocument: _reloadDocument,
|
|
674
|
-
unsafeRelative: _unsafeRelative,
|
|
675
|
-
from: _from,
|
|
676
|
-
_fromLocation,
|
|
677
|
-
...propsSafeToSpread
|
|
678
|
-
} = options;
|
|
194
|
+
const { activeProps, inactiveProps, activeOptions, to, preload: userPreload, preloadDelay: userPreloadDelay, preloadIntentProximity: _preloadIntentProximity, hashScrollIntoView, replace, startTransition, resetScroll, viewTransition, children, target, disabled, style, className, onClick, onBlur, onFocus, onMouseEnter, onMouseLeave, onTouchStart, ignoreBlocker, params: _params, search: _search, hash: _hash, state: _state, mask: _mask, reloadDocument: _reloadDocument, unsafeRelative: _unsafeRelative, from: _from, _fromLocation, ...propsSafeToSpread } = options;
|
|
679
195
|
{
|
|
680
196
|
const safeInternal = isSafeInternal(to);
|
|
681
|
-
if (typeof to === "string" && !safeInternal &&
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
if (isDangerousProtocol(to, router.protocolAllowlist)) {
|
|
686
|
-
if (false) ;
|
|
687
|
-
return {
|
|
688
|
-
...propsSafeToSpread,
|
|
689
|
-
ref: innerRef,
|
|
690
|
-
href: void 0,
|
|
691
|
-
...children && { children },
|
|
692
|
-
...target && { target },
|
|
693
|
-
...disabled && { disabled },
|
|
694
|
-
...style && { style },
|
|
695
|
-
...className && { className }
|
|
696
|
-
};
|
|
697
|
-
}
|
|
197
|
+
if (typeof to === "string" && !safeInternal && to.indexOf(":") > -1) try {
|
|
198
|
+
new URL(to);
|
|
199
|
+
if (isDangerousProtocol(to, router.protocolAllowlist)) {
|
|
200
|
+
if (false) ;
|
|
698
201
|
return {
|
|
699
202
|
...propsSafeToSpread,
|
|
700
203
|
ref: innerRef,
|
|
701
|
-
href:
|
|
204
|
+
href: void 0,
|
|
702
205
|
...children && { children },
|
|
703
206
|
...target && { target },
|
|
704
207
|
...disabled && { disabled },
|
|
705
208
|
...style && { style },
|
|
706
209
|
...className && { className }
|
|
707
210
|
};
|
|
708
|
-
} catch {
|
|
709
211
|
}
|
|
212
|
+
return {
|
|
213
|
+
...propsSafeToSpread,
|
|
214
|
+
ref: innerRef,
|
|
215
|
+
href: to,
|
|
216
|
+
...children && { children },
|
|
217
|
+
...target && { target },
|
|
218
|
+
...disabled && { disabled },
|
|
219
|
+
...style && { style },
|
|
220
|
+
...className && { className }
|
|
221
|
+
};
|
|
222
|
+
} catch {
|
|
710
223
|
}
|
|
711
|
-
const next2 = router.buildLocation({
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
hrefOptionExternal2,
|
|
717
|
-
router.history,
|
|
718
|
-
disabled
|
|
719
|
-
);
|
|
224
|
+
const next2 = router.buildLocation({
|
|
225
|
+
...options,
|
|
226
|
+
from: options.from
|
|
227
|
+
});
|
|
228
|
+
const hrefOption2 = getHrefOption(next2.maskedLocation ? next2.maskedLocation.publicHref : next2.publicHref, next2.maskedLocation ? next2.maskedLocation.external : next2.external, router.history, disabled);
|
|
720
229
|
const externalLink2 = (() => {
|
|
721
230
|
if (hrefOption2?.external) {
|
|
722
231
|
if (isDangerousProtocol(hrefOption2.href, router.protocolAllowlist)) {
|
|
723
|
-
return
|
|
232
|
+
return;
|
|
724
233
|
}
|
|
725
234
|
return hrefOption2.href;
|
|
726
235
|
}
|
|
727
236
|
if (safeInternal) return void 0;
|
|
728
|
-
if (typeof to === "string" && to.indexOf(":") > -1) {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
if (
|
|
732
|
-
|
|
733
|
-
return void 0;
|
|
734
|
-
}
|
|
735
|
-
return to;
|
|
736
|
-
} catch {
|
|
237
|
+
if (typeof to === "string" && to.indexOf(":") > -1) try {
|
|
238
|
+
new URL(to);
|
|
239
|
+
if (isDangerousProtocol(to, router.protocolAllowlist)) {
|
|
240
|
+
if (false) ;
|
|
241
|
+
return;
|
|
737
242
|
}
|
|
243
|
+
return to;
|
|
244
|
+
} catch {
|
|
738
245
|
}
|
|
739
|
-
return void 0;
|
|
740
246
|
})();
|
|
741
247
|
const isActive2 = (() => {
|
|
742
248
|
if (externalLink2) return false;
|
|
743
|
-
const
|
|
249
|
+
const currentLocation2 = router.stores.location.get();
|
|
744
250
|
const exact = activeOptions?.exact ?? false;
|
|
745
251
|
if (exact) {
|
|
746
|
-
|
|
747
|
-
currentLocation.pathname,
|
|
748
|
-
next2.pathname,
|
|
749
|
-
router.basepath
|
|
750
|
-
);
|
|
751
|
-
if (!testExact) {
|
|
752
|
-
return false;
|
|
753
|
-
}
|
|
252
|
+
if (!exactPathTest(currentLocation2.pathname, next2.pathname, router.basepath)) return false;
|
|
754
253
|
} else {
|
|
755
|
-
const currentPathSplit = removeTrailingSlash(
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
);
|
|
759
|
-
const nextPathSplit = removeTrailingSlash(
|
|
760
|
-
next2.pathname,
|
|
761
|
-
router.basepath
|
|
762
|
-
);
|
|
763
|
-
const pathIsFuzzyEqual = currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/");
|
|
764
|
-
if (!pathIsFuzzyEqual) {
|
|
765
|
-
return false;
|
|
766
|
-
}
|
|
254
|
+
const currentPathSplit = removeTrailingSlash(currentLocation2.pathname, router.basepath);
|
|
255
|
+
const nextPathSplit = removeTrailingSlash(next2.pathname, router.basepath);
|
|
256
|
+
if (!(currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/"))) return false;
|
|
767
257
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
const
|
|
772
|
-
const nextSearchEmpty = !next2.search || typeof next2.search === "object" && Object.keys(next2.search).length === 0;
|
|
258
|
+
if (activeOptions?.includeSearch ?? true) {
|
|
259
|
+
if (currentLocation2.search !== next2.search) {
|
|
260
|
+
const currentSearchEmpty = !currentLocation2.search || typeof currentLocation2.search === "object" && !hasKeys(currentLocation2.search);
|
|
261
|
+
const nextSearchEmpty = !next2.search || typeof next2.search === "object" && !hasKeys(next2.search);
|
|
773
262
|
if (!(currentSearchEmpty && nextSearchEmpty)) {
|
|
774
|
-
|
|
263
|
+
if (!deepEqual(currentLocation2.search, next2.search, {
|
|
775
264
|
partial: !exact,
|
|
776
265
|
ignoreUndefined: !activeOptions?.explicitUndefined
|
|
777
|
-
});
|
|
778
|
-
if (!searchTest) {
|
|
779
|
-
return false;
|
|
780
|
-
}
|
|
266
|
+
})) return false;
|
|
781
267
|
}
|
|
782
268
|
}
|
|
783
269
|
}
|
|
784
|
-
if (activeOptions?.includeHash)
|
|
785
|
-
return false;
|
|
786
|
-
}
|
|
270
|
+
if (activeOptions?.includeHash) return false;
|
|
787
271
|
return true;
|
|
788
272
|
})();
|
|
789
|
-
if (externalLink2) {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
};
|
|
800
|
-
}
|
|
273
|
+
if (externalLink2) return {
|
|
274
|
+
...propsSafeToSpread,
|
|
275
|
+
ref: innerRef,
|
|
276
|
+
href: externalLink2,
|
|
277
|
+
...children && { children },
|
|
278
|
+
...target && { target },
|
|
279
|
+
...disabled && { disabled },
|
|
280
|
+
...style && { style },
|
|
281
|
+
...className && { className }
|
|
282
|
+
};
|
|
801
283
|
const resolvedActiveProps2 = isActive2 ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
|
|
802
284
|
const resolvedInactiveProps2 = isActive2 ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
|
|
803
285
|
const resolvedStyle2 = (() => {
|
|
804
286
|
const baseStyle = style;
|
|
805
287
|
const activeStyle = resolvedActiveProps2.style;
|
|
806
288
|
const inactiveStyle = resolvedInactiveProps2.style;
|
|
807
|
-
if (!baseStyle && !activeStyle && !inactiveStyle)
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
if (baseStyle && !activeStyle &&
|
|
811
|
-
return baseStyle;
|
|
812
|
-
}
|
|
813
|
-
if (!baseStyle && activeStyle && !inactiveStyle) {
|
|
814
|
-
return activeStyle;
|
|
815
|
-
}
|
|
816
|
-
if (!baseStyle && !activeStyle && inactiveStyle) {
|
|
817
|
-
return inactiveStyle;
|
|
818
|
-
}
|
|
289
|
+
if (!baseStyle && !activeStyle && !inactiveStyle) return;
|
|
290
|
+
if (baseStyle && !activeStyle && !inactiveStyle) return baseStyle;
|
|
291
|
+
if (!baseStyle && activeStyle && !inactiveStyle) return activeStyle;
|
|
292
|
+
if (!baseStyle && !activeStyle && inactiveStyle) return inactiveStyle;
|
|
819
293
|
return {
|
|
820
294
|
...baseStyle,
|
|
821
295
|
...activeStyle,
|
|
@@ -826,19 +300,11 @@ function useLinkProps(options, forwardedRef) {
|
|
|
826
300
|
const baseClassName = className;
|
|
827
301
|
const activeClassName = resolvedActiveProps2.className;
|
|
828
302
|
const inactiveClassName = resolvedInactiveProps2.className;
|
|
829
|
-
if (!baseClassName && !activeClassName && !inactiveClassName)
|
|
830
|
-
return "";
|
|
831
|
-
}
|
|
303
|
+
if (!baseClassName && !activeClassName && !inactiveClassName) return "";
|
|
832
304
|
let out = "";
|
|
833
|
-
if (baseClassName)
|
|
834
|
-
|
|
835
|
-
}
|
|
836
|
-
if (activeClassName) {
|
|
837
|
-
out = out ? `${out} ${activeClassName}` : activeClassName;
|
|
838
|
-
}
|
|
839
|
-
if (inactiveClassName) {
|
|
840
|
-
out = out ? `${out} ${inactiveClassName}` : inactiveClassName;
|
|
841
|
-
}
|
|
305
|
+
if (baseClassName) out = baseClassName;
|
|
306
|
+
if (activeClassName) out = out ? `${out} ${activeClassName}` : activeClassName;
|
|
307
|
+
if (inactiveClassName) out = out ? `${out} ${inactiveClassName}` : inactiveClassName;
|
|
842
308
|
return out;
|
|
843
309
|
})();
|
|
844
310
|
return {
|
|
@@ -856,15 +322,22 @@ function useLinkProps(options, forwardedRef) {
|
|
|
856
322
|
};
|
|
857
323
|
}
|
|
858
324
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
325
|
+
var STATIC_EMPTY_OBJECT = {};
|
|
326
|
+
var STATIC_ACTIVE_OBJECT = { className: "active" };
|
|
327
|
+
var STATIC_DISABLED_PROPS = {
|
|
328
|
+
role: "link",
|
|
329
|
+
"aria-disabled": true
|
|
330
|
+
};
|
|
331
|
+
var STATIC_ACTIVE_PROPS = {
|
|
332
|
+
"data-status": "active",
|
|
333
|
+
"aria-current": "page"
|
|
334
|
+
};
|
|
863
335
|
function getHrefOption(publicHref, external, history, disabled) {
|
|
864
336
|
if (disabled) return void 0;
|
|
865
|
-
if (external) {
|
|
866
|
-
|
|
867
|
-
|
|
337
|
+
if (external) return {
|
|
338
|
+
href: publicHref,
|
|
339
|
+
external: true
|
|
340
|
+
};
|
|
868
341
|
return {
|
|
869
342
|
href: history.createHref(publicHref) || "/",
|
|
870
343
|
external: false
|
|
@@ -876,24 +349,20 @@ function isSafeInternal(to) {
|
|
|
876
349
|
if (zero === 47) return to.charCodeAt(1) !== 47;
|
|
877
350
|
return zero === 46;
|
|
878
351
|
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
if (!_asChild) {
|
|
887
|
-
const { disabled: _, ...rest2 } = linkProps;
|
|
888
|
-
return reactExports.createElement("a", rest2, children);
|
|
889
|
-
}
|
|
890
|
-
return reactExports.createElement(_asChild, linkProps, children);
|
|
352
|
+
var Link = reactExports.forwardRef((props, ref) => {
|
|
353
|
+
const { _asChild, ...rest } = props;
|
|
354
|
+
const { type: _type, ...linkProps } = useLinkProps(rest, ref);
|
|
355
|
+
const children = typeof rest.children === "function" ? rest.children({ isActive: linkProps["data-status"] === "active" }) : rest.children;
|
|
356
|
+
if (!_asChild) {
|
|
357
|
+
const { disabled: _, ...rest2 } = linkProps;
|
|
358
|
+
return reactExports.createElement("a", rest2, children);
|
|
891
359
|
}
|
|
892
|
-
);
|
|
893
|
-
|
|
360
|
+
return reactExports.createElement(_asChild, linkProps, children);
|
|
361
|
+
});
|
|
362
|
+
var Route = class extends BaseRoute {
|
|
894
363
|
/**
|
|
895
|
-
|
|
896
|
-
|
|
364
|
+
* @deprecated Use the `createRoute` function instead.
|
|
365
|
+
*/
|
|
897
366
|
constructor(options) {
|
|
898
367
|
super(options);
|
|
899
368
|
this.useMatch = (opts) => {
|
|
@@ -904,10 +373,9 @@ class Route extends BaseRoute {
|
|
|
904
373
|
});
|
|
905
374
|
};
|
|
906
375
|
this.useRouteContext = (opts) => {
|
|
907
|
-
return
|
|
376
|
+
return useRouteContext({
|
|
908
377
|
...opts,
|
|
909
|
-
from: this.id
|
|
910
|
-
select: (d) => opts?.select ? opts.select(d.context) : d.context
|
|
378
|
+
from: this.id
|
|
911
379
|
});
|
|
912
380
|
};
|
|
913
381
|
this.useSearch = (opts) => {
|
|
@@ -925,32 +393,36 @@ class Route extends BaseRoute {
|
|
|
925
393
|
});
|
|
926
394
|
};
|
|
927
395
|
this.useLoaderDeps = (opts) => {
|
|
928
|
-
return useLoaderDeps({
|
|
396
|
+
return useLoaderDeps({
|
|
397
|
+
...opts,
|
|
398
|
+
from: this.id
|
|
399
|
+
});
|
|
929
400
|
};
|
|
930
401
|
this.useLoaderData = (opts) => {
|
|
931
|
-
return useLoaderData({
|
|
402
|
+
return useLoaderData({
|
|
403
|
+
...opts,
|
|
404
|
+
from: this.id
|
|
405
|
+
});
|
|
932
406
|
};
|
|
933
407
|
this.useNavigate = () => {
|
|
934
408
|
return useNavigate({ from: this.fullPath });
|
|
935
409
|
};
|
|
936
|
-
this.Link = React
|
|
937
|
-
(
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
410
|
+
this.Link = React.forwardRef((props, ref) => {
|
|
411
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Link, {
|
|
412
|
+
ref,
|
|
413
|
+
from: this.fullPath,
|
|
414
|
+
...props
|
|
415
|
+
});
|
|
416
|
+
});
|
|
942
417
|
}
|
|
943
|
-
}
|
|
418
|
+
};
|
|
944
419
|
function createRoute(options) {
|
|
945
|
-
return new Route(
|
|
946
|
-
// TODO: Help us TypeChris, you're our only hope!
|
|
947
|
-
options
|
|
948
|
-
);
|
|
420
|
+
return new Route(options);
|
|
949
421
|
}
|
|
950
|
-
|
|
422
|
+
var RootRoute = class extends BaseRootRoute {
|
|
951
423
|
/**
|
|
952
|
-
|
|
953
|
-
|
|
424
|
+
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
425
|
+
*/
|
|
954
426
|
constructor(options) {
|
|
955
427
|
super(options);
|
|
956
428
|
this.useMatch = (opts) => {
|
|
@@ -961,10 +433,9 @@ class RootRoute extends BaseRootRoute {
|
|
|
961
433
|
});
|
|
962
434
|
};
|
|
963
435
|
this.useRouteContext = (opts) => {
|
|
964
|
-
return
|
|
436
|
+
return useRouteContext({
|
|
965
437
|
...opts,
|
|
966
|
-
from: this.id
|
|
967
|
-
select: (d) => opts?.select ? opts.select(d.context) : d.context
|
|
438
|
+
from: this.id
|
|
968
439
|
});
|
|
969
440
|
};
|
|
970
441
|
this.useSearch = (opts) => {
|
|
@@ -982,121 +453,67 @@ class RootRoute extends BaseRootRoute {
|
|
|
982
453
|
});
|
|
983
454
|
};
|
|
984
455
|
this.useLoaderDeps = (opts) => {
|
|
985
|
-
return useLoaderDeps({
|
|
456
|
+
return useLoaderDeps({
|
|
457
|
+
...opts,
|
|
458
|
+
from: this.id
|
|
459
|
+
});
|
|
986
460
|
};
|
|
987
461
|
this.useLoaderData = (opts) => {
|
|
988
|
-
return useLoaderData({
|
|
462
|
+
return useLoaderData({
|
|
463
|
+
...opts,
|
|
464
|
+
from: this.id
|
|
465
|
+
});
|
|
989
466
|
};
|
|
990
467
|
this.useNavigate = () => {
|
|
991
468
|
return useNavigate({ from: this.fullPath });
|
|
992
469
|
};
|
|
993
|
-
this.Link = React
|
|
994
|
-
(
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
470
|
+
this.Link = React.forwardRef((props, ref) => {
|
|
471
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Link, {
|
|
472
|
+
ref,
|
|
473
|
+
from: this.fullPath,
|
|
474
|
+
...props
|
|
475
|
+
});
|
|
476
|
+
});
|
|
999
477
|
}
|
|
1000
|
-
}
|
|
478
|
+
};
|
|
1001
479
|
function createRootRoute(options) {
|
|
1002
480
|
return new RootRoute(options);
|
|
1003
481
|
}
|
|
1004
482
|
function createFileRoute(path) {
|
|
1005
|
-
|
|
1006
|
-
return new FileRoute(path, {
|
|
1007
|
-
silent: true
|
|
1008
|
-
}).createRoute(path);
|
|
1009
|
-
}
|
|
1010
|
-
return new FileRoute(path, {
|
|
1011
|
-
silent: true
|
|
1012
|
-
}).createRoute;
|
|
483
|
+
return new FileRoute(path, { silent: true }).createRoute;
|
|
1013
484
|
}
|
|
1014
|
-
|
|
485
|
+
var FileRoute = class {
|
|
1015
486
|
constructor(path, _opts) {
|
|
1016
487
|
this.path = path;
|
|
1017
488
|
this.createRoute = (options) => {
|
|
1018
|
-
warning(
|
|
1019
|
-
this.silent
|
|
1020
|
-
);
|
|
1021
489
|
const route = createRoute(options);
|
|
1022
490
|
route.isRoot = false;
|
|
1023
491
|
return route;
|
|
1024
492
|
};
|
|
1025
493
|
this.silent = _opts?.silent;
|
|
1026
494
|
}
|
|
1027
|
-
}
|
|
1028
|
-
class LazyRoute {
|
|
1029
|
-
constructor(opts) {
|
|
1030
|
-
this.useMatch = (opts2) => {
|
|
1031
|
-
return useMatch({
|
|
1032
|
-
select: opts2?.select,
|
|
1033
|
-
from: this.options.id,
|
|
1034
|
-
structuralSharing: opts2?.structuralSharing
|
|
1035
|
-
});
|
|
1036
|
-
};
|
|
1037
|
-
this.useRouteContext = (opts2) => {
|
|
1038
|
-
return useMatch({
|
|
1039
|
-
from: this.options.id,
|
|
1040
|
-
select: (d) => opts2?.select ? opts2.select(d.context) : d.context
|
|
1041
|
-
});
|
|
1042
|
-
};
|
|
1043
|
-
this.useSearch = (opts2) => {
|
|
1044
|
-
return useSearch({
|
|
1045
|
-
select: opts2?.select,
|
|
1046
|
-
structuralSharing: opts2?.structuralSharing,
|
|
1047
|
-
from: this.options.id
|
|
1048
|
-
});
|
|
1049
|
-
};
|
|
1050
|
-
this.useParams = (opts2) => {
|
|
1051
|
-
return useParams({
|
|
1052
|
-
select: opts2?.select,
|
|
1053
|
-
structuralSharing: opts2?.structuralSharing,
|
|
1054
|
-
from: this.options.id
|
|
1055
|
-
});
|
|
1056
|
-
};
|
|
1057
|
-
this.useLoaderDeps = (opts2) => {
|
|
1058
|
-
return useLoaderDeps({ ...opts2, from: this.options.id });
|
|
1059
|
-
};
|
|
1060
|
-
this.useLoaderData = (opts2) => {
|
|
1061
|
-
return useLoaderData({ ...opts2, from: this.options.id });
|
|
1062
|
-
};
|
|
1063
|
-
this.useNavigate = () => {
|
|
1064
|
-
const router = useRouter();
|
|
1065
|
-
return useNavigate({ from: router.routesById[this.options.id].fullPath });
|
|
1066
|
-
};
|
|
1067
|
-
this.options = opts;
|
|
1068
|
-
this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
function createLazyFileRoute(id) {
|
|
1072
|
-
if (typeof id === "object") {
|
|
1073
|
-
return new LazyRoute(id);
|
|
1074
|
-
}
|
|
1075
|
-
return (opts) => new LazyRoute({ id, ...opts });
|
|
1076
|
-
}
|
|
495
|
+
};
|
|
1077
496
|
function lazyRouteComponent(importer, exportName) {
|
|
1078
497
|
let loadPromise;
|
|
1079
498
|
let comp;
|
|
1080
499
|
let error;
|
|
1081
500
|
let reload;
|
|
1082
501
|
const load = () => {
|
|
1083
|
-
if (!loadPromise) {
|
|
1084
|
-
loadPromise =
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
if (
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
reload = true;
|
|
1095
|
-
}
|
|
502
|
+
if (!loadPromise) loadPromise = importer().then((res) => {
|
|
503
|
+
loadPromise = void 0;
|
|
504
|
+
comp = res[exportName];
|
|
505
|
+
}).catch((err) => {
|
|
506
|
+
error = err;
|
|
507
|
+
if (isModuleNotFoundError(error)) {
|
|
508
|
+
if (error instanceof Error && typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
|
|
509
|
+
const storageKey = `tanstack_router_reload:${error.message}`;
|
|
510
|
+
if (!sessionStorage.getItem(storageKey)) {
|
|
511
|
+
sessionStorage.setItem(storageKey, "1");
|
|
512
|
+
reload = true;
|
|
1096
513
|
}
|
|
1097
514
|
}
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
515
|
+
}
|
|
516
|
+
});
|
|
1100
517
|
return loadPromise;
|
|
1101
518
|
};
|
|
1102
519
|
const lazyComp = function Lazy(props) {
|
|
@@ -1105,68 +522,305 @@ function lazyRouteComponent(importer, exportName) {
|
|
|
1105
522
|
throw new Promise(() => {
|
|
1106
523
|
});
|
|
1107
524
|
}
|
|
1108
|
-
if (error)
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
if (!comp) {
|
|
1112
|
-
if (reactUse) {
|
|
1113
|
-
reactUse(load());
|
|
1114
|
-
} else {
|
|
1115
|
-
throw load();
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
525
|
+
if (error) throw error;
|
|
526
|
+
if (!comp) if (reactUse) reactUse(load());
|
|
527
|
+
else throw load();
|
|
1118
528
|
return reactExports.createElement(comp, props);
|
|
1119
529
|
};
|
|
1120
530
|
lazyComp.preload = load;
|
|
1121
531
|
return lazyComp;
|
|
1122
532
|
}
|
|
1123
|
-
|
|
533
|
+
function CatchNotFound(props) {
|
|
534
|
+
const router = useRouter();
|
|
535
|
+
{
|
|
536
|
+
const resetKey = `not-found-${router.stores.location.get().pathname}-${router.stores.status.get()}`;
|
|
537
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CatchBoundary, {
|
|
538
|
+
getResetKey: () => resetKey,
|
|
539
|
+
onCatch: (error, errorInfo) => {
|
|
540
|
+
if (isNotFound(error)) props.onCatch?.(error, errorInfo);
|
|
541
|
+
else throw error;
|
|
542
|
+
},
|
|
543
|
+
errorComponent: ({ error }) => {
|
|
544
|
+
if (isNotFound(error)) return props.fallback?.(error);
|
|
545
|
+
else throw error;
|
|
546
|
+
},
|
|
547
|
+
children: props.children
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
function DefaultGlobalNotFound() {
|
|
552
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Not Found" });
|
|
553
|
+
}
|
|
554
|
+
function ScriptOnce({ children }) {
|
|
555
|
+
const router = useRouter();
|
|
556
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("script", {
|
|
557
|
+
nonce: router.options.ssr?.nonce,
|
|
558
|
+
dangerouslySetInnerHTML: { __html: children + ";document.currentScript.remove()" }
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
function SafeFragment(props) {
|
|
562
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: props.children });
|
|
563
|
+
}
|
|
564
|
+
function renderRouteNotFound(router, route, data) {
|
|
565
|
+
if (!route.options.notFoundComponent) {
|
|
566
|
+
if (router.options.defaultNotFoundComponent) return /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.defaultNotFoundComponent, { ...data });
|
|
567
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultGlobalNotFound, {});
|
|
568
|
+
}
|
|
569
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(route.options.notFoundComponent, { ...data });
|
|
570
|
+
}
|
|
571
|
+
function ScrollRestoration() {
|
|
572
|
+
const script = getScrollRestorationScriptForRouter(useRouter());
|
|
573
|
+
if (!script) return null;
|
|
574
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ScriptOnce, { children: script });
|
|
575
|
+
}
|
|
576
|
+
var Match = reactExports.memo(function MatchImpl({ matchId }) {
|
|
577
|
+
const router = useRouter();
|
|
578
|
+
{
|
|
579
|
+
const match2 = router.stores.matchStores.get(matchId)?.get();
|
|
580
|
+
if (!match2) {
|
|
581
|
+
invariant();
|
|
582
|
+
}
|
|
583
|
+
const routeId = match2.routeId;
|
|
584
|
+
const parentRouteId = router.routesById[routeId].parentRoute?.id;
|
|
585
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(MatchView, {
|
|
586
|
+
router,
|
|
587
|
+
matchId,
|
|
588
|
+
resetKey: router.stores.loadedAt.get(),
|
|
589
|
+
matchState: {
|
|
590
|
+
routeId,
|
|
591
|
+
ssr: match2.ssr,
|
|
592
|
+
_displayPending: match2._displayPending,
|
|
593
|
+
parentRouteId
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
function MatchView({ router, matchId, resetKey, matchState }) {
|
|
599
|
+
const route = router.routesById[matchState.routeId];
|
|
600
|
+
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
601
|
+
const pendingElement = PendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(PendingComponent, {}) : null;
|
|
602
|
+
const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
|
|
603
|
+
const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
|
|
604
|
+
const routeNotFoundComponent = route.isRoot ? route.options.notFoundComponent ?? router.options.notFoundRoute?.options.component : route.options.notFoundComponent;
|
|
605
|
+
const resolvedNoSsr = matchState.ssr === false || matchState.ssr === "data-only";
|
|
606
|
+
const ResolvedSuspenseBoundary = (!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) && (route.options.wrapInSuspense ?? PendingComponent ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? reactExports.Suspense : SafeFragment;
|
|
607
|
+
const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
|
|
608
|
+
const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
|
|
609
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment, { children: [/* @__PURE__ */ jsxRuntimeExports.jsx(matchContext.Provider, {
|
|
610
|
+
value: matchId,
|
|
611
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResolvedSuspenseBoundary, {
|
|
612
|
+
fallback: pendingElement,
|
|
613
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResolvedCatchBoundary, {
|
|
614
|
+
getResetKey: () => resetKey,
|
|
615
|
+
errorComponent: routeErrorComponent || ErrorComponent,
|
|
616
|
+
onCatch: (error, errorInfo) => {
|
|
617
|
+
if (isNotFound(error)) {
|
|
618
|
+
error.routeId ??= matchState.routeId;
|
|
619
|
+
throw error;
|
|
620
|
+
}
|
|
621
|
+
routeOnCatch?.(error, errorInfo);
|
|
622
|
+
},
|
|
623
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResolvedNotFoundBoundary, {
|
|
624
|
+
fallback: (error) => {
|
|
625
|
+
error.routeId ??= matchState.routeId;
|
|
626
|
+
if (!routeNotFoundComponent || error.routeId && error.routeId !== matchState.routeId || !error.routeId && !route.isRoot) throw error;
|
|
627
|
+
return reactExports.createElement(routeNotFoundComponent, error);
|
|
628
|
+
},
|
|
629
|
+
children: resolvedNoSsr || matchState._displayPending ? /* @__PURE__ */ jsxRuntimeExports.jsx(ClientOnly, {
|
|
630
|
+
fallback: pendingElement,
|
|
631
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(MatchInner, { matchId })
|
|
632
|
+
}) : /* @__PURE__ */ jsxRuntimeExports.jsx(MatchInner, { matchId })
|
|
633
|
+
})
|
|
634
|
+
})
|
|
635
|
+
})
|
|
636
|
+
}), matchState.parentRouteId === rootRouteId ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [/* @__PURE__ */ jsxRuntimeExports.jsx(OnRendered, {}), router.options.scrollRestoration && isServer ? /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollRestoration, {}) : null] }) : null] });
|
|
637
|
+
}
|
|
638
|
+
function OnRendered() {
|
|
639
|
+
useRouter();
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
var MatchInner = reactExports.memo(function MatchInnerImpl({ matchId }) {
|
|
643
|
+
const router = useRouter();
|
|
644
|
+
const getMatchPromise = (match2, key2) => {
|
|
645
|
+
return router.getMatch(match2.id)?._nonReactive[key2] ?? match2._nonReactive[key2];
|
|
646
|
+
};
|
|
647
|
+
{
|
|
648
|
+
const match2 = router.stores.matchStores.get(matchId)?.get();
|
|
649
|
+
if (!match2) {
|
|
650
|
+
invariant();
|
|
651
|
+
}
|
|
652
|
+
const routeId2 = match2.routeId;
|
|
653
|
+
const route2 = router.routesById[routeId2];
|
|
654
|
+
const remountDeps = (router.routesById[routeId2].options.remountDeps ?? router.options.defaultRemountDeps)?.({
|
|
655
|
+
routeId: routeId2,
|
|
656
|
+
loaderDeps: match2.loaderDeps,
|
|
657
|
+
params: match2._strictParams,
|
|
658
|
+
search: match2._strictSearch
|
|
659
|
+
});
|
|
660
|
+
const key2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
|
|
661
|
+
const Comp = route2.options.component ?? router.options.defaultComponent;
|
|
662
|
+
const out2 = Comp ? /* @__PURE__ */ jsxRuntimeExports.jsx(Comp, {}, key2) : /* @__PURE__ */ jsxRuntimeExports.jsx(Outlet, {});
|
|
663
|
+
if (match2._displayPending) throw getMatchPromise(match2, "displayPendingPromise");
|
|
664
|
+
if (match2._forcePending) throw getMatchPromise(match2, "minPendingPromise");
|
|
665
|
+
if (match2.status === "pending") throw getMatchPromise(match2, "loadPromise");
|
|
666
|
+
if (match2.status === "notFound") {
|
|
667
|
+
if (!isNotFound(match2.error)) {
|
|
668
|
+
invariant();
|
|
669
|
+
}
|
|
670
|
+
return renderRouteNotFound(router, route2, match2.error);
|
|
671
|
+
}
|
|
672
|
+
if (match2.status === "redirected") {
|
|
673
|
+
if (!isRedirect(match2.error)) {
|
|
674
|
+
invariant();
|
|
675
|
+
}
|
|
676
|
+
throw getMatchPromise(match2, "loadPromise");
|
|
677
|
+
}
|
|
678
|
+
if (match2.status === "error") return /* @__PURE__ */ jsxRuntimeExports.jsx((route2.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent, {
|
|
679
|
+
error: match2.error,
|
|
680
|
+
reset: void 0,
|
|
681
|
+
info: { componentStack: "" }
|
|
682
|
+
});
|
|
683
|
+
return out2;
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
var Outlet = reactExports.memo(function OutletImpl() {
|
|
687
|
+
const router = useRouter();
|
|
688
|
+
const matchId = reactExports.useContext(matchContext);
|
|
689
|
+
let routeId;
|
|
690
|
+
let parentGlobalNotFound = false;
|
|
691
|
+
let childMatchId;
|
|
692
|
+
{
|
|
693
|
+
const matches = router.stores.matches.get();
|
|
694
|
+
const parentIndex = matchId ? matches.findIndex((match) => match.id === matchId) : -1;
|
|
695
|
+
const parentMatch = parentIndex >= 0 ? matches[parentIndex] : void 0;
|
|
696
|
+
routeId = parentMatch?.routeId;
|
|
697
|
+
parentGlobalNotFound = parentMatch?.globalNotFound ?? false;
|
|
698
|
+
childMatchId = parentIndex >= 0 ? matches[parentIndex + 1]?.id : void 0;
|
|
699
|
+
}
|
|
700
|
+
const route = routeId ? router.routesById[routeId] : void 0;
|
|
701
|
+
const pendingElement = router.options.defaultPendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.defaultPendingComponent, {}) : null;
|
|
702
|
+
if (parentGlobalNotFound) {
|
|
703
|
+
if (!route) {
|
|
704
|
+
invariant();
|
|
705
|
+
}
|
|
706
|
+
return renderRouteNotFound(router, route, void 0);
|
|
707
|
+
}
|
|
708
|
+
if (!childMatchId) return null;
|
|
709
|
+
const nextMatch = /* @__PURE__ */ jsxRuntimeExports.jsx(Match, { matchId: childMatchId });
|
|
710
|
+
if (routeId === rootRouteId) return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, {
|
|
711
|
+
fallback: pendingElement,
|
|
712
|
+
children: nextMatch
|
|
713
|
+
});
|
|
714
|
+
return nextMatch;
|
|
715
|
+
});
|
|
716
|
+
function Matches() {
|
|
717
|
+
const router = useRouter();
|
|
718
|
+
const PendingComponent = router.routesById[rootRouteId].options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
719
|
+
const pendingElement = PendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(PendingComponent, {}) : null;
|
|
720
|
+
const inner = /* @__PURE__ */ jsxRuntimeExports.jsxs(SafeFragment, {
|
|
721
|
+
fallback: pendingElement,
|
|
722
|
+
children: [false, /* @__PURE__ */ jsxRuntimeExports.jsx(MatchesInner, {})]
|
|
723
|
+
});
|
|
724
|
+
return router.options.InnerWrap ? /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.InnerWrap, { children: inner }) : inner;
|
|
725
|
+
}
|
|
726
|
+
function MatchesInner() {
|
|
727
|
+
const router = useRouter();
|
|
728
|
+
const matchId = router.stores.firstId.get();
|
|
729
|
+
const resetKey = router.stores.loadedAt.get();
|
|
730
|
+
const matchComponent = matchId ? /* @__PURE__ */ jsxRuntimeExports.jsx(Match, { matchId }) : null;
|
|
731
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(matchContext.Provider, {
|
|
732
|
+
value: matchId,
|
|
733
|
+
children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ jsxRuntimeExports.jsx(CatchBoundary, {
|
|
734
|
+
getResetKey: () => resetKey,
|
|
735
|
+
errorComponent: ErrorComponent,
|
|
736
|
+
onCatch: void 0,
|
|
737
|
+
children: matchComponent
|
|
738
|
+
})
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
var getStoreFactory = (opts) => {
|
|
742
|
+
return {
|
|
743
|
+
createMutableStore: createNonReactiveMutableStore,
|
|
744
|
+
createReadonlyStore: createNonReactiveReadonlyStore,
|
|
745
|
+
batch: (fn) => fn()
|
|
746
|
+
};
|
|
747
|
+
};
|
|
748
|
+
var createRouter = (options) => {
|
|
1124
749
|
return new Router(options);
|
|
1125
750
|
};
|
|
1126
|
-
|
|
751
|
+
var Router = class extends RouterCore {
|
|
1127
752
|
constructor(options) {
|
|
1128
|
-
super(options);
|
|
753
|
+
super(options, getStoreFactory);
|
|
1129
754
|
}
|
|
755
|
+
};
|
|
756
|
+
function RouterContextProvider({ router, children, ...rest }) {
|
|
757
|
+
if (hasKeys(rest)) router.update({
|
|
758
|
+
...router.options,
|
|
759
|
+
...rest,
|
|
760
|
+
context: {
|
|
761
|
+
...router.options.context,
|
|
762
|
+
...rest.context
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
const provider = /* @__PURE__ */ jsxRuntimeExports.jsx(routerContext.Provider, {
|
|
766
|
+
value: router,
|
|
767
|
+
children
|
|
768
|
+
});
|
|
769
|
+
if (router.options.Wrap) return /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.Wrap, { children: provider });
|
|
770
|
+
return provider;
|
|
771
|
+
}
|
|
772
|
+
function RouterProvider({ router, ...rest }) {
|
|
773
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(RouterContextProvider, {
|
|
774
|
+
router,
|
|
775
|
+
...rest,
|
|
776
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Matches, {})
|
|
777
|
+
});
|
|
1130
778
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
window.createLazyFileRoute = createLazyFileRoute;
|
|
779
|
+
var noopScriptHandler = () => {
|
|
780
|
+
};
|
|
781
|
+
function setScriptAttrs(script, attrs) {
|
|
782
|
+
if (!attrs) return;
|
|
783
|
+
for (const [key, value] of Object.entries(attrs)) if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) script.setAttribute(key, typeof value === "boolean" ? "" : String(value));
|
|
1137
784
|
}
|
|
1138
|
-
function Asset({
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
children,
|
|
1142
|
-
nonce
|
|
1143
|
-
}) {
|
|
1144
|
-
switch (tag) {
|
|
785
|
+
function Asset(asset) {
|
|
786
|
+
const { attrs, children, nonce, preventScriptHoist } = asset;
|
|
787
|
+
switch (asset.tag) {
|
|
1145
788
|
case "title":
|
|
1146
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("title", {
|
|
789
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("title", {
|
|
790
|
+
...attrs,
|
|
791
|
+
suppressHydrationWarning: true,
|
|
792
|
+
children
|
|
793
|
+
});
|
|
1147
794
|
case "meta":
|
|
1148
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("meta", {
|
|
795
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("meta", {
|
|
796
|
+
...attrs,
|
|
797
|
+
suppressHydrationWarning: true
|
|
798
|
+
});
|
|
1149
799
|
case "link":
|
|
1150
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("link", {
|
|
800
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("link", {
|
|
801
|
+
...attrs,
|
|
802
|
+
precedence: attrs?.precedence ?? (attrs?.rel === "stylesheet" ? "default" : void 0),
|
|
803
|
+
nonce,
|
|
804
|
+
suppressHydrationWarning: true
|
|
805
|
+
});
|
|
1151
806
|
case "style":
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
}
|
|
1159
|
-
);
|
|
807
|
+
if (asset.inlineCss && false) ;
|
|
808
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("style", {
|
|
809
|
+
...attrs,
|
|
810
|
+
dangerouslySetInnerHTML: { __html: children },
|
|
811
|
+
nonce
|
|
812
|
+
});
|
|
1160
813
|
case "script":
|
|
1161
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(Script, {
|
|
814
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Script, {
|
|
815
|
+
attrs,
|
|
816
|
+
preventScriptHoist,
|
|
817
|
+
children
|
|
818
|
+
});
|
|
1162
819
|
default:
|
|
1163
820
|
return null;
|
|
1164
821
|
}
|
|
1165
822
|
}
|
|
1166
|
-
function Script({
|
|
1167
|
-
attrs,
|
|
1168
|
-
children
|
|
1169
|
-
}) {
|
|
823
|
+
function Script({ attrs, children, preventScriptHoist }) {
|
|
1170
824
|
useRouter();
|
|
1171
825
|
useHydrated();
|
|
1172
826
|
const dataScript = typeof attrs?.type === "string" && attrs.type !== "" && attrs.type !== "text/javascript" && attrs.type !== "module";
|
|
@@ -1181,291 +835,333 @@ function Script({
|
|
|
1181
835
|
return attrs.src;
|
|
1182
836
|
}
|
|
1183
837
|
})();
|
|
1184
|
-
const
|
|
1185
|
-
document.querySelectorAll("script[src]")
|
|
1186
|
-
).find((el) => el.src === normSrc);
|
|
1187
|
-
if (existingScript) {
|
|
1188
|
-
return;
|
|
1189
|
-
}
|
|
838
|
+
for (const el of document.querySelectorAll("script[src]")) if (el.src === normSrc) return;
|
|
1190
839
|
const script = document.createElement("script");
|
|
1191
|
-
|
|
1192
|
-
if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
|
|
1193
|
-
script.setAttribute(
|
|
1194
|
-
key,
|
|
1195
|
-
typeof value === "boolean" ? "" : String(value)
|
|
1196
|
-
);
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
840
|
+
setScriptAttrs(script, attrs);
|
|
1199
841
|
document.head.appendChild(script);
|
|
1200
|
-
return () =>
|
|
1201
|
-
if (script.parentNode) {
|
|
1202
|
-
script.parentNode.removeChild(script);
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
842
|
+
return () => script.remove();
|
|
1205
843
|
}
|
|
1206
844
|
if (typeof children === "string") {
|
|
1207
845
|
const typeAttr = typeof attrs?.type === "string" ? attrs.type : "text/javascript";
|
|
1208
846
|
const nonceAttr = typeof attrs?.nonce === "string" ? attrs.nonce : void 0;
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1211
|
-
).find((el) => {
|
|
1212
|
-
if (!(el instanceof HTMLScriptElement)) return false;
|
|
847
|
+
for (const el of document.querySelectorAll("script:not([src])")) {
|
|
848
|
+
if (!(el instanceof HTMLScriptElement)) continue;
|
|
1213
849
|
const sType = el.getAttribute("type") ?? "text/javascript";
|
|
1214
850
|
const sNonce = el.getAttribute("nonce") ?? void 0;
|
|
1215
|
-
|
|
1216
|
-
});
|
|
1217
|
-
if (existingScript) {
|
|
1218
|
-
return;
|
|
851
|
+
if (el.textContent === children && sType === typeAttr && sNonce === nonceAttr) return;
|
|
1219
852
|
}
|
|
1220
853
|
const script = document.createElement("script");
|
|
1221
854
|
script.textContent = children;
|
|
1222
|
-
|
|
1223
|
-
for (const [key, value] of Object.entries(attrs)) {
|
|
1224
|
-
if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
|
|
1225
|
-
script.setAttribute(
|
|
1226
|
-
key,
|
|
1227
|
-
typeof value === "boolean" ? "" : String(value)
|
|
1228
|
-
);
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
855
|
+
setScriptAttrs(script, attrs);
|
|
1232
856
|
document.head.appendChild(script);
|
|
1233
|
-
return () =>
|
|
1234
|
-
if (script.parentNode) {
|
|
1235
|
-
script.parentNode.removeChild(script);
|
|
1236
|
-
}
|
|
1237
|
-
};
|
|
857
|
+
return () => script.remove();
|
|
1238
858
|
}
|
|
1239
|
-
|
|
1240
|
-
|
|
859
|
+
}, [
|
|
860
|
+
attrs,
|
|
861
|
+
children,
|
|
862
|
+
dataScript
|
|
863
|
+
]);
|
|
1241
864
|
{
|
|
1242
865
|
if (attrs?.src) {
|
|
1243
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("script", {
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
}
|
|
1253
|
-
);
|
|
866
|
+
if (!preventScriptHoist) return /* @__PURE__ */ jsxRuntimeExports.jsx("script", {
|
|
867
|
+
...attrs,
|
|
868
|
+
suppressHydrationWarning: true
|
|
869
|
+
});
|
|
870
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("script", {
|
|
871
|
+
...attrs,
|
|
872
|
+
onLoad: noopScriptHandler,
|
|
873
|
+
suppressHydrationWarning: true
|
|
874
|
+
});
|
|
1254
875
|
}
|
|
876
|
+
if (typeof children === "string") return /* @__PURE__ */ jsxRuntimeExports.jsx("script", {
|
|
877
|
+
...attrs,
|
|
878
|
+
dangerouslySetInnerHTML: { __html: children },
|
|
879
|
+
suppressHydrationWarning: true
|
|
880
|
+
});
|
|
1255
881
|
return null;
|
|
1256
882
|
}
|
|
1257
883
|
}
|
|
1258
|
-
|
|
1259
|
-
const
|
|
1260
|
-
const
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
});
|
|
1292
|
-
} catch {
|
|
1293
|
-
}
|
|
1294
|
-
} else {
|
|
1295
|
-
const attribute = m.name ?? m.property;
|
|
1296
|
-
if (attribute) {
|
|
1297
|
-
if (metaByAttribute[attribute]) {
|
|
1298
|
-
continue;
|
|
1299
|
-
} else {
|
|
1300
|
-
metaByAttribute[attribute] = true;
|
|
1301
|
-
}
|
|
884
|
+
function buildTagsFromMatches(router, nonce, matches, assetCrossOrigin) {
|
|
885
|
+
const routeMeta = matches.map((match) => match.meta).filter((meta) => meta !== void 0);
|
|
886
|
+
const resultMeta = [];
|
|
887
|
+
const metaByAttribute = {};
|
|
888
|
+
let title;
|
|
889
|
+
for (let i = routeMeta.length - 1; i >= 0; i--) {
|
|
890
|
+
const metas = routeMeta[i];
|
|
891
|
+
for (let j = metas.length - 1; j >= 0; j--) {
|
|
892
|
+
const m = metas[j];
|
|
893
|
+
if (!m) continue;
|
|
894
|
+
if (m.title) {
|
|
895
|
+
if (!title) title = {
|
|
896
|
+
tag: "title",
|
|
897
|
+
children: m.title
|
|
898
|
+
};
|
|
899
|
+
} else if ("script:ld+json" in m) try {
|
|
900
|
+
const json = JSON.stringify(m["script:ld+json"]);
|
|
901
|
+
resultMeta.push({
|
|
902
|
+
tag: "script",
|
|
903
|
+
attrs: { type: "application/ld+json" },
|
|
904
|
+
children: escapeHtml(json)
|
|
905
|
+
});
|
|
906
|
+
} catch {
|
|
907
|
+
}
|
|
908
|
+
else {
|
|
909
|
+
const attribute = m.name ?? m.property;
|
|
910
|
+
if (attribute) if (metaByAttribute[attribute]) continue;
|
|
911
|
+
else metaByAttribute[attribute] = true;
|
|
912
|
+
resultMeta.push({
|
|
913
|
+
tag: "meta",
|
|
914
|
+
attrs: {
|
|
915
|
+
...m,
|
|
916
|
+
nonce
|
|
1302
917
|
}
|
|
1303
|
-
|
|
1304
|
-
tag: "meta",
|
|
1305
|
-
attrs: {
|
|
1306
|
-
...m,
|
|
1307
|
-
nonce
|
|
1308
|
-
}
|
|
1309
|
-
});
|
|
1310
|
-
}
|
|
918
|
+
});
|
|
1311
919
|
}
|
|
1312
920
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
921
|
+
}
|
|
922
|
+
if (title) resultMeta.push(title);
|
|
923
|
+
if (nonce) resultMeta.push({
|
|
924
|
+
tag: "meta",
|
|
925
|
+
attrs: {
|
|
926
|
+
property: "csp-nonce",
|
|
927
|
+
content: nonce
|
|
1315
928
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
});
|
|
929
|
+
});
|
|
930
|
+
resultMeta.reverse();
|
|
931
|
+
const constructedLinks = matches.flatMap((match) => match.links ?? []).filter((link) => link !== void 0).map((link) => ({
|
|
932
|
+
tag: "link",
|
|
933
|
+
attrs: {
|
|
934
|
+
...link,
|
|
935
|
+
nonce
|
|
1324
936
|
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
...link,
|
|
1334
|
-
nonce
|
|
1335
|
-
}
|
|
1336
|
-
}));
|
|
1337
|
-
const manifest = router.ssr?.manifest;
|
|
1338
|
-
const assets = state.matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map(
|
|
1339
|
-
(asset) => ({
|
|
937
|
+
}));
|
|
938
|
+
const manifest = router.ssr?.manifest;
|
|
939
|
+
const manifestCssTags = [];
|
|
940
|
+
if (manifest) {
|
|
941
|
+
matches.forEach((match) => {
|
|
942
|
+
manifest.routes[match.routeId]?.css?.forEach((link) => {
|
|
943
|
+
const resolvedLink = resolveManifestCssLink(link);
|
|
944
|
+
manifestCssTags.push({
|
|
1340
945
|
tag: "link",
|
|
1341
946
|
attrs: {
|
|
1342
|
-
|
|
947
|
+
rel: "stylesheet",
|
|
948
|
+
...resolvedLink,
|
|
949
|
+
crossOrigin: getAssetCrossOrigin(assetCrossOrigin, "stylesheet") ?? resolvedLink.crossOrigin,
|
|
1343
950
|
suppressHydrationWarning: true,
|
|
1344
951
|
nonce
|
|
1345
952
|
}
|
|
1346
|
-
})
|
|
1347
|
-
);
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
structuralSharing: true
|
|
1351
|
-
});
|
|
1352
|
-
const preloadLinks = useRouterState({
|
|
1353
|
-
select: (state) => {
|
|
1354
|
-
const preloadLinks2 = [];
|
|
1355
|
-
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
|
|
1356
|
-
(route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
|
|
1357
|
-
preloadLinks2.push({
|
|
1358
|
-
tag: "link",
|
|
1359
|
-
attrs: {
|
|
1360
|
-
rel: "modulepreload",
|
|
1361
|
-
href: preload,
|
|
1362
|
-
nonce
|
|
1363
|
-
}
|
|
1364
|
-
});
|
|
1365
|
-
})
|
|
1366
|
-
);
|
|
1367
|
-
return preloadLinks2;
|
|
1368
|
-
},
|
|
1369
|
-
structuralSharing: true
|
|
1370
|
-
});
|
|
1371
|
-
const styles = useRouterState({
|
|
1372
|
-
select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
|
|
953
|
+
});
|
|
954
|
+
});
|
|
955
|
+
});
|
|
956
|
+
if (manifest.inlineStyle) manifestCssTags.push({
|
|
1373
957
|
tag: "style",
|
|
1374
958
|
attrs: {
|
|
1375
|
-
...attrs,
|
|
959
|
+
...manifest.inlineStyle.attrs,
|
|
1376
960
|
nonce
|
|
1377
961
|
},
|
|
1378
|
-
children
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
}
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
return uniqBy(
|
|
1394
|
-
[
|
|
1395
|
-
...meta,
|
|
1396
|
-
...preloadLinks,
|
|
1397
|
-
...links,
|
|
1398
|
-
...styles,
|
|
1399
|
-
...headScripts
|
|
1400
|
-
],
|
|
1401
|
-
(d) => {
|
|
1402
|
-
return JSON.stringify(d);
|
|
1403
|
-
}
|
|
1404
|
-
);
|
|
1405
|
-
};
|
|
1406
|
-
function uniqBy(arr, fn) {
|
|
1407
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1408
|
-
return arr.filter((item) => {
|
|
1409
|
-
const key = fn(item);
|
|
1410
|
-
if (seen.has(key)) {
|
|
1411
|
-
return false;
|
|
1412
|
-
}
|
|
1413
|
-
seen.add(key);
|
|
1414
|
-
return true;
|
|
962
|
+
children: manifest.inlineStyle.children,
|
|
963
|
+
inlineCss: true
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
const preloadLinks = [];
|
|
967
|
+
if (manifest) matches.forEach((match) => {
|
|
968
|
+
manifest.routes[match.routeId]?.preloads?.forEach((preload) => {
|
|
969
|
+
preloadLinks.push({
|
|
970
|
+
tag: "link",
|
|
971
|
+
attrs: {
|
|
972
|
+
...getScriptPreloadAttrs(manifest, preload, assetCrossOrigin),
|
|
973
|
+
nonce
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
});
|
|
1415
977
|
});
|
|
978
|
+
const styles = matches.flatMap((match) => match.styles ?? []).filter((style) => style !== void 0).map(({ children, ...attrs }) => ({
|
|
979
|
+
tag: "style",
|
|
980
|
+
attrs: {
|
|
981
|
+
...attrs,
|
|
982
|
+
nonce
|
|
983
|
+
},
|
|
984
|
+
children
|
|
985
|
+
}));
|
|
986
|
+
const headScripts = matches.flatMap((match) => match.headScripts ?? []).filter((script) => script !== void 0).map(({ children, ...script }) => ({
|
|
987
|
+
tag: "script",
|
|
988
|
+
attrs: {
|
|
989
|
+
...script,
|
|
990
|
+
nonce
|
|
991
|
+
},
|
|
992
|
+
children
|
|
993
|
+
}));
|
|
994
|
+
const tags = [];
|
|
995
|
+
appendUniqueUserTags(tags, resultMeta);
|
|
996
|
+
tags.push(...preloadLinks);
|
|
997
|
+
appendUniqueUserTags(tags, constructedLinks);
|
|
998
|
+
tags.push(...manifestCssTags);
|
|
999
|
+
appendUniqueUserTags(tags, styles);
|
|
1000
|
+
appendUniqueUserTags(tags, headScripts);
|
|
1001
|
+
return tags;
|
|
1416
1002
|
}
|
|
1417
|
-
|
|
1418
|
-
const tags = useTags();
|
|
1003
|
+
var useTags = (assetCrossOrigin) => {
|
|
1419
1004
|
const router = useRouter();
|
|
1420
1005
|
const nonce = router.options.ssr?.nonce;
|
|
1421
|
-
return
|
|
1006
|
+
return buildTagsFromMatches(router, nonce, router.stores.matches.get(), assetCrossOrigin);
|
|
1007
|
+
};
|
|
1008
|
+
function HeadContent(props) {
|
|
1009
|
+
const tags = useTags(props.assetCrossOrigin);
|
|
1010
|
+
const nonce = useRouter().options.ssr?.nonce;
|
|
1011
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: tags.map((tag) => /* @__PURE__ */ reactExports.createElement(Asset, {
|
|
1012
|
+
...tag,
|
|
1013
|
+
key: `tsr-meta-${JSON.stringify(tag)}`,
|
|
1014
|
+
nonce
|
|
1015
|
+
})) });
|
|
1422
1016
|
}
|
|
1423
|
-
|
|
1017
|
+
var Scripts = () => {
|
|
1424
1018
|
const router = useRouter();
|
|
1425
1019
|
const nonce = router.options.ssr?.nonce;
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
(route) => manifest.routes[route.id]?.assets?.filter((d) => d.tag === "script").forEach((asset) => {
|
|
1435
|
-
assetScripts2.push({
|
|
1436
|
-
tag: "script",
|
|
1437
|
-
attrs: { ...asset.attrs, nonce },
|
|
1438
|
-
children: asset.children
|
|
1439
|
-
});
|
|
1440
|
-
})
|
|
1441
|
-
);
|
|
1442
|
-
return assetScripts2;
|
|
1443
|
-
},
|
|
1444
|
-
structuralSharing: true
|
|
1445
|
-
});
|
|
1446
|
-
const { scripts } = useRouterState({
|
|
1447
|
-
select: (state) => ({
|
|
1448
|
-
scripts: state.matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
1020
|
+
const getAssetScripts = (matches) => {
|
|
1021
|
+
const assetScripts = [];
|
|
1022
|
+
const manifest = router.ssr?.manifest;
|
|
1023
|
+
if (!manifest) return [];
|
|
1024
|
+
for (const match of matches) {
|
|
1025
|
+
const scripts = manifest.routes[match.routeId]?.scripts;
|
|
1026
|
+
if (!scripts) continue;
|
|
1027
|
+
for (const asset of scripts) assetScripts.push({
|
|
1449
1028
|
tag: "script",
|
|
1450
1029
|
attrs: {
|
|
1451
|
-
...
|
|
1452
|
-
suppressHydrationWarning: true,
|
|
1030
|
+
...asset.attrs,
|
|
1453
1031
|
nonce
|
|
1454
1032
|
},
|
|
1455
|
-
children
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1033
|
+
children: asset.children,
|
|
1034
|
+
...typeof asset.attrs?.src === "string" ? { preventScriptHoist: true } : {}
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
return assetScripts;
|
|
1038
|
+
};
|
|
1039
|
+
const getScripts = (matches) => matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
1040
|
+
tag: "script",
|
|
1041
|
+
attrs: {
|
|
1042
|
+
...script,
|
|
1043
|
+
suppressHydrationWarning: true,
|
|
1044
|
+
nonce
|
|
1045
|
+
},
|
|
1046
|
+
children
|
|
1047
|
+
}));
|
|
1048
|
+
{
|
|
1049
|
+
const activeMatches = router.stores.matches.get();
|
|
1050
|
+
const assetScripts = getAssetScripts(activeMatches);
|
|
1051
|
+
return renderScripts(router, getScripts(activeMatches), assetScripts);
|
|
1463
1052
|
}
|
|
1053
|
+
};
|
|
1054
|
+
function renderScripts(router, scripts, assetScripts) {
|
|
1464
1055
|
const allScripts = [...scripts, ...assetScripts];
|
|
1465
|
-
if (
|
|
1466
|
-
|
|
1056
|
+
if (router.serverSsr) {
|
|
1057
|
+
const serverBufferedScript = router.serverSsr.takeBufferedScripts();
|
|
1058
|
+
if (serverBufferedScript) allScripts.unshift(serverBufferedScript);
|
|
1059
|
+
}
|
|
1060
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: allScripts.map((asset, i) => /* @__PURE__ */ reactExports.createElement(Asset, {
|
|
1061
|
+
...asset,
|
|
1062
|
+
key: `tsr-scripts-${asset.tag}-${i}`
|
|
1063
|
+
})) });
|
|
1064
|
+
}
|
|
1065
|
+
var noop = () => {
|
|
1066
|
+
};
|
|
1067
|
+
async function waitForReadyOrAbort(ready, signal) {
|
|
1068
|
+
let cleanup = noop;
|
|
1069
|
+
try {
|
|
1070
|
+
await Promise.race([ready, new Promise((resolve) => {
|
|
1071
|
+
const onAbort = () => resolve();
|
|
1072
|
+
cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
1073
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1074
|
+
if (signal.aborted) resolve();
|
|
1075
|
+
})]);
|
|
1076
|
+
} finally {
|
|
1077
|
+
cleanup();
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
var isAbortError = (request, error) => request.signal.aborted && error === request.signal.reason || error instanceof Error && error.name === "AbortError";
|
|
1081
|
+
var renderRouterToStream = async ({ request, router, responseHeaders, children }) => {
|
|
1082
|
+
if (typeof ReactDOMServer.renderToReadableStream === "function") {
|
|
1083
|
+
const stream = await ReactDOMServer.renderToReadableStream(children, {
|
|
1084
|
+
signal: request.signal,
|
|
1085
|
+
nonce: router.options.ssr?.nonce,
|
|
1086
|
+
progressiveChunkSize: Number.POSITIVE_INFINITY,
|
|
1087
|
+
onError: (error, info) => {
|
|
1088
|
+
if (!isAbortError(request, error)) console.error("Error in renderToReadableStream:", error, info);
|
|
1089
|
+
}
|
|
1090
|
+
});
|
|
1091
|
+
if (isbot(request.headers.get("User-Agent"))) await waitForReadyOrAbort(stream.allReady, request.signal);
|
|
1092
|
+
const responseStream = transformReadableStreamWithRouter(router, stream, { onAbort: () => stream.cancel().catch(() => {
|
|
1093
|
+
}) });
|
|
1094
|
+
return createSsrStreamResponse(router, new Response(responseStream, {
|
|
1095
|
+
status: router.stores.statusCode.get(),
|
|
1096
|
+
headers: responseHeaders
|
|
1097
|
+
}));
|
|
1098
|
+
}
|
|
1099
|
+
if (typeof ReactDOMServer.renderToPipeableStream === "function") {
|
|
1100
|
+
const reactAppPassthrough = new PassThrough();
|
|
1101
|
+
let pipeable;
|
|
1102
|
+
let responseAttached = false;
|
|
1103
|
+
let aborted = false;
|
|
1104
|
+
let endedBeforeAttach = false;
|
|
1105
|
+
let pendingAbortReason;
|
|
1106
|
+
const toError = (reason) => reason instanceof Error ? reason : new Error(String(reason ?? "SSR aborted"));
|
|
1107
|
+
const destroyError = (reason) => reason === void 0 ? void 0 : toError(reason);
|
|
1108
|
+
const pendingDestroyError = () => pendingAbortReason === void 0 ? toError(pendingAbortReason) : destroyError(pendingAbortReason);
|
|
1109
|
+
const finishPassThrough = (reason, opts) => {
|
|
1110
|
+
if (reactAppPassthrough.destroyed) return;
|
|
1111
|
+
if (responseAttached) reactAppPassthrough.destroy(opts?.defaultError ? toError(reason) : destroyError(reason));
|
|
1112
|
+
else endedBeforeAttach = true;
|
|
1113
|
+
};
|
|
1114
|
+
const abortPipeable = (reason, opts) => {
|
|
1115
|
+
if (aborted) return;
|
|
1116
|
+
aborted = true;
|
|
1117
|
+
pendingAbortReason = reason;
|
|
1118
|
+
const err = toError(reason);
|
|
1119
|
+
try {
|
|
1120
|
+
pipeable?.abort(err);
|
|
1121
|
+
} catch {
|
|
1122
|
+
}
|
|
1123
|
+
finishPassThrough(reason, opts);
|
|
1124
|
+
};
|
|
1125
|
+
if (request.signal.aborted) abortPipeable(request.signal.reason);
|
|
1126
|
+
else {
|
|
1127
|
+
const onRequestAbort = () => abortPipeable(request.signal.reason);
|
|
1128
|
+
request.signal.addEventListener("abort", onRequestAbort, { once: true });
|
|
1129
|
+
router.serverSsr?.onCleanup(() => {
|
|
1130
|
+
request.signal.removeEventListener("abort", onRequestAbort);
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
try {
|
|
1134
|
+
pipeable = ReactDOMServer.renderToPipeableStream(children, {
|
|
1135
|
+
nonce: router.options.ssr?.nonce,
|
|
1136
|
+
progressiveChunkSize: Number.POSITIVE_INFINITY,
|
|
1137
|
+
...isbot(request.headers.get("User-Agent")) ? { onAllReady() {
|
|
1138
|
+
pipeable.pipe(reactAppPassthrough);
|
|
1139
|
+
} } : { onShellReady() {
|
|
1140
|
+
pipeable.pipe(reactAppPassthrough);
|
|
1141
|
+
} },
|
|
1142
|
+
onError: (error, info) => {
|
|
1143
|
+
if (!isAbortError(request, error)) console.error("Error in renderToPipeableStream:", error, info);
|
|
1144
|
+
abortPipeable(error, { defaultError: true });
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
} catch (e) {
|
|
1148
|
+
console.error("Error in renderToPipeableStream:", e);
|
|
1149
|
+
router.serverSsr?.cleanup();
|
|
1150
|
+
throw e;
|
|
1151
|
+
}
|
|
1152
|
+
const responseStream = transformPipeableStreamWithRouter(router, reactAppPassthrough, { onAbort: abortPipeable });
|
|
1153
|
+
responseAttached = true;
|
|
1154
|
+
if (endedBeforeAttach) reactAppPassthrough.destroy(pendingDestroyError());
|
|
1155
|
+
if (aborted && pipeable) try {
|
|
1156
|
+
pipeable.abort(toError(pendingAbortReason));
|
|
1157
|
+
} catch {
|
|
1158
|
+
}
|
|
1159
|
+
return createSsrStreamResponse(router, new Response(responseStream, {
|
|
1160
|
+
status: router.stores.statusCode.get(),
|
|
1161
|
+
headers: responseHeaders
|
|
1162
|
+
}));
|
|
1467
1163
|
}
|
|
1468
|
-
|
|
1164
|
+
throw new Error("No renderToReadableStream or renderToPipeableStream found in react-dom/server. Ensure you are using a version of react-dom that supports streaming.");
|
|
1469
1165
|
};
|
|
1470
1166
|
export {
|
|
1471
1167
|
HeadContent as H,
|