vite-plugin-react-server 0.3.3 → 0.3.5
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/_virtual/sourcemap-codec.umd.js +11 -0
- package/dist/_virtual/sourcemap-codec.umd.js.map +1 -0
- package/dist/_virtual/sourcemap-codec.umd2.js +9 -0
- package/dist/_virtual/sourcemap-codec.umd2.js.map +1 -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 +6 -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/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +457 -0
- package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +1 -0
- 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 +131 -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 +52 -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 +4 -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 +4 -0
- package/dist/plugin/react-server/index.d.ts.map +1 -0
- package/dist/plugin/react-server/index.js +10 -0
- package/dist/{react-server → plugin/react-server}/plugin.d.ts +2 -2
- package/dist/plugin/react-server/plugin.d.ts.map +1 -0
- package/dist/plugin/react-server/plugin.js +375 -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 -3
- package/dist/plugin/transformer/plugin.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.js +86 -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 +121 -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 +44 -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 +60 -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 +110 -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 +13 -0
- package/plugin/react-server/plugin.ts +465 -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 +131 -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 +187 -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/bump-version.mjs +68 -0
- package/scripts/check-react-version.mjs +66 -0
- 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 +10259 -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.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/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
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { createWriteStream } from "node:fs";
|
|
2
|
-
import { Readable, Writable } from "node:stream";
|
|
3
|
-
import { parentPort } from "node:worker_threads";
|
|
4
|
-
import { renderToPipeableStream } from "react-dom/server";
|
|
5
|
-
import { createFromNodeStream } from "react-server-dom-esm/client.node";
|
|
6
|
-
import type { RenderState } from "./types.js";
|
|
7
|
-
|
|
8
|
-
const concatter = (chunk: string) => {
|
|
9
|
-
if (Array.isArray(chunk)) {
|
|
10
|
-
return Buffer.from(chunk);
|
|
11
|
-
}
|
|
12
|
-
return Buffer.from(chunk);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export function createHtmlStream(
|
|
16
|
-
renderState: RenderState,
|
|
17
|
-
writeStream: Writable
|
|
18
|
-
) {
|
|
19
|
-
const outputPath = renderState.htmlOutputPath;
|
|
20
|
-
|
|
21
|
-
// Create readable stream from RSC content
|
|
22
|
-
const rscStream = Readable.from(renderState.chunks.map(concatter));
|
|
23
|
-
|
|
24
|
-
// Create RSC node stream
|
|
25
|
-
const reactElements = createFromNodeStream(
|
|
26
|
-
rscStream,
|
|
27
|
-
renderState.moduleBasePath,
|
|
28
|
-
renderState.moduleBaseURL
|
|
29
|
-
);
|
|
30
|
-
// rsc file destination follows the same path as the html file, but with a .rsc extension
|
|
31
|
-
const rscOutputPath = renderState.htmlOutputPath.endsWith(".html")
|
|
32
|
-
? renderState.htmlOutputPath.slice(0, -5) + ".rsc"
|
|
33
|
-
: renderState.htmlOutputPath.endsWith("/")
|
|
34
|
-
? renderState.htmlOutputPath + "index.rsc"
|
|
35
|
-
: renderState.htmlOutputPath.endsWith(".")
|
|
36
|
-
? renderState.htmlOutputPath + "rsc"
|
|
37
|
-
: renderState.htmlOutputPath + ".rsc";
|
|
38
|
-
|
|
39
|
-
const writeRscEntry = createWriteStream(rscOutputPath);
|
|
40
|
-
rscStream.on("data", (chunk) => {
|
|
41
|
-
writeRscEntry.write(chunk);
|
|
42
|
-
});
|
|
43
|
-
rscStream.on("end", () => {
|
|
44
|
-
writeRscEntry.end();
|
|
45
|
-
});
|
|
46
|
-
const stream = renderToPipeableStream(reactElements as React.ReactNode, {
|
|
47
|
-
...renderState.pipableStreamOptions,
|
|
48
|
-
onAllReady() {
|
|
49
|
-
writeStream.on("finish", () => {
|
|
50
|
-
parentPort?.postMessage({
|
|
51
|
-
type: "HTML",
|
|
52
|
-
outputPath,
|
|
53
|
-
route: renderState.id,
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
writeStream.on("error", (error) => {
|
|
57
|
-
console.error("[Worker] Write error at", error);
|
|
58
|
-
stream.abort();
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
onShellReady() {
|
|
62
|
-
stream.pipe(writeStream);
|
|
63
|
-
},
|
|
64
|
-
onError(error) {
|
|
65
|
-
console.error("[Worker] Render error at", error);
|
|
66
|
-
stream.abort();
|
|
67
|
-
writeStream.destroy();
|
|
68
|
-
},
|
|
69
|
-
onShellError(error) {
|
|
70
|
-
console.error("[Worker] Shell error at", error);
|
|
71
|
-
stream.abort();
|
|
72
|
-
writeStream.destroy();
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
return { stream, writeStream };
|
|
76
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { Worker } from "node:worker_threads";
|
|
3
|
-
|
|
4
|
-
type CreateWorkerOptions = {
|
|
5
|
-
workerPath: string;
|
|
6
|
-
nodePath: string;
|
|
7
|
-
mode: "production" | "development";
|
|
8
|
-
workerOptions?: WorkerOptions;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export async function createWorker(
|
|
12
|
-
options: CreateWorkerOptions
|
|
13
|
-
) {
|
|
14
|
-
const { workerPath, nodePath, mode, workerOptions } = options;
|
|
15
|
-
console.log("[Worker] Creating worker...");
|
|
16
|
-
console.log("[Worker] Worker path:", workerPath);
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
const worker = new Worker(workerPath, {
|
|
20
|
-
env: {
|
|
21
|
-
NODE_OPTIONS: "",
|
|
22
|
-
NODE_ENV: mode,
|
|
23
|
-
NODE_PATH: nodePath,
|
|
24
|
-
},
|
|
25
|
-
...workerOptions,
|
|
26
|
-
});
|
|
27
|
-
worker.setMaxListeners(1000);
|
|
28
|
-
|
|
29
|
-
// Wait for worker to be ready
|
|
30
|
-
await new Promise<void>((resolve, reject) => {
|
|
31
|
-
worker.once("message", (message) => {
|
|
32
|
-
if (message.type === "READY") {
|
|
33
|
-
resolve();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
worker.once("error", reject);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return worker;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error("[Worker] Startup error:", error);
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { join, resolve as resolvePath } from "node:path";
|
|
2
|
-
import { Transform } from "node:stream";
|
|
3
|
-
import type { Worker } from "node:worker_threads";
|
|
4
|
-
import type { PipeableStreamOptions } from "react-dom/server.node";
|
|
5
|
-
import { createHandler } from "../react-server/createHandler.js";
|
|
6
|
-
import type { StreamPluginOptions } from "../types.js";
|
|
7
|
-
import type {
|
|
8
|
-
WorkerRscChunkMessage,
|
|
9
|
-
WorkerRscEndMessage,
|
|
10
|
-
} from "./types.js";
|
|
11
|
-
|
|
12
|
-
type RenderPagesOptions = {
|
|
13
|
-
pluginOptions: Required<
|
|
14
|
-
Pick<
|
|
15
|
-
StreamPluginOptions,
|
|
16
|
-
"moduleBase" | "moduleBasePath" | "moduleBaseURL" | "projectRoot"
|
|
17
|
-
>
|
|
18
|
-
> &
|
|
19
|
-
Pick<
|
|
20
|
-
StreamPluginOptions,
|
|
21
|
-
"Page" | "props" | "build" | "Html" | "pageExportName" | "propsExportName"
|
|
22
|
-
>;
|
|
23
|
-
outDir: string;
|
|
24
|
-
manifest: Record<string, { file: string }>;
|
|
25
|
-
worker: Worker;
|
|
26
|
-
pipableStreamOptions?: PipeableStreamOptions;
|
|
27
|
-
loader: (id: string) => Promise<Record<string, any>>;
|
|
28
|
-
onCssFile?: (path: string) => void;
|
|
29
|
-
clientCss?: string[];
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export async function renderPages(
|
|
33
|
-
routes: string[],
|
|
34
|
-
options: RenderPagesOptions
|
|
35
|
-
) {
|
|
36
|
-
const destinationRoot = resolvePath(
|
|
37
|
-
options.pluginOptions.projectRoot,
|
|
38
|
-
options.outDir
|
|
39
|
-
);
|
|
40
|
-
const failedRoutes = new Map<string, Error>();
|
|
41
|
-
const moduleBasePath = join(
|
|
42
|
-
destinationRoot,
|
|
43
|
-
options.pluginOptions.moduleBasePath
|
|
44
|
-
);
|
|
45
|
-
const moduleBaseURL = options.pluginOptions.moduleBaseURL;
|
|
46
|
-
|
|
47
|
-
const htmlRoot = resolvePath(
|
|
48
|
-
options.pluginOptions.projectRoot,
|
|
49
|
-
options.pluginOptions.build?.client ?? options.outDir
|
|
50
|
-
);
|
|
51
|
-
const filesOutputted: string[] = [];
|
|
52
|
-
|
|
53
|
-
options.worker.on("message", (msg) => {
|
|
54
|
-
switch (msg.type) {
|
|
55
|
-
case "ERROR":
|
|
56
|
-
console.error("[RenderPages] Worker error:", msg.error);
|
|
57
|
-
break;
|
|
58
|
-
case "HTML":
|
|
59
|
-
filesOutputted.push(msg.outputPath);
|
|
60
|
-
if (filesOutputted.length === routes.length) {
|
|
61
|
-
renderPromises.push(
|
|
62
|
-
new Promise<void>((resolve) => {
|
|
63
|
-
options.worker.removeAllListeners();
|
|
64
|
-
options.worker.terminate();
|
|
65
|
-
resolve();
|
|
66
|
-
})
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
break;
|
|
70
|
-
default:
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
const pipableStreamOptions = options.pipableStreamOptions ?? {};
|
|
75
|
-
|
|
76
|
-
// Create promises for each route in the batch
|
|
77
|
-
const renderPromises = routes.map(async (route) => {
|
|
78
|
-
try {
|
|
79
|
-
// Wait for handler creation
|
|
80
|
-
const result = await createHandler(route, options.pluginOptions, {
|
|
81
|
-
loader: options.loader,
|
|
82
|
-
manifest: options.manifest,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
if (result.type !== "success") {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const htmlOutputPath = join(htmlRoot, route, "index.html");
|
|
89
|
-
|
|
90
|
-
// Create a promise that resolves when the worker completes
|
|
91
|
-
await new Promise<void>((resolve, reject) => {
|
|
92
|
-
// Pipe RSC stream to worker
|
|
93
|
-
const transform = new Transform({
|
|
94
|
-
transform(chunk, _encoding, callback) {
|
|
95
|
-
// Send raw chunk
|
|
96
|
-
options.worker.postMessage({
|
|
97
|
-
type: "RSC_CHUNK",
|
|
98
|
-
id: route,
|
|
99
|
-
chunk: chunk,
|
|
100
|
-
moduleBasePath,
|
|
101
|
-
moduleBaseURL,
|
|
102
|
-
htmlOutputPath: htmlOutputPath,
|
|
103
|
-
outDir: options.outDir,
|
|
104
|
-
pipableStreamOptions,
|
|
105
|
-
} satisfies WorkerRscChunkMessage);
|
|
106
|
-
callback();
|
|
107
|
-
},
|
|
108
|
-
flush(callback) {
|
|
109
|
-
options.worker.postMessage({
|
|
110
|
-
type: "RSC_END",
|
|
111
|
-
id: route,
|
|
112
|
-
} satisfies WorkerRscEndMessage);
|
|
113
|
-
callback();
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// Listen for worker response for this route
|
|
118
|
-
const messageHandler = (msg: any) => {
|
|
119
|
-
if (msg.route === route) {
|
|
120
|
-
if (msg.type === "ERROR") {
|
|
121
|
-
options.worker.removeListener("message", messageHandler);
|
|
122
|
-
reject(new Error(msg.error));
|
|
123
|
-
} else if (msg.type === "HTML") {
|
|
124
|
-
options.worker.removeListener("message", messageHandler);
|
|
125
|
-
resolve();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
options.worker.on("message", messageHandler);
|
|
131
|
-
result.stream?.pipe(transform);
|
|
132
|
-
});
|
|
133
|
-
} catch (error) {
|
|
134
|
-
failedRoutes.set(route, error as Error);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
// Wait for all routes to complete
|
|
139
|
-
await Promise.all(renderPromises);
|
|
140
|
-
|
|
141
|
-
if (failedRoutes.size > 0) {
|
|
142
|
-
console.error("[vite-react-stream] Failed routes:", failedRoutes);
|
|
143
|
-
}
|
|
144
|
-
}
|
package/src/worker/types.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { PipeableStreamOptions } from "react-dom/server.node";
|
|
2
|
-
|
|
3
|
-
export interface RenderState {
|
|
4
|
-
chunks: string[];
|
|
5
|
-
complete: boolean;
|
|
6
|
-
rendered: boolean;
|
|
7
|
-
outDir: string;
|
|
8
|
-
moduleBasePath: string;
|
|
9
|
-
moduleBaseURL: string;
|
|
10
|
-
htmlOutputPath: string;
|
|
11
|
-
id: string;
|
|
12
|
-
pipableStreamOptions: PipeableStreamOptions;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface WorkerRscChunkMessage {
|
|
16
|
-
type: "RSC_CHUNK";
|
|
17
|
-
id: string;
|
|
18
|
-
chunk: string;
|
|
19
|
-
moduleBasePath: string;
|
|
20
|
-
moduleBaseURL: string;
|
|
21
|
-
outDir: string;
|
|
22
|
-
htmlOutputPath: string;
|
|
23
|
-
pipableStreamOptions: PipeableStreamOptions;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface WorkerRscEndMessage {
|
|
27
|
-
type: "RSC_END";
|
|
28
|
-
id: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface WorkerShutdownMessage {
|
|
32
|
-
type: "SHUTDOWN";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type WorkerMessage =
|
|
36
|
-
| WorkerRscChunkMessage
|
|
37
|
-
| WorkerRscEndMessage
|
|
38
|
-
| WorkerShutdownMessage;
|
package/src/worker/worker.tsx
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { createWriteStream } from "node:fs";
|
|
2
|
-
import { mkdir } from "node:fs/promises";
|
|
3
|
-
import { dirname } from "node:path";
|
|
4
|
-
import { Writable } from "node:stream";
|
|
5
|
-
import { parentPort } from "node:worker_threads";
|
|
6
|
-
import type { PipeableStream } from "react-server-dom-esm/server.node";
|
|
7
|
-
import { createHtmlStream } from "./createHtmlStream.js";
|
|
8
|
-
import type { RenderState, WorkerMessage } from "./types.js";
|
|
9
|
-
|
|
10
|
-
if (!parentPort) {
|
|
11
|
-
throw new Error("This module must be run as a worker");
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare global {
|
|
15
|
-
interface Window {
|
|
16
|
-
href: string;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
// Initialize happy-dom window
|
|
20
|
-
(global as any).window = {
|
|
21
|
-
href: undefined,
|
|
22
|
-
pathname: undefined,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Track active renders
|
|
26
|
-
const activeRenders = new Map<string, RenderState>();
|
|
27
|
-
const activeStreams = new Map<string, PipeableStream>();
|
|
28
|
-
const activeWrites = new Map<string, Writable>();
|
|
29
|
-
|
|
30
|
-
async function shutdown() {
|
|
31
|
-
console.log("[Worker] Shutting down forcefully");
|
|
32
|
-
while (activeRenders.size > 0) {
|
|
33
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
34
|
-
}
|
|
35
|
-
for (const stream of activeStreams.values()) {
|
|
36
|
-
stream.abort();
|
|
37
|
-
}
|
|
38
|
-
for (const writeStream of activeWrites.values()) {
|
|
39
|
-
writeStream.destroy();
|
|
40
|
-
}
|
|
41
|
-
process.exit(0);
|
|
42
|
-
}
|
|
43
|
-
// Handle incoming messages
|
|
44
|
-
parentPort.on("message", async (message: WorkerMessage) => {
|
|
45
|
-
if (message.type === "SHUTDOWN") {
|
|
46
|
-
await shutdown();
|
|
47
|
-
}
|
|
48
|
-
if (!parentPort) {
|
|
49
|
-
throw new Error("No parent port available");
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
switch (message.type) {
|
|
53
|
-
case "RSC_CHUNK": {
|
|
54
|
-
const { chunk, id, ...rest } = message;
|
|
55
|
-
(global as any).window.pathname = id;
|
|
56
|
-
// Skip if already rendered
|
|
57
|
-
let renderState = activeRenders.get(id);
|
|
58
|
-
if (renderState?.rendered) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
// Initialize render state
|
|
62
|
-
if (!renderState) {
|
|
63
|
-
renderState = {
|
|
64
|
-
chunks: [],
|
|
65
|
-
complete: false,
|
|
66
|
-
rendered: false,
|
|
67
|
-
id: id,
|
|
68
|
-
...rest,
|
|
69
|
-
};
|
|
70
|
-
activeRenders.set(id, renderState);
|
|
71
|
-
}
|
|
72
|
-
// Add chunk
|
|
73
|
-
if (chunk) renderState.chunks.push(chunk);
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
case "RSC_END": {
|
|
78
|
-
const { id } = message;
|
|
79
|
-
const render = activeRenders.get(id);
|
|
80
|
-
|
|
81
|
-
if (!render || !parentPort || render.rendered) return;
|
|
82
|
-
try {
|
|
83
|
-
const writeToFile = render.outDir && render.htmlOutputPath;
|
|
84
|
-
// Write RSC content
|
|
85
|
-
if (writeToFile) {
|
|
86
|
-
await mkdir(dirname(render.htmlOutputPath), { recursive: true });
|
|
87
|
-
}
|
|
88
|
-
const { stream, writeStream } = createHtmlStream(
|
|
89
|
-
render,
|
|
90
|
-
writeToFile
|
|
91
|
-
? createWriteStream(render.htmlOutputPath)
|
|
92
|
-
: new Writable({
|
|
93
|
-
write(chunk, _, callback) {
|
|
94
|
-
parentPort?.postMessage({
|
|
95
|
-
type: "HTML",
|
|
96
|
-
route: render.id,
|
|
97
|
-
content: chunk.toString(),
|
|
98
|
-
});
|
|
99
|
-
callback();
|
|
100
|
-
},
|
|
101
|
-
})
|
|
102
|
-
);
|
|
103
|
-
activeStreams.set(id, stream);
|
|
104
|
-
activeWrites.set(id, writeStream);
|
|
105
|
-
writeStream.on("finish", () => {
|
|
106
|
-
activeStreams.delete(id);
|
|
107
|
-
activeWrites.delete(id);
|
|
108
|
-
});
|
|
109
|
-
writeStream.on("error", () => {
|
|
110
|
-
activeStreams.delete(id);
|
|
111
|
-
activeWrites.delete(id);
|
|
112
|
-
stream.abort();
|
|
113
|
-
});
|
|
114
|
-
} catch (error) {
|
|
115
|
-
activeRenders.delete(id);
|
|
116
|
-
activeStreams.delete(id);
|
|
117
|
-
activeWrites.delete(id);
|
|
118
|
-
throw error;
|
|
119
|
-
} finally {
|
|
120
|
-
activeRenders.delete(id);
|
|
121
|
-
}
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
} catch (error) {
|
|
126
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
127
|
-
parentPort?.postMessage({
|
|
128
|
-
type: "ERROR",
|
|
129
|
-
error: errorMessage,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
// Signal ready only after loader is registered
|
|
135
|
-
parentPort.postMessage({ type: "READY" });
|
|
136
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|