@react-router/dev 0.0.0-experimental-c0856287f
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/CHANGELOG.md +1773 -0
- package/LICENSE.md +23 -0
- package/README.md +13 -0
- package/dist/cli/commands.d.ts +12 -0
- package/dist/cli/commands.js +174 -0
- package/dist/cli/detectPackageManager.d.ts +10 -0
- package/dist/cli/detectPackageManager.js +39 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +19 -0
- package/dist/cli/run.d.ts +5 -0
- package/dist/cli/run.js +180 -0
- package/dist/cli/useJavascript.d.ts +4 -0
- package/dist/cli/useJavascript.js +66 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +21 -0
- package/dist/colors.d.ts +17 -0
- package/dist/colors.js +49 -0
- package/dist/config/defaults/entry.client.tsx +12 -0
- package/dist/config/defaults/entry.dev.d.ts +2 -0
- package/dist/config/defaults/entry.dev.ts +13 -0
- package/dist/config/defaults/entry.server.cloudflare.tsx +55 -0
- package/dist/config/defaults/entry.server.deno.tsx +55 -0
- package/dist/config/defaults/entry.server.node.tsx +155 -0
- package/dist/config/defaults/entry.server.spa.tsx +20 -0
- package/dist/config/flat-routes.d.ts +14 -0
- package/dist/config/flat-routes.js +418 -0
- package/dist/config/format.d.ts +5 -0
- package/dist/config/format.js +68 -0
- package/dist/config/routes.d.ts +98 -0
- package/dist/config/routes.js +93 -0
- package/dist/config/serverModes.d.ts +9 -0
- package/dist/config/serverModes.js +28 -0
- package/dist/config.d.ts +75 -0
- package/dist/config.js +152 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +23 -0
- package/dist/invariant.d.ts +2 -0
- package/dist/invariant.js +22 -0
- package/dist/manifest.d.ts +28 -0
- package/dist/vite/babel.d.ts +20 -0
- package/dist/vite/babel.js +49 -0
- package/dist/vite/build.d.ts +15 -0
- package/dist/vite/build.js +271 -0
- package/dist/vite/cloudflare-proxy-plugin.d.ts +15 -0
- package/dist/vite/cloudflare-proxy-plugin.js +82 -0
- package/dist/vite/dev.d.ts +15 -0
- package/dist/vite/dev.js +81 -0
- package/dist/vite/import-vite-esm-sync.d.ts +4 -0
- package/dist/vite/import-vite-esm-sync.js +28 -0
- package/dist/vite/index.d.ts +4 -0
- package/dist/vite/index.js +30 -0
- package/dist/vite/node-adapter.d.ts +6 -0
- package/dist/vite/node-adapter.js +78 -0
- package/dist/vite/plugin.d.ts +165 -0
- package/dist/vite/plugin.js +1178 -0
- package/dist/vite/profiler.d.ts +5 -0
- package/dist/vite/profiler.js +55 -0
- package/dist/vite/remove-exports-test.d.ts +1 -0
- package/dist/vite/remove-exports.d.ts +2 -0
- package/dist/vite/remove-exports.js +278 -0
- package/dist/vite/resolve-file-url.d.ts +3 -0
- package/dist/vite/resolve-file-url.js +53 -0
- package/dist/vite/static/refresh-utils.cjs +185 -0
- package/dist/vite/styles.d.ts +13 -0
- package/dist/vite/styles.js +176 -0
- package/dist/vite/vmod.d.ts +3 -0
- package/dist/vite/vmod.js +21 -0
- package/package.json +107 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
import("react");
|
|
6
|
+
import("react/jsx-dev-runtime");
|
|
7
|
+
import("react/jsx-runtime");
|
|
8
|
+
import("react-dom");
|
|
9
|
+
import("react-dom/client");
|
|
10
|
+
import("react-refresh/runtime");
|
|
11
|
+
import("react-router-dom");
|
|
12
|
+
import("react-router:hmr");
|
|
13
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AppLoadContext, EntryContext } from "@react-router/cloudflare";
|
|
2
|
+
import { RemixServer } from "react-router";
|
|
3
|
+
import * as isbotModule from "isbot";
|
|
4
|
+
import { renderToReadableStream } from "react-dom/server";
|
|
5
|
+
|
|
6
|
+
export default async function handleRequest(
|
|
7
|
+
request: Request,
|
|
8
|
+
responseStatusCode: number,
|
|
9
|
+
responseHeaders: Headers,
|
|
10
|
+
remixContext: EntryContext,
|
|
11
|
+
loadContext: AppLoadContext
|
|
12
|
+
) {
|
|
13
|
+
const body = await renderToReadableStream(
|
|
14
|
+
<RemixServer context={remixContext} url={request.url} />,
|
|
15
|
+
{
|
|
16
|
+
signal: request.signal,
|
|
17
|
+
onError(error: unknown) {
|
|
18
|
+
// Log streaming rendering errors from inside the shell
|
|
19
|
+
console.error(error);
|
|
20
|
+
responseStatusCode = 500;
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (isBotRequest(request.headers.get("user-agent"))) {
|
|
26
|
+
await body.allReady;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
responseHeaders.set("Content-Type", "text/html");
|
|
30
|
+
return new Response(body, {
|
|
31
|
+
headers: responseHeaders,
|
|
32
|
+
status: responseStatusCode,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// We have some Remix apps in the wild already running with isbot@3 so we need
|
|
37
|
+
// to maintain backwards compatibility even though we want new apps to use
|
|
38
|
+
// isbot@4. That way, we can ship this as a minor Semver update to @react-router/dev.
|
|
39
|
+
function isBotRequest(userAgent: string | null) {
|
|
40
|
+
if (!userAgent) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// isbot >= 3.8.0, >4
|
|
45
|
+
if ("isbot" in isbotModule && typeof isbotModule.isbot === "function") {
|
|
46
|
+
return isbotModule.isbot(userAgent);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// isbot < 3.8.0
|
|
50
|
+
if ("default" in isbotModule && typeof isbotModule.default === "function") {
|
|
51
|
+
return isbotModule.default(userAgent);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AppLoadContext, EntryContext } from "@react-router/deno";
|
|
2
|
+
import { RemixServer } from "@remix-run/react";
|
|
3
|
+
import * as isbotModule from "isbot";
|
|
4
|
+
import { renderToReadableStream } from "react-dom/server";
|
|
5
|
+
|
|
6
|
+
export default async function handleRequest(
|
|
7
|
+
request: Request,
|
|
8
|
+
responseStatusCode: number,
|
|
9
|
+
responseHeaders: Headers,
|
|
10
|
+
remixContext: EntryContext,
|
|
11
|
+
loadContext: AppLoadContext
|
|
12
|
+
) {
|
|
13
|
+
const body = await renderToReadableStream(
|
|
14
|
+
<RemixServer context={remixContext} url={request.url} />,
|
|
15
|
+
{
|
|
16
|
+
signal: request.signal,
|
|
17
|
+
onError(error: unknown) {
|
|
18
|
+
// Log streaming rendering errors from inside the shell
|
|
19
|
+
console.error(error);
|
|
20
|
+
responseStatusCode = 500;
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (isBotRequest(request.headers.get("user-agent"))) {
|
|
26
|
+
await body.allReady;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
responseHeaders.set("Content-Type", "text/html");
|
|
30
|
+
return new Response(body, {
|
|
31
|
+
headers: responseHeaders,
|
|
32
|
+
status: responseStatusCode,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// We have some Remix apps in the wild already running with isbot@3 so we need
|
|
37
|
+
// to maintain backwards compatibility even though we want new apps to use
|
|
38
|
+
// isbot@4. That way, we can ship this as a minor Semver update to @react-router/dev.
|
|
39
|
+
function isBotRequest(userAgent: string | null) {
|
|
40
|
+
if (!userAgent) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// isbot >= 3.8.0, >4
|
|
45
|
+
if ("isbot" in isbotModule && typeof isbotModule.isbot === "function") {
|
|
46
|
+
return isbotModule.isbot(userAgent);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// isbot < 3.8.0
|
|
50
|
+
if ("default" in isbotModule && typeof isbotModule.default === "function") {
|
|
51
|
+
return isbotModule.default(userAgent);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { PassThrough } from "node:stream";
|
|
2
|
+
|
|
3
|
+
import type { AppLoadContext, EntryContext } from "@react-router/node";
|
|
4
|
+
import { createReadableStreamFromReadable } from "@react-router/node";
|
|
5
|
+
import { RemixServer } from "react-router";
|
|
6
|
+
import * as isbotModule from "isbot";
|
|
7
|
+
import { renderToPipeableStream } from "react-dom/server";
|
|
8
|
+
|
|
9
|
+
const ABORT_DELAY = 5_000;
|
|
10
|
+
|
|
11
|
+
export default function handleRequest(
|
|
12
|
+
request: Request,
|
|
13
|
+
responseStatusCode: number,
|
|
14
|
+
responseHeaders: Headers,
|
|
15
|
+
remixContext: EntryContext,
|
|
16
|
+
loadContext: AppLoadContext
|
|
17
|
+
) {
|
|
18
|
+
let prohibitOutOfOrderStreaming =
|
|
19
|
+
isBotRequest(request.headers.get("user-agent")) || remixContext.isSpaMode;
|
|
20
|
+
|
|
21
|
+
return prohibitOutOfOrderStreaming
|
|
22
|
+
? handleBotRequest(
|
|
23
|
+
request,
|
|
24
|
+
responseStatusCode,
|
|
25
|
+
responseHeaders,
|
|
26
|
+
remixContext
|
|
27
|
+
)
|
|
28
|
+
: handleBrowserRequest(
|
|
29
|
+
request,
|
|
30
|
+
responseStatusCode,
|
|
31
|
+
responseHeaders,
|
|
32
|
+
remixContext
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// We have some Remix apps in the wild already running with isbot@3 so we need
|
|
37
|
+
// to maintain backwards compatibility even though we want new apps to use
|
|
38
|
+
// isbot@4. That way, we can ship this as a minor Semver update to @react-router/dev.
|
|
39
|
+
function isBotRequest(userAgent: string | null) {
|
|
40
|
+
if (!userAgent) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// isbot >= 3.8.0, >4
|
|
45
|
+
if ("isbot" in isbotModule && typeof isbotModule.isbot === "function") {
|
|
46
|
+
return isbotModule.isbot(userAgent);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// isbot < 3.8.0
|
|
50
|
+
if ("default" in isbotModule && typeof isbotModule.default === "function") {
|
|
51
|
+
return isbotModule.default(userAgent);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleBotRequest(
|
|
58
|
+
request: Request,
|
|
59
|
+
responseStatusCode: number,
|
|
60
|
+
responseHeaders: Headers,
|
|
61
|
+
remixContext: EntryContext
|
|
62
|
+
) {
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
let shellRendered = false;
|
|
65
|
+
const { pipe, abort } = renderToPipeableStream(
|
|
66
|
+
<RemixServer
|
|
67
|
+
context={remixContext}
|
|
68
|
+
url={request.url}
|
|
69
|
+
abortDelay={ABORT_DELAY}
|
|
70
|
+
/>,
|
|
71
|
+
{
|
|
72
|
+
onAllReady() {
|
|
73
|
+
shellRendered = true;
|
|
74
|
+
const body = new PassThrough();
|
|
75
|
+
const stream = createReadableStreamFromReadable(body);
|
|
76
|
+
|
|
77
|
+
responseHeaders.set("Content-Type", "text/html");
|
|
78
|
+
|
|
79
|
+
resolve(
|
|
80
|
+
new Response(stream, {
|
|
81
|
+
headers: responseHeaders,
|
|
82
|
+
status: responseStatusCode,
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
pipe(body);
|
|
87
|
+
},
|
|
88
|
+
onShellError(error: unknown) {
|
|
89
|
+
reject(error);
|
|
90
|
+
},
|
|
91
|
+
onError(error: unknown) {
|
|
92
|
+
responseStatusCode = 500;
|
|
93
|
+
// Log streaming rendering errors from inside the shell. Don't log
|
|
94
|
+
// errors encountered during initial shell rendering since they'll
|
|
95
|
+
// reject and get logged in handleDocumentRequest.
|
|
96
|
+
if (shellRendered) {
|
|
97
|
+
console.error(error);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
setTimeout(abort, ABORT_DELAY);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function handleBrowserRequest(
|
|
108
|
+
request: Request,
|
|
109
|
+
responseStatusCode: number,
|
|
110
|
+
responseHeaders: Headers,
|
|
111
|
+
remixContext: EntryContext
|
|
112
|
+
) {
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
let shellRendered = false;
|
|
115
|
+
const { pipe, abort } = renderToPipeableStream(
|
|
116
|
+
<RemixServer
|
|
117
|
+
context={remixContext}
|
|
118
|
+
url={request.url}
|
|
119
|
+
abortDelay={ABORT_DELAY}
|
|
120
|
+
/>,
|
|
121
|
+
{
|
|
122
|
+
onShellReady() {
|
|
123
|
+
shellRendered = true;
|
|
124
|
+
const body = new PassThrough();
|
|
125
|
+
const stream = createReadableStreamFromReadable(body);
|
|
126
|
+
|
|
127
|
+
responseHeaders.set("Content-Type", "text/html");
|
|
128
|
+
|
|
129
|
+
resolve(
|
|
130
|
+
new Response(stream, {
|
|
131
|
+
headers: responseHeaders,
|
|
132
|
+
status: responseStatusCode,
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
pipe(body);
|
|
137
|
+
},
|
|
138
|
+
onShellError(error: unknown) {
|
|
139
|
+
reject(error);
|
|
140
|
+
},
|
|
141
|
+
onError(error: unknown) {
|
|
142
|
+
responseStatusCode = 500;
|
|
143
|
+
// Log streaming rendering errors from inside the shell. Don't log
|
|
144
|
+
// errors encountered during initial shell rendering since they'll
|
|
145
|
+
// reject and get logged in handleDocumentRequest.
|
|
146
|
+
if (shellRendered) {
|
|
147
|
+
console.error(error);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
setTimeout(abort, ABORT_DELAY);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EntryContext } from "@react-router/node";
|
|
2
|
+
import { RemixServer } from "react-router";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { renderToString } from "react-dom/server";
|
|
5
|
+
|
|
6
|
+
export default function handleRequest(
|
|
7
|
+
request: Request,
|
|
8
|
+
responseStatusCode: number,
|
|
9
|
+
responseHeaders: Headers,
|
|
10
|
+
remixContext: EntryContext
|
|
11
|
+
) {
|
|
12
|
+
let html = renderToString(
|
|
13
|
+
<RemixServer context={remixContext} url={request.url} />
|
|
14
|
+
);
|
|
15
|
+
html = "<!DOCTYPE html>\n" + html;
|
|
16
|
+
return new Response(html, {
|
|
17
|
+
headers: { "Content-Type": "text/html" },
|
|
18
|
+
status: responseStatusCode,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RouteManifest } from "./routes";
|
|
2
|
+
export declare const routeModuleExts: string[];
|
|
3
|
+
export declare let paramPrefixChar: "$";
|
|
4
|
+
export declare let escapeStart: "[";
|
|
5
|
+
export declare let escapeEnd: "]";
|
|
6
|
+
export declare let optionalStart: "(";
|
|
7
|
+
export declare let optionalEnd: ")";
|
|
8
|
+
export declare function flatRoutes(appDirectory: string, ignoredFilePatterns?: string[], prefix?: string): RouteManifest;
|
|
9
|
+
export declare function flatRoutesUniversal(appDirectory: string, routes: string[], prefix?: string): RouteManifest;
|
|
10
|
+
export declare function getRouteSegments(routeId: string): [string[], string[]];
|
|
11
|
+
export declare function createRoutePath(routeSegments: string[], rawRouteSegments: string[], isIndex?: boolean): string | undefined;
|
|
12
|
+
export declare function getRoutePathConflictErrorMessage(pathname: string, routes: string[]): string;
|
|
13
|
+
export declare function getRouteIdConflictErrorMessage(routeId: string, files: string[]): string;
|
|
14
|
+
export declare function isSegmentSeparator(checkChar: string | undefined): boolean;
|