@chuvenger/devdock 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +200 -12
- package/dist/{chunk-3MVFATRN.js → chunk-2IQRWZ7T.js} +3 -3
- package/dist/{chunk-3MVFATRN.js.map → chunk-2IQRWZ7T.js.map} +1 -1
- package/dist/{chunk-NXZNFF34.js → chunk-2YX4DI2D.js} +253 -145
- package/dist/chunk-2YX4DI2D.js.map +1 -0
- package/dist/{dock-d3HqT25k.d.cts → dock-C7wZ8pQb.d.cts} +1 -1
- package/dist/{dock-P6l6pKjS.d.ts → dock-DJZuGmih.d.ts} +1 -1
- package/dist/index.cjs +253 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/{match-DwGIF1Xt.d.ts → match-C8MsaP6h.d.ts} +1 -1
- package/dist/{match-DDSJIRYW.d.cts → match-Dw1CSS0G.d.cts} +1 -1
- package/dist/react-router.cjs +348 -148
- package/dist/react-router.cjs.map +1 -1
- package/dist/react-router.d.cts +59 -11
- package/dist/react-router.d.ts +59 -11
- package/dist/react-router.js +101 -8
- package/dist/react-router.js.map +1 -1
- package/dist/react.cjs +250 -143
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +3 -2
- package/dist/react.d.ts +3 -2
- package/dist/react.js +2 -2
- package/dist/svelte.cjs +253 -143
- package/dist/svelte.cjs.map +1 -1
- package/dist/svelte.d.cts +4 -3
- package/dist/svelte.d.ts +4 -3
- package/dist/svelte.js +2 -2
- package/dist/svelte.js.map +1 -1
- package/dist/sveltekit.cjs +253 -143
- package/dist/sveltekit.cjs.map +1 -1
- package/dist/sveltekit.d.cts +5 -4
- package/dist/sveltekit.d.ts +5 -4
- package/dist/sveltekit.js +2 -2
- package/dist/{types-B_SpF32A.d.cts → types-B8WgSe7o.d.cts} +103 -3
- package/dist/{types-B_SpF32A.d.ts → types-B8WgSe7o.d.ts} +103 -3
- package/package.json +4 -1
- package/dist/chunk-NXZNFF34.js.map +0 -1
package/dist/react-router.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DevDock } from './chunk-
|
|
1
|
+
import { DevDock } from './chunk-2IQRWZ7T.js';
|
|
2
2
|
import { isDevPath, isMatcher, dedupeByPath, toPredicate } from './chunk-NRBOZ6H5.js';
|
|
3
|
-
import './chunk-
|
|
4
|
-
import { useContext, useMemo } from 'react';
|
|
3
|
+
import './chunk-2YX4DI2D.js';
|
|
4
|
+
import { useContext, useMemo, useState, useEffect, useRef } from 'react';
|
|
5
5
|
import { UNSAFE_DataRouterContext, useNavigate } from 'react-router';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
@@ -36,23 +36,116 @@ function walk(routes, parent, staticRoutes, inherited) {
|
|
|
36
36
|
}
|
|
37
37
|
return out;
|
|
38
38
|
}
|
|
39
|
+
var NO_ROUTES = [];
|
|
40
|
+
var NO_HANDLES = /* @__PURE__ */ new Map();
|
|
41
|
+
function lazyHandleOf(route) {
|
|
42
|
+
const lazy = route.lazy;
|
|
43
|
+
if (typeof lazy === "function") return async () => (await lazy())?.handle;
|
|
44
|
+
return typeof lazy?.handle === "function" ? lazy.handle : void 0;
|
|
45
|
+
}
|
|
46
|
+
async function readLazyHandle(route) {
|
|
47
|
+
try {
|
|
48
|
+
return await lazyHandleOf(route)?.();
|
|
49
|
+
} catch {
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function collectLazy(routes, out = []) {
|
|
54
|
+
for (const r of routes) {
|
|
55
|
+
if (r.handle == null && lazyHandleOf(r) != null) out.push(r);
|
|
56
|
+
if (r.children?.length) collectLazy(r.children, out);
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
function signature(routes, out = []) {
|
|
61
|
+
for (const r of routes) {
|
|
62
|
+
const h = r.handle;
|
|
63
|
+
out.push(
|
|
64
|
+
`${r.path ?? ""}|${r.index ? 1 : 0}|${h?.dev}|${h?.devLabel}|${h?.devGroup}|${h?.hidden}|${lazyHandleOf(r) ? 1 : 0}`
|
|
65
|
+
);
|
|
66
|
+
if (r.children?.length) signature(r.children, out);
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
function useRouteTree(router) {
|
|
71
|
+
const routes = router?.routes ?? NO_ROUTES;
|
|
72
|
+
const [sig, setSig] = useState(() => signature(routes).join("\n"));
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!router?.subscribe) return;
|
|
75
|
+
const check = () => {
|
|
76
|
+
const next = signature(router.routes ?? NO_ROUTES).join("\n");
|
|
77
|
+
setSig((prev) => prev === next ? prev : next);
|
|
78
|
+
};
|
|
79
|
+
check();
|
|
80
|
+
return router.subscribe(check);
|
|
81
|
+
}, [router]);
|
|
82
|
+
return [routes, sig];
|
|
83
|
+
}
|
|
84
|
+
function useLazyHandles(routes, sig, enabled) {
|
|
85
|
+
const [handles, setHandles] = useState(NO_HANDLES);
|
|
86
|
+
const started = useRef(
|
|
87
|
+
/* @__PURE__ */ new WeakMap()
|
|
88
|
+
);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!enabled) return;
|
|
91
|
+
const targets = collectLazy(routes);
|
|
92
|
+
if (targets.length === 0) return;
|
|
93
|
+
let cancelled = false;
|
|
94
|
+
void Promise.all(
|
|
95
|
+
targets.map((route) => {
|
|
96
|
+
let pending = started.current.get(route);
|
|
97
|
+
if (!pending) {
|
|
98
|
+
pending = readLazyHandle(route);
|
|
99
|
+
started.current.set(route, pending);
|
|
100
|
+
}
|
|
101
|
+
return pending.then((handle) => [route, handle]);
|
|
102
|
+
})
|
|
103
|
+
).then((resolved) => {
|
|
104
|
+
if (cancelled) return;
|
|
105
|
+
const found = resolved.filter(
|
|
106
|
+
(entry) => entry[1] != null
|
|
107
|
+
);
|
|
108
|
+
setHandles(
|
|
109
|
+
(prev) => found.some(([route, handle]) => prev.get(route) !== handle) ? new Map([...prev, ...found]) : prev
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
return () => {
|
|
113
|
+
cancelled = true;
|
|
114
|
+
};
|
|
115
|
+
}, [routes, sig, enabled]);
|
|
116
|
+
return handles;
|
|
117
|
+
}
|
|
118
|
+
function mergeHandles(routes, handles) {
|
|
119
|
+
let changed = false;
|
|
120
|
+
const merged = routes.map((r) => {
|
|
121
|
+
const handle = r.handle ?? handles.get(r);
|
|
122
|
+
const children = r.children ? mergeHandles(r.children, handles) : r.children;
|
|
123
|
+
if (handle === r.handle && children === r.children) return r;
|
|
124
|
+
changed = true;
|
|
125
|
+
return { ...r, handle, children };
|
|
126
|
+
});
|
|
127
|
+
return changed ? merged : routes;
|
|
128
|
+
}
|
|
39
129
|
function useDetectedRoutes(options = {}) {
|
|
40
130
|
const opts = isMatcher(options) ? { match: options } : options;
|
|
41
|
-
const { match, staticRoutes } = opts;
|
|
131
|
+
const { match, staticRoutes, loadHandles } = opts;
|
|
42
132
|
const ctx = useContext(UNSAFE_DataRouterContext);
|
|
43
|
-
const routes = ctx?.router
|
|
133
|
+
const [routes, sig] = useRouteTree(ctx?.router);
|
|
134
|
+
const handles = useLazyHandles(routes, sig, loadHandles === true);
|
|
44
135
|
return useMemo(() => {
|
|
45
|
-
const
|
|
136
|
+
const tree = handles.size > 0 ? mergeHandles(routes, handles) : routes;
|
|
137
|
+
const deduped = dedupeByPath(flattenRoutes(tree, "", { staticRoutes }));
|
|
46
138
|
return match ? deduped.filter(toPredicate(match)) : deduped;
|
|
47
|
-
}, [routes, match, staticRoutes]);
|
|
139
|
+
}, [routes, sig, handles, match, staticRoutes]);
|
|
48
140
|
}
|
|
49
141
|
function ReactRouterDevDock({
|
|
50
142
|
match,
|
|
51
143
|
staticRoutes,
|
|
144
|
+
loadHandles,
|
|
52
145
|
...props
|
|
53
146
|
}) {
|
|
54
147
|
const navigate = useNavigate();
|
|
55
|
-
const detected = useDetectedRoutes({ match, staticRoutes });
|
|
148
|
+
const detected = useDetectedRoutes({ match, staticRoutes, loadHandles });
|
|
56
149
|
const routes = useMemo(
|
|
57
150
|
() => [...detected, ...props.routes ?? []],
|
|
58
151
|
[detected, props.routes]
|
package/dist/react-router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react/react-router.tsx"],"names":["DataRouterContext"],"mappings":";;;;;;;AAkCA,SAAS,QAAA,CAAS,QAAgB,KAAA,EAAuB;AACvD,EAAA,IAAI,KAAA,CAAM,UAAA,CAAW,GAAG,CAAA,EAAG,OAAO,KAAA;AAClC,EAAA,IAAI,CAAC,KAAA,EAAO,OAAO,MAAA,IAAU,GAAA;AAC7B,EAAA,MAAM,IAAA,GAAO,OAAO,QAAA,CAAS,GAAG,IAAI,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,GAAI,MAAA;AAC1D,EAAA,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AACzB;AAGA,SAAS,YAAY,MAAA,EAAoC;AACvD,EAAA,OACE,QAAQ,GAAA,KAAQ,IAAA,IAAQ,QAAQ,QAAA,IAAY,IAAA,IAAQ,QAAQ,QAAA,IAAY,IAAA;AAE5E;AAgCO,SAAS,cACd,MAAA,EACA,MAAA,GAAS,EAAA,EACT,OAAA,GAA+C,EAAC,EACpC;AACZ,EAAA,OAAO,IAAA,CAAK,QAAQ,MAAA,EAAQ,OAAA,CAAQ,iBAAiB,IAAA,EAAM,EAAE,GAAA,EAAK,KAAA,EAAO,CAAA;AAC3E;AAEA,SAAS,IAAA,CACP,MAAA,EACA,MAAA,EACA,YAAA,EACA,SAAA,EACY;AACZ,EAAA,MAAM,MAAkB,EAAC;AACzB,EAAA,KAAA,MAAW,KAAK,MAAA,EAAQ;AACtB,IAAA,MAAM,IAAA,GAAO,EAAE,KAAA,GAAQ,MAAA,GAAS,SAAS,MAAA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AA,IAAU,EAAC;AACxC,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,MAAM,OAAA,GAAU,aAAa,aAAA,CAAc,MAAA,EAAQ,IAAI,EAAE,YAAA,EAAc,CAAC,CAAA;AACxE,IAAA,OAAO,QAAQ,OAAA,CAAQ,MAAA,CAAO,WAAA,CAAY,KAAK,CAAC,CAAA,GAAI,OAAA;AAAA,EACtD,CAAA,EAAG,CAAC,MAAA,EAAQ,KAAA,EAAO,YAAY,CAAC,CAAA;AAClC;AAqBO,SAAS,kBAAA,CAAmB;AAAA,EACjC,KAAA;AAAA,EACA,YAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA4B;AAC1B,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,QAAA,GAAW,iBAAA,CAAkB,EAAE,KAAA,EAAO,cAAc,CAAA;AAC1D,EAAA,MAAM,MAAA,GAAS,OAAA;AAAA,IACb,MAAM,CAAC,GAAG,QAAA,EAAU,GAAI,KAAA,CAAM,MAAA,IAAU,EAAG,CAAA;AAAA,IAC3C,CAAC,QAAA,EAAU,KAAA,CAAM,MAAM;AAAA,GACzB;AACA,EAAA,uBACE,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,MAAA;AAAA,MACA,YAAY,KAAA,CAAM,UAAA,KAAe,CAAC,IAAA,KAAS,SAAS,IAAI,CAAA;AAAA;AAAA,GAC1D;AAEJ","file":"react-router.js","sourcesContent":["import { useContext, useMemo } from \"react\";\nimport {\n useNavigate,\n // UNSAFE_DataRouterContext is the supported way to reach the active\n // router instance (and its full route tree) for data routers. Imported\n // from `react-router` (not `react-router-dom`) so this works on v6, v7\n // and v8 — v8 dropped the `react-router-dom` package entirely.\n UNSAFE_DataRouterContext as DataRouterContext,\n} from \"react-router\";\nimport { DevDock, type DevDockProps } from \"./DevDock\";\nimport type { DevRoute } from \"../core/types\";\nimport {\n dedupeByPath,\n isDevPath,\n isMatcher,\n toPredicate,\n type RouteMatcher,\n} from \"../core/match\";\n\nexport type { RouteMatcher };\n\n/** Minimal shape of a react-router route object we care about. */\ninterface RRRoute {\n path?: string;\n index?: boolean;\n children?: RRRoute[];\n handle?: {\n dev?: boolean;\n devLabel?: string;\n devGroup?: string;\n hidden?: boolean;\n } & Record<string, unknown>;\n}\n\nfunction joinPath(parent: string, child: string): string {\n if (child.startsWith(\"/\")) return child;\n if (!child) return parent || \"/\";\n const base = parent.endsWith(\"/\") ? parent.slice(0, -1) : parent;\n return `${base}/${child}`;\n}\n\n/** Opt-in markers that make a route a dev destination. */\nfunction isDevMarked(handle: RRRoute[\"handle\"]): boolean {\n return (\n handle?.dev === true || handle?.devLabel != null || handle?.devGroup != null\n );\n}\n\nexport interface DetectOptions {\n /**\n * Only keep routes that match. A glob string (`*` = any characters), a\n * `RegExp`, or a predicate.\n */\n match?: RouteMatcher;\n /**\n * Also list the app's ordinary static routes, not just the dev ones.\n * Default: `false`.\n */\n staticRoutes?: boolean;\n}\n\n/** State handed down to descendants of a dev-marked route. */\ninterface Inherited {\n dev: boolean;\n group?: string;\n}\n\n/**\n * Flatten a react-router route tree into navigable {@link DevRoute}s.\n *\n * Only dev destinations are returned: routes under `/dev`, routes marked with\n * `handle.dev`, `handle.devLabel` or `handle.devGroup`, and everything nested\n * under them. Pass `{ staticRoutes: true }` to list every static route instead.\n *\n * Dynamic (`:param`) and splat (`*`) segments are skipped since they can't be\n * navigated to without arguments. Mark a route with `handle.hidden` to exclude\n * it, or `handle.devLabel` to rename it.\n */\nexport function flattenRoutes(\n routes: RRRoute[],\n parent = \"\",\n options: Pick<DetectOptions, \"staticRoutes\"> = {},\n): DevRoute[] {\n return walk(routes, parent, options.staticRoutes === true, { dev: false });\n}\n\nfunction walk(\n routes: RRRoute[],\n parent: string,\n staticRoutes: boolean,\n inherited: Inherited,\n): DevRoute[] {\n const out: DevRoute[] = [];\n for (const r of routes) {\n const full = r.index ? parent : joinPath(parent, r.path ?? \"\");\n // A dev route makes its whole subtree dev, so marking a section's layout\n // route is enough to surface the pages inside it. The `/dev` check reads\n // the joined path, which also catches flat routes like `dev/inspector`.\n const dev = inherited.dev || isDevMarked(r.handle) || isDevPath(full);\n const group = r.handle?.devGroup ?? inherited.group;\n const navigable =\n !r.index &&\n r.path != null &&\n !full.includes(\":\") &&\n !full.includes(\"*\") &&\n r.handle?.hidden !== true &&\n (dev || staticRoutes);\n if (navigable) {\n out.push({\n path: full || \"/\",\n label: r.handle?.devLabel ?? (full || \"/\"),\n group,\n });\n }\n if (r.children?.length)\n out.push(...walk(r.children, full, staticRoutes, { dev, group }));\n }\n return out;\n}\n\n/**\n * Read the dev routes off the active react-router data router — anything under\n * `/dev` or marked with `handle.dev` / `devLabel` / `devGroup`, plus their\n * children.\n * Pass `{ staticRoutes: true }` to include the app's ordinary routes too, and\n * `{ match }` to scope the results. A bare matcher is accepted as shorthand.\n */\nexport function useDetectedRoutes(\n options: DetectOptions | RouteMatcher = {},\n): DevRoute[] {\n const opts: DetectOptions = isMatcher(options) ? { match: options } : options;\n const { match, staticRoutes } = opts;\n const ctx = useContext(DataRouterContext);\n const routes = (ctx?.router?.routes ?? []) as RRRoute[];\n return useMemo(() => {\n const deduped = dedupeByPath(flattenRoutes(routes, \"\", { staticRoutes }));\n return match ? deduped.filter(toPredicate(match)) : deduped;\n }, [routes, match, staticRoutes]);\n}\n\nexport interface ReactRouterDevDockProps extends DevDockProps {\n /**\n * Only auto-detect routes that match. A glob string (`*` = any characters,\n * e.g. `\"/dev/*\"`), a `RegExp`, or a predicate. Manual `routes` are always\n * included regardless of this filter.\n */\n match?: RouteMatcher;\n /**\n * List the app's ordinary static routes alongside the dev ones.\n * Off by default, so the dock only shows what you opted in.\n */\n staticRoutes?: boolean;\n}\n\n/**\n * Drop-in {@link DevDock} for react-router apps: navigates via the SPA router\n * and auto-detects the dev routes from the active data router. Any `routes`\n * you pass are appended to the detected ones.\n */\nexport function ReactRouterDevDock({\n match,\n staticRoutes,\n ...props\n}: ReactRouterDevDockProps) {\n const navigate = useNavigate();\n const detected = useDetectedRoutes({ match, staticRoutes });\n const routes = useMemo(\n () => [...detected, ...(props.routes ?? [])],\n [detected, props.routes],\n );\n return (\n <DevDock\n {...props}\n routes={routes}\n onNavigate={props.onNavigate ?? ((path) => navigate(path))}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/react/react-router.tsx"],"names":["DataRouterContext"],"mappings":";;;;;;;AAyDA,SAAS,QAAA,CAAS,QAAgB,KAAA,EAAuB;AACvD,EAAA,IAAI,KAAA,CAAM,UAAA,CAAW,GAAG,CAAA,EAAG,OAAO,KAAA;AAClC,EAAA,IAAI,CAAC,KAAA,EAAO,OAAO,MAAA,IAAU,GAAA;AAC7B,EAAA,MAAM,IAAA,GAAO,OAAO,QAAA,CAAS,GAAG,IAAI,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,GAAI,MAAA;AAC1D,EAAA,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AACzB;AAGA,SAAS,YAAY,MAAA,EAAoC;AACvD,EAAA,OACE,QAAQ,GAAA,KAAQ,IAAA,IAAQ,QAAQ,QAAA,IAAY,IAAA,IAAQ,QAAQ,QAAA,IAAY,IAAA;AAE5E;AAkDO,SAAS,cACd,MAAA,EACA,MAAA,GAAS,EAAA,EACT,OAAA,GAA+C,EAAC,EACpC;AACZ,EAAA,OAAO,IAAA,CAAK,QAAQ,MAAA,EAAQ,OAAA,CAAQ,iBAAiB,IAAA,EAAM,EAAE,GAAA,EAAK,KAAA,EAAO,CAAA;AAC3E;AAEA,SAAS,IAAA,CACP,MAAA,EACA,MAAA,EACA,YAAA,EACA,SAAA,EACY;AACZ,EAAA,MAAM,MAAkB,EAAC;AACzB,EAAA,KAAA,MAAW,KAAK,MAAA,EAAQ;AACtB,IAAA,MAAM,IAAA,GAAO,EAAE,KAAA,GAAQ,MAAA,GAAS,SAAS,MAAA,EAAQ,C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AAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,WAAW,iBAAA,CAAkB,EAAE,KAAA,EAAO,YAAA,EAAc,aAAa,CAAA;AACvE,EAAA,MAAM,MAAA,GAAS,OAAA;AAAA,IACb,MAAM,CAAC,GAAG,QAAA,EAAU,GAAI,KAAA,CAAM,MAAA,IAAU,EAAG,CAAA;AAAA,IAC3C,CAAC,QAAA,EAAU,KAAA,CAAM,MAAM;AAAA,GACzB;AACA,EAAA,uBACE,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACE,GAAG,KAAA;AAAA,MACJ,MAAA;AAAA,MACA,YAAY,KAAA,CAAM,UAAA,KAAe,CAAC,IAAA,KAAS,SAAS,IAAI,CAAA;AAAA;AAAA,GAC1D;AAEJ","file":"react-router.js","sourcesContent":["import { useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n useNavigate,\n // UNSAFE_DataRouterContext is the supported way to reach the active\n // router instance (and its full route tree) for data routers. Imported\n // from `react-router` (not `react-router-dom`) so this works on v6, v7\n // and v8 — v8 dropped the `react-router-dom` package entirely.\n UNSAFE_DataRouterContext as DataRouterContext,\n} from \"react-router\";\nimport { DevDock, type DevDockProps } from \"./DevDock\";\nimport type { DevRoute } from \"../core/types\";\nimport {\n dedupeByPath,\n isDevPath,\n isMatcher,\n toPredicate,\n type RouteMatcher,\n} from \"../core/match\";\n\nexport type { RouteMatcher };\n\n/** The `handle` fields the dock reads off a route. */\ninterface DevHandle {\n dev?: boolean;\n devLabel?: string;\n devGroup?: string;\n hidden?: boolean;\n /** Whatever else the app puts on `handle`; the dock ignores it. */\n [key: string]: unknown;\n}\n\n/** `handle` loader for one route property, as lazy route objects expose it. */\ntype LazyProperty<T> = () => Promise<T | undefined>;\n\n/** Minimal shape of a react-router route object we care about. */\ninterface RRRoute {\n path?: string;\n index?: boolean;\n children?: RRRoute[];\n handle?: DevHandle;\n /**\n * Set while the route's module is still unloaded. Two shapes exist: a\n * function resolving to the module, whose exports are the route's properties\n * (`lazy: () => import(\"./route\")`, v6.19+), and an object with one loader\n * per property (v7.5+, and what framework mode builds for every route).\n * `handle` rides along in both.\n */\n lazy?:\n LazyProperty<{ handle?: DevHandle }> | { handle?: LazyProperty<DevHandle> };\n}\n\n/** The slice of the data router the adapter uses, across v6/v7/v8. */\ninterface RRRouter {\n routes?: RRRoute[];\n subscribe?: (listener: () => void) => () => void;\n}\n\nfunction joinPath(parent: string, child: string): string {\n if (child.startsWith(\"/\")) return child;\n if (!child) return parent || \"/\";\n const base = parent.endsWith(\"/\") ? parent.slice(0, -1) : parent;\n return `${base}/${child}`;\n}\n\n/** Opt-in markers that make a route a dev destination. */\nfunction isDevMarked(handle: RRRoute[\"handle\"]): boolean {\n return (\n handle?.dev === true || handle?.devLabel != null || handle?.devGroup != null\n );\n}\n\nexport interface DetectOptions {\n /**\n * Only keep routes that match. A glob string (`*` = any characters), a\n * `RegExp`, or a predicate.\n */\n match?: RouteMatcher;\n /**\n * Also list the app's ordinary static routes, not just the dev ones.\n * Default: `false`.\n */\n staticRoutes?: boolean;\n /**\n * Import lazy route modules to read their `handle`.\n *\n * In framework mode (`app/routes.ts`) every route is lazy, so `handle` is\n * not on the route object the router exposes — it lives in the route module\n * and only reaches the route once that module loads, i.e. once you visit the\n * page. Without this, framework-mode routes are detected by the `/dev/*`\n * path convention alone and `handle.dev` / `devLabel` / `devGroup` /\n * `hidden` are silently ignored.\n *\n * Opt-in because reading a handle up front means importing the module up\n * front — dev only, but that is still every lazy route's module, and any\n * import side effects with it. Default: `false`.\n */\n loadHandles?: boolean;\n}\n\n/** State handed down to descendants of a dev-marked route. */\ninterface Inherited {\n dev: boolean;\n group?: string;\n}\n\n/**\n * Flatten a react-router route tree into navigable {@link DevRoute}s.\n *\n * Only dev destinations are returned: routes under `/dev`, routes marked with\n * `handle.dev`, `handle.devLabel` or `handle.devGroup`, and everything nested\n * under them. Pass `{ staticRoutes: true }` to list every static route instead.\n *\n * Dynamic (`:param`) and splat (`*`) segments are skipped since they can't be\n * navigated to without arguments. Mark a route with `handle.hidden` to exclude\n * it, or `handle.devLabel` to rename it.\n *\n * Reads `handle` straight off each route object, so a tree whose routes are\n * still lazy has no handles to read — see {@link DetectOptions.loadHandles}.\n */\nexport function flattenRoutes(\n routes: RRRoute[],\n parent = \"\",\n options: Pick<DetectOptions, \"staticRoutes\"> = {},\n): DevRoute[] {\n return walk(routes, parent, options.staticRoutes === true, { dev: false });\n}\n\nfunction walk(\n routes: RRRoute[],\n parent: string,\n staticRoutes: boolean,\n inherited: Inherited,\n): DevRoute[] {\n const out: DevRoute[] = [];\n for (const r of routes) {\n const full = r.index ? parent : joinPath(parent, r.path ?? \"\");\n // A dev route makes its whole subtree dev, so marking a section's layout\n // route is enough to surface the pages inside it. The `/dev` check reads\n // the joined path, which also catches flat routes like `dev/inspector`.\n const dev = inherited.dev || isDevMarked(r.handle) || isDevPath(full);\n const group = r.handle?.devGroup ?? inherited.group;\n const navigable =\n !r.index &&\n r.path != null &&\n !full.includes(\":\") &&\n !full.includes(\"*\") &&\n r.handle?.hidden !== true &&\n (dev || staticRoutes);\n if (navigable) {\n out.push({\n path: full || \"/\",\n label: r.handle?.devLabel ?? (full || \"/\"),\n group,\n });\n }\n if (r.children?.length)\n out.push(...walk(r.children, full, staticRoutes, { dev, group }));\n }\n return out;\n}\n\n// ---- lazy handles ---------------------------------------------------------\n\nconst NO_ROUTES: RRRoute[] = [];\nconst NO_HANDLES: ReadonlyMap<RRRoute, DevHandle> = new Map();\n\n/** The route's `handle` loader, whichever `lazy` shape it uses. */\nfunction lazyHandleOf(route: RRRoute): LazyProperty<DevHandle> | undefined {\n const lazy = route.lazy;\n if (typeof lazy === \"function\") return async () => (await lazy())?.handle;\n return typeof lazy?.handle === \"function\" ? lazy.handle : undefined;\n}\n\nasync function readLazyHandle(route: RRRoute): Promise<DevHandle | undefined> {\n try {\n return await lazyHandleOf(route)?.();\n } catch {\n // A route module that won't load is the app's problem, not the dock's.\n // Fall back to listing the route by path.\n return undefined;\n }\n}\n\nfunction collectLazy(routes: RRRoute[], out: RRRoute[] = []): RRRoute[] {\n for (const r of routes) {\n // A `handle` already on the route is the router's own resolved value.\n if (r.handle == null && lazyHandleOf(r) != null) out.push(r);\n if (r.children?.length) collectLazy(r.children, out);\n }\n return out;\n}\n\n/**\n * Everything the dock reads out of the route tree, as a comparable string.\n *\n * Neither the tree's identity nor its contents are a reliable change signal on\n * their own: the router resolves `lazy` by mutating route objects in place, and\n * patches discovered branches into the arrays it already handed out. Only some\n * versions swap the top-level array. So compare what we actually read.\n */\nfunction signature(routes: RRRoute[], out: string[] = []): string[] {\n for (const r of routes) {\n const h = r.handle;\n out.push(\n `${r.path ?? \"\"}|${r.index ? 1 : 0}|${h?.dev}|${h?.devLabel}` +\n `|${h?.devGroup}|${h?.hidden}|${lazyHandleOf(r) ? 1 : 0}`,\n );\n if (r.children?.length) signature(r.children, out);\n }\n return out;\n}\n\n/**\n * The router's route tree, plus a signature that changes whenever the tree\n * does. Routes arrive late in framework mode — `lazy` modules resolve on\n * navigation and lazy route discovery patches whole branches in as links\n * render — and both land as a router state update.\n */\nfunction useRouteTree(router: RRRouter | undefined): [RRRoute[], string] {\n const routes = router?.routes ?? NO_ROUTES;\n const [sig, setSig] = useState(() => signature(routes).join(\"\\n\"));\n useEffect(() => {\n if (!router?.subscribe) return;\n const check = () => {\n const next = signature(router.routes ?? NO_ROUTES).join(\"\\n\");\n setSig((prev) => (prev === next ? prev : next));\n };\n // The tree can have moved between render and effect.\n check();\n return router.subscribe(check);\n }, [router]);\n return [routes, sig];\n}\n\n/** Handles read out of lazy route modules, keyed by route object. */\nfunction useLazyHandles(\n routes: RRRoute[],\n sig: string,\n enabled: boolean,\n): ReadonlyMap<RRRoute, DevHandle> {\n const [handles, setHandles] = useState(NO_HANDLES);\n // Promises, not values, and keyed by the route objects the router reuses: a\n // module is imported once no matter how often the effect re-runs, and an\n // effect that was cleaned up mid-flight (StrictMode's double invoke) can\n // re-await the same work instead of dropping it.\n const started = useRef(\n new WeakMap<RRRoute, Promise<DevHandle | undefined>>(),\n );\n useEffect(() => {\n if (!enabled) return;\n const targets = collectLazy(routes);\n if (targets.length === 0) return;\n let cancelled = false;\n void Promise.all(\n targets.map((route) => {\n let pending = started.current.get(route);\n if (!pending) {\n pending = readLazyHandle(route);\n started.current.set(route, pending);\n }\n return pending.then((handle) => [route, handle] as const);\n }),\n ).then((resolved) => {\n if (cancelled) return;\n const found = resolved.filter(\n (entry): entry is [RRRoute, DevHandle] => entry[1] != null,\n );\n setHandles((prev) =>\n found.some(([route, handle]) => prev.get(route) !== handle)\n ? new Map([...prev, ...found])\n : prev,\n );\n });\n return () => {\n cancelled = true;\n };\n }, [routes, sig, enabled]);\n return handles;\n}\n\n/**\n * The tree with lazily-read handles filled in. A copy rather than a mutation:\n * assigning `route.handle` ourselves makes the router warn about a \"static\n * property\" and skip its own resolution of the lazy one.\n */\nfunction mergeHandles(\n routes: RRRoute[],\n handles: ReadonlyMap<RRRoute, DevHandle>,\n): RRRoute[] {\n let changed = false;\n const merged = routes.map((r) => {\n const handle = r.handle ?? handles.get(r);\n const children = r.children\n ? mergeHandles(r.children, handles)\n : r.children;\n if (handle === r.handle && children === r.children) return r;\n changed = true;\n return { ...r, handle, children };\n });\n return changed ? merged : routes;\n}\n\n/**\n * Read the dev routes off the active react-router data router — anything under\n * `/dev` or marked with `handle.dev` / `devLabel` / `devGroup`, plus their\n * children.\n * Pass `{ staticRoutes: true }` to include the app's ordinary routes too,\n * `{ match }` to scope the results, and `{ loadHandles: true }` to read\n * `handle` from routes whose module hasn't loaded yet (framework mode). A bare\n * matcher is accepted as shorthand.\n *\n * Re-reads the tree as the router grows it, so routes that are discovered or\n * resolved after the first render show up on their own.\n */\nexport function useDetectedRoutes(\n options: DetectOptions | RouteMatcher = {},\n): DevRoute[] {\n const opts: DetectOptions = isMatcher(options) ? { match: options } : options;\n const { match, staticRoutes, loadHandles } = opts;\n const ctx = useContext(DataRouterContext);\n const [routes, sig] = useRouteTree(ctx?.router as RRRouter | undefined);\n const handles = useLazyHandles(routes, sig, loadHandles === true);\n // `sig` is a dep because the tree is mutated in place (see useRouteTree).\n return useMemo(() => {\n const tree = handles.size > 0 ? mergeHandles(routes, handles) : routes;\n const deduped = dedupeByPath(flattenRoutes(tree, \"\", { staticRoutes }));\n return match ? deduped.filter(toPredicate(match)) : deduped;\n }, [routes, sig, handles, match, staticRoutes]);\n}\n\nexport interface ReactRouterDevDockProps extends DevDockProps {\n /**\n * Only auto-detect routes that match. A glob string (`*` = any characters,\n * e.g. `\"/dev/*\"`), a `RegExp`, or a predicate. Manual `routes` are always\n * included regardless of this filter.\n */\n match?: RouteMatcher;\n /**\n * List the app's ordinary static routes alongside the dev ones.\n * Off by default, so the dock only shows what you opted in.\n */\n staticRoutes?: boolean;\n /**\n * Import lazy route modules so their `handle` is visible. Needed for\n * `handle.dev` / `devLabel` / `devGroup` / `hidden` in React Router\n * framework mode. See {@link DetectOptions.loadHandles}.\n */\n loadHandles?: boolean;\n}\n\n/**\n * Drop-in {@link DevDock} for react-router apps: navigates via the SPA router\n * and auto-detects the dev routes from the active data router. Any `routes`\n * you pass are appended to the detected ones.\n */\nexport function ReactRouterDevDock({\n match,\n staticRoutes,\n loadHandles,\n ...props\n}: ReactRouterDevDockProps) {\n const navigate = useNavigate();\n const detected = useDetectedRoutes({ match, staticRoutes, loadHandles });\n const routes = useMemo(\n () => [...detected, ...(props.routes ?? [])],\n [detected, props.routes],\n );\n return (\n <DevDock\n {...props}\n routes={routes}\n onNavigate={props.onNavigate ?? ((path) => navigate(path))}\n />\n );\n}\n"]}
|