@tanstack/solid-router 1.167.5 → 1.168.1
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/Match.cjs +244 -223
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Match.d.cts +1 -3
- package/dist/cjs/Matches.cjs +32 -31
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Scripts.cjs +10 -8
- package/dist/cjs/Scripts.cjs.map +1 -1
- package/dist/cjs/Scripts.d.cts +2 -1
- package/dist/cjs/Transitioner.cjs +26 -26
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/cjs/headContentUtils.cjs +15 -15
- package/dist/cjs/headContentUtils.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.dev.cjs +1 -1
- package/dist/cjs/link.cjs +119 -84
- 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 +67 -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 +2 -2
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/ssr/renderRouterToString.d.cts +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 +17 -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 -19
- 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 +0 -14
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +0 -4
- package/dist/esm/Match.d.ts +1 -3
- package/dist/esm/Match.js +245 -224
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +34 -33
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/Scripts.d.ts +2 -1
- package/dist/esm/Scripts.js +8 -7
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/Transitioner.js +26 -26
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/headContentUtils.js +15 -15
- 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 +120 -85
- 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 +65 -0
- package/dist/esm/routerStores.js.map +1 -0
- 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.d.ts +1 -1
- package/dist/esm/ssr/renderRouterToString.js +2 -2
- package/dist/esm/ssr/renderRouterToString.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 +18 -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 +10 -18
- 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 -4
- package/dist/esm/utils.js +1 -14
- package/dist/esm/utils.js.map +1 -1
- package/dist/source/Match.d.ts +1 -3
- package/dist/source/Match.jsx +246 -237
- package/dist/source/Match.jsx.map +1 -1
- package/dist/source/Matches.jsx +42 -44
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/Scripts.d.ts +2 -1
- package/dist/source/Scripts.jsx +31 -36
- package/dist/source/Scripts.jsx.map +1 -1
- package/dist/source/Transitioner.jsx +26 -31
- package/dist/source/Transitioner.jsx.map +1 -1
- package/dist/source/headContentUtils.jsx +64 -72
- package/dist/source/headContentUtils.jsx.map +1 -1
- package/dist/source/link.jsx +136 -107
- 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 +71 -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.d.ts +1 -1
- package/dist/source/ssr/renderRouterToString.jsx +2 -2
- package/dist/source/ssr/renderRouterToString.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 +30 -27
- 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 +12 -33
- 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 -4
- package/dist/source/utils.js +0 -13
- package/dist/source/utils.js.map +1 -1
- package/package.json +2 -3
- package/skills/solid-router/SKILL.md +2 -0
- package/src/Match.tsx +351 -304
- package/src/Matches.tsx +49 -52
- package/src/Scripts.tsx +40 -41
- package/src/Transitioner.tsx +67 -66
- package/src/headContentUtils.tsx +89 -91
- package/src/link.tsx +179 -141
- package/src/matchContext.tsx +16 -7
- package/src/not-found.tsx +6 -6
- package/src/router.ts +2 -1
- package/src/routerStores.ts +107 -0
- package/src/ssr/RouterClient.tsx +1 -1
- package/src/ssr/renderRouterToStream.tsx +1 -1
- package/src/ssr/renderRouterToString.tsx +2 -2
- package/src/useCanGoBack.ts +6 -2
- package/src/useLoaderDeps.tsx +2 -3
- package/src/useLocation.tsx +18 -5
- package/src/useMatch.tsx +36 -43
- package/src/useParams.tsx +2 -3
- package/src/useRouterState.tsx +17 -41
- package/src/useSearch.tsx +2 -1
- package/src/utils.ts +0 -20
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let solid_js = require("solid-js");
|
|
3
3
|
solid_js = require_runtime.__toESM(solid_js);
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
var nearestMatchContext = solid_js.createContext({
|
|
5
|
+
matchId: () => void 0,
|
|
6
|
+
routeId: () => void 0,
|
|
7
|
+
match: () => void 0,
|
|
8
|
+
hasPending: () => false
|
|
9
|
+
});
|
|
7
10
|
//#endregion
|
|
8
|
-
exports.
|
|
9
|
-
exports.matchContext = matchContext;
|
|
11
|
+
exports.nearestMatchContext = nearestMatchContext;
|
|
10
12
|
|
|
11
13
|
//# sourceMappingURL=matchContext.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchContext.cjs","names":["Solid","
|
|
1
|
+
{"version":3,"file":"matchContext.cjs","names":["Solid","AnyRouteMatch","NearestMatchContextValue","matchId","Accessor","routeId","match","hasPending","defaultNearestMatchContext","undefined","nearestMatchContext","createContext"],"sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport type { AnyRouteMatch } from '@tanstack/router-core'\n\nexport type NearestMatchContextValue = {\n matchId: Solid.Accessor<string | undefined>\n routeId: Solid.Accessor<string | undefined>\n match: Solid.Accessor<AnyRouteMatch | undefined>\n hasPending: Solid.Accessor<boolean>\n}\n\nconst defaultNearestMatchContext: NearestMatchContextValue = {\n matchId: () => undefined,\n routeId: () => undefined,\n match: () => undefined,\n hasPending: () => false,\n}\n\nexport const nearestMatchContext =\n Solid.createContext<NearestMatchContextValue>(defaultNearestMatchContext)\n"],"mappings":";;;AAiBA,IAAaU,sBACXV,SAAMW,cARqD;CAC3DR,eAAeM,KAAAA;CACfJ,eAAeI,KAAAA;CACfH,aAAaG,KAAAA;CACbF,kBAAkB;CACnB,CAG0E"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { AnyRouteMatch } from '@tanstack/router-core';
|
|
1
2
|
import * as Solid from 'solid-js';
|
|
2
|
-
export
|
|
3
|
-
|
|
3
|
+
export type NearestMatchContextValue = {
|
|
4
|
+
matchId: Solid.Accessor<string | undefined>;
|
|
5
|
+
routeId: Solid.Accessor<string | undefined>;
|
|
6
|
+
match: Solid.Accessor<AnyRouteMatch | undefined>;
|
|
7
|
+
hasPending: Solid.Accessor<boolean>;
|
|
8
|
+
};
|
|
9
|
+
export declare const nearestMatchContext: Solid.Context<NearestMatchContextValue>;
|
package/dist/cjs/not-found.cjs
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_CatchBoundary = require("./CatchBoundary.cjs");
|
|
3
|
-
const
|
|
3
|
+
const require_useRouter = require("./useRouter.cjs");
|
|
4
4
|
let _tanstack_router_core = require("@tanstack/router-core");
|
|
5
5
|
let solid_js_web = require("solid-js/web");
|
|
6
|
+
let solid_js = require("solid-js");
|
|
7
|
+
solid_js = require_runtime.__toESM(solid_js);
|
|
6
8
|
//#region src/not-found.tsx
|
|
7
9
|
var _tmpl$ = /* @__PURE__ */ (0, solid_js_web.template)(`<p>Not Found`);
|
|
8
10
|
function CatchNotFound(props) {
|
|
9
|
-
const
|
|
11
|
+
const router = require_useRouter.useRouter();
|
|
12
|
+
const pathname = solid_js.createMemo(() => router.stores.location.state.pathname);
|
|
13
|
+
const status = solid_js.createMemo(() => router.stores.status.state);
|
|
10
14
|
return (0, solid_js_web.createComponent)(require_CatchBoundary.CatchBoundary, {
|
|
11
|
-
getResetKey: () =>
|
|
15
|
+
getResetKey: () => `not-found-${pathname()}-${status()}`,
|
|
12
16
|
onCatch: (error) => {
|
|
13
17
|
if ((0, _tanstack_router_core.isNotFound)(error)) props.onCatch?.(error);
|
|
14
18
|
else throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.cjs","names":["isNotFound","
|
|
1
|
+
{"version":3,"file":"not-found.cjs","names":["isNotFound","Solid","CatchBoundary","useRouter","NotFoundError","CatchNotFound","props","fallback","error","JSX","Element","onCatch","Error","children","router","pathname","createMemo","stores","location","state","status","_$createComponent","getResetKey","errorComponent","DefaultGlobalNotFound","_tmpl$"],"sources":["../../src/not-found.tsx"],"sourcesContent":["import { isNotFound } from '@tanstack/router-core'\nimport * as Solid from 'solid-js'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport type { NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Solid.JSX.Element\n onCatch?: (error: Error) => void\n children: Solid.JSX.Element\n}) {\n const router = useRouter()\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const pathname = Solid.createMemo(() => router.stores.location.state.pathname)\n const status = Solid.createMemo(() => router.stores.status.state)\n\n return (\n <CatchBoundary\n getResetKey={() => `not-found-${pathname()}-${status()}`}\n onCatch={(error) => {\n if (isNotFound(error)) {\n props.onCatch?.(error)\n } else {\n throw error\n }\n }}\n errorComponent={({ error }) => {\n if (isNotFound(error)) {\n return props.fallback?.(error)\n } else {\n throw error\n }\n }}\n >\n {props.children}\n </CatchBoundary>\n )\n}\n\nexport function DefaultGlobalNotFound() {\n return <p>Not Found</p>\n}\n"],"mappings":";;;;;;;;;AAMA,SAAgBK,cAAcC,OAI3B;CACD,MAAMQ,SAASX,kBAAAA,WAAW;CAE1B,MAAMY,WAAWd,SAAMe,iBAAiBF,OAAOG,OAAOC,SAASC,MAAMJ,SAAS;CAC9E,MAAMK,SAASnB,SAAMe,iBAAiBF,OAAOG,OAAOG,OAAOD,MAAM;AAEjE,SAAA,GAAA,aAAA,iBACGjB,sBAAAA,eAAa;EACZoB,mBAAmB,aAAaP,UAAU,CAAA,GAAIK,QAAQ;EACtDT,UAAUH,UAAU;AAClB,QAAA,GAAA,sBAAA,YAAeA,MAAM,CACnBF,OAAMK,UAAUH,MAAM;OAEtB,OAAMA;;EAGVe,iBAAiB,EAAEf,YAAY;AAC7B,QAAA,GAAA,sBAAA,YAAeA,MAAM,CACnB,QAAOF,MAAMC,WAAWC,MAAM;OAE9B,OAAMA;;EAET,IAAAK,WAAA;AAAA,UAEAP,MAAMO;;EAAQ,CAAA;;AAKrB,SAAgBW,wBAAwB;AACtC,QAAAC,QAAA"}
|
package/dist/cjs/not-found.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NotFoundError } from '@tanstack/router-core';
|
|
2
|
-
import
|
|
2
|
+
import * as Solid from 'solid-js';
|
|
3
3
|
export declare function CatchNotFound(props: {
|
|
4
4
|
fallback?: (error: NotFoundError) => Solid.JSX.Element;
|
|
5
5
|
onCatch?: (error: Error) => void;
|
package/dist/cjs/router.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_fileRoute = require("./fileRoute.cjs");
|
|
3
|
+
const require_routerStores = require("./routerStores.cjs");
|
|
3
4
|
let _tanstack_router_core = require("@tanstack/router-core");
|
|
4
5
|
//#region src/router.ts
|
|
5
6
|
var createRouter = (options) => {
|
|
@@ -7,7 +8,7 @@ var createRouter = (options) => {
|
|
|
7
8
|
};
|
|
8
9
|
var Router = class extends _tanstack_router_core.RouterCore {
|
|
9
10
|
constructor(options) {
|
|
10
|
-
super(options);
|
|
11
|
+
super(options, require_routerStores.getStoreFactory);
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
if (typeof globalThis !== "undefined") {
|
package/dist/cjs/router.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.cjs","names":[],"sources":["../../src/router.ts"],"sourcesContent":["import { RouterCore } from '@tanstack/router-core'\nimport { createFileRoute, createLazyFileRoute } from './fileRoute'\nimport type { RouterHistory } from '@tanstack/history'\nimport type {\n AnyRoute,\n CreateRouterFn,\n RouterConstructorOptions,\n TrailingSlashOption,\n} from '@tanstack/router-core'\nimport type {\n ErrorRouteComponent,\n NotFoundRouteComponent,\n RouteComponent,\n} from './route'\nimport type { JSX } from 'solid-js'\n\ndeclare module '@tanstack/router-core' {\n export interface RouterOptionsExtensions {\n /**\n * The default `component` a route should use if no component is provided.\n *\n * @default Outlet\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultcomponent-property)\n */\n defaultComponent?: RouteComponent\n /**\n * The default `errorComponent` a route should use if no error component is provided.\n *\n * @default ErrorComponent\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaulterrorcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)\n */\n defaultErrorComponent?: ErrorRouteComponent\n /**\n * The default `pendingComponent` a route should use if no pending component is provided.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultpendingcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#showing-a-pending-component)\n */\n defaultPendingComponent?: RouteComponent\n /**\n * The default `notFoundComponent` a route should use if no notFound component is provided.\n *\n * @default NotFound\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultnotfoundcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/not-found-errors#default-router-wide-not-found-handling)\n */\n defaultNotFoundComponent?: NotFoundRouteComponent\n /**\n * A component that will be used to wrap the entire router.\n *\n * This is useful for providing a context to the entire router.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#wrap-property)\n */\n Wrap?: (props: { children: any }) => JSX.Element\n /**\n * A component that will be used to wrap the inner contents of the router.\n *\n * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#innerwrap-property)\n */\n InnerWrap?: (props: { children: any }) => JSX.Element\n\n /**\n * The default `onCatch` handler for errors caught by the Router ErrorBoundary\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)\n */\n defaultOnCatch?: (error: Error) => void\n }\n}\n\nexport const createRouter: CreateRouterFn = (options) => {\n return new Router(options)\n}\n\nexport class Router<\n in out TRouteTree extends AnyRoute,\n in out TTrailingSlashOption extends TrailingSlashOption = 'never',\n in out TDefaultStructuralSharingOption extends boolean = false,\n in out TRouterHistory extends RouterHistory = RouterHistory,\n in out TDehydrated extends Record<string, any> = Record<string, any>,\n> extends RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n> {\n constructor(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n ) {\n super(options)\n }\n}\n\nif (typeof globalThis !== 'undefined') {\n ;(globalThis as any).createFileRoute = createFileRoute\n ;(globalThis as any).createLazyFileRoute = createLazyFileRoute\n} else if (typeof window !== 'undefined') {\n ;(window as any).createFileRoute = createFileRoute\n ;(window as any).createLazyFileRoute = createLazyFileRoute\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.cjs","names":[],"sources":["../../src/router.ts"],"sourcesContent":["import { RouterCore } from '@tanstack/router-core'\nimport { createFileRoute, createLazyFileRoute } from './fileRoute'\nimport { getStoreFactory } from './routerStores'\nimport type { RouterHistory } from '@tanstack/history'\nimport type {\n AnyRoute,\n CreateRouterFn,\n RouterConstructorOptions,\n TrailingSlashOption,\n} from '@tanstack/router-core'\nimport type {\n ErrorRouteComponent,\n NotFoundRouteComponent,\n RouteComponent,\n} from './route'\nimport type { JSX } from 'solid-js'\n\ndeclare module '@tanstack/router-core' {\n export interface RouterOptionsExtensions {\n /**\n * The default `component` a route should use if no component is provided.\n *\n * @default Outlet\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultcomponent-property)\n */\n defaultComponent?: RouteComponent\n /**\n * The default `errorComponent` a route should use if no error component is provided.\n *\n * @default ErrorComponent\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaulterrorcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#handling-errors-with-routeoptionserrorcomponent)\n */\n defaultErrorComponent?: ErrorRouteComponent\n /**\n * The default `pendingComponent` a route should use if no pending component is provided.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultpendingcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#showing-a-pending-component)\n */\n defaultPendingComponent?: RouteComponent\n /**\n * The default `notFoundComponent` a route should use if no notFound component is provided.\n *\n * @default NotFound\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#defaultnotfoundcomponent-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/solid/guide/not-found-errors#default-router-wide-not-found-handling)\n */\n defaultNotFoundComponent?: NotFoundRouteComponent\n /**\n * A component that will be used to wrap the entire router.\n *\n * This is useful for providing a context to the entire router.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#wrap-property)\n */\n Wrap?: (props: { children: any }) => JSX.Element\n /**\n * A component that will be used to wrap the inner contents of the router.\n *\n * This is useful for providing a context to the inner contents of the router where you also need access to the router context and hooks.\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/solid/api/router/RouterOptionsType#innerwrap-property)\n */\n InnerWrap?: (props: { children: any }) => JSX.Element\n\n /**\n * The default `onCatch` handler for errors caught by the Router ErrorBoundary\n *\n * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultoncatch-property)\n * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#handling-errors-with-routeoptionsoncatch)\n */\n defaultOnCatch?: (error: Error) => void\n }\n}\n\nexport const createRouter: CreateRouterFn = (options) => {\n return new Router(options)\n}\n\nexport class Router<\n in out TRouteTree extends AnyRoute,\n in out TTrailingSlashOption extends TrailingSlashOption = 'never',\n in out TDefaultStructuralSharingOption extends boolean = false,\n in out TRouterHistory extends RouterHistory = RouterHistory,\n in out TDehydrated extends Record<string, any> = Record<string, any>,\n> extends RouterCore<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n> {\n constructor(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n ) {\n super(options, getStoreFactory)\n }\n}\n\nif (typeof globalThis !== 'undefined') {\n ;(globalThis as any).createFileRoute = createFileRoute\n ;(globalThis as any).createLazyFileRoute = createLazyFileRoute\n} else if (typeof window !== 'undefined') {\n ;(window as any).createFileRoute = createFileRoute\n ;(window as any).createLazyFileRoute = createLazyFileRoute\n}\n"],"mappings":";;;;;AA4EA,IAAa,gBAAgC,YAAY;AACvD,QAAO,IAAI,OAAO,QAAQ;;AAG5B,IAAa,SAAb,cAMU,sBAAA,WAMR;CACA,YACE,SAOA;AACA,QAAM,SAAS,qBAAA,gBAAgB;;;AAInC,IAAI,OAAO,eAAe,aAAa;AACnC,YAAmB,kBAAkB,kBAAA;AACrC,YAAmB,sBAAsB,kBAAA;WAClC,OAAO,WAAW,aAAa;AACtC,QAAe,kBAAkB,kBAAA;AACjC,QAAe,sBAAsB,kBAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _tanstack_router_core = require("@tanstack/router-core");
|
|
3
|
+
let solid_js = require("solid-js");
|
|
4
|
+
solid_js = require_runtime.__toESM(solid_js);
|
|
5
|
+
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
|
|
6
|
+
//#region src/routerStores.ts
|
|
7
|
+
function initRouterStores(stores, createReadonlyStore) {
|
|
8
|
+
stores.childMatchIdByRouteId = createReadonlyStore(() => {
|
|
9
|
+
const ids = stores.matchesId.state;
|
|
10
|
+
const obj = {};
|
|
11
|
+
for (let i = 0; i < ids.length - 1; i++) {
|
|
12
|
+
const parentStore = stores.activeMatchStoresById.get(ids[i]);
|
|
13
|
+
if (parentStore?.routeId) obj[parentStore.routeId] = ids[i + 1];
|
|
14
|
+
}
|
|
15
|
+
return obj;
|
|
16
|
+
});
|
|
17
|
+
stores.pendingRouteIds = createReadonlyStore(() => {
|
|
18
|
+
const ids = stores.pendingMatchesId.state;
|
|
19
|
+
const obj = {};
|
|
20
|
+
for (const id of ids) {
|
|
21
|
+
const store = stores.pendingMatchStoresById.get(id);
|
|
22
|
+
if (store?.routeId) obj[store.routeId] = true;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function createSolidMutableStore(initialValue) {
|
|
28
|
+
const [signal, setSignal] = solid_js.createSignal(initialValue);
|
|
29
|
+
return {
|
|
30
|
+
get state() {
|
|
31
|
+
return signal();
|
|
32
|
+
},
|
|
33
|
+
setState: setSignal
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var finalizationRegistry = null;
|
|
37
|
+
if (typeof globalThis !== "undefined" && "FinalizationRegistry" in globalThis) finalizationRegistry = new FinalizationRegistry((cb) => cb());
|
|
38
|
+
function createSolidReadonlyStore(read) {
|
|
39
|
+
let dispose;
|
|
40
|
+
const memo = solid_js.createRoot((d) => {
|
|
41
|
+
dispose = d;
|
|
42
|
+
return solid_js.createMemo(read);
|
|
43
|
+
});
|
|
44
|
+
const store = { get state() {
|
|
45
|
+
return memo();
|
|
46
|
+
} };
|
|
47
|
+
finalizationRegistry?.register(store, dispose);
|
|
48
|
+
return store;
|
|
49
|
+
}
|
|
50
|
+
var getStoreFactory = (opts) => {
|
|
51
|
+
if (_tanstack_router_core_isServer.isServer ?? opts.isServer) return {
|
|
52
|
+
createMutableStore: _tanstack_router_core.createNonReactiveMutableStore,
|
|
53
|
+
createReadonlyStore: _tanstack_router_core.createNonReactiveReadonlyStore,
|
|
54
|
+
batch: (fn) => fn(),
|
|
55
|
+
init: (stores) => initRouterStores(stores, _tanstack_router_core.createNonReactiveReadonlyStore)
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
createMutableStore: createSolidMutableStore,
|
|
59
|
+
createReadonlyStore: createSolidReadonlyStore,
|
|
60
|
+
batch: solid_js.batch,
|
|
61
|
+
init: (stores) => initRouterStores(stores, createSolidReadonlyStore)
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
exports.getStoreFactory = getStoreFactory;
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=routerStores.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routerStores.cjs","names":[],"sources":["../../src/routerStores.ts"],"sourcesContent":["import * as Solid from 'solid-js'\nimport {\n createNonReactiveMutableStore,\n createNonReactiveReadonlyStore,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport type {\n AnyRoute,\n GetStoreConfig,\n RouterReadableStore,\n RouterStores,\n RouterWritableStore,\n} from '@tanstack/router-core'\n\ndeclare module '@tanstack/router-core' {\n export interface RouterStores<in out TRouteTree extends AnyRoute> {\n /** Maps each active routeId to the matchId of its child in the match tree. */\n childMatchIdByRouteId: RouterReadableStore<Record<string, string>>\n /** Maps each pending routeId to true for quick lookup. */\n pendingRouteIds: RouterReadableStore<Record<string, boolean>>\n }\n}\n\nfunction initRouterStores(\n stores: RouterStores<AnyRoute>,\n createReadonlyStore: <TValue>(\n read: () => TValue,\n ) => RouterReadableStore<TValue>,\n) {\n stores.childMatchIdByRouteId = createReadonlyStore(() => {\n const ids = stores.matchesId.state\n const obj: Record<string, string> = {}\n for (let i = 0; i < ids.length - 1; i++) {\n const parentStore = stores.activeMatchStoresById.get(ids[i]!)\n if (parentStore?.routeId) {\n obj[parentStore.routeId] = ids[i + 1]!\n }\n }\n return obj\n })\n\n stores.pendingRouteIds = createReadonlyStore(() => {\n const ids = stores.pendingMatchesId.state\n const obj: Record<string, boolean> = {}\n for (const id of ids) {\n const store = stores.pendingMatchStoresById.get(id)\n if (store?.routeId) {\n obj[store.routeId] = true\n }\n }\n return obj\n })\n}\n\nfunction createSolidMutableStore<TValue>(\n initialValue: TValue,\n): RouterWritableStore<TValue> {\n const [signal, setSignal] = Solid.createSignal(initialValue)\n\n return {\n get state() {\n return signal()\n },\n setState: setSignal,\n }\n}\n\nlet finalizationRegistry: FinalizationRegistry<() => void> | null = null\nif (typeof globalThis !== 'undefined' && 'FinalizationRegistry' in globalThis) {\n finalizationRegistry = new FinalizationRegistry((cb) => cb())\n}\n\nfunction createSolidReadonlyStore<TValue>(\n read: () => TValue,\n): RouterReadableStore<TValue> {\n let dispose!: () => void\n const memo = Solid.createRoot((d) => {\n dispose = d\n return Solid.createMemo(read)\n })\n const store = {\n get state() {\n return memo()\n },\n }\n finalizationRegistry?.register(store, dispose)\n return store\n}\n\nexport const getStoreFactory: GetStoreConfig = (opts) => {\n if (isServer ?? opts.isServer) {\n return {\n createMutableStore: createNonReactiveMutableStore,\n createReadonlyStore: createNonReactiveReadonlyStore,\n batch: (fn) => fn(),\n init: (stores) =>\n initRouterStores(stores, createNonReactiveReadonlyStore),\n }\n }\n\n return {\n createMutableStore: createSolidMutableStore,\n createReadonlyStore: createSolidReadonlyStore,\n batch: Solid.batch,\n init: (stores) => initRouterStores(stores, createSolidReadonlyStore),\n }\n}\n"],"mappings":";;;;;;AAuBA,SAAS,iBACP,QACA,qBAGA;AACA,QAAO,wBAAwB,0BAA0B;EACvD,MAAM,MAAM,OAAO,UAAU;EAC7B,MAAM,MAA8B,EAAE;AACtC,OAAK,IAAI,IAAI,GAAG,IAAI,IAAI,SAAS,GAAG,KAAK;GACvC,MAAM,cAAc,OAAO,sBAAsB,IAAI,IAAI,GAAI;AAC7D,OAAI,aAAa,QACf,KAAI,YAAY,WAAW,IAAI,IAAI;;AAGvC,SAAO;GACP;AAEF,QAAO,kBAAkB,0BAA0B;EACjD,MAAM,MAAM,OAAO,iBAAiB;EACpC,MAAM,MAA+B,EAAE;AACvC,OAAK,MAAM,MAAM,KAAK;GACpB,MAAM,QAAQ,OAAO,uBAAuB,IAAI,GAAG;AACnD,OAAI,OAAO,QACT,KAAI,MAAM,WAAW;;AAGzB,SAAO;GACP;;AAGJ,SAAS,wBACP,cAC6B;CAC7B,MAAM,CAAC,QAAQ,aAAa,SAAM,aAAa,aAAa;AAE5D,QAAO;EACL,IAAI,QAAQ;AACV,UAAO,QAAQ;;EAEjB,UAAU;EACX;;AAGH,IAAI,uBAAgE;AACpE,IAAI,OAAO,eAAe,eAAe,0BAA0B,WACjE,wBAAuB,IAAI,sBAAsB,OAAO,IAAI,CAAC;AAG/D,SAAS,yBACP,MAC6B;CAC7B,IAAI;CACJ,MAAM,OAAO,SAAM,YAAY,MAAM;AACnC,YAAU;AACV,SAAO,SAAM,WAAW,KAAK;GAC7B;CACF,MAAM,QAAQ,EACZ,IAAI,QAAQ;AACV,SAAO,MAAM;IAEhB;AACD,uBAAsB,SAAS,OAAO,QAAQ;AAC9C,QAAO;;AAGT,IAAa,mBAAmC,SAAS;AACvD,KAAI,+BAAA,YAAY,KAAK,SACnB,QAAO;EACL,oBAAoB,sBAAA;EACpB,qBAAqB,sBAAA;EACrB,QAAQ,OAAO,IAAI;EACnB,OAAO,WACL,iBAAiB,QAAQ,sBAAA,+BAA+B;EAC3D;AAGH,QAAO;EACL,oBAAoB;EACpB,qBAAqB;EACrB,OAAO,SAAM;EACb,OAAO,WAAW,iBAAiB,QAAQ,yBAAyB;EACrE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AnyRoute, GetStoreConfig, RouterReadableStore } from '@tanstack/router-core';
|
|
2
|
+
declare module '@tanstack/router-core' {
|
|
3
|
+
interface RouterStores<in out TRouteTree extends AnyRoute> {
|
|
4
|
+
/** Maps each active routeId to the matchId of its child in the match tree. */
|
|
5
|
+
childMatchIdByRouteId: RouterReadableStore<Record<string, string>>;
|
|
6
|
+
/** Maps each pending routeId to true for quick lookup. */
|
|
7
|
+
pendingRouteIds: RouterReadableStore<Record<string, boolean>>;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare const getStoreFactory: GetStoreConfig;
|
|
@@ -8,7 +8,7 @@ let _tanstack_router_core_ssr_client = require("@tanstack/router-core/ssr/client
|
|
|
8
8
|
var hydrationPromise;
|
|
9
9
|
var Dummy = (props) => (0, solid_js_web.memo)(() => props.children);
|
|
10
10
|
function RouterClient(props) {
|
|
11
|
-
if (!hydrationPromise) if (!props.router.state.
|
|
11
|
+
if (!hydrationPromise) if (!props.router.stores.matchesId.state.length) hydrationPromise = (0, _tanstack_router_core_ssr_client.hydrate)(props.router);
|
|
12
12
|
else hydrationPromise = Promise.resolve();
|
|
13
13
|
return (0, solid_js_web.createComponent)(require_awaited.Await, {
|
|
14
14
|
promise: hydrationPromise,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterClient.cjs","names":["hydrate","Await","HeadContent","RouterProvider","AnyRouter","JSXElement","hydrationPromise","Promise","Array","Dummy","props","children","_$memo","RouterClient","router","
|
|
1
|
+
{"version":3,"file":"RouterClient.cjs","names":["hydrate","Await","HeadContent","RouterProvider","AnyRouter","JSXElement","hydrationPromise","Promise","Array","Dummy","props","children","_$memo","RouterClient","router","stores","matchesId","state","length","resolve","_$createComponent","promise","InnerWrap"],"sources":["../../../src/ssr/RouterClient.tsx"],"sourcesContent":["import { hydrate } from '@tanstack/router-core/ssr/client'\nimport { Await } from '../awaited'\nimport { HeadContent } from '../HeadContent'\nimport { RouterProvider } from '../RouterProvider'\nimport type { AnyRouter } from '@tanstack/router-core'\nimport type { JSXElement } from 'solid-js'\n\nlet hydrationPromise: Promise<void | Array<Array<void>>> | undefined\n\nconst Dummy = (props: { children?: JSXElement }) => <>{props.children}</>\n\nexport function RouterClient(props: { router: AnyRouter }) {\n if (!hydrationPromise) {\n if (!props.router.stores.matchesId.state.length) {\n hydrationPromise = hydrate(props.router)\n } else {\n hydrationPromise = Promise.resolve()\n }\n }\n return (\n <Await\n promise={hydrationPromise}\n children={() => (\n <Dummy>\n <Dummy>\n <RouterProvider\n router={props.router}\n InnerWrap={(props) => (\n <Dummy>\n <Dummy>\n <HeadContent />\n {props.children}\n </Dummy>\n <Dummy />\n </Dummy>\n )}\n />\n </Dummy>\n </Dummy>\n )}\n />\n )\n}\n"],"mappings":";;;;;;;AAOA,IAAIM;AAEJ,IAAMG,SAASC,WAAAA,GAAAA,aAAAA,YAAwCA,MAAMC,SAAY;AAEzE,SAAgBE,aAAaH,OAA8B;AACzD,KAAI,CAACJ,iBACH,KAAI,CAACI,MAAMI,OAAOC,OAAOC,UAAUC,MAAMC,OACvCZ,qBAAAA,GAAAA,iCAAAA,SAA2BI,MAAMI,OAAO;KAExCR,oBAAmBC,QAAQY,SAAS;AAGxC,SAAA,GAAA,aAAA,iBACGlB,gBAAAA,OAAK;EACJoB,SAASf;EACTK,iBAAAA,GAAAA,aAAAA,iBACGF,OAAK,EAAA,IAAAE,WAAA;AAAA,WAAA,GAAA,aAAA,iBACHF,OAAK,EAAA,IAAAE,WAAA;AAAA,YAAA,GAAA,aAAA,iBACHR,uBAAAA,gBAAc;KAAA,IACbW,SAAM;AAAA,aAAEJ,MAAMI;;KACdQ,YAAYZ,WAAAA,GAAAA,aAAAA,iBACTD,OAAK,EAAA,IAAAE,WAAA;AAAA,aAAA,EAAA,GAAA,aAAA,iBACHF,OAAK,EAAA,IAAAE,WAAA;AAAA,cAAA,EAAA,GAAA,aAAA,iBACHT,oBAAAA,aAAW,EAAA,CAAA,GAAA,GAAA,aAAA,YACXQ,MAAMC,SAAQ,CAAA;SAAA,CAAA,GAAA,GAAA,aAAA,iBAEhBF,OAAK,EAAA,CAAA,CAAA;QAAA,CAAA;KAET,CAAA;MAAA,CAAA;KAAA,CAAA;EAIR,CAAA"}
|
|
@@ -19,7 +19,7 @@ var renderRouterToStream = async ({ request, router, responseHeaders, children }
|
|
|
19
19
|
stream.pipeTo(writable);
|
|
20
20
|
const responseStream = (0, _tanstack_router_core_ssr_server.transformReadableStreamWithRouter)(router, readable);
|
|
21
21
|
return new Response(responseStream, {
|
|
22
|
-
status: router.
|
|
22
|
+
status: router.stores.statusCode.state,
|
|
23
23
|
headers: responseHeaders
|
|
24
24
|
});
|
|
25
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRouterToStream.cjs","names":["Solid","isbot","transformReadableStreamWithRouter","makeSsrSerovalPlugin","JSXElement","ReadableStream","AnyRouter","renderRouterToStream","request","router","responseHeaders","children","Request","Headers","writable","readable","TransformStream","docType","ssr","serializationAdapters","options","serovalPlugins","map","adapter","plugin","didRun","stream","renderToStream","_$memo","nonce","plugins","headers","get","pipeTo","responseStream","Response","status","
|
|
1
|
+
{"version":3,"file":"renderRouterToStream.cjs","names":["Solid","isbot","transformReadableStreamWithRouter","makeSsrSerovalPlugin","JSXElement","ReadableStream","AnyRouter","renderRouterToStream","request","router","responseHeaders","children","Request","Headers","writable","readable","TransformStream","docType","ssr","serializationAdapters","options","serovalPlugins","map","adapter","plugin","didRun","stream","renderToStream","_$memo","nonce","plugins","headers","get","pipeTo","responseStream","Response","status","stores","statusCode","state"],"sources":["../../../src/ssr/renderRouterToStream.tsx"],"sourcesContent":["import * as Solid from 'solid-js/web'\nimport { isbot } from 'isbot'\nimport { transformReadableStreamWithRouter } from '@tanstack/router-core/ssr/server'\nimport { makeSsrSerovalPlugin } from '@tanstack/router-core'\nimport type { JSXElement } from 'solid-js'\nimport type { ReadableStream } from 'node:stream/web'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport const renderRouterToStream = async ({\n request,\n router,\n responseHeaders,\n children,\n}: {\n request: Request\n router: AnyRouter\n responseHeaders: Headers\n children: () => JSXElement\n}) => {\n const { writable, readable } = new TransformStream()\n\n const docType = Solid.ssr('<!DOCTYPE html>')\n\n const serializationAdapters =\n (router.options as any)?.serializationAdapters ||\n (router.options.ssr as any)?.serializationAdapters\n const serovalPlugins = serializationAdapters?.map((adapter: any) => {\n const plugin = makeSsrSerovalPlugin(adapter, { didRun: false })\n return plugin\n })\n\n const stream = Solid.renderToStream(\n () => (\n <>\n {docType}\n {children()}\n </>\n ),\n {\n nonce: router.options.ssr?.nonce,\n plugins: serovalPlugins,\n } as any,\n )\n\n if (isbot(request.headers.get('User-Agent'))) {\n await stream\n }\n stream.pipeTo(writable)\n\n const responseStream = transformReadableStreamWithRouter(\n router,\n readable as unknown as ReadableStream,\n )\n return new Response(responseStream as any, {\n status: router.stores.statusCode.state,\n headers: responseHeaders,\n })\n}\n"],"mappings":";;;;;;;AAQA,IAAaO,uBAAuB,OAAO,EACzCC,SACAC,QACAC,iBACAC,eAMI;CACJ,MAAM,EAAEG,UAAUC,aAAa,IAAIC,iBAAiB;CAEpD,MAAMC,UAAUjB,aAAMkB,IAAI,kBAAkB;CAK5C,MAAMG,kBAFHZ,OAAOW,SAAiBD,yBACxBV,OAAOW,QAAQF,KAAaC,wBACeG,KAAKC,YAAiB;AAElE,UAAA,GAAA,sBAAA,sBADoCA,SAAS,EAAEE,QAAQ,OAAO,CAAC;GAE/D;CAEF,MAAMC,SAAS1B,aAAM2B,qBACnB,CAEKV,UAAAA,GAAAA,aAAAA,MACAN,SAAQ,CAEZ,EACD;EACEkB,OAAOpB,OAAOW,QAAQF,KAAKW;EAC3BC,SAAST;EACV,CACF;AAED,MAAA,GAAA,MAAA,OAAUb,QAAQuB,QAAQC,IAAI,aAAa,CAAC,CAC1C,OAAMN;AAERA,QAAOO,OAAOnB,SAAS;CAEvB,MAAMoB,kBAAAA,GAAAA,iCAAAA,mCACJzB,QACAM,SACD;AACD,QAAO,IAAIoB,SAASD,gBAAuB;EACzCE,QAAQ3B,OAAO4B,OAAOC,WAAWC;EACjCR,SAASrB;EACV,CAAC"}
|
|
@@ -3,7 +3,7 @@ let _tanstack_router_core = require("@tanstack/router-core");
|
|
|
3
3
|
let solid_js_web = require("solid-js/web");
|
|
4
4
|
solid_js_web = require_runtime.__toESM(solid_js_web);
|
|
5
5
|
//#region src/ssr/renderRouterToString.tsx
|
|
6
|
-
var renderRouterToString =
|
|
6
|
+
var renderRouterToString = ({ router, responseHeaders, children }) => {
|
|
7
7
|
try {
|
|
8
8
|
const serovalPlugins = (router.options?.serializationAdapters || router.options.ssr?.serializationAdapters)?.map((adapter) => {
|
|
9
9
|
return (0, _tanstack_router_core.makeSsrSerovalPlugin)(adapter, { didRun: false });
|
|
@@ -16,7 +16,7 @@ var renderRouterToString = async ({ router, responseHeaders, children }) => {
|
|
|
16
16
|
const injectedHtml = router.serverSsr.takeBufferedHtml();
|
|
17
17
|
if (injectedHtml) html = html.replace(`</body>`, () => `${injectedHtml}</body>`);
|
|
18
18
|
return new Response(`<!DOCTYPE html>${html}`, {
|
|
19
|
-
status: router.
|
|
19
|
+
status: router.stores.statusCode.state,
|
|
20
20
|
headers: responseHeaders
|
|
21
21
|
});
|
|
22
22
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRouterToString.cjs","names":["Solid","makeSsrSerovalPlugin","AnyRouter","JSXElement","renderRouterToString","router","responseHeaders","children","Headers","serializationAdapters","options","ssr","serovalPlugins","map","adapter","plugin","didRun","html","renderToString","nonce","plugins","serverSsr","setRenderFinished","injectedHtml","takeBufferedHtml","replace","Response","status","
|
|
1
|
+
{"version":3,"file":"renderRouterToString.cjs","names":["Solid","makeSsrSerovalPlugin","AnyRouter","JSXElement","renderRouterToString","router","responseHeaders","children","Headers","serializationAdapters","options","ssr","serovalPlugins","map","adapter","plugin","didRun","html","renderToString","nonce","plugins","serverSsr","setRenderFinished","injectedHtml","takeBufferedHtml","replace","Response","status","stores","statusCode","state","headers","error","console","cleanup"],"sources":["../../../src/ssr/renderRouterToString.tsx"],"sourcesContent":["import * as Solid from 'solid-js/web'\nimport { makeSsrSerovalPlugin } from '@tanstack/router-core'\nimport type { AnyRouter } from '@tanstack/router-core'\nimport type { JSXElement } from 'solid-js'\n\nexport const renderRouterToString = ({\n router,\n responseHeaders,\n children,\n}: {\n router: AnyRouter\n responseHeaders: Headers\n children: () => JSXElement\n}) => {\n try {\n const serializationAdapters =\n (router.options as any)?.serializationAdapters ||\n (router.options.ssr as any)?.serializationAdapters\n const serovalPlugins = serializationAdapters?.map((adapter: any) => {\n const plugin = makeSsrSerovalPlugin(adapter, { didRun: false })\n return plugin\n })\n\n let html = Solid.renderToString(children, {\n nonce: router.options.ssr?.nonce,\n plugins: serovalPlugins,\n } as any)\n router.serverSsr!.setRenderFinished()\n\n const injectedHtml = router.serverSsr!.takeBufferedHtml()\n if (injectedHtml) {\n html = html.replace(`</body>`, () => `${injectedHtml}</body>`)\n }\n return new Response(`<!DOCTYPE html>${html}`, {\n status: router.stores.statusCode.state,\n headers: responseHeaders,\n })\n } catch (error) {\n console.error('Render to string error:', error)\n return new Response('Internal Server Error', {\n status: 500,\n headers: responseHeaders,\n })\n } finally {\n router.serverSsr?.cleanup()\n }\n}\n"],"mappings":";;;;;AAKA,IAAaI,wBAAwB,EACnCC,QACAC,iBACAC,eAKI;AACJ,KAAI;EAIF,MAAMK,kBAFHP,OAAOK,SAAiBD,yBACxBJ,OAAOK,QAAQC,KAAaF,wBACeI,KAAKC,YAAiB;AAElE,WAAA,GAAA,sBAAA,sBADoCA,SAAS,EAAEE,QAAQ,OAAO,CAAC;IAE/D;EAEF,IAAIC,OAAOjB,aAAMkB,eAAeX,UAAU;GACxCY,OAAOd,OAAOK,QAAQC,KAAKQ;GAC3BC,SAASR;GACV,CAAQ;AACTP,SAAOgB,UAAWC,mBAAmB;EAErC,MAAMC,eAAelB,OAAOgB,UAAWG,kBAAkB;AACzD,MAAID,aACFN,QAAOA,KAAKQ,QAAQ,iBAAiB,GAAGF,aAAY,SAAU;AAEhE,SAAO,IAAIG,SAAS,kBAAkBT,QAAQ;GAC5CU,QAAQtB,OAAOuB,OAAOC,WAAWC;GACjCC,SAASzB;GACV,CAAC;UACK0B,OAAO;AACdC,UAAQD,MAAM,2BAA2BA,MAAM;AAC/C,SAAO,IAAIN,SAAS,yBAAyB;GAC3CC,QAAQ;GACRI,SAASzB;GACV,CAAC;WACM;AACRD,SAAOgB,WAAWa,SAAS"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_useRouter = require("./useRouter.cjs");
|
|
3
|
+
let solid_js = require("solid-js");
|
|
4
|
+
solid_js = require_runtime.__toESM(solid_js);
|
|
2
5
|
//#region src/useCanGoBack.ts
|
|
3
6
|
function useCanGoBack() {
|
|
4
|
-
|
|
7
|
+
const router = require_useRouter.useRouter();
|
|
8
|
+
return solid_js.createMemo(() => router.stores.location.state.state.__TSR_index !== 0);
|
|
5
9
|
}
|
|
6
10
|
//#endregion
|
|
7
11
|
exports.useCanGoBack = useCanGoBack;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCanGoBack.cjs","names":[],"sources":["../../src/useCanGoBack.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useCanGoBack.cjs","names":[],"sources":["../../src/useCanGoBack.ts"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { useRouter } from './useRouter'\n\nexport function useCanGoBack() {\n const router = useRouter()\n return Solid.createMemo(\n () => router.stores.location.state.state.__TSR_index !== 0,\n )\n}\n"],"mappings":";;;;;AAGA,SAAgB,eAAe;CAC7B,MAAM,SAAS,kBAAA,WAAW;AAC1B,QAAO,SAAM,iBACL,OAAO,OAAO,SAAS,MAAM,MAAM,gBAAgB,EAC1D"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Solid from 'solid-js';
|
|
2
|
+
export declare function useCanGoBack(): Solid.Accessor<boolean>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const require_useMatch = require("./useMatch.cjs");
|
|
2
2
|
//#region src/useLoaderDeps.tsx
|
|
3
3
|
function useLoaderDeps(opts) {
|
|
4
|
-
const { select, ...rest } = opts;
|
|
5
4
|
return require_useMatch.useMatch({
|
|
6
|
-
...
|
|
5
|
+
...opts,
|
|
7
6
|
select: (s) => {
|
|
8
|
-
return select ? select(s.loaderDeps) : s.loaderDeps;
|
|
7
|
+
return opts.select ? opts.select(s.loaderDeps) : s.loaderDeps;
|
|
9
8
|
}
|
|
10
9
|
});
|
|
11
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoaderDeps.cjs","names":["useMatch","Accessor","AnyRouter","RegisteredRouter","ResolveUseLoaderDeps","StrictOrFrom","UseLoaderDepsResult","UseLoaderDepsBaseOptions","select","deps","TRouter","TFrom","TSelected","UseLoaderDepsOptions","UseLoaderDepsRoute","opts","TId","useLoaderDeps","
|
|
1
|
+
{"version":3,"file":"useLoaderDeps.cjs","names":["useMatch","Accessor","AnyRouter","RegisteredRouter","ResolveUseLoaderDeps","StrictOrFrom","UseLoaderDepsResult","UseLoaderDepsBaseOptions","select","deps","TRouter","TFrom","TSelected","UseLoaderDepsOptions","UseLoaderDepsRoute","opts","TId","useLoaderDeps","s","loaderDeps"],"sources":["../../src/useLoaderDeps.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type { Accessor } from 'solid-js'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseLoaderDeps,\n StrictOrFrom,\n UseLoaderDepsResult,\n} from '@tanstack/router-core'\n\nexport interface UseLoaderDepsBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TSelected,\n> {\n select?: (deps: ResolveUseLoaderDeps<TRouter, TFrom>) => TSelected\n}\n\nexport type UseLoaderDepsOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TSelected,\n> = StrictOrFrom<TRouter, TFrom> &\n UseLoaderDepsBaseOptions<TRouter, TFrom, TSelected>\n\nexport type UseLoaderDepsRoute<out TId> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseLoaderDepsBaseOptions<TRouter, TId, TSelected>,\n) => Accessor<UseLoaderDepsResult<TRouter, TId, TSelected>>\n\nexport function useLoaderDeps<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TSelected = unknown,\n>(\n opts: UseLoaderDepsOptions<TRouter, TFrom, TSelected>,\n): Accessor<UseLoaderDepsResult<TRouter, TFrom, TSelected>> {\n return useMatch({\n ...opts,\n select: (s) => {\n return opts.select ? opts.select(s.loaderDeps) : s.loaderDeps\n },\n }) as Accessor<UseLoaderDepsResult<TRouter, TFrom, TSelected>>\n}\n"],"mappings":";;AAgCA,SAAgBiB,cAKdF,MAC0D;AAC1D,QAAOf,iBAAAA,SAAS;EACd,GAAGe;EACHP,SAASU,MAAM;AACb,UAAOH,KAAKP,SAASO,KAAKP,OAAOU,EAAEC,WAAW,GAAGD,EAAEC;;EAEtD,CAAC"}
|
package/dist/cjs/useLocation.cjs
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_useRouter = require("./useRouter.cjs");
|
|
3
|
+
let _tanstack_router_core = require("@tanstack/router-core");
|
|
4
|
+
let solid_js = require("solid-js");
|
|
5
|
+
solid_js = require_runtime.__toESM(solid_js);
|
|
2
6
|
//#region src/useLocation.tsx
|
|
3
7
|
function useLocation(opts) {
|
|
4
|
-
|
|
8
|
+
const router = require_useRouter.useRouter();
|
|
9
|
+
if (!opts?.select) return (() => router.stores.location.state);
|
|
10
|
+
const select = opts.select;
|
|
11
|
+
return solid_js.createMemo((prev) => {
|
|
12
|
+
const res = select(router.stores.location.state);
|
|
13
|
+
if (prev === void 0) return res;
|
|
14
|
+
return (0, _tanstack_router_core.replaceEqualDeep)(prev, res);
|
|
15
|
+
});
|
|
5
16
|
}
|
|
6
17
|
//#endregion
|
|
7
18
|
exports.useLocation = useLocation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocation.cjs","names":["
|
|
1
|
+
{"version":3,"file":"useLocation.cjs","names":["Solid","replaceEqualDeep","useRouter","AnyRouter","RegisteredRouter","RouterState","Accessor","UseLocationBaseOptions","select","state","TRouter","TSelected","UseLocationResult","useLocation","opts","router","stores","location","createMemo","prev","res","undefined"],"sources":["../../src/useLocation.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { replaceEqualDeep } from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterState,\n} from '@tanstack/router-core'\nimport type { Accessor } from 'solid-js'\n\nexport interface UseLocationBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (state: RouterState<TRouter['routeTree']>['location']) => TSelected\n}\n\nexport type UseLocationResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected\n ? RouterState<TRouter['routeTree']>['location']\n : TSelected\n\nexport function useLocation<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseLocationBaseOptions<TRouter, TSelected>,\n): Accessor<UseLocationResult<TRouter, TSelected>> {\n const router = useRouter<TRouter>()\n\n if (!opts?.select) {\n return (() => router.stores.location.state) as Accessor<\n UseLocationResult<TRouter, TSelected>\n >\n }\n\n const select = opts.select\n\n return Solid.createMemo((prev: TSelected | undefined) => {\n const res = select(router.stores.location.state)\n if (prev === undefined) return res\n return replaceEqualDeep(prev, res)\n }) as Accessor<UseLocationResult<TRouter, TSelected>>\n}\n"],"mappings":";;;;;;AAqBA,SAAgBa,YAIdC,MACiD;CACjD,MAAMC,SAASb,kBAAAA,WAAoB;AAEnC,KAAI,CAACY,MAAMN,OACT,eAAcO,OAAOC,OAAOC,SAASR;CAKvC,MAAMD,SAASM,KAAKN;AAEpB,QAAOR,SAAMkB,YAAYC,SAAgC;EACvD,MAAMC,MAAMZ,OAAOO,OAAOC,OAAOC,SAASR,MAAM;AAChD,MAAIU,SAASE,KAAAA,EAAW,QAAOD;AAC/B,UAAA,GAAA,sBAAA,kBAAwBD,MAAMC,IAAI;GAClC"}
|
package/dist/cjs/useMatch.cjs
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const
|
|
2
|
+
const require_useRouter = require("./useRouter.cjs");
|
|
3
3
|
const require_matchContext = require("./matchContext.cjs");
|
|
4
|
+
let _tanstack_router_core = require("@tanstack/router-core");
|
|
4
5
|
let solid_js = require("solid-js");
|
|
5
6
|
solid_js = require_runtime.__toESM(solid_js);
|
|
6
7
|
let tiny_invariant = require("tiny-invariant");
|
|
7
8
|
tiny_invariant = require_runtime.__toESM(tiny_invariant);
|
|
8
9
|
//#region src/useMatch.tsx
|
|
9
10
|
function useMatch(opts) {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
return {
|
|
18
|
-
match: opts.select ? opts.select(match) : match,
|
|
19
|
-
shouldThrowError: false
|
|
20
|
-
};
|
|
21
|
-
} });
|
|
11
|
+
const router = require_useRouter.useRouter();
|
|
12
|
+
const nearestMatch = opts.from ? void 0 : solid_js.useContext(require_matchContext.nearestMatchContext);
|
|
13
|
+
const match = () => {
|
|
14
|
+
if (opts.from) return router.stores.getMatchStoreByRouteId(opts.from).state;
|
|
15
|
+
return nearestMatch?.match();
|
|
16
|
+
};
|
|
22
17
|
solid_js.createEffect(() => {
|
|
23
|
-
if (
|
|
18
|
+
if (match() !== void 0) return;
|
|
19
|
+
(0, tiny_invariant.default)(!(!(opts.from ? Boolean(router.stores.pendingRouteIds.state[opts.from]) : nearestMatch?.hasPending() ?? false) && !router.stores.isTransitioning.state && (opts.shouldThrow ?? true)), `Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`);
|
|
20
|
+
});
|
|
21
|
+
return solid_js.createMemo((prev) => {
|
|
22
|
+
const selectedMatch = match();
|
|
23
|
+
if (selectedMatch === void 0) return void 0;
|
|
24
|
+
const res = opts.select ? opts.select(selectedMatch) : selectedMatch;
|
|
25
|
+
if (prev === void 0) return res;
|
|
26
|
+
return (0, _tanstack_router_core.replaceEqualDeep)(prev, res);
|
|
24
27
|
});
|
|
25
|
-
return solid_js.createMemo(() => matchState().match);
|
|
26
28
|
}
|
|
27
29
|
//#endregion
|
|
28
30
|
exports.useMatch = useMatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatch.cjs","names":["Solid","invariant","
|
|
1
|
+
{"version":3,"file":"useMatch.cjs","names":["Solid","invariant","replaceEqualDeep","nearestMatchContext","useRouter","AnyRouter","MakeRouteMatch","MakeRouteMatchUnion","RegisteredRouter","StrictOrFrom","ThrowConstraint","ThrowOrOptional","UseMatchBaseOptions","select","match","TRouter","TFrom","TStrict","TSelected","shouldThrow","TThrow","UseMatchRoute","opts","Accessor","UseMatchResult","UseMatchOptions","useMatch","router","nearestMatch","from","undefined","useContext","stores","getMatchStoreByRouteId","state","createEffect","hasPendingMatch","Boolean","pendingRouteIds","hasPending","isTransitioning","createMemo","prev","selectedMatch","res"],"sources":["../../src/useMatch.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport invariant from 'tiny-invariant'\nimport { replaceEqualDeep } from '@tanstack/router-core'\nimport { nearestMatchContext } from './matchContext'\nimport { useRouter } from './useRouter'\nimport type {\n AnyRouter,\n MakeRouteMatch,\n MakeRouteMatchUnion,\n RegisteredRouter,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n} from '@tanstack/router-core'\n\nexport interface UseMatchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n> {\n select?: (\n match: MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>,\n ) => TSelected\n shouldThrow?: TThrow\n}\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchBaseOptions<TRouter, TFrom, true, true, TSelected>,\n) => Solid.Accessor<UseMatchResult<TRouter, TFrom, true, TSelected>>\n\nexport type UseMatchOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseMatchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\n\nexport type UseMatchResult<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n> = unknown extends TSelected\n ? TStrict extends true\n ? MakeRouteMatch<TRouter['routeTree'], TFrom, TStrict>\n : MakeRouteMatchUnion<TRouter>\n : TSelected\n\nexport function useMatch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n>(\n opts: UseMatchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Solid.Accessor<\n ThrowOrOptional<UseMatchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n const router = useRouter<TRouter>()\n const nearestMatch = opts.from\n ? undefined\n : Solid.useContext(nearestMatchContext)\n\n const match = () => {\n if (opts.from) {\n return router.stores.getMatchStoreByRouteId(opts.from).state\n }\n\n return nearestMatch?.match()\n }\n\n Solid.createEffect(() => {\n if (match() !== undefined) {\n return\n }\n\n const hasPendingMatch = opts.from\n ? Boolean(router.stores.pendingRouteIds.state[opts.from!])\n : (nearestMatch?.hasPending() ?? false)\n\n invariant(\n !(\n !hasPendingMatch &&\n !router.stores.isTransitioning.state &&\n (opts.shouldThrow ?? true)\n ),\n `Could not find ${opts.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'}`,\n )\n })\n\n return Solid.createMemo((prev: TSelected | undefined) => {\n const selectedMatch = match()\n\n if (selectedMatch === undefined) return undefined\n const res = opts.select ? opts.select(selectedMatch as any) : selectedMatch\n if (prev === undefined) return res as TSelected\n return replaceEqualDeep(prev, res) as TSelected\n }) as any\n}\n"],"mappings":";;;;;;;;;AAuDA,SAAgB0B,SAOdJ,MASA;CACA,MAAMK,SAASvB,kBAAAA,WAAoB;CACnC,MAAMwB,eAAeN,KAAKO,OACtBC,KAAAA,IACA9B,SAAM+B,WAAW5B,qBAAAA,oBAAoB;CAEzC,MAAMW,cAAc;AAClB,MAAIQ,KAAKO,KACP,QAAOF,OAAOK,OAAOC,uBAAuBX,KAAKO,KAAK,CAACK;AAGzD,SAAON,cAAcd,OAAO;;AAG9Bd,UAAMmC,mBAAmB;AACvB,MAAIrB,OAAO,KAAKgB,KAAAA,EACd;AAOF7B,GAAAA,GAAAA,eAAAA,SACE,EACE,EANoBqB,KAAKO,OACzBQ,QAAQV,OAAOK,OAAOM,gBAAgBJ,MAAMZ,KAAKO,MAAO,GACvDD,cAAcW,YAAY,IAAI,UAK/B,CAACZ,OAAOK,OAAOQ,gBAAgBN,UAC9BZ,KAAKH,eAAe,QAEvB,kBAAkBG,KAAKO,OAAO,yBAAyBP,KAAKO,KAAI,KAAM,qBACvE;GACD;AAEF,QAAO7B,SAAMyC,YAAYC,SAAgC;EACvD,MAAMC,gBAAgB7B,OAAO;AAE7B,MAAI6B,kBAAkBb,KAAAA,EAAW,QAAOA,KAAAA;EACxC,MAAMc,MAAMtB,KAAKT,SAASS,KAAKT,OAAO8B,cAAqB,GAAGA;AAC9D,MAAID,SAASZ,KAAAA,EAAW,QAAOc;AAC/B,UAAA,GAAA,sBAAA,kBAAwBF,MAAME,IAAI;GAClC"}
|
package/dist/cjs/useParams.cjs
CHANGED
|
@@ -3,8 +3,8 @@ const require_useMatch = require("./useMatch.cjs");
|
|
|
3
3
|
function useParams(opts) {
|
|
4
4
|
return require_useMatch.useMatch({
|
|
5
5
|
from: opts.from,
|
|
6
|
-
shouldThrow: opts.shouldThrow,
|
|
7
6
|
strict: opts.strict,
|
|
7
|
+
shouldThrow: opts.shouldThrow,
|
|
8
8
|
select: (match) => {
|
|
9
9
|
const params = opts.strict === false ? match.params : match._strictParams;
|
|
10
10
|
return opts.select ? opts.select(params) : params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParams.cjs","names":["useMatch","Accessor","AnyRouter","RegisteredRouter","ResolveUseParams","StrictOrFrom","ThrowConstraint","ThrowOrOptional","UseParamsResult","UseParamsBaseOptions","select","params","TRouter","TFrom","TStrict","TSelected","shouldThrow","TThrow","UseParamsOptions","UseParamsRoute","opts","useParams","from","strict","match","_strictParams"],"sources":["../../src/useParams.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type { Accessor } from 'solid-js'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseParams,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseParamsResult,\n} from '@tanstack/router-core'\n\nexport interface UseParamsBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n> {\n select?: (params: ResolveUseParams<TRouter, TFrom, TStrict>) => TSelected\n shouldThrow?: TThrow\n}\n\nexport type UseParamsOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseParamsBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\n\nexport type UseParamsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseParamsBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected\n >,\n) => Accessor<UseParamsResult<TRouter, TFrom, true, TSelected>>\n\nexport function useParams<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n>(\n opts: UseParamsOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Accessor<\n ThrowOrOptional<UseParamsResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n return useMatch({\n from: opts.from!,\n
|
|
1
|
+
{"version":3,"file":"useParams.cjs","names":["useMatch","Accessor","AnyRouter","RegisteredRouter","ResolveUseParams","StrictOrFrom","ThrowConstraint","ThrowOrOptional","UseParamsResult","UseParamsBaseOptions","select","params","TRouter","TFrom","TStrict","TSelected","shouldThrow","TThrow","UseParamsOptions","UseParamsRoute","opts","useParams","from","strict","match","_strictParams"],"sources":["../../src/useParams.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type { Accessor } from 'solid-js'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseParams,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseParamsResult,\n} from '@tanstack/router-core'\n\nexport interface UseParamsBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n> {\n select?: (params: ResolveUseParams<TRouter, TFrom, TStrict>) => TSelected\n shouldThrow?: TThrow\n}\n\nexport type UseParamsOptions<\n TRouter extends AnyRouter,\n TFrom extends string | undefined,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseParamsBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected>\n\nexport type UseParamsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseParamsBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected\n >,\n) => Accessor<UseParamsResult<TRouter, TFrom, true, TSelected>>\n\nexport function useParams<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n>(\n opts: UseParamsOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): Accessor<\n ThrowOrOptional<UseParamsResult<TRouter, TFrom, TStrict, TSelected>, TThrow>\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n select: (match: any) => {\n const params = opts.strict === false ? match.params : match._strictParams\n return opts.select ? opts.select(params) : params\n },\n }) as Accessor<any>\n}\n"],"mappings":";;AA6CA,SAAgBqB,UAOdD,MASA;AACA,QAAOpB,iBAAAA,SAAS;EACdsB,MAAMF,KAAKE;EACXC,QAAQH,KAAKG;EACbP,aAAaI,KAAKJ;EAClBN,SAASc,UAAe;GACtB,MAAMb,SAASS,KAAKG,WAAW,QAAQC,MAAMb,SAASa,MAAMC;AAC5D,UAAOL,KAAKV,SAASU,KAAKV,OAAOC,OAAO,GAAGA;;EAE9C,CAAC"}
|
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_useRouter = require("./useRouter.cjs");
|
|
3
|
+
let _tanstack_router_core = require("@tanstack/router-core");
|
|
4
|
+
let solid_js = require("solid-js");
|
|
5
|
+
solid_js = require_runtime.__toESM(solid_js);
|
|
3
6
|
let _tanstack_router_core_isServer = require("@tanstack/router-core/isServer");
|
|
4
|
-
let _tanstack_solid_store = require("@tanstack/solid-store");
|
|
5
7
|
//#region src/useRouterState.tsx
|
|
6
|
-
function deepEqual(a, b) {
|
|
7
|
-
if (Object.is(a, b)) return true;
|
|
8
|
-
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) return false;
|
|
9
|
-
const keysA = Object.keys(a);
|
|
10
|
-
const keysB = Object.keys(b);
|
|
11
|
-
if (keysA.length !== keysB.length) return false;
|
|
12
|
-
for (const key of keysA) {
|
|
13
|
-
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
14
|
-
if (!deepEqual(a[key], b[key])) return false;
|
|
15
|
-
}
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
8
|
function useRouterState(opts) {
|
|
19
9
|
const contextRouter = require_useRouter.useRouter({ warn: opts?.router === void 0 });
|
|
20
10
|
const router = opts?.router || contextRouter;
|
|
21
11
|
if (_tanstack_router_core_isServer.isServer ?? router.isServer) {
|
|
22
|
-
const state = router.state;
|
|
12
|
+
const state = router.stores.__store.state;
|
|
23
13
|
const selected = opts?.select ? opts.select(state) : state;
|
|
24
14
|
return (() => selected);
|
|
25
15
|
}
|
|
26
|
-
return (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
if (!opts?.select) return (() => router.stores.__store.state);
|
|
17
|
+
const select = opts.select;
|
|
18
|
+
return solid_js.createMemo((prev) => {
|
|
19
|
+
const res = select(router.stores.__store.state);
|
|
20
|
+
if (prev === void 0) return res;
|
|
21
|
+
return (0, _tanstack_router_core.replaceEqualDeep)(prev, res);
|
|
22
|
+
});
|
|
30
23
|
}
|
|
31
24
|
//#endregion
|
|
32
25
|
exports.useRouterState = useRouterState;
|