vite-plugin-react-server 1.1.12 → 1.1.13
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/dist/package.json +10 -8
- package/dist/plugin/components/css-collector-elements.d.ts +4 -2
- package/dist/plugin/components/css-collector-elements.d.ts.map +1 -1
- package/dist/plugin/components/css-collector-elements.js +21 -7
- package/dist/plugin/components/css-collector-elements.js.map +1 -1
- package/dist/plugin/components/css-collector.d.ts +4 -5
- package/dist/plugin/components/css-collector.d.ts.map +1 -1
- package/dist/plugin/components/css-collector.js +5 -9
- package/dist/plugin/components/css-collector.js.map +1 -1
- package/dist/plugin/components/html.d.ts +1 -1
- package/dist/plugin/components/html.d.ts.map +1 -1
- package/dist/plugin/components/html.js +14 -3
- package/dist/plugin/components/html.js.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +4 -4
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +14 -9
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +1 -1
- package/dist/plugin/config/defaults.d.ts +66 -12
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +69 -15
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts +5 -0
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts.map +1 -0
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js +25 -0
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js.map +1 -0
- package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
- package/dist/plugin/config/resolveEnv.js +16 -5
- package/dist/plugin/config/resolveEnv.js.map +1 -1
- package/dist/plugin/config/resolveOptions.d.ts +3 -3
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +59 -87
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts +4 -4
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +8 -1
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/error/toError.d.ts +3 -0
- package/dist/plugin/error/toError.d.ts.map +1 -1
- package/dist/plugin/error/toError.js +33 -4
- package/dist/plugin/error/toError.js.map +1 -1
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -1
- package/dist/plugin/helpers/cleanObject.js +19 -5
- package/dist/plugin/helpers/cleanObject.js.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +3 -3
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -1
- package/dist/plugin/helpers/createCssProps.d.ts +4 -3
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
- package/dist/plugin/helpers/createCssProps.js +7 -2
- package/dist/plugin/helpers/createCssProps.js.map +1 -1
- package/dist/plugin/helpers/createHandler.d.ts +4 -3
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +1 -1
- package/dist/plugin/helpers/createHandler.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts +2 -2
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +15 -5
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/helpers/index.d.ts +2 -2
- package/dist/plugin/helpers/index.d.ts.map +1 -1
- package/dist/plugin/helpers/index.js +2 -2
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +4 -1
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/moduleResolver.d.ts +3 -0
- package/dist/plugin/helpers/moduleResolver.d.ts.map +1 -0
- package/dist/plugin/helpers/moduleResolver.js +25 -0
- package/dist/plugin/helpers/requestInfo.d.ts +18 -3
- package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
- package/dist/plugin/helpers/requestInfo.js +75 -11
- package/dist/plugin/helpers/requestInfo.js.map +1 -1
- package/dist/plugin/helpers/resolvePage.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePage.js +2 -3
- package/dist/plugin/helpers/resolvePage.js.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +4 -3
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -1
- package/dist/plugin/helpers/serializeUserOptions.d.ts +3 -2
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
- package/dist/plugin/helpers/serializeUserOptions.js +13 -1
- package/dist/plugin/helpers/serializeUserOptions.js.map +1 -1
- package/dist/plugin/helpers/sourceMap.d.ts +8 -0
- package/dist/plugin/helpers/sourceMap.d.ts.map +1 -0
- package/dist/plugin/helpers/sourceMap.js +136 -0
- package/dist/plugin/helpers.js +1 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +7 -22
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +79 -65
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/createDefaultLoader.d.ts +13 -0
- package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -0
- package/dist/plugin/loader/createDefaultLoader.js +47 -0
- package/dist/plugin/loader/css-loader.development.d.ts +1 -0
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.development.js +1 -1
- package/dist/plugin/loader/css-loader.development.js.map +1 -1
- package/dist/plugin/loader/handleExports.d.ts +33 -0
- package/dist/plugin/loader/handleExports.d.ts.map +1 -0
- package/dist/plugin/loader/handleExports.js +174 -0
- package/dist/plugin/loader/handleExports.js.map +1 -0
- package/dist/plugin/loader/index.d.ts +1 -1
- package/dist/plugin/loader/index.d.ts.map +1 -1
- package/dist/plugin/loader/index.js +4 -1
- package/dist/plugin/loader/parse.d.ts +6 -0
- package/dist/plugin/loader/parse.d.ts.map +1 -0
- package/dist/plugin/loader/parse.js +23 -0
- package/dist/plugin/loader/parse.js.map +1 -0
- package/dist/plugin/loader/react-loader.client.d.ts +2 -0
- package/dist/plugin/loader/react-loader.client.d.ts.map +1 -0
- package/dist/plugin/loader/react-loader.client.js +2 -0
- package/dist/plugin/loader/react-loader.d.ts +1 -12
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +5 -687
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/loader/react-loader.server.d.ts +21 -0
- package/dist/plugin/loader/react-loader.server.d.ts.map +1 -0
- package/dist/plugin/loader/react-loader.server.js +69 -0
- package/dist/plugin/loader/sourceMap.d.ts +35 -0
- package/dist/plugin/loader/sourceMap.d.ts.map +1 -0
- package/dist/plugin/loader/sourceMap.js +105 -0
- package/dist/plugin/loader/temporaryReferences.d.ts +1 -1
- package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -1
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts +2 -0
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -0
- package/dist/plugin/loader/transformModuleIfNeeded.js +27 -0
- package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts +27 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +52 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -0
- package/dist/plugin/loader/types.d.ts +8 -0
- package/dist/plugin/loader/types.d.ts.map +1 -0
- package/dist/plugin/loader/types.js +1 -0
- package/dist/plugin/plugin.client.d.ts +2 -2
- package/dist/plugin/plugin.client.d.ts.map +1 -1
- package/dist/plugin/plugin.client.js +2 -3
- package/dist/plugin/plugin.client.js.map +1 -1
- package/dist/plugin/plugin.server.d.ts +2 -2
- package/dist/plugin/plugin.server.d.ts.map +1 -1
- package/dist/plugin/plugin.server.js +2 -2
- package/dist/plugin/plugin.server.js.map +1 -1
- package/dist/plugin/preserver/plugin.d.ts +2 -2
- package/dist/plugin/preserver/plugin.d.ts.map +1 -1
- package/dist/plugin/preserver/plugin.js +6 -2
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/{server.d.ts → configureWorkerRequestHandler.d.ts} +4 -4
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -0
- package/dist/plugin/react-client/{server.js → configureWorkerRequestHandler.js} +11 -8
- package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -0
- package/dist/plugin/react-client/createMessageHandlers.d.ts +1 -1
- package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
- package/dist/plugin/react-client/createMessageHandlers.js +18 -11
- package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.d.ts +5 -3
- package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.js +61 -27
- package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js +14 -4
- package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
- package/dist/plugin/react-client/plugin.d.ts +2 -2
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +7 -8
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-client/restartWorker.d.ts +1 -1
- package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
- package/dist/plugin/react-client/restartWorker.js +9 -3
- package/dist/plugin/react-client/restartWorker.js.map +1 -1
- package/dist/plugin/react-server/configureReactServer.d.ts +9 -0
- package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -0
- package/dist/plugin/react-server/{server.js → configureReactServer.js} +26 -8
- package/dist/plugin/react-server/configureReactServer.js.map +1 -0
- package/dist/plugin/react-server/handleServerAction.d.ts +5 -0
- package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -0
- package/dist/plugin/react-server/handleServerAction.js +145 -0
- package/dist/plugin/react-server/handleServerAction.js.map +1 -0
- package/dist/plugin/react-server/plugin.d.ts +2 -2
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +1 -1
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +2 -2
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -1
- package/dist/plugin/react-static/collectRscContent.d.ts +2 -2
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectRscContent.js.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.d.ts +3 -3
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.js +18 -7
- package/dist/plugin/react-static/configurePreviewServer.js.map +1 -1
- package/dist/plugin/react-static/plugin.d.ts +2 -2
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +28 -12
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/renderPage.d.ts +2 -2
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPage.js.map +1 -1
- package/dist/plugin/react-static/renderPages.d.ts +2 -2
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPages.js.map +1 -1
- package/dist/plugin/react-static/renderStreams.d.ts +2 -2
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
- package/dist/plugin/react-static/renderStreams.js +4 -4
- package/dist/plugin/react-static/renderStreams.js.map +1 -1
- package/dist/plugin/source-map/createMappingsSerializer.d.ts +2 -0
- package/dist/plugin/source-map/createMappingsSerializer.d.ts.map +1 -0
- package/dist/plugin/source-map/createMappingsSerializer.js +159 -0
- package/dist/plugin/source-map/readMappings.d.ts +2 -0
- package/dist/plugin/source-map/readMappings.d.ts.map +1 -0
- package/dist/plugin/source-map/readMappings.js +201 -0
- package/dist/plugin/transformer/index.d.ts +0 -1
- package/dist/plugin/transformer/index.d.ts.map +1 -1
- package/dist/plugin/transformer/index.js +0 -1
- package/dist/plugin/transformer/plugin.client.d.ts +1 -3
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.client.js +1 -84
- package/dist/plugin/transformer/plugin.server.d.ts +2 -2
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.server.js +52 -20
- package/dist/plugin/transformer/plugin.server.js.map +1 -1
- package/dist/plugin/types.d.ts +89 -119
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/utils/callServer.d.ts +1 -1
- package/dist/plugin/utils/callServer.d.ts.map +1 -1
- package/dist/plugin/utils/createCallServer.d.ts +1 -1
- package/dist/plugin/utils/createCallServer.d.ts.map +1 -1
- package/dist/plugin/utils/createCallServer.js +13 -4
- package/dist/plugin/utils/createCallServer.js.map +1 -1
- package/dist/plugin/utils/index.d.ts +1 -0
- package/dist/plugin/utils/index.d.ts.map +1 -1
- package/dist/plugin/utils/index.js +1 -0
- package/dist/plugin/utils.js +1 -0
- package/dist/plugin/utils.js.map +1 -1
- package/dist/plugin/vendor/vendor.client.d.ts +2 -1
- package/dist/plugin/vendor/vendor.client.d.ts.map +1 -1
- package/dist/plugin/vendor/vendor.client.js +2 -1
- package/dist/plugin/vendor/vendor.client.js.map +1 -1
- package/dist/plugin/vendor/vendor.server.d.ts.map +1 -1
- package/dist/plugin/vendor/vendor.server.js +1 -1
- package/dist/plugin/vendor/vendor.server.js.map +1 -1
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +17 -22
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +25 -4
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +15 -13
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +2 -12
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +2 -2
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.d.ts +2 -1
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +8 -8
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +166 -107
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +112 -52
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +5 -64
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +5 -1
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/sendMessage.d.ts +2 -0
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
- package/dist/plugin/worker/sendMessage.js +2 -1
- package/dist/plugin/worker/sendMessage.js.map +1 -1
- package/dist/plugin/worker/types.d.ts +52 -53
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -8
- package/plugin/components/css-collector-elements.tsx +30 -9
- package/plugin/components/css-collector.tsx +13 -22
- package/plugin/components/html.tsx +12 -5
- package/plugin/config/autoDiscover/resolveAutoDiscover.ts +31 -13
- package/plugin/config/defaults.tsx +72 -16
- package/plugin/config/resolveAutoDiscoverMatcher.ts +23 -0
- package/plugin/config/resolveEnv.ts +20 -12
- package/plugin/config/resolveOptions.ts +152 -155
- package/plugin/config/resolveUserConfig.ts +20 -5
- package/plugin/error/toError.ts +35 -1
- package/plugin/helpers/cleanObject.ts +79 -15
- package/plugin/helpers/collectViteModuleGraphCss.ts +4 -3
- package/plugin/helpers/createCssProps.tsx +26 -9
- package/plugin/helpers/createHandler.ts +7 -4
- package/plugin/helpers/createRscStream.tsx +20 -14
- package/plugin/helpers/index.ts +2 -2
- package/plugin/helpers/inputNormalizer.ts +4 -2
- package/plugin/helpers/moduleResolver.ts +36 -0
- package/plugin/helpers/requestInfo.ts +117 -23
- package/plugin/helpers/resolvePage.ts +2 -3
- package/plugin/helpers/resolvePageAndProps.ts +7 -6
- package/plugin/helpers/serializeUserOptions.ts +20 -2
- package/plugin/helpers/sourceMap.ts +182 -0
- package/plugin/loader/createBuildLoader.ts +124 -104
- package/plugin/loader/createDefaultLoader.ts +62 -0
- package/plugin/loader/css-loader.development.ts +3 -2
- package/plugin/loader/handleExports.ts +276 -0
- package/plugin/loader/index.ts +6 -1
- package/plugin/loader/parse.ts +22 -0
- package/plugin/loader/react-loader.client.ts +1 -0
- package/plugin/loader/react-loader.server.ts +107 -0
- package/plugin/loader/react-loader.ts +4 -1002
- package/plugin/loader/sourceMap.ts +118 -0
- package/plugin/loader/transformModuleIfNeeded.ts +33 -0
- package/plugin/loader/transformModuleWithPreservedFunctions.ts +119 -0
- package/plugin/loader/types.ts +10 -0
- package/plugin/plugin.client.ts +18 -11
- package/plugin/plugin.server.ts +6 -3
- package/plugin/preserver/plugin.ts +37 -17
- package/plugin/react-client/{server.ts → configureWorkerRequestHandler.ts} +22 -12
- package/plugin/react-client/createMessageHandlers.ts +21 -13
- package/plugin/react-client/createWorkerStream.ts +71 -33
- package/plugin/react-client/handleWorkerRscStream.ts +15 -5
- package/plugin/react-client/plugin.ts +18 -13
- package/plugin/react-client/restartWorker.ts +17 -5
- package/plugin/react-server/{server.ts → configureReactServer.ts} +40 -9
- package/plugin/react-server/handleServerAction.ts +177 -0
- package/plugin/react-server/plugin.ts +8 -3
- package/plugin/react-static/collectHtmlWorkerContent.ts +11 -3
- package/plugin/react-static/collectRscContent.ts +17 -9
- package/plugin/react-static/configurePreviewServer.ts +37 -17
- package/plugin/react-static/plugin.ts +45 -22
- package/plugin/react-static/renderPage.ts +12 -6
- package/plugin/react-static/renderPages.ts +15 -4
- package/plugin/react-static/renderStreams.ts +13 -12
- package/plugin/source-map/createMappingsSerializer.ts +182 -0
- package/plugin/source-map/readMappings.ts +195 -0
- package/plugin/transformer/README.md +295 -29
- package/plugin/transformer/index.ts +0 -1
- package/plugin/transformer/plugin.client.ts +0 -111
- package/plugin/transformer/plugin.server.ts +94 -25
- package/plugin/types/react-server-dom-esm.d.ts +183 -24
- package/plugin/types/sourceMap.d.ts +2 -0
- package/plugin/types/webpack-sources.d.ts +24 -0
- package/plugin/types.ts +169 -132
- package/plugin/utils/createCallServer.ts +21 -6
- package/plugin/utils/index.ts +2 -1
- package/plugin/vendor/vendor.client.ts +2 -1
- package/plugin/vendor/vendor.server.ts +1 -1
- package/plugin/worker/createWorker.ts +21 -24
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +31 -7
- package/plugin/worker/html/html-worker.development.tsx +16 -16
- package/plugin/worker/html/html-worker.production.tsx +3 -19
- package/plugin/worker/html/messageHandler.tsx +2 -4
- package/plugin/worker/rsc/handleRender.ts +15 -12
- package/plugin/worker/rsc/messageHandler.tsx +191 -120
- package/plugin/worker/rsc/rsc-worker.development.ts +148 -77
- package/plugin/worker/rsc/rsc-worker.production.ts +1 -1
- package/plugin/worker/rsc/state.ts +10 -0
- package/plugin/worker/sendMessage.ts +32 -14
- package/plugin/worker/types.ts +99 -64
- package/dist/plugin/react-client/server.d.ts.map +0 -1
- package/dist/plugin/react-client/server.js.map +0 -1
- package/dist/plugin/react-server/server.d.ts +0 -9
- package/dist/plugin/react-server/server.d.ts.map +0 -1
- package/dist/plugin/react-server/server.js.map +0 -1
- package/dist/plugin/transformer/plugin.client.js.map +0 -1
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +0 -2
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +0 -1
- package/dist/plugin/transformer/upgradeCssModuleCode.js +0 -40
- package/dist/plugin/worker/loader.d.ts +0 -5
- package/dist/plugin/worker/loader.d.ts.map +0 -1
- package/dist/plugin/worker/loader.js +0 -11
- package/dist/plugin/worker/loader.js.map +0 -1
- package/plugin/transformer/upgradeCssModuleCode.ts +0 -42
- package/plugin/worker/loader.ts +0 -7
package/plugin/types.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Readable } from "node:stream";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Worker } from "node:worker_threads";
|
|
3
3
|
import type React from "react";
|
|
4
|
-
import type { PropsWithChildren } from "react";
|
|
5
4
|
import type {
|
|
6
5
|
NormalizedOutputOptions,
|
|
7
6
|
OutputBundle,
|
|
@@ -66,6 +65,7 @@ export type AutoDiscoveredFiles = ResolvedBuildPages & {
|
|
|
66
65
|
clientEntry: Record<string, string>;
|
|
67
66
|
inputs: Record<string, string>;
|
|
68
67
|
staticManifest: Manifest;
|
|
68
|
+
serverActions: Record<string, string>;
|
|
69
69
|
};
|
|
70
70
|
export type FileWriterOptions = Pick<
|
|
71
71
|
CreateHandlerOptions,
|
|
@@ -118,6 +118,7 @@ export type ResolvedUserConfig = Required<
|
|
|
118
118
|
| "ssrManifest"
|
|
119
119
|
| "manifest"
|
|
120
120
|
| "rollupOptions"
|
|
121
|
+
| "modulePreload"
|
|
121
122
|
>
|
|
122
123
|
>
|
|
123
124
|
> &
|
|
@@ -151,10 +152,11 @@ export interface StreamPluginOptionsClient {
|
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
export type ResolvedUserOptions<
|
|
154
|
-
|
|
155
|
+
T extends PagePropOpt = PagePropOpt,
|
|
156
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
155
157
|
> = Required<
|
|
156
158
|
Pick<
|
|
157
|
-
StreamPluginOptions,
|
|
159
|
+
StreamPluginOptions<T, InlineCSS>,
|
|
158
160
|
| "moduleBase"
|
|
159
161
|
| "moduleBasePath"
|
|
160
162
|
| "moduleBaseURL"
|
|
@@ -171,7 +173,7 @@ export type ResolvedUserOptions<
|
|
|
171
173
|
| "loaderPath"
|
|
172
174
|
| "clientEntry"
|
|
173
175
|
| "serverEntry"
|
|
174
|
-
| "moduleBaseExceptions"
|
|
176
|
+
// | "moduleBaseExceptions"
|
|
175
177
|
| "pipeableStreamOptions"
|
|
176
178
|
| "onMetrics"
|
|
177
179
|
| "onEvent"
|
|
@@ -187,10 +189,14 @@ export type ResolvedUserOptions<
|
|
|
187
189
|
| string
|
|
188
190
|
| ((url: string) => string)
|
|
189
191
|
| ((url: string) => Promise<string>);
|
|
190
|
-
build: NonNullable<Required<StreamPluginOptions<InlineCSS>["build"]>>;
|
|
191
|
-
css: NonNullable<Required<StreamPluginOptions<InlineCSS>["css"]
|
|
192
|
+
build: NonNullable<Required<StreamPluginOptions<T, InlineCSS>["build"]>>;
|
|
193
|
+
css: NonNullable<Required<StreamPluginOptions<T, InlineCSS>["css"]>> & {
|
|
194
|
+
inlineCss: InlineCSS;
|
|
195
|
+
};
|
|
192
196
|
autoDiscover: {
|
|
193
197
|
moduleExtension: RegExp;
|
|
198
|
+
serverDirective: RegExp;
|
|
199
|
+
clientDirective: RegExp;
|
|
194
200
|
modulePattern: (path: string) => boolean;
|
|
195
201
|
cssPattern: (path: string) => boolean;
|
|
196
202
|
jsonPattern: (path: string) => boolean;
|
|
@@ -205,6 +211,8 @@ export type ResolvedUserOptions<
|
|
|
205
211
|
nodeOnly: (path: string) => boolean;
|
|
206
212
|
dotFiles: (path: string) => boolean;
|
|
207
213
|
virtualPattern: (path: string) => boolean;
|
|
214
|
+
isServerFunction: (code: string) => boolean;
|
|
215
|
+
isClientComponent: (code: string) => boolean;
|
|
208
216
|
};
|
|
209
217
|
};
|
|
210
218
|
|
|
@@ -231,14 +239,70 @@ export interface RenderMetrics {
|
|
|
231
239
|
rscSizes: Map<string, number>;
|
|
232
240
|
}
|
|
233
241
|
|
|
234
|
-
export interface CssCollectorOptions
|
|
235
|
-
|
|
236
|
-
|
|
242
|
+
export interface CssCollectorOptions<
|
|
243
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
244
|
+
> {
|
|
245
|
+
inlineCss?: InlineCSS;
|
|
237
246
|
inlineThreshold?: number;
|
|
238
247
|
inlinePatterns?: RegExp[];
|
|
239
248
|
linkPatterns?: RegExp[];
|
|
240
249
|
}
|
|
241
250
|
|
|
251
|
+
export type CssContent<InlineCSS extends InlineCssOpt = InlineCssOpt> =
|
|
252
|
+
InlineCSS extends true
|
|
253
|
+
? StyleCssProps
|
|
254
|
+
: InlineCSS extends false
|
|
255
|
+
? LinkCssProps
|
|
256
|
+
: InlineCSS extends undefined | boolean
|
|
257
|
+
? StyleCssProps | LinkCssProps
|
|
258
|
+
: never;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Boxed component type for the CssCollector
|
|
262
|
+
*/
|
|
263
|
+
export type CssCollectorBoxedType<
|
|
264
|
+
_T extends PagePropOpt = PagePropOpt,
|
|
265
|
+
_InlineCSS extends InlineCssOpt = InlineCssOpt,
|
|
266
|
+
_As extends AsOpt = AsOpt
|
|
267
|
+
> = <
|
|
268
|
+
T extends _T = _T,
|
|
269
|
+
InlineCSS extends _InlineCSS = _InlineCSS,
|
|
270
|
+
As extends _As = _As
|
|
271
|
+
>(
|
|
272
|
+
props: CssCollectorProps<T, InlineCSS, As>
|
|
273
|
+
) => React.ReactElement;
|
|
274
|
+
|
|
275
|
+
export type CssCollectorProps<
|
|
276
|
+
T extends PagePropOpt = PagePropOpt,
|
|
277
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt,
|
|
278
|
+
As extends AsOpt = AsOpt
|
|
279
|
+
> = {
|
|
280
|
+
as: As;
|
|
281
|
+
cssFiles?: Map<string, CssContent<InlineCSS>>;
|
|
282
|
+
pageProps?: T;
|
|
283
|
+
Page: PageComponentType<T>;
|
|
284
|
+
id?: string;
|
|
285
|
+
} & React.ComponentPropsWithoutRef<As>;
|
|
286
|
+
|
|
287
|
+
export type CssCollectorComponent = (
|
|
288
|
+
props: CssCollectorProps
|
|
289
|
+
) => React.ReactElement;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Boxed component type for the Html component
|
|
293
|
+
*/
|
|
294
|
+
export type HtmlBoxedType<
|
|
295
|
+
_T extends PagePropOpt = PagePropOpt,
|
|
296
|
+
_InlineCSS extends InlineCssOpt = InlineCssOpt,
|
|
297
|
+
_As extends AsOpt = "div"
|
|
298
|
+
> = <
|
|
299
|
+
T extends _T = _T,
|
|
300
|
+
InlineCSS extends _InlineCSS = _InlineCSS,
|
|
301
|
+
As extends _As = _As
|
|
302
|
+
>(
|
|
303
|
+
props: HtmlProps<T, InlineCSS, As> & { key?: string }
|
|
304
|
+
) => React.ReactNode;
|
|
305
|
+
|
|
242
306
|
export type FileWriteEvent = {
|
|
243
307
|
type: "file.write";
|
|
244
308
|
data: {
|
|
@@ -362,7 +426,8 @@ export type PluginEvent =
|
|
|
362
426
|
export type PluginEventType = PluginEvent["type"];
|
|
363
427
|
|
|
364
428
|
export interface StreamPluginOptions<
|
|
365
|
-
|
|
429
|
+
T extends PagePropOpt = PagePropOpt,
|
|
430
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
366
431
|
> {
|
|
367
432
|
projectRoot?: string; // defaults to process.cwd()
|
|
368
433
|
moduleBase: string; // defaults to 'src'
|
|
@@ -375,35 +440,44 @@ export interface StreamPluginOptions<
|
|
|
375
440
|
// Auto-discovery (zero-config)
|
|
376
441
|
autoDiscover?:
|
|
377
442
|
| {
|
|
443
|
+
// default: /\.(m|c)?(j|t)sx?$/
|
|
378
444
|
moduleExtension?: RegExp;
|
|
445
|
+
// default: /^"use server"[\s;]*\n?/m
|
|
446
|
+
serverDirective?: RegExp;
|
|
447
|
+
// default: /^"use client"[\s;]*\n?/m
|
|
448
|
+
clientDirective?: RegExp;
|
|
379
449
|
// default: /\.(m|c)?(j|t)sx?$/
|
|
380
|
-
modulePattern?:
|
|
450
|
+
modulePattern?: RegExpOpt;
|
|
381
451
|
// default: [Pp]age.tsx
|
|
382
|
-
pagePattern?:
|
|
452
|
+
pagePattern?: RegExpOpt;
|
|
383
453
|
// default: [Pp]rops.ts
|
|
384
|
-
propsPattern?:
|
|
454
|
+
propsPattern?: RegExpOpt;
|
|
385
455
|
// default: "use client" and .client./\.(m|c)?(j|t)sx?$/
|
|
386
|
-
clientComponents?:
|
|
456
|
+
clientComponents?: RegExpOpt;
|
|
387
457
|
// default: "use server" and .server./\.(m|c)?(j|t)sx?$/
|
|
388
|
-
serverFunctions?:
|
|
458
|
+
serverFunctions?: RegExpOpt;
|
|
389
459
|
// default: /\.css$/
|
|
390
|
-
cssPattern?:
|
|
460
|
+
cssPattern?: RegExpOpt;
|
|
391
461
|
// default: /\.json$/
|
|
392
|
-
jsonPattern?:
|
|
462
|
+
jsonPattern?: RegExpOpt;
|
|
393
463
|
// default: /\.html$/
|
|
394
|
-
htmlPattern?:
|
|
464
|
+
htmlPattern?: RegExpOpt;
|
|
395
465
|
// default: /\.css\.js/
|
|
396
|
-
cssModulePattern?:
|
|
466
|
+
cssModulePattern?: RegExpOpt;
|
|
397
467
|
// default: /node_modules|(_virtual)/
|
|
398
|
-
vendorPattern?:
|
|
468
|
+
vendorPattern?: RegExpOpt;
|
|
399
469
|
// default: /\.node\.js$/
|
|
400
|
-
nodeOnly?:
|
|
470
|
+
nodeOnly?: RegExpOpt;
|
|
401
471
|
// default: /\.node\.js$/
|
|
402
|
-
dotFiles?:
|
|
472
|
+
dotFiles?: RegExpOpt;
|
|
403
473
|
// default: /^\/_virtual\//
|
|
404
|
-
virtualPattern?:
|
|
474
|
+
virtualPattern?: RegExpOpt;
|
|
405
475
|
// default: /\.rsc$/
|
|
406
|
-
rscPattern?:
|
|
476
|
+
rscPattern?: RegExpOpt;
|
|
477
|
+
// default serverDirective regex
|
|
478
|
+
isServerFunction?: RegExpOpt;
|
|
479
|
+
// default clientDirective regex
|
|
480
|
+
isClientComponent?: RegExpOpt;
|
|
407
481
|
}
|
|
408
482
|
| undefined;
|
|
409
483
|
// Manual configuration
|
|
@@ -419,13 +493,11 @@ export interface StreamPluginOptions<
|
|
|
419
493
|
loaderPath?: string;
|
|
420
494
|
pageExportName?: string;
|
|
421
495
|
propsExportName?: string;
|
|
422
|
-
Html?: React.FC<
|
|
423
|
-
CssCollector?:
|
|
424
|
-
React.PropsWithChildren<CssCollectorProps<InlineCSS>>
|
|
425
|
-
>;
|
|
496
|
+
Html?: React.FC<HtmlProps<T, InlineCSS>>;
|
|
497
|
+
CssCollector?: CssCollectorBoxedType<T, InlineCSS>;
|
|
426
498
|
build?: BuildConfig;
|
|
427
|
-
css?: CssCollectorOptions
|
|
428
|
-
moduleBaseExceptions?: string[];
|
|
499
|
+
css?: CssCollectorOptions<InlineCSS>;
|
|
500
|
+
// moduleBaseExceptions?: string[];
|
|
429
501
|
pipeableStreamOptions?: ReactServerDomEsmOptions;
|
|
430
502
|
onMetrics?: (metrics: RenderMetrics) => void;
|
|
431
503
|
onEvent?: (event: PluginEvent) => void;
|
|
@@ -434,8 +506,11 @@ export interface StreamPluginOptions<
|
|
|
434
506
|
verbose?: boolean;
|
|
435
507
|
}
|
|
436
508
|
|
|
437
|
-
export type MultiPageHandlerOptions
|
|
438
|
-
|
|
509
|
+
export type MultiPageHandlerOptions<
|
|
510
|
+
T extends PagePropOpt = PagePropOpt,
|
|
511
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
512
|
+
> = Omit<
|
|
513
|
+
CreateHandlerOptions<T, InlineCSS>,
|
|
439
514
|
| "pagePath"
|
|
440
515
|
| "route"
|
|
441
516
|
| "cssFiles"
|
|
@@ -445,11 +520,10 @@ export type MultiPageHandlerOptions = Omit<
|
|
|
445
520
|
>;
|
|
446
521
|
|
|
447
522
|
export type CreateHandlerOptions<
|
|
448
|
-
T =
|
|
449
|
-
|
|
450
|
-
InlineCSS extends boolean | undefined = undefined
|
|
523
|
+
T extends PagePropOpt = PagePropOpt,
|
|
524
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
451
525
|
> = Pick<
|
|
452
|
-
ResolvedUserOptions<InlineCSS>,
|
|
526
|
+
ResolvedUserOptions<T, InlineCSS>,
|
|
453
527
|
| "autoDiscover"
|
|
454
528
|
| "css"
|
|
455
529
|
| "pageExportName"
|
|
@@ -470,16 +544,16 @@ export type CreateHandlerOptions<
|
|
|
470
544
|
pagePath: string;
|
|
471
545
|
propsPath?: string;
|
|
472
546
|
pageProps?: T;
|
|
473
|
-
PageComponent?:
|
|
547
|
+
PageComponent?: PageComponentType<T>;
|
|
474
548
|
route: string;
|
|
475
549
|
manifest: Manifest;
|
|
476
550
|
worker?: Worker;
|
|
477
551
|
server?: ViteDevServer;
|
|
478
552
|
importedCss?: Set<string>;
|
|
479
|
-
cssFiles: Map<string, CssContent
|
|
480
|
-
globalCss: Map<string, CssContent
|
|
553
|
+
cssFiles: Map<string, CssContent<InlineCSS>>;
|
|
554
|
+
globalCss: Map<string, CssContent<InlineCSS>>;
|
|
481
555
|
build: Pick<
|
|
482
|
-
ResolvedUserOptions["build"],
|
|
556
|
+
ResolvedUserOptions<T, InlineCSS>["build"],
|
|
483
557
|
| "outDir"
|
|
484
558
|
| "pages"
|
|
485
559
|
| "server"
|
|
@@ -667,24 +741,28 @@ export type ResolvedBuildPages = {
|
|
|
667
741
|
errors: Error[];
|
|
668
742
|
};
|
|
669
743
|
|
|
670
|
-
// Add strict type checking for worker messages
|
|
671
|
-
export type WorkerMessage =
|
|
672
|
-
| { type: "READY" }
|
|
673
|
-
| { type: "ERROR"; error: string | Error }
|
|
674
|
-
| { type: "RSC_CHUNK"; id: string; chunk: Buffer }
|
|
675
|
-
| { type: "RSC_END"; id: string }
|
|
676
|
-
| { type: "SHUTDOWN"; id: string }
|
|
677
|
-
| { type: "SHUTDOWN_COMPLETE" }
|
|
678
|
-
| { type: "CHUNK_PROCESSED"; id: string; success: boolean }
|
|
679
|
-
| { type: "CHUNK_ERROR"; id: string; error: string }
|
|
680
|
-
| { type: "METRICS"; metrics: StreamMetrics };
|
|
681
|
-
|
|
682
744
|
// Add branded types for safety
|
|
683
745
|
export type ModuleId = string & { readonly __brand: unique symbol };
|
|
684
746
|
export type PagePath = string & { readonly __brand: unique symbol };
|
|
685
747
|
|
|
686
|
-
export type
|
|
687
|
-
|
|
748
|
+
export type InlineCssOpt = undefined | boolean;
|
|
749
|
+
export type PagePropOpt = Record<string, unknown> | undefined;
|
|
750
|
+
export type RegExpOpt = RegExp | string | ((path: string) => boolean);
|
|
751
|
+
|
|
752
|
+
export type AsOpt = Exclude<
|
|
753
|
+
keyof React.JSX.IntrinsicElements,
|
|
754
|
+
"symbol" | "object"
|
|
755
|
+
>;
|
|
756
|
+
export type PageComponentType<T extends PagePropOpt = PagePropOpt> =
|
|
757
|
+
React.ComponentType<T & React.PropsWithChildren<{}>>;
|
|
758
|
+
|
|
759
|
+
export type HtmlProps<
|
|
760
|
+
T extends PagePropOpt = PagePropOpt,
|
|
761
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt,
|
|
762
|
+
As extends AsOpt = AsOpt
|
|
763
|
+
> = {
|
|
764
|
+
pageProps?: T;
|
|
765
|
+
Page: PageComponentType<T>;
|
|
688
766
|
route: string;
|
|
689
767
|
url: string;
|
|
690
768
|
projectRoot: string;
|
|
@@ -692,10 +770,12 @@ export type HtmlProps = {
|
|
|
692
770
|
moduleBaseURL: string;
|
|
693
771
|
moduleBasePath: string;
|
|
694
772
|
moduleRootPath: string;
|
|
695
|
-
cssFiles: Map<string, CssContent
|
|
773
|
+
cssFiles: Map<string, CssContent<InlineCSS>>;
|
|
696
774
|
manifest: Manifest;
|
|
697
|
-
CssCollector:
|
|
698
|
-
globalCss: Map<string, CssContent
|
|
775
|
+
CssCollector: CssCollectorBoxedType<T, InlineCSS, As>;
|
|
776
|
+
globalCss: Map<string, CssContent<InlineCSS>>;
|
|
777
|
+
children?: React.ReactNode;
|
|
778
|
+
as: As;
|
|
699
779
|
};
|
|
700
780
|
|
|
701
781
|
export interface PageAsset {
|
|
@@ -709,16 +789,17 @@ type BaseCssProps = {
|
|
|
709
789
|
id: string;
|
|
710
790
|
};
|
|
711
791
|
|
|
712
|
-
type
|
|
792
|
+
export type LinkCssProps = BaseCssProps & {
|
|
713
793
|
as: "link";
|
|
714
794
|
type?: never;
|
|
715
|
-
children?:
|
|
795
|
+
children?: never;
|
|
716
796
|
id: string;
|
|
717
797
|
href: string;
|
|
718
798
|
rel: "stylesheet";
|
|
719
799
|
precedence?: string;
|
|
720
800
|
};
|
|
721
|
-
|
|
801
|
+
|
|
802
|
+
export type StyleCssProps = BaseCssProps & {
|
|
722
803
|
as: "style";
|
|
723
804
|
type: "text/css";
|
|
724
805
|
children?: React.ReactNode;
|
|
@@ -727,60 +808,8 @@ type InlineCssProps = BaseCssProps & {
|
|
|
727
808
|
href?: never;
|
|
728
809
|
};
|
|
729
810
|
|
|
730
|
-
export type CssContent<InlineCSS extends boolean | undefined = undefined> =
|
|
731
|
-
InlineCSS extends true
|
|
732
|
-
? InlineCssProps
|
|
733
|
-
: InlineCSS extends false
|
|
734
|
-
? CssProps
|
|
735
|
-
: CssProps | InlineCssProps;
|
|
736
|
-
|
|
737
|
-
export interface JsContent {
|
|
738
|
-
type?: string;
|
|
739
|
-
content: string;
|
|
740
|
-
key?: string;
|
|
741
|
-
path: string;
|
|
742
|
-
id?: string;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
export type CssCollectorProps<
|
|
746
|
-
InlineCSS extends boolean | undefined = undefined
|
|
747
|
-
> = {
|
|
748
|
-
as?: React.ElementType; // defaults to react fragment
|
|
749
|
-
children?: React.ReactNode; // the children containing the css content
|
|
750
|
-
/** A map containing all the css files imported by the route and their proxy values
|
|
751
|
-
* - when inlineCss is true, will contain the `content` property
|
|
752
|
-
* - when prugeCss is true, will contain the module proxy which includes a `userClasses`
|
|
753
|
-
* @example ```tsx
|
|
754
|
-
* import styles from './styles.module.css';
|
|
755
|
-
* export const Page = () => {
|
|
756
|
-
* return <div className={styles.userClass}>Hello World</div>
|
|
757
|
-
* }
|
|
758
|
-
* ```
|
|
759
|
-
* then the module will basically contain whatever `styles` exported here. But how does it track css class usages
|
|
760
|
-
* during streaming?
|
|
761
|
-
*
|
|
762
|
-
* const tags = Array.from(importedCss?.values() ?? []).map(cssFile => {
|
|
763
|
-
* return <link rel="stylesheet" href={cssFile.path} />
|
|
764
|
-
* })
|
|
765
|
-
* ```
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
* */
|
|
769
|
-
cssFiles?: Map<string, CssContent<InlineCSS>>;
|
|
770
|
-
} & React.HTMLAttributes<HTMLElement>;
|
|
771
|
-
|
|
772
|
-
export interface InlineCssCollectorProps {
|
|
773
|
-
cssFiles: Map<string, CssContent>;
|
|
774
|
-
moduleBaseURL: string;
|
|
775
|
-
moduleRootPath: string;
|
|
776
|
-
moduleBasePath: string;
|
|
777
|
-
route?: string;
|
|
778
|
-
purgeCss?: boolean;
|
|
779
|
-
children?: React.ReactNode;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
811
|
export type CssCollectorElementsProps<
|
|
783
|
-
InlineCSS extends
|
|
812
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
784
813
|
> = {
|
|
785
814
|
cssFiles: Map<string, CssContent<InlineCSS>>;
|
|
786
815
|
};
|
|
@@ -840,27 +869,28 @@ export type RenderPagesResult =
|
|
|
840
869
|
>;
|
|
841
870
|
};
|
|
842
871
|
|
|
843
|
-
export type HandlerAssets = {
|
|
844
|
-
css: CssContent[];
|
|
872
|
+
export type HandlerAssets<InlineCSS extends InlineCssOpt = InlineCssOpt> = {
|
|
873
|
+
css: CssContent<InlineCSS>[];
|
|
845
874
|
js: string[];
|
|
846
875
|
bootstrapModules: string[];
|
|
847
876
|
};
|
|
848
877
|
|
|
849
|
-
export type CreateHandlerResult =
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
878
|
+
export type CreateHandlerResult<InlineCSS extends InlineCssOpt = InlineCssOpt> =
|
|
879
|
+
|
|
880
|
+
| {
|
|
881
|
+
type: "success";
|
|
882
|
+
controller: AbortController;
|
|
883
|
+
stream: any;
|
|
884
|
+
assets: {
|
|
885
|
+
css: CssContent<InlineCSS>[];
|
|
886
|
+
js: string[];
|
|
887
|
+
bootstrapModules: string[];
|
|
888
|
+
};
|
|
889
|
+
route: string;
|
|
890
|
+
metrics: StreamMetrics;
|
|
891
|
+
}
|
|
892
|
+
| { type: "error"; error: Error }
|
|
893
|
+
| { type: "skip" };
|
|
864
894
|
|
|
865
895
|
export type ReactStaticEvent =
|
|
866
896
|
| FileWriteEvent
|
|
@@ -874,7 +904,14 @@ export type ReactStaticEvent =
|
|
|
874
904
|
|
|
875
905
|
// Define LoaderContext interface locally
|
|
876
906
|
export interface LoaderContext {
|
|
877
|
-
|
|
907
|
+
format?: string;
|
|
908
|
+
importAttributes?: Record<string, string>;
|
|
909
|
+
conditions?: string[];
|
|
910
|
+
env?: {
|
|
911
|
+
targetEnvironment?: "client" | "server" | "browser";
|
|
912
|
+
};
|
|
913
|
+
url: string;
|
|
914
|
+
userOptions?: any; // Add userOptions to the context
|
|
878
915
|
}
|
|
879
916
|
// Add type declaration for import.meta.cssModules
|
|
880
917
|
declare global {
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createFromFetch,
|
|
3
3
|
encodeReply,
|
|
4
|
-
// @ts-ignore
|
|
5
4
|
} from "react-server-dom-esm/client.browser";
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
interface ServerActionResponse {
|
|
7
|
+
returnValue: unknown;
|
|
8
|
+
type: 'server-action-response';
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
8
11
|
|
|
9
12
|
export const createCallServer = (moduleBaseURL: string) => {
|
|
10
|
-
const callServer = async (
|
|
13
|
+
const callServer = async (id: string, args: unknown[]): Promise<unknown> => {
|
|
11
14
|
const response = await createFromFetch(
|
|
12
15
|
fetch(moduleBaseURL, {
|
|
13
16
|
method: "POST",
|
|
14
|
-
body: await encodeReply(
|
|
17
|
+
body: await encodeReply({
|
|
18
|
+
id,
|
|
19
|
+
args
|
|
20
|
+
}),
|
|
15
21
|
headers: {
|
|
16
22
|
Accept: "application/json",
|
|
17
23
|
"Content-Type": "application/json",
|
|
@@ -19,8 +25,17 @@ export const createCallServer = (moduleBaseURL: string) => {
|
|
|
19
25
|
}),
|
|
20
26
|
{ callServer, moduleBaseURL }
|
|
21
27
|
);
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
|
|
29
|
+
// Check if this is a server action response
|
|
30
|
+
if (response && typeof response === 'object' && 'returnValue' in response) {
|
|
31
|
+
const serverResponse = response as ServerActionResponse;
|
|
32
|
+
if (serverResponse.error) {
|
|
33
|
+
throw new Error(serverResponse.error);
|
|
34
|
+
}
|
|
35
|
+
return serverResponse.returnValue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return response;
|
|
24
39
|
};
|
|
25
40
|
return callServer;
|
|
26
41
|
};
|
package/plugin/utils/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ const nodeRequire = createRequire(join(projectRoot, "package.json"));
|
|
|
7
7
|
|
|
8
8
|
// Import ReactDOM from the project's node_modules
|
|
9
9
|
const ReactDOMServer = nodeRequire("react-dom/server");
|
|
10
|
+
const ReactDOMClient = nodeRequire("react-server-dom-esm/client");
|
|
10
11
|
const React = nodeRequire("react");
|
|
11
12
|
|
|
12
|
-
export { ReactDOMServer, React };
|
|
13
|
+
export { ReactDOMServer, React, ReactDOMClient };
|
|
@@ -6,7 +6,7 @@ const projectRoot = workerData?.projectRoot || process.env["npm_config_local_pre
|
|
|
6
6
|
const nodeRequire = createRequire(join(projectRoot, "package.json"));
|
|
7
7
|
|
|
8
8
|
// Import ReactDOM from the project's node_modules
|
|
9
|
-
const ReactDOMServer = nodeRequire("react-server-dom-esm/server");
|
|
9
|
+
const ReactDOMServer = nodeRequire("react-server-dom-esm/server.node");
|
|
10
10
|
const React = nodeRequire("react");
|
|
11
11
|
|
|
12
12
|
export { ReactDOMServer, React };
|
|
@@ -12,6 +12,7 @@ import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
|
12
12
|
import { createLogger, type Logger } from "vite";
|
|
13
13
|
import type { HtmlWorkerOutputMessage } from "./types.js";
|
|
14
14
|
import type { RscWorkerOutputMessage } from "./types.js";
|
|
15
|
+
import { toError } from "../error/toError.js";
|
|
15
16
|
|
|
16
17
|
export type CreateWorkerOptions = {
|
|
17
18
|
projectRoot?: string;
|
|
@@ -73,14 +74,11 @@ export async function createWorker(
|
|
|
73
74
|
logger = createLogger(),
|
|
74
75
|
verbose = false,
|
|
75
76
|
} = options;
|
|
77
|
+
const id = reverseCondition === "react-server" ? "worker/rsc" : "worker/html";
|
|
76
78
|
let workerPathWithDefault =
|
|
77
79
|
typeof workerPath === "string" ? workerPath : undefined;
|
|
78
80
|
if (!workerPathWithDefault) {
|
|
79
|
-
|
|
80
|
-
workerPathWithDefault = join(pluginRoot, `worker/rsc`);
|
|
81
|
-
} else {
|
|
82
|
-
workerPathWithDefault = join(pluginRoot, `worker/html`);
|
|
83
|
-
}
|
|
81
|
+
workerPathWithDefault = join(pluginRoot, id);
|
|
84
82
|
}
|
|
85
83
|
if (!workerPathWithDefault.startsWith("/")) {
|
|
86
84
|
workerPathWithDefault = join("./", workerPathWithDefault);
|
|
@@ -89,6 +87,7 @@ export async function createWorker(
|
|
|
89
87
|
const workerData = {
|
|
90
88
|
...options.workerData,
|
|
91
89
|
reactVersion: React.version,
|
|
90
|
+
id: id,
|
|
92
91
|
};
|
|
93
92
|
|
|
94
93
|
try {
|
|
@@ -147,24 +146,25 @@ export async function createWorker(
|
|
|
147
146
|
workerPath: workerPathWithDefault,
|
|
148
147
|
} satisfies CreateWorkerSkip);
|
|
149
148
|
} else {
|
|
150
|
-
const error =
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
error,
|
|
149
|
+
const error = `[create:${id}] exited with code ${code}`;
|
|
150
|
+
resolve({
|
|
151
|
+
type: "skip",
|
|
152
|
+
reason: error,
|
|
155
153
|
workerPath: workerPathWithDefault,
|
|
156
|
-
} satisfies
|
|
154
|
+
} satisfies CreateWorkerSkip);
|
|
157
155
|
}
|
|
158
156
|
};
|
|
159
|
-
const messageHandler = (
|
|
160
|
-
|
|
157
|
+
const messageHandler = (
|
|
158
|
+
msg: HtmlWorkerOutputMessage | RscWorkerOutputMessage
|
|
159
|
+
) => {
|
|
160
|
+
if (verbose) logger.info(`[create:${id}] Initial worker message ${msg.type}`);
|
|
161
161
|
if (msg.type === "READY") {
|
|
162
|
-
if (verbose) logger.info(`Worker running for ${msg.env}`);
|
|
162
|
+
if (verbose) logger.info(`[create:${id}] Worker running for ${msg.env}`);
|
|
163
163
|
clearTimeout(timeout);
|
|
164
164
|
worker.removeListener("message", messageHandler);
|
|
165
165
|
worker.removeListener("exit", exitHandler);
|
|
166
166
|
if (msg.env !== nodeEnv) {
|
|
167
|
-
if (verbose) logger.info(`Worker environment mismatch.`);
|
|
167
|
+
if (verbose) logger.info(`[create:${id}] Worker environment mismatch.`);
|
|
168
168
|
reject({
|
|
169
169
|
type: "error",
|
|
170
170
|
error: new Error(
|
|
@@ -179,19 +179,16 @@ export async function createWorker(
|
|
|
179
179
|
workerPath: workerPathWithDefault,
|
|
180
180
|
} satisfies CreateWorkerSuccess);
|
|
181
181
|
}
|
|
182
|
-
}
|
|
182
|
+
};
|
|
183
183
|
worker.once("message", messageHandler);
|
|
184
184
|
worker.once("exit", exitHandler);
|
|
185
185
|
}
|
|
186
186
|
);
|
|
187
187
|
} catch (error) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
} satisfies CreateWorkerError;
|
|
194
|
-
}
|
|
195
|
-
return error as CreateWorkerError;
|
|
188
|
+
return {
|
|
189
|
+
type: "error",
|
|
190
|
+
error: toError(error),
|
|
191
|
+
workerPath: workerPathWithDefault,
|
|
192
|
+
};
|
|
196
193
|
}
|
|
197
194
|
}
|