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,160 @@
|
|
|
1
|
+
import type { CreateHandlerOptions, CssContent } from "../types.js";
|
|
2
|
+
import { createCssProps } from "./createCssProps.js";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
|
|
6
|
+
type CssCollectionOptions = Pick<
|
|
7
|
+
CreateHandlerOptions<unknown, React.ComponentType<unknown>>,
|
|
8
|
+
| "projectRoot"
|
|
9
|
+
| "build"
|
|
10
|
+
| "moduleBaseURL"
|
|
11
|
+
| "moduleBasePath"
|
|
12
|
+
| "moduleRootPath"
|
|
13
|
+
| "css"
|
|
14
|
+
| "cssFiles"
|
|
15
|
+
| "manifest"
|
|
16
|
+
>
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Recursively collects CSS files from a bundle manifest
|
|
20
|
+
*/
|
|
21
|
+
async function collectCssFromModule(
|
|
22
|
+
moduleKey: string,
|
|
23
|
+
manifest: Record<string, any>,
|
|
24
|
+
cssMap: Map<string, CssContent>,
|
|
25
|
+
options: CssCollectionOptions
|
|
26
|
+
): Promise<void> {
|
|
27
|
+
const mod = manifest[moduleKey];
|
|
28
|
+
if (!mod) return;
|
|
29
|
+
|
|
30
|
+
// Handle CSS imports
|
|
31
|
+
if (mod.imports) {
|
|
32
|
+
for (const importPath of mod.imports) {
|
|
33
|
+
if (importPath === moduleKey) continue;
|
|
34
|
+
if (importPath) {
|
|
35
|
+
const cssEntry = manifest[importPath];
|
|
36
|
+
// Handle CSS array
|
|
37
|
+
if (Array.isArray(cssEntry.css)) {
|
|
38
|
+
for (const cssFile of cssEntry.css) {
|
|
39
|
+
if (cssMap.has(cssFile)) continue;
|
|
40
|
+
const file = join(
|
|
41
|
+
options.projectRoot,
|
|
42
|
+
options.build.outDir,
|
|
43
|
+
options.build.static,
|
|
44
|
+
cssFile
|
|
45
|
+
);
|
|
46
|
+
const code =
|
|
47
|
+
"source" in cssEntry && typeof cssEntry.source === "string"
|
|
48
|
+
? cssEntry.source
|
|
49
|
+
: await readFile(file, "utf-8");
|
|
50
|
+
cssMap.set(
|
|
51
|
+
importPath,
|
|
52
|
+
createCssProps({
|
|
53
|
+
id: cssFile,
|
|
54
|
+
css: options.css,
|
|
55
|
+
code,
|
|
56
|
+
moduleBaseURL: options.moduleBaseURL,
|
|
57
|
+
moduleBasePath: options.moduleBasePath,
|
|
58
|
+
moduleRootPath: options.moduleRootPath,
|
|
59
|
+
projectRoot: options.projectRoot,
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Recursively process non-CSS imports
|
|
66
|
+
await collectCssFromModule(importPath, manifest, cssMap, options);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Handle direct CSS files
|
|
71
|
+
if (mod.css) {
|
|
72
|
+
for (const cssFile of mod.css) {
|
|
73
|
+
if (cssMap.has(cssFile)) {
|
|
74
|
+
continue
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const file = join(
|
|
78
|
+
options.projectRoot,
|
|
79
|
+
options.build.outDir,
|
|
80
|
+
options.build.server,
|
|
81
|
+
cssFile
|
|
82
|
+
);
|
|
83
|
+
const code =
|
|
84
|
+
"code" in manifest[cssFile] &&
|
|
85
|
+
typeof manifest[cssFile].code === "string"
|
|
86
|
+
? manifest[cssFile].code
|
|
87
|
+
: await readFile(file, "utf-8");
|
|
88
|
+
cssMap.set(
|
|
89
|
+
moduleKey,
|
|
90
|
+
createCssProps({
|
|
91
|
+
id: cssFile,
|
|
92
|
+
css: options.css,
|
|
93
|
+
code,
|
|
94
|
+
moduleBaseURL: options.moduleBaseURL,
|
|
95
|
+
moduleBasePath: options.moduleBasePath,
|
|
96
|
+
moduleRootPath: options.moduleRootPath,
|
|
97
|
+
projectRoot: options.projectRoot,
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
} catch {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Collects CSS files from a bundle manifest using async generators
|
|
109
|
+
*/
|
|
110
|
+
export async function collectBundleManifestCss(
|
|
111
|
+
pages: string[] | string,
|
|
112
|
+
options: CssCollectionOptions,
|
|
113
|
+
_bundleManifest: Record<string, any>
|
|
114
|
+
): Promise<Map<string, CssContent>> {
|
|
115
|
+
const cssMap = new Map<string, CssContent>();
|
|
116
|
+
if (options.cssFiles) {
|
|
117
|
+
for (const [key, value] of options.cssFiles.entries()) {
|
|
118
|
+
if (typeof value !== "string") {
|
|
119
|
+
cssMap.set(key, value);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const file = join(
|
|
123
|
+
options.projectRoot,
|
|
124
|
+
options.build.outDir,
|
|
125
|
+
options.build.server,
|
|
126
|
+
value
|
|
127
|
+
);
|
|
128
|
+
const code =
|
|
129
|
+
options.manifest != null &&
|
|
130
|
+
value in options.manifest &&
|
|
131
|
+
"code" in options.manifest[value] &&
|
|
132
|
+
typeof options.manifest[value].code === "string"
|
|
133
|
+
? options.manifest[value].code
|
|
134
|
+
: await readFile(file, "utf-8");
|
|
135
|
+
cssMap.set(
|
|
136
|
+
file,
|
|
137
|
+
createCssProps({
|
|
138
|
+
id: file,
|
|
139
|
+
code: code,
|
|
140
|
+
css: options.css,
|
|
141
|
+
moduleBaseURL: options.moduleBaseURL,
|
|
142
|
+
moduleBasePath: options.moduleBasePath,
|
|
143
|
+
moduleRootPath: options.moduleRootPath,
|
|
144
|
+
projectRoot: options.projectRoot,
|
|
145
|
+
})
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Process page and props modules
|
|
151
|
+
if (typeof pages === "string") {
|
|
152
|
+
await collectCssFromModule(pages, options.manifest, cssMap, options);
|
|
153
|
+
} else if (Array.isArray(pages)) {
|
|
154
|
+
for (const _id of pages) {
|
|
155
|
+
await collectCssFromModule(_id, options.manifest, cssMap, options);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return cssMap;
|
|
160
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Manifest } from "vite";
|
|
2
|
+
import type { ResolvedUserOptions } from "../types.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Collects CSS file paths from a manifest by walking through imports starting from a given file
|
|
6
|
+
*/
|
|
7
|
+
export function collectManifestCss(
|
|
8
|
+
manifest: Manifest,
|
|
9
|
+
startFile: string | string[],
|
|
10
|
+
userOptions: Pick<ResolvedUserOptions, "normalizer">
|
|
11
|
+
): Record<string, string> {
|
|
12
|
+
const cssInputs: Record<string, string> = {};
|
|
13
|
+
const visited = new Set<string>();
|
|
14
|
+
|
|
15
|
+
// Convert startFile to array and ensure we have valid file paths
|
|
16
|
+
const toVisit = Array.isArray(startFile) ? startFile : [startFile];
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
while (toVisit.length > 0) {
|
|
20
|
+
const currentFile = toVisit.pop()!;
|
|
21
|
+
if (visited.has(currentFile)) continue;
|
|
22
|
+
visited.add(currentFile);
|
|
23
|
+
|
|
24
|
+
const fileInfo = manifest[currentFile];
|
|
25
|
+
if (!fileInfo) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Add CSS files from the css property
|
|
30
|
+
if (fileInfo.css) {
|
|
31
|
+
for (const cssFile of fileInfo.css) {
|
|
32
|
+
const [keyNormalized, valueNormalized] = userOptions.normalizer(cssFile);
|
|
33
|
+
cssInputs[keyNormalized] = valueNormalized;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Add imports to visit
|
|
38
|
+
if (fileInfo.imports) {
|
|
39
|
+
for (const importPath of fileInfo.imports) {
|
|
40
|
+
// Skip if we've already visited this import
|
|
41
|
+
if (visited.has(importPath)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Add the import to visit
|
|
46
|
+
toVisit.push(importPath);
|
|
47
|
+
|
|
48
|
+
// Check if the imported file has CSS
|
|
49
|
+
const importedFile = manifest[importPath];
|
|
50
|
+
if (importedFile?.css) {
|
|
51
|
+
for (const cssFile of importedFile.css) {
|
|
52
|
+
const [keyNormalized, valueNormalized] = userOptions.normalizer(cssFile);
|
|
53
|
+
cssInputs[keyNormalized] = valueNormalized;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return cssInputs;
|
|
61
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { EnvironmentModuleGraph, ModuleGraph } from "vite";
|
|
2
|
+
import type { CreateHandlerOptions, CssContent } from "../types.js";
|
|
3
|
+
import { createCssProps } from "./createCssProps.js";
|
|
4
|
+
|
|
5
|
+
type CollectViteModuleGraphCssResult =
|
|
6
|
+
| {
|
|
7
|
+
type: "success";
|
|
8
|
+
cssFiles: Map<string, CssContent>;
|
|
9
|
+
error?: never;
|
|
10
|
+
metrics: {
|
|
11
|
+
cssFiles: number;
|
|
12
|
+
processing: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
| {
|
|
16
|
+
type: "error";
|
|
17
|
+
error: Error;
|
|
18
|
+
cssFiles?: never;
|
|
19
|
+
metrics: {
|
|
20
|
+
cssFiles: number;
|
|
21
|
+
processing: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
type: "skip";
|
|
26
|
+
cssFiles?: never;
|
|
27
|
+
error?: never;
|
|
28
|
+
metrics?: never;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export async function collectViteModuleGraphCss<
|
|
32
|
+
InlineCSS extends boolean | undefined = undefined
|
|
33
|
+
>({
|
|
34
|
+
moduleGraph,
|
|
35
|
+
pagePath,
|
|
36
|
+
onCss,
|
|
37
|
+
loader,
|
|
38
|
+
parentUrl,
|
|
39
|
+
moduleBaseURL,
|
|
40
|
+
moduleBasePath,
|
|
41
|
+
moduleRootPath,
|
|
42
|
+
projectRoot,
|
|
43
|
+
css,
|
|
44
|
+
}: Pick<
|
|
45
|
+
CreateHandlerOptions<InlineCSS>,
|
|
46
|
+
| "pagePath"
|
|
47
|
+
| "moduleBaseURL"
|
|
48
|
+
| "moduleBasePath"
|
|
49
|
+
| "moduleRootPath"
|
|
50
|
+
| "projectRoot"
|
|
51
|
+
| "css"
|
|
52
|
+
| "loader"
|
|
53
|
+
> & {
|
|
54
|
+
moduleGraph: ModuleGraph | EnvironmentModuleGraph;
|
|
55
|
+
onCss?: (cssContent: CssContent, parentUrl: string) => void;
|
|
56
|
+
parentUrl?: string;
|
|
57
|
+
}): Promise<CollectViteModuleGraphCssResult> {
|
|
58
|
+
if (!pagePath) return { type: "skip" };
|
|
59
|
+
|
|
60
|
+
const cssFiles = new Map<string, CssContent>();
|
|
61
|
+
const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);
|
|
62
|
+
if (!pageModule) {
|
|
63
|
+
return { type: "skip" };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const seen = new Set<string>();
|
|
67
|
+
const processing = new Set<string>();
|
|
68
|
+
|
|
69
|
+
const walkModule = async (mod: any) => {
|
|
70
|
+
if (!mod?.id) {
|
|
71
|
+
// Module has no id
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (seen.has(mod.id)) {
|
|
76
|
+
// Already processed module
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (processing.has(mod.id)) {
|
|
81
|
+
// Circular dependency detected for module
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
processing.add(mod.id);
|
|
86
|
+
// Processing module
|
|
87
|
+
if (mod.id.endsWith(".css")) {
|
|
88
|
+
const string = await loader(mod.id + "?inline").then(
|
|
89
|
+
(m) => m?.['default'] ?? ""
|
|
90
|
+
);
|
|
91
|
+
if (typeof string !== "string") {
|
|
92
|
+
throw new Error(`CSS module ${mod.id}?inline did not return a string`);
|
|
93
|
+
} else if (string === "") {
|
|
94
|
+
throw new Error(`CSS module ${mod.id}?inline returned an empty string`);
|
|
95
|
+
}
|
|
96
|
+
const cssContent = createCssProps({
|
|
97
|
+
id: mod?.url,
|
|
98
|
+
code: string,
|
|
99
|
+
moduleBaseURL: moduleBaseURL,
|
|
100
|
+
moduleBasePath: moduleBasePath,
|
|
101
|
+
moduleRootPath: moduleRootPath,
|
|
102
|
+
projectRoot: projectRoot,
|
|
103
|
+
css: css,
|
|
104
|
+
});
|
|
105
|
+
cssFiles.set(mod?.url, cssContent);
|
|
106
|
+
onCss?.(cssContent, parentUrl ?? pagePath);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (mod.importedModules) {
|
|
110
|
+
// Processing imports for module
|
|
111
|
+
const importedModules = Array.from(mod.importedModules);
|
|
112
|
+
// Found imported modules
|
|
113
|
+
for (const importedMod of importedModules) {
|
|
114
|
+
if (typeof importedMod === "object" && importedMod != null) {
|
|
115
|
+
if (
|
|
116
|
+
"id" in importedMod &&
|
|
117
|
+
importedMod.id &&
|
|
118
|
+
typeof importedMod.id === "string"
|
|
119
|
+
) {
|
|
120
|
+
await walkModule(importedMod);
|
|
121
|
+
} else {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`Imported module has no id`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`Imported module is not an object`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
processing.delete(mod.id);
|
|
135
|
+
seen.add(mod.id);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
await walkModule(pageModule);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
return {
|
|
142
|
+
type: "error",
|
|
143
|
+
error: error as Error,
|
|
144
|
+
metrics: {
|
|
145
|
+
cssFiles: cssFiles.size,
|
|
146
|
+
processing: processing.size,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
type: "success",
|
|
152
|
+
cssFiles,
|
|
153
|
+
metrics: {
|
|
154
|
+
cssFiles: cssFiles.size,
|
|
155
|
+
processing: processing.size,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ResolvedUserOptions, CssContent } from "../types.js";
|
|
2
|
+
import { join, relative } from "node:path";
|
|
3
|
+
import { deserializeRegExp } from "./serializeUserOptions.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a CssContent object for a given path and css options
|
|
7
|
+
*
|
|
8
|
+
* Requirements:
|
|
9
|
+
* - path is a string
|
|
10
|
+
* - css is an object with the following properties:
|
|
11
|
+
* - inlineCss: boolean
|
|
12
|
+
* - purgeCss: boolean
|
|
13
|
+
* - inlineThreshold: number
|
|
14
|
+
* - inlinePatterns: RegExp[]
|
|
15
|
+
* - linkPatterns: RegExp[]
|
|
16
|
+
* based on the bundle, we retrieve the css content and check if it should be inlined or linked
|
|
17
|
+
* inlined tags get the as:style and the children are the css content
|
|
18
|
+
* linked tags get the as:link and the href is the path
|
|
19
|
+
*
|
|
20
|
+
* @param path - The path to the css file
|
|
21
|
+
* @param css - The css options
|
|
22
|
+
* @returns A CssContent object
|
|
23
|
+
*/
|
|
24
|
+
export const createCssProps = ({
|
|
25
|
+
id,
|
|
26
|
+
css,
|
|
27
|
+
code,
|
|
28
|
+
projectRoot,
|
|
29
|
+
moduleBaseURL,
|
|
30
|
+
moduleBasePath,
|
|
31
|
+
moduleRootPath,
|
|
32
|
+
}: {
|
|
33
|
+
id: string;
|
|
34
|
+
code: string;
|
|
35
|
+
} & Pick<
|
|
36
|
+
ResolvedUserOptions,
|
|
37
|
+
"css" | "moduleBaseURL" | "moduleBasePath" | "moduleRootPath" | "projectRoot"
|
|
38
|
+
>): CssContent => {
|
|
39
|
+
// If we don't have a bundle entry, create a linked CSS file
|
|
40
|
+
let inline = typeof code === "string" && code.length > css.inlineThreshold;
|
|
41
|
+
// Normalize the ID to be relative to src/
|
|
42
|
+
const normalizedId = id.startsWith(projectRoot)
|
|
43
|
+
? relative(projectRoot, id)
|
|
44
|
+
: id;
|
|
45
|
+
|
|
46
|
+
if (css.inlinePatterns?.length) {
|
|
47
|
+
// Deserialize RegExp patterns if they exist
|
|
48
|
+
const inlinePatterns = css.inlinePatterns?.map((pattern) =>
|
|
49
|
+
typeof pattern === "string" ? deserializeRegExp(pattern) : pattern
|
|
50
|
+
);
|
|
51
|
+
if (inlinePatterns.some((pattern) => pattern.test?.(normalizedId))) {
|
|
52
|
+
inline = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (css.linkPatterns?.length) {
|
|
56
|
+
const linkPatterns = css.linkPatterns?.map((pattern) =>
|
|
57
|
+
typeof pattern === "string" ? deserializeRegExp(pattern) : pattern
|
|
58
|
+
);
|
|
59
|
+
if (linkPatterns.some((pattern) => pattern.test?.(normalizedId))) {
|
|
60
|
+
inline = false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (inline) {
|
|
64
|
+
return {
|
|
65
|
+
type: "text/css",
|
|
66
|
+
id: normalizedId,
|
|
67
|
+
as: "style",
|
|
68
|
+
children: code.trim(),
|
|
69
|
+
...(process.env["NODE_ENV"] !== "production"
|
|
70
|
+
? {
|
|
71
|
+
"data-vite-dev-id": join(projectRoot, moduleRootPath, normalizedId),
|
|
72
|
+
}
|
|
73
|
+
: {}),
|
|
74
|
+
} as CssContent<true>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Default case
|
|
78
|
+
return {
|
|
79
|
+
id: normalizedId,
|
|
80
|
+
as: "link",
|
|
81
|
+
rel: "stylesheet",
|
|
82
|
+
href: join(moduleBaseURL, moduleBasePath, normalizedId),
|
|
83
|
+
precedence: "high",
|
|
84
|
+
} as CssContent<false>;
|
|
85
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PluginEvent } from "../types.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a unified event handler that can be used by both static and server plugins.
|
|
5
|
+
* This handler converts React stream events into plugin events and provides a consistent
|
|
6
|
+
* interface for event handling across the codebase.
|
|
7
|
+
*
|
|
8
|
+
* @param options Options for the event handler
|
|
9
|
+
* @returns A function that handles both React stream events and plugin events
|
|
10
|
+
*/
|
|
11
|
+
export interface EventHandlerOptions {
|
|
12
|
+
onEvent?: (event: PluginEvent) => void | Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createEventHandler(onEvent : EventHandlerOptions['onEvent']) {
|
|
16
|
+
return async function handleEvent(event: PluginEvent) {
|
|
17
|
+
// Call the user's event handler if provided
|
|
18
|
+
if (onEvent) {
|
|
19
|
+
const result = onEvent(event);
|
|
20
|
+
if (!result) {
|
|
21
|
+
return {
|
|
22
|
+
type: "success",
|
|
23
|
+
data: undefined,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (result instanceof Promise) {
|
|
27
|
+
try {
|
|
28
|
+
const awaited = await result;
|
|
29
|
+
return {
|
|
30
|
+
type: "success",
|
|
31
|
+
data: awaited,
|
|
32
|
+
};
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
type: "error",
|
|
36
|
+
error: error as Error,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return event;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -1,135 +1,66 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { resolvePage } from "../resolvePage.js";
|
|
3
|
-
import { resolveProps } from "../resolveProps.js";
|
|
4
|
-
import type { CreateHandlerOptions, CssContent } from "../types.js";
|
|
1
|
+
import type { CreateHandlerOptions } from "../types.js";
|
|
5
2
|
import { createRscStream } from "./createRscStream.js";
|
|
6
|
-
type CreateHandlerResult =
|
|
7
|
-
| {
|
|
8
|
-
type: "success";
|
|
9
|
-
controller: AbortController;
|
|
10
|
-
stream: PipeableStream;
|
|
11
|
-
assets: any;
|
|
12
|
-
route: string;
|
|
13
|
-
}
|
|
14
|
-
| { type: "error"; error: Error }
|
|
15
|
-
| { type: "skip" };
|
|
16
|
-
|
|
17
|
-
interface HandlerAssets {
|
|
18
|
-
css: (string | CssContent)[];
|
|
19
|
-
bootstrapModules: string[];
|
|
20
|
-
}
|
|
21
3
|
|
|
22
|
-
export async function createHandler<T>({
|
|
23
|
-
getCss,
|
|
24
|
-
root,
|
|
25
|
-
cssFiles = [],
|
|
26
|
-
cssModules = new Map<string, string | CssContent>(),
|
|
27
|
-
onCssFile,
|
|
28
|
-
logger,
|
|
29
|
-
loader,
|
|
30
|
-
Html,
|
|
31
|
-
CssCollector,
|
|
32
|
-
pagePath,
|
|
33
|
-
propsPath,
|
|
34
|
-
pageExportName,
|
|
35
|
-
propsExportName,
|
|
36
|
-
inlineCss,
|
|
37
|
-
moduleBase,
|
|
38
|
-
preserveModulesRoot: _preserveModulesRoot,
|
|
39
|
-
moduleBasePath,
|
|
40
|
-
moduleRootPath,
|
|
41
|
-
moduleBaseURL,
|
|
42
|
-
route,
|
|
43
|
-
pipableStreamOptions,
|
|
44
|
-
}: CreateHandlerOptions<T>): Promise<CreateHandlerResult> {
|
|
45
|
-
const controller = new AbortController();
|
|
46
4
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
5
|
+
export async function createHandler(handlerOptions: CreateHandlerOptions) {
|
|
6
|
+
if(!handlerOptions.PageComponent) {
|
|
7
|
+
throw new Error("PageComponent is required");
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const adaptedOnEvent = (event: "error" | "postpone", data: any) => {
|
|
11
|
+
if (event === "error") {
|
|
12
|
+
handlerOptions.onEvent?.({
|
|
13
|
+
type: "route.error",
|
|
14
|
+
data: {
|
|
15
|
+
route: handlerOptions.route,
|
|
16
|
+
...data,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
} else if (event === "postpone") {
|
|
20
|
+
handlerOptions.onEvent?.({
|
|
21
|
+
type: "route.postpone",
|
|
22
|
+
data: {
|
|
23
|
+
route: handlerOptions.route,
|
|
24
|
+
...data,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
64
27
|
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
28
|
+
};
|
|
67
29
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
if (PropsModule.type !== "success") {
|
|
77
|
-
return PropsModule;
|
|
78
|
-
}
|
|
79
|
-
const PageModule = await resolvePage({
|
|
80
|
-
pageModule: pagePath
|
|
81
|
-
? await loadWithCss(pagePath)
|
|
82
|
-
: { [pageExportName]: () => null },
|
|
83
|
-
path: String(pagePath),
|
|
84
|
-
exportName: pageExportName,
|
|
85
|
-
url: route,
|
|
86
|
-
});
|
|
87
|
-
if (PageModule.type !== "success") {
|
|
88
|
-
return PageModule;
|
|
89
|
-
}
|
|
30
|
+
const streamResult = createRscStream({
|
|
31
|
+
...handlerOptions,
|
|
32
|
+
onEvent: adaptedOnEvent,
|
|
33
|
+
cssFiles: handlerOptions.cssFiles,
|
|
34
|
+
PageComponent: handlerOptions.PageComponent as any,
|
|
35
|
+
pageProps: handlerOptions.pageProps,
|
|
36
|
+
});
|
|
90
37
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Html: Html,
|
|
102
|
-
CssCollector: CssCollector,
|
|
103
|
-
Page: PageModule[pageExportName as keyof typeof PageModule],
|
|
104
|
-
props: PropsModule[propsExportName as keyof typeof PropsModule],
|
|
105
|
-
moduleBase: moduleBase,
|
|
106
|
-
moduleRootPath: moduleRootPath,
|
|
107
|
-
moduleBasePath: moduleBasePath,
|
|
108
|
-
moduleBaseURL: moduleBaseURL,
|
|
109
|
-
logger: logger,
|
|
110
|
-
cssFiles: Array.from(cssModules.values()),
|
|
111
|
-
route,
|
|
112
|
-
url,
|
|
113
|
-
pipableStreamOptions: pipableStreamOptions,
|
|
114
|
-
htmlProps: {},
|
|
115
|
-
root: root,
|
|
116
|
-
loader: loader,
|
|
117
|
-
inlineCss: inlineCss,
|
|
118
|
-
});
|
|
38
|
+
if (streamResult.type === "error") {
|
|
39
|
+
handlerOptions.onEvent?.({
|
|
40
|
+
type: "route.error",
|
|
41
|
+
data: {
|
|
42
|
+
route: handlerOptions.route,
|
|
43
|
+
error: streamResult.error,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
throw streamResult.error;
|
|
47
|
+
}
|
|
119
48
|
|
|
120
|
-
|
|
121
|
-
|
|
49
|
+
return {
|
|
50
|
+
type: "success",
|
|
51
|
+
stream: streamResult.stream,
|
|
52
|
+
};
|
|
53
|
+
} catch (error) {
|
|
54
|
+
handlerOptions.onEvent?.({
|
|
55
|
+
type: "route.error",
|
|
56
|
+
data: {
|
|
57
|
+
route: handlerOptions.route,
|
|
58
|
+
error,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
type: "error",
|
|
63
|
+
error: error as Error,
|
|
64
|
+
};
|
|
122
65
|
}
|
|
123
|
-
|
|
124
|
-
const assets: HandlerAssets = {
|
|
125
|
-
css: cssFiles,
|
|
126
|
-
bootstrapModules: pipableStreamOptions?.bootstrapModules ?? [],
|
|
127
|
-
};
|
|
128
|
-
return {
|
|
129
|
-
type: "success",
|
|
130
|
-
controller,
|
|
131
|
-
stream,
|
|
132
|
-
assets,
|
|
133
|
-
route: route,
|
|
134
|
-
};
|
|
135
66
|
}
|