@tanstack/react-router 1.121.20 → 1.121.21
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 +41 -0
- package/dist/cjs/Asset.cjs.map +1 -0
- package/dist/cjs/Asset.d.cts +2 -0
- package/dist/cjs/CatchBoundary.cjs +114 -0
- package/dist/cjs/CatchBoundary.cjs.map +1 -0
- package/dist/cjs/CatchBoundary.d.cts +12 -0
- package/dist/cjs/ClientOnly.cjs +20 -0
- package/dist/cjs/ClientOnly.cjs.map +1 -0
- package/dist/cjs/ClientOnly.d.cts +29 -0
- package/dist/cjs/HeadContent.cjs +155 -0
- package/dist/cjs/HeadContent.cjs.map +1 -0
- package/dist/cjs/HeadContent.d.cts +7 -0
- package/dist/cjs/Match.cjs +257 -0
- package/dist/cjs/Match.cjs.map +1 -0
- package/dist/cjs/Match.d.cts +8 -0
- package/dist/cjs/Matches.cjs +136 -0
- package/dist/cjs/Matches.cjs.map +1 -0
- package/dist/cjs/Matches.d.cts +26 -0
- package/dist/cjs/RouterProvider.cjs +33 -0
- package/dist/cjs/RouterProvider.cjs.map +1 -0
- package/dist/cjs/RouterProvider.d.cts +10 -0
- package/dist/cjs/SafeFragment.cjs +8 -0
- package/dist/cjs/SafeFragment.cjs.map +1 -0
- package/dist/cjs/SafeFragment.d.cts +1 -0
- package/dist/cjs/ScriptOnce.cjs +28 -0
- package/dist/cjs/ScriptOnce.cjs.map +1 -0
- package/dist/cjs/ScriptOnce.d.cts +5 -0
- package/dist/cjs/Scripts.cjs +51 -0
- package/dist/cjs/Scripts.cjs.map +1 -0
- package/dist/cjs/Scripts.d.cts +1 -0
- package/dist/cjs/ScrollRestoration.cjs +39 -0
- package/dist/cjs/ScrollRestoration.cjs.map +1 -0
- package/dist/cjs/ScrollRestoration.d.cts +14 -0
- package/dist/cjs/Transitioner.cjs +115 -0
- package/dist/cjs/Transitioner.cjs.map +1 -0
- package/dist/cjs/Transitioner.d.cts +1 -0
- package/dist/cjs/awaited.cjs +48 -0
- package/dist/cjs/awaited.cjs.map +1 -0
- package/dist/cjs/awaited.d.cts +10 -0
- package/dist/cjs/fileRoute.cjs +107 -0
- package/dist/cjs/fileRoute.cjs.map +1 -0
- package/dist/cjs/fileRoute.d.cts +54 -0
- package/dist/cjs/history.d.cts +8 -0
- package/dist/cjs/index.cjs +289 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +55 -0
- package/dist/cjs/lazyRouteComponent.cjs +78 -0
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -0
- package/dist/cjs/lazyRouteComponent.d.cts +2 -0
- package/dist/cjs/link.cjs +324 -0
- package/dist/cjs/link.cjs.map +1 -0
- package/dist/cjs/link.d.cts +48 -0
- package/dist/cjs/matchContext.cjs +27 -0
- package/dist/cjs/matchContext.cjs.map +1 -0
- package/dist/cjs/matchContext.d.cts +3 -0
- package/dist/cjs/not-found.cjs +40 -0
- package/dist/cjs/not-found.cjs.map +1 -0
- package/dist/cjs/not-found.d.cts +9 -0
- package/dist/cjs/renderRouteNotFound.cjs +22 -0
- package/dist/cjs/renderRouteNotFound.cjs.map +1 -0
- package/dist/cjs/renderRouteNotFound.d.cts +2 -0
- package/dist/cjs/route.cjs +205 -0
- package/dist/cjs/route.cjs.map +1 -0
- package/dist/cjs/route.d.cts +95 -0
- package/dist/cjs/router.cjs +22 -0
- package/dist/cjs/router.cjs.map +1 -0
- package/dist/cjs/router.d.cts +72 -0
- package/dist/cjs/routerContext.cjs +33 -0
- package/dist/cjs/routerContext.cjs.map +1 -0
- package/dist/cjs/routerContext.d.cts +8 -0
- package/dist/cjs/scroll-restoration.cjs +24 -0
- package/dist/cjs/scroll-restoration.cjs.map +1 -0
- package/dist/cjs/scroll-restoration.d.cts +1 -0
- package/dist/cjs/serializer.d.cts +6 -0
- package/dist/cjs/structuralSharing.d.cts +8 -0
- package/dist/cjs/typePrimitives.d.cts +16 -0
- package/dist/cjs/useBlocker.cjs +165 -0
- package/dist/cjs/useBlocker.cjs.map +1 -0
- package/dist/cjs/useBlocker.d.cts +66 -0
- package/dist/cjs/useCanGoBack.cjs +8 -0
- package/dist/cjs/useCanGoBack.cjs.map +1 -0
- package/dist/cjs/useCanGoBack.d.cts +1 -0
- package/dist/cjs/useLoaderData.cjs +15 -0
- package/dist/cjs/useLoaderData.cjs.map +1 -0
- package/dist/cjs/useLoaderData.d.cts +8 -0
- package/dist/cjs/useLoaderDeps.cjs +14 -0
- package/dist/cjs/useLoaderDeps.cjs.map +1 -0
- package/dist/cjs/useLoaderDeps.d.cts +8 -0
- package/dist/cjs/useLocation.cjs +10 -0
- package/dist/cjs/useLocation.cjs.map +1 -0
- package/dist/cjs/useLocation.d.cts +7 -0
- package/dist/cjs/useMatch.cjs +47 -0
- package/dist/cjs/useMatch.cjs.map +1 -0
- package/dist/cjs/useMatch.d.cts +10 -0
- package/dist/cjs/useNavigate.cjs +55 -0
- package/dist/cjs/useNavigate.cjs.map +1 -0
- package/dist/cjs/useNavigate.d.cts +5 -0
- package/dist/cjs/useParams.cjs +16 -0
- package/dist/cjs/useParams.cjs.map +1 -0
- package/dist/cjs/useParams.d.cts +9 -0
- package/dist/cjs/useRouteContext.cjs +11 -0
- package/dist/cjs/useRouteContext.cjs.map +1 -0
- package/dist/cjs/useRouteContext.d.cts +3 -0
- package/dist/cjs/useRouter.cjs +32 -0
- package/dist/cjs/useRouter.cjs.map +1 -0
- package/dist/cjs/useRouter.d.cts +4 -0
- package/dist/cjs/useRouterState.cjs +29 -0
- package/dist/cjs/useRouterState.cjs.map +1 -0
- package/dist/cjs/useRouterState.d.cts +8 -0
- package/dist/cjs/useSearch.cjs +16 -0
- package/dist/cjs/useSearch.cjs.map +1 -0
- package/dist/cjs/useSearch.d.cts +9 -0
- package/dist/cjs/utils.cjs +72 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +49 -0
- package/dist/esm/Asset.d.ts +2 -0
- package/dist/esm/Asset.js +41 -0
- package/dist/esm/Asset.js.map +1 -0
- package/dist/esm/CatchBoundary.d.ts +12 -0
- package/dist/esm/CatchBoundary.js +97 -0
- package/dist/esm/CatchBoundary.js.map +1 -0
- package/dist/esm/ClientOnly.d.ts +29 -0
- package/dist/esm/ClientOnly.js +20 -0
- package/dist/esm/ClientOnly.js.map +1 -0
- package/dist/esm/HeadContent.d.ts +7 -0
- package/dist/esm/HeadContent.js +139 -0
- package/dist/esm/HeadContent.js.map +1 -0
- package/dist/esm/Match.d.ts +8 -0
- package/dist/esm/Match.js +240 -0
- package/dist/esm/Match.js.map +1 -0
- package/dist/esm/Matches.d.ts +26 -0
- package/dist/esm/Matches.js +119 -0
- package/dist/esm/Matches.js.map +1 -0
- package/dist/esm/RouterProvider.d.ts +10 -0
- package/dist/esm/RouterProvider.js +33 -0
- package/dist/esm/RouterProvider.js.map +1 -0
- package/dist/esm/SafeFragment.d.ts +1 -0
- package/dist/esm/SafeFragment.js +8 -0
- package/dist/esm/SafeFragment.js.map +1 -0
- package/dist/esm/ScriptOnce.d.ts +5 -0
- package/dist/esm/ScriptOnce.js +28 -0
- package/dist/esm/ScriptOnce.js.map +1 -0
- package/dist/esm/Scripts.d.ts +1 -0
- package/dist/esm/Scripts.js +51 -0
- package/dist/esm/Scripts.js.map +1 -0
- package/dist/esm/ScrollRestoration.d.ts +14 -0
- package/dist/esm/ScrollRestoration.js +39 -0
- package/dist/esm/ScrollRestoration.js.map +1 -0
- package/dist/esm/Transitioner.d.ts +1 -0
- package/dist/esm/Transitioner.js +98 -0
- package/dist/esm/Transitioner.js.map +1 -0
- package/dist/esm/awaited.d.ts +10 -0
- package/dist/esm/awaited.js +31 -0
- package/dist/esm/awaited.js.map +1 -0
- package/dist/esm/fileRoute.d.ts +54 -0
- package/dist/esm/fileRoute.js +107 -0
- package/dist/esm/fileRoute.js.map +1 -0
- package/dist/esm/history.d.ts +8 -0
- package/dist/esm/index.d.ts +55 -0
- package/dist/esm/index.js +151 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lazyRouteComponent.d.ts +2 -0
- package/dist/esm/lazyRouteComponent.js +61 -0
- package/dist/esm/lazyRouteComponent.js.map +1 -0
- package/dist/esm/link.d.ts +48 -0
- package/dist/esm/link.js +307 -0
- package/dist/esm/link.js.map +1 -0
- package/dist/esm/matchContext.d.ts +3 -0
- package/dist/esm/matchContext.js +10 -0
- package/dist/esm/matchContext.js.map +1 -0
- package/dist/esm/not-found.d.ts +9 -0
- package/dist/esm/not-found.js +40 -0
- package/dist/esm/not-found.js.map +1 -0
- package/dist/esm/renderRouteNotFound.d.ts +2 -0
- package/dist/esm/renderRouteNotFound.js +22 -0
- package/dist/esm/renderRouteNotFound.js.map +1 -0
- package/dist/esm/route.d.ts +95 -0
- package/dist/esm/route.js +205 -0
- package/dist/esm/route.js.map +1 -0
- package/dist/esm/router.d.ts +72 -0
- package/dist/esm/router.js +22 -0
- package/dist/esm/router.js.map +1 -0
- package/dist/esm/routerContext.d.ts +8 -0
- package/dist/esm/routerContext.js +16 -0
- package/dist/esm/routerContext.js.map +1 -0
- package/dist/esm/scroll-restoration.d.ts +1 -0
- package/dist/esm/scroll-restoration.js +24 -0
- package/dist/esm/scroll-restoration.js.map +1 -0
- package/dist/esm/serializer.d.ts +6 -0
- package/dist/esm/structuralSharing.d.ts +8 -0
- package/dist/esm/typePrimitives.d.ts +16 -0
- package/dist/esm/useBlocker.d.ts +66 -0
- package/dist/esm/useBlocker.js +148 -0
- package/dist/esm/useBlocker.js.map +1 -0
- package/dist/esm/useCanGoBack.d.ts +1 -0
- package/dist/esm/useCanGoBack.js +8 -0
- package/dist/esm/useCanGoBack.js.map +1 -0
- package/dist/esm/useLoaderData.d.ts +8 -0
- package/dist/esm/useLoaderData.js +15 -0
- package/dist/esm/useLoaderData.js.map +1 -0
- package/dist/esm/useLoaderDeps.d.ts +8 -0
- package/dist/esm/useLoaderDeps.js +14 -0
- package/dist/esm/useLoaderDeps.js.map +1 -0
- package/dist/esm/useLocation.d.ts +7 -0
- package/dist/esm/useLocation.js +10 -0
- package/dist/esm/useLocation.js.map +1 -0
- package/dist/esm/useMatch.d.ts +10 -0
- package/dist/esm/useMatch.js +30 -0
- package/dist/esm/useMatch.js.map +1 -0
- package/dist/esm/useNavigate.d.ts +5 -0
- package/dist/esm/useNavigate.js +38 -0
- package/dist/esm/useNavigate.js.map +1 -0
- package/dist/esm/useParams.d.ts +9 -0
- package/dist/esm/useParams.js +16 -0
- package/dist/esm/useParams.js.map +1 -0
- package/dist/esm/useRouteContext.d.ts +3 -0
- package/dist/esm/useRouteContext.js +11 -0
- package/dist/esm/useRouteContext.js.map +1 -0
- package/dist/esm/useRouter.d.ts +4 -0
- package/dist/esm/useRouter.js +15 -0
- package/dist/esm/useRouter.js.map +1 -0
- package/dist/esm/useRouterState.d.ts +8 -0
- package/dist/esm/useRouterState.js +29 -0
- package/dist/esm/useRouterState.js.map +1 -0
- package/dist/esm/useSearch.d.ts +9 -0
- package/dist/esm/useSearch.js +16 -0
- package/dist/esm/useSearch.js.map +1 -0
- package/dist/esm/utils.d.ts +49 -0
- package/dist/esm/utils.js +55 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/llms/index.d.ts +3 -0
- package/dist/llms/index.js +35 -0
- package/dist/llms/rules/api.d.ts +2 -0
- package/dist/llms/rules/api.js +4241 -0
- package/dist/llms/rules/guide.d.ts +2 -0
- package/dist/llms/rules/guide.js +6225 -0
- package/dist/llms/rules/routing.d.ts +2 -0
- package/dist/llms/rules/routing.js +1946 -0
- package/dist/llms/rules/setup-and-architecture.d.ts +2 -0
- package/dist/llms/rules/setup-and-architecture.js +932 -0
- package/package.json +3 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactStore = require("@tanstack/react-store");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const routerCore = require("@tanstack/router-core");
|
|
6
|
+
const useRouter = require("./useRouter.cjs");
|
|
7
|
+
function useRouterState(opts) {
|
|
8
|
+
const contextRouter = useRouter.useRouter({
|
|
9
|
+
warn: (opts == null ? void 0 : opts.router) === void 0
|
|
10
|
+
});
|
|
11
|
+
const router = (opts == null ? void 0 : opts.router) || contextRouter;
|
|
12
|
+
const previousResult = React.useRef(void 0);
|
|
13
|
+
return reactStore.useStore(router.__store, (state) => {
|
|
14
|
+
if (opts == null ? void 0 : opts.select) {
|
|
15
|
+
if (opts.structuralSharing ?? router.options.defaultStructuralSharing) {
|
|
16
|
+
const newSlice = routerCore.replaceEqualDeep(
|
|
17
|
+
previousResult.current,
|
|
18
|
+
opts.select(state)
|
|
19
|
+
);
|
|
20
|
+
previousResult.current = newSlice;
|
|
21
|
+
return newSlice;
|
|
22
|
+
}
|
|
23
|
+
return opts.select(state);
|
|
24
|
+
}
|
|
25
|
+
return state;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.useRouterState = useRouterState;
|
|
29
|
+
//# sourceMappingURL=useRouterState.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRouterState.cjs","sources":["../../src/useRouterState.tsx"],"sourcesContent":["import { useStore } from '@tanstack/react-store'\nimport { useRef } from 'react'\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 {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\n\nexport type UseRouterStateOptions<\n TRouter extends AnyRouter,\n TSelected,\n TStructuralSharing,\n> = {\n router?: TRouter\n select?: (\n state: RouterState<TRouter['routeTree']>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n} & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseRouterStateResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? RouterState<TRouter['routeTree']> : TSelected\n\nexport function useRouterState<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseRouterStateOptions<TRouter, TSelected, TStructuralSharing>,\n): UseRouterStateResult<TRouter, TSelected> {\n const contextRouter = useRouter<TRouter>({\n warn: opts?.router === undefined,\n })\n const router = opts?.router || contextRouter\n const previousResult =\n useRef<ValidateSelected<TRouter, TSelected, TStructuralSharing>>(undefined)\n\n return useStore(router.__store, (state) => {\n if (opts?.select) {\n if (opts.structuralSharing ?? router.options.defaultStructuralSharing) {\n const newSlice = replaceEqualDeep(\n previousResult.current,\n opts.select(state),\n )\n previousResult.current = newSlice\n return newSlice\n }\n return opts.select(state)\n }\n return state\n }) as UseRouterStateResult<TRouter, TSelected>\n}\n"],"names":["useRouter","useRef","useStore","replaceEqualDeep"],"mappings":";;;;;;AA8BO,SAAS,eAKd,MAC0C;AAC1C,QAAM,gBAAgBA,UAAAA,UAAmB;AAAA,IACvC,OAAM,6BAAM,YAAW;AAAA,EAAA,CACxB;AACK,QAAA,UAAS,6BAAM,WAAU;AACzB,QAAA,iBACJC,aAAiE,MAAS;AAE5E,SAAOC,oBAAS,OAAO,SAAS,CAAC,UAAU;AACzC,QAAI,6BAAM,QAAQ;AAChB,UAAI,KAAK,qBAAqB,OAAO,QAAQ,0BAA0B;AACrE,cAAM,WAAWC,WAAA;AAAA,UACf,eAAe;AAAA,UACf,KAAK,OAAO,KAAK;AAAA,QACnB;AACA,uBAAe,UAAU;AAClB,eAAA;AAAA,MAAA;AAEF,aAAA,KAAK,OAAO,KAAK;AAAA,IAAA;AAEnB,WAAA;AAAA,EAAA,CACR;AACH;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AnyRouter, RegisteredRouter, RouterState } from '@tanstack/router-core';
|
|
2
|
+
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.cjs';
|
|
3
|
+
export type UseRouterStateOptions<TRouter extends AnyRouter, TSelected, TStructuralSharing> = {
|
|
4
|
+
router?: TRouter;
|
|
5
|
+
select?: (state: RouterState<TRouter['routeTree']>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
|
|
6
|
+
} & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>;
|
|
7
|
+
export type UseRouterStateResult<TRouter extends AnyRouter, TSelected> = unknown extends TSelected ? RouterState<TRouter['routeTree']> : TSelected;
|
|
8
|
+
export declare function useRouterState<TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseRouterStateOptions<TRouter, TSelected, TStructuralSharing>): UseRouterStateResult<TRouter, TSelected>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const useMatch = require("./useMatch.cjs");
|
|
4
|
+
function useSearch(opts) {
|
|
5
|
+
return useMatch.useMatch({
|
|
6
|
+
from: opts.from,
|
|
7
|
+
strict: opts.strict,
|
|
8
|
+
shouldThrow: opts.shouldThrow,
|
|
9
|
+
structuralSharing: opts.structuralSharing,
|
|
10
|
+
select: (match) => {
|
|
11
|
+
return opts.select ? opts.select(match.search) : match.search;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.useSearch = useSearch;
|
|
16
|
+
//# sourceMappingURL=useSearch.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSearch.cjs","sources":["../../src/useSearch.tsx"],"sourcesContent":["import { useMatch } from './useMatch'\nimport type {\n StructuralSharingOption,\n ValidateSelected,\n} from './structuralSharing'\nimport type {\n AnyRouter,\n RegisteredRouter,\n ResolveUseSearch,\n StrictOrFrom,\n ThrowConstraint,\n ThrowOrOptional,\n UseSearchResult,\n} from '@tanstack/router-core'\n\nexport interface UseSearchBaseOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> {\n select?: (\n state: ResolveUseSearch<TRouter, TFrom, TStrict>,\n ) => ValidateSelected<TRouter, TSelected, TStructuralSharing>\n shouldThrow?: TThrow\n}\n\nexport type UseSearchOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n TStructuralSharing,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n UseSearchBaseOptions<\n TRouter,\n TFrom,\n TStrict,\n TThrow,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>\n\nexport type UseSearchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n TStructuralSharing extends boolean = boolean,\n>(\n opts?: UseSearchBaseOptions<\n TRouter,\n TFrom,\n /* TStrict */ true,\n /* TThrow */ true,\n TSelected,\n TStructuralSharing\n > &\n StructuralSharingOption<TRouter, TSelected, TStructuralSharing>,\n) => UseSearchResult<TRouter, TFrom, true, TSelected>\n\nexport function useSearch<\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 TStructuralSharing extends boolean = boolean,\n>(\n opts: UseSearchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected,\n TStructuralSharing\n >,\n): ThrowOrOptional<\n UseSearchResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatch({\n from: opts.from!,\n strict: opts.strict,\n shouldThrow: opts.shouldThrow,\n structuralSharing: opts.structuralSharing,\n select: (match: any) => {\n return opts.select ? opts.select(match.search) : match.search\n },\n }) as any\n}\n"],"names":["useMatch"],"mappings":";;;AA+DO,SAAS,UAQd,MAWA;AACA,SAAOA,kBAAS;AAAA,IACd,MAAM,KAAK;AAAA,IACX,QAAQ,KAAK;AAAA,IACb,aAAa,KAAK;AAAA,IAClB,mBAAmB,KAAK;AAAA,IACxB,QAAQ,CAAC,UAAe;AACtB,aAAO,KAAK,SAAS,KAAK,OAAO,MAAM,MAAM,IAAI,MAAM;AAAA,IAAA;AAAA,EACzD,CACD;AACH;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StructuralSharingOption, ValidateSelected } from './structuralSharing.cjs';
|
|
2
|
+
import { AnyRouter, RegisteredRouter, ResolveUseSearch, StrictOrFrom, ThrowConstraint, ThrowOrOptional, UseSearchResult } from '@tanstack/router-core';
|
|
3
|
+
export interface UseSearchBaseOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing> {
|
|
4
|
+
select?: (state: ResolveUseSearch<TRouter, TFrom, TStrict>) => ValidateSelected<TRouter, TSelected, TStructuralSharing>;
|
|
5
|
+
shouldThrow?: TThrow;
|
|
6
|
+
}
|
|
7
|
+
export type UseSearchOptions<TRouter extends AnyRouter, TFrom, TStrict extends boolean, TThrow extends boolean, TSelected, TStructuralSharing> = StrictOrFrom<TRouter, TFrom, TStrict> & UseSearchBaseOptions<TRouter, TFrom, TStrict, TThrow, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>;
|
|
8
|
+
export type UseSearchRoute<out TFrom> = <TRouter extends AnyRouter = RegisteredRouter, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts?: UseSearchBaseOptions<TRouter, TFrom, true, true, TSelected, TStructuralSharing> & StructuralSharingOption<TRouter, TSelected, TStructuralSharing>) => UseSearchResult<TRouter, TFrom, true, TSelected>;
|
|
9
|
+
export declare function useSearch<TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string | undefined = undefined, TStrict extends boolean = true, TThrow extends boolean = true, TSelected = unknown, TStructuralSharing extends boolean = boolean>(opts: UseSearchOptions<TRouter, TFrom, TStrict, ThrowConstraint<TStrict, TThrow>, TSelected, TStructuralSharing>): ThrowOrOptional<UseSearchResult<TRouter, TFrom, TStrict, TSelected>, TThrow>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
function _interopNamespaceDefault(e) {
|
|
5
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
6
|
+
if (e) {
|
|
7
|
+
for (const k in e) {
|
|
8
|
+
if (k !== "default") {
|
|
9
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
10
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: () => e[k]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
n.default = e;
|
|
18
|
+
return Object.freeze(n);
|
|
19
|
+
}
|
|
20
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
21
|
+
function useStableCallback(fn) {
|
|
22
|
+
const fnRef = React__namespace.useRef(fn);
|
|
23
|
+
fnRef.current = fn;
|
|
24
|
+
const ref = React__namespace.useRef((...args) => fnRef.current(...args));
|
|
25
|
+
return ref.current;
|
|
26
|
+
}
|
|
27
|
+
const useLayoutEffect = typeof window !== "undefined" ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
28
|
+
function usePrevious(value) {
|
|
29
|
+
const ref = React__namespace.useRef({
|
|
30
|
+
value,
|
|
31
|
+
prev: null
|
|
32
|
+
});
|
|
33
|
+
const current = ref.current.value;
|
|
34
|
+
if (value !== current) {
|
|
35
|
+
ref.current = {
|
|
36
|
+
value,
|
|
37
|
+
prev: current
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return ref.current.prev;
|
|
41
|
+
}
|
|
42
|
+
function useIntersectionObserver(ref, callback, intersectionObserverOptions = {}, options = {}) {
|
|
43
|
+
const isIntersectionObserverAvailable = React__namespace.useRef(
|
|
44
|
+
typeof IntersectionObserver === "function"
|
|
45
|
+
);
|
|
46
|
+
const observerRef = React__namespace.useRef(null);
|
|
47
|
+
React__namespace.useEffect(() => {
|
|
48
|
+
if (!ref.current || !isIntersectionObserverAvailable.current || options.disabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
observerRef.current = new IntersectionObserver(([entry]) => {
|
|
52
|
+
callback(entry);
|
|
53
|
+
}, intersectionObserverOptions);
|
|
54
|
+
observerRef.current.observe(ref.current);
|
|
55
|
+
return () => {
|
|
56
|
+
var _a;
|
|
57
|
+
(_a = observerRef.current) == null ? void 0 : _a.disconnect();
|
|
58
|
+
};
|
|
59
|
+
}, [callback, intersectionObserverOptions, options.disabled, ref]);
|
|
60
|
+
return observerRef.current;
|
|
61
|
+
}
|
|
62
|
+
function useForwardedRef(ref) {
|
|
63
|
+
const innerRef = React__namespace.useRef(null);
|
|
64
|
+
React__namespace.useImperativeHandle(ref, () => innerRef.current, []);
|
|
65
|
+
return innerRef;
|
|
66
|
+
}
|
|
67
|
+
exports.useForwardedRef = useForwardedRef;
|
|
68
|
+
exports.useIntersectionObserver = useIntersectionObserver;
|
|
69
|
+
exports.useLayoutEffect = useLayoutEffect;
|
|
70
|
+
exports.usePrevious = usePrevious;
|
|
71
|
+
exports.useStableCallback = useStableCallback;
|
|
72
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["import * as React from 'react'\n\nexport function useStableCallback<T extends (...args: Array<any>) => any>(\n fn: T,\n): T {\n const fnRef = React.useRef(fn)\n fnRef.current = fn\n\n const ref = React.useRef((...args: Array<any>) => fnRef.current(...args))\n return ref.current as T\n}\n\nexport const useLayoutEffect =\n typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\n/**\n * Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3\n */\nexport function usePrevious<T>(value: T): T | null {\n // initialise the ref with previous and current values\n const ref = React.useRef<{ value: T; prev: T | null }>({\n value: value,\n prev: null,\n })\n\n const current = ref.current.value\n\n // if the value passed into hook doesn't match what we store as \"current\"\n // move the \"current\" to the \"previous\"\n // and store the passed value as \"current\"\n if (value !== current) {\n ref.current = {\n value: value,\n prev: current,\n }\n }\n\n // return the previous value only\n return ref.current.prev\n}\n\n/**\n * React hook to wrap `IntersectionObserver`.\n *\n * This hook will create an `IntersectionObserver` and observe the ref passed to it.\n *\n * When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.\n *\n * @param ref - The ref to observe\n * @param intersectionObserverOptions - The options to pass to the IntersectionObserver\n * @param options - The options to pass to the hook\n * @param callback - The callback to call when the intersection changes\n * @returns The IntersectionObserver instance\n * @example\n * ```tsx\n * const MyComponent = () => {\n * const ref = React.useRef<HTMLDivElement>(null)\n * useIntersectionObserver(\n * ref,\n * (entry) => { doSomething(entry) },\n * { rootMargin: '10px' },\n * { disabled: false }\n * )\n * return <div ref={ref} />\n * ```\n */\nexport function useIntersectionObserver<T extends Element>(\n ref: React.RefObject<T | null>,\n callback: (entry: IntersectionObserverEntry | undefined) => void,\n intersectionObserverOptions: IntersectionObserverInit = {},\n options: { disabled?: boolean } = {},\n): IntersectionObserver | null {\n const isIntersectionObserverAvailable = React.useRef(\n typeof IntersectionObserver === 'function',\n )\n\n const observerRef = React.useRef<IntersectionObserver | null>(null)\n\n React.useEffect(() => {\n if (\n !ref.current ||\n !isIntersectionObserverAvailable.current ||\n options.disabled\n ) {\n return\n }\n\n observerRef.current = new IntersectionObserver(([entry]) => {\n callback(entry)\n }, intersectionObserverOptions)\n\n observerRef.current.observe(ref.current)\n\n return () => {\n observerRef.current?.disconnect()\n }\n }, [callback, intersectionObserverOptions, options.disabled, ref])\n\n return observerRef.current\n}\n\n/**\n * React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.\n *\n * @param ref - The forwarded ref\n * @returns The inner ref returned by `useRef`\n * @example\n * ```tsx\n * const MyComponent = React.forwardRef((props, ref) => {\n * const innerRef = useForwardedRef(ref)\n * return <div ref={innerRef} />\n * })\n * ```\n */\nexport function useForwardedRef<T>(ref?: React.ForwardedRef<T>) {\n const innerRef = React.useRef<T>(null)\n React.useImperativeHandle(ref, () => innerRef.current!, [])\n return innerRef\n}\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEO,SAAS,kBACd,IACG;AACG,QAAA,QAAQA,iBAAM,OAAO,EAAE;AAC7B,QAAM,UAAU;AAEV,QAAA,MAAMA,iBAAM,OAAO,IAAI,SAAqB,MAAM,QAAQ,GAAG,IAAI,CAAC;AACxE,SAAO,IAAI;AACb;AAEO,MAAM,kBACX,OAAO,WAAW,cAAcA,iBAAM,kBAAkBA,iBAAM;AAKzD,SAAS,YAAe,OAAoB;AAE3C,QAAA,MAAMA,iBAAM,OAAqC;AAAA,IACrD;AAAA,IACA,MAAM;AAAA,EAAA,CACP;AAEK,QAAA,UAAU,IAAI,QAAQ;AAK5B,MAAI,UAAU,SAAS;AACrB,QAAI,UAAU;AAAA,MACZ;AAAA,MACA,MAAM;AAAA,IACR;AAAA,EAAA;AAIF,SAAO,IAAI,QAAQ;AACrB;AA2BgB,SAAA,wBACd,KACA,UACA,8BAAwD,CACxD,GAAA,UAAkC,IACL;AAC7B,QAAM,kCAAkCA,iBAAM;AAAA,IAC5C,OAAO,yBAAyB;AAAA,EAClC;AAEM,QAAA,cAAcA,iBAAM,OAAoC,IAAI;AAElEA,mBAAM,UAAU,MAAM;AACpB,QACE,CAAC,IAAI,WACL,CAAC,gCAAgC,WACjC,QAAQ,UACR;AACA;AAAA,IAAA;AAGF,gBAAY,UAAU,IAAI,qBAAqB,CAAC,CAAC,KAAK,MAAM;AAC1D,eAAS,KAAK;AAAA,OACb,2BAA2B;AAElB,gBAAA,QAAQ,QAAQ,IAAI,OAAO;AAEvC,WAAO,MAAM;;AACX,wBAAY,YAAZ,mBAAqB;AAAA,IACvB;AAAA,EAAA,GACC,CAAC,UAAU,6BAA6B,QAAQ,UAAU,GAAG,CAAC;AAEjE,SAAO,YAAY;AACrB;AAeO,SAAS,gBAAmB,KAA6B;AACxD,QAAA,WAAWA,iBAAM,OAAU,IAAI;AACrCA,mBAAM,oBAAoB,KAAK,MAAM,SAAS,SAAU,CAAA,CAAE;AACnD,SAAA;AACT;;;;;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare function useStableCallback<T extends (...args: Array<any>) => any>(fn: T): T;
|
|
3
|
+
export declare const useLayoutEffect: typeof React.useEffect;
|
|
4
|
+
/**
|
|
5
|
+
* Taken from https://www.developerway.com/posts/implementing-advanced-use-previous-hook#part3
|
|
6
|
+
*/
|
|
7
|
+
export declare function usePrevious<T>(value: T): T | null;
|
|
8
|
+
/**
|
|
9
|
+
* React hook to wrap `IntersectionObserver`.
|
|
10
|
+
*
|
|
11
|
+
* This hook will create an `IntersectionObserver` and observe the ref passed to it.
|
|
12
|
+
*
|
|
13
|
+
* When the intersection changes, the callback will be called with the `IntersectionObserverEntry`.
|
|
14
|
+
*
|
|
15
|
+
* @param ref - The ref to observe
|
|
16
|
+
* @param intersectionObserverOptions - The options to pass to the IntersectionObserver
|
|
17
|
+
* @param options - The options to pass to the hook
|
|
18
|
+
* @param callback - The callback to call when the intersection changes
|
|
19
|
+
* @returns The IntersectionObserver instance
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const MyComponent = () => {
|
|
23
|
+
* const ref = React.useRef<HTMLDivElement>(null)
|
|
24
|
+
* useIntersectionObserver(
|
|
25
|
+
* ref,
|
|
26
|
+
* (entry) => { doSomething(entry) },
|
|
27
|
+
* { rootMargin: '10px' },
|
|
28
|
+
* { disabled: false }
|
|
29
|
+
* )
|
|
30
|
+
* return <div ref={ref} />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function useIntersectionObserver<T extends Element>(ref: React.RefObject<T | null>, callback: (entry: IntersectionObserverEntry | undefined) => void, intersectionObserverOptions?: IntersectionObserverInit, options?: {
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
}): IntersectionObserver | null;
|
|
36
|
+
/**
|
|
37
|
+
* React hook to take a `React.ForwardedRef` and returns a `ref` that can be used on a DOM element.
|
|
38
|
+
*
|
|
39
|
+
* @param ref - The forwarded ref
|
|
40
|
+
* @returns The inner ref returned by `useRef`
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const MyComponent = React.forwardRef((props, ref) => {
|
|
44
|
+
* const innerRef = useForwardedRef(ref)
|
|
45
|
+
* return <div ref={innerRef} />
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function useForwardedRef<T>(ref?: React.ForwardedRef<T>): React.RefObject<T | null>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
function Asset({ tag, attrs, children }) {
|
|
3
|
+
switch (tag) {
|
|
4
|
+
case "title":
|
|
5
|
+
return /* @__PURE__ */ jsx("title", { ...attrs, suppressHydrationWarning: true, children });
|
|
6
|
+
case "meta":
|
|
7
|
+
return /* @__PURE__ */ jsx("meta", { ...attrs, suppressHydrationWarning: true });
|
|
8
|
+
case "link":
|
|
9
|
+
return /* @__PURE__ */ jsx("link", { ...attrs, suppressHydrationWarning: true });
|
|
10
|
+
case "style":
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"style",
|
|
13
|
+
{
|
|
14
|
+
...attrs,
|
|
15
|
+
dangerouslySetInnerHTML: { __html: children }
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
case "script":
|
|
19
|
+
if (attrs && attrs.src) {
|
|
20
|
+
return /* @__PURE__ */ jsx("script", { ...attrs, suppressHydrationWarning: true });
|
|
21
|
+
}
|
|
22
|
+
if (typeof children === "string")
|
|
23
|
+
return /* @__PURE__ */ jsx(
|
|
24
|
+
"script",
|
|
25
|
+
{
|
|
26
|
+
...attrs,
|
|
27
|
+
dangerouslySetInnerHTML: {
|
|
28
|
+
__html: children
|
|
29
|
+
},
|
|
30
|
+
suppressHydrationWarning: true
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
return null;
|
|
34
|
+
default:
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
Asset
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=Asset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Asset.js","sources":["../../src/Asset.tsx"],"sourcesContent":["import type { RouterManagedTag } from '@tanstack/router-core'\n\nexport function Asset({ tag, attrs, children }: RouterManagedTag): any {\n switch (tag) {\n case 'title':\n return (\n <title {...attrs} suppressHydrationWarning>\n {children}\n </title>\n )\n case 'meta':\n return <meta {...attrs} suppressHydrationWarning />\n case 'link':\n return <link {...attrs} suppressHydrationWarning />\n case 'style':\n return (\n <style\n {...attrs}\n dangerouslySetInnerHTML={{ __html: children as any }}\n />\n )\n case 'script':\n if ((attrs as any) && (attrs as any).src) {\n return <script {...attrs} suppressHydrationWarning />\n }\n if (typeof children === 'string')\n return (\n <script\n {...attrs}\n dangerouslySetInnerHTML={{\n __html: children,\n }}\n suppressHydrationWarning\n />\n )\n return null\n default:\n return null\n }\n}\n"],"names":[],"mappings":";AAEO,SAAS,MAAM,EAAE,KAAK,OAAO,YAAmC;AACrE,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,iCACG,SAAO,EAAA,GAAG,OAAO,0BAAwB,MACvC,UACH;AAAA,IAEJ,KAAK;AACH,aAAQ,oBAAA,QAAA,EAAM,GAAG,OAAO,0BAAwB,MAAC;AAAA,IACnD,KAAK;AACH,aAAQ,oBAAA,QAAA,EAAM,GAAG,OAAO,0BAAwB,MAAC;AAAA,IACnD,KAAK;AAED,aAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ,yBAAyB,EAAE,QAAQ,SAAgB;AAAA,QAAA;AAAA,MACrD;AAAA,IAEJ,KAAK;AACE,UAAA,SAAkB,MAAc,KAAK;AACxC,eAAQ,oBAAA,UAAA,EAAQ,GAAG,OAAO,0BAAwB,MAAC;AAAA,MAAA;AAErD,UAAI,OAAO,aAAa;AAEpB,eAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACE,GAAG;AAAA,YACJ,yBAAyB;AAAA,cACvB,QAAQ;AAAA,YACV;AAAA,YACA,0BAAwB;AAAA,UAAA;AAAA,QAC1B;AAEG,aAAA;AAAA,IACT;AACS,aAAA;AAAA,EAAA;AAEb;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ErrorRouteComponent } from './route.js';
|
|
2
|
+
import { ErrorInfo } from 'react';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export declare function CatchBoundary(props: {
|
|
5
|
+
getResetKey: () => number | string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
errorComponent?: ErrorRouteComponent;
|
|
8
|
+
onCatch?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function ErrorComponent({ error }: {
|
|
11
|
+
error: any;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
function CatchBoundary(props) {
|
|
4
|
+
const errorComponent = props.errorComponent ?? ErrorComponent;
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
CatchBoundaryImpl,
|
|
7
|
+
{
|
|
8
|
+
getResetKey: props.getResetKey,
|
|
9
|
+
onCatch: props.onCatch,
|
|
10
|
+
children: ({ error, reset }) => {
|
|
11
|
+
if (error) {
|
|
12
|
+
return React.createElement(errorComponent, {
|
|
13
|
+
error,
|
|
14
|
+
reset
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return props.children;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
class CatchBoundaryImpl extends React.Component {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.state = { error: null };
|
|
26
|
+
}
|
|
27
|
+
static getDerivedStateFromProps(props) {
|
|
28
|
+
return { resetKey: props.getResetKey() };
|
|
29
|
+
}
|
|
30
|
+
static getDerivedStateFromError(error) {
|
|
31
|
+
return { error };
|
|
32
|
+
}
|
|
33
|
+
reset() {
|
|
34
|
+
this.setState({ error: null });
|
|
35
|
+
}
|
|
36
|
+
componentDidUpdate(prevProps, prevState) {
|
|
37
|
+
if (prevState.error && prevState.resetKey !== this.state.resetKey) {
|
|
38
|
+
this.reset();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
componentDidCatch(error, errorInfo) {
|
|
42
|
+
if (this.props.onCatch) {
|
|
43
|
+
this.props.onCatch(error, errorInfo);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
return this.props.children({
|
|
48
|
+
error: this.state.resetKey !== this.props.getResetKey() ? null : this.state.error,
|
|
49
|
+
reset: () => {
|
|
50
|
+
this.reset();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function ErrorComponent({ error }) {
|
|
56
|
+
const [show, setShow] = React.useState(process.env.NODE_ENV !== "production");
|
|
57
|
+
return /* @__PURE__ */ jsxs("div", { style: { padding: ".5rem", maxWidth: "100%" }, children: [
|
|
58
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: ".5rem" }, children: [
|
|
59
|
+
/* @__PURE__ */ jsx("strong", { style: { fontSize: "1rem" }, children: "Something went wrong!" }),
|
|
60
|
+
/* @__PURE__ */ jsx(
|
|
61
|
+
"button",
|
|
62
|
+
{
|
|
63
|
+
style: {
|
|
64
|
+
appearance: "none",
|
|
65
|
+
fontSize: ".6em",
|
|
66
|
+
border: "1px solid currentColor",
|
|
67
|
+
padding: ".1rem .2rem",
|
|
68
|
+
fontWeight: "bold",
|
|
69
|
+
borderRadius: ".25rem"
|
|
70
|
+
},
|
|
71
|
+
onClick: () => setShow((d) => !d),
|
|
72
|
+
children: show ? "Hide Error" : "Show Error"
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
] }),
|
|
76
|
+
/* @__PURE__ */ jsx("div", { style: { height: ".25rem" } }),
|
|
77
|
+
show ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
78
|
+
"pre",
|
|
79
|
+
{
|
|
80
|
+
style: {
|
|
81
|
+
fontSize: ".7em",
|
|
82
|
+
border: "1px solid red",
|
|
83
|
+
borderRadius: ".25rem",
|
|
84
|
+
padding: ".3rem",
|
|
85
|
+
color: "red",
|
|
86
|
+
overflow: "auto"
|
|
87
|
+
},
|
|
88
|
+
children: error.message ? /* @__PURE__ */ jsx("code", { children: error.message }) : null
|
|
89
|
+
}
|
|
90
|
+
) }) : null
|
|
91
|
+
] });
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
CatchBoundary,
|
|
95
|
+
ErrorComponent
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=CatchBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CatchBoundary.js","sources":["../../src/CatchBoundary.tsx"],"sourcesContent":["import * as React from 'react'\nimport type { ErrorRouteComponent } from './route'\nimport type { ErrorInfo } from 'react'\n\nexport function CatchBoundary(props: {\n getResetKey: () => number | string\n children: React.ReactNode\n errorComponent?: ErrorRouteComponent\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n}) {\n const errorComponent = props.errorComponent ?? ErrorComponent\n\n return (\n <CatchBoundaryImpl\n getResetKey={props.getResetKey}\n onCatch={props.onCatch}\n children={({ error, reset }) => {\n if (error) {\n return React.createElement(errorComponent, {\n error,\n reset,\n })\n }\n\n return props.children\n }}\n />\n )\n}\n\nclass CatchBoundaryImpl extends React.Component<{\n getResetKey: () => number | string\n children: (props: {\n error: Error | null\n reset: () => void\n }) => React.ReactNode\n onCatch?: (error: Error, errorInfo: ErrorInfo) => void\n}> {\n state = { error: null } as { error: Error | null; resetKey: string }\n static getDerivedStateFromProps(props: any) {\n return { resetKey: props.getResetKey() }\n }\n static getDerivedStateFromError(error: Error) {\n return { error }\n }\n reset() {\n this.setState({ error: null })\n }\n componentDidUpdate(\n prevProps: Readonly<{\n getResetKey: () => string\n children: (props: { error: any; reset: () => void }) => any\n onCatch?: ((error: any, info: any) => void) | undefined\n }>,\n prevState: any,\n ): void {\n if (prevState.error && prevState.resetKey !== this.state.resetKey) {\n this.reset()\n }\n }\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n if (this.props.onCatch) {\n this.props.onCatch(error, errorInfo)\n }\n }\n render() {\n // If the resetKey has changed, don't render the error\n return this.props.children({\n error:\n this.state.resetKey !== this.props.getResetKey()\n ? null\n : this.state.error,\n reset: () => {\n this.reset()\n },\n })\n }\n}\n\nexport function ErrorComponent({ error }: { error: any }) {\n const [show, setShow] = React.useState(process.env.NODE_ENV !== 'production')\n\n return (\n <div style={{ padding: '.5rem', maxWidth: '100%' }}>\n <div style={{ display: 'flex', alignItems: 'center', gap: '.5rem' }}>\n <strong style={{ fontSize: '1rem' }}>Something went wrong!</strong>\n <button\n style={{\n appearance: 'none',\n fontSize: '.6em',\n border: '1px solid currentColor',\n padding: '.1rem .2rem',\n fontWeight: 'bold',\n borderRadius: '.25rem',\n }}\n onClick={() => setShow((d) => !d)}\n >\n {show ? 'Hide Error' : 'Show Error'}\n </button>\n </div>\n <div style={{ height: '.25rem' }} />\n {show ? (\n <div>\n <pre\n style={{\n fontSize: '.7em',\n border: '1px solid red',\n borderRadius: '.25rem',\n padding: '.3rem',\n color: 'red',\n overflow: 'auto',\n }}\n >\n {error.message ? <code>{error.message}</code> : null}\n </pre>\n </div>\n ) : null}\n </div>\n )\n}\n"],"names":[],"mappings":";;AAIO,SAAS,cAAc,OAK3B;AACK,QAAA,iBAAiB,MAAM,kBAAkB;AAG7C,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAa,MAAM;AAAA,MACnB,SAAS,MAAM;AAAA,MACf,UAAU,CAAC,EAAE,OAAO,YAAY;AAC9B,YAAI,OAAO;AACF,iBAAA,MAAM,cAAc,gBAAgB;AAAA,YACzC;AAAA,YACA;AAAA,UAAA,CACD;AAAA,QAAA;AAGH,eAAO,MAAM;AAAA,MAAA;AAAA,IACf;AAAA,EACF;AAEJ;AAEA,MAAM,0BAA0B,MAAM,UAOnC;AAAA,EAPH,cAAA;AAAA,UAAA,GAAA,SAAA;AAQU,SAAA,QAAA,EAAE,OAAO,KAAK;AAAA,EAAA;AAAA,EACtB,OAAO,yBAAyB,OAAY;AAC1C,WAAO,EAAE,UAAU,MAAM,cAAc;AAAA,EAAA;AAAA,EAEzC,OAAO,yBAAyB,OAAc;AAC5C,WAAO,EAAE,MAAM;AAAA,EAAA;AAAA,EAEjB,QAAQ;AACN,SAAK,SAAS,EAAE,OAAO,KAAA,CAAM;AAAA,EAAA;AAAA,EAE/B,mBACE,WAKA,WACM;AACN,QAAI,UAAU,SAAS,UAAU,aAAa,KAAK,MAAM,UAAU;AACjE,WAAK,MAAM;AAAA,IAAA;AAAA,EACb;AAAA,EAEF,kBAAkB,OAAc,WAAsB;AAChD,QAAA,KAAK,MAAM,SAAS;AACjB,WAAA,MAAM,QAAQ,OAAO,SAAS;AAAA,IAAA;AAAA,EACrC;AAAA,EAEF,SAAS;AAEA,WAAA,KAAK,MAAM,SAAS;AAAA,MACzB,OACE,KAAK,MAAM,aAAa,KAAK,MAAM,gBAC/B,OACA,KAAK,MAAM;AAAA,MACjB,OAAO,MAAM;AACX,aAAK,MAAM;AAAA,MAAA;AAAA,IACb,CACD;AAAA,EAAA;AAEL;AAEgB,SAAA,eAAe,EAAE,SAAyB;AAClD,QAAA,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,QAAQ,IAAI,aAAa,YAAY;AAG1E,SAAA,qBAAC,SAAI,OAAO,EAAE,SAAS,SAAS,UAAU,OACxC,GAAA,UAAA;AAAA,IAAC,qBAAA,OAAA,EAAI,OAAO,EAAE,SAAS,QAAQ,YAAY,UAAU,KAAK,QAAA,GACxD,UAAA;AAAA,MAAA,oBAAC,YAAO,OAAO,EAAE,UAAU,UAAU,UAAqB,yBAAA;AAAA,MAC1D;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,OAAO;AAAA,YACL,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,QAAQ;AAAA,YACR,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,cAAc;AAAA,UAChB;AAAA,UACA,SAAS,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;AAAA,UAE/B,iBAAO,eAAe;AAAA,QAAA;AAAA,MAAA;AAAA,IACzB,GACF;AAAA,wBACC,OAAI,EAAA,OAAO,EAAE,QAAQ,YAAY;AAAA,IACjC,2BACE,OACC,EAAA,UAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,OAAO;AAAA,UACL,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,cAAc;AAAA,UACd,SAAS;AAAA,UACT,OAAO;AAAA,UACP,UAAU;AAAA,QACZ;AAAA,QAEC,gBAAM,UAAU,oBAAC,QAAM,EAAA,UAAA,MAAM,SAAQ,IAAU;AAAA,MAAA;AAAA,OAEpD,IACE;AAAA,EAAA,GACN;AAEJ;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface ClientOnlyProps {
|
|
3
|
+
/**
|
|
4
|
+
* The children to render when the JS is loaded.
|
|
5
|
+
*/
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* The fallback component to render if the JS is not yet loaded.
|
|
9
|
+
*/
|
|
10
|
+
fallback?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Render the children only after the JS has loaded client-side. Use an optional
|
|
14
|
+
* fallback component if the JS is not yet loaded.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* Render a Chart component if JS loads, renders a simple FakeChart
|
|
18
|
+
* component server-side or if there is no JS. The FakeChart can have only the
|
|
19
|
+
* UI without the behavior or be a loading spinner or skeleton.
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* return (
|
|
23
|
+
* <ClientOnly fallback={<FakeChart />}>
|
|
24
|
+
* <Chart />
|
|
25
|
+
* </ClientOnly>
|
|
26
|
+
* )
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function ClientOnly({ children, fallback }: ClientOnlyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React__default from "react";
|
|
3
|
+
function ClientOnly({ children, fallback = null }) {
|
|
4
|
+
return useHydrated() ? /* @__PURE__ */ jsx(React__default.Fragment, { children }) : /* @__PURE__ */ jsx(React__default.Fragment, { children: fallback });
|
|
5
|
+
}
|
|
6
|
+
function useHydrated() {
|
|
7
|
+
return React__default.useSyncExternalStore(
|
|
8
|
+
subscribe,
|
|
9
|
+
() => true,
|
|
10
|
+
() => false
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
function subscribe() {
|
|
14
|
+
return () => {
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
ClientOnly
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=ClientOnly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientOnly.js","sources":["../../src/ClientOnly.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface ClientOnlyProps {\n /**\n * The children to render when the JS is loaded.\n */\n children: React.ReactNode\n /**\n * The fallback component to render if the JS is not yet loaded.\n */\n fallback?: React.ReactNode\n}\n\n/**\n * Render the children only after the JS has loaded client-side. Use an optional\n * fallback component if the JS is not yet loaded.\n *\n * @example\n * Render a Chart component if JS loads, renders a simple FakeChart\n * component server-side or if there is no JS. The FakeChart can have only the\n * UI without the behavior or be a loading spinner or skeleton.\n *\n * ```tsx\n * return (\n * <ClientOnly fallback={<FakeChart />}>\n * <Chart />\n * </ClientOnly>\n * )\n * ```\n */\nexport function ClientOnly({ children, fallback = null }: ClientOnlyProps) {\n return useHydrated() ? (\n <React.Fragment>{children}</React.Fragment>\n ) : (\n <React.Fragment>{fallback}</React.Fragment>\n )\n}\n\n/**\n * Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @example\n * ```tsx\n * // Disable a button that needs JS to work.\n * let hydrated = useHydrated()\n * return (\n * <button type=\"button\" disabled={!hydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * )\n * ```\n * @returns True if the JS has been hydrated already, false otherwise.\n */\nfunction useHydrated(): boolean {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n )\n}\n\nfunction subscribe() {\n return () => {}\n}\n"],"names":["React"],"mappings":";;AA8BO,SAAS,WAAW,EAAE,UAAU,WAAW,QAAyB;AACzE,SAAO,YAAY,IAChB,oBAAAA,eAAM,UAAN,EAAgB,SAAS,CAAA,IAEzB,oBAAAA,eAAM,UAAN,EAAgB,UAAS,SAAA,CAAA;AAE9B;AAqBA,SAAS,cAAuB;AAC9B,SAAOA,eAAM;AAAA,IACX;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACF;AAEA,SAAS,YAAY;AACnB,SAAO,MAAM;AAAA,EAAC;AAChB;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RouterManagedTag } from '@tanstack/router-core';
|
|
2
|
+
export declare const useTags: () => RouterManagedTag[];
|
|
3
|
+
/**
|
|
4
|
+
* @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.
|
|
5
|
+
* It should be rendered in the `<head>` of your document.
|
|
6
|
+
*/
|
|
7
|
+
export declare function HeadContent(): import("react/jsx-runtime").JSX.Element[];
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { Asset } from "./Asset.js";
|
|
4
|
+
import { useRouter } from "./useRouter.js";
|
|
5
|
+
import { useRouterState } from "./useRouterState.js";
|
|
6
|
+
const useTags = () => {
|
|
7
|
+
const router = useRouter();
|
|
8
|
+
const routeMeta = useRouterState({
|
|
9
|
+
select: (state) => {
|
|
10
|
+
return state.matches.map((match) => match.meta).filter(Boolean);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const meta = React.useMemo(() => {
|
|
14
|
+
const resultMeta = [];
|
|
15
|
+
const metaByAttribute = {};
|
|
16
|
+
let title;
|
|
17
|
+
[...routeMeta].reverse().forEach((metas) => {
|
|
18
|
+
[...metas].reverse().forEach((m) => {
|
|
19
|
+
if (!m) return;
|
|
20
|
+
if (m.title) {
|
|
21
|
+
if (!title) {
|
|
22
|
+
title = {
|
|
23
|
+
tag: "title",
|
|
24
|
+
children: m.title
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
const attribute = m.name ?? m.property;
|
|
29
|
+
if (attribute) {
|
|
30
|
+
if (metaByAttribute[attribute]) {
|
|
31
|
+
return;
|
|
32
|
+
} else {
|
|
33
|
+
metaByAttribute[attribute] = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
resultMeta.push({
|
|
37
|
+
tag: "meta",
|
|
38
|
+
attrs: {
|
|
39
|
+
...m
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
if (title) {
|
|
46
|
+
resultMeta.push(title);
|
|
47
|
+
}
|
|
48
|
+
resultMeta.reverse();
|
|
49
|
+
return resultMeta;
|
|
50
|
+
}, [routeMeta]);
|
|
51
|
+
const links = useRouterState({
|
|
52
|
+
select: (state) => {
|
|
53
|
+
var _a;
|
|
54
|
+
const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
|
|
55
|
+
tag: "link",
|
|
56
|
+
attrs: {
|
|
57
|
+
...link
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
const manifest = (_a = router.ssr) == null ? void 0 : _a.manifest;
|
|
61
|
+
const assets = state.matches.map((match) => {
|
|
62
|
+
var _a2;
|
|
63
|
+
return ((_a2 = manifest == null ? void 0 : manifest.routes[match.routeId]) == null ? void 0 : _a2.assets) ?? [];
|
|
64
|
+
}).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map(
|
|
65
|
+
(asset) => ({
|
|
66
|
+
tag: "link",
|
|
67
|
+
attrs: {
|
|
68
|
+
...asset.attrs,
|
|
69
|
+
suppressHydrationWarning: true
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
return [...constructed, ...assets];
|
|
74
|
+
},
|
|
75
|
+
structuralSharing: true
|
|
76
|
+
});
|
|
77
|
+
const preloadMeta = useRouterState({
|
|
78
|
+
select: (state) => {
|
|
79
|
+
const preloadMeta2 = [];
|
|
80
|
+
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
|
|
81
|
+
(route) => {
|
|
82
|
+
var _a, _b, _c, _d;
|
|
83
|
+
return (_d = (_c = (_b = (_a = router.ssr) == null ? void 0 : _a.manifest) == null ? void 0 : _b.routes[route.id]) == null ? void 0 : _c.preloads) == null ? void 0 : _d.filter(Boolean).forEach((preload) => {
|
|
84
|
+
preloadMeta2.push({
|
|
85
|
+
tag: "link",
|
|
86
|
+
attrs: {
|
|
87
|
+
rel: "modulepreload",
|
|
88
|
+
href: preload
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
return preloadMeta2;
|
|
95
|
+
},
|
|
96
|
+
structuralSharing: true
|
|
97
|
+
});
|
|
98
|
+
const headScripts = useRouterState({
|
|
99
|
+
select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
100
|
+
tag: "script",
|
|
101
|
+
attrs: {
|
|
102
|
+
...script
|
|
103
|
+
},
|
|
104
|
+
children
|
|
105
|
+
})),
|
|
106
|
+
structuralSharing: true
|
|
107
|
+
});
|
|
108
|
+
return uniqBy(
|
|
109
|
+
[
|
|
110
|
+
...meta,
|
|
111
|
+
...preloadMeta,
|
|
112
|
+
...links,
|
|
113
|
+
...headScripts
|
|
114
|
+
],
|
|
115
|
+
(d) => {
|
|
116
|
+
return JSON.stringify(d);
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
function HeadContent() {
|
|
121
|
+
const tags = useTags();
|
|
122
|
+
return tags.map((tag) => /* @__PURE__ */ createElement(Asset, { ...tag, key: `tsr-meta-${JSON.stringify(tag)}` }));
|
|
123
|
+
}
|
|
124
|
+
function uniqBy(arr, fn) {
|
|
125
|
+
const seen = /* @__PURE__ */ new Set();
|
|
126
|
+
return arr.filter((item) => {
|
|
127
|
+
const key = fn(item);
|
|
128
|
+
if (seen.has(key)) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
seen.add(key);
|
|
132
|
+
return true;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
HeadContent,
|
|
137
|
+
useTags
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=HeadContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeadContent.js","sources":["../../src/HeadContent.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Asset } from './Asset'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport type { RouterManagedTag } from '@tanstack/router-core'\n\nexport const useTags = () => {\n const router = useRouter()\n\n const routeMeta = useRouterState({\n select: (state) => {\n return state.matches.map((match) => match.meta!).filter(Boolean)\n },\n })\n\n const meta: Array<RouterManagedTag> = React.useMemo(() => {\n const resultMeta: Array<RouterManagedTag> = []\n const metaByAttribute: Record<string, true> = {}\n let title: RouterManagedTag | undefined\n ;[...routeMeta].reverse().forEach((metas) => {\n ;[...metas].reverse().forEach((m) => {\n if (!m) return\n\n if (m.title) {\n if (!title) {\n title = {\n tag: 'title',\n children: m.title,\n }\n }\n } else {\n const attribute = m.name ?? m.property\n if (attribute) {\n if (metaByAttribute[attribute]) {\n return\n } else {\n metaByAttribute[attribute] = true\n }\n }\n\n resultMeta.push({\n tag: 'meta',\n attrs: {\n ...m,\n },\n })\n }\n })\n })\n\n if (title) {\n resultMeta.push(title)\n }\n\n resultMeta.reverse()\n\n return resultMeta\n }, [routeMeta])\n\n const links = useRouterState({\n select: (state) => {\n const constructed = state.matches\n .map((match) => match.links!)\n .filter(Boolean)\n .flat(1)\n .map((link) => ({\n tag: 'link',\n attrs: {\n ...link,\n },\n })) satisfies Array<RouterManagedTag>\n\n const manifest = router.ssr?.manifest\n\n // These are the assets extracted from the ViteManifest\n // using the `startManifestPlugin`\n const assets = state.matches\n .map((match) => manifest?.routes[match.routeId]?.assets ?? [])\n .filter(Boolean)\n .flat(1)\n .filter((asset) => asset.tag === 'link')\n .map(\n (asset) =>\n ({\n tag: 'link',\n attrs: {\n ...asset.attrs,\n suppressHydrationWarning: true,\n },\n }) satisfies RouterManagedTag,\n )\n\n return [...constructed, ...assets]\n },\n structuralSharing: true as any,\n })\n\n const preloadMeta = useRouterState({\n select: (state) => {\n const preloadMeta: Array<RouterManagedTag> = []\n\n state.matches\n .map((match) => router.looseRoutesById[match.routeId]!)\n .forEach((route) =>\n router.ssr?.manifest?.routes[route.id]?.preloads\n ?.filter(Boolean)\n .forEach((preload) => {\n preloadMeta.push({\n tag: 'link',\n attrs: {\n rel: 'modulepreload',\n href: preload,\n },\n })\n }),\n )\n\n return preloadMeta\n },\n structuralSharing: true as any,\n })\n\n const headScripts = useRouterState({\n select: (state) =>\n (\n state.matches\n .map((match) => match.headScripts!)\n .flat(1)\n .filter(Boolean) as Array<RouterManagedTag>\n ).map(({ children, ...script }) => ({\n tag: 'script',\n attrs: {\n ...script,\n },\n children,\n })),\n structuralSharing: true as any,\n })\n\n return uniqBy(\n [\n ...meta,\n ...preloadMeta,\n ...links,\n ...headScripts,\n ] as Array<RouterManagedTag>,\n (d) => {\n return JSON.stringify(d)\n },\n )\n}\n\n/**\n * @description The `HeadContent` component is used to render meta tags, links, and scripts for the current route.\n * It should be rendered in the `<head>` of your document.\n */\nexport function HeadContent() {\n const tags = useTags()\n return tags.map((tag) => (\n <Asset {...tag} key={`tsr-meta-${JSON.stringify(tag)}`} />\n ))\n}\n\nfunction uniqBy<T>(arr: Array<T>, fn: (item: T) => string) {\n const seen = new Set<string>()\n return arr.filter((item) => {\n const key = fn(item)\n if (seen.has(key)) {\n return false\n }\n seen.add(key)\n return true\n })\n}\n"],"names":["_a","preloadMeta"],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare const Match: React.NamedExoticComponent<{
|
|
3
|
+
matchId: string;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const MatchInner: React.NamedExoticComponent<{
|
|
6
|
+
matchId: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const Outlet: React.NamedExoticComponent<object>;
|