vite-plugin-react-server 1.0.2 → 1.1.0
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 +49 -76
- package/bin/patch.mjs +27 -20
- package/dist/_virtual/dynamic-import-helper.js +24 -0
- package/dist/_virtual/dynamic-import-helper.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -26
- package/dist/index.js.map +1 -1
- package/dist/package.json +24 -14
- package/dist/plugin/components.d.ts +1 -1
- package/dist/plugin/components.d.ts.map +1 -1
- package/dist/plugin/components.js +1 -1
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +30 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts +13 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js +24 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts +11 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +29 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js +83 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +18 -14
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +42 -21
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/getCondition.d.ts +1 -1
- package/dist/plugin/config/getCondition.d.ts.map +1 -1
- package/dist/plugin/config/getCondition.js +2 -2
- package/dist/plugin/config/getCondition.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.map +1 -1
- package/dist/plugin/config/index.d.ts +0 -1
- package/dist/plugin/config/index.d.ts.map +1 -1
- package/dist/plugin/config/index.js +0 -1
- package/dist/plugin/config/resolveAutoDiscover.d.ts +20 -0
- package/dist/plugin/config/resolveAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/resolveAutoDiscover.js +128 -0
- package/dist/plugin/config/resolveAutoDiscover.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 +109 -77
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +0 -1
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js +6 -8
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUrlOption.d.ts +16 -0
- package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -0
- package/dist/plugin/config/resolveUrlOption.js +37 -0
- package/dist/plugin/config/resolveUrlOption.js.map +1 -0
- package/dist/plugin/config/resolveUserConfig.d.ts +4 -5
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +80 -132
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/copy.d.ts +7 -0
- package/dist/plugin/copy.d.ts.map +1 -0
- package/dist/plugin/copy.js +30 -0
- package/dist/plugin/css-collector-elements.d.ts +4 -0
- package/dist/plugin/css-collector-elements.d.ts.map +1 -0
- package/dist/plugin/css-collector-elements.js +19 -0
- package/dist/plugin/css-collector-elements.js.map +1 -0
- package/dist/plugin/css-collector.d.ts +2 -8
- package/dist/plugin/css-collector.d.ts.map +1 -1
- package/dist/plugin/css-collector.js +9 -36
- package/dist/plugin/css-collector.js.map +1 -1
- package/dist/plugin/helpers/cleanObject.d.ts +3 -0
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -0
- package/dist/plugin/helpers/cleanObject.js +47 -0
- package/dist/plugin/helpers/cleanObject.js.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts +8 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.js +110 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts +7 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectManifestCss.js +44 -0
- package/dist/plugin/helpers/collectManifestCss.js.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +31 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +104 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -0
- package/dist/plugin/helpers/createCssProps.d.ts +25 -0
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -0
- package/dist/plugin/helpers/createCssProps.js +57 -0
- package/dist/plugin/helpers/createCssProps.js.map +1 -0
- package/dist/plugin/helpers/createEventHandler.d.ts +22 -0
- package/dist/plugin/helpers/createEventHandler.d.ts.map +1 -0
- package/dist/plugin/helpers/createEventHandler.js +36 -0
- package/dist/plugin/helpers/createEventHandler.js.map +1 -0
- package/dist/plugin/helpers/createHandler.d.ts +7 -13
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +54 -96
- package/dist/plugin/helpers/createHandler.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts +12 -26
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +105 -51
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/helpers/defaultFileWriter.d.ts +2 -0
- package/dist/plugin/helpers/defaultFileWriter.d.ts.map +1 -0
- package/dist/plugin/helpers/defaultFileWriter.js +1 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts +10 -16
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +30 -22
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
- package/dist/plugin/helpers/getRouteFiles.d.ts +14 -0
- package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -0
- package/dist/plugin/helpers/getRouteFiles.js +36 -0
- package/dist/plugin/helpers/getRouteFiles.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +38 -32
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/metrics.d.ts +11 -0
- package/dist/plugin/helpers/metrics.d.ts.map +1 -0
- package/dist/plugin/helpers/metrics.js +35 -0
- package/dist/plugin/helpers/metrics.js.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +27 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.js +51 -0
- package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts +8 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.js +182 -0
- package/dist/plugin/helpers/serializeUserOptions.js.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts +2 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.js +14 -0
- package/dist/plugin/helpers/tryManifest.d.ts +5 -3
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +16 -7
- package/dist/plugin/helpers/tryManifest.js.map +1 -1
- package/dist/plugin/html.d.ts +2 -3
- package/dist/plugin/html.d.ts.map +1 -1
- package/dist/plugin/html.js +7 -1
- package/dist/plugin/html.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +3 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +26 -4
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +98 -33
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/css-loader.development.d.ts +57 -0
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.development.js +81 -0
- package/dist/plugin/loader/css-loader.development.js.map +1 -0
- package/dist/plugin/loader/css-loader.production.d.ts +31 -0
- package/dist/plugin/loader/css-loader.production.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.production.js +45 -0
- package/dist/plugin/loader/css-loader.production.js.map +1 -0
- package/dist/plugin/loader/index.d.ts +2 -0
- package/dist/plugin/loader/index.d.ts.map +1 -0
- package/dist/plugin/loader/index.js +1 -0
- package/dist/plugin/loader/plugin.d.ts +22 -0
- package/dist/plugin/loader/plugin.d.ts.map +1 -0
- package/dist/plugin/loader/plugin.js +27 -0
- package/dist/plugin/loader/react-loader.d.ts +3 -7
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +85 -30
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/loader/temporaryReferences.d.ts +2 -0
- package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -0
- package/dist/plugin/loader/temporaryReferences.js +11 -0
- package/dist/plugin/loader/temporaryReferences.js.map +1 -0
- package/dist/plugin/moduleRefs.d.ts +7 -0
- package/dist/plugin/moduleRefs.d.ts.map +1 -0
- package/dist/plugin/moduleRefs.js +17 -0
- package/dist/plugin/moduleRefs.js.map +1 -0
- package/dist/plugin/plugin.client.d.ts +3 -0
- package/dist/plugin/plugin.client.d.ts.map +1 -0
- package/dist/plugin/plugin.client.js +19 -0
- package/dist/plugin/plugin.client.js.map +1 -0
- package/dist/plugin/plugin.d.ts +1 -5
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +3 -9
- package/dist/plugin/plugin.server.d.ts +3 -0
- package/dist/plugin/plugin.server.d.ts.map +1 -0
- package/dist/plugin/plugin.server.js +28 -0
- package/dist/plugin/plugin.server.js.map +1 -0
- package/dist/plugin/preserver/plugin.js +1 -1
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/index.d.ts +1 -2
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +1 -19
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +60 -219
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-client/server.d.ts +27 -0
- package/dist/plugin/react-client/server.d.ts.map +1 -0
- package/dist/plugin/react-client/server.js +197 -0
- package/dist/plugin/react-client/server.js.map +1 -0
- package/dist/plugin/react-server/index.d.ts +1 -2
- package/dist/plugin/react-server/index.d.ts.map +1 -1
- package/dist/plugin/react-server/index.js +1 -21
- package/dist/plugin/react-server/plugin.d.ts +0 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +60 -186
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-server/server.d.ts +9 -0
- package/dist/plugin/react-server/server.d.ts.map +1 -0
- package/dist/plugin/react-server/server.js +120 -0
- package/dist/plugin/react-server/server.js.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +23 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js +85 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -0
- package/dist/plugin/react-static/collectRscContent.d.ts +24 -0
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectRscContent.js +49 -0
- package/dist/plugin/react-static/collectRscContent.js.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts +7 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.js +67 -0
- package/dist/plugin/react-static/configurePreviewServer.js.map +1 -0
- package/dist/plugin/react-static/fileWriter.d.ts +23 -0
- package/dist/plugin/react-static/fileWriter.d.ts.map +1 -0
- package/dist/plugin/react-static/fileWriter.js +65 -0
- package/dist/plugin/react-static/fileWriter.js.map +1 -0
- package/dist/plugin/react-static/plugin.d.ts +15 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +248 -149
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/renderPage.d.ts +3 -0
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPage.js +116 -0
- package/dist/plugin/react-static/renderPage.js.map +1 -0
- package/dist/plugin/react-static/renderPages.d.ts +3 -0
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPages.js +125 -0
- package/dist/plugin/react-static/renderPages.js.map +1 -0
- package/dist/plugin/react-static/renderStreams.d.ts +26 -0
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -0
- package/dist/plugin/react-static/renderStreams.js +27 -0
- package/dist/plugin/react-static/renderStreams.js.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts +22 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.js +54 -0
- package/dist/plugin/react-static/rscToHtmlStream.js.map +1 -0
- package/dist/plugin/react-static/streamHandler.d.ts +2 -0
- package/dist/plugin/react-static/streamHandler.d.ts.map +1 -0
- package/dist/plugin/react-static/streamHandler.js +1 -0
- package/dist/plugin/react-static/types.d.ts +11 -0
- package/dist/plugin/react-static/types.d.ts.map +1 -1
- package/dist/plugin/resolvePage.d.ts +26 -9
- package/dist/plugin/resolvePage.d.ts.map +1 -1
- package/dist/plugin/resolvePage.js +41 -39
- package/dist/plugin/resolvePage.js.map +1 -1
- package/dist/plugin/resolveProps.d.ts +40 -7
- package/dist/plugin/resolveProps.d.ts.map +1 -1
- package/dist/plugin/resolveProps.js +100 -75
- package/dist/plugin/resolveProps.js.map +1 -1
- package/dist/plugin/root.d.ts +1 -0
- package/dist/plugin/root.d.ts.map +1 -1
- package/dist/plugin/root.js +1 -0
- package/dist/plugin/root.js.map +1 -1
- package/dist/plugin/transformer/index.d.ts +2 -1
- package/dist/plugin/transformer/index.d.ts.map +1 -1
- package/dist/plugin/transformer/index.js +2 -1
- package/dist/plugin/transformer/plugin.client.d.ts +4 -0
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.client.js +83 -0
- package/dist/plugin/transformer/plugin.client.js.map +1 -0
- package/dist/plugin/transformer/plugin.d.ts +1 -27
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +3 -87
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/plugin.server.d.ts +4 -0
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.server.js +76 -0
- package/dist/plugin/transformer/plugin.server.js.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +11 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.js +38 -0
- package/dist/plugin/types/css-tracking.d.ts +6 -0
- package/dist/plugin/types/css-tracking.d.ts.map +1 -0
- package/dist/plugin/types/css-tracking.js +1 -0
- package/dist/plugin/types.d.ts +372 -86
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js +1 -1
- package/dist/plugin/vendor.client.d.ts +4 -0
- package/dist/plugin/vendor.client.d.ts.map +1 -0
- package/dist/plugin/vendor.client.js +16 -0
- package/dist/plugin/vendor.client.js.map +1 -0
- package/dist/plugin/vendor.server.d.ts +4 -0
- package/dist/plugin/vendor.server.d.ts.map +1 -0
- package/dist/plugin/vendor.server.js +16 -0
- package/dist/plugin/vendor.server.js.map +1 -0
- package/dist/plugin/worker/createWorker.d.ts +25 -7
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +108 -33
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +12 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +103 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts +0 -30
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +3 -17
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +12 -5
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +87 -84
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/types.d.ts +18 -0
- package/dist/plugin/worker/html/types.d.ts.map +1 -0
- package/dist/plugin/worker/html/types.js +1 -0
- package/dist/plugin/worker/registerLoaders.d.ts +9 -0
- package/dist/plugin/worker/registerLoaders.d.ts.map +1 -0
- package/dist/plugin/worker/registerLoaders.js +45 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts +4 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/handleRender.js +147 -0
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +47 -112
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +0 -30
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +29 -4
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +3 -3
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +73 -2
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +40 -3
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/sendMessage.d.ts +3 -0
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -0
- package/dist/plugin/worker/sendMessage.js +48 -0
- package/dist/plugin/worker/types.d.ts +218 -76
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/plugin/components.ts +1 -1
- package/plugin/config/autoDiscover/createGlobAutoDiscover.ts +29 -0
- package/plugin/config/autoDiscover/customWorkerFiles.ts +27 -0
- package/plugin/config/autoDiscover/pageAndPropFiles.ts +36 -0
- package/plugin/config/autoDiscover/resolveBuildPages.ts +98 -0
- package/plugin/config/defaults.tsx +38 -29
- package/plugin/config/getCondition.ts +7 -3
- package/plugin/config/getPaths.ts +1 -7
- package/plugin/config/index.ts +0 -1
- package/plugin/config/resolveAutoDiscover.ts +177 -0
- package/plugin/config/resolveOptions.ts +220 -118
- package/plugin/config/resolvePages.ts +5 -7
- package/plugin/config/resolveUrlOption.ts +43 -0
- package/plugin/config/resolveUserConfig.ts +116 -166
- package/plugin/copy.ts +39 -0
- package/plugin/css-collector-elements.tsx +21 -0
- package/plugin/css-collector.tsx +20 -53
- package/plugin/helpers/cleanObject.ts +50 -0
- package/plugin/helpers/collectBundleManifestCss.ts +160 -0
- package/plugin/helpers/collectManifestCss.ts +61 -0
- package/plugin/helpers/collectViteModuleGraphCss.ts +158 -0
- package/plugin/helpers/createCssProps.tsx +85 -0
- package/plugin/helpers/createEventHandler.ts +44 -0
- package/plugin/helpers/createHandler.ts +57 -126
- package/plugin/helpers/createRscStream.tsx +156 -0
- package/plugin/helpers/defaultFileWriter.ts +0 -0
- package/plugin/helpers/getBundleManifest.ts +42 -37
- package/plugin/helpers/getRouteFiles.ts +47 -0
- package/plugin/helpers/inputNormalizer.ts +16 -10
- package/plugin/helpers/metrics.ts +64 -0
- package/plugin/helpers/resolvePageAndProps.ts +81 -0
- package/plugin/helpers/serializeUserOptions.ts +209 -0
- package/plugin/helpers/stashReturnValue.ts +16 -0
- package/plugin/helpers/tryManifest.ts +35 -18
- package/plugin/html.tsx +14 -3
- package/plugin/index.ts +5 -2
- package/plugin/loader/createBuildLoader.ts +152 -47
- package/plugin/loader/css-loader.development.ts +157 -0
- package/plugin/loader/css-loader.production.ts +86 -0
- package/plugin/loader/index.ts +1 -0
- package/plugin/loader/plugin.ts +33 -0
- package/plugin/loader/react-loader.ts +109 -41
- package/plugin/loader/temporaryReferences.ts +3 -0
- package/plugin/moduleRefs.ts +11 -0
- package/plugin/plugin.client.ts +12 -0
- package/plugin/plugin.server.ts +25 -0
- package/plugin/plugin.ts +5 -9
- package/plugin/preserver/plugin.ts +1 -1
- package/plugin/react-client/index.ts +1 -12
- package/plugin/react-client/plugin.ts +70 -259
- package/plugin/react-client/server.ts +276 -0
- package/plugin/react-server/index.ts +1 -14
- package/plugin/react-server/plugin.ts +69 -220
- package/plugin/react-server/server.ts +128 -0
- package/plugin/react-static/collectHtmlWorkerContent.ts +120 -0
- package/plugin/react-static/collectRscContent.ts +77 -0
- package/plugin/react-static/configurePreviewServer.ts +68 -0
- package/plugin/react-static/fileWriter.ts +103 -0
- package/plugin/react-static/plugin.ts +308 -181
- package/plugin/react-static/renderPage.ts +151 -0
- package/plugin/react-static/renderPages.ts +154 -0
- package/plugin/react-static/renderStreams.ts +48 -0
- package/plugin/react-static/rscToHtmlStream.ts +85 -0
- package/plugin/react-static/streamHandler.ts +0 -0
- package/plugin/react-static/types.ts +10 -0
- package/plugin/resolvePage.ts +67 -57
- package/plugin/resolveProps.ts +148 -104
- package/plugin/root.ts +1 -1
- package/plugin/transformer/index.ts +2 -1
- package/plugin/transformer/plugin.client.ts +109 -0
- package/plugin/transformer/plugin.server.ts +98 -0
- package/plugin/transformer/plugin.ts +2 -115
- package/plugin/transformer/upgradeCssModuleCode.ts +42 -0
- package/plugin/types/css-tracking.ts +5 -0
- package/plugin/types/react-server-dom-esm.d.ts +54 -0
- package/plugin/types.ts +508 -97
- package/plugin/vendor.client.ts +12 -0
- package/plugin/vendor.server.ts +12 -0
- package/plugin/worker/createWorker.ts +158 -53
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +112 -0
- package/plugin/worker/html/html-worker.development.tsx +5 -75
- package/plugin/worker/html/html-worker.production.tsx +18 -7
- package/plugin/worker/html/messageHandler.tsx +126 -0
- package/plugin/worker/html/types.ts +19 -0
- package/plugin/worker/registerLoaders.ts +54 -0
- package/plugin/worker/rsc/handleRender.ts +180 -0
- package/plugin/worker/rsc/messageHandler.tsx +58 -132
- package/plugin/worker/rsc/rsc-worker.development.ts +49 -63
- package/plugin/worker/rsc/rsc-worker.production.ts +5 -5
- package/plugin/worker/rsc/state.ts +79 -2
- package/plugin/worker/sendMessage.ts +49 -0
- package/plugin/worker/types.ts +299 -100
- package/scripts/check-react-version.mjs +60 -48
- package/scripts/react+0.0.0-experimental-0ca8420f-20250504.patch +57 -0
- package/scripts/react-dom+0.0.0-experimental-0ca8420f-20250504.patch +819 -0
- package/scripts/{react-server-dom-esm+0.0.0-experimental-eda36a1c-20250228.patch → react-server-dom-esm+0.0.0-experimental-0ca8420f-20250504.patch} +1702 -2820
- package/tsconfig.json +7 -2
- package/dist/plugin/assertServerCondition.d.ts +0 -6
- package/dist/plugin/assertServerCondition.d.ts.map +0 -1
- package/dist/plugin/assertServerCondition.js +0 -13
- package/dist/plugin/checkFilesExist.d.ts +0 -3
- package/dist/plugin/checkFilesExist.d.ts.map +0 -1
- package/dist/plugin/checkFilesExist.js +0 -67
- package/dist/plugin/checkFilesExist.js.map +0 -1
- package/dist/plugin/collect-manifest-client-files.d.ts +0 -23
- package/dist/plugin/collect-manifest-client-files.d.ts.map +0 -1
- package/dist/plugin/collect-manifest-client-files.js +0 -131
- package/dist/plugin/collect-manifest-client-files.js.map +0 -1
- package/dist/plugin/config/getWorkerPath.d.ts +0 -2
- package/dist/plugin/config/getWorkerPath.d.ts.map +0 -1
- package/dist/plugin/config/getWorkerPath.js +0 -4
- package/dist/plugin/copy-dir.d.ts +0 -4
- package/dist/plugin/copy-dir.d.ts.map +0 -1
- package/dist/plugin/copy-dir.js +0 -25
- package/dist/plugin/copy-dir.js.map +0 -1
- package/dist/plugin/css-collector-inline.d.ts +0 -10
- package/dist/plugin/css-collector-inline.d.ts.map +0 -1
- package/dist/plugin/css-collector-inline.js +0 -55
- package/dist/plugin/css-collector-inline.js.map +0 -1
- package/dist/plugin/loader/css-loader.d.ts +0 -16
- package/dist/plugin/loader/css-loader.d.ts.map +0 -1
- package/dist/plugin/loader/css-loader.js +0 -70
- package/dist/plugin/loader/css-loader.js.map +0 -1
- package/dist/plugin/react-client/index.js.map +0 -1
- package/dist/plugin/react-server/index.js.map +0 -1
- package/dist/plugin/worker/html/renderPages.d.ts +0 -26
- package/dist/plugin/worker/html/renderPages.d.ts.map +0 -1
- package/dist/plugin/worker/html/renderPages.js +0 -241
- package/dist/plugin/worker/html/renderPages.js.map +0 -1
- package/plugin/assertServerCondition.ts +0 -12
- package/plugin/checkFilesExist.ts +0 -66
- package/plugin/collect-manifest-client-files.ts +0 -167
- package/plugin/config/getWorkerPath.ts +0 -5
- package/plugin/copy-dir.ts +0 -27
- package/plugin/css-collector-inline.tsx +0 -60
- package/plugin/helpers/createRscStream.ts +0 -109
- package/plugin/loader/css-loader.ts +0 -94
- package/plugin/worker/html/messageHandler.ts +0 -130
- package/plugin/worker/html/renderPages.ts +0 -293
- package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +0 -159
- package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +0 -12508
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { createRenderMetrics } from "../helpers/metrics.js";
|
|
2
|
+
import { resolvePageAndProps } from "../helpers/resolvePageAndProps.js";
|
|
3
|
+
import type { CreateHandlerOptions, RenderPageResult } from "../types.js";
|
|
4
|
+
import { renderStreams } from "./renderStreams.js";
|
|
5
|
+
import { collectHtmlWorkerContent } from "./collectHtmlWorkerContent.js";
|
|
6
|
+
import { collectRscContent } from "./collectRscContent.js";
|
|
7
|
+
|
|
8
|
+
export async function* renderPage(
|
|
9
|
+
handlerOptions: CreateHandlerOptions<unknown, React.ComponentType<unknown>>
|
|
10
|
+
): AsyncGenerator<RenderPageResult, void, unknown> {
|
|
11
|
+
if (!handlerOptions.pagePath) {
|
|
12
|
+
yield {
|
|
13
|
+
type: "skip",
|
|
14
|
+
};
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const metrics = createRenderMetrics(handlerOptions.route);
|
|
20
|
+
|
|
21
|
+
const pageAndPropsResult = await resolvePageAndProps(handlerOptions);
|
|
22
|
+
|
|
23
|
+
if (pageAndPropsResult.type === "error") {
|
|
24
|
+
yield {
|
|
25
|
+
type: "error",
|
|
26
|
+
error: pageAndPropsResult.error,
|
|
27
|
+
};
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (pageAndPropsResult.type === "skip") {
|
|
32
|
+
yield {
|
|
33
|
+
type: "skip",
|
|
34
|
+
};
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { PageComponent, pageProps } = pageAndPropsResult;
|
|
39
|
+
|
|
40
|
+
const newHandlerOptions = {
|
|
41
|
+
...handlerOptions,
|
|
42
|
+
PageComponent: PageComponent,
|
|
43
|
+
pageProps: pageProps,
|
|
44
|
+
} satisfies CreateHandlerOptions;
|
|
45
|
+
// Create streams with CSS files
|
|
46
|
+
const [rscFull, rscHeadless] = await renderStreams(newHandlerOptions);
|
|
47
|
+
|
|
48
|
+
// Handle stream creation errors
|
|
49
|
+
if (rscFull.type !== "success") {
|
|
50
|
+
yield {
|
|
51
|
+
type: "error",
|
|
52
|
+
error: new Error(
|
|
53
|
+
rscFull.type === "error"
|
|
54
|
+
? `Failed to create RSC full stream: ${
|
|
55
|
+
rscFull.error instanceof Error
|
|
56
|
+
? rscFull.error.message
|
|
57
|
+
: String(rscFull.error)
|
|
58
|
+
}`
|
|
59
|
+
: "RSC full stream creation was skipped"
|
|
60
|
+
),
|
|
61
|
+
};
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!rscFull.stream) {
|
|
66
|
+
yield {
|
|
67
|
+
type: "error",
|
|
68
|
+
error: new Error("RSC full stream is undefined"),
|
|
69
|
+
};
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (rscHeadless.type !== "success") {
|
|
74
|
+
yield {
|
|
75
|
+
type: "error",
|
|
76
|
+
error: new Error(
|
|
77
|
+
rscHeadless.type === "error"
|
|
78
|
+
? `Failed to create RSC headless stream: ${
|
|
79
|
+
rscHeadless.error instanceof Error
|
|
80
|
+
? rscHeadless.error.message
|
|
81
|
+
: String(rscHeadless.error)
|
|
82
|
+
}`
|
|
83
|
+
: "RSC headless stream creation was skipped"
|
|
84
|
+
),
|
|
85
|
+
};
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!rscHeadless.stream) {
|
|
90
|
+
yield {
|
|
91
|
+
type: "error",
|
|
92
|
+
error: new Error("RSC headless stream is undefined"),
|
|
93
|
+
};
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Collect HTML and RSC content
|
|
98
|
+
const [
|
|
99
|
+
{ stream: rscStream, metrics: rscMetrics },
|
|
100
|
+
{ stream: htmlStream, metrics: htmlMetrics },
|
|
101
|
+
] = await Promise.all([
|
|
102
|
+
collectRscContent(rscHeadless.stream, handlerOptions),
|
|
103
|
+
collectHtmlWorkerContent(rscFull.stream, handlerOptions),
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
// Update metrics
|
|
107
|
+
metrics.htmlSizes.set(handlerOptions.route, htmlMetrics.bytes);
|
|
108
|
+
metrics.rscSizes.set(handlerOptions.route, rscMetrics.bytes);
|
|
109
|
+
metrics.htmlSize = htmlMetrics.bytes;
|
|
110
|
+
metrics.rscSize = rscMetrics.bytes;
|
|
111
|
+
|
|
112
|
+
// Combine metrics from both streams
|
|
113
|
+
metrics.streamMetrics = {
|
|
114
|
+
...htmlMetrics,
|
|
115
|
+
chunks: Math.max(htmlMetrics.chunks, rscMetrics.chunks),
|
|
116
|
+
bytes: Math.max(htmlMetrics.bytes, rscMetrics.bytes),
|
|
117
|
+
duration: Math.max(htmlMetrics.duration, rscMetrics.duration),
|
|
118
|
+
startTime: Math.min(htmlMetrics.startTime, rscMetrics.startTime),
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
metrics.processingTime = metrics.streamMetrics.duration;
|
|
122
|
+
metrics.chunks = metrics.streamMetrics.chunks;
|
|
123
|
+
metrics.chunkRate =
|
|
124
|
+
metrics.streamMetrics.chunks / (metrics.processingTime / 1000);
|
|
125
|
+
|
|
126
|
+
// Emit metrics via callback
|
|
127
|
+
if (handlerOptions.onMetrics) {
|
|
128
|
+
handlerOptions.onMetrics(metrics);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
yield {
|
|
132
|
+
type: "success",
|
|
133
|
+
html: htmlStream,
|
|
134
|
+
rsc: rscStream,
|
|
135
|
+
metrics: {
|
|
136
|
+
rscFull: htmlMetrics,
|
|
137
|
+
rscHeadless: rscMetrics,
|
|
138
|
+
},
|
|
139
|
+
} as const;
|
|
140
|
+
} catch (err) {
|
|
141
|
+
yield {
|
|
142
|
+
type: "error",
|
|
143
|
+
error:
|
|
144
|
+
err instanceof Error
|
|
145
|
+
? err
|
|
146
|
+
: typeof err === "string"
|
|
147
|
+
? new Error(err)
|
|
148
|
+
: (err as Error),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* renderPages.ts
|
|
3
|
+
*
|
|
4
|
+
* PURPOSE: Processes React Server Components (RSC) streams and writes output files
|
|
5
|
+
*
|
|
6
|
+
* This module:
|
|
7
|
+
* 1. Creates RSC and HTML streams for each route
|
|
8
|
+
* 2. Pipes RSC stream directly to .rsc files
|
|
9
|
+
* 3. Transforms RSC to HTML via worker and pipes to .html files
|
|
10
|
+
* 4. Collects metrics and handles errors
|
|
11
|
+
*/
|
|
12
|
+
import { createRenderMetrics } from "../helpers/metrics.js";
|
|
13
|
+
import { renderPage } from "./renderPage.js";
|
|
14
|
+
import { PassThrough } from "node:stream";
|
|
15
|
+
import type { StreamMetrics, RenderPagesResult, AutoDiscoveredFiles, CssContent, MultiPageHandlerOptions } from "../types.js";
|
|
16
|
+
|
|
17
|
+
export async function* renderPages(
|
|
18
|
+
autoDiscoveredFiles: AutoDiscoveredFiles,
|
|
19
|
+
handlerOptions: MultiPageHandlerOptions,
|
|
20
|
+
cssFilesByPage: Map<string, Map<string, CssContent>>,
|
|
21
|
+
): AsyncGenerator<RenderPagesResult, RenderPagesResult, unknown> {
|
|
22
|
+
const routes = Array.from(autoDiscoveredFiles.urlMap.keys());
|
|
23
|
+
const completedRoutes = new Set<string>();
|
|
24
|
+
const failedRoutes = new Set<string>();
|
|
25
|
+
const baseMetrics = createRenderMetrics(routes[0]);
|
|
26
|
+
const results = new Map<
|
|
27
|
+
string,
|
|
28
|
+
{
|
|
29
|
+
html: PassThrough;
|
|
30
|
+
rsc: PassThrough;
|
|
31
|
+
metrics: {
|
|
32
|
+
rscFull: StreamMetrics;
|
|
33
|
+
rscHeadless: StreamMetrics;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
>();
|
|
37
|
+
const errors: Error[] = [];
|
|
38
|
+
|
|
39
|
+
if (!autoDiscoveredFiles.urlMap) {
|
|
40
|
+
throw new Error("No urlMap provided to renderPages");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const route of routes) {
|
|
44
|
+
const { page, props } = autoDiscoveredFiles.urlMap.get(route) || {};
|
|
45
|
+
if (!page) continue;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const pageRenderer = renderPage({
|
|
49
|
+
...handlerOptions,
|
|
50
|
+
route,
|
|
51
|
+
pagePath: page,
|
|
52
|
+
propsPath: props,
|
|
53
|
+
cssFiles: cssFilesByPage.get(route) ?? new Map(),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
for await (const result of pageRenderer) {
|
|
57
|
+
if (result.type === "skip") continue;
|
|
58
|
+
|
|
59
|
+
if (result.type === "error") {
|
|
60
|
+
failedRoutes.add(route);
|
|
61
|
+
errors.push(result.error);
|
|
62
|
+
yield {
|
|
63
|
+
type: "error",
|
|
64
|
+
error: result.error,
|
|
65
|
+
failedRoutes,
|
|
66
|
+
completedRoutes,
|
|
67
|
+
htmlSizes: baseMetrics.htmlSizes,
|
|
68
|
+
rscSizes: baseMetrics.rscSizes,
|
|
69
|
+
streamMetrics: baseMetrics.streamMetrics,
|
|
70
|
+
results,
|
|
71
|
+
} as const;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (result.type === "success") {
|
|
76
|
+
completedRoutes.add(route);
|
|
77
|
+
results.set(route, {
|
|
78
|
+
html: result.html,
|
|
79
|
+
rsc: result.rsc,
|
|
80
|
+
metrics: result.metrics,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Update metrics
|
|
84
|
+
baseMetrics.htmlSizes.set(route, result.metrics.rscFull.bytes);
|
|
85
|
+
baseMetrics.rscSizes.set(route, result.metrics.rscHeadless.bytes);
|
|
86
|
+
baseMetrics.streamMetrics = {
|
|
87
|
+
...baseMetrics.streamMetrics,
|
|
88
|
+
chunks: Math.max(
|
|
89
|
+
baseMetrics.streamMetrics.chunks,
|
|
90
|
+
result.metrics.rscFull.chunks
|
|
91
|
+
),
|
|
92
|
+
bytes: Math.max(
|
|
93
|
+
baseMetrics.streamMetrics.bytes,
|
|
94
|
+
result.metrics.rscFull.bytes
|
|
95
|
+
),
|
|
96
|
+
duration: Math.max(
|
|
97
|
+
baseMetrics.streamMetrics.duration,
|
|
98
|
+
result.metrics.rscFull.duration
|
|
99
|
+
),
|
|
100
|
+
startTime: Math.min(
|
|
101
|
+
baseMetrics.streamMetrics.startTime,
|
|
102
|
+
result.metrics.rscFull.startTime
|
|
103
|
+
),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
yield {
|
|
107
|
+
type: "success",
|
|
108
|
+
completedRoutes,
|
|
109
|
+
htmlSizes: baseMetrics.htmlSizes,
|
|
110
|
+
rscSizes: baseMetrics.rscSizes,
|
|
111
|
+
streamMetrics: baseMetrics.streamMetrics,
|
|
112
|
+
results,
|
|
113
|
+
} as const;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} catch (err) {
|
|
117
|
+
failedRoutes.add(route);
|
|
118
|
+
errors.push(err instanceof Error ? err : new Error(String(err)));
|
|
119
|
+
yield {
|
|
120
|
+
type: "error",
|
|
121
|
+
error: err instanceof Error ? err : new Error(String(err)),
|
|
122
|
+
failedRoutes,
|
|
123
|
+
completedRoutes,
|
|
124
|
+
htmlSizes: baseMetrics.htmlSizes,
|
|
125
|
+
rscSizes: baseMetrics.rscSizes,
|
|
126
|
+
streamMetrics: baseMetrics.streamMetrics,
|
|
127
|
+
results,
|
|
128
|
+
} as const;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (failedRoutes.size > 0) {
|
|
133
|
+
return {
|
|
134
|
+
type: "error",
|
|
135
|
+
error: errors[0],
|
|
136
|
+
failedRoutes,
|
|
137
|
+
completedRoutes,
|
|
138
|
+
htmlSizes: baseMetrics.htmlSizes,
|
|
139
|
+
rscSizes: baseMetrics.rscSizes,
|
|
140
|
+
streamMetrics: baseMetrics.streamMetrics,
|
|
141
|
+
results,
|
|
142
|
+
} as const;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
type: "success",
|
|
147
|
+
completedRoutes,
|
|
148
|
+
failedRoutes: undefined,
|
|
149
|
+
htmlSizes: baseMetrics.htmlSizes,
|
|
150
|
+
rscSizes: baseMetrics.rscSizes,
|
|
151
|
+
streamMetrics: baseMetrics.streamMetrics,
|
|
152
|
+
results,
|
|
153
|
+
} as const;
|
|
154
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* renderStreams.ts
|
|
3
|
+
*
|
|
4
|
+
* PURPOSE: Creates specialized streams for React Server Components (RSC) rendering
|
|
5
|
+
*
|
|
6
|
+
* This module:
|
|
7
|
+
* 1. Creates RSC stream (React.Fragment wrapper) for client-side navigation
|
|
8
|
+
* - This stream is saved to .rsc files and used when navigating between pages
|
|
9
|
+
* - The Fragment wrapper allows the browser to update only the necessary parts of the DOM
|
|
10
|
+
* - This is more efficient than reloading the entire HTML document
|
|
11
|
+
* 2. Creates Document stream (Html wrapper) for initial page loads
|
|
12
|
+
* - This stream includes the full HTML document structure
|
|
13
|
+
* - Used for the initial page load when the browser needs the complete HTML
|
|
14
|
+
* 3. Sets up stream handlers with proper wrappers and options
|
|
15
|
+
* 4. Returns streams for renderPages to process
|
|
16
|
+
*/
|
|
17
|
+
import { createHandler } from "../helpers/createHandler.js";
|
|
18
|
+
import type {
|
|
19
|
+
CreateHandlerOptions,
|
|
20
|
+
} from "../types.js";
|
|
21
|
+
import React from "react";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates handlers for both document and RSC streams
|
|
25
|
+
*
|
|
26
|
+
* @param handler The handler options for creating streams
|
|
27
|
+
* @param options The render options
|
|
28
|
+
* @returns A tuple containing the document worker result and RSC direct result
|
|
29
|
+
*/
|
|
30
|
+
export function renderStreams(
|
|
31
|
+
handler: CreateHandlerOptions,
|
|
32
|
+
) {
|
|
33
|
+
return Promise.all([
|
|
34
|
+
/**
|
|
35
|
+
* This stream goes to the document worker for client side rendering with full HTML structure,
|
|
36
|
+
* links are already bubbled up in the static document which required us
|
|
37
|
+
* to include the head in the stream as well
|
|
38
|
+
*/
|
|
39
|
+
createHandler(handler),
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* This stream is saved to index.rsc file (if configured) and can be used
|
|
43
|
+
* for navigating to pages (without the Html wrapper, but does contain
|
|
44
|
+
* css/head information that can bubble up to the browser's dom)
|
|
45
|
+
*/
|
|
46
|
+
createHandler({...handler, Html: React.Fragment}),
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rscToHtmlStream.ts
|
|
3
|
+
*
|
|
4
|
+
* PURPOSE: Transforms RSC stream to HTML stream via worker communication
|
|
5
|
+
*
|
|
6
|
+
* This module:
|
|
7
|
+
* 1. Takes RSC stream as input
|
|
8
|
+
* 2. Communicates with worker to transform RSC to HTML
|
|
9
|
+
* 3. Returns a writeable stream of HTML content
|
|
10
|
+
* 4. Handles worker message processing and error cases
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { Transform } from "node:stream";
|
|
14
|
+
import type {
|
|
15
|
+
HtmlWorkerInputMessage,
|
|
16
|
+
} from "../worker/types.js";
|
|
17
|
+
import type { CreateHandlerOptions } from "../types.js";
|
|
18
|
+
import type { Worker } from "node:worker_threads";
|
|
19
|
+
import type { ViteDevServer } from "vite";
|
|
20
|
+
|
|
21
|
+
export type RscToHtmlOptions = Pick<
|
|
22
|
+
CreateHandlerOptions,
|
|
23
|
+
| "worker"
|
|
24
|
+
| "route"
|
|
25
|
+
| "moduleRootPath"
|
|
26
|
+
| "moduleBaseURL"
|
|
27
|
+
| "pipeableStreamOptions"
|
|
28
|
+
| "build"
|
|
29
|
+
| "cssFiles"
|
|
30
|
+
| "projectRoot"
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates a transform stream that converts RSC content to HTML via worker
|
|
35
|
+
*
|
|
36
|
+
* @param options The options for RSC to HTML transformation
|
|
37
|
+
* @returns A transform stream that outputs HTML content
|
|
38
|
+
*/
|
|
39
|
+
export function createRscToHtmlStream(options: RscToHtmlOptions): Transform {
|
|
40
|
+
const worker = options.worker as Worker | ViteDevServer;
|
|
41
|
+
if (!("postMessage" in worker)) {
|
|
42
|
+
throw new Error("Worker is not a valid worker");
|
|
43
|
+
}
|
|
44
|
+
let sequence = 0;
|
|
45
|
+
const stream = new Transform({
|
|
46
|
+
transform(chunk, _encoding, callback) {
|
|
47
|
+
try {
|
|
48
|
+
worker.postMessage({
|
|
49
|
+
type: "RSC_CHUNK",
|
|
50
|
+
id: options.route,
|
|
51
|
+
chunk,
|
|
52
|
+
sequence: sequence++,
|
|
53
|
+
} satisfies HtmlWorkerInputMessage);
|
|
54
|
+
callback();
|
|
55
|
+
} catch (error) {
|
|
56
|
+
callback(error as Error);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
flush(callback) {
|
|
60
|
+
try {
|
|
61
|
+
worker.postMessage({
|
|
62
|
+
type: "RSC_END",
|
|
63
|
+
id: options.route,
|
|
64
|
+
} satisfies HtmlWorkerInputMessage);
|
|
65
|
+
callback();
|
|
66
|
+
} catch (error) {
|
|
67
|
+
callback(error as Error);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Signal ready to receive HTML
|
|
73
|
+
worker.postMessage({
|
|
74
|
+
type: "ROUTE_READY",
|
|
75
|
+
id: options.route,
|
|
76
|
+
// replace server with client
|
|
77
|
+
moduleRootPath: options.moduleRootPath,
|
|
78
|
+
moduleBaseURL: options.moduleBaseURL,
|
|
79
|
+
cssFiles: options.cssFiles,
|
|
80
|
+
pipeableStreamOptions: options.pipeableStreamOptions,
|
|
81
|
+
projectRoot: options.projectRoot,
|
|
82
|
+
} satisfies HtmlWorkerInputMessage);
|
|
83
|
+
|
|
84
|
+
return stream;
|
|
85
|
+
}
|
|
File without changes
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import type { FileWriteEvent } from "../types.js";
|
|
2
|
+
|
|
1
3
|
export type ReactStaticPluginOptions = {
|
|
2
4
|
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type ReactStaticEvent = FileWriteEvent | {
|
|
8
|
+
type: 'build.start';
|
|
9
|
+
data: {
|
|
10
|
+
pages: string[];
|
|
11
|
+
files: Array<[string, { page: string; props?: string }]>;
|
|
12
|
+
};
|
|
3
13
|
};
|
package/plugin/resolvePage.ts
CHANGED
|
@@ -1,74 +1,84 @@
|
|
|
1
|
-
import { stashedPages } from "./config/resolvePages.js";
|
|
2
1
|
|
|
3
|
-
type ResolvePageOptions = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exportName: string;
|
|
2
|
+
type ResolvePageOptions<N extends string> = {
|
|
3
|
+
id: string;
|
|
4
|
+
exportName: N;
|
|
5
|
+
loader: (id: string) => Promise<any>;
|
|
8
6
|
};
|
|
9
7
|
|
|
10
|
-
type ResolvePageResult =
|
|
11
|
-
| { type: "success";
|
|
8
|
+
type ResolvePageResult<T, N extends string> =
|
|
9
|
+
| { type: "success"; Page: T; module: { [key in N]: T } }
|
|
12
10
|
| { type: "error"; error: Error }
|
|
13
11
|
| { type: "skip" };
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Resolves a page component from a module.
|
|
15
|
+
*
|
|
16
|
+
* During development (ssrLoadModule):
|
|
17
|
+
* - Real modules have exports available directly on the module object
|
|
18
|
+
* - Virtual modules have exports stored in temporaryReferences
|
|
19
|
+
*
|
|
20
|
+
* @param options.id - The module ID to resolve
|
|
21
|
+
* @param options.exportName - The name of the export to resolve (e.g. 'Page')
|
|
22
|
+
* @param options.loader - The loader function to use for loading the module
|
|
23
|
+
*
|
|
24
|
+
* @returns A result object containing:
|
|
25
|
+
* - type: "success" | "error" | "skip"
|
|
26
|
+
* - Page: The resolved page component if successful
|
|
27
|
+
* - error: Error message if failed
|
|
28
|
+
*/
|
|
29
|
+
export const resolvePage = async <T, N extends string>({
|
|
30
|
+
id,
|
|
19
31
|
exportName,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!pageModule) {
|
|
29
|
-
return {
|
|
30
|
-
type: "error",
|
|
31
|
-
error: new Error(`pageModule is ${typeof pageModule}`),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const keys =
|
|
35
|
-
typeof pageModule === "object" && pageModule != null
|
|
36
|
-
? Object.keys(pageModule)
|
|
37
|
-
: [];
|
|
38
|
-
const found = keys.find((v) => v === exportName || v === url || v === path);
|
|
39
|
-
if (found) {
|
|
40
|
-
if (typeof pageModule[found] === "function") {
|
|
32
|
+
loader,
|
|
33
|
+
}: ResolvePageOptions<N>): Promise<ResolvePageResult<T, N>> => {
|
|
34
|
+
// Check if this is a stashed page that needs special handling
|
|
35
|
+
const pageLoadResult = await (async (): Promise<
|
|
36
|
+
| { type: "success"; key: string; module: { [key in N]: T } }
|
|
37
|
+
| { type: "error"; error: Error; module?: never }
|
|
38
|
+
> => {
|
|
39
|
+
try {
|
|
41
40
|
return {
|
|
42
41
|
type: "success",
|
|
43
|
-
key:
|
|
44
|
-
|
|
42
|
+
key: id,
|
|
43
|
+
module: await loader(id),
|
|
45
44
|
};
|
|
46
|
-
}
|
|
47
|
-
if (
|
|
48
|
-
typeof pageModule === "object" &&
|
|
49
|
-
pageModule != null &&
|
|
50
|
-
Object.keys(pageModule).includes("type")
|
|
51
|
-
)
|
|
52
|
-
return pageModule as ResolvePageResult;
|
|
45
|
+
} catch (error) {
|
|
53
46
|
return {
|
|
54
47
|
type: "error",
|
|
55
|
-
|
|
56
|
-
error: pageModule[found]["error"],
|
|
48
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
57
49
|
};
|
|
58
50
|
}
|
|
51
|
+
})();
|
|
52
|
+
|
|
53
|
+
if (pageLoadResult.type !== "success") {
|
|
54
|
+
return pageLoadResult;
|
|
55
|
+
}
|
|
56
|
+
const { module } = pageLoadResult;
|
|
57
|
+
const Page = module[exportName as N];
|
|
58
|
+
if (module instanceof Error) {
|
|
59
|
+
return {
|
|
60
|
+
type: "error",
|
|
61
|
+
error: module,
|
|
62
|
+
};
|
|
63
|
+
} else if (!(exportName in module)) {
|
|
64
|
+
return {
|
|
65
|
+
type: "error",
|
|
66
|
+
error: new Error(`Export ${exportName} not found in module ${id}`),
|
|
67
|
+
};
|
|
68
|
+
} else if (!Page) {
|
|
69
|
+
return {
|
|
70
|
+
type: "error",
|
|
71
|
+
error: new Error(`Export ${exportName} is null or undefined in module ${id}`),
|
|
72
|
+
};
|
|
73
|
+
} else if (Page instanceof Error) {
|
|
74
|
+
return {
|
|
75
|
+
type: "error",
|
|
76
|
+
error: Page,
|
|
77
|
+
};
|
|
59
78
|
}
|
|
60
|
-
if (keys.includes("type")) return pageModule as ResolvePageResult;
|
|
61
79
|
return {
|
|
62
|
-
type: "
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
typeof pageModule === "object" && pageModule != null
|
|
66
|
-
? keys.length
|
|
67
|
-
? "Available exports: " + keys.join(", ")
|
|
68
|
-
: "The object was defined but has no properties. \"" + JSON.stringify(pageModule) + "\""
|
|
69
|
-
: "typeof pageModule =" + typeof pageModule
|
|
70
|
-
}`,
|
|
71
|
-
{ cause: pageModule }
|
|
72
|
-
),
|
|
80
|
+
type: "success",
|
|
81
|
+
Page,
|
|
82
|
+
module: module as { [key in N]: T },
|
|
73
83
|
};
|
|
74
|
-
}
|
|
84
|
+
};
|