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
|
@@ -3,122 +3,57 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import React__default from 'react';
|
|
10
|
-
import { addCssFile, cssFiles } from './state.js';
|
|
11
|
-
import { InlineCssCollector } from '../../css-collector-inline.js';
|
|
12
|
-
import { createRscStream } from '../../helpers/createRscStream.js';
|
|
13
|
-
import { createLogger } from 'vite';
|
|
6
|
+
import { parentPort, workerData } from 'node:worker_threads';
|
|
7
|
+
import { addCssFileContent, hmrState } from './state.js';
|
|
8
|
+
import { handleRender } from './handleRender.js';
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
function messageHandler(msg, port = parentPort, reactLoaderPort, cssLoaderPort) {
|
|
11
|
+
if (!port) {
|
|
12
|
+
throw new Error("No port found");
|
|
13
|
+
}
|
|
14
|
+
switch (msg.type) {
|
|
17
15
|
case "RSC_RENDER":
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
logger: createLogger(),
|
|
54
|
-
inlineCss: true,
|
|
55
|
-
cssFiles: Array.from(cssFiles.values()).map((css) => ({
|
|
56
|
-
type: "text/css",
|
|
57
|
-
content: css,
|
|
58
|
-
path: css
|
|
59
|
-
})),
|
|
60
|
-
route: url,
|
|
61
|
-
url: typeof moduleBaseURL === "string" && moduleBaseURL !== "" ? new URL(url, moduleBaseURL).toString() : url,
|
|
62
|
-
root: projectRoot,
|
|
63
|
-
pipableStreamOptions: {
|
|
64
|
-
...pipableStreamOptions,
|
|
65
|
-
onError: (error) => {
|
|
66
|
-
if (typeof pipableStreamOptions.onError === "function") {
|
|
67
|
-
pipableStreamOptions.onError(error);
|
|
68
|
-
}
|
|
69
|
-
parentPort?.postMessage({
|
|
70
|
-
type: "ERROR",
|
|
71
|
-
id,
|
|
72
|
-
error: error instanceof Error ? error.message : String(error)
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
onPostpone: (reason) => {
|
|
76
|
-
if (typeof pipableStreamOptions.onPostpone === "function") {
|
|
77
|
-
pipableStreamOptions.onPostpone(reason);
|
|
78
|
-
}
|
|
79
|
-
parentPort?.postMessage({
|
|
80
|
-
type: "POSTPONE",
|
|
81
|
-
id,
|
|
82
|
-
reason
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
if (!stream) {
|
|
88
|
-
throw new Error("Failed to create stream");
|
|
89
|
-
}
|
|
90
|
-
const passThrough = new PassThrough();
|
|
91
|
-
stream.pipe(passThrough);
|
|
92
|
-
passThrough.on("data", (chunk) => {
|
|
93
|
-
parentPort?.postMessage({
|
|
94
|
-
type: "RSC_CHUNK",
|
|
95
|
-
id,
|
|
96
|
-
chunk: chunk.toString(),
|
|
97
|
-
moduleRootPath: moduleBasePath,
|
|
98
|
-
moduleBaseURL,
|
|
99
|
-
outDir,
|
|
100
|
-
rscOutputPath: `${outDir}/${id}.rsc`,
|
|
101
|
-
cssFiles: Array.from(cssFiles.entries())
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
passThrough.on("end", () => {
|
|
105
|
-
parentPort?.postMessage({
|
|
106
|
-
type: "RSC_END",
|
|
107
|
-
id
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
} catch (error) {
|
|
111
|
-
console.trace(error);
|
|
112
|
-
parentPort?.postMessage({
|
|
113
|
-
type: "ERROR",
|
|
114
|
-
id,
|
|
115
|
-
error: error instanceof Error ? error.message : String(error)
|
|
16
|
+
return handleRender(msg, port);
|
|
17
|
+
case "INITIALIZED_REACT_LOADER":
|
|
18
|
+
return;
|
|
19
|
+
case "INITIALIZED_CSS_LOADER":
|
|
20
|
+
return;
|
|
21
|
+
case "HMR_UPDATE":
|
|
22
|
+
hmrState.set(msg.path, {
|
|
23
|
+
timestamp: msg.timestamp || Date.now(),
|
|
24
|
+
invalidated: true,
|
|
25
|
+
routes: msg.routes || []
|
|
26
|
+
});
|
|
27
|
+
port.postMessage({
|
|
28
|
+
type: "HMR_ACCEPT",
|
|
29
|
+
path: msg.path,
|
|
30
|
+
routes: msg.routes
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
case "HMR_CLEANUP":
|
|
34
|
+
hmrState.delete(msg.path);
|
|
35
|
+
port.postMessage({
|
|
36
|
+
type: "HMR_ACCEPT",
|
|
37
|
+
path: msg.path
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
case "CSS_FILE":
|
|
41
|
+
if (msg.id) {
|
|
42
|
+
const cssOptions = workerData.userOptions.css || {
|
|
43
|
+
inlineThreshold: 1e3
|
|
44
|
+
};
|
|
45
|
+
addCssFileContent(msg.id, msg.content, {
|
|
46
|
+
projectRoot: workerData.userOptions.projectRoot || process.cwd(),
|
|
47
|
+
moduleBaseURL: workerData.userOptions.moduleBaseURL || "",
|
|
48
|
+
moduleBasePath: workerData.userOptions.moduleBasePath || "",
|
|
49
|
+
moduleRootPath: workerData.userOptions.moduleRootPath || "",
|
|
50
|
+
css: cssOptions
|
|
116
51
|
});
|
|
117
52
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
53
|
+
return;
|
|
54
|
+
default: {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
122
57
|
}
|
|
123
58
|
}
|
|
124
59
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageHandler.js","sources":["../../../../plugin/worker/rsc/messageHandler.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"messageHandler.js","sources":["../../../../plugin/worker/rsc/messageHandler.tsx"],"sourcesContent":["import { parentPort, workerData, type MessagePort } from \"node:worker_threads\";\nimport { addCssFileContent, hmrState } from \"./state.js\";\nimport { handleRender } from \"./handleRender.js\";\n\nexport function messageHandler(\n msg: any,\n port = parentPort,\n reactLoaderPort: MessagePort,\n cssLoaderPort: MessagePort\n) {\n if (!port) {\n throw new Error(\"No port found\");\n }\n switch (msg.type) {\n case \"RSC_RENDER\":\n return handleRender(msg, port, reactLoaderPort, cssLoaderPort);\n case \"INITIALIZED_REACT_LOADER\":\n return;\n case \"INITIALIZED_CSS_LOADER\":\n return;\n case \"HMR_UPDATE\":\n // Mark the module as invalidated\n hmrState.set(msg.path, {\n timestamp: msg.timestamp || Date.now(),\n invalidated: true,\n routes: msg.routes || [],\n });\n // Notify the main thread that we've processed the update\n port.postMessage({\n type: \"HMR_ACCEPT\",\n path: msg.path,\n routes: msg.routes,\n });\n return;\n case \"HMR_CLEANUP\":\n // Clear the invalidation state\n hmrState.delete(msg.path);\n // Notify the main thread that we've processed the cleanup\n port.postMessage({\n type: \"HMR_ACCEPT\",\n path: msg.path,\n });\n return;\n case \"CSS_FILE\":\n if (msg.id) {\n const cssOptions = workerData.userOptions.css || {\n inlineThreshold: 1000,\n };\n \n addCssFileContent(msg.id, msg.content, {\n projectRoot: workerData.userOptions.projectRoot || process.cwd(),\n moduleBaseURL: workerData.userOptions.moduleBaseURL || \"\",\n moduleBasePath: workerData.userOptions.moduleBasePath || \"\",\n moduleRootPath: workerData.userOptions.moduleRootPath || \"\",\n css: cssOptions,\n });\n }\n return;\n default: {\n return;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAIO,SAAS,cACd,CAAA,GAAA,EACA,IAAO,GAAA,UAAA,EACP,iBACA,aACA,EAAA;AACA,EAAA,IAAI,CAAC,IAAM,EAAA;AACT,IAAM,MAAA,IAAI,MAAM,eAAe,CAAA;AAAA;AAEjC,EAAA,QAAQ,IAAI,IAAM;AAAA,IAChB,KAAK,YAAA;AACH,MAAA,OAAO,YAAa,CAAA,GAAA,EAAK,IAAoC,CAAA;AAAA,IAC/D,KAAK,0BAAA;AACH,MAAA;AAAA,IACF,KAAK,wBAAA;AACH,MAAA;AAAA,IACF,KAAK,YAAA;AAEH,MAAS,QAAA,CAAA,GAAA,CAAI,IAAI,IAAM,EAAA;AAAA,QACrB,SAAW,EAAA,GAAA,CAAI,SAAa,IAAA,IAAA,CAAK,GAAI,EAAA;AAAA,QACrC,WAAa,EAAA,IAAA;AAAA,QACb,MAAA,EAAQ,GAAI,CAAA,MAAA,IAAU;AAAC,OACxB,CAAA;AAED,MAAA,IAAA,CAAK,WAAY,CAAA;AAAA,QACf,IAAM,EAAA,YAAA;AAAA,QACN,MAAM,GAAI,CAAA,IAAA;AAAA,QACV,QAAQ,GAAI,CAAA;AAAA,OACb,CAAA;AACD,MAAA;AAAA,IACF,KAAK,aAAA;AAEH,MAAS,QAAA,CAAA,MAAA,CAAO,IAAI,IAAI,CAAA;AAExB,MAAA,IAAA,CAAK,WAAY,CAAA;AAAA,QACf,IAAM,EAAA,YAAA;AAAA,QACN,MAAM,GAAI,CAAA;AAAA,OACX,CAAA;AACD,MAAA;AAAA,IACF,KAAK,UAAA;AACH,MAAA,IAAI,IAAI,EAAI,EAAA;AACV,QAAM,MAAA,UAAA,GAAa,UAAW,CAAA,WAAA,CAAY,GAAO,IAAA;AAAA,UAC/C,eAAiB,EAAA;AAAA,SACnB;AAEA,QAAkB,iBAAA,CAAA,GAAA,CAAI,EAAI,EAAA,GAAA,CAAI,OAAS,EAAA;AAAA,UACrC,WAAa,EAAA,UAAA,CAAW,WAAY,CAAA,WAAA,IAAe,QAAQ,GAAI,EAAA;AAAA,UAC/D,aAAA,EAAe,UAAW,CAAA,WAAA,CAAY,aAAiB,IAAA,EAAA;AAAA,UACvD,cAAA,EAAgB,UAAW,CAAA,WAAA,CAAY,cAAkB,IAAA,EAAA;AAAA,UACzD,cAAA,EAAgB,UAAW,CAAA,WAAA,CAAY,cAAkB,IAAA,EAAA;AAAA,UACzD,GAAK,EAAA;AAAA,SACN,CAAA;AAAA;AAEH,MAAA;AAAA,IACF,SAAS;AACP,MAAA;AAAA;AACF;AAEJ;;;;"}
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
declare module 'node:module' {
|
|
2
|
-
interface ImportAttributes {
|
|
3
|
-
[key: string]: string | undefined;
|
|
4
|
-
}
|
|
5
|
-
interface ResolveHookContext {
|
|
6
|
-
conditions: string[];
|
|
7
|
-
parentURL: string | undefined;
|
|
8
|
-
importAttributes: ImportAttributes;
|
|
9
|
-
}
|
|
10
|
-
interface LoadHookContext {
|
|
11
|
-
conditions: string[];
|
|
12
|
-
format: ModuleFormat | null | undefined;
|
|
13
|
-
importAttributes: ImportAttributes;
|
|
14
|
-
shortCircuit?: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface ResolveResult {
|
|
17
|
-
url: string;
|
|
18
|
-
shortCircuit: boolean;
|
|
19
|
-
}
|
|
20
|
-
interface LoadResult {
|
|
21
|
-
format: string;
|
|
22
|
-
source: string | SharedArrayBuffer | Uint8Array;
|
|
23
|
-
shortCircuit: boolean;
|
|
24
|
-
}
|
|
25
|
-
interface HooksAPI {
|
|
26
|
-
resolve?: (specifier: string, context: ResolveHookContext, nextResolve: (specifier: string, context: ResolveHookContext) => ResolveResult) => ResolveResult;
|
|
27
|
-
load?: (url: string, context: LoadHookContext, nextLoad: (url: string, context: LoadHookContext) => LoadResult) => LoadResult;
|
|
28
|
-
}
|
|
29
|
-
function registerHooks(hooks: HooksAPI): void;
|
|
30
|
-
}
|
|
31
1
|
export {};
|
|
32
2
|
//# sourceMappingURL=rsc-worker.development.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc-worker.development.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/rsc-worker.development.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rsc-worker.development.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/rsc-worker.development.ts"],"names":[],"mappings":""}
|
|
@@ -3,22 +3,26 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import { parentPort, MessageChannel } from 'node:worker_threads';
|
|
6
|
+
import { parentPort, workerData, MessageChannel } from 'node:worker_threads';
|
|
7
7
|
import { messageHandler } from './messageHandler.js';
|
|
8
8
|
import { register } from 'node:module';
|
|
9
9
|
import { register as register$1 } from 'tsx/esm/api';
|
|
10
10
|
import { join } from 'node:path';
|
|
11
11
|
import { pluginRoot } from '../../root.js';
|
|
12
|
+
import { deserializeRegExp } from '../../helpers/serializeUserOptions.js';
|
|
12
13
|
|
|
13
14
|
if (!parentPort) {
|
|
14
15
|
throw new Error("This module must be run as a worker");
|
|
15
16
|
}
|
|
17
|
+
if (workerData) {
|
|
18
|
+
workerData.userOptions = deserializeRegExp(workerData.userOptions);
|
|
19
|
+
}
|
|
16
20
|
const reactLoaderChannel = new MessageChannel();
|
|
17
21
|
const cssLoaderChannel = new MessageChannel();
|
|
18
22
|
reactLoaderChannel.port2.on("message", messageHandler);
|
|
19
23
|
cssLoaderChannel.port2.on("message", messageHandler);
|
|
20
24
|
const loaderPath = "file://" + join(pluginRoot, "loader/react-loader.js");
|
|
21
|
-
const cssLoaderPath = "file://" + join(pluginRoot, "loader/css-loader.js");
|
|
25
|
+
const cssLoaderPath = "file://" + join(pluginRoot, "loader/css-loader.development.js");
|
|
22
26
|
register(loaderPath, {
|
|
23
27
|
parentURL: pluginRoot,
|
|
24
28
|
data: { port: reactLoaderChannel.port1 },
|
|
@@ -26,12 +30,33 @@ register(loaderPath, {
|
|
|
26
30
|
});
|
|
27
31
|
register(cssLoaderPath, {
|
|
28
32
|
parentURL: pluginRoot,
|
|
29
|
-
data: { port: cssLoaderChannel.port1 },
|
|
33
|
+
data: { port: cssLoaderChannel.port1, resolvedConfig: workerData.resolvedConfig },
|
|
30
34
|
transferList: [cssLoaderChannel.port1]
|
|
31
35
|
});
|
|
32
36
|
register$1();
|
|
33
37
|
parentPort.on("message", messageHandler);
|
|
34
|
-
|
|
38
|
+
const { hmrPort } = workerData;
|
|
39
|
+
if (hmrPort) {
|
|
40
|
+
hmrPort.start();
|
|
41
|
+
hmrPort.on("message", (message) => {
|
|
42
|
+
if (message.type === "HMR_UPDATE") {
|
|
43
|
+
parentPort.postMessage({
|
|
44
|
+
type: "HMR_UPDATE",
|
|
45
|
+
path: message.path
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
hmrPort.on("message", (message) => {
|
|
50
|
+
parentPort.postMessage({
|
|
51
|
+
type: "HMR_ACCEPT",
|
|
52
|
+
path: message.path
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
parentPort.postMessage({
|
|
57
|
+
type: "READY",
|
|
58
|
+
env: process.env["NODE_ENV"]
|
|
59
|
+
});
|
|
35
60
|
if (process.env["NODE_ENV"] !== "development") {
|
|
36
61
|
throw new Error("This module must be run in development mode");
|
|
37
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc-worker.development.js","sources":["../../../../plugin/worker/rsc/rsc-worker.development.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"rsc-worker.development.js","sources":["../../../../plugin/worker/rsc/rsc-worker.development.ts"],"sourcesContent":["import { parentPort, MessageChannel, workerData } from \"node:worker_threads\";\nimport { messageHandler } from \"./messageHandler.js\";\nimport { register } from \"node:module\";\nimport { register as registerTsx } from \"tsx/esm/api\";\nimport { join } from \"node:path\";\nimport { pluginRoot } from \"../../root.js\";\nimport { deserializeRegExp } from \"../../helpers/serializeUserOptions.js\";\n\n// Initialize worker\nif (!parentPort) {\n throw new Error(\"This module must be run as a worker\");\n}\n\n// Deserialize workerData to restore RegExp objects\nif (workerData) {\n workerData.userOptions = deserializeRegExp(workerData.userOptions);\n}\n\n// Create channels for each loader\nconst reactLoaderChannel = new MessageChannel();\nconst cssLoaderChannel = new MessageChannel();\n\n// Listen for messages from loaders\nreactLoaderChannel.port2.on(\"message\", messageHandler);\ncssLoaderChannel.port2.on(\"message\", messageHandler);\n\nconst loaderPath = \"file://\" + join(pluginRoot, \"loader/react-loader.js\");\nconst cssLoaderPath =\n \"file://\" + join(pluginRoot, \"loader/css-loader.development.js\");\n\n// Register react-loader\nregister(loaderPath, {\n parentURL: pluginRoot,\n data: { port: reactLoaderChannel.port1 },\n transferList: [reactLoaderChannel.port1],\n});\nregister(cssLoaderPath, {\n parentURL: pluginRoot,\n data: { port: cssLoaderChannel.port1, resolvedConfig: workerData.resolvedConfig },\n transferList: [cssLoaderChannel.port1],\n});\n\n// Register loaders\nregisterTsx();\n\n// Set up message handling\nparentPort!.on(\"message\", messageHandler);\n\nconst { hmrPort } = workerData;\nif (hmrPort) {\n // Start the message port\n hmrPort.start();\n\n // Listen for file changes\n hmrPort.on(\"message\", (message: any) => {\n if (message.type === \"HMR_UPDATE\") {\n // Invalidate the module in the worker\n parentPort!.postMessage({\n type: \"HMR_UPDATE\",\n path: message.path,\n });\n }\n });\n\n // Listen for HMR updates\n hmrPort.on(\"message\", (message: any) => {\n // Handle the update\n parentPort!.postMessage({\n type: \"HMR_ACCEPT\",\n path: message.path,\n });\n });\n}\n\n// Notify parent that we're ready\nparentPort!.postMessage({\n type: \"READY\",\n env: process.env[\"NODE_ENV\"],\n});\n\nif (process.env[\"NODE_ENV\"] !== \"development\") {\n throw new Error(\"This module must be run in development mode\");\n}\n"],"names":["registerTsx"],"mappings":";;;;;;;;;;;;;AASA,IAAI,CAAC,UAAY,EAAA;AACf,EAAM,MAAA,IAAI,MAAM,qCAAqC,CAAA;AACvD;AAGA,IAAI,UAAY,EAAA;AACd,EAAW,UAAA,CAAA,WAAA,GAAc,iBAAkB,CAAA,UAAA,CAAW,WAAW,CAAA;AACnE;AAGA,MAAM,kBAAA,GAAqB,IAAI,cAAe,EAAA;AAC9C,MAAM,gBAAA,GAAmB,IAAI,cAAe,EAAA;AAG5C,kBAAmB,CAAA,KAAA,CAAM,EAAG,CAAA,SAAA,EAAW,cAAc,CAAA;AACrD,gBAAiB,CAAA,KAAA,CAAM,EAAG,CAAA,SAAA,EAAW,cAAc,CAAA;AAEnD,MAAM,UAAa,GAAA,SAAA,GAAY,IAAK,CAAA,UAAA,EAAY,wBAAwB,CAAA;AACxE,MAAM,aACJ,GAAA,SAAA,GAAY,IAAK,CAAA,UAAA,EAAY,kCAAkC,CAAA;AAGjE,QAAA,CAAS,UAAY,EAAA;AAAA,EACnB,SAAW,EAAA,UAAA;AAAA,EACX,IAAM,EAAA,EAAE,IAAM,EAAA,kBAAA,CAAmB,KAAM,EAAA;AAAA,EACvC,YAAA,EAAc,CAAC,kBAAA,CAAmB,KAAK;AACzC,CAAC,CAAA;AACD,QAAA,CAAS,aAAe,EAAA;AAAA,EACtB,SAAW,EAAA,UAAA;AAAA,EACX,MAAM,EAAE,IAAA,EAAM,iBAAiB,KAAO,EAAA,cAAA,EAAgB,WAAW,cAAe,EAAA;AAAA,EAChF,YAAA,EAAc,CAAC,gBAAA,CAAiB,KAAK;AACvC,CAAC,CAAA;AAGDA,UAAY,EAAA;AAGZ,UAAY,CAAA,EAAA,CAAG,WAAW,cAAc,CAAA;AAExC,MAAM,EAAE,SAAY,GAAA,UAAA;AACpB,IAAI,OAAS,EAAA;AAEX,EAAA,OAAA,CAAQ,KAAM,EAAA;AAGd,EAAQ,OAAA,CAAA,EAAA,CAAG,SAAW,EAAA,CAAC,OAAiB,KAAA;AACtC,IAAI,IAAA,OAAA,CAAQ,SAAS,YAAc,EAAA;AAEjC,MAAA,UAAA,CAAY,WAAY,CAAA;AAAA,QACtB,IAAM,EAAA,YAAA;AAAA,QACN,MAAM,OAAQ,CAAA;AAAA,OACf,CAAA;AAAA;AACH,GACD,CAAA;AAGD,EAAQ,OAAA,CAAA,EAAA,CAAG,SAAW,EAAA,CAAC,OAAiB,KAAA;AAEtC,IAAA,UAAA,CAAY,WAAY,CAAA;AAAA,MACtB,IAAM,EAAA,YAAA;AAAA,MACN,MAAM,OAAQ,CAAA;AAAA,KACf,CAAA;AAAA,GACF,CAAA;AACH;AAGA,UAAA,CAAY,WAAY,CAAA;AAAA,EACtB,IAAM,EAAA,OAAA;AAAA,EACN,GAAA,EAAK,OAAQ,CAAA,GAAA,CAAI,UAAU;AAC7B,CAAC,CAAA;AAED,IAAI,OAAQ,CAAA,GAAA,CAAI,UAAU,CAAA,KAAM,aAAe,EAAA;AAC7C,EAAM,MAAA,IAAI,MAAM,6CAA6C,CAAA;AAC/D"}
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
import { parentPort } from 'node:worker_threads';
|
|
7
7
|
import { messageHandler } from './messageHandler.js';
|
|
8
8
|
|
|
9
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
9
12
|
if (!parentPort) {
|
|
10
13
|
throw new Error("This module must be run as a worker");
|
|
11
14
|
}
|
|
12
15
|
parentPort.on("message", messageHandler);
|
|
13
16
|
parentPort.postMessage({ type: "READY", env: process.env["NODE_ENV"] });
|
|
14
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
15
|
-
throw new Error("This module must be run in production mode");
|
|
16
|
-
}
|
|
17
17
|
//# sourceMappingURL=rsc-worker.production.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc-worker.production.js","sources":["../../../../plugin/worker/rsc/rsc-worker.production.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"rsc-worker.production.js","sources":["../../../../plugin/worker/rsc/rsc-worker.production.ts"],"sourcesContent":["// Check environment before any imports\nif (process.env[\"NODE_ENV\"] !== \"production\") {\n process.exit(1);\n}\n\nimport { parentPort } from \"node:worker_threads\";\nimport { messageHandler } from \"./messageHandler.js\";\n\nif (!parentPort) {\n throw new Error(\"This module must be run as a worker\");\n}\n\n// Handle incoming messages\nparentPort.on(\"message\", messageHandler);\n\n// Signal ready\nparentPort.postMessage({ type: \"READY\", env: process.env[\"NODE_ENV\"] });\n"],"names":[],"mappings":";;;;;;;;AACA,IAAI,OAAQ,CAAA,GAAA,CAAI,UAAU,CAAA,KAAM,YAAc,EAAA;AAC5C,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB;AAKA,IAAI,CAAC,UAAY,EAAA;AACf,EAAM,MAAA,IAAI,MAAM,qCAAqC,CAAA;AACvD;AAGA,UAAW,CAAA,EAAA,CAAG,WAAW,cAAc,CAAA;AAGvC,UAAW,CAAA,WAAA,CAAY,EAAE,IAAM,EAAA,OAAA,EAAS,KAAK,OAAQ,CAAA,GAAA,CAAI,UAAU,CAAA,EAAG,CAAA"}
|
|
@@ -1,11 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CssContent, ResolvedUserOptions, HmrState } from "../../types.js";
|
|
2
|
+
import type { PassThrough } from "node:stream";
|
|
3
|
+
export declare const activeStreams: Map<string, PassThrough>;
|
|
4
|
+
export declare const cssFiles: Map<string, ({
|
|
5
|
+
as: string;
|
|
6
|
+
id: string;
|
|
7
|
+
} & {
|
|
8
|
+
as: "link";
|
|
9
|
+
type?: never;
|
|
10
|
+
children?: {
|
|
11
|
+
as: string;
|
|
12
|
+
id: string;
|
|
13
|
+
} & {
|
|
14
|
+
as: "style";
|
|
15
|
+
type: "text/css";
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
precedence?: never;
|
|
18
|
+
rel?: never;
|
|
19
|
+
href?: never;
|
|
20
|
+
} extends false ? never : React.ReactNode;
|
|
21
|
+
id: string;
|
|
22
|
+
href: string;
|
|
23
|
+
rel: "stylesheet";
|
|
24
|
+
precedence?: string;
|
|
25
|
+
}) | ({
|
|
26
|
+
as: string;
|
|
27
|
+
id: string;
|
|
28
|
+
} & {
|
|
29
|
+
as: "style";
|
|
30
|
+
type: "text/css";
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
precedence?: never;
|
|
33
|
+
rel?: never;
|
|
34
|
+
href?: never;
|
|
35
|
+
})>;
|
|
36
|
+
export declare const hmrState: Map<string, HmrState>;
|
|
2
37
|
export declare const clientFiles: Set<string>;
|
|
3
38
|
export declare const serverActionFiles: Set<string>;
|
|
4
39
|
export declare function clearCssFiles(): void;
|
|
40
|
+
export declare function getCssFiles(): MapIterator<[string, ({
|
|
41
|
+
as: string;
|
|
42
|
+
id: string;
|
|
43
|
+
} & {
|
|
44
|
+
as: "link";
|
|
45
|
+
type?: never;
|
|
46
|
+
children?: {
|
|
47
|
+
as: string;
|
|
48
|
+
id: string;
|
|
49
|
+
} & {
|
|
50
|
+
as: "style";
|
|
51
|
+
type: "text/css";
|
|
52
|
+
children?: React.ReactNode;
|
|
53
|
+
precedence?: never;
|
|
54
|
+
rel?: never;
|
|
55
|
+
href?: never;
|
|
56
|
+
} extends false ? never : React.ReactNode;
|
|
57
|
+
id: string;
|
|
58
|
+
href: string;
|
|
59
|
+
rel: "stylesheet";
|
|
60
|
+
precedence?: string;
|
|
61
|
+
}) | ({
|
|
62
|
+
as: string;
|
|
63
|
+
id: string;
|
|
64
|
+
} & {
|
|
65
|
+
as: "style";
|
|
66
|
+
type: "text/css";
|
|
67
|
+
children?: React.ReactNode;
|
|
68
|
+
precedence?: never;
|
|
69
|
+
rel?: never;
|
|
70
|
+
href?: never;
|
|
71
|
+
})]>;
|
|
5
72
|
export declare function clearClientFiles(): void;
|
|
6
73
|
export declare function clearServerActionFiles(): void;
|
|
7
|
-
export declare function addCssFile(id: string, cssFile:
|
|
74
|
+
export declare function addCssFile(id: string, cssFile: CssContent): void;
|
|
75
|
+
export declare function addCssFileContent(id: string, code: string, userOptions: Pick<ResolvedUserOptions, "projectRoot" | "moduleBaseURL" | "moduleBasePath" | "moduleRootPath" | "css">): void;
|
|
8
76
|
export declare function addClientFile(url: string): void;
|
|
9
77
|
export declare function addServerActionFile(url: string): void;
|
|
10
78
|
export declare function clearAllFiles(): void;
|
|
79
|
+
export declare function isModuleInvalidated(path: string): boolean;
|
|
80
|
+
export declare function clearHmrState(path: string): void;
|
|
81
|
+
export declare function getInvalidatedModules(): string[];
|
|
11
82
|
//# sourceMappingURL=state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../plugin/worker/rsc/state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C,eAAO,MAAM,aAAa,0BAAiC,CAAC;AAG5D,eAAO,MAAM,QAAQ;;;;;;;;;;;;mBAmG0xZ,MAAO,SAAS;;;;8BAArM,MAAO,SAAS;;;;;;;;;;;eAAqK,MAAO,SAAS;;;;GAnG1wZ,CAAC;AAGtD,eAAO,MAAM,QAAQ,uBAA8B,CAAC;AAyBpD,eAAO,MAAM,WAAW,aAAoB,CAAC;AAC7C,eAAO,MAAM,iBAAiB,aAAoB,CAAC;AAGnD,wBAAgB,aAAa,SAE5B;AAED,wBAAgB,WAAW;;;;;;;;;;;;mBA+DoxZ,MAAO,SAAS;;;;8BAArM,MAAO,SAAS;;;;;;;;;;;eAAqK,MAAO,SAAS;;;;KA7D9zZ;AAED,wBAAgB,gBAAgB,SAE/B;AAED,wBAAgB,sBAAsB,SAErC;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,QAEzD;AAGD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,KAAK,CAAC,QAchL;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,QAExC;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,QAE9C;AAED,wBAAgB,aAAa,SAI5B;AAGD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGzD;AAGD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEhD;AAGD,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAIhD"}
|
|
@@ -3,10 +3,47 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
+
import { workerData } from 'node:worker_threads';
|
|
7
|
+
import { createCssProps } from '../../helpers/createCssProps.js';
|
|
8
|
+
import { relative } from 'node:path';
|
|
9
|
+
|
|
10
|
+
const activeStreams = /* @__PURE__ */ new Map();
|
|
6
11
|
const cssFiles = /* @__PURE__ */ new Map();
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
const hmrState = /* @__PURE__ */ new Map();
|
|
13
|
+
if (workerData) {
|
|
14
|
+
if (workerData.hmrPort) {
|
|
15
|
+
workerData.hmrPort.on("message", (msg) => {
|
|
16
|
+
if (msg.type === "HMR_UPDATE") {
|
|
17
|
+
const normalizedPath = relative(workerData.userOptions.projectRoot, msg.path);
|
|
18
|
+
hmrState.set(normalizedPath, {
|
|
19
|
+
timestamp: Date.now(),
|
|
20
|
+
invalidated: true,
|
|
21
|
+
routes: msg.routes || []
|
|
22
|
+
});
|
|
23
|
+
} else if (msg.type === "HMR_ACCEPT") {
|
|
24
|
+
const normalizedPath = relative(workerData.userOptions.projectRoot, msg.path);
|
|
25
|
+
hmrState.delete(normalizedPath);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
throw new Error("This module must be run with workerData");
|
|
31
|
+
}
|
|
32
|
+
function addCssFileContent(id, code, userOptions) {
|
|
33
|
+
if (typeof code !== "string") {
|
|
34
|
+
throw new Error(`Expected css to be loaded as a string, but got ${typeof code}`);
|
|
35
|
+
}
|
|
36
|
+
const normalizeId = id.startsWith(userOptions.moduleRootPath) ? id.slice(userOptions.moduleRootPath.length) : id;
|
|
37
|
+
cssFiles.set(normalizeId, createCssProps({
|
|
38
|
+
id,
|
|
39
|
+
code,
|
|
40
|
+
projectRoot: userOptions.projectRoot,
|
|
41
|
+
moduleBaseURL: userOptions.moduleBaseURL,
|
|
42
|
+
moduleBasePath: userOptions.moduleBasePath,
|
|
43
|
+
moduleRootPath: userOptions.moduleRootPath,
|
|
44
|
+
css: userOptions.css
|
|
45
|
+
}));
|
|
9
46
|
}
|
|
10
47
|
|
|
11
|
-
export {
|
|
48
|
+
export { activeStreams, addCssFileContent, cssFiles, hmrState };
|
|
12
49
|
//# sourceMappingURL=state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sources":["../../../../plugin/worker/rsc/state.ts"],"sourcesContent":["//
|
|
1
|
+
{"version":3,"file":"state.js","sources":["../../../../plugin/worker/rsc/state.ts"],"sourcesContent":["import { workerData } from \"node:worker_threads\";\nimport { createCssProps } from \"../../helpers/createCssProps.js\";\nimport type { CssContent, ResolvedUserOptions, HmrState } from \"../../types.js\";\nimport type { PassThrough } from \"node:stream\";\nimport { relative } from \"node:path\";\n\n\n// Track active RSC streams\nexport const activeStreams = new Map<string, PassThrough>();\n\n// Track CSS files\nexport const cssFiles = new Map<string, CssContent>();\n\n\nexport const hmrState = new Map<string, HmrState>();\n\nif(workerData) {\n if(workerData.hmrPort) {\n workerData.hmrPort.on('message', (msg: { type: string; path: string; routes?: string[] }) => {\n if(msg.type === 'HMR_UPDATE') {\n // Normalize the path relative to project root\n const normalizedPath = relative(workerData.userOptions.projectRoot, msg.path);\n hmrState.set(normalizedPath, { \n timestamp: Date.now(), \n invalidated: true,\n routes: msg.routes || []\n });\n } else if(msg.type === 'HMR_ACCEPT') {\n // Normalize the path relative to project root\n const normalizedPath = relative(workerData.userOptions.projectRoot, msg.path);\n hmrState.delete(normalizedPath);\n }\n });\n }\n} else {\n throw new Error(\"This module must be run with workerData\");\n}\n\n// Create shared CSS registry\nexport const clientFiles = new Set<string>();\nexport const serverActionFiles = new Set<string>();\n\n// Helper functions\nexport function clearCssFiles() {\n cssFiles.clear();\n}\n\nexport function getCssFiles() {\n return cssFiles.entries();\n}\n\nexport function clearClientFiles() {\n clientFiles.clear();\n}\n\nexport function clearServerActionFiles() {\n serverActionFiles.clear();\n}\n\nexport function addCssFile(id: string, cssFile: CssContent) {\n cssFiles.set(id, cssFile);\n}\n\n\nexport function addCssFileContent(id: string, code: string, userOptions: Pick<ResolvedUserOptions, \"projectRoot\" | \"moduleBaseURL\" | \"moduleBasePath\" | \"moduleRootPath\" | \"css\">) {\n if(typeof code !== \"string\"){\n throw new Error(`Expected css to be loaded as a string, but got ${typeof code}`);\n }\n const normalizeId = id.startsWith(userOptions.moduleRootPath) ? id.slice(userOptions.moduleRootPath.length) : id;\n cssFiles.set(normalizeId, createCssProps({\n id,\n code,\n projectRoot: userOptions.projectRoot,\n moduleBaseURL: userOptions.moduleBaseURL,\n moduleBasePath: userOptions.moduleBasePath,\n moduleRootPath: userOptions.moduleRootPath,\n css: userOptions.css,\n }));\n} \n\nexport function addClientFile(url: string) {\n clientFiles.add(url);\n}\n\nexport function addServerActionFile(url: string) {\n serverActionFiles.add(url);\n}\n\nexport function clearAllFiles() {\n clearCssFiles();\n clearClientFiles();\n clearServerActionFiles();\n}\n\n// Helper to check if a module is invalidated\nexport function isModuleInvalidated(path: string): boolean {\n const state = hmrState.get(path);\n return state?.invalidated || false;\n}\n\n// Helper to clear HMR state for a module\nexport function clearHmrState(path: string): void {\n hmrState.delete(path);\n}\n\n// Helper to get all invalidated modules\nexport function getInvalidatedModules(): string[] {\n return Array.from(hmrState.entries())\n .filter(([_, state]) => state.invalidated)\n .map(([path]) => path);\n} "],"names":[],"mappings":";;;;;;;;;AAQa,MAAA,aAAA,uBAAoB,GAAyB;AAG7C,MAAA,QAAA,uBAAe,GAAwB;AAGvC,MAAA,QAAA,uBAAe,GAAsB;AAElD,IAAG,UAAY,EAAA;AACb,EAAA,IAAG,WAAW,OAAS,EAAA;AACrB,IAAA,UAAA,CAAW,OAAQ,CAAA,EAAA,CAAG,SAAW,EAAA,CAAC,GAA2D,KAAA;AAC3F,MAAG,IAAA,GAAA,CAAI,SAAS,YAAc,EAAA;AAE5B,QAAA,MAAM,iBAAiB,QAAS,CAAA,UAAA,CAAW,WAAY,CAAA,WAAA,EAAa,IAAI,IAAI,CAAA;AAC5E,QAAA,QAAA,CAAS,IAAI,cAAgB,EAAA;AAAA,UAC3B,SAAA,EAAW,KAAK,GAAI,EAAA;AAAA,UACpB,WAAa,EAAA,IAAA;AAAA,UACb,MAAA,EAAQ,GAAI,CAAA,MAAA,IAAU;AAAC,SACxB,CAAA;AAAA,OACH,MAAA,IAAU,GAAI,CAAA,IAAA,KAAS,YAAc,EAAA;AAEnC,QAAA,MAAM,iBAAiB,QAAS,CAAA,UAAA,CAAW,WAAY,CAAA,WAAA,EAAa,IAAI,IAAI,CAAA;AAC5E,QAAA,QAAA,CAAS,OAAO,cAAc,CAAA;AAAA;AAChC,KACD,CAAA;AAAA;AAEL,CAAO,MAAA;AACL,EAAM,MAAA,IAAI,MAAM,yCAAyC,CAAA;AAC3D;AA4BgB,SAAA,iBAAA,CAAkB,EAAY,EAAA,IAAA,EAAc,WAAuH,EAAA;AACjL,EAAG,IAAA,OAAO,SAAS,QAAS,EAAA;AAC1B,IAAA,MAAM,IAAI,KAAA,CAAM,CAAkD,+CAAA,EAAA,OAAO,IAAI,CAAE,CAAA,CAAA;AAAA;AAEjF,EAAM,MAAA,WAAA,GAAc,EAAG,CAAA,UAAA,CAAW,WAAY,CAAA,cAAc,CAAI,GAAA,EAAA,CAAG,KAAM,CAAA,WAAA,CAAY,cAAe,CAAA,MAAM,CAAI,GAAA,EAAA;AAC9G,EAAS,QAAA,CAAA,GAAA,CAAI,aAAa,cAAe,CAAA;AAAA,IACvC,EAAA;AAAA,IACA,IAAA;AAAA,IACA,aAAa,WAAY,CAAA,WAAA;AAAA,IACzB,eAAe,WAAY,CAAA,aAAA;AAAA,IAC3B,gBAAgB,WAAY,CAAA,cAAA;AAAA,IAC5B,gBAAgB,WAAY,CAAA,cAAA;AAAA,IAC5B,KAAK,WAAY,CAAA;AAAA,GAClB,CAAC,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { HtmlWorkerOutputMessage, RscWorkerOutputMessage } from "./types.js";
|
|
2
|
+
export declare function sendMessage(msg: HtmlWorkerOutputMessage | RscWorkerOutputMessage, port?: import("worker_threads").MessagePort | null): void;
|
|
3
|
+
//# sourceMappingURL=sendMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../../plugin/worker/sendMessage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGlF,wBAAgB,WAAW,CAAC,GAAG,EAAE,uBAAuB,GAAG,sBAAsB,EAAE,IAAI,8CAAa,QA4CnG"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { cleanObject } from "../helpers/cleanObject.js";
|
|
2
|
+
import { parentPort } from "node:worker_threads";
|
|
3
|
+
export function sendMessage(msg, port = parentPort) {
|
|
4
|
+
if (!port) {
|
|
5
|
+
console.error("[Worker] No port available to send message");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
// Handle error messages
|
|
10
|
+
if ('error' in msg) {
|
|
11
|
+
const error = msg.error;
|
|
12
|
+
const serializedError = error instanceof Error ? {
|
|
13
|
+
message: error.message,
|
|
14
|
+
stack: error.stack,
|
|
15
|
+
name: error.name,
|
|
16
|
+
cause: error.cause,
|
|
17
|
+
} : {
|
|
18
|
+
message: String(error),
|
|
19
|
+
name: 'Error',
|
|
20
|
+
};
|
|
21
|
+
port.postMessage({
|
|
22
|
+
...cleanObject(msg),
|
|
23
|
+
error: serializedError,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// Handle non-error messages
|
|
28
|
+
port.postMessage(cleanObject(msg));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
console.error("[Worker] Failed to send message:", err);
|
|
33
|
+
// Try to send a basic error message
|
|
34
|
+
try {
|
|
35
|
+
port.postMessage({
|
|
36
|
+
type: "ERROR",
|
|
37
|
+
error: {
|
|
38
|
+
message: err instanceof Error ? err.message : String(err),
|
|
39
|
+
name: err instanceof Error ? err.name : 'Error',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// If we can't even send an error message, just log it
|
|
45
|
+
console.error("[Worker] Critical error - could not send error message");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|