@tanstack/react-router 0.0.1-beta.219 → 0.0.1-beta.220

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.
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import { RouterHistory } from '@tanstack/history'\n\n//\n\nimport {\n AnySearchSchema,\n AnyRoute,\n AnyContext,\n AnyPathParams,\n RouteMask,\n} from './route'\nimport { FullSearchSchema } from './routeInfo'\nimport { defaultParseSearch, defaultStringifySearch } from './searchParams'\nimport { PickAsRequired, Updater, NonNullableUpdater } from './utils'\nimport {\n ErrorRouteComponent,\n PendingRouteComponent,\n RouteComponent,\n} from './route'\nimport { RouteMatch } from './RouterProvider'\nimport { ParsedLocation } from './location'\nimport { LocationState } from './location'\nimport { SearchSerializer, SearchParser } from './searchParams'\nimport { RouterContext } from './RouterProvider'\n\n//\n\ndeclare global {\n interface Window {\n __TSR_DEHYDRATED__?: HydrationCtx\n __TSR_ROUTER_CONTEXT__?: React.Context<RouterContext<any>>\n }\n}\n\nexport interface Register {\n // router: Router\n}\n\nexport type AnyRouter = Router<AnyRoute, any>\n\nexport type RegisteredRouter = Register extends {\n router: infer TRouter extends AnyRouter\n}\n ? TRouter\n : AnyRouter\n\nexport type HydrationCtx = {\n router: DehydratedRouter\n payload: Record<string, any>\n}\n\nexport type RouterContextOptions<TRouteTree extends AnyRoute> =\n AnyContext extends TRouteTree['types']['routerContext']\n ? {\n context?: TRouteTree['types']['routerContext']\n }\n : {\n context: TRouteTree['types']['routerContext']\n }\n\nexport interface RouterOptions<\n TRouteTree extends AnyRoute,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> {\n history?: RouterHistory\n stringifySearch?: SearchSerializer\n parseSearch?: SearchParser\n defaultPreload?: false | 'intent'\n defaultPreloadDelay?: number\n defaultComponent?: RouteComponent<AnySearchSchema, AnyPathParams, AnyContext>\n defaultErrorComponent?: ErrorRouteComponent<\n AnySearchSchema,\n AnyPathParams,\n AnyContext\n >\n defaultPendingComponent?: PendingRouteComponent<\n AnySearchSchema,\n AnyPathParams,\n AnyContext\n >\n defaultMaxAge?: number\n defaultGcMaxAge?: number\n defaultPreloadMaxAge?: number\n caseSensitive?: boolean\n routeTree?: TRouteTree\n basepath?: string\n createRoute?: (opts: { route: AnyRoute; router: AnyRouter }) => void\n context?: TRouteTree['types']['routerContext']\n // dehydrate?: () => TDehydrated\n // hydrate?: (dehydrated: TDehydrated) => void\n routeMasks?: RouteMask<TRouteTree>[]\n unmaskOnReload?: boolean\n}\n\nexport interface RouterState<TRouteTree extends AnyRoute = AnyRoute> {\n status: 'pending' | 'idle'\n matches: RouteMatch<TRouteTree>[]\n pendingMatches: RouteMatch<TRouteTree>[]\n location: ParsedLocation<FullSearchSchema<TRouteTree>>\n resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>\n lastUpdated: number\n}\n\nexport type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void\n\nexport interface BuildNextOptions {\n to?: string | number | null\n params?: true | Updater<unknown>\n search?: true | Updater<unknown>\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<LocationState>\n mask?: {\n to?: string | number | null\n params?: true | Updater<unknown>\n search?: true | Updater<unknown>\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<LocationState>\n unmaskOnReload?: boolean\n }\n from?: string\n}\n\nexport interface DehydratedRouterState {\n dehydratedMatches: DehydratedRouteMatch[]\n}\n\nexport type DehydratedRouteMatch = Pick<\n RouteMatch,\n 'fetchedAt' | 'invalid' | 'id' | 'status' | 'updatedAt'\n>\n\nexport interface DehydratedRouter {\n state: DehydratedRouterState\n}\n\nexport type RouterConstructorOptions<\n TRouteTree extends AnyRoute,\n TDehydrated extends Record<string, any>,\n> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> &\n RouterContextOptions<TRouteTree>\n\nexport const componentTypes = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n] as const\n\nexport type RouterEvents = {\n onBeforeLoad: {\n type: 'onBeforeLoad'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onLoad: {\n type: 'onLoad'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onResolved: {\n type: 'onResolved'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n}\n\nexport type RouterEvent = RouterEvents[keyof RouterEvents]\n\nexport type RouterListener<TRouterEvent extends RouterEvent> = {\n eventType: TRouterEvent['type']\n fn: ListenerFn<TRouterEvent>\n}\n\nexport class Router<\n TRouteTree extends AnyRoute = AnyRoute,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> {\n options: PickAsRequired<\n RouterOptions<TRouteTree, TDehydrated>,\n 'stringifySearch' | 'parseSearch' | 'context'\n >\n routeTree: TRouteTree\n // dehydratedData?: TDehydrated\n // resetNextScroll = false\n // tempLocationKey = `${Math.round(Math.random() * 10000000)}`\n\n constructor(options: RouterConstructorOptions<TRouteTree, TDehydrated>) {\n this.options = {\n defaultPreloadDelay: 50,\n context: undefined!,\n ...options,\n stringifySearch: options?.stringifySearch ?? defaultStringifySearch,\n parseSearch: options?.parseSearch ?? defaultParseSearch,\n }\n\n this.routeTree = this.options.routeTree as TRouteTree\n }\n\n subscribers = new Set<RouterListener<RouterEvent>>()\n\n subscribe = <TType extends keyof RouterEvents>(\n eventType: TType,\n fn: ListenerFn<RouterEvents[TType]>,\n ) => {\n const listener: RouterListener<any> = {\n eventType,\n fn,\n }\n\n this.subscribers.add(listener)\n\n return () => {\n this.subscribers.delete(listener)\n }\n }\n\n emit = (routerEvent: RouterEvent) => {\n this.subscribers.forEach((listener) => {\n if (listener.eventType === routerEvent.type) {\n listener.fn(routerEvent)\n }\n })\n }\n\n // dehydrate = (): DehydratedRouter => {\n // return {\n // state: {\n // dehydratedMatches: state.matches.map((d) =>\n // pick(d, ['fetchedAt', 'invalid', 'id', 'status', 'updatedAt']),\n // ),\n // },\n // }\n // }\n\n // hydrate = async (__do_not_use_server_ctx?: HydrationCtx) => {\n // let _ctx = __do_not_use_server_ctx\n // // Client hydrates from window\n // if (typeof document !== 'undefined') {\n // _ctx = window.__TSR_DEHYDRATED__\n // }\n\n // invariant(\n // _ctx,\n // 'Expected to find a __TSR_DEHYDRATED__ property on window... but we did not. Did you forget to render <DehydrateRouter /> in your app?',\n // )\n\n // const ctx = _ctx\n // this.dehydratedData = ctx.payload as any\n // this.options.hydrate?.(ctx.payload as any)\n // const dehydratedState = ctx.router.state\n\n // let matches = this.matchRoutes(\n // state.location.pathname,\n // state.location.search,\n // ).map((match) => {\n // const dehydratedMatch = dehydratedState.dehydratedMatches.find(\n // (d) => d.id === match.id,\n // )\n\n // invariant(\n // dehydratedMatch,\n // `Could not find a client-side match for dehydrated match with id: ${match.id}!`,\n // )\n\n // if (dehydratedMatch) {\n // return {\n // ...match,\n // ...dehydratedMatch,\n // }\n // }\n // return match\n // })\n\n // this.setState((s) => {\n // return {\n // ...s,\n // matches: dehydratedState.dehydratedMatches as any,\n // }\n // })\n // }\n\n // TODO:\n // injectedHtml: (string | (() => Promise<string> | string))[] = []\n\n // TODO:\n // injectHtml = async (html: string | (() => Promise<string> | string)) => {\n // this.injectedHtml.push(html)\n // }\n\n // TODO:\n // dehydrateData = <T>(key: any, getData: T | (() => Promise<T> | T)) => {\n // if (typeof document === 'undefined') {\n // const strKey = typeof key === 'string' ? key : JSON.stringify(key)\n\n // this.injectHtml(async () => {\n // const id = `__TSR_DEHYDRATED__${strKey}`\n // const data =\n // typeof getData === 'function' ? await (getData as any)() : getData\n // return `<script id='${id}' suppressHydrationWarning>window[\"__TSR_DEHYDRATED__${escapeJSON(\n // strKey,\n // )}\"] = ${JSON.stringify(data)}\n // ;(() => {\n // var el = document.getElementById('${id}')\n // el.parentElement.removeChild(el)\n // })()\n // </script>`\n // })\n\n // return () => this.hydrateData<T>(key)\n // }\n\n // return () => undefined\n // }\n\n // hydrateData = <T = unknown>(key: any) => {\n // if (typeof document !== 'undefined') {\n // const strKey = typeof key === 'string' ? key : JSON.stringify(key)\n\n // return window[`__TSR_DEHYDRATED__${strKey}` as any] as T\n // }\n\n // return undefined\n // }\n\n // resolveMatchPromise = (matchId: string, key: string, value: any) => {\n // state.matches\n // .find((d) => d.id === matchId)\n // ?.__promisesByKey[key]?.resolve(value)\n // }\n\n // setRouteMatch = (\n // id: string,\n // pending: boolean,\n // updater: NonNullableUpdater<RouteMatch<TRouteTree>>,\n // ) => {\n // const key = pending ? 'pendingMatches' : 'matches'\n\n // this.setState((prev) => {\n // return {\n // ...prev,\n // [key]: prev[key].map((d) => {\n // if (d.id === id) {\n // return functionalUpdate(updater, d)\n // }\n\n // return d\n // }),\n // }\n // })\n // }\n\n // setPendingRouteMatch = (\n // id: string,\n // updater: NonNullableUpdater<RouteMatch<TRouteTree>>,\n // ) => {\n // this.setRouteMatch(id, true, updater)\n // }\n}\n\nfunction escapeJSON(jsonString: string) {\n return jsonString\n .replace(/\\\\/g, '\\\\\\\\') // Escape backslashes\n .replace(/'/g, \"\\\\'\") // Escape single quotes\n .replace(/\"/g, '\\\\\"') // Escape double quotes\n}\n\n// A function that takes an import() argument which is a function and returns a new function that will\n// proxy arguments from the caller to the imported function, retaining all type\n// information along the way\nexport function lazyFn<\n T extends Record<string, (...args: any[]) => any>,\n TKey extends keyof T = 'default',\n>(fn: () => Promise<T>, key?: TKey) {\n return async (...args: Parameters<T[TKey]>): Promise<ReturnType<T[TKey]>> => {\n const imported = await fn()\n return imported[key || 'default'](...args)\n }\n}\n"],"names":["componentTypes","Router","constructor","options","defaultPreloadDelay","context","undefined","stringifySearch","defaultStringifySearch","parseSearch","defaultParseSearch","routeTree","subscribers","Set","subscribe","eventType","fn","listener","add","delete","emit","routerEvent","forEach","type","lazyFn","key","args","imported"],"mappings":";;;;;;;;;;;;;;;;AAEA;;AAuBA;;AAoHO,MAAMA,cAAc,GAAG,CAC5B,WAAW,EACX,gBAAgB,EAChB,kBAAkB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EA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACF,CAAA;;AASA;AACA;AACA;AACO,SAASG,MAAMA,CAGpBR,EAAoB,EAAES,GAAU,EAAE;EAClC,OAAO,OAAO,GAAGC,IAAyB,KAAmC;AAC3E,IAAA,MAAMC,QAAQ,GAAG,MAAMX,EAAE,EAAE,CAAA;IAC3B,OAAOW,QAAQ,CAACF,GAAG,IAAI,SAAS,CAAC,CAAC,GAAGC,IAAI,CAAC,CAAA;GAC3C,CAAA;AACH;;;;;;"}
1
+ {"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import { RouterHistory } from '@tanstack/history'\n\n//\n\nimport {\n AnySearchSchema,\n AnyRoute,\n AnyContext,\n AnyPathParams,\n RouteMask,\n} from './route'\nimport { FullSearchSchema } from './routeInfo'\nimport { defaultParseSearch, defaultStringifySearch } from './searchParams'\nimport { PickAsRequired, Updater, NonNullableUpdater } from './utils'\nimport {\n ErrorRouteComponent,\n PendingRouteComponent,\n RouteComponent,\n} from './route'\nimport { RouteMatch } from './RouterProvider'\nimport { ParsedLocation } from './location'\nimport { LocationState } from './location'\nimport { SearchSerializer, SearchParser } from './searchParams'\nimport { RouterContext } from './RouterProvider'\n\n//\n\ndeclare global {\n interface Window {\n __TSR_DEHYDRATED__?: HydrationCtx\n __TSR_ROUTER_CONTEXT__?: React.Context<RouterContext<any>>\n }\n}\n\nexport interface Register {\n // router: Router\n}\n\nexport type AnyRouter = Router<AnyRoute, any>\n\nexport type RegisteredRouter = Register extends {\n router: infer TRouter extends AnyRouter\n}\n ? TRouter\n : AnyRouter\n\nexport type HydrationCtx = {\n router: DehydratedRouter\n payload: Record<string, any>\n}\n\nexport type RouterContextOptions<TRouteTree extends AnyRoute> =\n AnyContext extends TRouteTree['types']['routerContext']\n ? {\n context?: TRouteTree['types']['routerContext']\n }\n : {\n context: TRouteTree['types']['routerContext']\n }\n\nexport interface RouterOptions<\n TRouteTree extends AnyRoute,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> {\n history?: RouterHistory\n stringifySearch?: SearchSerializer\n parseSearch?: SearchParser\n defaultPreload?: false | 'intent'\n defaultPreloadDelay?: number\n defaultComponent?: RouteComponent<AnySearchSchema, AnyPathParams, AnyContext>\n defaultErrorComponent?: ErrorRouteComponent<\n AnySearchSchema,\n AnyPathParams,\n AnyContext\n >\n defaultPendingComponent?: PendingRouteComponent<\n AnySearchSchema,\n AnyPathParams,\n AnyContext\n >\n defaultMaxAge?: number\n defaultGcMaxAge?: number\n defaultPreloadMaxAge?: number\n caseSensitive?: boolean\n routeTree?: TRouteTree\n basepath?: string\n createRoute?: (opts: { route: AnyRoute; router: AnyRouter }) => void\n context?: TRouteTree['types']['routerContext']\n // dehydrate?: () => TDehydrated\n // hydrate?: (dehydrated: TDehydrated) => void\n routeMasks?: RouteMask<TRouteTree>[]\n unmaskOnReload?: boolean\n}\n\nexport interface RouterState<TRouteTree extends AnyRoute = AnyRoute> {\n status: 'pending' | 'idle'\n matches: RouteMatch<TRouteTree>[]\n pendingMatches: RouteMatch<TRouteTree>[]\n location: ParsedLocation<FullSearchSchema<TRouteTree>>\n resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>\n lastUpdated: number\n}\n\nexport type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void\n\nexport interface BuildNextOptions {\n to?: string | number | null\n params?: true | Updater<unknown>\n search?: true | Updater<unknown>\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<LocationState>\n mask?: {\n to?: string | number | null\n params?: true | Updater<unknown>\n search?: true | Updater<unknown>\n hash?: true | Updater<string>\n state?: true | NonNullableUpdater<LocationState>\n unmaskOnReload?: boolean\n }\n from?: string\n}\n\nexport interface DehydratedRouterState {\n dehydratedMatches: DehydratedRouteMatch[]\n}\n\nexport type DehydratedRouteMatch = Pick<\n RouteMatch,\n 'fetchedAt' | 'invalid' | 'id' | 'status' | 'updatedAt'\n>\n\nexport interface DehydratedRouter {\n state: DehydratedRouterState\n}\n\nexport type RouterConstructorOptions<\n TRouteTree extends AnyRoute,\n TDehydrated extends Record<string, any>,\n> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> &\n RouterContextOptions<TRouteTree>\n\nexport const componentTypes = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n] as const\n\nexport type RouterEvents = {\n onBeforeLoad: {\n type: 'onBeforeLoad'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onLoad: {\n type: 'onLoad'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n onResolved: {\n type: 'onResolved'\n fromLocation: ParsedLocation\n toLocation: ParsedLocation\n pathChanged: boolean\n }\n}\n\nexport type RouterEvent = RouterEvents[keyof RouterEvents]\n\nexport type RouterListener<TRouterEvent extends RouterEvent> = {\n eventType: TRouterEvent['type']\n fn: ListenerFn<TRouterEvent>\n}\n\nexport class Router<\n TRouteTree extends AnyRoute = AnyRoute,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> {\n options: PickAsRequired<\n RouterOptions<TRouteTree, TDehydrated>,\n 'stringifySearch' | 'parseSearch' | 'context'\n >\n routeTree: TRouteTree\n // dehydratedData?: TDehydrated\n // resetNextScroll = false\n // tempLocationKey = `${Math.round(Math.random() * 10000000)}`\n\n constructor(options: RouterConstructorOptions<TRouteTree, TDehydrated>) {\n this.options = {\n defaultPreloadDelay: 50,\n context: undefined!,\n ...options,\n stringifySearch: options?.stringifySearch ?? defaultStringifySearch,\n parseSearch: options?.parseSearch ?? defaultParseSearch,\n }\n\n this.routeTree = this.options.routeTree as TRouteTree\n }\n\n subscribers = new Set<RouterListener<RouterEvent>>()\n\n subscribe = <TType extends keyof RouterEvents>(\n eventType: TType,\n fn: ListenerFn<RouterEvents[TType]>,\n ) => {\n const listener: RouterListener<any> = {\n eventType,\n fn,\n }\n\n this.subscribers.add(listener)\n\n return () => {\n this.subscribers.delete(listener)\n }\n }\n\n emit = (routerEvent: RouterEvent) => {\n this.subscribers.forEach((listener) => {\n if (listener.eventType === routerEvent.type) {\n listener.fn(routerEvent)\n }\n })\n }\n\n // dehydrate = (): DehydratedRouter => {\n // return {\n // state: {\n // dehydratedMatches: state.matches.map((d) =>\n // pick(d, ['fetchedAt', 'invalid', 'id', 'status', 'updatedAt']),\n // ),\n // },\n // }\n // }\n\n // hydrate = async (__do_not_use_server_ctx?: HydrationCtx) => {\n // let _ctx = __do_not_use_server_ctx\n // // Client hydrates from window\n // if (typeof document !== 'undefined') {\n // _ctx = window.__TSR_DEHYDRATED__\n // }\n\n // invariant(\n // _ctx,\n // 'Expected to find a __TSR_DEHYDRATED__ property on window... but we did not. Did you forget to render <DehydrateRouter /> in your app?',\n // )\n\n // const ctx = _ctx\n // this.dehydratedData = ctx.payload as any\n // this.options.hydrate?.(ctx.payload as any)\n // const dehydratedState = ctx.router.state\n\n // let matches = this.matchRoutes(\n // state.location.pathname,\n // state.location.search,\n // ).map((match) => {\n // const dehydratedMatch = dehydratedState.dehydratedMatches.find(\n // (d) => d.id === match.id,\n // )\n\n // invariant(\n // dehydratedMatch,\n // `Could not find a client-side match for dehydrated match with id: ${match.id}!`,\n // )\n\n // if (dehydratedMatch) {\n // return {\n // ...match,\n // ...dehydratedMatch,\n // }\n // }\n // return match\n // })\n\n // this.setState((s) => {\n // return {\n // ...s,\n // matches: dehydratedState.dehydratedMatches as any,\n // }\n // })\n // }\n\n // resolveMatchPromise = (matchId: string, key: string, value: any) => {\n // state.matches\n // .find((d) => d.id === matchId)\n // ?.__promisesByKey[key]?.resolve(value)\n // }\n\n // setRouteMatch = (\n // id: string,\n // pending: boolean,\n // updater: NonNullableUpdater<RouteMatch<TRouteTree>>,\n // ) => {\n // const key = pending ? 'pendingMatches' : 'matches'\n\n // this.setState((prev) => {\n // return {\n // ...prev,\n // [key]: prev[key].map((d) => {\n // if (d.id === id) {\n // return functionalUpdate(updater, d)\n // }\n\n // return d\n // }),\n // }\n // })\n // }\n\n // setPendingRouteMatch = (\n // id: string,\n // updater: NonNullableUpdater<RouteMatch<TRouteTree>>,\n // ) => {\n // this.setRouteMatch(id, true, updater)\n // }\n}\n\n// A function that takes an import() argument which is a function and returns a new function that will\n// proxy arguments from the caller to the imported function, retaining all type\n// information along the way\nexport function lazyFn<\n T extends Record<string, (...args: any[]) => any>,\n TKey extends keyof T = 'default',\n>(fn: () => Promise<T>, key?: TKey) {\n return async (...args: Parameters<T[TKey]>): Promise<ReturnType<T[TKey]>> => {\n const imported = await fn()\n return imported[key || 'default'](...args)\n }\n}\n"],"names":["componentTypes","Router","constructor","options","defaultPreloadDelay","context","undefined","stringifySearch","defaultStringifySearch","parseSearch","defaultParseSearch","routeTree","subscribers","Set","subscribe","eventType","fn","listener","add","delete","emit","routerEvent","forEach","type","lazyFn","key","args","imported"],"mappings":";;;;;;;;;;;;;;;;AAEA;;AAuBA;;AAoHO,MAAMA,cAAc,GAAG,CAC5B,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EACV;AA8BH,MAAMC,MAAM,CAGjB;AAMA;AACA;AACA;EAEAC,WAAWA,CAACC,OAA0D,EAAE;IACtE,IAAI,CAACA,OAAO,GAAG;AACbC,MAAAA,mBAAmB,EAAE,EAAE;AACvBC,MAAAA,OAAO,EAAEC,SAAU;AACnB,MAAA,GAAGH,OAAO;AACVI,MAAAA,eAAe,EAAEJ,OAAO,EAAEI,eA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F,CAAA;;AAEA;AACA;AACA;AACO,SAASG,MAAMA,CAGpBR,EAAoB,EAAES,GAAU,EAAE;EAClC,OAAO,OAAO,GAAGC,IAAyB,KAAmC;AAC3E,IAAA,MAAMC,QAAQ,GAAG,MAAMX,EAAE,EAAE,CAAA;IAC3B,OAAOW,QAAQ,CAACF,GAAG,IAAI,SAAS,CAAC,CAAC,GAAGC,IAAI,CAAC,CAAA;GAC3C,CAAA;AACH;;;;;;"}
@@ -215,8 +215,14 @@ function useRouteContext(opts) {
215
215
  });
