vite-plugin-react-server 0.3.18 → 0.3.19
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/README.md +119 -118
- package/bin/patch.mjs +8 -2
- package/dist/package.json +3 -3
- package/dist/plugin/checkFilesExist.d.ts.map +1 -1
- package/dist/plugin/checkFilesExist.js +6 -2
- package/dist/plugin/checkFilesExist.js.map +1 -1
- package/dist/plugin/collect-manifest-client-files.d.ts +23 -0
- package/dist/plugin/collect-manifest-client-files.d.ts.map +1 -0
- package/dist/plugin/collect-manifest-client-files.js +117 -0
- package/dist/plugin/collect-manifest-client-files.js.map +1 -0
- package/dist/plugin/components.d.ts +9 -9
- package/dist/plugin/components.d.ts.map +1 -1
- package/dist/plugin/components.js +50 -9
- package/dist/plugin/components.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +7 -6
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +8 -5
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/getPaths.d.ts +0 -1
- package/dist/plugin/config/getPaths.d.ts.map +1 -1
- package/dist/plugin/config/getPaths.js +2 -7
- package/dist/plugin/config/getPaths.js.map +1 -1
- package/dist/plugin/config/mimeTypes.d.ts +2 -0
- package/dist/plugin/config/mimeTypes.d.ts.map +1 -0
- package/dist/plugin/config/mimeTypes.js +24 -0
- package/dist/plugin/config/mimeTypes.js.map +1 -0
- package/dist/plugin/config/resolveOptions.d.ts +1 -1
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +41 -28
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +1 -0
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js +9 -5
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts +2 -1
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +10 -5
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/copy-dir.js +23 -18
- package/dist/plugin/copy-dir.js.map +1 -0
- package/dist/plugin/helpers/createHandler.d.ts +22 -0
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -0
- package/dist/plugin/{react-server → helpers}/createHandler.js +36 -48
- package/dist/plugin/helpers/createHandler.js.map +1 -0
- package/dist/plugin/{react-server → helpers}/createRscStream.d.ts +2 -1
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -0
- package/dist/plugin/helpers/createRscStream.js +71 -0
- package/dist/plugin/helpers/createRscStream.js.map +1 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +12 -4
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +1 -1
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +8 -5
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/css-loader.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.js.map +1 -1
- package/dist/plugin/loader/react-loader.js +2 -2
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/preserver/plugin.d.ts.map +1 -1
- package/dist/plugin/preserver/plugin.js +49 -14
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +18 -76
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-server/index.d.ts.map +1 -1
- package/dist/plugin/react-server/index.js +2 -0
- package/dist/plugin/react-server/index.js.map +1 -1
- package/dist/plugin/react-server/plugin.d.ts +2 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +53 -217
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-static/index.d.ts +2 -0
- package/dist/plugin/react-static/index.d.ts.map +1 -0
- package/dist/plugin/react-static/index.js +1 -0
- package/dist/plugin/react-static/plugin.d.ts +7 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -0
- package/dist/plugin/react-static/plugin.js +199 -0
- package/dist/plugin/react-static/plugin.js.map +1 -0
- package/dist/plugin/resolvePage.d.ts.map +1 -1
- package/dist/plugin/resolvePage.js +9 -0
- package/dist/plugin/resolvePage.js.map +1 -1
- package/dist/plugin/root.d.ts +2 -0
- package/dist/plugin/root.d.ts.map +1 -0
- package/dist/plugin/root.js +12 -0
- package/dist/plugin/root.js.map +1 -0
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +32 -23
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/types.d.ts +1 -18
- package/dist/plugin/transformer/types.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +24 -6
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +0 -1
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.d.ts +30 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +30 -2
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +3 -5
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +8 -2
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/plugin.d.ts.map +1 -1
- package/dist/plugin/worker/html/plugin.js +2 -3
- package/dist/plugin/worker/html/renderPages.d.ts +8 -4
- package/dist/plugin/worker/html/renderPages.d.ts.map +1 -1
- package/dist/plugin/worker/html/renderPages.js +118 -83
- package/dist/plugin/worker/html/renderPages.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +89 -84
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/plugin.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/plugin.js +1 -2
- package/dist/plugin/worker/rsc/rsc-worker.development.js +13 -18
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +4 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/plugin/checkFilesExist.ts +7 -3
- package/plugin/collect-manifest-client-files.ts +152 -0
- package/plugin/components.tsx +55 -10
- package/plugin/config/defaults.tsx +69 -0
- package/plugin/config/getPaths.ts +1 -7
- package/plugin/config/mimeTypes.ts +17 -0
- package/plugin/config/resolveOptions.ts +48 -40
- package/plugin/config/resolvePages.ts +8 -4
- package/plugin/config/resolveUserConfig.ts +12 -9
- package/plugin/{react-server → helpers}/createHandler.ts +46 -63
- package/plugin/helpers/createRscStream.ts +81 -0
- package/plugin/helpers/getBundleManifest.ts +14 -5
- package/plugin/loader/createBuildLoader.ts +9 -6
- package/plugin/loader/css-loader.ts +0 -2
- package/plugin/loader/react-loader.ts +2 -2
- package/plugin/preserver/plugin.ts +64 -17
- package/plugin/react-client/plugin.ts +20 -91
- package/plugin/react-server/index.ts +2 -0
- package/plugin/react-server/plugin.ts +66 -293
- package/plugin/react-static/index.ts +1 -0
- package/plugin/react-static/plugin.ts +247 -0
- package/plugin/resolvePage.ts +9 -0
- package/plugin/root.ts +4 -0
- package/plugin/transformer/plugin.ts +40 -31
- package/plugin/transformer/types.ts +0 -19
- package/plugin/types.ts +25 -6
- package/plugin/worker/createWorker.ts +1 -1
- package/plugin/worker/html/README.md +63 -0
- package/plugin/worker/html/html-worker.development.tsx +89 -2
- package/plugin/worker/html/html-worker.production.tsx +8 -10
- package/plugin/worker/html/messageHandler.ts +8 -2
- package/plugin/worker/html/plugin.ts +2 -3
- package/plugin/worker/html/renderPages.ts +150 -114
- package/plugin/worker/rsc/README.md +58 -0
- package/plugin/worker/rsc/messageHandler.tsx +95 -111
- package/plugin/worker/rsc/plugin.ts +1 -2
- package/plugin/worker/rsc/rsc-worker.development.ts +12 -22
- package/plugin/worker/rsc/rsc-worker.production.ts +5 -1
- package/plugin/worker/rsc/state.ts +0 -3
- package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +114 -12
- package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +10571 -121
- package/tsconfig.json +2 -2
- package/dist/plugin/collect-css-manifest.d.ts +0 -4
- package/dist/plugin/collect-css-manifest.d.ts.map +0 -1
- package/dist/plugin/collect-css-manifest.js +0 -65
- package/dist/plugin/collect-css-manifest.js.map +0 -1
- package/dist/plugin/config/createModuleIdGenerator.d.ts +0 -11
- package/dist/plugin/config/createModuleIdGenerator.d.ts.map +0 -1
- package/dist/plugin/config/createModuleIdGenerator.js +0 -44
- package/dist/plugin/config/createModuleIdGenerator.js.map +0 -1
- package/dist/plugin/loader/createCssLoader.d.ts +0 -30
- package/dist/plugin/loader/createCssLoader.d.ts.map +0 -1
- package/dist/plugin/loader/createCssLoader.js +0 -35
- package/dist/plugin/loader/createPageLoader.d.ts +0 -24
- package/dist/plugin/loader/createPageLoader.d.ts.map +0 -1
- package/dist/plugin/loader/createPageLoader.js +0 -50
- package/dist/plugin/loader/rsc/messageHandler.d.ts +0 -2
- package/dist/plugin/loader/rsc/messageHandler.d.ts.map +0 -1
- package/dist/plugin/loader/rsc/messageHandler.js +0 -1
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts +0 -2
- package/dist/plugin/loader/rsc/rsc-worker.development.d.ts.map +0 -1
- package/dist/plugin/loader/rsc/rsc-worker.development.js +0 -1
- package/dist/plugin/react-server/createHandler.d.ts +0 -17
- package/dist/plugin/react-server/createHandler.d.ts.map +0 -1
- package/dist/plugin/react-server/createHandler.js.map +0 -1
- package/dist/plugin/react-server/createRscStream.d.ts.map +0 -1
- package/dist/plugin/react-server/createRscStream.js +0 -70
- package/dist/plugin/react-server/createRscStream.js.map +0 -1
- package/dist/plugin/react-server/createSsrHandler.d.ts +0 -4
- package/dist/plugin/react-server/createSsrHandler.d.ts.map +0 -1
- package/dist/plugin/react-server/createSsrHandler.js +0 -95
- package/dist/plugin/utils/logger.d.ts +0 -9
- package/dist/plugin/utils/logger.d.ts.map +0 -1
- package/dist/plugin/utils/logger.js +0 -68
- package/dist/plugin/utils/logger.js.map +0 -1
- package/plugin/collect-css-manifest.ts +0 -82
- package/plugin/config/createModuleIdGenerator.ts +0 -52
- package/plugin/config/defaults.ts +0 -51
- package/plugin/loader/createCssLoader.ts +0 -73
- package/plugin/loader/createPageLoader.ts +0 -103
- package/plugin/loader/rsc/messageHandler.tsx +0 -1
- package/plugin/loader/rsc/rsc-worker.development.ts +0 -1
- package/plugin/react-server/createRscStream.ts +0 -86
- package/plugin/react-server/createSsrHandler.ts +0 -125
- package/plugin/utils/logger.ts +0 -52
package/tsconfig.json
CHANGED
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
// We don't allow property access from index signatures. In this case we prefer to write record['images'] instead of record.images
|
|
25
25
|
"noPropertyAccessFromIndexSignature": true,
|
|
26
26
|
// You'll get an error if you forget to remove a variable. Toggle on when you want to clean up code, turn off when you are working on a new feature.
|
|
27
|
-
"noUnusedLocals":
|
|
27
|
+
"noUnusedLocals": true,
|
|
28
28
|
// Same as above, but for function parameters.
|
|
29
|
-
"noUnusedParameters":
|
|
29
|
+
"noUnusedParameters": true,
|
|
30
30
|
// We allow JSON imports. In fact we promote using them. We need to use the `with {type: 'json'}` which is the most recent way to do it.
|
|
31
31
|
"resolveJsonModule": true,
|
|
32
32
|
// If you are having issues with libraries, you can disable this and it won't check the types of the libraries.
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Manifest, ModuleGraph } from 'vite';
|
|
2
|
-
export declare function collectModuleGraphCss(moduleGraph: ModuleGraph, pagePath: string, onCss?: (path: string) => void): Promise<Map<string, string>>;
|
|
3
|
-
export declare function collectManifestCss(manifest: Manifest, root: string, pagePath: string, onCss?: (path: string, parentUrl: string) => void, parentUrl?: string): Map<string, string>;
|
|
4
|
-
//# sourceMappingURL=collect-css-manifest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collect-css-manifest.d.ts","sourceRoot":"","sources":["../../plugin/collect-css-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAElD,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,gCAqB/B;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,EACjD,SAAS,CAAC,EAAE,MAAM,uBAgDnB"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
async function collectModuleGraphCss(moduleGraph, pagePath, onCss) {
|
|
7
|
-
if (!pagePath) return /* @__PURE__ */ new Map();
|
|
8
|
-
const cssFiles = /* @__PURE__ */ new Map();
|
|
9
|
-
const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);
|
|
10
|
-
if (!pageModule) {
|
|
11
|
-
return /* @__PURE__ */ new Map();
|
|
12
|
-
}
|
|
13
|
-
const seen = /* @__PURE__ */ new Set();
|
|
14
|
-
const walkModule = (mod) => {
|
|
15
|
-
if (!mod?.id || seen.has(mod.id)) return;
|
|
16
|
-
seen.add(mod.id);
|
|
17
|
-
if (mod?.id?.endsWith(".css")) {
|
|
18
|
-
cssFiles.set(mod?.url, mod?.id);
|
|
19
|
-
}
|
|
20
|
-
mod?.importedModules?.forEach((imp) => walkModule(imp));
|
|
21
|
-
};
|
|
22
|
-
walkModule(pageModule);
|
|
23
|
-
return cssFiles;
|
|
24
|
-
}
|
|
25
|
-
function collectManifestCss(manifest, root, pagePath, onCss, parentUrl) {
|
|
26
|
-
const relativePagePath = root !== "" && pagePath.startsWith(root.endsWith("/") ? root : root + "/") ? pagePath.slice(root.length + (root.endsWith("/") ? 0 : 1)) : pagePath;
|
|
27
|
-
const cssFiles = /* @__PURE__ */ new Map();
|
|
28
|
-
const seen = /* @__PURE__ */ new Set();
|
|
29
|
-
const manifestValues = Object.values(manifest);
|
|
30
|
-
const walkManifestEntry = (id) => {
|
|
31
|
-
if (seen.has(id)) return;
|
|
32
|
-
seen.add(id);
|
|
33
|
-
if (id.endsWith(".css")) {
|
|
34
|
-
cssFiles.set(id, id);
|
|
35
|
-
onCss?.(id, parentUrl ?? pagePath);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (id.endsWith(".css.js")) {
|
|
39
|
-
cssFiles.set(id.slice(0, -3), id.slice(0, -3));
|
|
40
|
-
onCss?.(id.slice(0, -3), parentUrl ?? pagePath);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const entry = manifest[id] ?? manifestValues.find((e) => e.file === id);
|
|
44
|
-
if (!entry) return;
|
|
45
|
-
if (entry.css) {
|
|
46
|
-
entry.css.forEach((css) => {
|
|
47
|
-
cssFiles.set(entry.src ?? entry.file ?? "", css);
|
|
48
|
-
onCss?.(css, parentUrl ?? pagePath);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (entry.imports) {
|
|
52
|
-
entry.imports.forEach((imp) => walkManifestEntry(imp));
|
|
53
|
-
}
|
|
54
|
-
if (entry.dynamicImports) {
|
|
55
|
-
entry.dynamicImports.forEach((imp) => walkManifestEntry(imp));
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
if (manifest[relativePagePath]) {
|
|
59
|
-
walkManifestEntry(relativePagePath);
|
|
60
|
-
}
|
|
61
|
-
return cssFiles;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { collectManifestCss, collectModuleGraphCss };
|
|
65
|
-
//# sourceMappingURL=collect-css-manifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collect-css-manifest.js","sources":["../../plugin/collect-css-manifest.ts"],"sourcesContent":["import type { Manifest, ModuleGraph } from 'vite';\n\nexport async function collectModuleGraphCss(\n moduleGraph: ModuleGraph,\n pagePath: string,\n onCss?: (path: string) => void\n) {\n if (!pagePath) return new Map<string, string>();\n\n const cssFiles = new Map<string, string>();\n const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);\n if (!pageModule) {\n return new Map<string, string>();\n }\n const seen = new Set<string>();\n const walkModule = (mod: any) => {\n if (!mod?.id || seen.has(mod.id)) return;\n seen.add(mod.id);\n if (mod?.id?.endsWith(\".css\")) {\n cssFiles.set(mod?.url, mod?.id);\n onCss?.(mod?.url);\n }\n mod?.importedModules?.forEach((imp: any) => walkModule(imp));\n };\n walkModule(pageModule);\n return cssFiles;\n}\n\nexport function collectManifestCss(\n manifest: Manifest,\n root: string,\n pagePath: string,\n onCss?: (path: string, parentUrl: string) => void,\n parentUrl?: string\n) {\n const relativePagePath = root !== \"\" && pagePath.startsWith(root.endsWith('/') ? root : root + '/')\n ? pagePath.slice(root.length + (root.endsWith('/') ? 0 : 1))\n : pagePath;\n const cssFiles = new Map<string, string>();\n const seen = new Set<string>();\n const manifestValues = Object.values(manifest);\n const walkManifestEntry = (id: string) => {\n if (seen.has(id)) return;\n seen.add(id);\n if (id.endsWith(\".css\")) {\n cssFiles.set(id, id);\n onCss?.(id, parentUrl ?? pagePath);\n return;\n }\n if (id.endsWith(\".css.js\")) {\n cssFiles.set(id.slice(0, -3), id.slice(0, -3));\n onCss?.(id.slice(0, -3), parentUrl ?? pagePath);\n return;\n }\n // Get the manifest entry\n const entry = manifest[id] ?? manifestValues.find(e => e.file === id);\n if (!entry) return;\n\n // Add direct CSS\n if (entry.css) {\n entry.css.forEach((css: string) => {\n cssFiles.set(entry.src ?? entry.file ?? '', css);\n onCss?.(css, parentUrl ?? pagePath);\n });\n }\n\n // Walk imports recursively\n if (entry.imports) {\n entry.imports.forEach((imp: string) => walkManifestEntry(imp));\n }\n\n // Also check dynamicImports\n if (entry.dynamicImports) {\n entry.dynamicImports.forEach((imp: string) => walkManifestEntry(imp));\n }\n };\n\n if (manifest[relativePagePath]) {\n walkManifestEntry(relativePagePath);\n }\n return cssFiles;\n}\n"],"names":[],"mappings":";;;;;AAEsB,eAAA,qBAAA,CACpB,WACA,EAAA,QAAA,EACA,KACA,EAAA;AACA,EAAA,IAAI,CAAC,QAAA,EAAiB,uBAAA,IAAI,GAAoB,EAAA;AAE9C,EAAM,MAAA,QAAA,uBAAe,GAAoB,EAAA;AACzC,EAAA,MAAM,UAAa,GAAA,MAAM,WAAY,CAAA,cAAA,CAAe,UAAU,IAAI,CAAA;AAClE,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAA,2BAAW,GAAoB,EAAA;AAAA;AAEjC,EAAM,MAAA,IAAA,uBAAW,GAAY,EAAA;AAC7B,EAAM,MAAA,UAAA,GAAa,CAAC,GAAa,KAAA;AAC/B,IAAA,IAAI,CAAC,GAAK,EAAA,EAAA,IAAM,KAAK,GAAI,CAAA,GAAA,CAAI,EAAE,CAAG,EAAA;AAClC,IAAK,IAAA,CAAA,GAAA,CAAI,IAAI,EAAE,CAAA;AACf,IAAA,IAAI,GAAK,EAAA,EAAA,E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ean;
|
|
3
|
-
inputRoot: string;
|
|
4
|
-
client: string;
|
|
5
|
-
server: string;
|
|
6
|
-
moduleBase: string;
|
|
7
|
-
preserveModulesRoot: boolean;
|
|
8
|
-
removeExtension: ((path: string) => boolean) | string | RegExp;
|
|
9
|
-
imports: Record<string, string>;
|
|
10
|
-
}) => (moduleIdPath: string, ssr?: boolean) => string;
|
|
11
|
-
//# sourceMappingURL=createModuleIdGenerator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createModuleIdGenerator.d.ts","sourceRoot":"","sources":["../../../plugin/config/createModuleIdGenerator.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,2GASjC;IACD,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC;IAC/D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,oBAMuB,MAAM,0BAyB7B,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
import { createInputNormalizer } from '../helpers/inputNormalizer.js';
|
|
7
|
-
|
|
8
|
-
const createModuleIdGenerator = ({
|
|
9
|
-
inputRoot,
|
|
10
|
-
client,
|
|
11
|
-
server,
|
|
12
|
-
moduleBase,
|
|
13
|
-
isProduction,
|
|
14
|
-
preserveModulesRoot,
|
|
15
|
-
imports,
|
|
16
|
-
removeExtension
|
|
17
|
-
}) => {
|
|
18
|
-
const normalizer = createInputNormalizer({
|
|
19
|
-
root: inputRoot,
|
|
20
|
-
removeExtension,
|
|
21
|
-
preserveModulesRoot: preserveModulesRoot === true ? moduleBase : undefined
|
|
22
|
-
});
|
|
23
|
-
return (moduleIdPath, ssr = isProduction) => {
|
|
24
|
-
const [moduleId, modulePath] = normalizer(moduleIdPath);
|
|
25
|
-
const key = preserveModulesRoot ? `${moduleBase}/${moduleId}` : moduleId;
|
|
26
|
-
const hasImports = key in imports;
|
|
27
|
-
if (hasImports) {
|
|
28
|
-
const mappedImport = imports[key];
|
|
29
|
-
const noRoot = mappedImport.startsWith(inputRoot) ? mappedImport.slice(inputRoot.length + 1) : mappedImport;
|
|
30
|
-
const noModuleBase = preserveModulesRoot ? noRoot.startsWith(moduleBase) ? noRoot.slice(moduleBase.length) : noRoot : noRoot;
|
|
31
|
-
return noModuleBase;
|
|
32
|
-
} else if (ssr && isProduction) {
|
|
33
|
-
const availableImports = Object.keys(imports).length > 0 ? Object.keys(imports).join(", ") : "none";
|
|
34
|
-
throw new Error(
|
|
35
|
-
`${availableImports === "none" ? "No imports." : `Module ID ${key}, ${modulePath} is not in imports. Available imports: ${availableImports}`}`
|
|
36
|
-
);
|
|
37
|
-
} else {
|
|
38
|
-
return moduleId;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { createModuleIdGenerator };
|
|
44
|
-
//# sourceMappingURL=createModuleIdGenerator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createModuleIdGenerator.js","sources":["../../../plugin/config/createModuleIdGenerator.ts"],"sourcesContent":["import { createInputNormalizer } from \"../helpers/inputNormalizer.js\";\n\nexport const createModuleIdGenerator = ({\n inputRoot,\n client,\n server,\n moduleBase,\n isProduction,\n preserveModulesRoot,\n imports,\n removeExtension\n}: {\n isProduction: boolean;\n inputRoot: string;\n client: string;\n server: string;\n moduleBase: string;\n preserveModulesRoot: boolean;\n removeExtension: ((path: string) => boolean) | string | RegExp;\n imports: Record<string, string>;\n}) => {\n const normalizer = createInputNormalizer({\n root: inputRoot,\n removeExtension: removeExtension,\n preserveModulesRoot: preserveModulesRoot === true ? moduleBase : undefined,\n });\n return (moduleIdPath: string, ssr = isProduction) => {\n const [moduleId, modulePath] = normalizer(moduleIdPath);\n const key = preserveModulesRoot ? `${moduleBase}/${moduleId}` : moduleId;\n const hasImports = key in imports;\n\n if (hasImports) {\n // Return the actual file path from the manifest\n const mappedImport = imports[key];\n const noRoot = mappedImport.startsWith(inputRoot) ? mappedImport.slice(inputRoot.length +1) : mappedImport;\n const noModuleBase = preserveModulesRoot ? noRoot.startsWith(moduleBase) ? noRoot.slice(moduleBase.length) : noRoot : noRoot;\n return noModuleBase;\n } else if (ssr && isProduction) {\n // Only throw in production SSR builds\n const availableImports =\n Object.keys(imports).length > 0\n ? Object.keys(imports).join(\", \")\n : \"none\";\n throw new Error(\n `${availableImports === \"none\" ? \"No imports.\" : `Module ID ${key}, ${modulePath} is not in imports. Available imports: ${availableImports}`}`\n );\n } else {\n // For development or non-SSR builds, use the module ID\n return moduleId;\n }\n };\n};\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,0BAA0B,CAAC;AAAA,EACtC,SAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,mBAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CASM,KAAA;AACJ,EAAA,MAAM,aAAa,qBAAsB,CAAA;AAAA,IACvC,IAAM,EAAA,SAAA;AAAA,IACN,eAAA;AAAA,IACA,mBAAA,EAAqB,mBAAwB,KAAA,IAAA,GAAO,UAAa,GAAA;AAAA,GAClE,CAAA;AACD,EAAO,OAAA,CAAC,YAAsB,EAAA,GAAA,GAAM,YAAiB,KAAA;AACnD,IAAA,MAAM,CAAC,QAAA,EAAU,UAAU,CAAA,GAAI,WAAW,YAAY,CAAA;AACtD,IAAA,MAAM,MAAM,mBAAsB,GAAA,CAAA,EAAG,UAAU,CAAA,CAAA,EAAI,QAAQ,CAAK,CAAA,GAAA,QAAA;AAChE,IAAA,MAAM,aAAa,GAAO,IAAA,OAAA;AAE1B,IAAA,IAAI,UAAY,EAAA;AAEd,MAAM,MAAA,YAAA,GAAe,QAAQ,GAAG,CAAA;AAChC,MAAM,MAAA,MAAA,GAAS,YAAa,CAAA,UAAA,CAAW,SAAS,CAAA,GAAI,aAAa,KAAM,CAAA,SAAA,CAAU,MAAQ,GAAA,CAAC,CAAI,GAAA,YAAA;AAC9F,MAAM,MAAA,YAAA,GAAe,mBAAsB,GAAA,MAAA,CAAO,UAAW,CAAA,UAAU,CAAI,GAAA,MAAA,CAAO,KAAM,CAAA,UAAA,CAAW,MAAM,CAAA,GAAI,MAAS,GAAA,MAAA;AACtH,MAAO,OAAA,YAAA;AAAA,KACT,MAAA,IAAW,OAAO,YAAc,EAAA;AAE9B,MAAA,MAAM,gBACJ,GAAA,MAAA,CAAO,IAAK,CAAA,OAAO,CAAE,CAAA,MAAA,GAAS,CAC1B,GAAA,MAAA,CAAO,IAAK,CAAA,OAAO,CAAE,CAAA,IAAA,CAAK,IAAI,CAC9B,GAAA,MAAA;AACN,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,EAAG,gBAAqB,KAAA,MAAA,GAAS,aAAgB,GAAA,CAAA,UAAA,EAAa,GAAG,CAAK,EAAA,EAAA,UAAU,CAA0C,uCAAA,EAAA,gBAAgB,CAAE,CAAA,CAAA;AAAA,OAC9I;AAAA,KACK,MAAA;AAEL,MAAO,OAAA,QAAA;AAAA;AACT,GACF;AACF;;;;"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ModuleGraph, type Manifest } from "vite";
|
|
2
|
-
type BaseCssLoaderOptions = {
|
|
3
|
-
/** callback to add css files to the stream */
|
|
4
|
-
onCssFile: (css: string) => void;
|
|
5
|
-
/** loader to load the module */
|
|
6
|
-
loader: (id: string) => Promise<Record<string, any>>;
|
|
7
|
-
/** url of the page */
|
|
8
|
-
url: string;
|
|
9
|
-
/** manually provided css files to add */
|
|
10
|
-
cssFiles: string[];
|
|
11
|
-
};
|
|
12
|
-
type CreateCssLoaderOptions = (BaseCssLoaderOptions & {
|
|
13
|
-
/** manifest to collect css from */
|
|
14
|
-
manifest: Manifest;
|
|
15
|
-
/** when manifest is given, moduleGraph is not needed */
|
|
16
|
-
moduleGraph?: never;
|
|
17
|
-
}) | (BaseCssLoaderOptions & {
|
|
18
|
-
/** when moduleGraph is given, manifest is not needed, manual cssFiles can still be provided */
|
|
19
|
-
manifest?: never;
|
|
20
|
-
/** when moduleGraph is given, manifest is not needed, manual cssFiles can still be provided */
|
|
21
|
-
moduleGraph: ModuleGraph;
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* create a loader that can be used to load css files from a manifest or a moduleGraph
|
|
25
|
-
* @param options
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
export declare function createCssLoader(options: CreateCssLoaderOptions): Promise<(id: string) => Promise<Record<string, any>>>;
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=createCssLoader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createCssLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createCssLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAMlD,KAAK,oBAAoB,GAAG;IAC1B,8CAA8C;IAC9C,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,gCAAgC;IAChC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACrD,sBAAsB;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,KAAK,sBAAsB,GACvB,CAAC,oBAAoB,GAAG;IACtB,mCAAmC;IACnC,QAAQ,EAAE,QAAQ,CAAC;IACnB,wDAAwD;IACxD,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC,GACF,CAAC,oBAAoB,GAAG;IACtB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,+FAA+F;IAC/F,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC,CAAC;AAEP;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,gBAkBpC,MAAM,mCAkBtC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ModuleGraph } from "vite";
|
|
2
|
-
import { collectManifestCss, collectModuleGraphCss, } from "../collect-css-manifest.js";
|
|
3
|
-
/**
|
|
4
|
-
* create a loader that can be used to load css files from a manifest or a moduleGraph
|
|
5
|
-
* @param options
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export async function createCssLoader(options) {
|
|
9
|
-
const root = process.cwd();
|
|
10
|
-
const cssModules = new Set();
|
|
11
|
-
if (!(options.manifest || options.moduleGraph))
|
|
12
|
-
throw new Error("Missing manifest or moduleGraph, pass it to options.");
|
|
13
|
-
const getCss = options.manifest
|
|
14
|
-
? (id) => collectManifestCss(options.manifest, root, id, options.onCssFile)
|
|
15
|
-
: (id) => collectModuleGraphCss(options.moduleGraph, id, options.onCssFile);
|
|
16
|
-
const loadWithCss = async (id) => {
|
|
17
|
-
if (!id)
|
|
18
|
-
return {};
|
|
19
|
-
try {
|
|
20
|
-
const mod = await options.loader(id);
|
|
21
|
-
const pageCss = await Promise.resolve(getCss(id));
|
|
22
|
-
Array.from(pageCss.keys()).forEach((css) => cssModules.add(css));
|
|
23
|
-
return mod;
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
if (e.message?.includes("module runner has been closed")) {
|
|
27
|
-
return { type: "skip" };
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return { type: "error", error: e };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
return loadWithCss;
|
|
35
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type CreatePageLoaderOptions = {
|
|
2
|
-
manifest: Record<string, {
|
|
3
|
-
file: string;
|
|
4
|
-
src?: string;
|
|
5
|
-
}>;
|
|
6
|
-
root: string;
|
|
7
|
-
outDir: string;
|
|
8
|
-
moduleBase: string;
|
|
9
|
-
registerServer?: string[];
|
|
10
|
-
registerClient?: string[];
|
|
11
|
-
alwaysRegisterServer?: boolean;
|
|
12
|
-
alwaysRegisterClient?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type CreateDefaultLoaderOptions = {
|
|
15
|
-
id: string;
|
|
16
|
-
registerServer?: string[];
|
|
17
|
-
registerClient?: string[];
|
|
18
|
-
alwaysRegisterServer?: boolean;
|
|
19
|
-
alwaysRegisterClient?: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare const createDefaultLoader: ({ id, registerServer, registerClient, alwaysRegisterServer, alwaysRegisterClient, }: CreateDefaultLoaderOptions) => (url: string) => Promise<any>;
|
|
22
|
-
export declare function createPageLoader({ manifest, root, outDir, moduleBase, alwaysRegisterServer, alwaysRegisterClient, registerServer, registerClient, }: CreatePageLoaderOptions): (id: string) => Promise<any>;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=createPageLoader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createPageLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createPageLoader.ts"],"names":[],"mappings":"AAaA,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,mBAAmB,wFAM7B,0BAA0B,WAqBR,MAAM,iBAM1B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,UAAU,EACV,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,cAAc,GACf,EAAE,uBAAuB,QACS,MAAM,kBAyBxC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { resolve as resolvePath } from "node:path";
|
|
2
|
-
import { load
|
|
3
|
-
// @ts-ignore
|
|
4
|
-
} from "react-server-dom-esm/node-loader";
|
|
5
|
-
import { registerClientReference, registerServerReference,
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
} from "react-server-dom-esm/server.node";
|
|
8
|
-
export const createDefaultLoader = ({ id, registerServer, registerClient, alwaysRegisterServer = false, alwaysRegisterClient = false, }) => {
|
|
9
|
-
const mapper = ([key, value]) => {
|
|
10
|
-
try {
|
|
11
|
-
if (registerClient?.includes(key) ||
|
|
12
|
-
(alwaysRegisterClient && typeof value === "function")) {
|
|
13
|
-
return [key, registerClientReference(value, id, key)];
|
|
14
|
-
}
|
|
15
|
-
if (registerServer?.includes(key) ||
|
|
16
|
-
(alwaysRegisterServer && typeof value === "function")) {
|
|
17
|
-
return [key, registerServerReference(value, id, key)];
|
|
18
|
-
}
|
|
19
|
-
return [key, value];
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
console.error("[RSC] Error registering reference:", key, value, e);
|
|
23
|
-
return [key, value];
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
return async (url) => {
|
|
27
|
-
console.log("[createDefaultLoader] Loading:", url);
|
|
28
|
-
const result = await import(url);
|
|
29
|
-
console.log("[createDefaultLoader] Result:", result);
|
|
30
|
-
return Object.fromEntries(Object.entries(result).map(mapper));
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
export function createPageLoader({ manifest, root, outDir, moduleBase, alwaysRegisterServer, alwaysRegisterClient, registerServer, registerClient, }) {
|
|
34
|
-
return async function loader(id) {
|
|
35
|
-
// Try to find the entry directly or by source file
|
|
36
|
-
const manifestEntry = manifest[id] ||
|
|
37
|
-
Object.values(manifest).find(entry => entry.src === id);
|
|
38
|
-
if (!manifestEntry) {
|
|
39
|
-
throw new Error(`Could not find manifest entry for ${id} from ${root}. Available entries: ${Object.keys(manifest).join(', ')}`);
|
|
40
|
-
}
|
|
41
|
-
const loaderResult = await load(resolvePath(root, outDir, manifestEntry.file), { format: "module" }, createDefaultLoader({
|
|
42
|
-
id,
|
|
43
|
-
registerServer,
|
|
44
|
-
registerClient,
|
|
45
|
-
alwaysRegisterServer,
|
|
46
|
-
alwaysRegisterClient,
|
|
47
|
-
}));
|
|
48
|
-
return loaderResult;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messageHandler.d.ts","sourceRoot":"","sources":["../../../../plugin/loader/rsc/messageHandler.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rsc-worker.development.d.ts","sourceRoot":"","sources":["../../../../plugin/loader/rsc/rsc-worker.development.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { PipeableStream } from "react-dom/server";
|
|
2
|
-
import type { CreateHandlerOptions, ResolvedUserOptions } from "../types.js";
|
|
3
|
-
type CreateHandlerResult = {
|
|
4
|
-
type: "success";
|
|
5
|
-
controller: AbortController;
|
|
6
|
-
stream: PipeableStream;
|
|
7
|
-
assets: any;
|
|
8
|
-
clientPath: string;
|
|
9
|
-
} | {
|
|
10
|
-
type: "error";
|
|
11
|
-
error: Error;
|
|
12
|
-
} | {
|
|
13
|
-
type: "skip";
|
|
14
|
-
};
|
|
15
|
-
export declare function createHandler<T>(url: string, pluginOptions: ResolvedUserOptions, streamOptions: CreateHandlerOptions<T>): Promise<CreateHandlerResult>;
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=createHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createHandler.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAG7E,KAAK,mBAAmB,GACpB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACzG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAOrB,wBAAsB,aAAa,CAAC,CAAC,EACnC,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,mBAAmB,EAClC,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAuI9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createHandler.js","sources":["../../../plugin/react-server/createHandler.ts"],"sourcesContent":["import type { PipeableStream } from \"react-dom/server\";\nimport { createLogger } from \"vite\";\nimport {\n collectManifestCss,\n collectModuleGraphCss,\n} from \"../collect-css-manifest.js\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\nimport { resolvePage } from \"../resolvePage.js\";\nimport { resolveProps } from \"../resolveProps.js\";\nimport type { CreateHandlerOptions, ResolvedUserOptions } from \"../types.js\";\nimport { createRscStream } from \"./createRscStream.js\";\n\ntype CreateHandlerResult = \n | { type: \"success\"; controller: AbortController; stream: PipeableStream; assets: any; clientPath: string }\n | { type: \"error\"; error: Error }\n | { type: \"skip\" };\n\ninterface HandlerAssets {\n css: Set<string>;\n clientPath: string;\n}\n\nexport async function createHandler<T>(\n url: string,\n pluginOptions: ResolvedUserOptions,\n streamOptions: CreateHandlerOptions<T>\n): Promise<CreateHandlerResult> {\n const root = pluginOptions.projectRoot ?? process.cwd();\n\n const Html = pluginOptions.Html ?? DEFAULT_CONFIG.HTML;\n const pageExportName =\n pluginOptions.pageExportName ?? DEFAULT_CONFIG.PAGE_EXPORT_NAME;\n const propsExportName =\n pluginOptions.propsExportName ?? DEFAULT_CONFIG.PROPS_EXPORT_NAME;\n const controller = new AbortController();\n\n const cssFiles = streamOptions.cssFiles;\n const propsPath =\n typeof pluginOptions.props === \"function\"\n ? pluginOptions.props(url)\n : pluginOptions.props;\n const pagePath =\n typeof pluginOptions.Page === \"function\"\n ? pluginOptions.Page(url)\n : pluginOptions.Page;\n\n const cssModules = new Set<string>();\n\n if (!(streamOptions.serverManifest || streamOptions.moduleGraph))\n throw new Error(\"Missing server manifest or moduleGraph, pass it to options.\");\n\n const getCss = streamOptions.serverManifest\n ? (id: string) =>\n collectManifestCss(\n streamOptions.serverManifest!,\n root,\n id,\n streamOptions.onCssFile\n )\n : (id: string) => collectModuleGraphCss(streamOptions.moduleGraph!, id);\n\n const loadWithCss = async (id: string, parentUrl: string) => {\n try {\n const mod = await streamOptions.loader(id);\n const pageCss = await Promise.resolve(getCss(id));\n Array.from(pageCss.keys()).forEach((css) => {\n cssModules.add(css);\n // Notify about new CSS file if callback exists\n if (streamOptions.onCssFile) {\n streamOptions.onCssFile(css, parentUrl);\n }\n });\n return mod as Record<string, any>;\n } catch (e: any) {\n if (e.message?.includes(\"module runner has been closed\")) {\n return { type: \"skip\" } as Record<string, any>;\n } else {\n return { type: \"error\", error: e } as Record<string, any>;\n }\n }\n };\n\n const PropsModule = await resolveProps({\n propsModule: await loadWithCss(propsPath ?? pagePath, url),\n path: String(propsPath ?? pagePath),\n exportName: propsExportName,\n url,\n });\n if (PropsModule.type === \"error\")\n return { type: PropsModule.type, error: PropsModule?.error };\n if (PropsModule.type === \"skip\") return { type: PropsModule.type };\n const props = PropsModule[propsExportName as keyof typeof PropsModule] as any;\n if (props?.type === \"error\") return { type: props.type, error: props.error };\n if (props?.type === \"skip\") return { type: props.type };\n\n const PageModule = await resolvePage({\n pageModule: await loadWithCss(pagePath, url),\n path: pagePath,\n exportName: pageExportName,\n url,\n });\n if (PageModule.type === \"error\")\n return { type: PageModule.type, error: PageModule.error };\n if (PageModule.type === \"skip\") return { type: PageModule.type };\n const Page = PageModule[pageExportName as keyof typeof PageModule] as any;\n if (Page?.type === \"error\") return { type: Page.type, error: Page.error };\n if (Page?.type === \"skip\") return { type: Page.type };\n if (!(typeof Page === \"function\")) {\n return {\n type: \"error\",\n error: new Error(\"Invalid Page component: \" + pagePath, {\n cause: Page,\n }),\n };\n }\n if (!(typeof props === \"object\")) {\n return {\n type: \"error\",\n error: new Error(\"Invalid props: \" + propsPath, {\n cause: props,\n }),\n } \n }\n\n // Add any additional CSS files\n if (streamOptions.cssFiles) {\n streamOptions.cssFiles.forEach((css) => cssModules.add(css));\n }\n const stream = createRscStream({\n Html: Html,\n Page: Page,\n props: props,\n moduleBasePath: '',\n logger: streamOptions.logger ?? createLogger(),\n cssFiles: Array.from(cssModules),\n route: url,\n url,\n pipableStreamOptions: streamOptions.pipableStreamOptions,\n htmlProps: {\n pageProps: props,\n route: url,\n url: url,\n },\n });\n\n if (!stream) {\n return { type: \"skip\" as const };\n }\n\n const assets: HandlerAssets = {\n css: new Set(cssFiles ?? []),\n clientPath: pagePath ?? ''\n };\n\n return {\n type: \"success\",\n controller,\n stream,\n assets,\n clientPath: assets.clientPath,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAsBsB,eAAA,aAAA,CACpB,GACA,EAAA,aAAA,EACA,aAC8B,EAAA;AAC9B,EAAA,MAAM,IAAO,GAAA,aAAA,CAAc,WAAe,IAAA,OAAA,CAAQ,GAAI,EAAA;AAEtD,EAAM,MAAA,IAAA,GAAO,aAAc,CAAA,IAAA,IAAQ,cAAe,CAAA,IAAA;AAClD,EAAM,MAAA,cAAA,GACJ,aAAc,CAAA,cAAA,IAAkB,cAAe,CAAA,gBAAA;AACjD,EAAM,MAAA,eAAA,GACJ,aAAc,CAAA,eAAA,IAAmB,cAAe,CAAA,iBAAA;AAClD,EAAM,MAAA,UAAA,GAAa,IAAI,eAAgB,EAAA;AAEvC,EAAA,MAAM,WAAW,aAAc,CAAA,QAAA;AAC/B,EAAM,MAAA,SAAA,GACJ,OAAO,aAAc,CAAA,KAAA,KAAU,aAC3B,aAAc,CAAA,KAAA,CAAM,GAAG,CAAA,GACvB,aAAc,CAAA,KAAA;AACpB,EAAM,MAAA,QAAA,GACJ,OAAO,aAAc,CAAA,IAAA,KAAS,aAC1B,aAAc,CAAA,IAAA,CAAK,GAAG,CAAA,GACtB,aAAc,CAAA,IAAA;AAEpB,EAAM,MAAA,UAAA,uBAAiB,GAAY,EAAA;AAEnC,EAAI,IAAA,EAAE,aAAc,CAAA,cAAA,IAAkB,aAAc,CAAA,WAAA,CAAA;AAClD,IAAM,MAAA,IAAI,MAAM,6DAA6D,C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B;AAEA,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,SAAA;AAAA,IACN,UAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,YAAY,MAAO,CAAA;AAAA,GACrB;AACF;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createRscStream.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createRscStream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AA2BnC,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,cAAc,EACd,MAAM,EACN,QAAa,EACb,KAAK,EACL,GAAG,EACH,oBAAoB,EACpB,SAAS,GACV,EAAE;IACD,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC/B,KAAK,EAAE,GAAG,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,CAAC,EAAE,qBAAqB,CAAC;IAC7C,SAAS,CAAC,EAAE,GAAG,CAAC;CACjB,OAgCA"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* vite-plugin-react-server
|
|
3
|
-
* Copyright (c) Nico Brinkkemper
|
|
4
|
-
* MIT License
|
|
5
|
-
*/
|
|
6
|
-
import * as React from 'react';
|
|
7
|
-
import { renderToPipeableStream } from 'react-server-dom-esm/server.node';
|
|
8
|
-
|
|
9
|
-
function CssCollector({
|
|
10
|
-
children,
|
|
11
|
-
cssFiles
|
|
12
|
-
}) {
|
|
13
|
-
return React.createElement(
|
|
14
|
-
React.Fragment,
|
|
15
|
-
null,
|
|
16
|
-
...cssFiles.map((css) => {
|
|
17
|
-
const url = css.startsWith("/") || css.startsWith("http") || css.startsWith("./") ? css : "/" + css;
|
|
18
|
-
return React.createElement("link", {
|
|
19
|
-
key: css,
|
|
20
|
-
rel: "stylesheet",
|
|
21
|
-
href: url,
|
|
22
|
-
precedence: "high"
|
|
23
|
-
});
|
|
24
|
-
}),
|
|
25
|
-
children
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
function createRscStream({
|
|
29
|
-
Html,
|
|
30
|
-
Page,
|
|
31
|
-
props,
|
|
32
|
-
moduleBasePath,
|
|
33
|
-
logger,
|
|
34
|
-
cssFiles = [],
|
|
35
|
-
route,
|
|
36
|
-
url,
|
|
37
|
-
pipableStreamOptions,
|
|
38
|
-
htmlProps
|
|
39
|
-
}) {
|
|
40
|
-
const htmlIsFragment = Html == React.Fragment;
|
|
41
|
-
const withCss = React.createElement(
|
|
42
|
-
CssCollector,
|
|
43
|
-
{ cssFiles },
|
|
44
|
-
React.createElement(Page, props)
|
|
45
|
-
);
|
|
46
|
-
const content = htmlIsFragment ? withCss : React.createElement(Html, htmlProps, withCss);
|
|
47
|
-
try {
|
|
48
|
-
return renderToPipeableStream(
|
|
49
|
-
content,
|
|
50
|
-
moduleBasePath,
|
|
51
|
-
{
|
|
52
|
-
onError: (error) => {
|
|
53
|
-
if (process.env["NODE_ENV"] === "development") {
|
|
54
|
-
console.trace(error);
|
|
55
|
-
}
|
|
56
|
-
logger.error(`Stream error at ${route}.`, { error });
|
|
57
|
-
},
|
|
58
|
-
onPostpone: logger.info ?? console.info,
|
|
59
|
-
environmentName: "Server",
|
|
60
|
-
...pipableStreamOptions
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
logger.error(`Failed to create stream for ${route}.`, { error });
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { createRscStream };
|
|
70
|
-
//# sourceMappingURL=createRscStream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createRscStream.js","sources":["../../../plugin/react-server/createRscStream.ts"],"sourcesContent":["import * as React from \"react\";\n// @ts-ignore\nimport { renderToPipeableStream } from \"react-server-dom-esm/server.node\";\nimport type { PipeableStreamOptions } from \"../worker/types.js\";\nimport type { Logger } from \"vite\";\n\n\n// CSS collector component\nfunction CssCollector({\n children,\n cssFiles,\n}: {\n children?: React.ReactNode;\n cssFiles: string[];\n}) {\n return React.createElement(\n React.Fragment,\n null,\n ...cssFiles.map((css) => {\n const url = css.startsWith('/') || css.startsWith('http') || css.startsWith('./') ? css : '/'+css\n return React.createElement('link', {\n key: css,\n rel: 'stylesheet',\n href: url,\n precedence: 'high'\n })\n }),\n children\n );\n}\n\nexport function createRscStream({\n Html,\n Page,\n props,\n moduleBasePath,\n logger,\n cssFiles = [],\n route,\n url,\n pipableStreamOptions,\n htmlProps,\n}: {\n Html: React.ComponentType<any>;\n Page: React.ComponentType<any>;\n props: any;\n moduleBasePath: string;\n logger: Logger;\n cssFiles?: string[];\n route: string;\n url: string;\n pipableStreamOptions?: PipeableStreamOptions;\n htmlProps?: any;\n}) {\n \n const htmlIsFragment = Html == React.Fragment;\n const withCss = React.createElement(\n CssCollector,\n { cssFiles },\n React.createElement(Page, props)\n )\n // Otherwise wrap with Html component\n const content = htmlIsFragment \n ? withCss\n : React.createElement(Html, htmlProps, withCss);\n try {\n return renderToPipeableStream(\n content,\n moduleBasePath,\n {\n onError: (error: Error) => {\n if(process.env['NODE_ENV'] === 'development') {\n console.trace(error);\n }\n logger.error(`Stream error at ${route}.`, {error});\n },\n onPostpone: logger.info ?? console.info, \n environmentName: \"Server\",\n ...pipableStreamOptions,\n }\n );\n } catch (error) {\n logger.error(`Failed to create stream for ${route}.`, {error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AAAA,MACA,cAAA;AAAA,MACA;AAAA,QACE,OAAA,EAAS,CAAC,KAAiB,KAAA;AACzB,UAAA,IAAG,OAAQ,CAAA,GAAA,CAAI,UAAU,CAAA,KAAM,aAAe,EAAA;AAC5C,YAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AAAA;AAErB,UAAA,MAAA,CAAO,MAAM,CAAmB,gBAAA,EAAA,KAAK,CAAK,CAAA,CAAA,EAAA,EAAC,OAAM,CAAA;AAAA,SACnD;AAAA,QACA,UAAA,EAAY,MAAO,CAAA,IAAA,IAAQ,OAAQ,CAAA,IAAA;AAAA,QACnC,eAAiB,EAAA,QAAA;AAAA,QACjB,GAAG;AAAA;AACL,KACF;AAAA,WACO,KAAO,EAAA;AACd,IAAA,MAAA,CAAO,MAAM,CAA+B,4BAAA,EAAA,KAAK,CAAK,CAAA,CAAA,EAAA,EAAC,OAAsB,CAAA;AAC7E,IAAO,OAAA,IAAA;AAAA;AAEX;;;;"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type ViteDevServer } from "vite";
|
|
2
|
-
import type { RequestHandler, ResolvedUserOptions } from "../types.js";
|
|
3
|
-
export declare function createSsrHandler(options: ResolvedUserOptions, server: ViteDevServer): RequestHandler;
|
|
4
|
-
//# sourceMappingURL=createSsrHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createSsrHandler.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createSsrHandler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKvE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,aAAa,GACpB,cAAc,CA+GhB"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { join, resolve } from "node:path";
|
|
2
|
-
import { Writable } from "node:stream";
|
|
3
|
-
import { Worker } from "node:worker_threads";
|
|
4
|
-
import {} from "vite";
|
|
5
|
-
import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
6
|
-
import { createHandler } from "./createHandler.js";
|
|
7
|
-
export function createSsrHandler(options, server) {
|
|
8
|
-
const worker = new Worker(options?.htmlWorkerPath
|
|
9
|
-
? resolve(server.config.root, options?.htmlWorkerPath)
|
|
10
|
-
: DEFAULT_CONFIG.HTML_WORKER_PATH, {
|
|
11
|
-
env: {
|
|
12
|
-
NODE_OPTIONS: "--conditions ''",
|
|
13
|
-
VITE_LOADER_PATH: resolve(server.config.cacheDir, "react-stream/worker/loader.js"),
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
return async function handleSsrRequest(req, res, next) {
|
|
17
|
-
if (!req.url ||
|
|
18
|
-
req.url.startsWith("/@") ||
|
|
19
|
-
(req.url.includes(".") && !req.url.endsWith(".html"))) {
|
|
20
|
-
return next();
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const result = await createHandler(req.url ?? "", {
|
|
24
|
-
...options,
|
|
25
|
-
projectRoot: server.config.root,
|
|
26
|
-
}, {
|
|
27
|
-
loader: server.ssrLoadModule.bind(server),
|
|
28
|
-
moduleGraph: server.moduleGraph,
|
|
29
|
-
});
|
|
30
|
-
const moduleRootPath = join(server.config.cacheDir, options.moduleBasePath);
|
|
31
|
-
// const htmlOutputPath = join(
|
|
32
|
-
// server.config.cacheDir,
|
|
33
|
-
// server.config.build.outDir,
|
|
34
|
-
// req.url,
|
|
35
|
-
// "index.html"
|
|
36
|
-
// );
|
|
37
|
-
if (result.type !== "success") {
|
|
38
|
-
throw new Error(result.type === "error" ? String(result.error) : "Skipped");
|
|
39
|
-
}
|
|
40
|
-
// Collect RSC stream data
|
|
41
|
-
const rscData = await new Promise((resolve, reject) => {
|
|
42
|
-
let data = "";
|
|
43
|
-
if (!result.stream) {
|
|
44
|
-
resolve(data);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const writable = new Writable({
|
|
48
|
-
write(chunk, _, callback) {
|
|
49
|
-
data += chunk;
|
|
50
|
-
callback();
|
|
51
|
-
},
|
|
52
|
-
final(callback) {
|
|
53
|
-
resolve(data);
|
|
54
|
-
callback();
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
result.stream.pipe(writable);
|
|
58
|
-
writable.on("error", reject);
|
|
59
|
-
});
|
|
60
|
-
// Get HTML from worker
|
|
61
|
-
const html = await new Promise((resolve, reject) => {
|
|
62
|
-
worker.postMessage({
|
|
63
|
-
type: "RSC_CHUNK",
|
|
64
|
-
id: req.url ?? "/",
|
|
65
|
-
chunk: rscData,
|
|
66
|
-
moduleRootPath: moduleRootPath,
|
|
67
|
-
moduleBaseURL: options.moduleBaseURL,
|
|
68
|
-
// Don't need file paths in dev mode
|
|
69
|
-
outDir: "",
|
|
70
|
-
htmlOutputPath: "",
|
|
71
|
-
pipableStreamOptions: options.pipableStreamOptions ?? {},
|
|
72
|
-
clientManifest: {},
|
|
73
|
-
serverManifest: {},
|
|
74
|
-
});
|
|
75
|
-
worker.once("message", (msg) => {
|
|
76
|
-
if (msg.type === "ERROR") {
|
|
77
|
-
const message = msg.error instanceof Error
|
|
78
|
-
? msg.error.message
|
|
79
|
-
: String(msg.error);
|
|
80
|
-
reject(new Error(message, { cause: msg }));
|
|
81
|
-
}
|
|
82
|
-
else if (msg.type === "HTML") {
|
|
83
|
-
// In dev, content will be the HTML string
|
|
84
|
-
resolve(msg.content);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
res.setHeader("Content-Type", "text/html");
|
|
89
|
-
res.end(html);
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
next(error);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type LogLevel } from 'vite';
|
|
2
|
-
export declare const createLogger: (prefix: string, logLevel?: LogLevel) => {
|
|
3
|
-
clear: () => void;
|
|
4
|
-
info: (msg: string, ...args: any[]) => void;
|
|
5
|
-
warn: (msg: string, ...args: any[]) => void;
|
|
6
|
-
error: (msg: string, ...args: any[]) => void;
|
|
7
|
-
debug: (msg: string, ...args: any[]) => void;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../plugin/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAwBvE,eAAO,MAAM,YAAY,WAA0D,MAAM,aAAY,QAAQ;;gBAM7F,MAAM,WAAW,GAAG,EAAE;gBAGtB,MAAM,WAAW,GAAG,EAAE;iBAGrB,MAAM,WAAW,GAAG,EAAE;iBAGtB,MAAM,WAAW,GAAG,EAAE;CAYtC,CAAC"}
|