@cedarjs/vite 5.0.2-rc.5 → 6.0.0-canary.2619
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/apiDevMiddleware.d.ts.map +1 -1
- package/dist/apiDevMiddleware.js +16 -2
- package/dist/buildApp.d.ts.map +1 -1
- package/dist/buildApp.js +8 -3
- package/dist/bundled/react-server-dom-webpack.server.js +1224 -28521
- package/dist/cjs/apiDevMiddleware.js +16 -2
- package/dist/cjs/buildApp.js +8 -3
- package/dist/cjs/devFeServer.js +268 -15
- package/dist/cjs/index.js +21 -13
- package/dist/cjs/lib/registerFwGlobalsAndShims.js +9 -0
- package/dist/cjs/plugins/vite-plugin-cedar-data-uri-shim.js +67 -0
- package/dist/cjs/plugins/vite-plugin-cedar-gqlorm-inject.js +106 -0
- package/dist/cjs/plugins/vite-plugin-cedar-graphql-options-extract.js +113 -0
- package/dist/cjs/plugins/vite-plugin-cedar-otel-wrapping.js +225 -0
- package/dist/cjs/plugins/vite-plugin-cedar-universal-deploy.js +1 -1
- package/dist/cjs/plugins/{vite-plugin-cedar-context-wrapping.js → vite-plugin-handler-als-wrapping.js} +21 -21
- package/dist/cjs/plugins/vite-plugin-rsc-ssr-router-import.js +2 -2
- package/dist/cjs/plugins/vite-plugin-rsc-transform-server.js +4 -0
- package/dist/cjs/rsc/rscRenderer.js +23 -9
- package/dist/cjs/rsc/rscRequestHandler.js +6 -6
- package/dist/cjs/rsc/rscWebSocketServer.js +56 -0
- package/dist/cjs/rsc/utils.js +56 -0
- package/dist/cjs/runFeServer.js +3 -22
- package/dist/cjs/streaming/createReactStreamingHandler.js +13 -10
- package/dist/cjs/streaming/streamHelpers.js +49 -32
- package/dist/cjs/streaming/triggerRouteHooks.js +3 -3
- package/dist/devFeServer.js +272 -16
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -9
- package/dist/lib/registerFwGlobalsAndShims.js +9 -0
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts +3 -0
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-data-uri-shim.js +43 -0
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts +29 -0
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-gqlorm-inject.js +76 -0
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts +38 -0
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.js +88 -0
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts +39 -0
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-otel-wrapping.js +200 -0
- package/dist/plugins/vite-plugin-cedar-universal-deploy.js +1 -1
- package/dist/plugins/{vite-plugin-cedar-context-wrapping.d.ts → vite-plugin-handler-als-wrapping.d.ts} +12 -12
- package/dist/plugins/vite-plugin-handler-als-wrapping.d.ts.map +1 -0
- package/dist/plugins/{vite-plugin-cedar-context-wrapping.js → vite-plugin-handler-als-wrapping.js} +16 -16
- 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 +2 -21
- 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 +2 -2
- package/dist/streaming/streamHelpers.d.ts.map +1 -1
- package/dist/streaming/streamHelpers.js +49 -31
- 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 +19 -20
- package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +0 -43
- package/dist/plugins/vite-plugin-cedar-context-wrapping.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +0 -3
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-cedar-node-polyfills.js +0 -19
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin that extracts options passed to createGraphQLHandler into an
|
|
4
|
+
* exported variable.
|
|
5
|
+
*
|
|
6
|
+
* Transforms:
|
|
7
|
+
* export const handler = createGraphQLHandler({ options })
|
|
8
|
+
* into:
|
|
9
|
+
* export const __cedar_graphqlOptions = { options }
|
|
10
|
+
* export const handler = createGraphQLHandler(__cedar_graphqlOptions)
|
|
11
|
+
*
|
|
12
|
+
* This allows options to be imported elsewhere and enables the gqlorm-inject
|
|
13
|
+
* plugin to mutate the sdls object in-place before the call.
|
|
14
|
+
*
|
|
15
|
+
* The extraction uses an oxc-parser AST walk (see `applyGraphqlOptionsExtract`
|
|
16
|
+
* below) so the transform is robust against aliased imports, nested calls, and
|
|
17
|
+
* string escapes. The same logic is duplicated in
|
|
18
|
+
* `@cedarjs/internal` (`applyGraphqlOptionsExtract`) for the standalone esbuild
|
|
19
|
+
* API build
|
|
20
|
+
*/
|
|
21
|
+
export declare function cedarGraphqlOptionsExtractPlugin(): Plugin;
|
|
22
|
+
/**
|
|
23
|
+
* Extracts the options argument from createGraphQLHandler calls and stores
|
|
24
|
+
* them in an exported variable. Returns the transformed code, or null if no
|
|
25
|
+
* transformation was needed.
|
|
26
|
+
*
|
|
27
|
+
* Transforms:
|
|
28
|
+
* export const handler = createGraphQLHandler({ options })
|
|
29
|
+
* into:
|
|
30
|
+
* export const __cedar_graphqlOptions = { options }
|
|
31
|
+
* export const handler = createGraphQLHandler(__cedar_graphqlOptions)
|
|
32
|
+
*
|
|
33
|
+
* Duplicate of `@cedarjs/internal`'s `applyGraphqlOptionsExtract` so this
|
|
34
|
+
* logic can run inside the Vite plugin pipeline without depending on internal's
|
|
35
|
+
* build output.
|
|
36
|
+
*/
|
|
37
|
+
export declare function applyGraphqlOptionsExtract(code: string): string | null;
|
|
38
|
+
//# sourceMappingURL=vite-plugin-cedar-graphql-options-extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-graphql-options-extract.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-graphql-options-extract.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gCAAgC,IAAI,MAAM,CA0BzD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA6FtE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { parseSync, Visitor } from "oxc-parser";
|
|
2
|
+
function cedarGraphqlOptionsExtractPlugin() {
|
|
3
|
+
return {
|
|
4
|
+
name: "cedar-graphql-options-extract",
|
|
5
|
+
transform(code, id) {
|
|
6
|
+
if (!id.endsWith("/graphql.ts") && !id.endsWith("/graphql.js")) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
if (!code.includes("createGraphQLHandler")) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const transformed = applyGraphqlOptionsExtract(code);
|
|
13
|
+
if (!transformed || transformed === code) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
code: transformed
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function applyGraphqlOptionsExtract(code) {
|
|
23
|
+
if (code.includes("__cedar_graphqlOptions")) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const { program } = parseSync("graphql.ts", code, {
|
|
27
|
+
// lang is only a parse hint; 'ts' also parses JS (the graphql handler can
|
|
28
|
+
// be graphql.js in JS projects), so this is safe for both file types.
|
|
29
|
+
lang: "ts",
|
|
30
|
+
sourceType: "module"
|
|
31
|
+
});
|
|
32
|
+
const importNames = /* @__PURE__ */ new Set();
|
|
33
|
+
for (const node of program.body) {
|
|
34
|
+
if (node.type === "ImportDeclaration") {
|
|
35
|
+
if (node.source.value !== "@cedarjs/graphql-server") {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
for (const specifier of node.specifiers) {
|
|
39
|
+
if (specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === "createGraphQLHandler") {
|
|
40
|
+
importNames.add(specifier.local.name);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (importNames.size === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const callExpressionPaths = [];
|
|
49
|
+
new Visitor({
|
|
50
|
+
CallExpression(node) {
|
|
51
|
+
if (node.callee.type === "Identifier" && importNames.has(node.callee.name)) {
|
|
52
|
+
callExpressionPaths.push(node);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}).visit(program);
|
|
56
|
+
if (callExpressionPaths.length > 1) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const callExpression = callExpressionPaths[0];
|
|
60
|
+
if (!callExpression) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const options = callExpression.arguments[0];
|
|
64
|
+
if (!options) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
if (options.type !== "Identifier" && options.type !== "ObjectExpression" && options.type !== "CallExpression" && options.type !== "ConditionalExpression") {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const optionsStart = options.start;
|
|
71
|
+
const optionsEnd = options.end;
|
|
72
|
+
const lineStart = code.lastIndexOf("\n", callExpression.start) + 1;
|
|
73
|
+
const indentMatch = /^[ \t]*/.exec(code.slice(lineStart));
|
|
74
|
+
const indent = indentMatch ? indentMatch[0] : "";
|
|
75
|
+
const optionsConst = `${indent}export const __cedar_graphqlOptions = ${code.slice(
|
|
76
|
+
optionsStart,
|
|
77
|
+
optionsEnd
|
|
78
|
+
)}
|
|
79
|
+
`;
|
|
80
|
+
const before = code.slice(0, lineStart);
|
|
81
|
+
const between = code.slice(lineStart, optionsStart);
|
|
82
|
+
const after = code.slice(optionsEnd);
|
|
83
|
+
return before + optionsConst + between + "__cedar_graphqlOptions" + after;
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
applyGraphqlOptionsExtract,
|
|
87
|
+
cedarGraphqlOptionsExtractPlugin
|
|
88
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin that wraps exported API functions with OpenTelemetry spans to
|
|
4
|
+
* provide automatic tracing in your Cedar API.
|
|
5
|
+
*
|
|
6
|
+
* For each `export const fn = (async?) (...) => {...}` declaration in an API
|
|
7
|
+
* file this plugin:
|
|
8
|
+
*
|
|
9
|
+
* 1. Adds an import at the top of the file:
|
|
10
|
+
* import { trace as OTEL_TRACE } from '@opentelemetry/api'
|
|
11
|
+
*
|
|
12
|
+
* 2. Wraps the original export with an OTel span:
|
|
13
|
+
* export const fn = (async?) (...params) => {
|
|
14
|
+
* const __fn = (async?) (...params) => { ...original body... }
|
|
15
|
+
* const OTEL_TRACER = OTEL_TRACE.getTracer('redwoodjs')
|
|
16
|
+
* const OTEL_RESULT = (await?) OTEL_TRACER.startActiveSpan(
|
|
17
|
+
* 'redwoodjs:api:<folder>:<fnName>',
|
|
18
|
+
* (async?) (span) => { ... }
|
|
19
|
+
* )
|
|
20
|
+
* return OTEL_RESULT
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* This replaces `babel-plugin-redwood-otel-wrapping` for all Vite and esbuild
|
|
24
|
+
* builds. The previous Babel plugin has been removed entirely; Jest transforms
|
|
25
|
+
* through the Vite SSR pipeline.
|
|
26
|
+
*
|
|
27
|
+
* NOTE: Known limitation. Spans will close before a Promise settles if a
|
|
28
|
+
* synchronous function returns a Promise. To trace async work correctly, mark
|
|
29
|
+
* the function as `async` if it returns or awaits Promises.
|
|
30
|
+
*/
|
|
31
|
+
export declare function cedarOtelWrappingPlugin(): Plugin;
|
|
32
|
+
/**
|
|
33
|
+
* Applies OpenTelemetry span wrapping to API source files.
|
|
34
|
+
*
|
|
35
|
+
* Exported as a standalone function so it can be tested without a Vite context.
|
|
36
|
+
* Returns the transformed code string, or `null` if nothing was changed.
|
|
37
|
+
*/
|
|
38
|
+
export declare function applyOtelWrapping(code: string, filename: string, apiFolder: string): string | null;
|
|
39
|
+
//# sourceMappingURL=vite-plugin-cedar-otel-wrapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-otel-wrapping.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-otel-wrapping.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAwBhD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CA+Ef"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { parseSync } from "oxc-parser";
|
|
2
|
+
import { normalizePath } from "vite";
|
|
3
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
4
|
+
function cedarOtelWrappingPlugin() {
|
|
5
|
+
return {
|
|
6
|
+
name: "cedar-otel-wrapping",
|
|
7
|
+
transform(code, id) {
|
|
8
|
+
let apiSrc;
|
|
9
|
+
try {
|
|
10
|
+
apiSrc = normalizePath(getPaths().api.src);
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (!normalizePath(id).startsWith(apiSrc + "/")) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const relativePath = normalizePath(id).slice(apiSrc.length + 1);
|
|
18
|
+
const apiFolder = relativePath.split("/")[0] ?? "?";
|
|
19
|
+
const result = applyOtelWrapping(code, id, apiFolder);
|
|
20
|
+
return result ? { code: result, map: null } : null;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function applyOtelWrapping(code, filename, apiFolder) {
|
|
25
|
+
const parseResult = parseSync(filename, code, { sourceType: "module" });
|
|
26
|
+
const replacements = [];
|
|
27
|
+
for (const node of parseResult.program.body) {
|
|
28
|
+
if (node.type !== "ExportNamedDeclaration") {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const decl = node.declaration;
|
|
32
|
+
if (decl?.type !== "VariableDeclaration") {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const declarator = decl.declarations[0];
|
|
36
|
+
if (!declarator) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const fn = declarator.init;
|
|
40
|
+
if (fn?.type !== "ArrowFunctionExpression") {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (declarator.id.type !== "Identifier") {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const fnName = declarator.id.name;
|
|
47
|
+
const innerArgs = buildInnerArgs(fn.params);
|
|
48
|
+
if (innerArgs === null) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const fnHeader = code.slice(fn.start, fn.body.start);
|
|
52
|
+
const originalFnSrc = code.slice(fn.start, fn.end);
|
|
53
|
+
const isAsync = fn.async;
|
|
54
|
+
const awaitKw = isAsync ? "await " : "";
|
|
55
|
+
const asyncKw = isAsync ? "async " : "";
|
|
56
|
+
replacements.push({
|
|
57
|
+
start: node.start,
|
|
58
|
+
end: node.end,
|
|
59
|
+
src: buildWrappedExport(
|
|
60
|
+
fnName,
|
|
61
|
+
fnHeader,
|
|
62
|
+
originalFnSrc,
|
|
63
|
+
innerArgs,
|
|
64
|
+
awaitKw,
|
|
65
|
+
asyncKw,
|
|
66
|
+
apiFolder,
|
|
67
|
+
filename
|
|
68
|
+
)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (replacements.length === 0) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
let output = code;
|
|
75
|
+
for (let i = replacements.length - 1; i >= 0; i--) {
|
|
76
|
+
const r = replacements[i];
|
|
77
|
+
output = output.slice(0, r.start) + r.src + output.slice(r.end);
|
|
78
|
+
}
|
|
79
|
+
return `import { trace as OTEL_TRACE } from '@opentelemetry/api'
|
|
80
|
+
` + output;
|
|
81
|
+
}
|
|
82
|
+
function buildInnerArgs(params) {
|
|
83
|
+
const args = [];
|
|
84
|
+
for (const param of params) {
|
|
85
|
+
if (param.type === "RestElement" || param.type === "ArrayPattern" || param.type === "TSParameterProperty") {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (param.type === "Identifier") {
|
|
89
|
+
args.push(param.name);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (param.type === "ObjectPattern") {
|
|
93
|
+
for (const prop of param.properties) {
|
|
94
|
+
if (prop.type === "RestElement") {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
if (prop.key.type !== "Identifier") {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const value = prop.value;
|
|
101
|
+
if (value.type !== "Identifier" && value.type !== "AssignmentPattern" && value.type !== "ObjectPattern") {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
if (value.type === "AssignmentPattern") {
|
|
105
|
+
if (value.left.type !== "Identifier" && value.left.type !== "ObjectPattern") {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const obj = buildObjectCallArg(param);
|
|
111
|
+
if (obj === null) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
args.push(obj);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (param.type === "AssignmentPattern") {
|
|
118
|
+
const ap = param;
|
|
119
|
+
if (ap.left.type === "Identifier") {
|
|
120
|
+
args.push(ap.left.name);
|
|
121
|
+
} else if (ap.left.type === "ObjectPattern") {
|
|
122
|
+
const obj = buildObjectCallArg(ap.left);
|
|
123
|
+
if (obj === null) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
args.push(obj);
|
|
127
|
+
} else {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return args.join(", ");
|
|
135
|
+
}
|
|
136
|
+
function buildObjectCallArg(pattern) {
|
|
137
|
+
const keys = [];
|
|
138
|
+
for (const prop of pattern.properties) {
|
|
139
|
+
if (prop.type === "RestElement") {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
if (prop.key.type !== "Identifier") {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
const keyName = prop.key.name;
|
|
146
|
+
let valueName = null;
|
|
147
|
+
if (prop.value.type === "Identifier") {
|
|
148
|
+
valueName = prop.value.name;
|
|
149
|
+
} else if (prop.value.type === "AssignmentPattern") {
|
|
150
|
+
if (prop.value.left.type === "Identifier") {
|
|
151
|
+
valueName = prop.value.left.name;
|
|
152
|
+
} else {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
if (valueName !== keyName) {
|
|
159
|
+
keys.push(`${keyName}: ${valueName}`);
|
|
160
|
+
} else {
|
|
161
|
+
keys.push(keyName);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return `{ ${keys.join(", ")} }`;
|
|
165
|
+
}
|
|
166
|
+
function buildWrappedExport(fnName, fnHeader, originalFnSrc, innerArgs, awaitKw, asyncKw, apiFolder, filename) {
|
|
167
|
+
const privateName = `__${fnName}`;
|
|
168
|
+
const spanName = `redwoodjs:api:${apiFolder}:${fnName}`;
|
|
169
|
+
return `export const ${fnName} = ${fnHeader}{
|
|
170
|
+
const ${privateName} = ${originalFnSrc}
|
|
171
|
+
const OTEL_TRACER = OTEL_TRACE.getTracer('redwoodjs')
|
|
172
|
+
const OTEL_RESULT = ${awaitKw}OTEL_TRACER.startActiveSpan(
|
|
173
|
+
'${spanName}',
|
|
174
|
+
${asyncKw}(span) => {
|
|
175
|
+
span.setAttribute('code.function', '${fnName}')
|
|
176
|
+
span.setAttribute('code.filepath', ${JSON.stringify(filename)})
|
|
177
|
+
try {
|
|
178
|
+
const OTEL_INNER_RESULT = ${awaitKw}${privateName}(${innerArgs})
|
|
179
|
+
span.end()
|
|
180
|
+
return OTEL_INNER_RESULT
|
|
181
|
+
} catch (error) {
|
|
182
|
+
span.recordException(error)
|
|
183
|
+
span.setStatus({
|
|
184
|
+
code: 2,
|
|
185
|
+
message:
|
|
186
|
+
error?.message?.split('\\n')[0] ??
|
|
187
|
+
error?.toString()?.split('\\n')[0],
|
|
188
|
+
})
|
|
189
|
+
span.end()
|
|
190
|
+
throw error
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
return OTEL_RESULT
|
|
195
|
+
}`;
|
|
196
|
+
}
|
|
197
|
+
export {
|
|
198
|
+
applyOtelWrapping,
|
|
199
|
+
cedarOtelWrappingPlugin
|
|
200
|
+
};
|
|
@@ -296,7 +296,7 @@ async function generateFunctionModule(distPath) {
|
|
|
296
296
|
const ctx = await buildCedarContext(request);
|
|
297
297
|
// Wrap the handler in an AsyncLocalStorage run so the global
|
|
298
298
|
// @cedarjs/context is available inside it (and isolated per request).
|
|
299
|
-
// Mirrors the GraphQL module above and the
|
|
299
|
+
// Mirrors the GraphQL module above and the handlerAlsWrappingPlugin
|
|
300
300
|
// used for non-UD builds.
|
|
301
301
|
const { getAsyncStoreInstance } = await import(
|
|
302
302
|
'@cedarjs/context/dist/store'
|
|
@@ -8,24 +8,24 @@ import type { Plugin } from 'vite';
|
|
|
8
8
|
* For each file in `api/src/functions/` that exports a `handler`, this plugin:
|
|
9
9
|
*
|
|
10
10
|
* 1. Adds an import at the top of the file:
|
|
11
|
-
* import { getAsyncStoreInstance as
|
|
11
|
+
* import { getAsyncStoreInstance as __cedar_getAsyncStoreInstance } from '@cedarjs/context/dist/store'
|
|
12
12
|
*
|
|
13
13
|
* 2. Renames the original handler:
|
|
14
|
-
* const
|
|
14
|
+
* const __cedar_handler = <original handler value>
|
|
15
15
|
*
|
|
16
16
|
* 3. Replaces the handler export with a wrapper that checks context isolation:
|
|
17
|
-
* export const handler = (
|
|
18
|
-
* const
|
|
19
|
-
* if (
|
|
20
|
-
* return
|
|
17
|
+
* export const handler = (__cedar_event, __cedar_context) => {
|
|
18
|
+
* const __cedar_contextStore = __cedar_getAsyncStoreInstance().getStore()
|
|
19
|
+
* if (__cedar_contextStore === undefined) {
|
|
20
|
+
* return __cedar_getAsyncStoreInstance().run(new Map(), __cedar_handler, __cedar_event, __cedar_context)
|
|
21
21
|
* }
|
|
22
|
-
* return
|
|
22
|
+
* return __cedar_handler(__cedar_event, __cedar_context)
|
|
23
23
|
* }
|
|
24
24
|
*
|
|
25
|
-
* This replaces `babel-plugin-
|
|
25
|
+
* This replaces `babel-plugin-handler-als-wrapping` for Vite builds.
|
|
26
26
|
* The babel plugin is still used for Jest and prerender.
|
|
27
27
|
*/
|
|
28
|
-
export declare function
|
|
28
|
+
export declare function handlerAlsWrappingPlugin({ projectIsEsm, }?: {
|
|
29
29
|
projectIsEsm?: boolean;
|
|
30
30
|
}): Plugin;
|
|
31
31
|
/**
|
|
@@ -34,11 +34,11 @@ export declare function cedarContextWrappingPlugin({ projectIsEsm, }?: {
|
|
|
34
34
|
* export a `handler`.
|
|
35
35
|
*
|
|
36
36
|
* This is the context-isolation safeguard that used to be performed by
|
|
37
|
-
* `babel-plugin-
|
|
37
|
+
* `babel-plugin-handler-als-wrapping`. It is exported as a standalone
|
|
38
38
|
* function so it can be applied from build pipelines that don't go through
|
|
39
39
|
* Vite's plugin pipeline (e.g. the legacy esbuild API build).
|
|
40
40
|
*/
|
|
41
|
-
export declare function
|
|
41
|
+
export declare function applyHandlerAlsWrapping(code: string, { projectIsEsm }?: {
|
|
42
42
|
projectIsEsm?: boolean;
|
|
43
43
|
}): string | null;
|
|
44
|
-
//# sourceMappingURL=vite-plugin-
|
|
44
|
+
//# sourceMappingURL=vite-plugin-handler-als-wrapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-handler-als-wrapping.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-handler-als-wrapping.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,YAAoB,GACrB,GAAE;IACD,YAAY,CAAC,EAAE,OAAO,CAAA;CAClB,GAAG,MAAM,CAuBd;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,EAAE,YAAoB,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,MAAM,GAAG,IAAI,CAsDf"}
|
package/dist/plugins/{vite-plugin-cedar-context-wrapping.js → vite-plugin-handler-als-wrapping.js}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { normalizePath } from "vite";
|
|
3
3
|
import { getPaths } from "@cedarjs/project-config";
|
|
4
|
-
function
|
|
4
|
+
function handlerAlsWrappingPlugin({
|
|
5
5
|
projectIsEsm = false
|
|
6
6
|
} = {}) {
|
|
7
7
|
return {
|
|
8
|
-
name: "
|
|
8
|
+
name: "handler-als-wrapping",
|
|
9
9
|
transform(code, id) {
|
|
10
10
|
let paths;
|
|
11
11
|
try {
|
|
@@ -17,12 +17,12 @@ function cedarContextWrappingPlugin({
|
|
|
17
17
|
if (!normalizePath(id).startsWith(functionsDir + "/")) {
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
|
-
const wrapped =
|
|
20
|
+
const wrapped = applyHandlerAlsWrapping(code, { projectIsEsm });
|
|
21
21
|
return wrapped ? { code: wrapped, map: null } : null;
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function applyHandlerAlsWrapping(code, { projectIsEsm = false } = {}) {
|
|
26
26
|
const handlerRe = /^export\s+(?:const|let|var)\s+handler(?:[^=]|=>)*?=(?![>=])/m;
|
|
27
27
|
const handlerMatch = handlerRe.exec(code);
|
|
28
28
|
if (!handlerMatch) {
|
|
@@ -31,30 +31,30 @@ function applyContextWrapping(code, { projectIsEsm = false } = {}) {
|
|
|
31
31
|
const afterEquals = code.slice(handlerMatch.index + handlerMatch[0].length).trimStart();
|
|
32
32
|
const isAsync = /^async(?:\s*[\(\*]|\s+function)/.test(afterEquals);
|
|
33
33
|
const storePath = projectIsEsm ? "@cedarjs/context/dist/store.js" : "@cedarjs/context/dist/store";
|
|
34
|
-
const importStatement = `import { getAsyncStoreInstance as
|
|
34
|
+
const importStatement = `import { getAsyncStoreInstance as __cedar_getAsyncStoreInstance } from '${storePath}'
|
|
35
35
|
`;
|
|
36
36
|
const handlerStart = handlerMatch.index;
|
|
37
37
|
const before = code.slice(0, handlerStart);
|
|
38
38
|
const after = code.slice(handlerStart);
|
|
39
|
-
const renamed = after.replace(handlerRe, "const
|
|
39
|
+
const renamed = after.replace(handlerRe, "const __cedar_handler =");
|
|
40
40
|
const wrappedHandler = `
|
|
41
|
-
export const handler = ${isAsync ? "async " : ""}(
|
|
41
|
+
export const handler = ${isAsync ? "async " : ""}(__cedar_event, __cedar_context) => {
|
|
42
42
|
// The store will be undefined if no context isolation has been performed yet
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
return
|
|
43
|
+
const __cedar_contextStore = __cedar_getAsyncStoreInstance().getStore()
|
|
44
|
+
if (__cedar_contextStore === undefined) {
|
|
45
|
+
return __cedar_getAsyncStoreInstance().run(
|
|
46
46
|
new Map(),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
__cedar_handler,
|
|
48
|
+
__cedar_event,
|
|
49
|
+
__cedar_context
|
|
50
50
|
)
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return __cedar_handler(__cedar_event, __cedar_context)
|
|
53
53
|
}
|
|
54
54
|
`;
|
|
55
55
|
return before + importStatement + renamed + wrappedHandler;
|
|
56
56
|
}
|
|
57
57
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
applyHandlerAlsWrapping,
|
|
59
|
+
handlerAlsWrappingPlugin
|
|
60
60
|
};
|
|
@@ -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"}
|