216
216
  }
217
217
  const useLayoutEffect = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
218
+ function escapeJSON(jsonString) {
219
+ return jsonString.replace(/\\/g, '\\\\') // Escape backslashes
220
+ .replace(/'/g, "\\'") // Escape single quotes
221
+ .replace(/"/g, '\\"'); // Escape double quotes
222
+ }
218
223
 
219
224
  exports.deepEqual = deepEqual;
225
+ exports.escapeJSON = escapeJSON;
220
226
  exports.functionalUpdate = functionalUpdate;
221
227
  exports.isPlainObject = isPlainObject;
222
228
  exports.isServer = isServer;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["import * as React from 'react'\nimport { useMatch } from './Matches'\nimport { RouteMatch } from './RouterProvider'\nimport { AnyRoute } from './route'\nimport { ParseRoute, RouteIds, RoutesById, RouteById } from './routeInfo'\nimport { RegisteredRouter } from './router'\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\nexport type IsAny<T, Y, N = T> = 1 extends 0 & T ? Y : N\nexport type IsAnyBoolean<T> = 1 extends 0 & T ? true : false\nexport type IsKnown<T, Y, N> = unknown extends T ? N : Y\nexport type PickAsRequired<T, K extends keyof T> = Omit<T, K> &\n Required<Pick<T, K>>\nexport type PickAsPartial<T, K extends keyof T> = Omit<T, K> &\n Partial<Pick<T, K>>\nexport type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never\nexport type PickExtra<T, K> = {\n [TKey in keyof K as string extends TKey\n ? never\n : TKey extends keyof T\n ? never\n : TKey]: K[TKey]\n}\n\nexport type PickRequired<T> = {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K]\n}\n\n// export type Expand<T> = T\nexport type Expand<T> = T extends object\n ? T extends infer O\n ? { [K in keyof O]: O[K] }\n : never\n : T\n\nexport type UnionToIntersection<U> = (\n U extends any ? (k: U) => void : never\n) extends (k: infer I) => any\n ? I\n : never\n\n// type Compute<T> = { [K in keyof T]: T[K] } | never\n\n// type AllKeys<T> = T extends any ? keyof T : never\n\n// export type MergeUnion<T, Keys extends keyof T = keyof T> = Compute<\n// {\n// [K in Keys]: T[Keys]\n// } & {\n// [K in AllKeys<T>]?: T extends any\n// ? K extends keyof T\n// ? T[K]\n// : never\n// : never\n// }\n// >\n\nexport type Assign<Left, Right> = Omit<Left, keyof Right> & Right\n\nexport type AssignAll<T extends any[]> = T extends [infer Left, ...infer Right]\n ? Right extends any[]\n ? Assign<Left, AssignAll<Right>>\n : Left\n : {}\n\n// // Sample types to merge\n// type TypeA = {\n// shared: string\n// onlyInA: string\n// nested: {\n// shared: string\n// aProp: string\n// }\n// array: string[]\n// }\n\n// type TypeB = {\n// shared: number\n// onlyInB: number\n// nested: {\n// shared: number\n// bProp: number\n// }\n// array: number[]\n// }\n\n// type TypeC = {\n// shared: boolean\n// onlyInC: boolean\n// nested: {\n// shared: boolean\n// cProp: boolean\n// }\n// array: boolean[]\n// }\n\n// type Test = Expand<Assign<TypeA, TypeB>>\n\n// // Using DeepMerge to merge TypeA and TypeB\n// type MergedType = Expand<AssignAll<[TypeA, TypeB, TypeC]>>\n\nexport type Values<O> = O[ValueKeys<O>]\nexport type ValueKeys<O> = Extract<keyof O, PropertyKey>\n\nexport type DeepAwaited<T> = T extends Promise<infer A>\n ? DeepAwaited<A>\n : T extends Record<infer A, Promise<infer B>>\n ? { [K in A]: DeepAwaited<B> }\n : T\n\nexport type PathParamMask<TRoutePath extends string> =\n TRoutePath extends `${infer L}/$${infer C}/${infer R}`\n ? PathParamMask<`${L}/${string}/${R}`>\n : TRoutePath extends `${infer L}/$${infer C}`\n ? PathParamMask<`${L}/${string}`>\n : TRoutePath\n\nexport type Timeout = ReturnType<typeof setTimeout>\n\nexport type Updater<TPrevious, TResult = TPrevious> =\n | TResult\n | ((prev?: TPrevious) => TResult)\n\nexport type NonNullableUpdater<TPrevious, TResult = TPrevious> =\n | TResult\n | ((prev: TPrevious) => TResult)\n\nexport type PickExtract<T, U> = {\n [K in keyof T as T[K] extends U ? K : never]: T[K]\n}\n\nexport type PickExclude<T, U> = {\n [K in keyof T as T[K] extends U ? never : K]: T[K]\n}\n\n//\n\nexport const isServer = typeof document === 'undefined'\n\nexport function last<T>(arr: T[]) {\n return arr[arr.length - 1]\n}\n\nfunction isFunction(d: any): d is Function {\n return typeof d === 'function'\n}\n\nexport function functionalUpdate<TResult>(\n updater: Updater<TResult> | NonNullableUpdater<TResult>,\n previous: TResult,\n): TResult {\n if (isFunction(updater)) {\n return updater(previous as TResult)\n }\n\n return updater\n}\n\nexport function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K> {\n return keys.reduce((obj: any, key: K) => {\n obj[key] = parent[key]\n return obj\n }, {} as any)\n}\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between immutable JSON values for example.\n * Do not use this with signals\n */\nexport function replaceEqualDeep<T>(prev: any, _next: T): T {\n if (prev === _next) {\n return prev\n }\n\n const next = _next as any\n\n const array = Array.isArray(prev) && Array.isArray(next)\n\n if (array || (isPlainObject(prev) && isPlainObject(next))) {\n const prevSize = array ? prev.length : Object.keys(prev).length\n const nextItems = array ? next : Object.keys(next)\n const nextSize = nextItems.length\n const copy: any = array ? [] : {}\n\n let equalItems = 0\n\n for (let i = 0; i < nextSize; i++) {\n const key = array ? i : nextItems[i]\n copy[key] = replaceEqualDeep(prev[key], next[key])\n if (copy[key] === prev[key]) {\n equalItems++\n }\n }\n\n return prevSize === nextSize && equalItems === prevSize ? prev : copy\n }\n\n return next\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any) {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has modified constructor\n const ctor = o.constructor\n if (typeof ctor === 'undefined') {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any) {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function deepEqual(a: any, b: any, partial: boolean = false): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n\n if (!partial && aKeys.length !== bKeys.length) {\n return false\n }\n\n return !bKeys.some(\n (key) => !(key in a) || !deepEqual(a[key], b[key], partial),\n )\n }\n\n if (Array.isArray(a) && Array.isArray(b)) {\n return !a.some((item, index) => !deepEqual(item, b[index], partial))\n }\n\n return false\n}\n\nexport function useStableCallback<T extends (...args: any[]) => any>(fn: T): T {\n const fnRef = React.useRef(fn)\n fnRef.current = fn\n\n const ref = React.useRef((...args: any[]) => fnRef.current(...args))\n return ref.current as T\n}\n\nexport function shallow<T>(objA: T, objB: T) {\n if (Object.is(objA, objB)) {\n return true\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false\n }\n\n const keysA = Object.keys(objA)\n if (keysA.length !== Object.keys(objB).length) {\n return false\n }\n\n for (let i = 0; i < keysA.length; i++) {\n if (\n !Object.prototype.hasOwnProperty.call(objB, keysA[i] as string) ||\n !Object.is(objA[keysA[i] as keyof T], objB[keysA[i] as keyof T])\n ) {\n return false\n }\n }\n return true\n}\n\nexport type StrictOrFrom<TFrom> =\n | {\n from: TFrom\n strict?: true\n }\n | {\n from?: never\n strict: false\n }\n\nexport type RouteFromIdOrRoute<\n T,\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n> = T extends ParseRoute<TRouteTree>\n ? T\n : T extends RouteIds<TRouteTree>\n ? RoutesById<TRouteTree>[T]\n : T extends string\n ? RouteIds<TRouteTree>\n : never\n\nexport function useRouteContext<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n TRouteContext = RouteById<TRouteTree, TFrom>['types']['allContext'],\n TSelected = TRouteContext,\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (search: TRouteContext) => TSelected\n },\n): TStrict extends true ? TSelected : TSelected | undefined {\n return useMatch({\n ...(opts as any),\n select: (match: RouteMatch) =>\n opts?.select\n ? opts.select(match.context as TRouteContext)\n : match.context,\n })\n}\n\nexport const useLayoutEffect =\n typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect\n"],"names":["isServer","document","last","arr","length","isFunction","d","functionalUpdate","updater","previous","pick","parent","keys","reduce","obj","key","replaceEqualDeep","prev","_next","next","array","Array","isArray","isPlainObject","prevSize","Object","nextItems","nextSize","copy","equalItems","i","o","hasObjectPrototype","ctor","constructor","prot","prototype","hasOwnProperty","toString","call","deepEqual","a","b","partial","aKeys","bKeys","some","item","index","useStableCallback","fn","fnRef","React","useRef","current","ref","args","shallow","objA","objB","is","keysA","useRouteContext","opts","useMatch","select","match","context","useLayoutEffect","window","useEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AAaA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;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M,CAACb,IAAI,CAAC+C,IAAI,CAAC,CAACvD,MAAM,EAAE;AAC7C,IAAA,OAAO,KAAK,CAAA;AACd,GAAA;AAEA,EAAA,KAAK,IAAI0B,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG+B,KAAK,CAACzD,MAAM,EAAE0B,CAAC,EAAE,EAAE;AACrC,IAAA,IACE,CAACL,MAAM,CAACW,SAAS,CAACC,cAAc,CAACE,IAAI,CAACoB,IAAI,EAAEE,KAAK,CAAC/B,CAAC,CAAW,CAAC,IAC/D,CAACL,MAAM,CAACmC,EAAE,CAACF,IAAI,CAACG,KAAK,CAAC/B,CAAC,CAAC,CAAY,EAAE6B,IAAI,CAACE,KAAK,CAAC/B,CAAC,CAAC,CAAY,CAAC,EAChE;AACA,MAAA,OAAO,KAAK,CAAA;AACd,KAAA;AACF,GAAA;AACA,EAAA,OAAO,IAAI,CAAA;AACb,CAAA;AAuBO,SAASgC,eAAeA,CAO7BC,IAEC,EACyD;AAC1D,EAAA,OAAOC,gBAAQ,CAAC;AACd,IAAA,GAAID,IAAY;AAChBE,IAAAA,MAAM,EAAGC,KAAiB,IACxBH,IAAI,EAAEE,MAAM,GACRF,IAAI,CAACE,MAAM,CAACC,KAAK,CAACC,OAAwB,CAAC,GAC3CD,KAAK,CAACC,OAAAA;AACd,GAAC,CAAC,CAAA;AACJ,CAAA;AAEaC,MAAAA,eAAe,GAC1B,OAAOC,MAAM,KAAK,WAAW,GAAGjB,gBAAK,CAACgB,eAAe,GAAGhB,gBAAK,CAACkB;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["import * as React from 'react'\nimport { useMatch } from './Matches'\nimport { RouteMatch } from './RouterProvider'\nimport { AnyRoute } from './route'\nimport { ParseRoute, RouteIds, RoutesById, RouteById } from './routeInfo'\nimport { RegisteredRouter } from './router'\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\nexport type IsAny<T, Y, N = T> = 1 extends 0 & T ? Y : N\nexport type IsAnyBoolean<T> = 1 extends 0 & T ? true : false\nexport type IsKnown<T, Y, N> = unknown extends T ? N : Y\nexport type PickAsRequired<T, K extends keyof T> = Omit<T, K> &\n Required<Pick<T, K>>\nexport type PickAsPartial<T, K extends keyof T> = Omit<T, K> &\n Partial<Pick<T, K>>\nexport type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never\nexport type PickExtra<T, K> = {\n [TKey in keyof K as string extends TKey\n ? never\n : TKey extends keyof T\n ? never\n : TKey]: K[TKey]\n}\n\nexport type PickRequired<T> = {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K]\n}\n\n// export type Expand<T> = T\nexport type Expand<T> = T extends object\n ? T extends infer O\n ? { [K in keyof O]: O[K] }\n : never\n : T\n\nexport type UnionToIntersection<U> = (\n U extends any ? (k: U) => void : never\n) extends (k: infer I) => any\n ? I\n : never\n\n// type Compute<T> = { [K in keyof T]: T[K] } | never\n\n// type AllKeys<T> = T extends any ? keyof T : never\n\n// export type MergeUnion<T, Keys extends keyof T = keyof T> = Compute<\n// {\n// [K in Keys]: T[Keys]\n// } & {\n// [K in AllKeys<T>]?: T extends any\n// ? K extends keyof T\n// ? T[K]\n// : never\n// : never\n// }\n// >\n\nexport type Assign<Left, Right> = Omit<Left, keyof Right> & Right\n\nexport type AssignAll<T extends any[]> = T extends [infer Left, ...infer Right]\n ? Right extends any[]\n ? Assign<Left, AssignAll<Right>>\n : Left\n : {}\n\n// // Sample types to merge\n// type TypeA = {\n// shared: string\n// onlyInA: string\n// nested: {\n// shared: string\n// aProp: string\n// }\n// array: string[]\n// }\n\n// type TypeB = {\n// shared: number\n// onlyInB: number\n// nested: {\n// shared: number\n// bProp: number\n// }\n// array: number[]\n// }\n\n// type TypeC = {\n// shared: boolean\n// onlyInC: boolean\n// nested: {\n// shared: boolean\n// cProp: boolean\n// }\n// array: boolean[]\n// }\n\n// type Test = Expand<Assign<TypeA, TypeB>>\n\n// // Using DeepMerge to merge TypeA and TypeB\n// type MergedType = Expand<AssignAll<[TypeA, TypeB, TypeC]>>\n\nexport type Values<O> = O[ValueKeys<O>]\nexport type ValueKeys<O> = Extract<keyof O, PropertyKey>\n\nexport type DeepAwaited<T> = T extends Promise<infer A>\n ? DeepAwaited<A>\n : T extends Record<infer A, Promise<infer B>>\n ? { [K in A]: DeepAwaited<B> }\n : T\n\nexport type PathParamMask<TRoutePath extends string> =\n TRoutePath extends `${infer L}/$${infer C}/${infer R}`\n ? PathParamMask<`${L}/${string}/${R}`>\n : TRoutePath extends `${infer L}/$${infer C}`\n ? PathParamMask<`${L}/${string}`>\n : TRoutePath\n\nexport type Timeout = ReturnType<typeof setTimeout>\n\nexport type Updater<TPrevious, TResult = TPrevious> =\n | TResult\n | ((prev?: TPrevious) => TResult)\n\nexport type NonNullableUpdater<TPrevious, TResult = TPrevious> =\n | TResult\n | ((prev: TPrevious) => TResult)\n\nexport type PickExtract<T, U> = {\n [K in keyof T as T[K] extends U ? K : never]: T[K]\n}\n\nexport type PickExclude<T, U> = {\n [K in keyof T as T[K] extends U ? never : K]: T[K]\n}\n\n//\n\nexport const isServer = typeof document === 'undefined'\n\nexport function last<T>(arr: T[]) {\n return arr[arr.length - 1]\n}\n\nfunction isFunction(d: any): d is Function {\n return typeof d === 'function'\n}\n\nexport function functionalUpdate<TResult>(\n updater: Updater<TResult> | NonNullableUpdater<TResult>,\n previous: TResult,\n): TResult {\n if (isFunction(updater)) {\n return updater(previous as TResult)\n }\n\n return updater\n}\n\nexport function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K> {\n return keys.reduce((obj: any, key: K) => {\n obj[key] = parent[key]\n return obj\n }, {} as any)\n}\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between immutable JSON values for example.\n * Do not use this with signals\n */\nexport function replaceEqualDeep<T>(prev: any, _next: T): T {\n if (prev === _next) {\n return prev\n }\n\n const next = _next as any\n\n const array = Array.isArray(prev) && Array.isArray(next)\n\n if (array || (isPlainObject(prev) && isPlainObject(next))) {\n const prevSize = array ? prev.length : Object.keys(prev).length\n const nextItems = array ? next : Object.keys(next)\n const nextSize = nextItems.length\n const copy: any = array ? [] : {}\n\n let equalItems = 0\n\n for (let i = 0; i < nextSize; i++) {\n const key = array ? i : nextItems[i]\n copy[key] = replaceEqualDeep(prev[key], next[key])\n if (copy[key] === prev[key]) {\n equalItems++\n }\n }\n\n return prevSize === nextSize && equalItems === prevSize ? prev : copy\n }\n\n return next\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any) {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has modified constructor\n const ctor = o.constructor\n if (typeof ctor === 'undefined') {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any) {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function deepEqual(a: any, b: any, partial: boolean = false): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (isPlainObject(a) && isPlainObject(b)) {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n\n if (!partial && aKeys.length !== bKeys.length) {\n return false\n }\n\n return !bKeys.some(\n (key) => !(key in a) || !deepEqual(a[key], b[key], partial),\n )\n }\n\n if (Array.isArray(a) && Array.isArray(b)) {\n return !a.some((item, index) => !deepEqual(item, b[index], partial))\n }\n\n return false\n}\n\nexport function useStableCallback<T extends (...args: any[]) => any>(fn: T): T {\n const fnRef = React.useRef(fn)\n fnRef.current = fn\n\n const ref = React.useRef((...args: any[]) => fnRef.current(...args))\n return ref.current as T\n}\n\nexport function shallow<T>(objA: T, objB: T) {\n if (Object.is(objA, objB)) {\n return true\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false\n }\n\n const keysA = Object.keys(objA)\n if (keysA.length !== Object.keys(objB).length) {\n return false\n }\n\n for (let i = 0; i < keysA.length; i++) {\n if (\n !Object.prototype.hasOwnProperty.call(objB, keysA[i] as string) ||\n !Object.is(objA[keysA[i] as keyof T], objB[keysA[i] as keyof T])\n ) {\n return false\n }\n }\n return true\n}\n\nexport type StrictOrFrom<TFrom> =\n | {\n from: TFrom\n strict?: true\n }\n | {\n from?: never\n strict: false\n }\n\nexport type RouteFromIdOrRoute<\n T,\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n> = T extends ParseRoute<TRouteTree>\n ? T\n : T extends RouteIds<TRouteTree>\n ? RoutesById<TRouteTree>[T]\n : T extends string\n ? RouteIds<TRouteTree>\n : never\n\nexport function useRouteContext<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TStrict extends boolean = true,\n TRouteContext = RouteById<TRouteTree, TFrom>['types']['allContext'],\n TSelected = TRouteContext,\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (search: TRouteContext) => TSelected\n },\n): TStrict extends true ? TSelected : TSelected | undefined {\n return useMatch({\n ...(opts as any),\n select: (match: RouteMatch) =>\n opts?.select\n ? opts.select(match.context as TRouteContext)\n : match.context,\n })\n}\n\nexport const useLayoutEffect =\n typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\nexport function escapeJSON(jsonString: string) {\n return jsonString\n .replace(/\\\\/g, '\\\\\\\\') // Escape backslashes\n .replace(/'/g, \"\\\\'\") // Escape single quotes\n .replace(/\"/g, '\\\\\"') // Escape double quotes\n}\n"],"names":["isServer","document","last","arr","length","isFunction","d","functionalUpdate","updater","previous","pick","parent","keys","reduce","obj","key","replaceEqualDeep","prev","_next","next","array","Array","isArray","isPlainObject","prevSize","Object","nextItems","nextSize","copy","equalItems","i","o","hasObjectPrototype","ctor","constructor","prot","prototype","hasOwnProperty","toString","call","deepEqual","a","b","partial","aKeys","bKeys","some","item","index","useStableCallback","fn","fnRef","React","useRef","current","ref","args","shallow","objA","objB","is","keysA","useRouteContext","opts","useMatch","select","match","context","useLayoutEffect","window","useEffect","escapeJSON","jsonString","replace"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;;AAaA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAoCA;;MAEaA,QAAQ,GAAG,OAAOC,QAAQ,KAAK,YAAW;AAEhD,SAASC,IAAIA,CAAIC,GAAQ,EAAE;AAChC,EAAA,OAAOA,GAAG,CAACA,GAAG,CAACC,MAAM,GAAG,CAAC,CAAC,CAAA;AAC5B,CAAA;AAEA,SAASC,UAAUA,CAACC,CAAM,EAAiB;EACzC,OAAO,OAAOA,CAAC,KAAK,UAAU,CAAA;AAChC,CAAA;AAEO,SAASC,gBAAgBA,CAC9BC,OAAuD,EACvDC,QAAiB,EACR;AACT,EAAA,IAAIJ,UAAU,CAACG,OAAO,CAAC,EAAE;IACvB,OAAOA,OAAO,CAACC,QAAmB,CAAC,CAAA;AACrC,GAAA;AAEA,EAAA,OAAOD,OAAO,CAAA;AAChB,CAAA;AAEO,SAASE,IAAIA,CAAuBC,MAAS,EAAEC,IAAS,EAAc;EAC3E,OAAOA,IAAI,CAACC,MAAM,CAAC,CAACC,GAAQ,EAAEC,GAAM,KAAK;AACvCD,IAAAA,GAAG,CAACC,GAAG,CAAC,GAAGJ,MAAM,CAACI,GAAG,CAAC,CAAA;AACtB,IAAA,OAAOD,GAAG,CAAA;GACX,EAAE,EAAS,CAAC,CAAA;AACf,CAAA;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