vite-plugin-react-server 0.3.4 → 0.3.6
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 +113 -222
- package/bin/patch.mjs +84 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +7 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -3
- package/dist/index.js.map +1 -1
- package/dist/node_modules/magic-string/dist/magic-string.es.js +1283 -0
- package/dist/node_modules/magic-string/dist/magic-string.es.js.map +1 -0
- package/dist/package.json +130 -0
- package/dist/plugin/assertServerCondition.d.ts.map +1 -0
- package/dist/plugin/assertServerCondition.js +15 -0
- package/dist/plugin/build/createClientBuildConfig.d.ts +3 -0
- package/dist/plugin/build/createClientBuildConfig.d.ts.map +1 -0
- package/dist/plugin/build/createClientBuildConfig.js +14 -0
- package/dist/plugin/build/createServerBuildConfig.d.ts +12 -0
- package/dist/plugin/build/createServerBuildConfig.d.ts.map +1 -0
- package/dist/plugin/build/createServerBuildConfig.js +40 -0
- package/dist/plugin/build/createSharedBuildConfig.d.ts +5 -0
- package/dist/plugin/build/createSharedBuildConfig.d.ts.map +1 -0
- package/dist/plugin/build/createSharedBuildConfig.js +28 -0
- package/dist/plugin/build/mergeInputs.d.ts +9 -0
- package/dist/plugin/build/mergeInputs.d.ts.map +1 -0
- package/dist/plugin/build/mergeInputs.js +56 -0
- package/dist/plugin/checkFilesExist.d.ts +3 -0
- package/dist/plugin/checkFilesExist.d.ts.map +1 -0
- package/dist/plugin/checkFilesExist.js +78 -0
- package/dist/plugin/checkFilesExist.js.map +1 -0
- package/dist/{collect-css-manifest.d.ts → plugin/collect-css-manifest.d.ts} +2 -2
- package/dist/plugin/collect-css-manifest.d.ts.map +1 -0
- package/dist/{src → plugin}/collect-css-manifest.js +8 -5
- package/dist/plugin/collect-css-manifest.js.map +1 -0
- package/dist/plugin/components.d.ts.map +1 -0
- package/dist/{src → plugin}/components.js +9 -4
- package/dist/plugin/components.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +51 -0
- package/dist/plugin/config/defaults.d.ts.map +1 -0
- package/dist/plugin/config/defaults.js +52 -0
- package/dist/plugin/config/defaults.js.map +1 -0
- package/dist/plugin/config/getCondition.d.ts +2 -0
- package/dist/plugin/config/getCondition.d.ts.map +1 -0
- package/dist/plugin/config/getCondition.js +11 -0
- package/dist/plugin/config/getCondition.js.map +1 -0
- package/dist/plugin/config/getPaths.d.ts +5 -0
- package/dist/plugin/config/getPaths.d.ts.map +1 -0
- package/dist/plugin/config/getPaths.js +21 -0
- package/dist/plugin/config/getPaths.js.map +1 -0
- package/dist/plugin/config/getWorkerPath.d.ts +2 -0
- package/dist/plugin/config/getWorkerPath.d.ts.map +1 -0
- package/dist/plugin/config/getWorkerPath.js +4 -0
- package/dist/plugin/config/index.d.ts +8 -0
- package/dist/plugin/config/index.d.ts.map +1 -0
- package/dist/plugin/config/index.js +7 -0
- package/dist/plugin/config/moduleIdDefault.d.ts +8 -0
- package/dist/plugin/config/moduleIdDefault.d.ts.map +1 -0
- package/dist/plugin/config/moduleIdDefault.js +23 -0
- package/dist/plugin/config/moduleIdDefault.js.map +1 -0
- package/dist/plugin/config/resolveOptions.d.ts +9 -0
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -0
- package/dist/plugin/config/resolveOptions.js +56 -0
- package/dist/plugin/config/resolveOptions.js.map +1 -0
- package/dist/plugin/config/resolvePages.d.ts +9 -0
- package/dist/plugin/config/resolvePages.d.ts.map +1 -0
- package/dist/plugin/config/resolvePages.js +38 -0
- package/dist/plugin/config/resolvePages.js.map +1 -0
- package/dist/plugin/config/resolveUserConfig.d.ts +18 -0
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -0
- package/dist/plugin/config/resolveUserConfig.js +84 -0
- package/dist/plugin/config/resolveUserConfig.js.map +1 -0
- package/dist/plugin/copy-dir.d.ts.map +1 -0
- package/dist/plugin/copy-dir.js +20 -0
- package/dist/plugin/getCondition.d.ts +2 -0
- package/dist/plugin/getCondition.d.ts.map +1 -0
- package/dist/plugin/getCondition.js +1 -0
- package/dist/plugin/getEnv.d.ts.map +1 -0
- package/dist/plugin/getEnv.js +107 -0
- package/dist/plugin/helpers/createClientInputNormalizer.d.ts +8 -0
- package/dist/plugin/helpers/createClientInputNormalizer.d.ts.map +1 -0
- package/dist/plugin/helpers/createClientInputNormalizer.js +35 -0
- package/dist/plugin/helpers/createServerInputNormalizer.d.ts +9 -0
- package/dist/plugin/helpers/createServerInputNormalizer.d.ts.map +1 -0
- package/dist/plugin/helpers/createServerInputNormalizer.js +37 -0
- package/dist/plugin/helpers/createStaticInputNormalizer.d.ts +7 -0
- package/dist/plugin/helpers/createStaticInputNormalizer.d.ts.map +1 -0
- package/dist/plugin/helpers/createStaticInputNormalizer.js +18 -0
- package/dist/plugin/helpers/getModuleManifest.d.ts +12 -0
- package/dist/plugin/helpers/getModuleManifest.d.ts.map +1 -0
- package/dist/plugin/helpers/getModuleManifest.js +24 -0
- package/dist/plugin/helpers/getModuleManifest.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts +3 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.js +35 -0
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizerWorker.d.ts +11 -0
- package/dist/plugin/helpers/inputNormalizerWorker.d.ts.map +1 -0
- package/dist/plugin/helpers/inputNormalizerWorker.js +30 -0
- package/dist/plugin/helpers/normalizedRelativePath.d.ts.map +1 -0
- package/dist/plugin/helpers/normalizedRelativePath.js +36 -0
- package/dist/plugin/helpers/resolveFilePath.d.ts +13 -0
- package/dist/plugin/helpers/resolveFilePath.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveFilePath.js +74 -0
- package/dist/plugin/helpers/resolveWorkerModule.d.ts +6 -0
- package/dist/plugin/helpers/resolveWorkerModule.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveWorkerModule.js +24 -0
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -0
- package/dist/{src → plugin}/helpers/tryManifest.js +11 -6
- package/dist/plugin/helpers/tryManifest.js.map +1 -0
- package/dist/plugin/helpers/validateModuleBase.d.ts +3 -0
- package/dist/plugin/helpers/validateModuleBase.d.ts.map +1 -0
- package/dist/plugin/helpers/validateModuleBase.js +16 -0
- package/dist/plugin/helpers/validateResolvedConfig.d.ts +3 -0
- package/dist/plugin/helpers/validateResolvedConfig.d.ts.map +1 -0
- package/dist/plugin/helpers/validateResolvedConfig.js +17 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +1 -0
- package/dist/plugin/loader/createBuildLoader.d.ts +9 -0
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -0
- package/dist/plugin/loader/createBuildLoader.js +38 -0
- package/dist/plugin/loader/createBuildLoader.js.map +1 -0
- package/dist/plugin/loader/createCssLoader.d.ts +30 -0
- package/dist/plugin/loader/createCssLoader.d.ts.map +1 -0
- package/dist/plugin/loader/createCssLoader.js +35 -0
- package/dist/{html → plugin/loader}/createPageLoader.d.ts +2 -4
- package/dist/plugin/loader/createPageLoader.d.ts.map +1 -0
- package/dist/plugin/loader/createPageLoader.js +57 -0
- package/dist/plugin/manifest.d.ts.map +1 -0
- package/dist/plugin/manifest.js +13 -0
- package/dist/plugin/module-graph.d.ts.map +1 -0
- package/dist/plugin/module-graph.js +35 -0
- package/dist/plugin/plugin.d.ts +7 -0
- package/dist/plugin/plugin.d.ts.map +1 -0
- package/dist/plugin/plugin.js +8 -0
- package/dist/plugin/preserver/index.d.ts +2 -0
- package/dist/plugin/preserver/index.d.ts.map +1 -0
- package/dist/plugin/preserver/index.js +1 -0
- package/dist/plugin/preserver/plugin.d.ts +3 -0
- package/dist/plugin/preserver/plugin.d.ts.map +1 -0
- package/dist/plugin/preserver/plugin.js +90 -0
- package/dist/plugin/preserver/plugin.js.map +1 -0
- package/dist/plugin/react-client/index.d.ts +2 -0
- package/dist/plugin/react-client/index.d.ts.map +1 -0
- package/dist/plugin/react-client/index.js +1 -0
- package/dist/plugin/react-client/plugin.d.ts +4 -0
- package/dist/plugin/react-client/plugin.d.ts.map +1 -0
- package/dist/plugin/react-client/plugin.js +34 -0
- package/dist/plugin/react-client/plugin.js.map +1 -0
- package/dist/plugin/react-server/createDevMiddleware.d.ts.map +1 -0
- package/dist/plugin/react-server/createDevMiddleware.js +68 -0
- package/dist/plugin/react-server/createDevServer.d.ts.map +1 -0
- package/dist/plugin/react-server/createDevServer.js +4 -0
- package/dist/plugin/react-server/createHandler.d.ts +17 -0
- package/dist/plugin/react-server/createHandler.d.ts.map +1 -0
- package/dist/{src → plugin}/react-server/createHandler.js +28 -17
- package/dist/plugin/react-server/createHandler.js.map +1 -0
- package/dist/plugin/react-server/createReactNodeStreamer.d.ts.map +1 -0
- package/dist/plugin/react-server/createReactNodeStreamer.js +7 -0
- package/dist/{react-server → plugin/react-server}/createRscStream.d.ts +1 -1
- package/dist/plugin/react-server/createRscStream.d.ts.map +1 -0
- package/dist/{src → plugin}/react-server/createRscStream.js +14 -13
- package/dist/plugin/react-server/createRscStream.js.map +1 -0
- package/dist/{react-server → plugin/react-server}/createSsrHandler.d.ts +1 -1
- package/dist/plugin/react-server/createSsrHandler.d.ts.map +1 -0
- package/dist/plugin/react-server/createSsrHandler.js +102 -0
- package/dist/plugin/react-server/index.d.ts +3 -0
- package/dist/plugin/react-server/index.d.ts.map +1 -0
- package/dist/plugin/react-server/index.js +10 -0
- package/dist/plugin/react-server/plugin.d.ts +7 -0
- package/dist/plugin/react-server/plugin.d.ts.map +1 -0
- package/dist/plugin/react-server/plugin.js +377 -0
- package/dist/plugin/react-server/plugin.js.map +1 -0
- package/dist/plugin/resolvePage.d.ts.map +1 -0
- package/dist/{src → plugin}/resolvePage.js +8 -4
- package/dist/plugin/resolvePage.js.map +1 -0
- package/dist/plugin/resolveProps.d.ts.map +1 -0
- package/dist/{src → plugin}/resolveProps.js +21 -8
- package/dist/plugin/resolveProps.js.map +1 -0
- package/dist/plugin/server.d.ts +2 -0
- package/dist/plugin/server.d.ts.map +1 -0
- package/dist/plugin/server.js +1 -0
- package/dist/plugin/transformer/index.d.ts +2 -0
- package/dist/plugin/transformer/index.d.ts.map +1 -0
- package/dist/plugin/transformer/index.js +1 -0
- package/dist/{transformer/index.d.ts → plugin/transformer/plugin.d.ts} +3 -4
- package/dist/plugin/transformer/plugin.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.js +94 -0
- package/dist/plugin/transformer/plugin.js.map +1 -0
- package/dist/plugin/transformer/transformer-client-components.d.ts +21 -0
- package/dist/plugin/transformer/transformer-client-components.d.ts.map +1 -0
- package/dist/plugin/transformer/transformer-client-components.js +61 -0
- package/dist/plugin/transformer/transformer-client-components.js.map +1 -0
- package/dist/{transformer/transformer.d.ts → plugin/transformer/transformer-server-actions.d.ts} +3 -4
- package/dist/plugin/transformer/transformer-server-actions.d.ts.map +1 -0
- package/dist/plugin/transformer/transformer-server-actions.js +76 -0
- package/dist/plugin/transformer/transformer-server-actions.js.map +1 -0
- package/dist/plugin/transformer/types.d.ts.map +1 -0
- package/dist/plugin/transformer/types.js +1 -0
- package/dist/plugin/types.d.ts +225 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin/types.js +1 -0
- package/dist/plugin/worker/createWorker.d.ts +15 -0
- package/dist/plugin/worker/createWorker.d.ts.map +1 -0
- package/dist/plugin/worker/createWorker.js +71 -0
- package/dist/plugin/worker/createWorker.js.map +1 -0
- package/dist/plugin/worker/html/html-worker.d.ts +2 -0
- package/dist/plugin/worker/html/html-worker.d.ts.map +1 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts +2 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -0
- package/dist/plugin/worker/html/html-worker.development.js +12 -0
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -0
- package/dist/plugin/worker/html/html-worker.js +4 -0
- package/dist/plugin/worker/html/html-worker.production.d.ts +2 -0
- package/dist/plugin/worker/html/html-worker.production.d.ts.map +1 -0
- package/dist/plugin/worker/html/html-worker.production.js +12 -0
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -0
- package/dist/plugin/worker/html/index.d.ts +2 -0
- package/dist/plugin/worker/html/index.d.ts.map +1 -0
- package/dist/plugin/worker/html/index.js +7 -0
- package/dist/plugin/worker/html/index.js.map +1 -0
- package/dist/plugin/worker/html/messageHandler.d.ts +3 -0
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -0
- package/dist/plugin/worker/html/messageHandler.js +98 -0
- package/dist/plugin/worker/html/messageHandler.js.map +1 -0
- package/dist/plugin/worker/html/plugin.d.ts +4 -0
- package/dist/plugin/worker/html/plugin.d.ts.map +1 -0
- package/dist/plugin/worker/html/plugin.js +89 -0
- package/dist/plugin/worker/html/renderPages.d.ts +38 -0
- package/dist/plugin/worker/html/renderPages.d.ts.map +1 -0
- package/dist/plugin/worker/html/renderPages.js +123 -0
- package/dist/plugin/worker/html/renderPages.js.map +1 -0
- package/dist/plugin/worker/loader.d.ts.map +1 -0
- package/dist/plugin/worker/loader.js +11 -0
- package/dist/plugin/worker/loader.js.map +1 -0
- package/dist/plugin/worker/plugin.d.ts +10 -0
- package/dist/plugin/worker/plugin.d.ts.map +1 -0
- package/dist/plugin/worker/plugin.js +14 -0
- package/dist/plugin/worker/rsc/createRscStream.d.ts +5 -0
- package/dist/plugin/worker/rsc/createRscStream.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/createRscStream.js +39 -0
- package/dist/plugin/worker/rsc/createRscStream.js.map +1 -0
- package/dist/plugin/worker/rsc/development.d.ts +5 -0
- package/dist/plugin/worker/rsc/development.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/development.js +13 -0
- package/dist/plugin/worker/rsc/development.js.map +1 -0
- package/dist/plugin/worker/rsc/index.d.ts +4 -0
- package/dist/plugin/worker/rsc/index.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/index.js +15 -0
- package/dist/plugin/worker/rsc/index.js.map +1 -0
- package/dist/plugin/worker/rsc/plugin.d.ts +4 -0
- package/dist/plugin/worker/rsc/plugin.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/plugin.js +82 -0
- package/dist/plugin/worker/rsc/plugin.js.map +1 -0
- package/dist/plugin/worker/rsc/production.d.ts +5 -0
- package/dist/plugin/worker/rsc/production.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/production.js +13 -0
- package/dist/plugin/worker/rsc/production.js.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.d.ts +2 -0
- package/dist/plugin/worker/rsc/rsc-worker.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/rsc-worker.js +106 -0
- package/dist/plugin/worker/types.d.ts +99 -0
- package/dist/plugin/worker/types.d.ts.map +1 -0
- package/dist/plugin/worker/types.js +1 -0
- package/dist/server.d.ts +4 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +9 -0
- package/dist/server.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +1 -201
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/package.json +42 -25
- package/plugin/build/createClientBuildConfig.ts +21 -0
- package/plugin/build/createServerBuildConfig.ts +66 -0
- package/plugin/build/createSharedBuildConfig.ts +35 -0
- package/plugin/build/mergeInputs.ts +58 -0
- package/plugin/checkFilesExist.ts +82 -0
- package/{src → plugin}/collect-css-manifest.ts +4 -2
- package/plugin/config/defaults.ts +44 -0
- package/plugin/config/getCondition.ts +3 -0
- package/plugin/config/getPaths.ts +25 -0
- package/plugin/config/getWorkerPath.ts +5 -0
- package/plugin/config/index.ts +8 -0
- package/plugin/config/moduleIdDefault.ts +23 -0
- package/plugin/config/resolveOptions.ts +53 -0
- package/plugin/config/resolvePages.ts +43 -0
- package/plugin/config/resolveUserConfig.ts +97 -0
- package/{src → plugin}/getEnv.ts +1 -1
- package/plugin/helpers/createClientInputNormalizer.ts +48 -0
- package/plugin/helpers/createServerInputNormalizer.ts +52 -0
- package/plugin/helpers/createStaticInputNormalizer.ts +26 -0
- package/plugin/helpers/getModuleManifest.ts +31 -0
- package/plugin/helpers/inputNormalizer.ts +39 -0
- package/plugin/helpers/inputNormalizerWorker.ts +47 -0
- package/plugin/helpers/resolveFilePath.ts +108 -0
- package/plugin/helpers/resolveWorkerModule.ts +41 -0
- package/plugin/helpers/validateModuleBase.ts +30 -0
- package/plugin/helpers/validateResolvedConfig.ts +21 -0
- package/plugin/index.ts +2 -0
- package/plugin/loader/createBuildLoader.ts +44 -0
- package/plugin/loader/createCssLoader.ts +73 -0
- package/{src/html → plugin/loader}/createPageLoader.ts +35 -27
- package/plugin/plugin.ts +8 -0
- package/plugin/preserver/index.ts +1 -0
- package/plugin/preserver/plugin.ts +109 -0
- package/plugin/react-client/index.ts +1 -0
- package/plugin/react-client/plugin.ts +33 -0
- package/{src → plugin}/react-server/createDevMiddleware.ts +17 -1
- package/{src → plugin}/react-server/createDevServer.ts +0 -1
- package/{src → plugin}/react-server/createHandler.ts +31 -10
- package/{src → plugin}/react-server/createReactNodeStreamer.ts +1 -0
- package/{src → plugin}/react-server/createRscStream.ts +8 -12
- package/{src → plugin}/react-server/createSsrHandler.ts +16 -19
- package/plugin/react-server/index.ts +12 -0
- package/plugin/react-server/plugin.ts +464 -0
- package/{src → plugin}/resolvePage.ts +1 -1
- package/{src → plugin}/resolveProps.ts +15 -6
- package/plugin/server.tsx +0 -0
- package/plugin/transformer/index.ts +1 -0
- package/plugin/transformer/plugin.ts +141 -0
- package/plugin/transformer/transformer-client-components.ts +94 -0
- package/{src/transformer/transformer.ts → plugin/transformer/transformer-server-actions.ts} +14 -27
- package/{src → plugin}/types.ts +97 -55
- package/plugin/worker/createWorker.ts +84 -0
- package/plugin/worker/html/html-worker.development.tsx +8 -0
- package/plugin/worker/html/html-worker.production.tsx +8 -0
- package/plugin/worker/html/html-worker.ts +5 -0
- package/plugin/worker/html/index.ts +5 -0
- package/plugin/worker/html/messageHandler.ts +116 -0
- package/plugin/worker/html/plugin.ts +97 -0
- package/plugin/worker/html/renderPages.ts +188 -0
- package/plugin/worker/plugin.ts +17 -0
- package/plugin/worker/rsc/createRscStream.ts +42 -0
- package/plugin/worker/rsc/development.ts +6 -0
- package/plugin/worker/rsc/index.ts +14 -0
- package/plugin/worker/rsc/plugin.ts +83 -0
- package/plugin/worker/rsc/production.ts +6 -0
- package/plugin/worker/rsc/rsc-worker.tsx +128 -0
- package/plugin/worker/types.ts +124 -0
- package/scripts/check-react-version.mjs +48 -30
- package/scripts/react+0.0.0-experimental-b3a95caf-20250113.patch +4291 -0
- package/scripts/react-dom+0.0.0-experimental-b3a95caf-20250113.patch +108798 -0
- package/scripts/react-server-dom-esm+0.0.0-experimental-b3a95caf-20250113.patch +24775 -0
- package/{patches → scripts}/react-server-dom-esm+0.0.1.patch +11354 -3
- package/tsconfig.json +15 -13
- package/dist/assertServerCondition.d.ts.map +0 -1
- package/dist/bin/patch.js +0 -51
- package/dist/bin/patch.js.map +0 -1
- package/dist/build/createBuildConfig.d.ts +0 -13
- package/dist/build/createBuildConfig.d.ts.map +0 -1
- package/dist/build/mergeInputs.d.ts +0 -5
- package/dist/build/mergeInputs.d.ts.map +0 -1
- package/dist/checkFilesExist.d.ts +0 -8
- package/dist/checkFilesExist.d.ts.map +0 -1
- package/dist/collect-css-manifest.d.ts.map +0 -1
- package/dist/components.d.ts.map +0 -1
- package/dist/copy-dir.d.ts.map +0 -1
- package/dist/getEnv.d.ts.map +0 -1
- package/dist/helpers/inputNormalizer.d.ts +0 -6
- package/dist/helpers/inputNormalizer.d.ts.map +0 -1
- package/dist/helpers/normalizedRelativePath.d.ts.map +0 -1
- package/dist/helpers/tryManifest.d.ts.map +0 -1
- package/dist/html/createPageLoader.d.ts.map +0 -1
- package/dist/manifest.d.ts.map +0 -1
- package/dist/module-graph.d.ts.map +0 -1
- package/dist/options.d.ts +0 -91
- package/dist/options.d.ts.map +0 -1
- package/dist/plugin.d.ts +0 -3
- package/dist/plugin.d.ts.map +0 -1
- package/dist/react-client/plugin.d.ts +0 -4
- package/dist/react-client/plugin.d.ts.map +0 -1
- package/dist/react-client/plugin.js +0 -28
- package/dist/react-client/plugin.js.map +0 -1
- package/dist/react-server/createDevMiddleware.d.ts.map +0 -1
- package/dist/react-server/createDevServer.d.ts.map +0 -1
- package/dist/react-server/createHandler.d.ts +0 -23
- package/dist/react-server/createHandler.d.ts.map +0 -1
- package/dist/react-server/createReactNodeStreamer.d.ts.map +0 -1
- package/dist/react-server/createRscStream.d.ts.map +0 -1
- package/dist/react-server/createSsrHandler.d.ts.map +0 -1
- package/dist/react-server/plugin.d.ts +0 -8
- package/dist/react-server/plugin.d.ts.map +0 -1
- package/dist/react-server/plugin.js +0 -345
- package/dist/react-server/plugin.js.map +0 -1
- package/dist/resolvePage.d.ts.map +0 -1
- package/dist/resolveProps.d.ts.map +0 -1
- package/dist/scripts/check-react-version.js +0 -34
- package/dist/scripts/check-react-version.js.map +0 -1
- package/dist/src/build/createBuildConfig.js +0 -44
- package/dist/src/build/createBuildConfig.js.map +0 -1
- package/dist/src/build/mergeInputs.js +0 -16
- package/dist/src/build/mergeInputs.js.map +0 -1
- package/dist/src/checkFilesExist.js +0 -61
- package/dist/src/checkFilesExist.js.map +0 -1
- package/dist/src/collect-css-manifest.js.map +0 -1
- package/dist/src/components.js.map +0 -1
- package/dist/src/getEnv.js +0 -76
- package/dist/src/getEnv.js.map +0 -1
- package/dist/src/helpers/inputNormalizer.js +0 -11
- package/dist/src/helpers/inputNormalizer.js.map +0 -1
- package/dist/src/helpers/normalizedRelativePath.js +0 -34
- package/dist/src/helpers/normalizedRelativePath.js.map +0 -1
- package/dist/src/helpers/tryManifest.js.map +0 -1
- package/dist/src/html/createPageLoader.js +0 -72
- package/dist/src/html/createPageLoader.js.map +0 -1
- package/dist/src/options.js +0 -307
- package/dist/src/options.js.map +0 -1
- package/dist/src/react-server/createHandler.js.map +0 -1
- package/dist/src/react-server/createRscStream.js.map +0 -1
- package/dist/src/resolvePage.js.map +0 -1
- package/dist/src/resolveProps.js.map +0 -1
- package/dist/src/worker/createHtmlStream.js +0 -62
- package/dist/src/worker/createHtmlStream.js.map +0 -1
- package/dist/src/worker/createWorker.js +0 -34
- package/dist/src/worker/createWorker.js.map +0 -1
- package/dist/src/worker/renderPages.js +0 -99
- package/dist/src/worker/renderPages.js.map +0 -1
- package/dist/transformer/index.d.ts.map +0 -1
- package/dist/transformer/preserveDirectives.d.ts +0 -4
- package/dist/transformer/preserveDirectives.d.ts.map +0 -1
- package/dist/transformer/preserver.d.ts +0 -2
- package/dist/transformer/preserver.d.ts.map +0 -1
- package/dist/transformer/transformer.d.ts.map +0 -1
- package/dist/transformer/types.d.ts.map +0 -1
- package/dist/worker/createHtmlStream.d.ts +0 -7
- package/dist/worker/createHtmlStream.d.ts.map +0 -1
- package/dist/worker/createWorker.d.ts +0 -10
- package/dist/worker/createWorker.d.ts.map +0 -1
- package/dist/worker/loader.d.ts.map +0 -1
- package/dist/worker/loader.js +0 -7
- package/dist/worker/loader.js.map +0 -1
- package/dist/worker/renderPages.d.ts +0 -18
- package/dist/worker/renderPages.d.ts.map +0 -1
- package/dist/worker/types.d.ts +0 -31
- package/dist/worker/types.d.ts.map +0 -1
- package/dist/worker/worker.d.ts +0 -7
- package/dist/worker/worker.d.ts.map +0 -1
- package/dist/worker/worker.js +0 -112
- package/dist/worker/worker.js.map +0 -1
- package/src/build/createBuildConfig.ts +0 -57
- package/src/build/mergeInputs.ts +0 -42
- package/src/checkFilesExist.ts +0 -67
- package/src/helpers/inputNormalizer.ts +0 -22
- package/src/index.ts +0 -4
- package/src/options.ts +0 -423
- package/src/plugin.ts +0 -5
- package/src/react-client/plugin.ts +0 -34
- package/src/react-server/plugin.ts +0 -409
- package/src/transformer/index.ts +0 -112
- package/src/transformer/preserveDirectives.ts +0 -100
- package/src/transformer/preserver.ts +0 -47
- package/src/worker/createHtmlStream.ts +0 -76
- package/src/worker/createWorker.ts +0 -44
- package/src/worker/renderPages.ts +0 -144
- package/src/worker/types.ts +0 -38
- package/src/worker/worker.tsx +0 -136
- /package/dist/{assertServerCondition.d.ts → plugin/assertServerCondition.d.ts} +0 -0
- /package/dist/{components.d.ts → plugin/components.d.ts} +0 -0
- /package/dist/{copy-dir.d.ts → plugin/copy-dir.d.ts} +0 -0
- /package/dist/{getEnv.d.ts → plugin/getEnv.d.ts} +0 -0
- /package/dist/{helpers → plugin/helpers}/normalizedRelativePath.d.ts +0 -0
- /package/dist/{helpers → plugin/helpers}/tryManifest.d.ts +0 -0
- /package/dist/{manifest.d.ts → plugin/manifest.d.ts} +0 -0
- /package/dist/{module-graph.d.ts → plugin/module-graph.d.ts} +0 -0
- /package/dist/{react-server → plugin/react-server}/createDevMiddleware.d.ts +0 -0
- /package/dist/{react-server → plugin/react-server}/createDevServer.d.ts +0 -0
- /package/dist/{react-server → plugin/react-server}/createReactNodeStreamer.d.ts +0 -0
- /package/dist/{resolvePage.d.ts → plugin/resolvePage.d.ts} +0 -0
- /package/dist/{resolveProps.d.ts → plugin/resolveProps.d.ts} +0 -0
- /package/dist/{transformer → plugin/transformer}/types.d.ts +0 -0
- /package/dist/{worker → plugin/worker}/loader.d.ts +0 -0
- /package/{src → plugin}/assertServerCondition.ts +0 -0
- /package/{src → plugin}/components.tsx +0 -0
- /package/{src → plugin}/copy-dir.ts +0 -0
- /package/{src/server.tsx → plugin/getCondition.ts} +0 -0
- /package/{src → plugin}/helpers/normalizedRelativePath.ts +0 -0
- /package/{src → plugin}/helpers/tryManifest.ts +0 -0
- /package/{src → plugin}/manifest.ts +0 -0
- /package/{src → plugin}/module-graph.ts +0 -0
- /package/{src → plugin}/transformer/README.md +0 -0
- /package/{src → plugin}/transformer/types.ts +0 -0
- /package/{src → plugin}/worker/loader.ts +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CreateHandlerOptions, StreamPluginOptions } from "../types.js";
|
|
2
|
+
import type { PipeableStream } from "react-dom/server";
|
|
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: Pick<StreamPluginOptions, "Page" | "props" | "build" | "Html" | "pageExportName" | "propsExportName"> & Required<Pick<StreamPluginOptions, "moduleBase" | "moduleBasePath" | "projectRoot">>, streamOptions: CreateHandlerOptions<T>): Promise<CreateHandlerResult>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=createHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHandler.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createHandler.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,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,IAAI,CACjB,mBAAmB,EACnB,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,CAC3E,GACC,QAAQ,CACN,IAAI,CAAC,mBAAmB,EAAE,YAAY,GAAG,gBAAgB,GAAG,aAAa,CAAC,CAC3E,EACH,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAoI9B"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { createLogger } from 'vite';
|
|
7
|
+
import { collectManifestCss, collectModuleGraphCss } from '../collect-css-manifest.js';
|
|
8
|
+
import { DEFAULT_CONFIG } from '../config/defaults.js';
|
|
9
|
+
import { resolvePage } from '../resolvePage.js';
|
|
10
|
+
import { resolveProps } from '../resolveProps.js';
|
|
11
|
+
import { createRscStream } from './createRscStream.js';
|
|
12
|
+
|
|
7
13
|
async function createHandler(url, pluginOptions, streamOptions) {
|
|
8
14
|
const root = pluginOptions.projectRoot ?? process.cwd();
|
|
9
15
|
const Html = pluginOptions.Html ?? DEFAULT_CONFIG.HTML;
|
|
@@ -23,7 +29,7 @@ async function createHandler(url, pluginOptions, streamOptions) {
|
|
|
23
29
|
streamOptions.onCssFile
|
|
24
30
|
) : (id) => collectModuleGraphCss(streamOptions.moduleGraph, id);
|
|
25
31
|
const loadWithCss = async (id) => {
|
|
26
|
-
|
|
32
|
+
console.log("[RSC] Loading module:", id);
|
|
27
33
|
try {
|
|
28
34
|
const mod = await streamOptions.loader(id);
|
|
29
35
|
const pageCss = await Promise.resolve(getCss(id));
|
|
@@ -85,26 +91,31 @@ async function createHandler(url, pluginOptions, streamOptions) {
|
|
|
85
91
|
Page,
|
|
86
92
|
props,
|
|
87
93
|
moduleBasePath: pluginOptions.moduleBasePath,
|
|
88
|
-
// eg /src
|
|
89
94
|
logger: streamOptions.logger ?? createLogger(),
|
|
90
95
|
cssFiles: Array.from(cssModules),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
pipableStreamOptions: streamOptions.pipableStreamOptions,
|
|
97
|
+
htmlProps: {
|
|
98
|
+
pageProps: props,
|
|
99
|
+
route: url,
|
|
100
|
+
url
|
|
101
|
+
}
|
|
94
102
|
});
|
|
95
103
|
if (!stream) {
|
|
104
|
+
console.log("[createHandler] No stream created for route:", url);
|
|
96
105
|
return { type: "skip" };
|
|
97
106
|
}
|
|
107
|
+
const assets = {
|
|
108
|
+
css: new Set(cssFiles ?? []),
|
|
109
|
+
clientPath: pagePath ?? ""
|
|
110
|
+
};
|
|
98
111
|
return {
|
|
99
112
|
type: "success",
|
|
100
113
|
controller,
|
|
101
114
|
stream,
|
|
102
|
-
assets
|
|
103
|
-
|
|
104
|
-
}
|
|
115
|
+
assets,
|
|
116
|
+
clientPath: assets.clientPath
|
|
105
117
|
};
|
|
106
118
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
119
|
+
|
|
120
|
+
export { createHandler };
|
|
110
121
|
//# sourceMappingURL=createHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHandler.js","sources":["../../../plugin/react-server/createHandler.ts"],"sourcesContent":["import { 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, StreamPluginOptions } from \"../types.js\";\nimport { createRscStream } from \"./createRscStream.js\";\nimport type { PipeableStream } from \"react-dom/server\";\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: Pick<\n StreamPluginOptions,\n \"Page\" | \"props\" | \"build\" | \"Html\" | \"pageExportName\" | \"propsExportName\"\n > &\n Required<\n Pick<StreamPluginOptions, \"moduleBase\" | \"moduleBasePath\" | \"projectRoot\">\n >,\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;\n const propsExportName =\n pluginOptions.propsExportName ?? DEFAULT_CONFIG.PROPS_EXPORT;\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.manifest || streamOptions.moduleGraph))\n throw new Error(\"Missing manifest or moduleGraph, pass it to options.\");\n\n const getCss = streamOptions.manifest\n ? (id: string) =>\n collectManifestCss(\n streamOptions.manifest!,\n root,\n id,\n streamOptions.onCssFile\n )\n : (id: string) => collectModuleGraphCss(streamOptions.moduleGraph!, id);\n\n const loadWithCss = async (id: string) => {\n console.log('[RSC] Loading module:', id);\n try {\n const mod = await streamOptions.loader(id);\n const pageCss = await Promise.resolve(getCss(id));\n Array.from(pageCss.keys()).forEach((css) => cssModules.add(css));\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),\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),\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\n const stream = createRscStream({\n Html: Html,\n Page: Page,\n props: props,\n moduleBasePath: pluginOptions.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 console.log(\"[createHandler] No stream created for route:\", url);\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,GAC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gB,uBAAuB,CAAC,EACtC,MAAM,EACN,cAAc,EACd,aAAa,EACb,OAAO,GACR,EAAE;IACD,MAAM,EAAE,QAAQ,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,GAMM,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CACnC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { createFromNodeStream,
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
} from "react-server-dom-esm/client.node";
|
|
5
|
+
export function createReactNodeStreamer({ stream, moduleBasePath, moduleBaseURL, options, }) {
|
|
6
|
+
return createFromNodeStream(stream, moduleBasePath, moduleBaseURL, options);
|
|
7
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PipeableStream } from "react-server-dom-esm/server.node";
|
|
2
1
|
import type { RscStreamOptions } from "../types.js";
|
|
2
|
+
import type { PipeableStream } from "react-dom/server";
|
|
3
3
|
export declare function createRscStream(streamOptions: RscStreamOptions): PipeableStream;
|
|
4
4
|
//# sourceMappingURL=createRscStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRscStream.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createRscStream.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,wBAAgB,eAAe,CAC7B,aAAa,EAAE,gBAAgB,GAC9B,cAAc,CAsChB"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
import { CssCollector } from '../components.js';
|
|
9
|
+
|
|
4
10
|
function createRscStream(streamOptions) {
|
|
5
11
|
const {
|
|
6
12
|
Html,
|
|
@@ -8,10 +14,9 @@ function createRscStream(streamOptions) {
|
|
|
8
14
|
props,
|
|
9
15
|
logger,
|
|
10
16
|
cssFiles,
|
|
11
|
-
route,
|
|
12
|
-
url,
|
|
13
17
|
moduleBasePath,
|
|
14
|
-
pipableStreamOptions
|
|
18
|
+
pipableStreamOptions,
|
|
19
|
+
htmlProps
|
|
15
20
|
} = streamOptions;
|
|
16
21
|
const css = Array.isArray(cssFiles) ? cssFiles.map(
|
|
17
22
|
(css2, index) => React.createElement(CssCollector, {
|
|
@@ -24,10 +29,7 @@ function createRscStream(streamOptions) {
|
|
|
24
29
|
Html,
|
|
25
30
|
{
|
|
26
31
|
key: "html",
|
|
27
|
-
|
|
28
|
-
moduleBasePath,
|
|
29
|
-
route,
|
|
30
|
-
url
|
|
32
|
+
...htmlProps
|
|
31
33
|
},
|
|
32
34
|
React.createElement(Page, { key: "page", ...props }),
|
|
33
35
|
...css
|
|
@@ -41,7 +43,6 @@ function createRscStream(streamOptions) {
|
|
|
41
43
|
}
|
|
42
44
|
);
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
46
|
+
|
|
47
|
+
export { createRscStream };
|
|
47
48
|
//# sourceMappingURL=createRscStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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 { CssCollector } from \"../components.js\";\nimport type { RscStreamOptions } from \"../types.js\";\nimport type { PipeableStream } from \"react-dom/server\";\n\nexport function createRscStream(\n streamOptions: RscStreamOptions\n): PipeableStream {\n const {\n Html,\n Page,\n props,\n logger,\n cssFiles,\n moduleBasePath,\n pipableStreamOptions,\n htmlProps,\n } = streamOptions;\n\n const css = Array.isArray(cssFiles)\n ? cssFiles.map((css, index) =>\n React.createElement(CssCollector, {\n key: `css-${index}`,\n url: css,\n })\n )\n : [];\n return renderToPipeableStream(\n React.createElement(\n Html,\n {\n key: \"html\",\n ...htmlProps\n },\n React.createElement(Page, { key: \"page\", ...props }),\n ...css\n ),\n moduleBasePath,\n {\n onError: logger?.error ?? console.error,\n onPostpone: logger?.info ?? console.info,\n environmentName: \"Server\",\n ...pipableStreamOptions\n }\n );\n}\n"],"names":["css"],"mappings":";;;;;;;;;AAOO,SAAS,gBACd,aACgB,EAAA;AAChB,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,cAAA;AAAA,IACA,oBAAA;AAAA,IACA;AAAA,GACE,GAAA,aAAA;AAEJ,EAAA,MAAM,GAAM,GAAA,KAAA,CAAM,OAAQ,CAAA,QAAQ,IAC9B,QAAS,CAAA,GAAA;AAAA,IAAI,CAACA,IAAAA,EAAK,KACjB,KAAA,KAAA,CAAM,cAAc,YAAc,EAAA;AAAA,MAChC,GAAA,EAAK,OAAO,KAAK,CAAA,CAAA;AAAA,MACjB,GAAKA,EAAAA;AAAA,KACN;AAAA,MAEH,EAAC;AACL,EAAO,OAAA,sBAAA;AAAA,IACL,KAAM,CAAA,aAAA;AAAA,MACJ,IAAA;AAAA,MACA;AAAA,QACE,GAAK,EAAA,MAAA;AAAA,QACL,GAAG;AAAA,OACL;AAAA,MACA,KAAA,CAAM,cAAc,IAAM,EAAA,EAAE,KAAK,MAAQ,EAAA,GAAG,OAAO,CAAA;AAAA,MACnD,GAAG;AAAA,KACL;AAAA,IACA,cAAA;AAAA,IACA;AAAA,MACE,OAAA,EAAS,MAAQ,EAAA,KAAA,IAAS,OAAQ,CAAA,KAAA;AAAA,MAClC,UAAA,EAAY,MAAQ,EAAA,IAAA,IAAQ,OAAQ,CAAA,IAAA;AAAA,MACpC,eAAiB,EAAA,QAAA;AAAA,MACjB,GAAG;AAAA;AACL,GACF;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ViteDevServer } from "vite";
|
|
2
2
|
import type { RequestHandler, StreamPluginOptions } from "../types.js";
|
|
3
|
-
export declare function createSsrHandler(options: Required<Pick<StreamPluginOptions, "Page" | "props" | "build" | "Html" | "pageExportName" | "propsExportName">> & Required<Pick<StreamPluginOptions, "moduleBase" | "moduleBasePath" | "moduleBaseURL" | "projectRoot"
|
|
3
|
+
export declare function createSsrHandler(options: Required<Pick<StreamPluginOptions, "Page" | "props" | "build" | "Html" | "pageExportName" | "propsExportName">> & Required<Pick<StreamPluginOptions, "moduleBase" | "moduleBasePath" | "moduleBaseURL" | "projectRoot" | "htmlWorkerPath">>, server: ViteDevServer, _clientComponents: Map<string, string>): RequestHandler;
|
|
4
4
|
//# sourceMappingURL=createSsrHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSsrHandler.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/createSsrHandler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKvE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,QAAQ,CACf,IAAI,CACF,mBAAmB,EACnB,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,CAC3E,CACF,GACC,QAAQ,CACN,IAAI,CACF,mBAAmB,EACnB,YAAY,GAAG,gBAAgB,GAAG,eAAe,GAAG,aAAa,GAAG,gBAAgB,CACrF,CACF,EACH,MAAM,EAAE,aAAa,EACrB,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,cAAc,CAsHhB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
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, _clientComponents) {
|
|
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
|
+
Page: options.Page,
|
|
25
|
+
props: options.props,
|
|
26
|
+
build: options.build,
|
|
27
|
+
Html: options.Html,
|
|
28
|
+
pageExportName: options.pageExportName,
|
|
29
|
+
propsExportName: options.propsExportName,
|
|
30
|
+
moduleBase: options.moduleBase,
|
|
31
|
+
moduleBasePath: options.moduleBasePath,
|
|
32
|
+
projectRoot: server.config.root,
|
|
33
|
+
}, {
|
|
34
|
+
loader: server.ssrLoadModule.bind(server),
|
|
35
|
+
moduleGraph: server.moduleGraph,
|
|
36
|
+
});
|
|
37
|
+
const moduleRootPath = join(server.config.cacheDir, options.moduleBasePath);
|
|
38
|
+
// const htmlOutputPath = join(
|
|
39
|
+
// server.config.cacheDir,
|
|
40
|
+
// server.config.build.outDir,
|
|
41
|
+
// req.url,
|
|
42
|
+
// "index.html"
|
|
43
|
+
// );
|
|
44
|
+
if (result.type !== "success") {
|
|
45
|
+
throw new Error(result.type === "error" ? String(result.error) : "Skipped");
|
|
46
|
+
}
|
|
47
|
+
// Collect RSC stream data
|
|
48
|
+
const rscData = await new Promise((resolve, reject) => {
|
|
49
|
+
let data = "";
|
|
50
|
+
if (!result.stream) {
|
|
51
|
+
resolve(data);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const writable = new Writable({
|
|
55
|
+
write(chunk, _, callback) {
|
|
56
|
+
data += chunk;
|
|
57
|
+
callback();
|
|
58
|
+
},
|
|
59
|
+
final(callback) {
|
|
60
|
+
resolve(data);
|
|
61
|
+
callback();
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
result.stream.pipe(writable);
|
|
65
|
+
writable.on("error", reject);
|
|
66
|
+
});
|
|
67
|
+
// Get HTML from worker
|
|
68
|
+
const html = await new Promise((resolve, reject) => {
|
|
69
|
+
worker.postMessage({
|
|
70
|
+
type: "RSC_CHUNK",
|
|
71
|
+
id: req.url ?? "/",
|
|
72
|
+
chunk: rscData,
|
|
73
|
+
moduleRootPath: moduleRootPath,
|
|
74
|
+
moduleBaseURL: options.moduleBaseURL,
|
|
75
|
+
// Don't need file paths in dev mode
|
|
76
|
+
outDir: "",
|
|
77
|
+
htmlOutputPath: "",
|
|
78
|
+
pipableStreamOptions: {
|
|
79
|
+
bootstrapModules: ["/dist/client.js"],
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
worker.once("message", (msg) => {
|
|
83
|
+
if (msg.type === "ERROR") {
|
|
84
|
+
const message = msg.error instanceof Error
|
|
85
|
+
? msg.error.message
|
|
86
|
+
: String(msg.error);
|
|
87
|
+
reject(new Error(message, { cause: msg }));
|
|
88
|
+
}
|
|
89
|
+
else if (msg.type === "HTML") {
|
|
90
|
+
// In dev, content will be the HTML string
|
|
91
|
+
resolve(msg.content);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
res.setHeader("Content-Type", "text/html");
|
|
96
|
+
res.end(html);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
next(error);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,wBAAgB,qBAAqB,CAAC,OAAO,GAAS,mBAAmB,GAAG,OAAO,MAAM,EAAE,MAAM,EAAE,CAMhG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { reactPreservePlugin } from "../preserver/plugin.js";
|
|
2
|
+
import { reactTransformPlugin } from "../transformer/plugin.js";
|
|
3
|
+
import { reactServerPlugin } from "./plugin.js";
|
|
4
|
+
export function vitePluginReactServer(options = {}) {
|
|
5
|
+
return [
|
|
6
|
+
reactTransformPlugin(options),
|
|
7
|
+
reactServerPlugin(options),
|
|
8
|
+
reactPreservePlugin(options),
|
|
9
|
+
];
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactStreamPluginMeta } from "../types.js";
|
|
2
|
+
import { type StreamPluginOptions } from "../types.js";
|
|
3
|
+
export declare function reactServerPlugin(options: StreamPluginOptions): import("vite").Plugin<{
|
|
4
|
+
meta: ReactStreamPluginMeta;
|
|
5
|
+
addCssFile: (path: string) => void;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../plugin/react-server/plugin.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAGV,qBAAqB,EAGtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAKvD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,MAAM,EAAE,MAAM,CAAC;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAE,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAAE,CA4a9F"}
|