@tanstack/solid-router
Version:
Modern and scalable routing for Solid applications
1 lines • 6.84 kB
Source Map (JSON)
{"version":3,"file":"RouterProvider.cjs","names":["<OptionalWrapper>\n <RouterContext value={router as AnyRouter}>\n <Solid.Show when={ready()}>\n {(_) => {\n // Native SSR transfer for the bare pairing (no-op under Start —\n // see registryTransfer): serialize settled match state into the\n // hydration registry while the render's serialization context is\n // live. Runs after the load gate so matches are committed. The\n // client half — the hydration-claiming boot — runs at router\n // creation, outside the render.\n if (isServer) {\n serializeMatchTransfer(router)\n }\n return children()\n }}\n </Solid.Show>\n </RouterContext>\n </OptionalWrapper>","<RouterContext value={router as AnyRouter}>\n <Solid.Show when={ready()}>\n {(_) => {\n // Native SSR transfer for the bare pairing (no-op under Start —\n // see registryTransfer): serialize settled match state into the\n // hydration registry while the render's serialization context is\n // live. Runs after the load gate so matches are committed. The\n // client half — the hydration-claiming boot — runs at router\n // creation, outside the render.\n if (isServer) {\n serializeMatchTransfer(router)\n }\n return children()\n }}\n </Solid.Show>\n </RouterContext>","value={router as AnyRouter}","<Solid.Show when={ready()}>\n {(_) => {\n // Native SSR transfer for the bare pairing (no-op under Start —\n // see registryTransfer): serialize settled match state into the\n // hydration registry while the render's serialization context is\n // live. Runs after the load gate so matches are committed. The\n // client half — the hydration-claiming boot — runs at router\n // creation, outside the render.\n if (isServer) {\n serializeMatchTransfer(router)\n }\n return children()\n }}\n </Solid.Show>","Solid.Show","<RouterContextProvider router={router} {...rest}>\n {() => <Matches />}\n </RouterContextProvider>","<Matches />"],"sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { routerContext } from './routerContext'\nimport { SafeFragment } from './SafeFragment'\nimport { Matches } from './Matches'\nimport { serializeMatchTransfer } from './registryTransfer'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\nimport type { JSX } from '@solidjs/web'\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: () => 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 // Server-side, the provider owns the load dispatch: if the app (or a host\n // framework like Start) hasn't already loaded the router, kick `load()`\n // and park the render on it. Solid's SSR awaits parked reads natively, so\n // blocking-loader semantics are preserved without a top-level\n // `await router.load()` in the server entry. The memo exists on both\n // environments so the component tree (and hydration keys) stay identical;\n // on the client it resolves immediately and the boot is handled by the\n // registry priming in the Router constructor plus Transitioner's\n // settled-time load.\n const ready = Solid.createMemo(() =>\n isServer && !router._serverResult ? router.load().then(() => true) : true,\n )\n\n const OptionalWrapper = router.options.Wrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <RouterContext value={router as AnyRouter}>\n <Solid.Show when={ready()}>\n {(_) => {\n // Native SSR transfer for the bare pairing (no-op under Start —\n // see registryTransfer): serialize settled match state into the\n // hydration registry while the render's serialization context is\n // live. Runs after the load gate so matches are committed. The\n // client half — the hydration-claiming boot — runs at router\n // creation, outside the render.\n if (isServer) {\n serializeMatchTransfer(router)\n }\n return children()\n }}\n </Solid.Show>\n </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":";;;;;;;;;;AAaA,IAAM,gBAAgB,sBAAA;AAKtB,SAAgB,sBAGd,EACA,QACA,UACA,GAAG,QAGF;CACD,IAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAC7B,SAAM,aAAa,YAAY;EAC7B,OAAO,OAAO;GACZ,GAAG,OAAO;GACV,GAAG;GACH,SAAS;IACP,GAAG,OAAO,QAAQ;IAClB,GAAG,KAAK;GACV;EACF,CAAQ;CACV,CAAC;CAYH,MAAM,QAAQ,SAAM,iBAClB,+BAAA,YAAY,CAAC,OAAO,gBAAgB,OAAO,KAAK,EAAE,WAAW,IAAI,IAAI,IACvE;CAIA,QAAA,GAAA,aAAA,iBAFwB,OAAO,QAAQ,QAAQ,qBAAA,cAG7CA,EAAAA,IAAAA,WAAAA;2CACEC,eAAAA;GAAeC,OAAO;GAAtB,IAAA,WAAA;6CACEC,SAACC,MAAD;KAAY,IAAA,OAAA;aAAM,MAAM;KAAC;KAAzBD,WACI,MAAM;MAON,IAAI,+BAAA,UACF,yBAAA,uBAAuB,MAAM;MAE/B,OAAO,SAAS;KAClB;IACU,CAAA;GACC;;CACA,EAAA,CAAA;AAErB;AAEA,SAAgB,eAGd,EAAE,QAAQ,GAAG,QAA2C;CACxD,QAAA,GAAA,aAAA,iBACEE,wBAAAA,GAAAA,aAAAA,YAAAA,EAA+B,OAER,GAFoB,MAA3C,EAAA,iBAAA,GAAA,aAAA,iBACSC,gBAAAA,SAAAA,CAAU,CAAA,EACI,CAAA,CAAA;AAE3B"}