@tanstack/solid-router 2.0.0-alpha.5 → 2.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Asset.cjs +2 -2
- package/dist/cjs/Asset.cjs.map +1 -1
- package/dist/cjs/HeadContent.cjs +11 -1
- package/dist/cjs/HeadContent.cjs.map +1 -1
- package/dist/cjs/HeadContent.dev.cjs +11 -1
- package/dist/cjs/HeadContent.dev.cjs.map +1 -1
- package/dist/cjs/Match.cjs +265 -248
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Match.d.cts +1 -3
- package/dist/cjs/Matches.cjs +35 -34
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/RouterProvider.cjs +12 -8
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/RouterProvider.d.cts +1 -1
- package/dist/cjs/Scripts.cjs +23 -12
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/Scripts.d.cts +2 -1
- package/dist/cjs/Transitioner.cjs +57 -36
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +26 -23
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/headContentUtils.d.cts +2 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.dev.cjs +1 -1
- package/dist/cjs/link.cjs +143 -101
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/matchContext.cjs +7 -5
- package/dist/cjs/matchContext.cjs.map +1 -1
- package/dist/cjs/matchContext.d.cts +8 -2
- package/dist/cjs/not-found.cjs +8 -4
- package/dist/cjs/not-found.cjs.map +1 -1
- package/dist/cjs/not-found.d.cts +1 -1
- package/dist/cjs/router.cjs +2 -1
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/routerStores.cjs +75 -0
- package/dist/cjs/routerStores.cjs.map +1 -0
- package/dist/cjs/routerStores.d.cts +10 -0
- package/dist/cjs/ssr/RouterClient.cjs +1 -1
- package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs +1 -1
- package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs +1 -1
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/useBlocker.cjs +12 -3
- package/dist/cjs/useBlocker.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.cjs +6 -2
- package/dist/cjs/useCanGoBack.cjs.map +1 -1
- package/dist/cjs/useCanGoBack.d.cts +2 -1
- package/dist/cjs/useLoaderDeps.cjs +2 -3
- package/dist/cjs/useLoaderDeps.cjs.map +1 -1
- package/dist/cjs/useLocation.cjs +13 -2
- package/dist/cjs/useLocation.cjs.map +1 -1
- package/dist/cjs/useMatch.cjs +27 -15
- package/dist/cjs/useMatch.cjs.map +1 -1
- package/dist/cjs/useParams.cjs +1 -1
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/cjs/useRouterState.cjs +12 -30
- package/dist/cjs/useRouterState.cjs.map +1 -1
- package/dist/cjs/useSearch.cjs +2 -1
- package/dist/cjs/useSearch.cjs.map +1 -1
- package/dist/cjs/utils.cjs +3 -17
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +0 -5
- package/dist/esm/Asset.js +6 -6
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/HeadContent.dev.js +12 -2
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +12 -2
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Match.d.ts +1 -3
- package/dist/esm/Match.js +267 -250
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +40 -39
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.d.ts +1 -1
- package/dist/esm/RouterProvider.js +10 -7
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.js +2 -2
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.d.ts +2 -1
- package/dist/esm/Scripts.js +21 -11
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.js +58 -37
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/headContentUtils.d.ts +2 -1
- package/dist/esm/headContentUtils.js +26 -23
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/link.js +146 -104
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.d.ts +8 -2
- package/dist/esm/matchContext.js +7 -4
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.d.ts +1 -1
- package/dist/esm/not-found.js +6 -3
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/router.js +2 -1
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerStores.d.ts +10 -0
- package/dist/esm/routerStores.js +73 -0
- package/dist/esm/routerStores.js.map +1 -0
- package/dist/esm/scroll-restoration.js +2 -2
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.js +1 -1
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +1 -1
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +1 -1
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/useBlocker.js +12 -3
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.d.ts +2 -1
- package/dist/esm/useCanGoBack.js +4 -2
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderDeps.js +2 -3
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +11 -2
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +28 -16
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useParams.js +1 -1
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouterState.js +11 -30
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js +2 -1
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.d.ts +0 -5
- package/dist/esm/utils.js +4 -17
- package/dist/esm/utils.js.map +1 -1
- package/dist/source/Asset.jsx +3 -3
- package/dist/source/Asset.jsx.map +1 -1
- package/dist/source/HeadContent.dev.jsx +5 -1
- package/dist/source/HeadContent.dev.jsx.map +1 -1
- package/dist/source/HeadContent.jsx +5 -1
- package/dist/source/HeadContent.jsx.map +1 -1
- package/dist/source/Match.d.ts +1 -3
- package/dist/source/Match.jsx +260 -264
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +46 -46
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/RouterProvider.d.ts +1 -1
- package/dist/source/RouterProvider.jsx +13 -9
- package/dist/source/RouterProvider.jsx.map +1 -1
- package/dist/source/Scripts.d.ts +2 -1
- package/dist/source/Scripts.jsx +46 -47
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +80 -44
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/headContentUtils.d.ts +2 -1
- package/dist/source/headContentUtils.jsx +79 -80
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/link.jsx +145 -112
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/matchContext.d.ts +8 -2
- package/dist/source/matchContext.jsx +7 -3
- package/dist/source/matchContext.jsx.map +1 -1
- package/dist/source/not-found.d.ts +1 -1
- package/dist/source/not-found.jsx +6 -5
- package/dist/source/not-found.jsx.map +1 -1
- package/dist/source/router.js +2 -1
- package/dist/source/router.js.map +1 -1
- package/dist/source/routerStores.d.ts +10 -0
- package/dist/source/routerStores.js +82 -0
- package/dist/source/routerStores.js.map +1 -0
- package/dist/source/ssr/RouterClient.jsx +1 -1
- package/dist/source/ssr/RouterClient.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToStream.jsx +1 -1
- package/dist/source/ssr/renderRouterToStream.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToString.jsx +1 -1
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -1
- package/dist/source/useBlocker.jsx +19 -8
- package/dist/source/useBlocker.jsx.map +1 -1
- package/dist/source/useCanGoBack.d.ts +2 -1
- package/dist/source/useCanGoBack.js +4 -2
- package/dist/source/useCanGoBack.js.map +1 -1
- package/dist/source/useLoaderDeps.jsx +2 -3
- package/dist/source/useLoaderDeps.jsx.map +1 -1
- package/dist/source/useLocation.jsx +13 -3
- package/dist/source/useLocation.jsx.map +1 -1
- package/dist/source/useMatch.jsx +33 -23
- package/dist/source/useMatch.jsx.map +1 -1
- package/dist/source/useParams.jsx +1 -1
- package/dist/source/useParams.jsx.map +1 -1
- package/dist/source/useRouterState.jsx +14 -55
- package/dist/source/useRouterState.jsx.map +1 -1
- package/dist/source/useSearch.jsx +2 -1
- package/dist/source/useSearch.jsx.map +1 -1
- package/dist/source/utils.d.ts +0 -5
- package/dist/source/utils.js +2 -15
- package/dist/source/utils.js.map +1 -1
- package/package.json +7 -7
- package/skills/solid-router/SKILL.md +2 -0
- package/src/Asset.tsx +3 -3
- package/src/HeadContent.dev.tsx +10 -1
- package/src/HeadContent.tsx +10 -1
- package/src/Match.tsx +395 -349
- package/src/Matches.tsx +55 -54
- package/src/RouterProvider.tsx +13 -10
- package/src/Scripts.tsx +55 -54
- package/src/Transitioner.tsx +103 -60
- package/src/headContentUtils.tsx +104 -96
- package/src/link.tsx +188 -146
- package/src/matchContext.tsx +16 -7
- package/src/not-found.tsx +6 -6
- package/src/router.ts +2 -1
- package/src/routerStores.ts +119 -0
- package/src/ssr/RouterClient.tsx +1 -1
- package/src/ssr/renderRouterToStream.tsx +1 -1
- package/src/ssr/renderRouterToString.tsx +1 -1
- package/src/useBlocker.tsx +80 -63
- package/src/useCanGoBack.ts +6 -2
- package/src/useLoaderDeps.tsx +2 -3
- package/src/useLocation.tsx +18 -5
- package/src/useMatch.tsx +37 -38
- package/src/useParams.tsx +2 -3
- package/src/useRouterState.tsx +21 -67
- package/src/useSearch.tsx +2 -1
- package/src/utils.ts +2 -24
package/dist/cjs/Match.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Match.cjs","names":["Solid","invariant","warning","createControlledPromise","getLocationChangeInfo","isNotFound","isRedirect","rootRouteId","isServer","Dynamic","CatchBoundary","ErrorComponent","useRouterState","useRouter","CatchNotFound","matchContext","SafeFragment","renderRouteNotFound","ScrollRestoration","AnyRoute","RootRouteOptions","MatchContext","Component","value","children","Match","props","matchId","router","matchState","select","s","match","matches","find","d","id","routeId","ssr","_displayPending","untrack","route","routesById","resolvePendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","resolvedNoSsr","createMemo","ResolvedSuspenseBoundary","Loading","ResolvedCatchBoundary","ResolvedNotFoundBoundary","resetKey","loadedAt","parentRouteId","index","findIndex","ShellComponent","shellComponent","_$createComponent","fallback","_$memo","undefined","getResetKey","error","Error","_$mergeProps","Switch","when","Show","MatchInner","OnRendered","lastOnRenderedKey","WeakMap","location","resolvedLocation","state","__TSR_key","createEffect","const","get","set","emit","type","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","key","JSON","stringify","status","_forcePending","componentKey","out","currentRoute","Comp","defaultComponent","Outlet","keyedOut","keyed","_key","_","displayPendingResult","getMatch","_nonReactive","displayPendingPromise","minPendingResult","minPendingPromise","currentMatch","pendingMinMs","defaultPendingMinMs","routerMatch","setTimeout","resolve","loaderResult","Promise","r","loadPromise","FallbackComponent","currentRouteId","_routeId","RouteErrorComponent","info","componentStack","useContext","parentGlobalNotFound","parentMatch","globalNotFound","childMatchId","v","childRouteId","childMatchStatus","shouldShowNotFound","matchIdAccessor","currentMatchId"],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from '@solidjs/web'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nconst MatchContext = matchContext as unknown as Solid.Component<{\n value: any\n children?: any\n}>\n\nexport const Match = (props: { matchId: string }) => {\n const router = useRouter()\n const matchState = useRouterState({\n select: (s) => {\n const match = s.matches.find((d) => d.id === props.matchId)\n\n // During navigation transitions, matches can be temporarily removed\n // Return null to avoid errors - the component will handle this gracefully\n if (!match) {\n return null\n }\n\n return {\n routeId: match.routeId,\n ssr: match.ssr,\n _displayPending: match._displayPending,\n }\n },\n })\n\n // If match doesn't exist yet, return null (component is being unmounted or not ready)\n if (!Solid.untrack(matchState)) return null\n\n const route: () => AnyRoute = () => router.routesById[matchState()!.routeId]\n\n const resolvePendingComponent = () =>\n route().options.pendingComponent ?? router.options.defaultPendingComponent\n\n const routeErrorComponent = () =>\n route().options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeOnCatch = () =>\n route().options.onCatch ?? router.options.defaultOnCatch\n\n const routeNotFoundComponent = () =>\n route().isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route().options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route().options.notFoundComponent\n\n const resolvedNoSsr = Solid.createMemo(\n () => matchState()!.ssr === false || matchState()!.ssr === 'data-only',\n )\n\n const ResolvedSuspenseBoundary = () =>\n resolvedNoSsr() ? SafeFragment : Solid.Loading\n\n const ResolvedCatchBoundary = () =>\n routeErrorComponent() ? CatchBoundary : SafeFragment\n\n const ResolvedNotFoundBoundary = () =>\n routeNotFoundComponent() ? CatchNotFound : SafeFragment\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const parentRouteId = useRouterState({\n select: (s) => {\n const index = s.matches.findIndex((d) => d.id === props.matchId)\n return s.matches[index - 1]?.routeId as string\n },\n })\n\n const ShellComponent = Solid.createMemo(() =>\n route().isRoot\n ? ((route().options as RootRouteOptions).shellComponent ?? SafeFragment)\n : SafeFragment,\n )\n\n return (\n <Dynamic component={ShellComponent()}>\n <MatchContext value={() => props.matchId}>\n <Dynamic\n component={ResolvedSuspenseBoundary()}\n fallback={\n // Don't show fallback on server when using no-ssr mode to avoid hydration mismatch\n (isServer ?? router.isServer) || resolvedNoSsr() ? undefined : (\n <Dynamic component={resolvePendingComponent()} />\n )\n }\n >\n <Dynamic\n component={ResolvedCatchBoundary()}\n getResetKey={() => resetKey()}\n errorComponent={routeErrorComponent() || ErrorComponent}\n onCatch={(error: Error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(\n false,\n `Error in route match: ${Solid.untrack(matchState)!.routeId}`,\n )\n routeOnCatch()?.(error)\n }}\n >\n <Dynamic\n component={ResolvedNotFoundBoundary()}\n fallback={(error: any) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent() ||\n (error.routeId && error.routeId !== matchState()!.routeId) ||\n (!error.routeId && !route().isRoot)\n )\n throw error\n\n return (\n <Dynamic component={routeNotFoundComponent()} {...error} />\n )\n }}\n >\n <Solid.Switch>\n <Solid.Match when={resolvedNoSsr()}>\n <Solid.Show\n when={!(isServer ?? router.isServer)}\n fallback={<Dynamic component={resolvePendingComponent()} />}\n >\n <MatchInner matchId={props.matchId} />\n </Solid.Show>\n </Solid.Match>\n <Solid.Match when={!resolvedNoSsr()}>\n <MatchInner matchId={props.matchId} />\n </Solid.Match>\n </Solid.Switch>\n </Dynamic>\n </Dynamic>\n </Dynamic>\n </MatchContext>\n\n {parentRouteId() === rootRouteId ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </Dynamic>\n )\n}\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.__TSR_key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\n//\n// In Solid, createEffect(source, fn) fires on initial mount as well as on\n// reactive changes. OnRendered can also remount when the first child route\n// changes (e.g. navigating from / to /posts). We deduplicate by tracking\n// the last emitted resolvedLocation key per router so each unique resolved\n// location only triggers one onRendered event regardless of remounts.\nconst lastOnRenderedKey = new WeakMap<object, string>()\n\nfunction OnRendered() {\n const router = useRouter()\n\n const location = useRouterState({\n select: (s) => {\n return s.resolvedLocation?.state.__TSR_key\n },\n })\n Solid.createEffect(\n () => [location()] as const,\n ([location]) => {\n if (!location) return\n if (lastOnRenderedKey.get(router) === location) return\n lastOnRenderedKey.set(router, location)\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(router.state),\n })\n },\n )\n return null\n}\n\nexport const MatchInner = (props: { matchId: string }): any => {\n const router = useRouter()\n\n const matchState = useRouterState({\n select: (s) => {\n const match = s.matches.find((d) => d.id === props.matchId)\n\n // During navigation transitions, matches can be temporarily removed\n if (!match) {\n return null\n }\n\n const routeId = match.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n search: match._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: {\n id: match.id,\n status: match.status,\n error: match.error,\n _forcePending: match._forcePending,\n _displayPending: match._displayPending,\n },\n }\n },\n })\n\n if (!Solid.untrack(matchState)) return null\n\n const route = () => router.routesById[matchState()!.routeId]!\n\n const match = () => matchState()!.match\n\n const componentKey = () => matchState()!.key ?? matchState()!.match.id\n\n const out = () => {\n const currentRoute = Solid.untrack(route)\n const Comp =\n currentRoute.options.component ?? router.options.defaultComponent\n if (Comp) {\n return <Comp />\n }\n return <Outlet />\n }\n\n const keyedOut = () => (\n <Solid.Show when={componentKey()} keyed>\n {(_key) => out()}\n </Solid.Show>\n )\n\n return (\n <Solid.Switch>\n <Solid.Match when={match()._displayPending}>\n {(_) => {\n const matchId = Solid.untrack(() => match().id)\n const displayPendingResult = Solid.createMemo(\n () => router.getMatch(matchId)?._nonReactive.displayPendingPromise,\n )\n\n return <>{displayPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={match()._forcePending}>\n {(_) => {\n const matchId = Solid.untrack(() => match().id)\n const minPendingResult = Solid.createMemo(\n () => router.getMatch(matchId)?._nonReactive.minPendingPromise,\n )\n\n return <>{minPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'pending'}>\n {(_) => {\n const currentMatch = Solid.untrack(match)\n const currentRoute = Solid.untrack(route)\n const pendingMinMs =\n currentRoute.options.pendingMinMs ??\n router.options.defaultPendingMinMs\n\n if (pendingMinMs) {\n const routerMatch = router.getMatch(currentMatch.id)\n if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise = minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n }\n\n const loaderResult = Solid.createMemo(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(currentMatch.id)?._nonReactive.loadPromise\n })\n\n const FallbackComponent =\n currentRoute.options.pendingComponent ??\n router.options.defaultPendingComponent\n\n return (\n <>\n {FallbackComponent && pendingMinMs > 0 ? (\n <Dynamic component={FallbackComponent} />\n ) : null}\n {loaderResult()}\n </>\n )\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'notFound'}>\n {(_) => {\n const currentMatch = Solid.untrack(match)\n const currentRoute = Solid.untrack(route)\n const currentRouteId = Solid.untrack(() => matchState()!.routeId)\n invariant(isNotFound(currentMatch.error), 'Expected a notFound error')\n\n // Use Show with keyed to ensure re-render when routeId changes\n return (\n <Solid.Show when={currentRouteId} keyed>\n {(_routeId) =>\n renderRouteNotFound(router, currentRoute, currentMatch.error)\n }\n </Solid.Show>\n )\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'redirected'}>\n {(_) => {\n const matchId = Solid.untrack(() => match().id)\n invariant(\n isRedirect(Solid.untrack(match).error),\n 'Expected a redirect error',\n )\n\n const loaderResult = Solid.createMemo(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(matchId)?._nonReactive.loadPromise\n })\n\n return <>{loaderResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'error'}>\n {(_) => {\n if (isServer ?? router.isServer) {\n const currentMatch = Solid.untrack(match)\n const RouteErrorComponent =\n (Solid.untrack(route).options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n\n return (\n <RouteErrorComponent\n error={currentMatch.error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw Solid.untrack(match).error\n }}\n </Solid.Match>\n <Solid.Match when={match().status === 'success'}>\n {keyedOut()}\n </Solid.Match>\n </Solid.Switch>\n )\n}\n\nexport const Outlet = () => {\n const router = useRouter()\n const matchId = Solid.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId())?.routeId as string,\n })\n\n const route = () => router.routesById[routeId()]!\n\n const parentGlobalNotFound = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId())\n\n // During navigation transitions, parent match can be temporarily removed\n // Return false to avoid errors - the component will handle this gracefully\n if (!parentMatch) {\n return false\n }\n\n return parentMatch.globalNotFound\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId())\n const v = matches[index + 1]?.id\n return v\n },\n })\n\n const childRouteId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId())\n return matches[index + 1]?.routeId\n },\n })\n\n const childMatchStatus = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId())\n return matches[index + 1]?.status\n },\n })\n\n // Only show not-found if we're not in a redirected state\n const shouldShowNotFound = () =>\n childMatchStatus() !== 'redirected' && parentGlobalNotFound()\n\n return (\n <Solid.Show\n when={!shouldShowNotFound() && childMatchId()}\n fallback={\n <Solid.Show when={shouldShowNotFound()}>\n {renderRouteNotFound(router, route(), undefined)}\n </Solid.Show>\n }\n >\n {(matchIdAccessor) => {\n // Use a memo to avoid stale accessor errors while keeping reactivity\n const currentMatchId = Solid.createMemo(() => matchIdAccessor())\n\n return (\n <Solid.Show\n when={routeId() === rootRouteId}\n fallback={<Match matchId={currentMatchId()} />}\n >\n <Solid.Show when={childRouteId()} keyed>\n {(_routeId) => (\n <Solid.Loading\n fallback={\n <Dynamic\n component={router.options.defaultPendingComponent}\n />\n }\n >\n <Match matchId={currentMatchId()} />\n </Solid.Loading>\n )}\n </Solid.Show>\n </Solid.Show>\n )\n }}\n </Solid.Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,IAAMqB,eAAeN,qBAAAA;AAKrB,IAAaU,SAASC,UAA+B;CACnD,MAAME,SAASf,kBAAAA,WAAW;CAC1B,MAAMgB,aAAajB,uBAAAA,eAAe,EA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,WAAA,GAAA,aAAA,YAAE,CAAA,CAAA,CAACqE,oBAAoB,CAAA,EAAA,IAAIJ,cAAc;;EAAA,IAC7CzE,WAAQ;AAAA,WAAA,GAAA,aAAA,iBACLxE,SAAMiF,MAAI;IAAA,IAACD,OAAI;AAAA,YAAEqE,oBAAoB;;IAAA,IAAA7H,WAAA;AAAA,YACnCP,4BAAAA,oBAAoBW,QAAQa,OAAO,EAAEiC,KAAAA,EAAU;;IAAA,CAAA;;EAAAlD,WAIlD8H,oBAAoB;GAEpB,MAAMC,iBAAiBvJ,SAAM2D,iBAAiB2F,iBAAiB,CAAC;AAEhE,WAAA,GAAA,aAAA,iBACGtJ,SAAMiF,MAAI;IAAA,IACTD,OAAI;AAAA,YAAE3C,SAAS,KAAK9B,sBAAAA;;IAAW,IAC/BiE,WAAQ;AAAA,aAAA,GAAA,aAAA,iBAAG/C,OAAK,EAAA,IAACE,UAAO;AAAA,aAAE4H,gBAAgB;QAAA,CAAA;;IAAA,IAAA/H,WAAA;AAAA,aAAA,GAAA,aAAA,iBAEzCxB,SAAMiF,MAAI;MAAA,IAACD,OAAI;AAAA,cAAEmE,cAAc;;MAAE/B,OAAK;MAAA5F,WACnCiH,cAAAA,GAAAA,aAAAA,iBACCzI,SAAM6D,SAAO;OAAA,IACZW,WAAQ;AAAA,gBAAA,GAAA,aAAA,iBACL/D,aAAAA,SAAO,EAAA,IACNgD,YAAS;AAAA,gBAAE7B,OAAOgB,QAAQE;WAAuB,CAAA;;OAAA,IAAAtB,WAAA;AAAA,gBAAA,GAAA,aAAA,iBAIpDC,OAAK,EAAA,IAACE,UAAO;AAAA,gBAAE4H,gBAAgB;WAAA,CAAA;;OAAA,CAAA;MAEnC,CAAA;;IAAA,CAAA;;EAIR,CAAA"}
|
|
1
|
+
{"version":3,"file":"Match.cjs","names":["Solid","invariant","warning","createControlledPromise","getLocationChangeInfo","isNotFound","isRedirect","rootRouteId","isServer","Dynamic","CatchBoundary","ErrorComponent","useRouter","CatchNotFound","nearestMatchContext","SafeFragment","renderRouteNotFound","ScrollRestoration","AnyRoute","RootRouteOptions","NearestMatchContext","Component","value","children","Match","props","matchId","router","match","createMemo","id","undefined","stores","activeMatchStoresById","get","state","rawMatchState","currentMatch","routeId","parentRouteId","routesById","parentRoute","ssr","_displayPending","hasPendingMatch","currentRouteId","Boolean","pendingRouteIds","nearestMatch","hasPending","_$createComponent","Show","when","currentMatchState","route","resolvePendingComponent","options","pendingComponent","defaultPendingComponent","routeErrorComponent","errorComponent","defaultErrorComponent","routeOnCatch","onCatch","defaultOnCatch","routeNotFoundComponent","isRoot","notFoundComponent","notFoundRoute","component","resolvedNoSsr","ResolvedSuspenseBoundary","Loading","ResolvedCatchBoundary","ResolvedNotFoundBoundary","ShellComponent","shellComponent","fallback","_$memo","getResetKey","loadedAt","error","Error","_$mergeProps","Switch","MatchInner","OnRendered","lastOnRenderedKey","WeakMap","location","resolvedLocation","__TSR_key","locationState","resolvedLocationState","createEffect","const","currentLocationState","currentResolvedLocationState","set","emit","type","useContext","remountFn","remountDeps","defaultRemountDeps","loaderDeps","params","_strictParams","search","_strictSearch","key","JSON","stringify","status","_forcePending","componentKey","Comp","defaultComponent","OutComponent","C","Outlet","RenderOut","keyedOut","keyed","_key","_","displayPendingResult","getMatch","_nonReactive","displayPendingPromise","minPendingResult","minPendingPromise","pendingMinMs","untrack","defaultPendingMinMs","routerMatch","setTimeout","resolve","loaderResult","Promise","r","loadPromise","FallbackComponent","matchError","_routeId","RouteErrorComponent","info","componentStack","nearestParentMatch","parentMatch","parentGlobalNotFound","globalNotFound","childMatchId","childMatchIdByRouteId","childRouteId","childRoute","childPendingComponent","childMatchStatus","shouldShowNotFound","resolvedRoute","childMatchIdAccessor","currentMatchId"],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport {\n createControlledPromise,\n getLocationChangeInfo,\n isNotFound,\n isRedirect,\n rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { Dynamic } from '@solidjs/web'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nconst NearestMatchContext = nearestMatchContext as unknown as Solid.Component<{\n value: any\n children?: any\n}>\n\nexport const Match = (props: { matchId: string }) => {\n const router = useRouter()\n\n const match = Solid.createMemo(() => {\n const id = props.matchId\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state\n })\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n const parentRouteId = (router.routesById[routeId] as AnyRoute)?.parentRoute\n ?.id\n\n return {\n matchId: currentMatch.id,\n routeId,\n ssr: currentMatch.ssr,\n _displayPending: currentMatch._displayPending,\n parentRouteId: parentRouteId as string | undefined,\n }\n })\n\n const hasPendingMatch = Solid.createMemo(() => {\n const currentRouteId = rawMatchState()?.routeId\n return currentRouteId\n ? Boolean(router.stores.pendingRouteIds.state[currentRouteId])\n : false\n })\n const nearestMatch = {\n matchId: () => rawMatchState()?.matchId,\n routeId: () => rawMatchState()?.routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route = Solid.createMemo(\n () => router.routesById[currentMatchState().routeId] as AnyRoute,\n )\n\n const resolvePendingComponent = Solid.createMemo(\n () =>\n route().options.pendingComponent ??\n router.options.defaultPendingComponent,\n )\n\n const routeErrorComponent = Solid.createMemo(\n () =>\n route().options.errorComponent ??\n router.options.defaultErrorComponent,\n )\n\n const routeOnCatch = Solid.createMemo(\n () => route().options.onCatch ?? router.options.defaultOnCatch,\n )\n\n const routeNotFoundComponent = Solid.createMemo(() =>\n route().isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n (route().options.notFoundComponent ??\n router.options.notFoundRoute?.options.component)\n : route().options.notFoundComponent,\n )\n\n const resolvedNoSsr = Solid.createMemo(\n () =>\n currentMatchState().ssr === false ||\n currentMatchState().ssr === 'data-only',\n )\n\n const ResolvedSuspenseBoundary = Solid.createMemo(() =>\n resolvedNoSsr() ? SafeFragment : Solid.Loading,\n )\n\n const ResolvedCatchBoundary = Solid.createMemo(() =>\n routeErrorComponent() ? CatchBoundary : SafeFragment,\n )\n\n const ResolvedNotFoundBoundary = Solid.createMemo(() =>\n routeNotFoundComponent() ? CatchNotFound : SafeFragment,\n )\n\n const ShellComponent = Solid.createMemo(() =>\n route().isRoot\n ? ((route().options as RootRouteOptions).shellComponent ??\n SafeFragment)\n : SafeFragment,\n )\n\n return (\n <Dynamic component={ShellComponent()}>\n <NearestMatchContext value={nearestMatch}>\n <Dynamic\n component={ResolvedSuspenseBoundary()}\n fallback={\n // Don't show fallback on server when using no-ssr mode to avoid hydration mismatch\n (isServer ?? router.isServer) &&\n resolvedNoSsr() ? undefined : (\n <Dynamic component={resolvePendingComponent()} />\n )\n }\n >\n <Dynamic\n component={ResolvedCatchBoundary()}\n getResetKey={() => router.stores.loadedAt.state}\n errorComponent={routeErrorComponent() || ErrorComponent}\n onCatch={(error: Error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(\n false,\n `Error in route match: ${currentMatchState().routeId}`,\n )\n routeOnCatch()?.(error)\n }}\n >\n <Dynamic\n component={ResolvedNotFoundBoundary()}\n fallback={(error: any) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent() ||\n (error.routeId &&\n error.routeId !== currentMatchState().routeId) ||\n (!error.routeId && !route().isRoot)\n )\n throw error\n\n return (\n <Dynamic\n component={routeNotFoundComponent()}\n {...error}\n />\n )\n }}\n >\n <Solid.Switch>\n <Solid.Match when={resolvedNoSsr()}>\n <Solid.Show\n when={!(isServer ?? router.isServer)}\n fallback={\n <Dynamic component={resolvePendingComponent()} />\n }\n >\n <MatchInner />\n </Solid.Show>\n </Solid.Match>\n <Solid.Match when={!resolvedNoSsr()}>\n <MatchInner />\n </Solid.Match>\n </Solid.Switch>\n </Dynamic>\n </Dynamic>\n </Dynamic>\n </NearestMatchContext>\n\n {currentMatchState().parentRouteId === rootRouteId ? (\n <>\n <OnRendered />\n <ScrollRestoration />\n </>\n ) : null}\n </Dynamic>\n )\n }}\n </Solid.Show>\n )\n}\n\n// On Rendered can't happen above the root layout because it actually\n// renders a dummy dom element to track the rendered state of the app.\n// We render a script tag with a key that changes based on the current\n// location state.__TSR_key. Also, because it's below the root layout, it\n// allows us to fire onRendered events even after a hydration mismatch\n// error that occurred above the root layout (like bad head/link tags,\n// which is common).\n//\n// In Solid, createEffect(source, fn) fires on initial mount as well as on\n// reactive changes. OnRendered can also remount when the first child route\n// changes (e.g. navigating from / to /posts). We deduplicate by tracking\n// the last emitted resolvedLocation key per router so each unique resolved\n// location only triggers one onRendered event regardless of remounts.\nconst lastOnRenderedKey = new WeakMap<object, string>()\n\nfunction OnRendered() {\n const router = useRouter()\n\n const location = Solid.createMemo(\n () => router.stores.resolvedLocation.state?.state.__TSR_key,\n )\n const locationState = Solid.createMemo(() => router.stores.location.state)\n const resolvedLocationState = Solid.createMemo(\n () => router.stores.resolvedLocation.state,\n )\n Solid.createEffect(\n () => [location(), locationState(), resolvedLocationState()] as const,\n ([location, currentLocationState, currentResolvedLocationState]) => {\n if (!location) return\n if (lastOnRenderedKey.get(router) === location) return\n lastOnRenderedKey.set(router, location)\n router.emit({\n type: 'onRendered',\n ...getLocationChangeInfo(\n currentLocationState,\n currentResolvedLocationState,\n ),\n })\n },\n )\n return null\n}\n\nexport const MatchInner = (): any => {\n const router = useRouter()\n const match = Solid.useContext(nearestMatchContext).match\n\n const rawMatchState = Solid.createMemo(() => {\n const currentMatch = match()\n if (!currentMatch) {\n return null\n }\n\n const routeId = currentMatch.routeId as string\n\n const remountFn =\n (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n router.options.defaultRemountDeps\n const remountDeps = remountFn?.({\n routeId,\n loaderDeps: currentMatch.loaderDeps,\n params: currentMatch._strictParams,\n search: currentMatch._strictSearch,\n })\n const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n\n return {\n key,\n routeId,\n match: {\n id: currentMatch.id,\n status: currentMatch.status,\n error: currentMatch.error,\n _forcePending: currentMatch._forcePending ?? false,\n _displayPending: currentMatch._displayPending ?? false,\n },\n }\n })\n\n return (\n <Solid.Show when={rawMatchState()}>\n {(currentMatchState) => {\n const route = Solid.createMemo(\n () => router.routesById[currentMatchState().routeId]!,\n )\n\n const currentMatch = Solid.createMemo(() => currentMatchState().match)\n\n const componentKey = Solid.createMemo(\n () => currentMatchState().key ?? currentMatchState().match.id,\n )\n\n const Comp = Solid.createMemo(\n () => route().options.component ?? router.options.defaultComponent,\n )\n\n const OutComponent = Solid.createMemo(() => {\n const C = Comp()\n return C || Outlet\n })\n\n const RenderOut = () => <Dynamic component={OutComponent()} />\n\n const keyedOut = () => (\n <Solid.Show when={componentKey()} keyed>\n {(_key) => <RenderOut />}\n </Solid.Show>\n )\n\n return (\n <Solid.Switch>\n <Solid.Match when={currentMatch()._displayPending}>\n {(_) => {\n const displayPendingResult = Solid.createMemo(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .displayPendingPromise,\n )\n\n return <>{displayPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch()._forcePending}>\n {(_) => {\n const minPendingResult = Solid.createMemo(\n () =>\n router.getMatch(currentMatch().id)?._nonReactive\n .minPendingPromise,\n )\n\n return <>{minPendingResult()}</>\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'pending'}>\n {(_) => {\n const pendingMinMs = Solid.untrack(\n () =>\n route().options.pendingMinMs ??\n router.options.defaultPendingMinMs,\n )\n\n if (pendingMinMs) {\n const routerMatch = Solid.untrack(() =>\n router.getMatch(currentMatch().id),\n )\n if (\n routerMatch &&\n !routerMatch._nonReactive.minPendingPromise\n ) {\n // Create a promise that will resolve after the minPendingMs\n if (!(isServer ?? router.isServer)) {\n const minPendingPromise = createControlledPromise<void>()\n\n routerMatch._nonReactive.minPendingPromise =\n minPendingPromise\n\n setTimeout(() => {\n minPendingPromise.resolve()\n // We've handled the minPendingPromise, so we can delete it\n routerMatch._nonReactive.minPendingPromise = undefined\n }, pendingMinMs)\n }\n }\n }\n\n const loaderResult = Solid.createMemo(async () => {\n await new Promise((r) => setTimeout(r, 0))\n return router.getMatch(currentMatch().id)?._nonReactive\n .loadPromise\n })\n\n const FallbackComponent = Solid.untrack(\n () =>\n route().options.pendingComponent ??\n router.options.defaultPendingComponent,\n )\n\n return (\n <>\n {FallbackComponent && pendingMinMs > 0 ? (\n <Dynamic component={FallbackComponent} />\n ) : null}\n {loaderResult()}\n </>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'notFound'}>\n {(_) => {\n const matchError = Solid.untrack(() => currentMatch().error)\n invariant(isNotFound(matchError), 'Expected a notFound error')\n\n // Use Show with keyed to ensure re-render when routeId changes\n return (\n <Solid.Show when={currentMatchState().routeId} keyed>\n {(_routeId) =>\n Solid.untrack(() =>\n renderRouteNotFound(router, route(), matchError),\n )\n }\n </Solid.Show>\n )\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'redirected'}>\n {(_) => {\n const matchError = Solid.untrack(() => currentMatch().error)\n invariant(isRedirect(matchError), 'Expected a redirect error')\n\n return null\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'error'}>\n {(_) => {\n const matchError = Solid.untrack(() => currentMatch().error)\n if (isServer ?? router.isServer) {\n const RouteErrorComponent =\n (route().options.errorComponent ??\n router.options.defaultErrorComponent) ||\n ErrorComponent\n\n return (\n <RouteErrorComponent\n error={matchError}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n throw matchError\n }}\n </Solid.Match>\n <Solid.Match when={currentMatch().status === 'success'}>\n {keyedOut()}\n </Solid.Match>\n </Solid.Switch>\n )\n }}\n </Solid.Show>\n )\n}\n\nexport const Outlet = () => {\n const router = useRouter()\n const nearestParentMatch = Solid.useContext(nearestMatchContext)\n const parentMatch = nearestParentMatch.match\n const routeId = nearestParentMatch.routeId\n const route = Solid.createMemo(() =>\n routeId() ? router.routesById[routeId()!] : undefined,\n )\n\n const parentGlobalNotFound = Solid.createMemo(\n () => parentMatch()?.globalNotFound ?? false,\n )\n\n const childMatchId = Solid.createMemo(() => {\n const currentRouteId = routeId()\n return currentRouteId\n ? router.stores.childMatchIdByRouteId.state[currentRouteId]\n : undefined\n })\n\n const childRouteId = Solid.createMemo(() => {\n const id = childMatchId()\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state.routeId\n })\n\n const childRoute = Solid.createMemo(() => {\n const id = childRouteId()\n return id ? (router.routesById[id] as AnyRoute) : undefined\n })\n\n const childPendingComponent = Solid.createMemo(\n () =>\n childRoute()?.options.pendingComponent ??\n router.options.defaultPendingComponent,\n )\n\n const childMatchStatus = Solid.createMemo(() => {\n const id = childMatchId()\n if (!id) return undefined\n return router.stores.activeMatchStoresById.get(id)?.state.status\n })\n\n // Only show not-found if we're not in a redirected state\n const shouldShowNotFound = () =>\n childMatchStatus() !== 'redirected' && parentGlobalNotFound()\n\n return (\n <Solid.Show\n when={!shouldShowNotFound() && childMatchId()}\n fallback={\n <Solid.Show when={shouldShowNotFound() && route()}>\n {(resolvedRoute) =>\n Solid.untrack(() =>\n renderRouteNotFound(router, resolvedRoute(), undefined),\n )\n }\n </Solid.Show>\n }\n >\n {(childMatchIdAccessor) => {\n const currentMatchId = Solid.createMemo(() => childMatchIdAccessor())\n\n return (\n <Solid.Show\n when={routeId() === rootRouteId}\n fallback={<Match matchId={currentMatchId()} />}\n >\n <Solid.Show when={childRouteId()} keyed>\n {(_routeId) => (\n <Solid.Loading\n fallback={\n childPendingComponent() ? (\n <Dynamic component={childPendingComponent()} />\n ) : null\n }\n >\n <Match matchId={currentMatchId()} />\n </Solid.Loading>\n )}\n </Solid.Show>\n </Solid.Show>\n )\n }}\n </Solid.Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,IAAMoB,sBAAsBN,qBAAAA;AAK5B,IAAaU,SAASC,UAA+B;CACnD,MAAME,SAASf,kBAAAA,WAAW;CAE1B,MAAMgB,QAAQ5B,SAAM6B,iBAAiB;EACnC,MAAMC,KAAKL,MAAMC;AACjB,MAAI,CAACI,GAAI,QAAOC,KAAAA;AAChB,SAAOJ,OAAOK,OAAOC,sBAAsBC,IAAIJ,GAAG,EAAEK;GACpD;CAEF,MAAMC,gBAAgBpC,SAAM6B,iBAAiB;EAC3C,MAAMQ,eAAeT,OAAO;AAC5B,MAAI,CAACS,aACH,QAAO;EAGT,MAAMC,UAAUD,aAAaC;EAC7B,MAAMC,gBAAiBZ,OAAOa,WAAWF,UAAuBG,aAC5DX;AAEJ,SAAO;GACLJ,SAASW,aAAaP;GACtBQ;GACAI,KAAKL,aAAaK;GAClBC,iBAAiBN,aAAaM;GACfJ;GAChB;GACD;CAQF,MAAMS,eAAe;EACnBtB,eAAeU,eAAe,EAAEV;EAChCY,eAAeF,eAAe,EAAEE;EAChCV;EACAqB,YAVsBjD,SAAM6B,iBAAiB;GAC7C,MAAMgB,iBAAiBT,eAAe,EAAEE;AACxC,UAAOO,iBACHC,QAAQnB,OAAOK,OAAOe,gBAAgBZ,MAAMU,gBAAgB,GAC5D;IACJ;EAMD;AAED,SAAA,GAAA,aAAA,iBACG7C,SAAMmD,MAAI;EAAA,IAACC,OAAI;AAAA,UAAEhB,eAAe;;EAAAb,WAC7B8B,sBAAsB;GACtB,MAAMC,QAAQtD,SAAM6B,iBACZF,OAAOa,WAAWa,mBAAmB,CAACf,SAC7C;GAED,MAAMiB,0BAA0B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iBAAiBmI,sBAAsB,CAAC;AAErE,WAAA,GAAA,aAAA,iBACGhK,SAAMmD,MAAI;IAAA,IACTC,OAAI;AAAA,YAAEd,SAAS,KAAK/B,sBAAAA;;IAAW,IAC/BsE,WAAQ;AAAA,aAAA,GAAA,aAAA,iBAAGrD,OAAK,EAAA,IAACE,UAAO;AAAA,aAAEuI,gBAAgB;QAAA,CAAA;;IAAA,IAAA1I,WAAA;AAAA,aAAA,GAAA,aAAA,iBAEzCvB,SAAMmD,MAAI;MAAA,IAACC,OAAI;AAAA,cAAEsG,cAAc;;MAAE/B,OAAK;MAAApG,WACnCyH,cAAAA,GAAAA,aAAAA,iBACChJ,SAAMwE,SAAO;OAAA,IACZK,WAAQ;AAAA,gBAAA,GAAA,aAAA,YACN,CAAA,CAAA+E,uBAAuB,CAAA,EAAA,IAAA,GAAA,aAAA,iBACpBnJ,aAAAA,SAAO,EAAA,IAAC4D,YAAS;AAAA,gBAAEuF,uBAAuB;WAAA,CAAA,GACzC;;OAAI,IAAArI,WAAA;AAAA,gBAAA,GAAA,aAAA,iBAGTC,OAAK,EAAA,IAACE,UAAO;AAAA,gBAAEuI,gBAAgB;WAAA,CAAA;;OAAA,CAAA;MAEnC,CAAA;;IAAA,CAAA;;EAIR,CAAA"}
|
package/dist/cjs/Match.d.cts
CHANGED
|
@@ -2,7 +2,5 @@ import * as Solid from 'solid-js';
|
|
|
2
2
|
export declare const Match: (props: {
|
|
3
3
|
matchId: string;
|
|
4
4
|
}) => Solid.JSX.Element;
|
|
5
|
-
export declare const MatchInner: (
|
|
6
|
-
matchId: string;
|
|
7
|
-
}) => any;
|
|
5
|
+
export declare const MatchInner: () => any;
|
|
8
6
|
export declare const Outlet: () => Solid.JSX.Element;
|
package/dist/cjs/Matches.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_CatchBoundary = require("./CatchBoundary.cjs");
|
|
3
3
|
const require_useRouter = require("./useRouter.cjs");
|
|
4
|
-
const require_useRouterState = require("./useRouterState.cjs");
|
|
5
4
|
const require_matchContext = require("./matchContext.cjs");
|
|
6
5
|
const require_Transitioner = require("./Transitioner.cjs");
|
|
7
6
|
const require_SafeFragment = require("./SafeFragment.cjs");
|
|
@@ -14,7 +13,7 @@ let tiny_warning = require("tiny-warning");
|
|
|
14
13
|
tiny_warning = require_runtime.__toESM(tiny_warning);
|
|
15
14
|
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
|
|
16
15
|
//#region src/Matches.tsx
|
|
17
|
-
var
|
|
16
|
+
var NearestMatchContext = require_matchContext.nearestMatchContext;
|
|
18
17
|
function Matches() {
|
|
19
18
|
const router = require_useRouter.useRouter();
|
|
20
19
|
const ResolvedSuspense = router.options.disableGlobalCatchBoundary || (_tanstack_router_core_isServer.isServer ?? router.isServer) || typeof document !== "undefined" && router.ssr ? require_SafeFragment.SafeFragment : solid_js.Loading;
|
|
@@ -33,10 +32,17 @@ function Matches() {
|
|
|
33
32
|
}
|
|
34
33
|
function MatchesInner() {
|
|
35
34
|
const router = require_useRouter.useRouter();
|
|
36
|
-
const matchId =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
35
|
+
const matchId = () => router.stores.firstMatchId.state;
|
|
36
|
+
const routeId = () => matchId() ? _tanstack_router_core.rootRouteId : void 0;
|
|
37
|
+
const match = () => routeId() ? router.stores.getMatchStoreByRouteId(_tanstack_router_core.rootRouteId).state : void 0;
|
|
38
|
+
const hasPendingMatch = () => routeId() ? Boolean(router.stores.pendingRouteIds.state[_tanstack_router_core.rootRouteId]) : false;
|
|
39
|
+
const resetKey = () => router.stores.loadedAt.state;
|
|
40
|
+
const nearestMatch = {
|
|
41
|
+
matchId,
|
|
42
|
+
routeId,
|
|
43
|
+
match,
|
|
44
|
+
hasPending: hasPendingMatch
|
|
45
|
+
};
|
|
40
46
|
const matchContent = () => (0, _solidjs_web.createComponent)(solid_js.Show, {
|
|
41
47
|
get when() {
|
|
42
48
|
return matchId();
|
|
@@ -47,22 +53,21 @@ function MatchesInner() {
|
|
|
47
53
|
} });
|
|
48
54
|
}
|
|
49
55
|
});
|
|
50
|
-
if (router.options.disableGlobalCatchBoundary) return (0, _solidjs_web.createComponent)(
|
|
51
|
-
value:
|
|
56
|
+
if (router.options.disableGlobalCatchBoundary) return (0, _solidjs_web.createComponent)(NearestMatchContext, {
|
|
57
|
+
value: nearestMatch,
|
|
52
58
|
get children() {
|
|
53
59
|
return matchContent();
|
|
54
60
|
}
|
|
55
61
|
});
|
|
56
|
-
return (0, _solidjs_web.createComponent)(
|
|
57
|
-
value:
|
|
62
|
+
return (0, _solidjs_web.createComponent)(NearestMatchContext, {
|
|
63
|
+
value: nearestMatch,
|
|
58
64
|
get children() {
|
|
59
65
|
return (0, _solidjs_web.createComponent)(require_CatchBoundary.CatchBoundary, {
|
|
60
66
|
getResetKey: () => resetKey(),
|
|
61
67
|
errorComponent: require_CatchBoundary.ErrorComponent,
|
|
62
68
|
get onCatch() {
|
|
63
69
|
return process.env.NODE_ENV !== "production" ? (error) => {
|
|
64
|
-
(0, tiny_warning.default)(false, `The following error wasn't caught by any route! At the very
|
|
65
|
-
t, consider setting an 'errorComponent' in your RootRoute!`);
|
|
70
|
+
(0, tiny_warning.default)(false, `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`);
|
|
66
71
|
(0, tiny_warning.default)(false, error.message || error.toString());
|
|
67
72
|
} : void 0;
|
|
68
73
|
},
|
|
@@ -75,11 +80,10 @@ function MatchesInner() {
|
|
|
75
80
|
}
|
|
76
81
|
function useMatchRoute() {
|
|
77
82
|
const router = require_useRouter.useRouter();
|
|
78
|
-
const status = require_useRouterState.useRouterState({ select: (s) => s.status });
|
|
79
83
|
return (opts) => {
|
|
80
|
-
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
|
|
81
84
|
return solid_js.createMemo(() => {
|
|
82
|
-
|
|
85
|
+
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
|
|
86
|
+
router.stores.matchRouteReactivity.state;
|
|
83
87
|
return router.matchRoute(rest, {
|
|
84
88
|
pending,
|
|
85
89
|
caseSensitive,
|
|
@@ -90,35 +94,32 @@ function useMatchRoute() {
|
|
|
90
94
|
};
|
|
91
95
|
}
|
|
92
96
|
function MatchRoute(props) {
|
|
93
|
-
const
|
|
94
|
-
return (0, _solidjs_web.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const params = useMatchRoute()(props)();
|
|
101
|
-
const child = props.children;
|
|
102
|
-
if (typeof child === "function") return child(params);
|
|
103
|
-
return params ? child : null;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
97
|
+
const params = useMatchRoute()(props);
|
|
98
|
+
return (0, _solidjs_web.memo)(solid_js.createMemo(() => {
|
|
99
|
+
const matchedParams = params();
|
|
100
|
+
const child = props.children;
|
|
101
|
+
if (typeof child === "function") return child(matchedParams);
|
|
102
|
+
return matchedParams ? child : null;
|
|
103
|
+
}));
|
|
106
104
|
}
|
|
107
105
|
function useMatches(opts) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
const router = require_useRouter.useRouter();
|
|
107
|
+
return solid_js.createMemo((prev) => {
|
|
108
|
+
const matches = router.stores.activeMatchesSnapshot.state;
|
|
109
|
+
const res = opts?.select ? opts.select(matches) : matches;
|
|
110
|
+
if (prev === void 0) return res;
|
|
111
|
+
return (0, _tanstack_router_core.replaceEqualDeep)(prev, res);
|
|
112
|
+
});
|
|
112
113
|
}
|
|
113
114
|
function useParentMatches(opts) {
|
|
114
|
-
const contextMatchId = solid_js.useContext(require_matchContext.
|
|
115
|
+
const contextMatchId = solid_js.useContext(require_matchContext.nearestMatchContext).matchId;
|
|
115
116
|
return useMatches({ select: (matches) => {
|
|
116
117
|
matches = matches.slice(0, matches.findIndex((d) => d.id === contextMatchId()));
|
|
117
118
|
return opts?.select ? opts.select(matches) : matches;
|
|
118
119
|
} });
|
|
119
120
|
}
|
|
120
121
|
function useChildMatches(opts) {
|
|
121
|
-
const contextMatchId = solid_js.useContext(require_matchContext.
|
|
122
|
+
const contextMatchId = solid_js.useContext(require_matchContext.nearestMatchContext).matchId;
|
|
122
123
|
return useMatches({ select: (matches) => {
|
|
123
124
|
matches = matches.slice(matches.findIndex((d) => d.id === contextMatchId()) + 1);
|
|
124
125
|
return opts?.select ? opts.select(matches) : matches;
|
package/dist/cjs/Matches.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.cjs","names":["Solid","warning","rootRouteId","isServer","CatchBoundary","ErrorComponent","useRouterState","useRouter","Transitioner","matchContext","SafeFragment","Match","AnyRoute","AnyRouter","DeepPartial","Expand","MakeOptionalPathParams","MakeOptionalSearchParams","MakeRouteMatchUnion","MaskOptions","MatchRouteOptions","NoInfer","RegisteredRouter","ResolveRelativePath","ResolveRoute","RouteByPath","RouterState","ToSubOptionsProps","MatchContext","Component","value","children","RouteMatchExtensions","meta","Array","JSX","IntrinsicElements","links","scripts","styles","headScripts","Matches","router","ResolvedSuspense","options","disableGlobalCatchBoundary","document","ssr","Loading","rootRoute","routesById","PendingComponent","pendingComponent","defaultPendingComponent","OptionalWrapper","InnerWrap","_$createComponent","fallback","MatchesInner","matchId","select","s","matches","id","resetKey","loadedAt","matchContent","Show","when","getResetKey","errorComponent","onCatch","process","env","NODE_ENV","error","message","toString","undefined","UseMatchRouteOptions","TFrom","TRouter","TTo","TMaskFrom","TMaskTo","useMatchRoute","status","opts","Accessor","pending","caseSensitive","fuzzy","includeSearch","rest","matchRoute","createMemo","MakeMatchRouteOptions","params","Element","MatchRoute","props","keyed","_","child","UseMatchesBaseOptions","TSelected","UseMatchesResult","useMatches","state","useParentMatches","contextMatchId","useContext","slice","findIndex","d","useChildMatches"],"sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport warning from 'tiny-warning'\nimport { rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { Match } from './Match'\nimport type {\n AnyRoute,\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n RouterState,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\nconst MatchContext = matchContext as unknown as Solid.Component<{\n value: any\n children: any\n}>\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Solid.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<Solid.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<Solid.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\nexport function Matches() {\n const router = useRouter()\n\n // When disableGlobalCatchBoundary is true, we must NOT wrap with Solid.Loading\n // because Solid.Loading transforms STATUS_ERROR into STATUS_PENDING, which\n // prevents errors from propagating to an external Errored boundary.\n const ResolvedSuspense =\n router.options.disableGlobalCatchBoundary ||\n (isServer ?? router.isServer) ||\n (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : Solid.Loading\n\n const rootRoute: () => AnyRoute = () => router.routesById[rootRouteId]\n const PendingComponent =\n rootRoute().options.pendingComponent ??\n router.options.defaultPendingComponent\n\n const OptionalWrapper = router.options.InnerWrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <ResolvedSuspense\n fallback={PendingComponent ? <PendingComponent /> : null}\n >\n <Transitioner />\n <MatchesInner />\n </ResolvedSuspense>\n </OptionalWrapper>\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return s.matches[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const matchContent = () => (\n <Solid.Show when={matchId()}>\n <Match matchId={matchId()!} />\n </Solid.Show>\n )\n\n if (router.options.disableGlobalCatchBoundary) {\n // When disableGlobalCatchBoundary is true, render without any internal\n // error boundary so errors bubble up freely to an external Errored boundary.\n return <MatchContext value={matchId}>{matchContent()}</MatchContext>\n }\n\n return (\n <MatchContext value={matchId}>\n <CatchBoundary\n getResetKey={() => resetKey()}\n errorComponent={ErrorComponent}\n onCatch={\n process.env.NODE_ENV !== 'production'\n ? (error) => {\n warning(\n false,\n `The following error wasn't caught by any route! At the very leas\n t, consider setting an 'errorComponent' in your RootRoute!`,\n )\n warning(false, error.message || error.toString())\n }\n : undefined\n }\n >\n {matchContent()}\n </CatchBoundary>\n </MatchContext>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n const status = useRouterState({\n select: (s) => s.status,\n })\n\n return <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): Solid.Accessor<\n false | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>\n > => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n const matchRoute = Solid.createMemo(() => {\n status()\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n\n return matchRoute\n }\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => Solid.JSX.Element)\n | Solid.JSX.Element\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const status = useRouterState({\n select: (s) => s.status,\n })\n\n return (\n <Solid.Show when={status()} keyed>\n {(_) => {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)() as boolean\n const child = props.children\n if (typeof child === 'function') {\n return (child as any)(params)\n }\n\n return params ? child : null\n }}\n </Solid.Show>\n )\n}\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n return useRouterState({\n select: (state: RouterState<TRouter['routeTree']>) => {\n const matches = state.matches\n return opts?.select\n ? opts.select(matches as Array<MakeRouteMatchUnion<TRouter>>)\n : matches\n },\n } as any) as Solid.Accessor<UseMatchesResult<TRouter, TSelected>>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId()),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId()) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,IAAM4B,eAAenB,qBAAAA;AAerB,SAAgBgC,UAAU;CACxB,MAAMC,SAASnC,kBAAAA,WAAW;CAK1B,MAAMoC,mBACJD,OAAOE,QAAQC,+BACd1C,+BAAAA,YAAYuC,OAAOvC,aACnB,OAAO2C,aAAa,eAAeJ,OAAOK,MACvCrC,qBAAAA,eACAV,SAAMgD;CAEZ,MAAMC,kBAAkCP,OAAOQ,WAAWhD,sBAAAA;CAC1D,MAAMiD,mBACJF,WAAW,CAACL,QAAQQ,oBACpBV,OAAOE,QAAQS;AAIjB,SAAA,GAAA,aAAA,iBAFwBX,OAAOE,QAAQW,aAAa7C,q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,QAAQkD,MAChB,GACAlD,QAAQmD,WAAWC,MAAMA,EAAEnD,OAAO+C,gBAAgB,CACpD,CAAC;AACD,SAAOvB,MAAM3B,SAAS2B,KAAK3B,OAAOE,QAAQ,GAAGA;IAEhD,CAAQ;;AAGX,SAAgBqD,gBAId5B,MACsD;CACtD,MAAMuB,iBAAiB9G,SAAM+G,WAAWtG,qBAAAA,aAAa;AAErD,QAAOkG,WAAW,EAChB/C,SAASE,YAAiD;AACxDA,YAAUA,QAAQkD,MAChBlD,QAAQmD,WAAWC,MAAMA,EAAEnD,OAAO+C,gBAAgB,CAAC,GAAG,EACvD;AACD,SAAOvB,MAAM3B,SAAS2B,KAAK3B,OAAOE,QAAQ,GAAGA;IAEhD,CAAQ"}
|
|
1
|
+
{"version":3,"file":"Matches.cjs","names":["Solid","warning","replaceEqualDeep","rootRouteId","isServer","CatchBoundary","ErrorComponent","useRouter","Transitioner","nearestMatchContext","SafeFragment","Match","AnyRoute","AnyRouter","DeepPartial","Expand","MakeOptionalPathParams","MakeOptionalSearchParams","MakeRouteMatchUnion","MaskOptions","MatchRouteOptions","NoInfer","RegisteredRouter","ResolveRelativePath","ResolveRoute","RouteByPath","ToSubOptionsProps","NearestMatchContext","Component","value","children","RouteMatchExtensions","meta","Array","JSX","IntrinsicElements","links","scripts","styles","headScripts","Matches","router","ResolvedSuspense","options","disableGlobalCatchBoundary","document","ssr","Loading","rootRoute","routesById","PendingComponent","pendingComponent","defaultPendingComponent","OptionalWrapper","InnerWrap","_$createComponent","fallback","MatchesInner","matchId","stores","firstMatchId","state","routeId","undefined","match","getMatchStoreByRouteId","hasPendingMatch","Boolean","pendingRouteIds","resetKey","loadedAt","nearestMatch","hasPending","matchContent","Show","when","getResetKey","errorComponent","onCatch","process","env","NODE_ENV","error","message","toString","UseMatchRouteOptions","TFrom","TRouter","TTo","TMaskFrom","TMaskTo","useMatchRoute","opts","Accessor","createMemo","pending","caseSensitive","fuzzy","includeSearch","rest","matchRouteReactivity","matchRoute","MakeMatchRouteOptions","params","Element","MatchRoute","props","renderedChild","matchedParams","child","_$memo","UseMatchesBaseOptions","select","matches","TSelected","UseMatchesResult","useMatches","prev","activeMatchesSnapshot","res","useParentMatches","contextMatchId","useContext","slice","findIndex","d","id","useChildMatches"],"sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport warning from 'tiny-warning'\nimport { replaceEqualDeep, rootRouteId } from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { nearestMatchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { Match } from './Match'\nimport type {\n AnyRoute,\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\nconst NearestMatchContext = nearestMatchContext as unknown as Solid.Component<{\n value: any\n children: any\n}>\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Solid.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<Solid.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<Solid.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\nexport function Matches() {\n const router = useRouter()\n\n // When disableGlobalCatchBoundary is true, we must NOT wrap with Solid.Loading\n // because Solid.Loading transforms STATUS_ERROR into STATUS_PENDING, which\n // prevents errors from propagating to an external Errored boundary.\n const ResolvedSuspense =\n router.options.disableGlobalCatchBoundary ||\n (isServer ?? router.isServer) ||\n (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : Solid.Loading\n\n const rootRoute: () => AnyRoute = () => router.routesById[rootRouteId]\n const PendingComponent =\n rootRoute().options.pendingComponent ??\n router.options.defaultPendingComponent\n\n const OptionalWrapper = router.options.InnerWrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <ResolvedSuspense\n fallback={PendingComponent ? <PendingComponent /> : null}\n >\n <Transitioner />\n <MatchesInner />\n </ResolvedSuspense>\n </OptionalWrapper>\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = () => router.stores.firstMatchId.state\n const routeId = () => (matchId() ? rootRouteId : undefined)\n const match = () =>\n routeId()\n ? router.stores.getMatchStoreByRouteId(rootRouteId).state\n : undefined\n const hasPendingMatch = () =>\n routeId()\n ? Boolean(router.stores.pendingRouteIds.state[rootRouteId])\n : false\n const resetKey = () => router.stores.loadedAt.state\n const nearestMatch = {\n matchId,\n routeId,\n match,\n hasPending: hasPendingMatch,\n }\n\n const matchContent = () => (\n <Solid.Show when={matchId()}>\n <Match matchId={matchId()!} />\n </Solid.Show>\n )\n\n if (router.options.disableGlobalCatchBoundary) {\n // When disableGlobalCatchBoundary is true, render without any internal\n // error boundary so errors bubble up freely to an external Errored boundary.\n return (\n <NearestMatchContext value={nearestMatch}>\n {matchContent()}\n </NearestMatchContext>\n )\n }\n\n return (\n <NearestMatchContext value={nearestMatch}>\n <CatchBoundary\n getResetKey={() => resetKey()}\n errorComponent={ErrorComponent}\n onCatch={\n process.env.NODE_ENV !== 'production'\n ? (error) => {\n warning(\n false,\n `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n warning(false, error.message || error.toString())\n }\n : undefined\n }\n >\n {matchContent()}\n </CatchBoundary>\n </NearestMatchContext>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n return <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): Solid.Accessor<\n false | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>\n > => {\n return Solid.createMemo(() => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n router.stores.matchRouteReactivity.state\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n }\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => Solid.JSX.Element)\n | Solid.JSX.Element\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n const renderedChild = Solid.createMemo(() => {\n const matchedParams = params()\n const child = props.children\n\n if (typeof child === 'function') {\n return (child as any)(matchedParams)\n }\n\n return matchedParams ? child : null\n })\n\n return <>{renderedChild()}</>\n}\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const router = useRouter<TRouter>()\n return Solid.createMemo((prev: TSelected | undefined) => {\n const matches = router.stores.activeMatchesSnapshot.state as Array<\n MakeRouteMatchUnion<TRouter>\n >\n const res = opts?.select ? opts.select(matches) : matches\n if (prev === undefined) return res\n return replaceEqualDeep(prev, res) as any\n }) as Solid.Accessor<UseMatchesResult<TRouter, TSelected>>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId()),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(nearestMatchContext).matchId\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId()) + 1,\n )\n return opts?.select ? opts.select(matches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2
2
|
const require_routerContext = require("./routerContext.cjs");
|
|
3
3
|
const require_SafeFragment = require("./SafeFragment.cjs");
|
|
4
4
|
const require_Matches = require("./Matches.cjs");
|
|
5
5
|
let _solidjs_web = require("@solidjs/web");
|
|
6
|
+
let solid_js = require("solid-js");
|
|
7
|
+
solid_js = require_runtime.__toESM(solid_js);
|
|
6
8
|
//#region src/RouterProvider.tsx
|
|
7
9
|
var RouterContext = require_routerContext.routerContext;
|
|
8
10
|
function RouterContextProvider({ router, children, ...rest }) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
if (Object.keys(rest).length > 0) solid_js.runWithOwner(null, () => {
|
|
12
|
+
router.update({
|
|
13
|
+
...router.options,
|
|
14
|
+
...rest,
|
|
15
|
+
context: {
|
|
16
|
+
...router.options.context,
|
|
17
|
+
...rest.context
|
|
18
|
+
}
|
|
19
|
+
});
|
|
16
20
|
});
|
|
17
21
|
return (0, _solidjs_web.createComponent)(router.options.Wrap || require_SafeFragment.SafeFragment, { get children() {
|
|
18
22
|
return (0, _solidjs_web.createComponent)(RouterContext, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterProvider.cjs","names":["routerContext","SafeFragment","Matches","AnyRouter","RegisteredRouter","RouterOptions","
|
|
1
|
+
{"version":3,"file":"RouterProvider.cjs","names":["Solid","routerContext","SafeFragment","Matches","AnyRouter","RegisteredRouter","RouterOptions","RouterContext","Component","value","children","RouterContextProvider","Record","router","rest","RouterProps","TRouter","TDehydrated","JSX","Element","Object","keys","length","runWithOwner","update","options","context","OptionalWrapper","Wrap","_$createComponent","RouterProvider","_$mergeProps","Omit","NonNullable","Partial"],"sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { routerContext } from './routerContext'\nimport { SafeFragment } from './SafeFragment'\nimport { Matches } from './Matches'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\nconst RouterContext = routerContext as unknown as Solid.Component<{\n value: any\n children: any\n}>\n\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: () => Solid.JSX.Element\n}) {\n if (Object.keys(rest).length > 0) {\n Solid.runWithOwner(null, () => {\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n } as any)\n })\n }\n\n const OptionalWrapper = router.options.Wrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <RouterContext value={router as AnyRouter}>{children()}</RouterContext>\n </OptionalWrapper>\n )\n}\n\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n {() => <Matches />}\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n false,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n false,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"mappings":";;;;;;;;AAUA,IAAMO,gBAAgBN,sBAAAA;AAKtB,SAAgBU,sBAGd,EACAE,QACAH,UACA,GAAGI,QAGF;AACD,KAAIM,OAAOC,KAAKP,KAAK,CAACQ,SAAS,EAC7BtB,UAAMuB,aAAa,YAAY;AAC7BV,SAAOW,OAAO;GACZ,GAAGX,OAAOY;GACV,GAAGX;GACHY,SAAS;IACP,GAAGb,OAAOY,QAAQC;IAClB,GAAGZ,KAAKY;IACV;GACD,CAAQ;GACT;AAKJ,SAAA,GAAA,aAAA,iBAFwBb,OAAOY,QAAQG,QAAQ1B,qBAAAA,cAG7B,EAAA,IAAAQ,WAAA;AAAA,UAAA,GAAA,aAAA,iBACbH,eAAa;GAACE,OAAOI;GAAmB,IAAAH,WAAA;AAAA,WAAGA,UAAU;;GAAA,CAAA;IAAA,CAAA;;AAK5D,SAAgBoB,eAGd,EAAEjB,QAAQ,GAAGC,QAA2C;AACxD,SAAA,GAAA,aAAA,iBACGH,wBAAAA,GAAAA,aAAAA,YAAqB,EAASE,QAAM,EAAMC,MAAI,EAAAJ,iBAAAA,GAAAA,aAAAA,iBACrCP,gBAAAA,SAAO,EAAA,CAAA,EAAG,CAAA,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyRouter, RegisteredRouter, RouterOptions } from '@tanstack/router-core';
|
|
2
|
-
import
|
|
2
|
+
import * as Solid from 'solid-js';
|
|
3
3
|
export declare function RouterContextProvider<TRouter extends AnyRouter = RegisteredRouter, TDehydrated extends Record<string, any> = Record<string, any>>({ router, children, ...rest }: RouterProps<TRouter, TDehydrated> & {
|
|
4
4
|
children: () => Solid.JSX.Element;
|
|
5
5
|
}): Solid.JSX.Element;
|
package/dist/cjs/Scripts.cjs
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_useRouter = require("./useRouter.cjs");
|
|
3
|
-
const require_useRouterState = require("./useRouterState.cjs");
|
|
4
3
|
const require_Asset = require("./Asset.cjs");
|
|
5
4
|
let _solidjs_web = require("@solidjs/web");
|
|
5
|
+
let solid_js = require("solid-js");
|
|
6
|
+
solid_js = require_runtime.__toESM(solid_js);
|
|
6
7
|
//#region src/Scripts.tsx
|
|
7
8
|
var Scripts = () => {
|
|
8
9
|
const router = require_useRouter.useRouter();
|
|
9
10
|
const nonce = router.options.ssr?.nonce;
|
|
10
|
-
const
|
|
11
|
+
const activeMatches = solid_js.createMemo(() => router.stores.activeMatchesSnapshot.state);
|
|
12
|
+
const assetScripts = solid_js.createMemo(() => {
|
|
11
13
|
const assetScripts = [];
|
|
12
14
|
const manifest = router.ssr?.manifest;
|
|
13
15
|
if (!manifest) return [];
|
|
14
|
-
|
|
16
|
+
activeMatches().map((match) => router.looseRoutesById[match.routeId]).forEach((route) => manifest.routes[route.id]?.assets?.filter((d) => d.tag === "script").forEach((asset) => {
|
|
15
17
|
assetScripts.push({
|
|
16
18
|
tag: "script",
|
|
17
19
|
attrs: {
|
|
@@ -22,21 +24,30 @@ var Scripts = () => {
|
|
|
22
24
|
});
|
|
23
25
|
}));
|
|
24
26
|
return assetScripts;
|
|
25
|
-
}
|
|
26
|
-
const scripts =
|
|
27
|
+
});
|
|
28
|
+
const scripts = solid_js.createMemo(() => activeMatches().map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
27
29
|
tag: "script",
|
|
28
30
|
attrs: {
|
|
29
31
|
...script,
|
|
30
32
|
nonce
|
|
31
33
|
},
|
|
32
34
|
children
|
|
33
|
-
}))
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
})));
|
|
36
|
+
const serverBufferedScript = router.serverSsr ? router.serverSsr.takeBufferedScripts() : void 0;
|
|
37
|
+
const allScripts = solid_js.createMemo(() => {
|
|
38
|
+
const result = [...scripts(), ...assetScripts()];
|
|
39
|
+
if (serverBufferedScript) result.unshift(serverBufferedScript);
|
|
40
|
+
return result;
|
|
41
|
+
});
|
|
38
42
|
return (0, _solidjs_web.createComponent)(_solidjs_web.NoHydration, { get children() {
|
|
39
|
-
return
|
|
43
|
+
return (0, _solidjs_web.createComponent)(solid_js.For, {
|
|
44
|
+
get each() {
|
|
45
|
+
return allScripts();
|
|
46
|
+
},
|
|
47
|
+
children: (asset) => {
|
|
48
|
+
return (0, _solidjs_web.createComponent)(require_Asset.Asset, solid_js.untrack(asset));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
40
51
|
} });
|
|
41
52
|
};
|
|
42
53
|
//#endregion
|
package/dist/cjs/Scripts.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scripts.cjs","names":["NoHydration","
|
|
1
|
+
{"version":3,"file":"Scripts.cjs","names":["NoHydration","Solid","Asset","useRouter","RouterManagedTag","Scripts","router","nonce","options","ssr","activeMatches","createMemo","stores","activeMatchesSnapshot","state","assetScripts","Array","manifest","map","match","looseRoutesById","routeId","forEach","route","routes","id","assets","filter","d","tag","asset","push","attrs","children","scripts","flat","Boolean","script","serverBufferedScript","serverSsr","takeBufferedScripts","undefined","allScripts","result","unshift","_$createComponent","For","each","a","untrack"],"sources":["../../src/Scripts.tsx"],"sourcesContent":["import { NoHydration } from '@solidjs/web'\nimport * as Solid from 'solid-js'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\nexport const Scripts = () => {\n const router = useRouter()\n const nonce = router.options.ssr?.nonce\n const activeMatches = Solid.createMemo(\n () => router.stores.activeMatchesSnapshot.state,\n )\n const assetScripts = Solid.createMemo(() => {\n const assetScripts: Array<RouterManagedTag> = []\n const manifest = router.ssr?.manifest\n\n if (!manifest) {\n return []\n }\n\n activeMatches()\n .map((match) => router.looseRoutesById[match.routeId]!)\n .forEach((route) =>\n manifest.routes[route.id]?.assets\n ?.filter((d) => d.tag === 'script')\n .forEach((asset) => {\n assetScripts.push({\n tag: 'script',\n attrs: { ...asset.attrs, nonce },\n children: asset.children,\n } as any)\n }),\n )\n\n return assetScripts\n })\n\n const scripts = Solid.createMemo(() =>\n (\n activeMatches()\n .map((match) => match.scripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script',\n attrs: {\n ...script,\n nonce,\n },\n children,\n })),\n )\n\n const serverBufferedScript: RouterManagedTag | undefined = router.serverSsr\n ? router.serverSsr.takeBufferedScripts()\n : undefined\n\n const allScripts = Solid.createMemo(() => {\n const result = [...scripts(), ...assetScripts()] as Array<RouterManagedTag>\n\n if (serverBufferedScript) {\n result.unshift(serverBufferedScript)\n }\n\n return result\n })\n\n return (\n <NoHydration>\n <Solid.For each={allScripts()}>\n {(asset) => {\n const a = Solid.untrack(asset)\n return <Asset {...a} />\n }}\n </Solid.For>\n </NoHydration>\n )\n}\n"],"mappings":";;;;;;;AAMA,IAAaK,gBAAgB;CAC3B,MAAMC,SAASH,kBAAAA,WAAW;CAC1B,MAAMI,QAAQD,OAAOE,QAAQC,KAAKF;CAClC,MAAMG,gBAAgBT,SAAMU,iBACpBL,OAAOM,OAAOC,sBAAsBC,MAC3C;CACD,MAAMC,eAAed,SAAMU,iBAAiB;EAC1C,MAAMI,eAAwC,EAAE;EAChD,MAAME,WAAWX,OAAOG,KAAKQ;AAE7B,MAAI,CAACA,SACH,QAAO,EAAE;AAGXP,iBAAe,CACZQ,KAAKC,UAAUb,OAAOc,gBAAgBD,MAAME,SAAU,CACtDC,SAASC,UACRN,SAASO,OAAOD,MAAME,KAAKC,QACvBC,QAAQC,MAAMA,EAAEC,QAAQ,SAAS,CAClCP,SAASQ,UAAU;AAClBf,gBAAagB,KAAK;IAChBF,KAAK;IACLG,OAAO;KAAE,GAAGF,MAAME;KAAOzB;KAAO;IAChC0B,UAAUH,MAAMG;IACjB,CAAQ;IAEf,CAAC;AAEH,SAAOlB;GACP;CAEF,MAAMmB,UAAUjC,SAAMU,iBAElBD,eAAe,CACZQ,KAAKC,UAAUA,MAAMe,QAAS,CAC9BC,KAAK,EAAE,CACPR,OAAOS,QAAQ,CAClBlB,KAAK,EAAEe,UAAU,GAAGI,cAAc;EAClCR,KAAK;EACLG,OAAO;GACL,GAAGK;GACH9B;GACD;EACD0B;EACD,EACH,CAAC;CAED,MAAMK,uBAAqDhC,OAAOiC,YAC9DjC,OAAOiC,UAAUC,qBAAqB,GACtCC,KAAAA;CAEJ,MAAMC,aAAazC,SAAMU,iBAAiB;EACxC,MAAMgC,SAAS,CAAC,GAAGT,SAAS,EAAE,GAAGnB,cAAc,CAAC;AAEhD,MAAIuB,qBACFK,QAAOC,QAAQN,qBAAqB;AAGtC,SAAOK;GACP;AAEF,SAAA,GAAA,aAAA,iBACG3C,aAAAA,aAAW,EAAA,IAAAiC,WAAA;AAAA,UAAA,GAAA,aAAA,iBACThC,SAAM6C,KAAG;GAAA,IAACC,OAAI;AAAA,WAAEL,YAAY;;GAAAT,WACzBH,UAAU;AAEV,YAAA,GAAA,aAAA,iBAAQ5B,cAAAA,OADED,SAAMgD,QAAQnB,MAAM,CACX;;GACpB,CAAA;IAAA,CAAA"}
|
package/dist/cjs/Scripts.d.cts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Solid from 'solid-js';
|
|
2
|
+
export declare const Scripts: () => Solid.JSX.Element;
|