react-router 0.0.0-experimental-c19b79d → 0.0.0-experimental-e0b6ce9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/{chunk-AGOH44BE.mjs → chunk-4FI4BC6Y.mjs} +67 -51
- package/dist/development/{chunk-IMKEG5CI.mjs → chunk-F6CT5MEB.mjs} +314 -30
- package/dist/development/{chunk-LUB73E44.js → chunk-INO4IHBF.js} +352 -71
- package/dist/development/{chunk-2G2U5HGB.js → chunk-ITZFCV4J.js} +164 -161
- package/dist/development/dom-export.d.mts +59 -4
- package/dist/development/dom-export.d.ts +59 -3
- package/dist/development/dom-export.js +8 -5
- package/dist/development/dom-export.mjs +8 -5
- package/dist/development/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-CYIi6gi0.d.mts} +198 -134
- package/dist/{production/index-react-server-client-DKvU8YRr.d.ts → development/index-react-server-client-ChBGplLn.d.ts} +198 -134
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +3 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +90 -1
- package/dist/development/index-react-server.d.ts +90 -1
- package/dist/development/index-react-server.js +188 -9
- package/dist/development/index-react-server.mjs +188 -9
- package/dist/development/index.d.mts +13 -20
- package/dist/development/index.d.ts +13 -18
- package/dist/development/index.js +161 -147
- package/dist/development/index.mjs +3 -5
- package/dist/development/instrumentation-BGrNA7uj.d.ts +1122 -0
- package/dist/development/lib/types/internal.d.mts +3 -3
- package/dist/development/lib/types/internal.d.ts +3 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{register-BrVEYTED.d.mts → register-DiOIlEq5.d.mts} +1 -7
- package/dist/{production/register-BrVEYTED.d.mts → development/register-DiOIlEq5.d.ts} +1 -7
- package/dist/development/{route-data-CDwqkzPE.d.mts → routeModules-Cy4Xsfoi.d.mts} +157 -147
- package/dist/{production/routeModules-BmVo7q9e.d.ts → development/routeModules-DqotkItD.d.ts} +73 -1046
- package/dist/{production/context-BqL5Eckq.d.mts → development/router-DWv6Clt-.d.mts} +1390 -1253
- package/dist/production/{chunk-AODJW4D3.mjs → chunk-52MYED7O.mjs} +67 -51
- package/dist/production/{chunk-FGRCWJDI.js → chunk-DASXXYNZ.js} +164 -161
- package/dist/production/{chunk-2L5AG5Y5.js → chunk-K7VXYOZD.js} +352 -71
- package/dist/production/{chunk-UOQCOPF6.mjs → chunk-LKSLGWXX.mjs} +314 -30
- package/dist/production/dom-export.d.mts +59 -4
- package/dist/production/dom-export.d.ts +59 -3
- package/dist/production/dom-export.js +8 -5
- package/dist/production/dom-export.mjs +8 -5
- package/dist/production/{index-react-server-client-2EDmGlsZ.d.mts → index-react-server-client-CYIi6gi0.d.mts} +140 -77
- package/dist/{development/index-react-server-client-2EDmGlsZ.d.mts → production/index-react-server-client-ChBGplLn.d.ts} +140 -77
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +3 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +90 -1
- package/dist/production/index-react-server.d.ts +90 -1
- package/dist/production/index-react-server.js +188 -9
- package/dist/production/index-react-server.mjs +188 -9
- package/dist/production/index.d.mts +13 -20
- package/dist/production/index.d.ts +13 -18
- package/dist/production/index.js +161 -147
- package/dist/production/index.mjs +3 -5
- package/dist/production/instrumentation-BGrNA7uj.d.ts +1122 -0
- package/dist/production/lib/types/internal.d.mts +3 -3
- package/dist/production/lib/types/internal.d.ts +3 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-D8NQoPsO.d.ts → production/register-DiOIlEq5.d.mts} +1 -7
- package/dist/production/{register-D8NQoPsO.d.ts → register-DiOIlEq5.d.ts} +1 -7
- package/dist/production/{route-data-CDwqkzPE.d.mts → routeModules-Cy4Xsfoi.d.mts} +157 -147
- package/dist/{development/routeModules-BmVo7q9e.d.ts → production/routeModules-DqotkItD.d.ts} +73 -1046
- package/dist/{development/context-BqL5Eckq.d.mts → production/router-DWv6Clt-.d.mts} +1390 -1253
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { R as RouterProviderProps$1, a as RouterInit, u as unstable_ClientOnErrorFunction } from './
|
|
2
|
+
import { R as RouterProviderProps$1, a as RouterInit, u as unstable_ClientInstrumentation, b as unstable_ClientOnErrorFunction } from './router-DWv6Clt-.mjs';
|
|
3
3
|
import './browser-z32v5KVN.mjs';
|
|
4
4
|
|
|
5
5
|
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
@@ -12,12 +12,67 @@ declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">):
|
|
|
12
12
|
*/
|
|
13
13
|
interface HydratedRouterProps {
|
|
14
14
|
/**
|
|
15
|
-
* Context
|
|
16
|
-
*
|
|
15
|
+
* Context factory function to be passed through to {@link createBrowserRouter}.
|
|
16
|
+
* This function will be called to create a fresh `context` instance on each
|
|
17
|
+
* navigation/fetch and made available to
|
|
17
18
|
* [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
|
|
18
|
-
* functions
|
|
19
|
+
* functions.
|
|
19
20
|
*/
|
|
20
21
|
getContext?: RouterInit["getContext"];
|
|
22
|
+
/**
|
|
23
|
+
* Array of instrumentation objects allowing you to instrument the router and
|
|
24
|
+
* individual routes prior to router initialization (and on any subsequently
|
|
25
|
+
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
|
26
|
+
* mostly useful for observability such as wrapping navigations, fetches,
|
|
27
|
+
* as well as route loaders/actions/middlewares with logging and/or performance
|
|
28
|
+
* tracing.
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* startTransition(() => {
|
|
32
|
+
* hydrateRoot(
|
|
33
|
+
* document,
|
|
34
|
+
* <HydratedRouter unstable_instrumentations={[logging]} />
|
|
35
|
+
* );
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* const logging = {
|
|
39
|
+
* router({ instrument }) {
|
|
40
|
+
* instrument({
|
|
41
|
+
* navigate: (impl, { to }) => logExecution(`navigate ${to}`, impl),
|
|
42
|
+
* fetch: (impl, { to }) => logExecution(`fetch ${to}`, impl)
|
|
43
|
+
* });
|
|
44
|
+
* },
|
|
45
|
+
* route({ instrument, id }) {
|
|
46
|
+
* instrument({
|
|
47
|
+
* middleware: (impl, { request }) => logExecution(
|
|
48
|
+
* `middleware ${request.url} (route ${id})`,
|
|
49
|
+
* impl
|
|
50
|
+
* ),
|
|
51
|
+
* loader: (impl, { request }) => logExecution(
|
|
52
|
+
* `loader ${request.url} (route ${id})`,
|
|
53
|
+
* impl
|
|
54
|
+
* ),
|
|
55
|
+
* action: (impl, { request }) => logExecution(
|
|
56
|
+
* `action ${request.url} (route ${id})`,
|
|
57
|
+
* impl
|
|
58
|
+
* ),
|
|
59
|
+
* })
|
|
60
|
+
* }
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* async function logExecution(label: string, impl: () => Promise<void>) {
|
|
64
|
+
* let start = performance.now();
|
|
65
|
+
* console.log(`start ${label}`);
|
|
66
|
+
* try {
|
|
67
|
+
* await impl();
|
|
68
|
+
* } finally {
|
|
69
|
+
* let end = performance.now();
|
|
70
|
+
* console.log(`end ${label} (${Math.round(end - start)}ms)`);
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
unstable_instrumentations?: unstable_ClientInstrumentation[];
|
|
21
76
|
/**
|
|
22
77
|
* An error handler function that will be called for any loader/action/render
|
|
23
78
|
* errors that are encountered in your application. This is useful for
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RouterProviderProps as RouterProviderProps$1, RouterInit, unstable_ClientOnErrorFunction } from 'react-router';
|
|
3
|
+
import { u as unstable_ClientInstrumentation } from './instrumentation-BGrNA7uj.js';
|
|
3
4
|
|
|
4
5
|
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
5
6
|
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
@@ -11,12 +12,67 @@ declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">):
|
|
|
11
12
|
*/
|
|
12
13
|
interface HydratedRouterProps {
|
|
13
14
|
/**
|
|
14
|
-
* Context
|
|
15
|
-
*
|
|
15
|
+
* Context factory function to be passed through to {@link createBrowserRouter}.
|
|
16
|
+
* This function will be called to create a fresh `context` instance on each
|
|
17
|
+
* navigation/fetch and made available to
|
|
16
18
|
* [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
|
|
17
|
-
* functions
|
|
19
|
+
* functions.
|
|
18
20
|
*/
|
|
19
21
|
getContext?: RouterInit["getContext"];
|
|
22
|
+
/**
|
|
23
|
+
* Array of instrumentation objects allowing you to instrument the router and
|
|
24
|
+
* individual routes prior to router initialization (and on any subsequently
|
|
25
|
+
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
|
26
|
+
* mostly useful for observability such as wrapping navigations, fetches,
|
|
27
|
+
* as well as route loaders/actions/middlewares with logging and/or performance
|
|
28
|
+
* tracing.
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* startTransition(() => {
|
|
32
|
+
* hydrateRoot(
|
|
33
|
+
* document,
|
|
34
|
+
* <HydratedRouter unstable_instrumentations={[logging]} />
|
|
35
|
+
* );
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* const logging = {
|
|
39
|
+
* router({ instrument }) {
|
|
40
|
+
* instrument({
|
|
41
|
+
* navigate: (impl, { to }) => logExecution(`navigate ${to}`, impl),
|
|
42
|
+
* fetch: (impl, { to }) => logExecution(`fetch ${to}`, impl)
|
|
43
|
+
* });
|
|
44
|
+
* },
|
|
45
|
+
* route({ instrument, id }) {
|
|
46
|
+
* instrument({
|
|
47
|
+
* middleware: (impl, { request }) => logExecution(
|
|
48
|
+
* `middleware ${request.url} (route ${id})`,
|
|
49
|
+
* impl
|
|
50
|
+
* ),
|
|
51
|
+
* loader: (impl, { request }) => logExecution(
|
|
52
|
+
* `loader ${request.url} (route ${id})`,
|
|
53
|
+
* impl
|
|
54
|
+
* ),
|
|
55
|
+
* action: (impl, { request }) => logExecution(
|
|
56
|
+
* `action ${request.url} (route ${id})`,
|
|
57
|
+
* impl
|
|
58
|
+
* ),
|
|
59
|
+
* })
|
|
60
|
+
* }
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* async function logExecution(label: string, impl: () => Promise<void>) {
|
|
64
|
+
* let start = performance.now();
|
|
65
|
+
* console.log(`start ${label}`);
|
|
66
|
+
* try {
|
|
67
|
+
* await impl();
|
|
68
|
+
* } finally {
|
|
69
|
+
* let end = performance.now();
|
|
70
|
+
* console.log(`end ${label} (${Math.round(end - start)}ms)`);
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
unstable_instrumentations?: unstable_ClientInstrumentation[];
|
|
20
76
|
/**
|
|
21
77
|
* An error handler function that will be called for any loader/action/render
|
|
22
78
|
* errors that are encountered in your application. This is useful for
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e0b6ce9
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"use client";
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkINO4IHBFjs = require('./chunk-INO4IHBF.js');
|
|
15
15
|
|
|
16
16
|
// lib/dom-export/dom-router-provider.tsx
|
|
17
17
|
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
|
|
@@ -67,7 +67,8 @@ function initSsrInfo() {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
function createHydratedRouter({
|
|
70
|
-
getContext
|
|
70
|
+
getContext,
|
|
71
|
+
unstable_instrumentations
|
|
71
72
|
}) {
|
|
72
73
|
initSsrInfo();
|
|
73
74
|
if (!ssrInfo) {
|
|
@@ -134,6 +135,7 @@ function createHydratedRouter({
|
|
|
134
135
|
getContext,
|
|
135
136
|
hydrationData,
|
|
136
137
|
hydrationRouteProperties: _reactrouter.UNSAFE_hydrationRouteProperties,
|
|
138
|
+
unstable_instrumentations,
|
|
137
139
|
mapRouteProperties: _reactrouter.UNSAFE_mapRouteProperties,
|
|
138
140
|
future: {
|
|
139
141
|
middleware: ssrInfo.context.future.v8_middleware
|
|
@@ -167,7 +169,8 @@ function createHydratedRouter({
|
|
|
167
169
|
function HydratedRouter(props) {
|
|
168
170
|
if (!router) {
|
|
169
171
|
router = createHydratedRouter({
|
|
170
|
-
getContext: props.getContext
|
|
172
|
+
getContext: props.getContext,
|
|
173
|
+
unstable_instrumentations: props.unstable_instrumentations
|
|
171
174
|
});
|
|
172
175
|
}
|
|
173
176
|
let [criticalCss, setCriticalCss] = React2.useState(
|
|
@@ -180,7 +183,7 @@ function HydratedRouter(props) {
|
|
|
180
183
|
}, []);
|
|
181
184
|
React2.useEffect(() => {
|
|
182
185
|
if (process.env.NODE_ENV === "development" && criticalCss === void 0) {
|
|
183
|
-
document.querySelectorAll(`[${
|
|
186
|
+
document.querySelectorAll(`[${_chunkINO4IHBFjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
|
|
184
187
|
}
|
|
185
188
|
}, [criticalCss]);
|
|
186
189
|
let [location, setLocation] = React2.useState(router.state.location);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e0b6ce9
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import {
|
|
13
13
|
deserializeErrors,
|
|
14
14
|
getHydrationData
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4FI4BC6Y.mjs";
|
|
16
16
|
import {
|
|
17
17
|
CRITICAL_CSS_DATA_ATTRIBUTE,
|
|
18
18
|
FrameworkContext,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
invariant,
|
|
30
30
|
mapRouteProperties,
|
|
31
31
|
useFogOFWarDiscovery
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-F6CT5MEB.mjs";
|
|
33
33
|
|
|
34
34
|
// lib/dom-export/dom-router-provider.tsx
|
|
35
35
|
import * as React from "react";
|
|
@@ -67,7 +67,8 @@ function initSsrInfo() {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
function createHydratedRouter({
|
|
70
|
-
getContext
|
|
70
|
+
getContext,
|
|
71
|
+
unstable_instrumentations
|
|
71
72
|
}) {
|
|
72
73
|
initSsrInfo();
|
|
73
74
|
if (!ssrInfo) {
|
|
@@ -134,6 +135,7 @@ function createHydratedRouter({
|
|
|
134
135
|
getContext,
|
|
135
136
|
hydrationData,
|
|
136
137
|
hydrationRouteProperties,
|
|
138
|
+
unstable_instrumentations,
|
|
137
139
|
mapRouteProperties,
|
|
138
140
|
future: {
|
|
139
141
|
middleware: ssrInfo.context.future.v8_middleware
|
|
@@ -167,7 +169,8 @@ function createHydratedRouter({
|
|
|
167
169
|
function HydratedRouter(props) {
|
|
168
170
|
if (!router) {
|
|
169
171
|
router = createHydratedRouter({
|
|
170
|
-
getContext: props.getContext
|
|
172
|
+
getContext: props.getContext,
|
|
173
|
+
unstable_instrumentations: props.unstable_instrumentations
|
|
171
174
|
});
|
|
172
175
|
}
|
|
173
176
|
let [criticalCss, setCriticalCss] = React2.useState(
|
|
@@ -1,5 +1,148 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bc as RouteManifest, H as HydrationState, G as DataRouteObject, Q as StaticHandlerContext, e as MiddlewareEnabled, c as RouterContextProvider, f as LoaderFunctionArgs, A as ActionFunctionArgs, ad as unstable_ServerInstrumentation, a4 as HTMLFormMethod, a2 as FormEncType, n as RelativeRoutingType, T as To, bd as History, O as GetScrollRestorationKeyFunction, a as RouterInit, be as FutureConfig$1, u as unstable_ClientInstrumentation, l as DataStrategyFunction, F as PatchRoutesOnNavigationFunction, N as NavigateOptions, V as Fetcher, v as RouteObject, k as Router, B as BlockerFunction, L as Location, bf as CreateStaticHandlerOptions$1, J as StaticHandler } from './router-DWv6Clt-.mjs';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { c as RouteModules, h as ClientLoaderFunction, o as ServerRouteModule, A as AppLoadContext, m as PageLinkDescriptor, d as SerializeFrom } from './routeModules-Cy4Xsfoi.mjs';
|
|
4
|
+
|
|
5
|
+
interface Route {
|
|
6
|
+
index?: boolean;
|
|
7
|
+
caseSensitive?: boolean;
|
|
8
|
+
id: string;
|
|
9
|
+
parentId?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
}
|
|
12
|
+
interface EntryRoute extends Route {
|
|
13
|
+
hasAction: boolean;
|
|
14
|
+
hasLoader: boolean;
|
|
15
|
+
hasClientAction: boolean;
|
|
16
|
+
hasClientLoader: boolean;
|
|
17
|
+
hasClientMiddleware: boolean;
|
|
18
|
+
hasErrorBoundary: boolean;
|
|
19
|
+
imports?: string[];
|
|
20
|
+
css?: string[];
|
|
21
|
+
module: string;
|
|
22
|
+
clientActionModule: string | undefined;
|
|
23
|
+
clientLoaderModule: string | undefined;
|
|
24
|
+
clientMiddlewareModule: string | undefined;
|
|
25
|
+
hydrateFallbackModule: string | undefined;
|
|
26
|
+
parentId?: string;
|
|
27
|
+
}
|
|
28
|
+
declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, ssr: boolean, isSpaMode: boolean): DataRouteObject[];
|
|
29
|
+
declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, ssr: boolean, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
|
|
30
|
+
declare function shouldHydrateRouteLoader(routeId: string, clientLoader: ClientLoaderFunction | undefined, hasLoader: boolean, isSpaMode: boolean): boolean;
|
|
31
|
+
|
|
32
|
+
type SerializedError = {
|
|
33
|
+
message: string;
|
|
34
|
+
stack?: string;
|
|
35
|
+
};
|
|
36
|
+
interface FrameworkContextObject {
|
|
37
|
+
manifest: AssetsManifest;
|
|
38
|
+
routeModules: RouteModules;
|
|
39
|
+
criticalCss?: CriticalCss;
|
|
40
|
+
serverHandoffString?: string;
|
|
41
|
+
future: FutureConfig;
|
|
42
|
+
ssr: boolean;
|
|
43
|
+
isSpaMode: boolean;
|
|
44
|
+
routeDiscovery: ServerBuild["routeDiscovery"];
|
|
45
|
+
serializeError?(error: Error): SerializedError;
|
|
46
|
+
renderMeta?: {
|
|
47
|
+
didRenderScripts?: boolean;
|
|
48
|
+
streamCache?: Record<number, Promise<void> & {
|
|
49
|
+
result?: {
|
|
50
|
+
done: boolean;
|
|
51
|
+
value: string;
|
|
52
|
+
};
|
|
53
|
+
error?: unknown;
|
|
54
|
+
}>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
interface EntryContext extends FrameworkContextObject {
|
|
58
|
+
staticHandlerContext: StaticHandlerContext;
|
|
59
|
+
serverHandoffStream?: ReadableStream<Uint8Array>;
|
|
60
|
+
}
|
|
61
|
+
interface FutureConfig {
|
|
62
|
+
unstable_subResourceIntegrity: boolean;
|
|
63
|
+
v8_middleware: boolean;
|
|
64
|
+
}
|
|
65
|
+
type CriticalCss = string | {
|
|
66
|
+
rel: "stylesheet";
|
|
67
|
+
href: string;
|
|
68
|
+
};
|
|
69
|
+
interface AssetsManifest {
|
|
70
|
+
entry: {
|
|
71
|
+
imports: string[];
|
|
72
|
+
module: string;
|
|
73
|
+
};
|
|
74
|
+
routes: RouteManifest<EntryRoute>;
|
|
75
|
+
url: string;
|
|
76
|
+
version: string;
|
|
77
|
+
hmr?: {
|
|
78
|
+
timestamp?: number;
|
|
79
|
+
runtime: string;
|
|
80
|
+
};
|
|
81
|
+
sri?: Record<string, string> | true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
|
|
85
|
+
interface ServerRoute extends Route {
|
|
86
|
+
children: ServerRoute[];
|
|
87
|
+
module: ServerRouteModule;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
type OptionalCriticalCss = CriticalCss | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* The output of the compiler for the server build.
|
|
93
|
+
*/
|
|
94
|
+
interface ServerBuild {
|
|
95
|
+
entry: {
|
|
96
|
+
module: ServerEntryModule;
|
|
97
|
+
};
|
|
98
|
+
routes: ServerRouteManifest;
|
|
99
|
+
assets: AssetsManifest;
|
|
100
|
+
basename?: string;
|
|
101
|
+
publicPath: string;
|
|
102
|
+
assetsBuildDirectory: string;
|
|
103
|
+
future: FutureConfig;
|
|
104
|
+
ssr: boolean;
|
|
105
|
+
unstable_getCriticalCss?: (args: {
|
|
106
|
+
pathname: string;
|
|
107
|
+
}) => OptionalCriticalCss | Promise<OptionalCriticalCss>;
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated This is now done via a custom header during prerendering
|
|
110
|
+
*/
|
|
111
|
+
isSpaMode: boolean;
|
|
112
|
+
prerender: string[];
|
|
113
|
+
routeDiscovery: {
|
|
114
|
+
mode: "lazy" | "initial";
|
|
115
|
+
manifestPath: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface HandleDocumentRequestFunction {
|
|
119
|
+
(request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: MiddlewareEnabled extends true ? RouterContextProvider : AppLoadContext): Promise<Response> | Response;
|
|
120
|
+
}
|
|
121
|
+
interface HandleDataRequestFunction {
|
|
122
|
+
(response: Response, args: {
|
|
123
|
+
request: LoaderFunctionArgs["request"] | ActionFunctionArgs["request"];
|
|
124
|
+
context: LoaderFunctionArgs["context"] | ActionFunctionArgs["context"];
|
|
125
|
+
params: LoaderFunctionArgs["params"] | ActionFunctionArgs["params"];
|
|
126
|
+
}): Promise<Response> | Response;
|
|
127
|
+
}
|
|
128
|
+
interface HandleErrorFunction {
|
|
129
|
+
(error: unknown, args: {
|
|
130
|
+
request: LoaderFunctionArgs["request"] | ActionFunctionArgs["request"];
|
|
131
|
+
context: LoaderFunctionArgs["context"] | ActionFunctionArgs["context"];
|
|
132
|
+
params: LoaderFunctionArgs["params"] | ActionFunctionArgs["params"];
|
|
133
|
+
}): void;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A module that serves as the entry point for a Remix app during server
|
|
137
|
+
* rendering.
|
|
138
|
+
*/
|
|
139
|
+
interface ServerEntryModule {
|
|
140
|
+
default: HandleDocumentRequestFunction;
|
|
141
|
+
handleDataRequest?: HandleDataRequestFunction;
|
|
142
|
+
handleError?: HandleErrorFunction;
|
|
143
|
+
unstable_instrumentations?: unstable_ServerInstrumentation[];
|
|
144
|
+
streamTimeout?: number;
|
|
145
|
+
}
|
|
3
146
|
|
|
4
147
|
type ParamKeyValuePair = [string, string];
|
|
5
148
|
type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
|
|
@@ -107,139 +250,6 @@ interface SubmitOptions extends FetcherSubmitOptions {
|
|
|
107
250
|
viewTransition?: boolean;
|
|
108
251
|
}
|
|
109
252
|
|
|
110
|
-
type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
|
|
111
|
-
interface ServerRoute extends Route {
|
|
112
|
-
children: ServerRoute[];
|
|
113
|
-
module: ServerRouteModule;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
type OptionalCriticalCss = CriticalCss | undefined;
|
|
117
|
-
/**
|
|
118
|
-
* The output of the compiler for the server build.
|
|
119
|
-
*/
|
|
120
|
-
interface ServerBuild {
|
|
121
|
-
entry: {
|
|
122
|
-
module: ServerEntryModule;
|
|
123
|
-
};
|
|
124
|
-
routes: ServerRouteManifest;
|
|
125
|
-
assets: AssetsManifest;
|
|
126
|
-
basename?: string;
|
|
127
|
-
publicPath: string;
|
|
128
|
-
assetsBuildDirectory: string;
|
|
129
|
-
future: FutureConfig;
|
|
130
|
-
ssr: boolean;
|
|
131
|
-
unstable_getCriticalCss?: (args: {
|
|
132
|
-
pathname: string;
|
|
133
|
-
}) => OptionalCriticalCss | Promise<OptionalCriticalCss>;
|
|
134
|
-
/**
|
|
135
|
-
* @deprecated This is now done via a custom header during prerendering
|
|
136
|
-
*/
|
|
137
|
-
isSpaMode: boolean;
|
|
138
|
-
prerender: string[];
|
|
139
|
-
routeDiscovery: {
|
|
140
|
-
mode: "lazy" | "initial";
|
|
141
|
-
manifestPath: string;
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
interface HandleDocumentRequestFunction {
|
|
145
|
-
(request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: MiddlewareEnabled extends true ? RouterContextProvider : AppLoadContext): Promise<Response> | Response;
|
|
146
|
-
}
|
|
147
|
-
interface HandleDataRequestFunction {
|
|
148
|
-
(response: Response, args: LoaderFunctionArgs | ActionFunctionArgs): Promise<Response> | Response;
|
|
149
|
-
}
|
|
150
|
-
interface HandleErrorFunction {
|
|
151
|
-
(error: unknown, args: LoaderFunctionArgs | ActionFunctionArgs): void;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* A module that serves as the entry point for a Remix app during server
|
|
155
|
-
* rendering.
|
|
156
|
-
*/
|
|
157
|
-
interface ServerEntryModule {
|
|
158
|
-
default: HandleDocumentRequestFunction;
|
|
159
|
-
handleDataRequest?: HandleDataRequestFunction;
|
|
160
|
-
handleError?: HandleErrorFunction;
|
|
161
|
-
streamTimeout?: number;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
interface Route {
|
|
165
|
-
index?: boolean;
|
|
166
|
-
caseSensitive?: boolean;
|
|
167
|
-
id: string;
|
|
168
|
-
parentId?: string;
|
|
169
|
-
path?: string;
|
|
170
|
-
}
|
|
171
|
-
interface EntryRoute extends Route {
|
|
172
|
-
hasAction: boolean;
|
|
173
|
-
hasLoader: boolean;
|
|
174
|
-
hasClientAction: boolean;
|
|
175
|
-
hasClientLoader: boolean;
|
|
176
|
-
hasClientMiddleware: boolean;
|
|
177
|
-
hasErrorBoundary: boolean;
|
|
178
|
-
imports?: string[];
|
|
179
|
-
css?: string[];
|
|
180
|
-
module: string;
|
|
181
|
-
clientActionModule: string | undefined;
|
|
182
|
-
clientLoaderModule: string | undefined;
|
|
183
|
-
clientMiddlewareModule: string | undefined;
|
|
184
|
-
hydrateFallbackModule: string | undefined;
|
|
185
|
-
parentId?: string;
|
|
186
|
-
}
|
|
187
|
-
declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, ssr: boolean, isSpaMode: boolean): DataRouteObject[];
|
|
188
|
-
declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState | null, ssr: boolean, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
|
|
189
|
-
declare function shouldHydrateRouteLoader(routeId: string, clientLoader: ClientLoaderFunction | undefined, hasLoader: boolean, isSpaMode: boolean): boolean;
|
|
190
|
-
|
|
191
|
-
type SerializedError = {
|
|
192
|
-
message: string;
|
|
193
|
-
stack?: string;
|
|
194
|
-
};
|
|
195
|
-
interface FrameworkContextObject {
|
|
196
|
-
manifest: AssetsManifest;
|
|
197
|
-
routeModules: RouteModules;
|
|
198
|
-
criticalCss?: CriticalCss;
|
|
199
|
-
serverHandoffString?: string;
|
|
200
|
-
future: FutureConfig;
|
|
201
|
-
ssr: boolean;
|
|
202
|
-
isSpaMode: boolean;
|
|
203
|
-
routeDiscovery: ServerBuild["routeDiscovery"];
|
|
204
|
-
serializeError?(error: Error): SerializedError;
|
|
205
|
-
renderMeta?: {
|
|
206
|
-
didRenderScripts?: boolean;
|
|
207
|
-
streamCache?: Record<number, Promise<void> & {
|
|
208
|
-
result?: {
|
|
209
|
-
done: boolean;
|
|
210
|
-
value: string;
|
|
211
|
-
};
|
|
212
|
-
error?: unknown;
|
|
213
|
-
}>;
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
interface EntryContext extends FrameworkContextObject {
|
|
217
|
-
staticHandlerContext: StaticHandlerContext;
|
|
218
|
-
serverHandoffStream?: ReadableStream<Uint8Array>;
|
|
219
|
-
}
|
|
220
|
-
interface FutureConfig {
|
|
221
|
-
unstable_subResourceIntegrity: boolean;
|
|
222
|
-
v8_middleware: boolean;
|
|
223
|
-
}
|
|
224
|
-
type CriticalCss = string | {
|
|
225
|
-
rel: "stylesheet";
|
|
226
|
-
href: string;
|
|
227
|
-
};
|
|
228
|
-
interface AssetsManifest {
|
|
229
|
-
entry: {
|
|
230
|
-
imports: string[];
|
|
231
|
-
module: string;
|
|
232
|
-
};
|
|
233
|
-
routes: RouteManifest<EntryRoute>;
|
|
234
|
-
url: string;
|
|
235
|
-
version: string;
|
|
236
|
-
hmr?: {
|
|
237
|
-
timestamp?: number;
|
|
238
|
-
runtime: string;
|
|
239
|
-
};
|
|
240
|
-
sri?: Record<string, string> | true;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
253
|
declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
|
|
244
254
|
/**
|
|
245
255
|
* Defines the discovery behavior of the link:
|
|
@@ -521,6 +531,58 @@ interface DOMRouterOpts {
|
|
|
521
531
|
* ```
|
|
522
532
|
*/
|
|
523
533
|
hydrationData?: HydrationState;
|
|
534
|
+
/**
|
|
535
|
+
* Array of instrumentation objects allowing you to instrument the router and
|
|
536
|
+
* individual routes prior to router initialization (and on any subsequently
|
|
537
|
+
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
|
538
|
+
* mostly useful for observability such as wrapping navigations, fetches,
|
|
539
|
+
* as well as route loaders/actions/middlewares with logging and/or performance
|
|
540
|
+
* tracing.
|
|
541
|
+
*
|
|
542
|
+
* ```tsx
|
|
543
|
+
* let router = createBrowserRouter(routes, {
|
|
544
|
+
* unstable_instrumentations: [logging]
|
|
545
|
+
* });
|
|
546
|
+
*
|
|
547
|
+
*
|
|
548
|
+
* let logging = {
|
|
549
|
+
* router({ instrument }) {
|
|
550
|
+
* instrument({
|
|
551
|
+
* navigate: (impl, info) => logExecution(`navigate ${info.to}`, impl),
|
|
552
|
+
* fetch: (impl, info) => logExecution(`fetch ${info.to}`, impl)
|
|
553
|
+
* });
|
|
554
|
+
* },
|
|
555
|
+
* route({ instrument, id }) {
|
|
556
|
+
* instrument({
|
|
557
|
+
* middleware: (impl, info) => logExecution(
|
|
558
|
+
* `middleware ${info.request.url} (route ${id})`,
|
|
559
|
+
* impl
|
|
560
|
+
* ),
|
|
561
|
+
* loader: (impl, info) => logExecution(
|
|
562
|
+
* `loader ${info.request.url} (route ${id})`,
|
|
563
|
+
* impl
|
|
564
|
+
* ),
|
|
565
|
+
* action: (impl, info) => logExecution(
|
|
566
|
+
* `action ${info.request.url} (route ${id})`,
|
|
567
|
+
* impl
|
|
568
|
+
* ),
|
|
569
|
+
* })
|
|
570
|
+
* }
|
|
571
|
+
* };
|
|
572
|
+
*
|
|
573
|
+
* async function logExecution(label: string, impl: () => Promise<void>) {
|
|
574
|
+
* let start = performance.now();
|
|
575
|
+
* console.log(`start ${label}`);
|
|
576
|
+
* try {
|
|
577
|
+
* await impl();
|
|
578
|
+
* } finally {
|
|
579
|
+
* let end = performance.now();
|
|
580
|
+
* console.log(`end ${label} (${Math.round(end - start)}ms)`);
|
|
581
|
+
* }
|
|
582
|
+
* }
|
|
583
|
+
* ```
|
|
584
|
+
*/
|
|
585
|
+
unstable_instrumentations?: unstable_ClientInstrumentation[];
|
|
524
586
|
/**
|
|
525
587
|
* Override the default data strategy of running loaders in parallel.
|
|
526
588
|
* See {@link DataStrategyFunction}.
|
|
@@ -1026,6 +1088,7 @@ interface DOMRouterOpts {
|
|
|
1026
1088
|
* @param {DOMRouterOpts.future} opts.future n/a
|
|
1027
1089
|
* @param {DOMRouterOpts.getContext} opts.getContext n/a
|
|
1028
1090
|
* @param {DOMRouterOpts.hydrationData} opts.hydrationData n/a
|
|
1091
|
+
* @param {DOMRouterOpts.unstable_instrumentations} opts.unstable_instrumentations n/a
|
|
1029
1092
|
* @param {DOMRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
|
|
1030
1093
|
* @param {DOMRouterOpts.window} opts.window n/a
|
|
1031
1094
|
* @returns An initialized {@link DataRouter| data router} to pass to {@link RouterProvider | `<RouterProvider>`}
|
|
@@ -1044,6 +1107,7 @@ declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts
|
|
|
1044
1107
|
* @param {DOMRouterOpts.future} opts.future n/a
|
|
1045
1108
|
* @param {DOMRouterOpts.getContext} opts.getContext n/a
|
|
1046
1109
|
* @param {DOMRouterOpts.hydrationData} opts.hydrationData n/a
|
|
1110
|
+
* @param {DOMRouterOpts.unstable_instrumentations} opts.unstable_instrumentations n/a
|
|
1047
1111
|
* @param {DOMRouterOpts.dataStrategy} opts.dataStrategy n/a
|
|
1048
1112
|
* @param {DOMRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
|
|
1049
1113
|
* @param {DOMRouterOpts.window} opts.window n/a
|