react-router
Advanced tools
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -38,3 +38,3 @@ | ||
| import { CreateRequestHandlerFunction, RequestHandler, createRequestHandler } from "./lib/server-runtime/server.js"; | ||
| import { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRouteFunction, InstrumentRouterFunction, InstrumentationHandlerResult, ServerInstrumentation } from "./lib/router/instrumentation.js"; | ||
| import { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRouteFunction, InstrumentRouterFunction, InstrumentationClientRouterResult, InstrumentationHandlerResult, InstrumentationServerHandlerResult, ServerInstrumentation } from "./lib/router/instrumentation.js"; | ||
@@ -45,2 +45,2 @@ //#region index.d.ts | ||
| //#endregion | ||
| export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState }; | ||
| export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState }; |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -25,3 +25,3 @@ * Copyright (c) Remix Software Inc. | ||
| try { | ||
| if (isBrowser) window.__reactRouterVersion = "8.0.1"; | ||
| if (isBrowser) window.__reactRouterVersion = "8.1.0"; | ||
| } catch (e) {} | ||
@@ -28,0 +28,0 @@ /** |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -15,2 +15,15 @@ | ||
| type InstrumentRouteFunction = (route: InstrumentableRoute) => void; | ||
| /** | ||
| * Route metadata available after React Router has matched an instrumented | ||
| * request, navigation, or fetcher call. | ||
| */ | ||
| type InstrumentationResultMeta = { | ||
| url: LoaderFunctionArgs["url"]; | ||
| pattern: string; | ||
| params: LoaderFunctionArgs["params"]; | ||
| }; | ||
| /** | ||
| * Result returned by route-level instrumented handler calls, such as | ||
| * instrumented loaders, actions, middleware, and lazy route functions. | ||
| */ | ||
| type InstrumentationHandlerResult = { | ||
@@ -23,3 +36,17 @@ status: "success"; | ||
| }; | ||
| type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>; | ||
| /** | ||
| * Result returned by client-side router instrumented navigation and fetcher | ||
| * calls. | ||
| */ | ||
| type InstrumentationClientRouterResult = InstrumentationHandlerResult & { | ||
| meta: InstrumentationResultMeta | undefined; | ||
| }; | ||
| /** | ||
| * Result returned by server request handler instrumentation. | ||
| */ | ||
| type InstrumentationServerHandlerResult = InstrumentationHandlerResult & { | ||
| statusCode: number; | ||
| meta: InstrumentationResultMeta | undefined; | ||
| }; | ||
| type InstrumentFunction<T, TInnerResult = InstrumentationHandlerResult> = (handler: () => Promise<TInnerResult>, info: T) => Promise<void>; | ||
| type ReadonlyRequest = { | ||
@@ -47,6 +74,4 @@ method: string; | ||
| type RouteLazyInstrumentationInfo = undefined; | ||
| type RouteHandlerInstrumentationInfo = Readonly<{ | ||
| type RouteHandlerInstrumentationInfo = Readonly<Omit<LoaderFunctionArgs, "request" | "context"> & { | ||
| request: ReadonlyRequest; | ||
| params: LoaderFunctionArgs["params"]; | ||
| pattern: string; | ||
| context: ReadonlyContext; | ||
@@ -58,4 +83,4 @@ }>; | ||
| type RouterInstrumentations = { | ||
| navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>; | ||
| fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>; | ||
| navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo, InstrumentationClientRouterResult>; | ||
| fetch?: InstrumentFunction<RouterFetchInstrumentationInfo, InstrumentationClientRouterResult>; | ||
| }; | ||
@@ -83,3 +108,3 @@ type RouterNavigationInstrumentationInfo = Readonly<{ | ||
| type RequestHandlerInstrumentations = { | ||
| request?: InstrumentFunction<RequestHandlerInstrumentationInfo>; | ||
| request?: InstrumentFunction<RequestHandlerInstrumentationInfo, InstrumentationServerHandlerResult>; | ||
| }; | ||
@@ -91,2 +116,2 @@ type RequestHandlerInstrumentationInfo = Readonly<{ | ||
| //#endregion | ||
| export { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRouteFunction, InstrumentRouterFunction, InstrumentationHandlerResult, ServerInstrumentation }; | ||
| export { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRouteFunction, InstrumentRouterFunction, InstrumentationClientRouterResult, InstrumentationHandlerResult, InstrumentationServerHandlerResult, ServerInstrumentation }; |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -12,4 +12,7 @@ * Copyright (c) Remix Software Inc. | ||
| import { createPath, invariant } from "./history.js"; | ||
| import { RouterContextProvider, createContext } from "./utils.js"; | ||
| //#region lib/router/instrumentation.ts | ||
| const UninstrumentedSymbol = Symbol("Uninstrumented"); | ||
| const instrumentationResultMetaContext = createContext(); | ||
| let instrumentationClientResultMetaReceivers = /* @__PURE__ */ new WeakMap(); | ||
| function getRouteInstrumentationUpdates(fns, route) { | ||
@@ -30,4 +33,9 @@ let aggregated = { | ||
| instrument(i) { | ||
| let keys = Object.keys(aggregated); | ||
| for (let key of keys) if (i[key]) aggregated[key].push(i[key]); | ||
| if (i.lazy != null) aggregated.lazy.push(i.lazy); | ||
| if (i["lazy.loader"] != null) aggregated["lazy.loader"].push(i["lazy.loader"]); | ||
| if (i["lazy.action"] != null) aggregated["lazy.action"].push(i["lazy.action"]); | ||
| if (i["lazy.middleware"] != null) aggregated["lazy.middleware"].push(i["lazy.middleware"]); | ||
| if (i.middleware != null) aggregated.middleware.push(i.middleware); | ||
| if (i.loader != null) aggregated.loader.push(i.loader); | ||
| if (i.action != null) aggregated.action.push(i.action); | ||
| } | ||
@@ -37,40 +45,52 @@ })); | ||
| if (typeof route.lazy === "function" && aggregated.lazy.length > 0) { | ||
| let instrumented = wrapImpl(aggregated.lazy, route.lazy, () => void 0); | ||
| if (instrumented) updates.lazy = instrumented; | ||
| let lazy = route.lazy; | ||
| updates.lazy = async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated.lazy, void 0, () => lazy(...args), getInstrumentationInnerResult)); | ||
| }; | ||
| } | ||
| if (typeof route.lazy === "object") { | ||
| let lazyObject = route.lazy; | ||
| [ | ||
| "middleware", | ||
| "loader", | ||
| "action" | ||
| ].forEach((key) => { | ||
| let lazyFn = lazyObject[key]; | ||
| let instrumentations = aggregated[`lazy.${key}`]; | ||
| if (typeof lazyFn === "function" && instrumentations.length > 0) { | ||
| let instrumented = wrapImpl(instrumentations, lazyFn, () => void 0); | ||
| if (instrumented) updates.lazy = Object.assign(updates.lazy || {}, { [key]: instrumented }); | ||
| } | ||
| }); | ||
| if (typeof lazyObject.middleware === "function" && aggregated["lazy.middleware"].length > 0) { | ||
| let middleware = lazyObject.middleware; | ||
| updates.lazy = Object.assign(updates.lazy || {}, { middleware: async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated["lazy.middleware"], void 0, () => middleware(...args), getInstrumentationInnerResult)); | ||
| } }); | ||
| } | ||
| if (typeof lazyObject.loader === "function" && aggregated["lazy.loader"].length > 0) { | ||
| let loader = lazyObject.loader; | ||
| updates.lazy = Object.assign(updates.lazy || {}, { loader: async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated["lazy.loader"], void 0, () => loader(...args), getInstrumentationInnerResult)); | ||
| } }); | ||
| } | ||
| if (typeof lazyObject.action === "function" && aggregated["lazy.action"].length > 0) { | ||
| let action = lazyObject.action; | ||
| updates.lazy = Object.assign(updates.lazy || {}, { action: async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated["lazy.action"], void 0, () => action(...args), getInstrumentationInnerResult)); | ||
| } }); | ||
| } | ||
| } | ||
| ["loader", "action"].forEach((key) => { | ||
| let handler = route[key]; | ||
| if (typeof handler === "function" && aggregated[key].length > 0) { | ||
| let original = handler[UninstrumentedSymbol] ?? handler; | ||
| let instrumented = wrapImpl(aggregated[key], original, (...args) => getHandlerInfo(args[0])); | ||
| if (instrumented) { | ||
| if (key === "loader" && original.hydrate === true) instrumented.hydrate = true; | ||
| instrumented[UninstrumentedSymbol] = original; | ||
| updates[key] = instrumented; | ||
| } | ||
| } | ||
| }); | ||
| if (typeof route.loader === "function" && aggregated.loader.length > 0) { | ||
| let original = getUninstrumentedHandler(route.loader); | ||
| let instrumented = async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated.loader, getHandlerInfo(args[0]), () => original(...args), getInstrumentationInnerResult)); | ||
| }; | ||
| if (original.hydrate === true) instrumented.hydrate = true; | ||
| setUninstrumentedHandler(instrumented, original); | ||
| updates.loader = instrumented; | ||
| } | ||
| if (typeof route.action === "function" && aggregated.action.length > 0) { | ||
| let original = getUninstrumentedHandler(route.action); | ||
| let instrumented = async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated.action, getHandlerInfo(args[0]), () => original(...args), getInstrumentationInnerResult)); | ||
| }; | ||
| setUninstrumentedHandler(instrumented, original); | ||
| updates.action = instrumented; | ||
| } | ||
| if (route.middleware && route.middleware.length > 0 && aggregated.middleware.length > 0) updates.middleware = route.middleware.map((middleware) => { | ||
| let original = middleware[UninstrumentedSymbol] ?? middleware; | ||
| let instrumented = wrapImpl(aggregated.middleware, original, (...args) => getHandlerInfo(args[0])); | ||
| if (instrumented) { | ||
| instrumented[UninstrumentedSymbol] = original; | ||
| return instrumented; | ||
| } | ||
| return middleware; | ||
| let original = getUninstrumentedHandler(middleware); | ||
| let instrumented = async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated.middleware, getHandlerInfo(args[0]), () => original(...args), getInstrumentationInnerResult)); | ||
| }; | ||
| setUninstrumentedHandler(instrumented, original); | ||
| return instrumented; | ||
| }); | ||
@@ -85,33 +105,57 @@ return updates; | ||
| fns.forEach((fn) => fn({ instrument(i) { | ||
| let keys = Object.keys(i); | ||
| for (let key of keys) if (i[key]) aggregated[key].push(i[key]); | ||
| if (i.navigate != null) aggregated.navigate.push(i.navigate); | ||
| if (i.fetch != null) aggregated.fetch.push(i.fetch); | ||
| } })); | ||
| if (aggregated.navigate.length > 0) { | ||
| let navigate = router.navigate[UninstrumentedSymbol] ?? router.navigate; | ||
| let instrumentedNavigate = wrapImpl(aggregated.navigate, navigate, (...args) => { | ||
| let navigate = getUninstrumentedHandler(router.navigate); | ||
| let instrumentedNavigate = async (...args) => { | ||
| let [to, opts] = args; | ||
| return { | ||
| let meta; | ||
| let info = { | ||
| to: typeof to === "number" || typeof to === "string" ? to : to ? createPath(to) : ".", | ||
| ...getRouterInfo(router, opts ?? {}) | ||
| }; | ||
| }); | ||
| if (instrumentedNavigate) { | ||
| instrumentedNavigate[UninstrumentedSymbol] = navigate; | ||
| router.navigate = instrumentedNavigate; | ||
| } | ||
| return throwOrReturnResult(await recurseRight(aggregated.navigate, info, async () => { | ||
| if (typeof to === "number") return await navigate(...args); | ||
| let cleanup = setInstrumentationClientResultMetaReceiver(router, (value) => { | ||
| meta = value; | ||
| }); | ||
| try { | ||
| return await navigate(...args); | ||
| } finally { | ||
| cleanup(); | ||
| } | ||
| }, (result) => ({ | ||
| ...getInstrumentationInnerResult(result), | ||
| meta | ||
| }))); | ||
| }; | ||
| setUninstrumentedHandler(instrumentedNavigate, navigate); | ||
| router.navigate = instrumentedNavigate; | ||
| } | ||
| if (aggregated.fetch.length > 0) { | ||
| let fetch = router.fetch[UninstrumentedSymbol] ?? router.fetch; | ||
| let instrumentedFetch = wrapImpl(aggregated.fetch, fetch, (...args) => { | ||
| let [key, , href, opts] = args; | ||
| return { | ||
| let fetch = getUninstrumentedHandler(router.fetch); | ||
| let instrumentedFetch = async (...args) => { | ||
| let [key, _, href, opts] = args; | ||
| let meta; | ||
| return throwOrReturnResult(await recurseRight(aggregated.fetch, { | ||
| href: href ?? ".", | ||
| fetcherKey: key, | ||
| ...getRouterInfo(router, opts ?? {}) | ||
| }; | ||
| }); | ||
| if (instrumentedFetch) { | ||
| instrumentedFetch[UninstrumentedSymbol] = fetch; | ||
| router.fetch = instrumentedFetch; | ||
| } | ||
| }, async () => { | ||
| let cleanup = setInstrumentationClientResultMetaReceiver(router, (value) => { | ||
| meta = value; | ||
| }); | ||
| try { | ||
| return await fetch(...args); | ||
| } finally { | ||
| cleanup(); | ||
| } | ||
| }, (result) => ({ | ||
| ...getInstrumentationInnerResult(result), | ||
| meta | ||
| }))); | ||
| }; | ||
| setUninstrumentedHandler(instrumentedFetch, fetch); | ||
| router.fetch = instrumentedFetch; | ||
| } | ||
@@ -123,52 +167,73 @@ return router; | ||
| fns.forEach((fn) => fn({ instrument(i) { | ||
| let keys = Object.keys(i); | ||
| for (let key of keys) if (i[key]) aggregated[key].push(i[key]); | ||
| if (i.request != null) aggregated.request.push(i.request); | ||
| } })); | ||
| let instrumentedHandler = handler; | ||
| if (aggregated.request.length > 0) instrumentedHandler = wrapImpl(aggregated.request, handler, (...args) => { | ||
| if (aggregated.request.length > 0) instrumentedHandler = async (...args) => { | ||
| let [request, context] = args; | ||
| return { | ||
| let instrumentationContext = context ?? new RouterContextProvider(); | ||
| return throwOrReturnResult(await recurseRight(aggregated.request, { | ||
| request: getReadonlyRequest(request), | ||
| context: context != null ? getReadonlyContext(context) : context | ||
| }; | ||
| }); | ||
| context: getReadonlyContext(instrumentationContext) | ||
| }, () => handler(request, instrumentationContext), (result, info) => { | ||
| let meta; | ||
| try { | ||
| meta = info.context?.get(instrumentationResultMetaContext); | ||
| } catch {} | ||
| invariant(result.value instanceof Response, "Expected a Response from the request handler"); | ||
| return { | ||
| ...getInstrumentationInnerResult(result), | ||
| statusCode: result.value.status, | ||
| meta | ||
| }; | ||
| })); | ||
| }; | ||
| return instrumentedHandler; | ||
| } | ||
| function wrapImpl(impls, handler, getInfo) { | ||
| if (impls.length === 0) return null; | ||
| return async (...args) => { | ||
| let result = await recurseRight(impls, getInfo(...args), () => handler(...args), impls.length - 1); | ||
| if (result.type === "error") throw result.value; | ||
| return result.value; | ||
| function getUninstrumentedHandler(handler) { | ||
| return handler[UninstrumentedSymbol] ?? handler; | ||
| } | ||
| function setUninstrumentedHandler(handler, uninstrumentedHandler) { | ||
| handler[UninstrumentedSymbol] = uninstrumentedHandler; | ||
| } | ||
| function setInstrumentationClientResultMetaReceiver(router, receiver) { | ||
| instrumentationClientResultMetaReceivers.set(router, receiver); | ||
| return () => { | ||
| if (instrumentationClientResultMetaReceivers.get(router) === receiver) instrumentationClientResultMetaReceivers.delete(router); | ||
| }; | ||
| } | ||
| async function recurseRight(impls, info, handler, index) { | ||
| function consumeInstrumentationClientResultMetaReceiver(router) { | ||
| let receiver = instrumentationClientResultMetaReceivers.get(router); | ||
| instrumentationClientResultMetaReceivers.delete(router); | ||
| return receiver; | ||
| } | ||
| function throwOrReturnResult(result) { | ||
| if (result.type === "error") throw result.value; | ||
| return result.value; | ||
| } | ||
| async function recurseRight(impls, info, handler, getInnerResult, state = { | ||
| result: null, | ||
| innerResult: null | ||
| }, index = impls.length - 1) { | ||
| let impl = impls[index]; | ||
| let result; | ||
| if (!impl) try { | ||
| result = { | ||
| type: "success", | ||
| value: await handler() | ||
| }; | ||
| } catch (e) { | ||
| result = { | ||
| type: "error", | ||
| value: e | ||
| }; | ||
| } | ||
| else { | ||
| if (!impl) { | ||
| try { | ||
| state.result = { | ||
| type: "success", | ||
| value: await handler() | ||
| }; | ||
| } catch (e) { | ||
| state.result = { | ||
| type: "error", | ||
| value: e | ||
| }; | ||
| } | ||
| state.innerResult = getInnerResult(state.result, info); | ||
| } else { | ||
| let handlerPromise = void 0; | ||
| let callHandler = async () => { | ||
| if (handlerPromise) console.error("You cannot call instrumented handlers more than once"); | ||
| else handlerPromise = recurseRight(impls, info, handler, index - 1); | ||
| result = await handlerPromise; | ||
| invariant(result, "Expected a result"); | ||
| if (result.type === "error" && result.value instanceof Error) return { | ||
| status: "error", | ||
| error: result.value | ||
| }; | ||
| return { | ||
| status: "success", | ||
| error: void 0 | ||
| }; | ||
| else handlerPromise = recurseRight(impls, info, handler, getInnerResult, state, index - 1); | ||
| await handlerPromise; | ||
| invariant(state.innerResult, "Expected an inner result"); | ||
| return state.innerResult; | ||
| }; | ||
@@ -183,14 +248,26 @@ try { | ||
| } | ||
| if (result) return result; | ||
| return { | ||
| if (state.result) return state.result; | ||
| state.result = { | ||
| type: "error", | ||
| value: /* @__PURE__ */ new Error("No result assigned in instrumentation chain.") | ||
| }; | ||
| state.innerResult = getInnerResult(state.result, info); | ||
| return state.result; | ||
| } | ||
| function getInstrumentationInnerResult(result) { | ||
| if (result.type === "error" && result.value instanceof Error) return { | ||
| status: "error", | ||
| error: result.value | ||
| }; | ||
| return { | ||
| status: "success", | ||
| error: void 0 | ||
| }; | ||
| } | ||
| function getHandlerInfo(args) { | ||
| let { request, context, params, pattern } = args; | ||
| let { request, context, params } = args; | ||
| return { | ||
| ...args, | ||
| request: getReadonlyRequest(request), | ||
| params: { ...params }, | ||
| pattern, | ||
| context: getReadonlyContext(context) | ||
@@ -219,2 +296,2 @@ }; | ||
| //#endregion | ||
| export { getRouteInstrumentationUpdates, instrumentClientSideRouter, instrumentHandler }; | ||
| export { consumeInstrumentationClientResultMetaReceiver, getRouteInstrumentationUpdates, instrumentClientSideRouter, instrumentHandler, instrumentationResultMetaContext }; |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -784,2 +784,17 @@ * Copyright (c) Remix Software Inc. | ||
| } | ||
| function createDataFunctionUrl(request, path) { | ||
| let url = new URL(typeof request === "string" || request instanceof URL ? request : request.url); | ||
| let parsed = typeof path === "string" ? parsePath(path) : path; | ||
| url.pathname = parsed.pathname || "/"; | ||
| if (parsed.search) { | ||
| let searchParams = new URLSearchParams(parsed.search); | ||
| let indexValues = searchParams.getAll("index"); | ||
| searchParams.delete("index"); | ||
| for (let value of indexValues.filter(Boolean)) searchParams.append("index", value); | ||
| let search = searchParams.toString(); | ||
| url.search = search ? `?${search}` : ""; | ||
| } else url.search = ""; | ||
| url.hash = parsed.hash || ""; | ||
| return url; | ||
| } | ||
| const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined"; | ||
@@ -811,2 +826,2 @@ function parseToInfo(_to, basename) { | ||
| //#endregion | ||
| export { ErrorResponseImpl, RouterContextProvider, SUPPORTED_ERROR_TYPES, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, data, decodePath, defaultMapRouteProperties, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, removeTrailingSlash, replace, resolvePath, resolveTo, stripBasename }; | ||
| export { ErrorResponseImpl, RouterContextProvider, SUPPORTED_ERROR_TYPES, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, createDataFunctionUrl, data, decodePath, defaultMapRouteProperties, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, removeTrailingSlash, replace, resolvePath, resolveTo, stripBasename }; |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -11,4 +11,4 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ErrorResponseImpl, RouterContextProvider, defaultMapRouteProperties, isRouteErrorResponse, removeTrailingSlash, stripBasename } from "../router/utils.js"; | ||
| import { instrumentHandler } from "../router/instrumentation.js"; | ||
| import { ErrorResponseImpl, RouterContextProvider, createDataFunctionUrl, defaultMapRouteProperties, getRoutePattern, isRouteErrorResponse, removeTrailingSlash, stripBasename } from "../router/utils.js"; | ||
| import { instrumentHandler, instrumentationResultMetaContext } from "../router/instrumentation.js"; | ||
| import { createStaticHandler, getStaticContextFromError, isMutationMethod, isRedirectResponse, isResponse } from "../router/router.js"; | ||
@@ -40,2 +40,3 @@ import { getManifestPath } from "../dom/ssr/fog-of-war.js"; | ||
| }); | ||
| let requestHandlerInstrumentations = build.entry.module.instrumentations?.map((i) => i.handler).filter(Boolean); | ||
| let requestHandler = async (request, initialContext) => { | ||
@@ -59,3 +60,4 @@ let params = {}; | ||
| let requestUrl = new URL(request.url); | ||
| let normalizedPathname = getNormalizedPath(request).pathname; | ||
| let normalizedPath = getNormalizedPath(request); | ||
| let normalizedPathname = normalizedPath.pathname; | ||
| let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes"; | ||
@@ -101,2 +103,7 @@ if (!build.ssr) { | ||
| if (matches && matches.length > 0) Object.assign(params, matches[0].params); | ||
| if (requestHandlerInstrumentations?.length) loadContext.set(instrumentationResultMetaContext, { | ||
| url: createDataFunctionUrl(request, normalizedPath), | ||
| pattern: matches ? getRoutePattern(matches) : "", | ||
| params: matches?.[0]?.params ? { ...matches[0].params } : {} | ||
| }); | ||
| let response; | ||
@@ -129,3 +136,3 @@ if (requestUrl.pathname.endsWith(".data")) { | ||
| }; | ||
| if (build.entry.module.instrumentations) requestHandler = instrumentHandler(requestHandler, build.entry.module.instrumentations.map((i) => i.handler).filter(Boolean)); | ||
| if (requestHandlerInstrumentations?.length) requestHandler = instrumentHandler(requestHandler, requestHandlerInstrumentations); | ||
| return { | ||
@@ -132,0 +139,0 @@ serverMode, |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -38,3 +38,3 @@ | ||
| import { CreateRequestHandlerFunction, RequestHandler, createRequestHandler } from "./lib/server-runtime/server.js"; | ||
| import { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRouteFunction, InstrumentRouterFunction, InstrumentationHandlerResult, ServerInstrumentation } from "./lib/router/instrumentation.js"; | ||
| import { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRouteFunction, InstrumentRouterFunction, InstrumentationClientRouterResult, InstrumentationHandlerResult, InstrumentationServerHandlerResult, ServerInstrumentation } from "./lib/router/instrumentation.js"; | ||
@@ -45,2 +45,2 @@ //#region index.d.ts | ||
| //#endregion | ||
| export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState }; | ||
| export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState }; |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -25,3 +25,3 @@ * Copyright (c) Remix Software Inc. | ||
| try { | ||
| if (isBrowser) window.__reactRouterVersion = "8.0.1"; | ||
| if (isBrowser) window.__reactRouterVersion = "8.1.0"; | ||
| } catch (e) {} | ||
@@ -28,0 +28,0 @@ /** |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -15,2 +15,15 @@ | ||
| type InstrumentRouteFunction = (route: InstrumentableRoute) => void; | ||
| /** | ||
| * Route metadata available after React Router has matched an instrumented | ||
| * request, navigation, or fetcher call. | ||
| */ | ||
| type InstrumentationResultMeta = { | ||
| url: LoaderFunctionArgs["url"]; | ||
| pattern: string; | ||
| params: LoaderFunctionArgs["params"]; | ||
| }; | ||
| /** | ||
| * Result returned by route-level instrumented handler calls, such as | ||
| * instrumented loaders, actions, middleware, and lazy route functions. | ||
| */ | ||
| type InstrumentationHandlerResult = { | ||
@@ -23,3 +36,17 @@ status: "success"; | ||
| }; | ||
| type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>; | ||
| /** | ||
| * Result returned by client-side router instrumented navigation and fetcher | ||
| * calls. | ||
| */ | ||
| type InstrumentationClientRouterResult = InstrumentationHandlerResult & { | ||
| meta: InstrumentationResultMeta | undefined; | ||
| }; | ||
| /** | ||
| * Result returned by server request handler instrumentation. | ||
| */ | ||
| type InstrumentationServerHandlerResult = InstrumentationHandlerResult & { | ||
| statusCode: number; | ||
| meta: InstrumentationResultMeta | undefined; | ||
| }; | ||
| type InstrumentFunction<T, TInnerResult = InstrumentationHandlerResult> = (handler: () => Promise<TInnerResult>, info: T) => Promise<void>; | ||
| type ReadonlyRequest = { | ||
@@ -47,6 +74,4 @@ method: string; | ||
| type RouteLazyInstrumentationInfo = undefined; | ||
| type RouteHandlerInstrumentationInfo = Readonly<{ | ||
| type RouteHandlerInstrumentationInfo = Readonly<Omit<LoaderFunctionArgs, "request" | "context"> & { | ||
| request: ReadonlyRequest; | ||
| params: LoaderFunctionArgs["params"]; | ||
| pattern: string; | ||
| context: ReadonlyContext; | ||
@@ -58,4 +83,4 @@ }>; | ||
| type RouterInstrumentations = { | ||
| navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>; | ||
| fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>; | ||
| navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo, InstrumentationClientRouterResult>; | ||
| fetch?: InstrumentFunction<RouterFetchInstrumentationInfo, InstrumentationClientRouterResult>; | ||
| }; | ||
@@ -83,3 +108,3 @@ type RouterNavigationInstrumentationInfo = Readonly<{ | ||
| type RequestHandlerInstrumentations = { | ||
| request?: InstrumentFunction<RequestHandlerInstrumentationInfo>; | ||
| request?: InstrumentFunction<RequestHandlerInstrumentationInfo, InstrumentationServerHandlerResult>; | ||
| }; | ||
@@ -91,2 +116,2 @@ type RequestHandlerInstrumentationInfo = Readonly<{ | ||
| //#endregion | ||
| export { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRouteFunction, InstrumentRouterFunction, InstrumentationHandlerResult, ServerInstrumentation }; | ||
| export { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRouteFunction, InstrumentRouterFunction, InstrumentationClientRouterResult, InstrumentationHandlerResult, InstrumentationServerHandlerResult, ServerInstrumentation }; |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -12,4 +12,7 @@ * Copyright (c) Remix Software Inc. | ||
| import { createPath, invariant } from "./history.js"; | ||
| import { RouterContextProvider, createContext } from "./utils.js"; | ||
| //#region lib/router/instrumentation.ts | ||
| const UninstrumentedSymbol = Symbol("Uninstrumented"); | ||
| const instrumentationResultMetaContext = createContext(); | ||
| let instrumentationClientResultMetaReceivers = /* @__PURE__ */ new WeakMap(); | ||
| function getRouteInstrumentationUpdates(fns, route) { | ||
@@ -30,4 +33,9 @@ let aggregated = { | ||
| instrument(i) { | ||
| let keys = Object.keys(aggregated); | ||
| for (let key of keys) if (i[key]) aggregated[key].push(i[key]); | ||
| if (i.lazy != null) aggregated.lazy.push(i.lazy); | ||
| if (i["lazy.loader"] != null) aggregated["lazy.loader"].push(i["lazy.loader"]); | ||
| if (i["lazy.action"] != null) aggregated["lazy.action"].push(i["lazy.action"]); | ||
| if (i["lazy.middleware"] != null) aggregated["lazy.middleware"].push(i["lazy.middleware"]); | ||
| if (i.middleware != null) aggregated.middleware.push(i.middleware); | ||
| if (i.loader != null) aggregated.loader.push(i.loader); | ||
| if (i.action != null) aggregated.action.push(i.action); | ||
| } | ||
@@ -37,40 +45,52 @@ })); | ||
| if (typeof route.lazy === "function" && aggregated.lazy.length > 0) { | ||
| let instrumented = wrapImpl(aggregated.lazy, route.lazy, () => void 0); | ||
| if (instrumented) updates.lazy = instrumented; | ||
| let lazy = route.lazy; | ||
| updates.lazy = async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated.lazy, void 0, () => lazy(...args), getInstrumentationInnerResult)); | ||
| }; | ||
| } | ||
| if (typeof route.lazy === "object") { | ||
| let lazyObject = route.lazy; | ||
| [ | ||
| "middleware", | ||
| "loader", | ||
| "action" | ||
| ].forEach((key) => { | ||
| let lazyFn = lazyObject[key]; | ||
| let instrumentations = aggregated[`lazy.${key}`]; | ||
| if (typeof lazyFn === "function" && instrumentations.length > 0) { | ||
| let instrumented = wrapImpl(instrumentations, lazyFn, () => void 0); | ||
| if (instrumented) updates.lazy = Object.assign(updates.lazy || {}, { [key]: instrumented }); | ||
| } | ||
| }); | ||
| if (typeof lazyObject.middleware === "function" && aggregated["lazy.middleware"].length > 0) { | ||
| let middleware = lazyObject.middleware; | ||
| updates.lazy = Object.assign(updates.lazy || {}, { middleware: async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated["lazy.middleware"], void 0, () => middleware(...args), getInstrumentationInnerResult)); | ||
| } }); | ||
| } | ||
| if (typeof lazyObject.loader === "function" && aggregated["lazy.loader"].length > 0) { | ||
| let loader = lazyObject.loader; | ||
| updates.lazy = Object.assign(updates.lazy || {}, { loader: async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated["lazy.loader"], void 0, () => loader(...args), getInstrumentationInnerResult)); | ||
| } }); | ||
| } | ||
| if (typeof lazyObject.action === "function" && aggregated["lazy.action"].length > 0) { | ||
| let action = lazyObject.action; | ||
| updates.lazy = Object.assign(updates.lazy || {}, { action: async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated["lazy.action"], void 0, () => action(...args), getInstrumentationInnerResult)); | ||
| } }); | ||
| } | ||
| } | ||
| ["loader", "action"].forEach((key) => { | ||
| let handler = route[key]; | ||
| if (typeof handler === "function" && aggregated[key].length > 0) { | ||
| let original = handler[UninstrumentedSymbol] ?? handler; | ||
| let instrumented = wrapImpl(aggregated[key], original, (...args) => getHandlerInfo(args[0])); | ||
| if (instrumented) { | ||
| if (key === "loader" && original.hydrate === true) instrumented.hydrate = true; | ||
| instrumented[UninstrumentedSymbol] = original; | ||
| updates[key] = instrumented; | ||
| } | ||
| } | ||
| }); | ||
| if (typeof route.loader === "function" && aggregated.loader.length > 0) { | ||
| let original = getUninstrumentedHandler(route.loader); | ||
| let instrumented = async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated.loader, getHandlerInfo(args[0]), () => original(...args), getInstrumentationInnerResult)); | ||
| }; | ||
| if (original.hydrate === true) instrumented.hydrate = true; | ||
| setUninstrumentedHandler(instrumented, original); | ||
| updates.loader = instrumented; | ||
| } | ||
| if (typeof route.action === "function" && aggregated.action.length > 0) { | ||
| let original = getUninstrumentedHandler(route.action); | ||
| let instrumented = async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated.action, getHandlerInfo(args[0]), () => original(...args), getInstrumentationInnerResult)); | ||
| }; | ||
| setUninstrumentedHandler(instrumented, original); | ||
| updates.action = instrumented; | ||
| } | ||
| if (route.middleware && route.middleware.length > 0 && aggregated.middleware.length > 0) updates.middleware = route.middleware.map((middleware) => { | ||
| let original = middleware[UninstrumentedSymbol] ?? middleware; | ||
| let instrumented = wrapImpl(aggregated.middleware, original, (...args) => getHandlerInfo(args[0])); | ||
| if (instrumented) { | ||
| instrumented[UninstrumentedSymbol] = original; | ||
| return instrumented; | ||
| } | ||
| return middleware; | ||
| let original = getUninstrumentedHandler(middleware); | ||
| let instrumented = async (...args) => { | ||
| return throwOrReturnResult(await recurseRight(aggregated.middleware, getHandlerInfo(args[0]), () => original(...args), getInstrumentationInnerResult)); | ||
| }; | ||
| setUninstrumentedHandler(instrumented, original); | ||
| return instrumented; | ||
| }); | ||
@@ -85,33 +105,57 @@ return updates; | ||
| fns.forEach((fn) => fn({ instrument(i) { | ||
| let keys = Object.keys(i); | ||
| for (let key of keys) if (i[key]) aggregated[key].push(i[key]); | ||
| if (i.navigate != null) aggregated.navigate.push(i.navigate); | ||
| if (i.fetch != null) aggregated.fetch.push(i.fetch); | ||
| } })); | ||
| if (aggregated.navigate.length > 0) { | ||
| let navigate = router.navigate[UninstrumentedSymbol] ?? router.navigate; | ||
| let instrumentedNavigate = wrapImpl(aggregated.navigate, navigate, (...args) => { | ||
| let navigate = getUninstrumentedHandler(router.navigate); | ||
| let instrumentedNavigate = async (...args) => { | ||
| let [to, opts] = args; | ||
| return { | ||
| let meta; | ||
| let info = { | ||
| to: typeof to === "number" || typeof to === "string" ? to : to ? createPath(to) : ".", | ||
| ...getRouterInfo(router, opts ?? {}) | ||
| }; | ||
| }); | ||
| if (instrumentedNavigate) { | ||
| instrumentedNavigate[UninstrumentedSymbol] = navigate; | ||
| router.navigate = instrumentedNavigate; | ||
| } | ||
| return throwOrReturnResult(await recurseRight(aggregated.navigate, info, async () => { | ||
| if (typeof to === "number") return await navigate(...args); | ||
| let cleanup = setInstrumentationClientResultMetaReceiver(router, (value) => { | ||
| meta = value; | ||
| }); | ||
| try { | ||
| return await navigate(...args); | ||
| } finally { | ||
| cleanup(); | ||
| } | ||
| }, (result) => ({ | ||
| ...getInstrumentationInnerResult(result), | ||
| meta | ||
| }))); | ||
| }; | ||
| setUninstrumentedHandler(instrumentedNavigate, navigate); | ||
| router.navigate = instrumentedNavigate; | ||
| } | ||
| if (aggregated.fetch.length > 0) { | ||
| let fetch = router.fetch[UninstrumentedSymbol] ?? router.fetch; | ||
| let instrumentedFetch = wrapImpl(aggregated.fetch, fetch, (...args) => { | ||
| let [key, , href, opts] = args; | ||
| return { | ||
| let fetch = getUninstrumentedHandler(router.fetch); | ||
| let instrumentedFetch = async (...args) => { | ||
| let [key, _, href, opts] = args; | ||
| let meta; | ||
| return throwOrReturnResult(await recurseRight(aggregated.fetch, { | ||
| href: href ?? ".", | ||
| fetcherKey: key, | ||
| ...getRouterInfo(router, opts ?? {}) | ||
| }; | ||
| }); | ||
| if (instrumentedFetch) { | ||
| instrumentedFetch[UninstrumentedSymbol] = fetch; | ||
| router.fetch = instrumentedFetch; | ||
| } | ||
| }, async () => { | ||
| let cleanup = setInstrumentationClientResultMetaReceiver(router, (value) => { | ||
| meta = value; | ||
| }); | ||
| try { | ||
| return await fetch(...args); | ||
| } finally { | ||
| cleanup(); | ||
| } | ||
| }, (result) => ({ | ||
| ...getInstrumentationInnerResult(result), | ||
| meta | ||
| }))); | ||
| }; | ||
| setUninstrumentedHandler(instrumentedFetch, fetch); | ||
| router.fetch = instrumentedFetch; | ||
| } | ||
@@ -123,52 +167,73 @@ return router; | ||
| fns.forEach((fn) => fn({ instrument(i) { | ||
| let keys = Object.keys(i); | ||
| for (let key of keys) if (i[key]) aggregated[key].push(i[key]); | ||
| if (i.request != null) aggregated.request.push(i.request); | ||
| } })); | ||
| let instrumentedHandler = handler; | ||
| if (aggregated.request.length > 0) instrumentedHandler = wrapImpl(aggregated.request, handler, (...args) => { | ||
| if (aggregated.request.length > 0) instrumentedHandler = async (...args) => { | ||
| let [request, context] = args; | ||
| return { | ||
| let instrumentationContext = context ?? new RouterContextProvider(); | ||
| return throwOrReturnResult(await recurseRight(aggregated.request, { | ||
| request: getReadonlyRequest(request), | ||
| context: context != null ? getReadonlyContext(context) : context | ||
| }; | ||
| }); | ||
| context: getReadonlyContext(instrumentationContext) | ||
| }, () => handler(request, instrumentationContext), (result, info) => { | ||
| let meta; | ||
| try { | ||
| meta = info.context?.get(instrumentationResultMetaContext); | ||
| } catch {} | ||
| invariant(result.value instanceof Response, "Expected a Response from the request handler"); | ||
| return { | ||
| ...getInstrumentationInnerResult(result), | ||
| statusCode: result.value.status, | ||
| meta | ||
| }; | ||
| })); | ||
| }; | ||
| return instrumentedHandler; | ||
| } | ||
| function wrapImpl(impls, handler, getInfo) { | ||
| if (impls.length === 0) return null; | ||
| return async (...args) => { | ||
| let result = await recurseRight(impls, getInfo(...args), () => handler(...args), impls.length - 1); | ||
| if (result.type === "error") throw result.value; | ||
| return result.value; | ||
| function getUninstrumentedHandler(handler) { | ||
| return handler[UninstrumentedSymbol] ?? handler; | ||
| } | ||
| function setUninstrumentedHandler(handler, uninstrumentedHandler) { | ||
| handler[UninstrumentedSymbol] = uninstrumentedHandler; | ||
| } | ||
| function setInstrumentationClientResultMetaReceiver(router, receiver) { | ||
| instrumentationClientResultMetaReceivers.set(router, receiver); | ||
| return () => { | ||
| if (instrumentationClientResultMetaReceivers.get(router) === receiver) instrumentationClientResultMetaReceivers.delete(router); | ||
| }; | ||
| } | ||
| async function recurseRight(impls, info, handler, index) { | ||
| function consumeInstrumentationClientResultMetaReceiver(router) { | ||
| let receiver = instrumentationClientResultMetaReceivers.get(router); | ||
| instrumentationClientResultMetaReceivers.delete(router); | ||
| return receiver; | ||
| } | ||
| function throwOrReturnResult(result) { | ||
| if (result.type === "error") throw result.value; | ||
| return result.value; | ||
| } | ||
| async function recurseRight(impls, info, handler, getInnerResult, state = { | ||
| result: null, | ||
| innerResult: null | ||
| }, index = impls.length - 1) { | ||
| let impl = impls[index]; | ||
| let result; | ||
| if (!impl) try { | ||
| result = { | ||
| type: "success", | ||
| value: await handler() | ||
| }; | ||
| } catch (e) { | ||
| result = { | ||
| type: "error", | ||
| value: e | ||
| }; | ||
| } | ||
| else { | ||
| if (!impl) { | ||
| try { | ||
| state.result = { | ||
| type: "success", | ||
| value: await handler() | ||
| }; | ||
| } catch (e) { | ||
| state.result = { | ||
| type: "error", | ||
| value: e | ||
| }; | ||
| } | ||
| state.innerResult = getInnerResult(state.result, info); | ||
| } else { | ||
| let handlerPromise = void 0; | ||
| let callHandler = async () => { | ||
| if (handlerPromise) console.error("You cannot call instrumented handlers more than once"); | ||
| else handlerPromise = recurseRight(impls, info, handler, index - 1); | ||
| result = await handlerPromise; | ||
| invariant(result, "Expected a result"); | ||
| if (result.type === "error" && result.value instanceof Error) return { | ||
| status: "error", | ||
| error: result.value | ||
| }; | ||
| return { | ||
| status: "success", | ||
| error: void 0 | ||
| }; | ||
| else handlerPromise = recurseRight(impls, info, handler, getInnerResult, state, index - 1); | ||
| await handlerPromise; | ||
| invariant(state.innerResult, "Expected an inner result"); | ||
| return state.innerResult; | ||
| }; | ||
@@ -183,14 +248,26 @@ try { | ||
| } | ||
| if (result) return result; | ||
| return { | ||
| if (state.result) return state.result; | ||
| state.result = { | ||
| type: "error", | ||
| value: /* @__PURE__ */ new Error("No result assigned in instrumentation chain.") | ||
| }; | ||
| state.innerResult = getInnerResult(state.result, info); | ||
| return state.result; | ||
| } | ||
| function getInstrumentationInnerResult(result) { | ||
| if (result.type === "error" && result.value instanceof Error) return { | ||
| status: "error", | ||
| error: result.value | ||
| }; | ||
| return { | ||
| status: "success", | ||
| error: void 0 | ||
| }; | ||
| } | ||
| function getHandlerInfo(args) { | ||
| let { request, context, params, pattern } = args; | ||
| let { request, context, params } = args; | ||
| return { | ||
| ...args, | ||
| request: getReadonlyRequest(request), | ||
| params: { ...params }, | ||
| pattern, | ||
| context: getReadonlyContext(context) | ||
@@ -219,2 +296,2 @@ }; | ||
| //#endregion | ||
| export { getRouteInstrumentationUpdates, instrumentClientSideRouter, instrumentHandler }; | ||
| export { consumeInstrumentationClientResultMetaReceiver, getRouteInstrumentationUpdates, instrumentClientSideRouter, instrumentHandler, instrumentationResultMetaContext }; |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -775,2 +775,17 @@ * Copyright (c) Remix Software Inc. | ||
| } | ||
| function createDataFunctionUrl(request, path) { | ||
| let url = new URL(typeof request === "string" || request instanceof URL ? request : request.url); | ||
| let parsed = typeof path === "string" ? parsePath(path) : path; | ||
| url.pathname = parsed.pathname || "/"; | ||
| if (parsed.search) { | ||
| let searchParams = new URLSearchParams(parsed.search); | ||
| let indexValues = searchParams.getAll("index"); | ||
| searchParams.delete("index"); | ||
| for (let value of indexValues.filter(Boolean)) searchParams.append("index", value); | ||
| let search = searchParams.toString(); | ||
| url.search = search ? `?${search}` : ""; | ||
| } else url.search = ""; | ||
| url.hash = parsed.hash || ""; | ||
| return url; | ||
| } | ||
| const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined"; | ||
@@ -802,2 +817,2 @@ function parseToInfo(_to, basename) { | ||
| //#endregion | ||
| export { ErrorResponseImpl, RouterContextProvider, SUPPORTED_ERROR_TYPES, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, data, decodePath, defaultMapRouteProperties, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, removeTrailingSlash, replace, resolvePath, resolveTo, stripBasename }; | ||
| export { ErrorResponseImpl, RouterContextProvider, SUPPORTED_ERROR_TYPES, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, createDataFunctionUrl, data, decodePath, defaultMapRouteProperties, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, removeTrailingSlash, replace, resolvePath, resolveTo, stripBasename }; |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -11,4 +11,4 @@ * Copyright (c) Remix Software Inc. | ||
| */ | ||
| import { ErrorResponseImpl, RouterContextProvider, defaultMapRouteProperties, isRouteErrorResponse, removeTrailingSlash, stripBasename } from "../router/utils.js"; | ||
| import { instrumentHandler } from "../router/instrumentation.js"; | ||
| import { ErrorResponseImpl, RouterContextProvider, createDataFunctionUrl, defaultMapRouteProperties, getRoutePattern, isRouteErrorResponse, removeTrailingSlash, stripBasename } from "../router/utils.js"; | ||
| import { instrumentHandler, instrumentationResultMetaContext } from "../router/instrumentation.js"; | ||
| import { createStaticHandler, getStaticContextFromError, isMutationMethod, isRedirectResponse, isResponse } from "../router/router.js"; | ||
@@ -40,2 +40,3 @@ import { getManifestPath } from "../dom/ssr/fog-of-war.js"; | ||
| }); | ||
| let requestHandlerInstrumentations = build.entry.module.instrumentations?.map((i) => i.handler).filter(Boolean); | ||
| let requestHandler = async (request, initialContext) => { | ||
@@ -59,3 +60,4 @@ let params = {}; | ||
| let requestUrl = new URL(request.url); | ||
| let normalizedPathname = getNormalizedPath(request).pathname; | ||
| let normalizedPath = getNormalizedPath(request); | ||
| let normalizedPathname = normalizedPath.pathname; | ||
| let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes"; | ||
@@ -101,2 +103,7 @@ if (!build.ssr) { | ||
| if (matches && matches.length > 0) Object.assign(params, matches[0].params); | ||
| if (requestHandlerInstrumentations?.length) loadContext.set(instrumentationResultMetaContext, { | ||
| url: createDataFunctionUrl(request, normalizedPath), | ||
| pattern: matches ? getRoutePattern(matches) : "", | ||
| params: matches?.[0]?.params ? { ...matches[0].params } : {} | ||
| }); | ||
| let response; | ||
@@ -129,3 +136,3 @@ if (requestUrl.pathname.endsWith(".data")) { | ||
| }; | ||
| if (build.entry.module.instrumentations) requestHandler = instrumentHandler(requestHandler, build.entry.module.instrumentations.map((i) => i.handler).filter(Boolean)); | ||
| if (requestHandlerInstrumentations?.length) requestHandler = instrumentHandler(requestHandler, requestHandlerInstrumentations); | ||
| return { | ||
@@ -132,0 +139,0 @@ serverMode, |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
| /** | ||
| * react-router v8.0.1 | ||
| * react-router v8.1.0 | ||
| * | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -47,4 +47,7 @@ --- | ||
| console.log(`Request start: ${url}`); | ||
| await handleRequest(); | ||
| console.log(`Request end: ${url}`); | ||
| let result = await handleRequest(); | ||
| let pattern = result.meta?.pattern ?? "unknown"; | ||
| console.log( | ||
| `Request end: ${url} (${result.statusCode} ${pattern})`, | ||
| ); | ||
| }, | ||
@@ -96,6 +99,8 @@ }); | ||
| async navigate(callNavigate, { currentUrl, to }) { | ||
| let nav = `${currentUrl} β ${to}`; | ||
| let nav = `${currentUrl} -> ${to}`; | ||
| console.log(`Navigation start: ${nav}`); | ||
| await callNavigate(); | ||
| console.log(`Navigation end: ${nav}`); | ||
| let result = await callNavigate(); | ||
| console.log( | ||
| `Navigation end: ${nav} (${result.meta?.pattern})`, | ||
| ); | ||
| }, | ||
@@ -107,6 +112,8 @@ // Instrument fetcher calls | ||
| ) { | ||
| let fetch = `${fetcherKey} β ${href}`; | ||
| let fetch = `${fetcherKey} -> ${href}`; | ||
| console.log(`Fetcher start: ${fetch}`); | ||
| await callFetch(); | ||
| console.log(`Fetcher end: ${fetch}`); | ||
| let result = await callFetch(); | ||
| console.log( | ||
| `Fetcher end: ${fetch} (${result.meta?.pattern})`, | ||
| ); | ||
| }, | ||
@@ -166,6 +173,8 @@ }); | ||
| async navigate(callNavigate, { currentUrl, to }) { | ||
| let nav = `${currentUrl} β ${to}`; | ||
| let nav = `${currentUrl} -> ${to}`; | ||
| console.log(`Navigation start: ${nav}`); | ||
| await callNavigate(); | ||
| console.log(`Navigation end: ${nav}`); | ||
| let result = await callNavigate(); | ||
| console.log( | ||
| `Navigation end: ${nav} (${result.meta?.pattern})`, | ||
| ); | ||
| }, | ||
@@ -177,6 +186,8 @@ // Instrument fetcher calls | ||
| ) { | ||
| let fetch = `${fetcherKey} β ${href}`; | ||
| let fetch = `${fetcherKey} -> ${href}`; | ||
| console.log(`Fetcher start: ${fetch}`); | ||
| await callFetch(); | ||
| console.log(`Fetcher end: ${fetch}`); | ||
| let result = await callFetch(); | ||
| console.log( | ||
| `Fetcher end: ${fetch} (${result.meta?.pattern})`, | ||
| ); | ||
| }, | ||
@@ -235,3 +246,5 @@ }); | ||
| // Runs around ALL requests to your app | ||
| await handleRequest(); | ||
| let result = await handleRequest(); | ||
| let statusCode = result.statusCode; | ||
| let routePattern = result.meta?.pattern; | ||
| }, | ||
@@ -257,3 +270,4 @@ }); | ||
| // Runs around navigation operations | ||
| await callNavigate(); | ||
| let result = await callNavigate(); | ||
| let routePattern = result.meta?.pattern; | ||
| }, | ||
@@ -265,3 +279,4 @@ async fetch( | ||
| // Runs around fetcher operations | ||
| await callFetch(); | ||
| let result = await callFetch(); | ||
| let routePattern = result.meta?.pattern; | ||
| }, | ||
@@ -338,3 +353,3 @@ }); | ||
| First, if a "handler" function (loader, action, request handler, navigation, etc.) throws an error, that error will not bubble out of the `callHandler` function invoked from your instrumentation. Instead, the `callHandler` function returns a discriminated union result of type `{ type: "success", error: undefined } | { type: "error", error: unknown }`. This ensures your entire instrumentation function runs without needing any try/catch/finally logic to handle application errors. | ||
| First, if a "handler" function (loader, action, request handler, navigation, etc.) throws an error, that error will not bubble out of the `callHandler` function invoked from your instrumentation. Instead, the `callHandler` function returns a discriminated union result of type `{ status: "success", error: undefined } | { status: "error", error: Error }`. This ensures your entire instrumentation function runs without needing any try/catch/finally logic to handle application errors. | ||
@@ -386,2 +401,60 @@ ```tsx | ||
| ### Result Metadata | ||
| Some instrumented calls return additional information that is only available after React Router starts processing the request, navigation, or fetcher call. | ||
| - Route-level instrumentations (`loader`/`action`/`middleware`) don't include `meta` because metadata is available on the `info` parameter | ||
| - Client navigation/fetcher and Server request handler instrumentations return a meta field | ||
| - `meta` contains the same values passed to loaders and actions | ||
| - `url`: The normalized `URL` for the matched route request | ||
| - `pattern`: The matched route pattern, such as `/projects/:id` | ||
| - `params`: The matched route params | ||
| - `meta` may be `undefined` when React Router does not have route metadata for the instrumented call, such as server manifest requests or numeric POP navigations like `navigate(-1)` | ||
| - For client navigations that redirect, `meta` describes the original navigation target instead of the final redirected location. | ||
| - Server request handler instrumentations also return the `statusCode` of the response | ||
| ```tsx | ||
| // entry.server.tsx | ||
| export const instrumentations = [ | ||
| { | ||
| handler(handler) { | ||
| handler.instrument({ | ||
| async request(handleRequest) { | ||
| let result = await handleRequest(); | ||
| let statusCode = result.statusCode; | ||
| let routeUrl = result.meta?.url; | ||
| let routePattern = result.meta?.pattern; | ||
| let routeParams = result.meta?.params; | ||
| }, | ||
| }); | ||
| }, | ||
| }, | ||
| ]; | ||
| // entry.client.tsx | ||
| const instrumentations = [ | ||
| { | ||
| router(router) { | ||
| router.instrument({ | ||
| async navigate(callNavigate) { | ||
| let result = await callNavigate(); | ||
| let routeUrl = result.meta?.url; | ||
| let routePattern = result.meta?.pattern; | ||
| let routeParams = result.meta?.params; | ||
| }, | ||
| async fetch(callFetch) { | ||
| let result = await callFetch(); | ||
| let routeUrl = result.meta?.url; | ||
| let routePattern = result.meta?.pattern; | ||
| let routeParams = result.meta?.params; | ||
| }, | ||
| }); | ||
| }, | ||
| }, | ||
| ]; | ||
| ``` | ||
| ### Composition | ||
@@ -442,4 +515,12 @@ | ||
| instrument({ | ||
| request: (fn, { request }) => | ||
| log(`request ${request.url}`, fn), | ||
| async request(fn, { request }) { | ||
| let label = `request ${request.url}`; | ||
| let start = Date.now(); | ||
| console.log(`-> ${label}`); | ||
| let result = await fn(); | ||
| let pattern = result.meta?.pattern ?? ""; | ||
| console.log( | ||
| `<- ${label} (${Date.now() - start}ms ${result.statusCode} ${pattern})`, | ||
| ); | ||
| }, | ||
| }); | ||
@@ -461,5 +542,5 @@ }, | ||
| let start = Date.now(); | ||
| console.log(`β‘οΈ ${label}`); | ||
| console.log(`-> ${label}`); | ||
| await cb(); | ||
| console.log(`β¬ οΈ ${label} (${Date.now() - start}ms)`); | ||
| console.log(`<- ${label} (${Date.now() - start}ms)`); | ||
| } | ||
@@ -538,6 +619,30 @@ | ||
| instrument({ | ||
| navigate: (fn, { to, currentUrl }) => | ||
| measure(`navigation:${currentUrl}->${to}`, fn), | ||
| fetch: (fn, { href }) => | ||
| measure(`fetcher:${href}`, fn), | ||
| async navigate(fn, { to, currentUrl }) { | ||
| let label = `navigation:${currentUrl}->${to}`; | ||
| performance.mark(`start:${label}`); | ||
| let result = await fn(); | ||
| performance.mark(`end:${label}`); | ||
| performance.measure( | ||
| label, | ||
| `start:${label}`, | ||
| `end:${label}`, | ||
| ); | ||
| console.log( | ||
| `navigation pattern: ${result.meta?.pattern}`, | ||
| ); | ||
| }, | ||
| async fetch(fn, { href }) { | ||
| let label = `fetcher:${href}`; | ||
| performance.mark(`start:${label}`); | ||
| let result = await fn(); | ||
| performance.mark(`end:${label}`); | ||
| performance.measure( | ||
| label, | ||
| `start:${label}`, | ||
| `end:${label}`, | ||
| ); | ||
| console.log( | ||
| `fetcher pattern: ${result.meta?.pattern}`, | ||
| ); | ||
| }, | ||
| }); | ||
@@ -544,0 +649,0 @@ }, |
@@ -12,3 +12,3 @@ --- | ||
| The React Router Vite plugin adds framework features to React Router. This guide will help you adopt the plugin in your app. If you run into any issues, please reach out for help on [Twitter](https://x.com/remix_run) or [Discord](https://rmx.as/discord). | ||
| The React Router Vite plugin adds framework features to React Router. This guide will help you adopt the plugin in your app. If you run into any issues, please reach out for help on [Twitter](https://x.com/remix_run) or [Discord](https://remix.run/discord). | ||
@@ -15,0 +15,0 @@ ## Features |
@@ -10,3 +10,3 @@ --- | ||
| The React Router Vite plugin adds framework features to React Router. This guide will help you adopt the plugin in your app. If you run into any issues, please reach out for help on [Twitter](https://x.com/remix_run) or [Discord](https://rmx.as/discord). | ||
| The React Router Vite plugin adds framework features to React Router. This guide will help you adopt the plugin in your app. If you run into any issues, please reach out for help on [Twitter](https://x.com/remix_run) or [Discord](https://remix.run/discord). | ||
@@ -13,0 +13,0 @@ ## Features |
+1
-1
| { | ||
| "name": "react-router", | ||
| "type": "module", | ||
| "version": "8.0.1", | ||
| "version": "8.1.0", | ||
| "description": "Declarative routing for React", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
2728774
0.86%57140
0.63%60
7.14%