@cedarjs/vite 7.0.0 → 8.0.0-canary.3265
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/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +3 -7
- package/dist/buildRouteHooks.d.ts +7 -13
- package/dist/buildRouteHooks.d.ts.map +1 -1
- package/dist/buildRouteHooks.js +5 -10
- package/dist/bundled/react-server-dom-webpack.server.js +2263 -29124
- package/dist/devFeServer.js +278 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/lib/registerFwGlobalsAndShims.js +9 -0
- package/dist/plugins/vite-plugin-cedar-cell.d.ts +2 -1
- package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-cell.js +30 -11
- package/dist/plugins/vite-plugin-cedar-parsed-scalars.d.ts +20 -0
- package/dist/plugins/vite-plugin-cedar-parsed-scalars.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-parsed-scalars.js +60 -0
- package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts +2 -6
- package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-handler-als-wrapping.js +4 -7
- package/dist/plugins/vite-plugin-rsc-ssr-router-import.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-rsc-ssr-router-import.js +2 -2
- package/dist/plugins/vite-plugin-rsc-transform-server.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-rsc-transform-server.js +4 -0
- package/dist/rsc/rscRenderer.d.ts.map +1 -1
- package/dist/rsc/rscRenderer.js +19 -5
- package/dist/rsc/rscRequestHandler.d.ts +2 -2
- package/dist/rsc/rscRequestHandler.d.ts.map +1 -1
- package/dist/rsc/rscRequestHandler.js +4 -4
- package/dist/rsc/rscWebSocketServer.d.ts +2 -0
- package/dist/rsc/rscWebSocketServer.d.ts.map +1 -0
- package/dist/rsc/rscWebSocketServer.js +22 -0
- package/dist/rsc/utils.d.ts +10 -0
- package/dist/rsc/utils.d.ts.map +1 -0
- package/dist/rsc/utils.js +21 -0
- package/dist/runFeServer.js +5 -24
- package/dist/streaming/createReactStreamingHandler.d.ts +1 -1
- package/dist/streaming/createReactStreamingHandler.d.ts.map +1 -1
- package/dist/streaming/createReactStreamingHandler.js +13 -10
- package/dist/streaming/streamHelpers.d.ts +8 -3
- package/dist/streaming/streamHelpers.d.ts.map +1 -1
- package/dist/streaming/streamHelpers.js +50 -32
- package/dist/streaming/triggerRouteHooks.d.ts +2 -2
- package/dist/streaming/triggerRouteHooks.d.ts.map +1 -1
- package/dist/streaming/triggerRouteHooks.js +3 -3
- package/package.json +32 -30
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { normalizePath } from "vite";
|
|
3
3
|
import { getPaths } from "@cedarjs/project-config";
|
|
4
|
-
function handlerAlsWrappingPlugin({
|
|
5
|
-
projectIsEsm = false
|
|
6
|
-
} = {}) {
|
|
4
|
+
function handlerAlsWrappingPlugin() {
|
|
7
5
|
return {
|
|
8
6
|
name: "handler-als-wrapping",
|
|
9
7
|
transform(code, id) {
|
|
@@ -17,12 +15,12 @@ function handlerAlsWrappingPlugin({
|
|
|
17
15
|
if (!normalizePath(id).startsWith(functionsDir + "/")) {
|
|
18
16
|
return null;
|
|
19
17
|
}
|
|
20
|
-
const wrapped = applyHandlerAlsWrapping(code
|
|
18
|
+
const wrapped = applyHandlerAlsWrapping(code);
|
|
21
19
|
return wrapped ? { code: wrapped, map: null } : null;
|
|
22
20
|
}
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
|
-
function applyHandlerAlsWrapping(code
|
|
23
|
+
function applyHandlerAlsWrapping(code) {
|
|
26
24
|
const handlerRe = /^export\s+(?:const|let|var)\s+handler(?:[^=]|=>)*?=(?![>=])/m;
|
|
27
25
|
const handlerMatch = handlerRe.exec(code);
|
|
28
26
|
if (!handlerMatch) {
|
|
@@ -30,8 +28,7 @@ function applyHandlerAlsWrapping(code, { projectIsEsm = false } = {}) {
|
|
|
30
28
|
}
|
|
31
29
|
const afterEquals = code.slice(handlerMatch.index + handlerMatch[0].length).trimStart();
|
|
32
30
|
const isAsync = /^async(?:\s*[\(\*]|\s+function)/.test(afterEquals);
|
|
33
|
-
const
|
|
34
|
-
const importStatement = `import { getAsyncStoreInstance as __cedar_getAsyncStoreInstance } from '${storePath}'
|
|
31
|
+
const importStatement = `import { getAsyncStoreInstance as __cedar_getAsyncStoreInstance } from '@cedarjs/context/dist/store.js'
|
|
35
32
|
`;
|
|
36
33
|
const handlerStart = handlerMatch.index;
|
|
37
34
|
const before = code.slice(0, handlerStart);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-rsc-ssr-router-import.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-rsc-ssr-router-import.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"vite-plugin-rsc-ssr-router-import.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-rsc-ssr-router-import.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAsC3C"}
|
|
@@ -11,8 +11,8 @@ function rscSsrRouterImport() {
|
|
|
11
11
|
const routesFileId = normalizePath(getPaths().web.routes);
|
|
12
12
|
return {
|
|
13
13
|
name: "rsc-ssr-router-import",
|
|
14
|
-
transform: async function(code, id) {
|
|
15
|
-
if (id !== routesFileId) {
|
|
14
|
+
transform: async function(code, id, options) {
|
|
15
|
+
if (!options?.ssr || id !== routesFileId) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
const ext = path.extname(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-rsc-transform-server.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-rsc-transform-server.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,MAAM,
|
|
1
|
+
{"version":3,"file":"vite-plugin-rsc-transform-server.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-rsc-transform-server.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,MAAM,CAuHR"}
|
|
@@ -8,6 +8,10 @@ function rscTransformUseServerPlugin(outDir, serverEntryFiles) {
|
|
|
8
8
|
if (!code.includes("use server")) {
|
|
9
9
|
return code;
|
|
10
10
|
}
|
|
11
|
+
if (id.includes("node_modules/.vite") || id.includes("/react-server-dom-webpack/") || id.includes("/react-server-dom-webpack.server")) {
|
|
12
|
+
console.log("vite-plugin-rsc-transform-server.ts: Skipping", id);
|
|
13
|
+
return code;
|
|
14
|
+
}
|
|
11
15
|
let mod;
|
|
12
16
|
const isTypescript = id.endsWith(".ts") || id.endsWith(".tsx");
|
|
13
17
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rscRenderer.d.ts","sourceRoot":"","sources":["../../src/rsc/rscRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"rscRenderer.d.ts","sourceRoot":"","sources":["../../src/rsc/rscRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AASrD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,CAAA;CAC7B,CAAA;AAID,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,cAAc,CAAC,CAEzB;AAyCD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CA2BtD"}
|
package/dist/rsc/rscRenderer.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { createElement } from "react";
|
|
3
|
-
import { renderToReadableStream } from "react-server-dom-webpack/server.edge";
|
|
4
2
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
3
|
import { getEntriesFromDist } from "../lib/entries.js";
|
|
6
4
|
import { StatusError } from "../lib/StatusError.js";
|
|
5
|
+
import { importRscReact, importRsdwServer } from "./utils.js";
|
|
7
6
|
let absoluteClientEntries = {};
|
|
8
|
-
function renderRscToStream(input) {
|
|
7
|
+
async function renderRscToStream(input) {
|
|
9
8
|
return input.rscId ? renderRsc(input) : executeRsa(input);
|
|
10
9
|
}
|
|
11
10
|
async function loadServerFile(filePath) {
|
|
12
11
|
console.log("rscRenderer.ts loadServerFile filePath", filePath);
|
|
12
|
+
if (globalThis.__cedarjs__vite_rsc_runtime) {
|
|
13
|
+
const serverMod = await globalThis.__cedarjs__vite_rsc_runtime.import(filePath);
|
|
14
|
+
return serverMod.default ? serverMod.default : serverMod;
|
|
15
|
+
}
|
|
13
16
|
return import(`file://${filePath}`);
|
|
14
17
|
}
|
|
15
18
|
const getRoutesComponent = async () => {
|
|
19
|
+
if (globalThis.__cedarjs__vite_rsc_runtime) {
|
|
20
|
+
const routesPath2 = getPaths().web.routes;
|
|
21
|
+
const routesMod = await globalThis.__cedarjs__vite_rsc_runtime.import(routesPath2);
|
|
22
|
+
return routesMod.default;
|
|
23
|
+
}
|
|
16
24
|
const serverEntries = await getEntriesFromDist();
|
|
17
25
|
console.log("rscRenderer.ts serverEntries", serverEntries);
|
|
18
26
|
const routesPath = path.join(
|
|
@@ -53,10 +61,12 @@ function getBundlerConfig() {
|
|
|
53
61
|
{},
|
|
54
62
|
{
|
|
55
63
|
get(_target, encodedId) {
|
|
56
|
-
console.log("Proxy get encodedId", encodedId);
|
|
64
|
+
console.log("rscRenderer.ts Proxy get encodedId", encodedId);
|
|
57
65
|
const [filePath, name] = encodedId.split("#");
|
|
66
|
+
console.log("filePath", filePath);
|
|
67
|
+
console.log("name", name);
|
|
58
68
|
const filePathSlash = filePath.replaceAll("\\", "/");
|
|
59
|
-
const id = absoluteClientEntries[filePathSlash];
|
|
69
|
+
const id = globalThis.__cedarjs__vite_rsc_runtime ? filePath : absoluteClientEntries[filePathSlash];
|
|
60
70
|
console.log("absoluteClientEntries", absoluteClientEntries);
|
|
61
71
|
console.log("filePath", filePathSlash);
|
|
62
72
|
if (!id) {
|
|
@@ -79,6 +89,8 @@ async function renderRsc(input) {
|
|
|
79
89
|
throw new Error("Unexpected input. Missing rscId or props.");
|
|
80
90
|
}
|
|
81
91
|
console.log("renderRsc input", input);
|
|
92
|
+
const { createElement } = await importRscReact();
|
|
93
|
+
const { renderToReadableStream } = await importRsdwServer();
|
|
82
94
|
const serverRoutes = await getRoutesComponent();
|
|
83
95
|
const model = {
|
|
84
96
|
__cedarjs__Routes: createElement(serverRoutes)
|
|
@@ -115,6 +127,8 @@ async function executeRsa(input) {
|
|
|
115
127
|
console.log("rscRenderer.ts args", ...input.args);
|
|
116
128
|
const data = await method(...input.args);
|
|
117
129
|
console.log("rscRenderer.ts rsa return data", data);
|
|
130
|
+
const { createElement } = await importRscReact();
|
|
131
|
+
const { renderToReadableStream } = await importRsdwServer();
|
|
118
132
|
const serverRoutes = await getRoutesComponent();
|
|
119
133
|
console.log("rscRenderer.ts executeRsa serverRoutes", serverRoutes);
|
|
120
134
|
const model = {
|
|
@@ -3,8 +3,8 @@ import type Router from 'find-my-way';
|
|
|
3
3
|
import type { ViteDevServer } from 'vite';
|
|
4
4
|
interface CreateRscRequestHandlerOptions {
|
|
5
5
|
getMiddlewareRouter: () => Promise<Router.Instance<any>>;
|
|
6
|
-
|
|
6
|
+
viteSsrDevServer?: ViteDevServer;
|
|
7
7
|
}
|
|
8
|
-
export declare function createRscRequestHandler(options: CreateRscRequestHandlerOptions): (req: ExpressRequest, res: ExpressResponse, next: () => void) => Promise<void
|
|
8
|
+
export declare function createRscRequestHandler(options: CreateRscRequestHandlerOptions): Promise<(req: ExpressRequest, res: ExpressResponse, next: () => void) => Promise<void>>;
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=rscRequestHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rscRequestHandler.d.ts","sourceRoot":"","sources":["../../src/rsc/rscRequestHandler.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,OAAO,IAAI,cAAc,EACzB,QAAQ,IAAI,eAAe,EAC5B,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"rscRequestHandler.d.ts","sourceRoot":"","sources":["../../src/rsc/rscRequestHandler.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,OAAO,IAAI,cAAc,EACzB,QAAQ,IAAI,eAAe,EAC5B,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAazC,UAAU,8BAA8B;IACtC,mBAAmB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;IACxD,gBAAgB,CAAC,EAAE,aAAa,CAAA;CACjC;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,8BAA8B,iBAShC,cAAc,OACd,eAAe,QACd,MAAM,IAAI,oBAqHnB"}
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
} from "../bundled/react-server-dom-webpack.server.js";
|
|
9
9
|
import { hasStatusCode } from "../lib/StatusError.js";
|
|
10
10
|
import { invoke } from "../middleware/invokeMiddleware.js";
|
|
11
|
-
import { renderRscToStream } from "./rscRenderer.js";
|
|
12
|
-
import { sendRscFlightToStudio } from "./rscStudioHandlers.js";
|
|
13
11
|
const BASE_PATH = "/rw-rsc/";
|
|
14
|
-
function createRscRequestHandler(options) {
|
|
12
|
+
async function createRscRequestHandler(options) {
|
|
13
|
+
const { renderRscToStream } = await import("./rscRenderer.js");
|
|
14
|
+
const { sendRscFlightToStudio } = await import("./rscStudioHandlers.js");
|
|
15
15
|
return async (req, res, next) => {
|
|
16
16
|
console.log("BASE_PATH", BASE_PATH);
|
|
17
17
|
console.log("req.originalUrl", req.originalUrl, "req.url", req.url);
|
|
@@ -26,7 +26,7 @@ function createRscRequestHandler(options) {
|
|
|
26
26
|
matchedMw?.handler,
|
|
27
27
|
{
|
|
28
28
|
params: matchedMw?.params,
|
|
29
|
-
|
|
29
|
+
viteSsrDevServer: options.viteSsrDevServer
|
|
30
30
|
}
|
|
31
31
|
);
|
|
32
32
|
const webRes = mwResponse.toResponse();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rscWebSocketServer.d.ts","sourceRoot":"","sources":["../../src/rsc/rscWebSocketServer.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,SAwBpC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import WebSocket, { WebSocketServer } from "ws";
|
|
2
|
+
function createWebSocketServer() {
|
|
3
|
+
const wsServer = new WebSocketServer({ port: 18998 });
|
|
4
|
+
wsServer.on("connection", (ws) => {
|
|
5
|
+
console.log("A new client connected.");
|
|
6
|
+
ws.on("message", (data) => {
|
|
7
|
+
const message = data.toString();
|
|
8
|
+
console.log("Received message:", message);
|
|
9
|
+
wsServer.clients.forEach((client) => {
|
|
10
|
+
if (client.readyState === WebSocket.OPEN) {
|
|
11
|
+
client.send(message);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
ws.on("close", () => {
|
|
16
|
+
console.log("A client disconnected.");
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
createWebSocketServer
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { default as RSDWServerModule } from 'react-server-dom-webpack/server.edge';
|
|
2
|
+
type RSDWServerType = typeof RSDWServerModule;
|
|
3
|
+
/**
|
|
4
|
+
* This function ensures we load the version of React that's been imported with
|
|
5
|
+
* the react-server condition.
|
|
6
|
+
*/
|
|
7
|
+
export declare function importRscReact(): Promise<any>;
|
|
8
|
+
export declare function importRsdwServer(): Promise<RSDWServerType>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/rsc/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AAEvF,KAAK,cAAc,GAAG,OAAO,gBAAgB,CAAA;AAE7C;;;GAGG;AACH,wBAAsB,cAAc,iBAQnC;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,cAAc,CAAC,CAUhE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
async function importRscReact() {
|
|
2
|
+
if (globalThis.__cedarjs__vite_rsc_runtime) {
|
|
3
|
+
const reactMod = await globalThis.__cedarjs__vite_rsc_runtime.import("react");
|
|
4
|
+
return reactMod.default;
|
|
5
|
+
}
|
|
6
|
+
return import("react");
|
|
7
|
+
}
|
|
8
|
+
async function importRsdwServer() {
|
|
9
|
+
if (globalThis.__cedarjs__vite_rsc_runtime) {
|
|
10
|
+
const rsdwServerMod = await globalThis.__cedarjs__vite_rsc_runtime.import(
|
|
11
|
+
"react-server-dom-webpack/server.edge"
|
|
12
|
+
);
|
|
13
|
+
return rsdwServerMod.default;
|
|
14
|
+
} else {
|
|
15
|
+
return import("react-server-dom-webpack/server.edge");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
importRscReact,
|
|
20
|
+
importRsdwServer
|
|
21
|
+
};
|
package/dist/runFeServer.js
CHANGED
|
@@ -5,13 +5,13 @@ import { createServerAdapter } from "@whatwg-node/server";
|
|
|
5
5
|
import { config as loadDotEnv } from "dotenv-defaults";
|
|
6
6
|
import express from "express";
|
|
7
7
|
import { createProxyMiddleware } from "http-proxy-middleware";
|
|
8
|
-
import WebSocket, { WebSocketServer } from "ws";
|
|
9
8
|
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
10
9
|
import { getRscStylesheetLinkGenerator } from "@cedarjs/router/rscCss";
|
|
11
10
|
import { createPerRequestMap, createServerStorage } from "@cedarjs/server-store";
|
|
12
11
|
import { registerFwGlobalsAndShims } from "./lib/registerFwGlobalsAndShims.js";
|
|
13
12
|
import { invoke } from "./middleware/invokeMiddleware.js";
|
|
14
13
|
import { createMiddlewareRouter } from "./middleware/register.js";
|
|
14
|
+
import { createWebSocketServer } from "./rsc/rscWebSocketServer.js";
|
|
15
15
|
import { createReactStreamingHandler } from "./streaming/createReactStreamingHandler.js";
|
|
16
16
|
import { convertExpressHeaders, getFullUrl } from "./utils.js";
|
|
17
17
|
loadDotEnv({
|
|
@@ -67,7 +67,7 @@ async function runFeServer() {
|
|
|
67
67
|
"/assets",
|
|
68
68
|
express.static(rwPaths.web.distBrowser + "/assets", { index: false })
|
|
69
69
|
);
|
|
70
|
-
app.use(
|
|
70
|
+
app.use((req, _res, next) => {
|
|
71
71
|
const fullUrl = getFullUrl(req, rscEnabled);
|
|
72
72
|
const headers = convertExpressHeaders(req.headersDistinct);
|
|
73
73
|
const perReqStore = createPerRequestMap({ headers, fullUrl });
|
|
@@ -86,7 +86,7 @@ async function runFeServer() {
|
|
|
86
86
|
const { createRscRequestHandler } = await import("./rsc/rscRequestHandler.js");
|
|
87
87
|
app.use(
|
|
88
88
|
"/rw-rsc",
|
|
89
|
-
createRscRequestHandler({
|
|
89
|
+
await createRscRequestHandler({
|
|
90
90
|
getMiddlewareRouter: async () => middlewareRouter
|
|
91
91
|
})
|
|
92
92
|
);
|
|
@@ -99,32 +99,13 @@ async function runFeServer() {
|
|
|
99
99
|
getStylesheetLinks,
|
|
100
100
|
getMiddlewareRouter: async () => middlewareRouter
|
|
101
101
|
});
|
|
102
|
-
app.get("*", createServerAdapter(routeHandler));
|
|
103
|
-
app.post("*", handleWithMiddleware());
|
|
102
|
+
app.get("/{*splat}", createServerAdapter(routeHandler));
|
|
103
|
+
app.post("/{*splat}", handleWithMiddleware());
|
|
104
104
|
app.listen(rwConfig.web.port);
|
|
105
105
|
console.log(
|
|
106
106
|
`Started production FE server on http://localhost:${rwConfig.web.port}`
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
|
-
function createWebSocketServer() {
|
|
110
|
-
const wsServer = new WebSocketServer({ port: 18998 });
|
|
111
|
-
wsServer.on("connection", (ws) => {
|
|
112
|
-
console.log("A new client connected.");
|
|
113
|
-
ws.on("message", (data) => {
|
|
114
|
-
const message = data.toString();
|
|
115
|
-
console.log("runFeServer.ts: Received message:");
|
|
116
|
-
console.log(message.slice(0, 120) + "...");
|
|
117
|
-
wsServer.clients.forEach((client) => {
|
|
118
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
119
|
-
client.send(message);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
ws.on("close", () => {
|
|
124
|
-
console.log("A client disconnected.");
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
109
|
runFeServer();
|
|
129
110
|
export {
|
|
130
111
|
runFeServer
|
|
@@ -7,6 +7,6 @@ interface CreateReactStreamingHandlerOptions {
|
|
|
7
7
|
getStylesheetLinks: (route?: RWRouteManifestItem | RouteSpec) => string[];
|
|
8
8
|
getMiddlewareRouter: () => Promise<Router.Instance<any>>;
|
|
9
9
|
}
|
|
10
|
-
export declare const createReactStreamingHandler: ({ routes, clientEntryPath, getStylesheetLinks, getMiddlewareRouter, }: CreateReactStreamingHandlerOptions,
|
|
10
|
+
export declare const createReactStreamingHandler: ({ routes, clientEntryPath, getStylesheetLinks, getMiddlewareRouter, }: CreateReactStreamingHandlerOptions, viteSsrDevServer?: ViteDevServer) => Promise<(req: Request) => Promise<Response>>;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=createReactStreamingHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createReactStreamingHandler.d.ts","sourceRoot":"","sources":["../../src/streaming/createReactStreamingHandler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAGrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAoBvE,UAAU,kCAAkC;IAC1C,MAAM,EAAE,mBAAmB,EAAE,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,CAAC,KAAK,CAAC,EAAE,mBAAmB,GAAG,SAAS,KAAK,MAAM,EAAE,CAAA;IACzE,mBAAmB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;CACzD;AAOD,eAAO,MAAM,2BAA2B,GACtC,uEAKG,kCAAkC,EACrC,
|
|
1
|
+
{"version":3,"file":"createReactStreamingHandler.d.ts","sourceRoot":"","sources":["../../src/streaming/createReactStreamingHandler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAGrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAoBvE,UAAU,kCAAkC;IAC1C,MAAM,EAAE,mBAAmB,EAAE,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAA;IACvB,kBAAkB,EAAE,CAAC,KAAK,CAAC,EAAE,mBAAmB,GAAG,SAAS,KAAK,MAAM,EAAE,CAAA;IACzE,mBAAmB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;CACzD;AAOD,eAAO,MAAM,2BAA2B,GACtC,uEAKG,kCAAkC,EACrC,mBAAmB,aAAa,mBAuBb,OAAO,uBAiJ3B,CAAA"}
|
|
@@ -23,10 +23,10 @@ const createReactStreamingHandler = async ({
|
|
|
23
23
|
clientEntryPath,
|
|
24
24
|
getStylesheetLinks,
|
|
25
25
|
getMiddlewareRouter
|
|
26
|
-
},
|
|
26
|
+
}, viteSsrDevServer) => {
|
|
27
27
|
const rwPaths = getPaths();
|
|
28
28
|
const rwConfig = getConfig();
|
|
29
|
-
const isProd = !
|
|
29
|
+
const isProd = !viteSsrDevServer;
|
|
30
30
|
const middlewareRouter = await getMiddlewareRouter();
|
|
31
31
|
let entryServerImport;
|
|
32
32
|
let fallbackDocumentImport;
|
|
@@ -70,7 +70,7 @@ const createReactStreamingHandler = async ({
|
|
|
70
70
|
route: currentRoute,
|
|
71
71
|
cssPaths: cssLinks,
|
|
72
72
|
params: matchedMw?.params,
|
|
73
|
-
|
|
73
|
+
viteSsrDevServer
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
76
|
if (mwResponse.isRedirect() || mwResponse.body) {
|
|
@@ -89,8 +89,8 @@ const createReactStreamingHandler = async ({
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
if (!isProd) {
|
|
92
|
-
entryServerImport = await ssrLoadEntryServer(
|
|
93
|
-
fallbackDocumentImport = await
|
|
92
|
+
entryServerImport = await ssrLoadEntryServer(viteSsrDevServer);
|
|
93
|
+
fallbackDocumentImport = await viteSsrDevServer.ssrLoadModule(
|
|
94
94
|
rwPaths.web.document
|
|
95
95
|
);
|
|
96
96
|
}
|
|
@@ -107,10 +107,12 @@ const createReactStreamingHandler = async ({
|
|
|
107
107
|
req,
|
|
108
108
|
parsedParams
|
|
109
109
|
},
|
|
110
|
-
|
|
110
|
+
viteSsrDevServer
|
|
111
111
|
});
|
|
112
112
|
metaTags = routeHookOutput.meta;
|
|
113
|
-
const jsBundles = [
|
|
113
|
+
const jsBundles = [
|
|
114
|
+
viteSsrDevServer ? clientEntryPath : "/" + clientEntryPath
|
|
115
|
+
];
|
|
114
116
|
if (currentRoute.bundle) {
|
|
115
117
|
jsBundles.push("/" + currentRoute.bundle);
|
|
116
118
|
}
|
|
@@ -130,12 +132,13 @@ const createReactStreamingHandler = async ({
|
|
|
130
132
|
{
|
|
131
133
|
waitForAllReady: isSeoCrawler,
|
|
132
134
|
onError: (err) => {
|
|
133
|
-
if (!isProd &&
|
|
134
|
-
|
|
135
|
+
if (!isProd && viteSsrDevServer) {
|
|
136
|
+
viteSsrDevServer.ssrFixStacktrace(err);
|
|
135
137
|
}
|
|
136
138
|
console.error(err);
|
|
137
139
|
}
|
|
138
|
-
}
|
|
140
|
+
},
|
|
141
|
+
viteSsrDevServer
|
|
139
142
|
);
|
|
140
143
|
return reactResponse;
|
|
141
144
|
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
+
import type { ViteDevServer } from 'vite';
|
|
2
3
|
import type { ServerAuthState } from '@cedarjs/auth/dist/AuthProvider/ServerAuthProvider.js';
|
|
3
4
|
import type { TagDescriptor } from '@cedarjs/web';
|
|
4
5
|
import type { MiddlewareResponse } from '@cedarjs/web/middleware';
|
|
5
6
|
import type { ServerEntryType } from '../types.js';
|
|
7
|
+
interface FallbackDocumentProps {
|
|
8
|
+
css: string[];
|
|
9
|
+
meta: TagDescriptor[];
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
}
|
|
6
12
|
interface RenderToStreamArgs {
|
|
7
13
|
ServerEntry: ServerEntryType;
|
|
8
|
-
FallbackDocument: React.FunctionComponent
|
|
14
|
+
FallbackDocument: React.FunctionComponent<FallbackDocumentProps>;
|
|
9
15
|
currentUrl: URL;
|
|
10
16
|
metaTags: TagDescriptor[];
|
|
11
17
|
cssLinks: string[];
|
|
@@ -17,7 +23,6 @@ interface StreamOptions {
|
|
|
17
23
|
waitForAllReady?: boolean;
|
|
18
24
|
onError?: (err: Error) => void;
|
|
19
25
|
}
|
|
20
|
-
export declare function reactRenderToStreamResponse(mwRes: MiddlewareResponse, renderOptions: RenderToStreamArgs, streamOptions: StreamOptions): Promise<Response>;
|
|
21
|
-
export declare function importModule(mod: 'rd-server' | '__cedarjs__react' | '__cedarjs__location' | '__cedarjs__server_auth_provider' | '__cedarjs__server_inject'): Promise<any>;
|
|
26
|
+
export declare function reactRenderToStreamResponse(mwRes: MiddlewareResponse, renderOptions: RenderToStreamArgs, streamOptions: StreamOptions, viteDevServer?: ViteDevServer): Promise<Response>;
|
|
22
27
|
export {};
|
|
23
28
|
//# sourceMappingURL=streamHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamHelpers.d.ts","sourceRoot":"","sources":["../../src/streaming/streamHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"streamHelpers.d.ts","sourceRoot":"","sources":["../../src/streaming/streamHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAI5F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAYlD,UAAU,qBAAqB;IAC7B,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,IAAI,EAAE,aAAa,EAAE,CAAA;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,UAAU,kBAAkB;IAC1B,WAAW,EAAE,eAAe,CAAA;IAC5B,gBAAgB,EAAE,KAAK,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAAA;IAChE,UAAU,EAAE,GAAG,CAAA;IACf,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,EAAE,eAAe,CAAA;CAC3B;AAED,UAAU,aAAa;IACrB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;CAC/B;AA2BD,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,kBAAkB,EACzB,aAAa,EAAE,kBAAkB,EACjC,aAAa,EAAE,aAAa,EAC5B,aAAa,CAAC,EAAE,aAAa,qBAgM9B"}
|
|
@@ -27,7 +27,7 @@ globalThis.__webpack_require__ ||= (id) => {
|
|
|
27
27
|
return globalThis.__rw_module_cache__.get(id)
|
|
28
28
|
};
|
|
29
29
|
`;
|
|
30
|
-
async function reactRenderToStreamResponse(mwRes, renderOptions, streamOptions) {
|
|
30
|
+
async function reactRenderToStreamResponse(mwRes, renderOptions, streamOptions, viteDevServer) {
|
|
31
31
|
const { waitForAllReady = false } = streamOptions;
|
|
32
32
|
const {
|
|
33
33
|
ServerEntry,
|
|
@@ -49,13 +49,13 @@ async function reactRenderToStreamResponse(mwRes, renderOptions, streamOptions)
|
|
|
49
49
|
meta: metaTags
|
|
50
50
|
});
|
|
51
51
|
const rscEnabled = getConfig().experimental?.rsc?.enabled;
|
|
52
|
-
const { createElement } = rscEnabled ? await importModule("__cedarjs__react") : await import("react");
|
|
52
|
+
const { createElement } = rscEnabled ? await importModule("__cedarjs__react", !!viteDevServer) : await import("react");
|
|
53
53
|
const {
|
|
54
54
|
createInjector,
|
|
55
55
|
ServerHtmlProvider,
|
|
56
56
|
ServerInjectedHtml
|
|
57
|
-
} = rscEnabled ? await importModule("__cedarjs__server_inject") : await import("@cedarjs/web/serverInject");
|
|
58
|
-
const { renderToString } = rscEnabled ? await importModule("rd-server") : await import("react-dom/server");
|
|
57
|
+
} = rscEnabled ? await importModule("__cedarjs__server_inject", !!viteDevServer) : await import("@cedarjs/web/serverInject");
|
|
58
|
+
const { renderToString } = rscEnabled ? await importModule("rd-server", !!viteDevServer) : await import("react-dom/server");
|
|
59
59
|
const { injectionState, injectToPage } = createInjector();
|
|
60
60
|
const bufferTransform = createBufferedTransformStream();
|
|
61
61
|
const serverInjectionTransform = createServerInjectionTransform({
|
|
@@ -70,8 +70,8 @@ async function reactRenderToStreamResponse(mwRes, renderOptions, streamOptions)
|
|
|
70
70
|
controller.abort();
|
|
71
71
|
}, 1e4);
|
|
72
72
|
const timeoutTransform = createTimeoutTransform(timeoutHandle);
|
|
73
|
-
const { ServerAuthProvider } = rscEnabled ? await importModule("__cedarjs__server_auth_provider") : await import("@cedarjs/auth/dist/AuthProvider/ServerAuthProvider.js");
|
|
74
|
-
const { LocationProvider } = rscEnabled ? await importModule("__cedarjs__location") : await import("@cedarjs/router/location");
|
|
73
|
+
const { ServerAuthProvider } = rscEnabled ? await importModule("__cedarjs__server_auth_provider", !!viteDevServer) : await import("@cedarjs/auth/dist/AuthProvider/ServerAuthProvider.js");
|
|
74
|
+
const { LocationProvider } = rscEnabled ? await importModule("__cedarjs__location", !!viteDevServer) : await import("@cedarjs/router/location");
|
|
75
75
|
const renderRoot = (url) => {
|
|
76
76
|
return createElement(
|
|
77
77
|
ServerAuthProvider,
|
|
@@ -103,7 +103,7 @@ async function reactRenderToStreamResponse(mwRes, renderOptions, streamOptions)
|
|
|
103
103
|
),
|
|
104
104
|
bootstrapModules: jsBundles
|
|
105
105
|
};
|
|
106
|
-
const { renderToReadableStream } = rscEnabled ? await importModule("rd-server") : await import("react-dom/server.edge");
|
|
106
|
+
const { renderToReadableStream } = rscEnabled ? await importModule("rd-server", !!viteDevServer) : await import("react-dom/server.edge");
|
|
107
107
|
try {
|
|
108
108
|
let didErrorOutsideShell = false;
|
|
109
109
|
const renderToStreamOptions = {
|
|
@@ -137,7 +137,7 @@ async function reactRenderToStreamResponse(mwRes, renderOptions, streamOptions)
|
|
|
137
137
|
console.error("\u{1F53B} Failed to render shell");
|
|
138
138
|
streamOptions.onError?.(e);
|
|
139
139
|
const fallbackShell = await renderToReadableStream(
|
|
140
|
-
FallbackDocument
|
|
140
|
+
createElement(FallbackDocument, {
|
|
141
141
|
children: null,
|
|
142
142
|
css: cssLinks,
|
|
143
143
|
meta: metaTags
|
|
@@ -162,33 +162,51 @@ function applyStreamTransforms(reactStream, transformsToApply) {
|
|
|
162
162
|
}
|
|
163
163
|
return outputStream;
|
|
164
164
|
}
|
|
165
|
-
async function importModule(mod) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
165
|
+
async function importModule(mod, isDev) {
|
|
166
|
+
if (isDev) {
|
|
167
|
+
if (mod === "rd-server") {
|
|
168
|
+
const loadedMod = await import("react-dom/server.edge");
|
|
169
|
+
return loadedMod.default;
|
|
170
|
+
} else if (mod === "__cedarjs__react") {
|
|
171
|
+
const loadedMod = await import("react");
|
|
172
|
+
return loadedMod.default;
|
|
173
|
+
} else if (mod === "__cedarjs__location") {
|
|
174
|
+
const loadedMod = await import("@cedarjs/router/location");
|
|
175
|
+
return loadedMod;
|
|
176
|
+
} else if (mod === "__cedarjs__server_auth_provider") {
|
|
177
|
+
const loadedMod = await import("@cedarjs/auth/dist/AuthProvider/ServerAuthProvider.js");
|
|
178
|
+
return loadedMod;
|
|
179
|
+
} else if (mod === "__cedarjs__server_inject") {
|
|
180
|
+
const loadedMod = await import("@cedarjs/web/serverInject");
|
|
181
|
+
return loadedMod;
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
const distSsr = getPaths().web.distSsr;
|
|
185
|
+
const rdServerPath = makeFilePath(path.join(distSsr, "rd-server.mjs"));
|
|
186
|
+
const reactPath = makeFilePath(path.join(distSsr, "__cedarjs__react.mjs"));
|
|
187
|
+
const locationPath = makeFilePath(
|
|
188
|
+
path.join(distSsr, "__cedarjs__location.mjs")
|
|
189
|
+
);
|
|
190
|
+
const serverAuthProviderPath = makeFilePath(
|
|
191
|
+
path.join(distSsr, "__cedarjs__server_auth_provider.mjs")
|
|
192
|
+
);
|
|
193
|
+
const serverInjectPath = makeFilePath(
|
|
194
|
+
path.join(distSsr, "__cedarjs__server_inject.mjs")
|
|
195
|
+
);
|
|
196
|
+
if (mod === "rd-server") {
|
|
197
|
+
return (await import(rdServerPath)).default;
|
|
198
|
+
} else if (mod === "__cedarjs__react") {
|
|
199
|
+
return (await import(reactPath)).default;
|
|
200
|
+
} else if (mod === "__cedarjs__location") {
|
|
201
|
+
return await import(locationPath);
|
|
202
|
+
} else if (mod === "__cedarjs__server_auth_provider") {
|
|
203
|
+
return await import(serverAuthProviderPath);
|
|
204
|
+
} else if (mod === "__cedarjs__server_inject") {
|
|
205
|
+
return await import(serverInjectPath);
|
|
206
|
+
}
|
|
188
207
|
}
|
|
189
208
|
throw new Error("Unknown module " + mod);
|
|
190
209
|
}
|
|
191
210
|
export {
|
|
192
|
-
importModule,
|
|
193
211
|
reactRenderToStreamResponse
|
|
194
212
|
};
|
|
@@ -18,9 +18,9 @@ interface LoadAndRunRouteHooks {
|
|
|
18
18
|
req: Request;
|
|
19
19
|
parsedParams?: Record<string, any>;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
viteSsrDevServer?: ViteDevServer;
|
|
22
22
|
previousOutput?: RouteHookOutput;
|
|
23
23
|
}
|
|
24
|
-
export declare const loadAndRunRouteHooks: ({ paths, reqMeta,
|
|
24
|
+
export declare const loadAndRunRouteHooks: ({ paths, reqMeta, viteSsrDevServer, previousOutput, }: LoadAndRunRouteHooks) => Promise<RouteHookOutput>;
|
|
25
25
|
export {};
|
|
26
26
|
//# sourceMappingURL=triggerRouteHooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggerRouteHooks.d.ts","sourceRoot":"","sources":["../../src/streaming/triggerRouteHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAGzC,OAAO,KAAK,EACV,QAAQ,EAER,eAAe,EACf,aAAa,EACd,MAAM,cAAc,CAAA;AAErB,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB;AAED,UAAU,sBAAsB;IAC9B,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,OAAO,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAClC,cAAc,CAAC,EAAE,eAAe,CAAA;CACjC;AAED,eAAO,MAAM,iBAAiB,GAAU,oDAKrC,sBAAsB;;EA4BxB,CAAA;AAED,UAAU,oBAAoB;IAC5B,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAA;IACpC,OAAO,EAAE;QACP,GAAG,EAAE,OAAO,CAAA;QACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KACnC,CAAA;IACD,
|
|
1
|
+
{"version":3,"file":"triggerRouteHooks.d.ts","sourceRoot":"","sources":["../../src/streaming/triggerRouteHooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAGzC,OAAO,KAAK,EACV,QAAQ,EAER,eAAe,EACf,aAAa,EACd,MAAM,cAAc,CAAA;AAErB,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB;AAED,UAAU,sBAAsB;IAC9B,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,OAAO,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAClC,cAAc,CAAC,EAAE,eAAe,CAAA;CACjC;AAED,eAAO,MAAM,iBAAiB,GAAU,oDAKrC,sBAAsB;;EA4BxB,CAAA;AAED,UAAU,oBAAoB;IAC5B,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAA;IACpC,OAAO,EAAE;QACP,GAAG,EAAE,OAAO,CAAA;QACZ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KACnC,CAAA;IACD,gBAAgB,CAAC,EAAE,aAAa,CAAA;IAChC,cAAc,CAAC,EAAE,eAAe,CAAA;CACjC;AAMD,eAAO,MAAM,oBAAoB,GAAU,uDAKxC,oBAAoB,KAAG,OAAO,CAAC,eAAe,CA2ChD,CAAA"}
|
|
@@ -31,11 +31,11 @@ const defaultRouteHookOutput = {
|
|
|
31
31
|
const loadAndRunRouteHooks = async ({
|
|
32
32
|
paths = [],
|
|
33
33
|
reqMeta,
|
|
34
|
-
|
|
34
|
+
viteSsrDevServer,
|
|
35
35
|
previousOutput = defaultRouteHookOutput
|
|
36
36
|
}) => {
|
|
37
37
|
const loadModule = async (path) => {
|
|
38
|
-
return
|
|
38
|
+
return viteSsrDevServer ? viteSsrDevServer.ssrLoadModule(path) : import(path);
|
|
39
39
|
};
|
|
40
40
|
let currentRouteHooks;
|
|
41
41
|
let rhOutput = defaultRouteHookOutput;
|
|
@@ -55,7 +55,7 @@ const loadAndRunRouteHooks = async ({
|
|
|
55
55
|
paths,
|
|
56
56
|
reqMeta,
|
|
57
57
|
previousOutput: rhOutput,
|
|
58
|
-
|
|
58
|
+
viteSsrDevServer
|
|
59
59
|
});
|
|
60
60
|
} else {
|
|
61
61
|
return rhOutput;
|