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
|
@@ -10,7 +10,12 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { PassThrough, Transform } from "node:stream";
|
|
13
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
CreateHandlerOptions,
|
|
15
|
+
StreamMetrics,
|
|
16
|
+
PagePropOpt,
|
|
17
|
+
InlineCssOpt,
|
|
18
|
+
} from "../types.js";
|
|
14
19
|
import { createStreamMetrics } from "../helpers/metrics.js";
|
|
15
20
|
import { createRscToHtmlStream } from "./rscToHtmlStream.js";
|
|
16
21
|
import { fileWriter } from "./fileWriter.js";
|
|
@@ -21,9 +26,12 @@ import { fileWriter } from "./fileWriter.js";
|
|
|
21
26
|
* @param rscFull The stream containing the RSC content
|
|
22
27
|
* @returns A promise that resolves with the complete RSC content
|
|
23
28
|
*/
|
|
24
|
-
export async function collectHtmlWorkerContent
|
|
29
|
+
export async function collectHtmlWorkerContent<
|
|
30
|
+
T extends PagePropOpt = PagePropOpt,
|
|
31
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
32
|
+
>(
|
|
25
33
|
rscStream: PassThrough,
|
|
26
|
-
handlerOptions: CreateHandlerOptions
|
|
34
|
+
handlerOptions: CreateHandlerOptions<T, InlineCSS>
|
|
27
35
|
): Promise<{ stream: PassThrough; metrics: StreamMetrics }> {
|
|
28
36
|
if (!handlerOptions.worker) {
|
|
29
37
|
throw new Error("Worker is not a valid worker");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* rscHandler.ts
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* PURPOSE: Handles collecting RSC content from the rscHeadless stream
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* This module:
|
|
7
7
|
* 1. Collects RSC content from the rscHeadless stream
|
|
8
8
|
* 2. Returns the complete RSC content when the stream is done
|
|
@@ -12,20 +12,28 @@
|
|
|
12
12
|
import { PassThrough, Transform } from "node:stream";
|
|
13
13
|
import { dirname, join } from "node:path";
|
|
14
14
|
import { mkdir } from "node:fs/promises";
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
CreateHandlerOptions,
|
|
17
|
+
StreamMetrics,
|
|
18
|
+
PagePropOpt,
|
|
19
|
+
InlineCssOpt,
|
|
20
|
+
} from "../types.js";
|
|
16
21
|
import { createStreamMetrics } from "../helpers/metrics.js";
|
|
17
22
|
import { fileWriter } from "./fileWriter.js";
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* Collects RSC content from the rscHeadless stream
|
|
21
|
-
*
|
|
26
|
+
*
|
|
22
27
|
* @param rscStream The stream containing the RSC content
|
|
23
28
|
* @param handlerOptions The options for the handler
|
|
24
29
|
* @returns A promise that resolves with the complete RSC content and metrics
|
|
25
30
|
*/
|
|
26
|
-
export async function collectRscContent
|
|
31
|
+
export async function collectRscContent<
|
|
32
|
+
T extends PagePropOpt = PagePropOpt,
|
|
33
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
34
|
+
>(
|
|
27
35
|
rscStream: PassThrough,
|
|
28
|
-
handlerOptions: CreateHandlerOptions
|
|
36
|
+
handlerOptions: CreateHandlerOptions<T, InlineCSS>
|
|
29
37
|
): Promise<{ stream: PassThrough; metrics: StreamMetrics }> {
|
|
30
38
|
const metrics = createStreamMetrics();
|
|
31
39
|
const startTime = performance.now();
|
|
@@ -51,7 +59,7 @@ export async function collectRscContent(
|
|
|
51
59
|
flush(callback) {
|
|
52
60
|
metrics.duration = performance.now() - startTime;
|
|
53
61
|
callback();
|
|
54
|
-
}
|
|
62
|
+
},
|
|
55
63
|
});
|
|
56
64
|
|
|
57
65
|
try {
|
|
@@ -63,7 +71,7 @@ export async function collectRscContent(
|
|
|
63
71
|
|
|
64
72
|
// Wait for stream to complete
|
|
65
73
|
await new Promise<void>((resolve) => {
|
|
66
|
-
metricsTransform.on(
|
|
74
|
+
metricsTransform.on("end", resolve);
|
|
67
75
|
});
|
|
68
76
|
|
|
69
77
|
// Wait for file writing to complete
|
|
@@ -74,4 +82,4 @@ export async function collectRscContent(
|
|
|
74
82
|
metricsTransform.destroy();
|
|
75
83
|
throw error;
|
|
76
84
|
}
|
|
77
|
-
}
|
|
85
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { PreviewServer } from "vite";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
ResolvedUserOptions,
|
|
4
|
+
PagePropOpt,
|
|
5
|
+
InlineCssOpt,
|
|
6
|
+
} from "../types.js";
|
|
3
7
|
import { join } from "node:path";
|
|
4
8
|
import { createReadStream } from "node:fs";
|
|
5
9
|
import { stat } from "node:fs/promises";
|
|
@@ -10,12 +14,15 @@ interface StreamError extends Error {
|
|
|
10
14
|
code?: string;
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
export async function configurePreviewServer
|
|
17
|
+
export async function configurePreviewServer<
|
|
18
|
+
T extends PagePropOpt = PagePropOpt,
|
|
19
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
20
|
+
>({
|
|
14
21
|
server,
|
|
15
22
|
userOptions,
|
|
16
23
|
}: {
|
|
17
24
|
server: PreviewServer;
|
|
18
|
-
userOptions: ResolvedUserOptions
|
|
25
|
+
userOptions: ResolvedUserOptions<T, InlineCSS>;
|
|
19
26
|
}) {
|
|
20
27
|
const staticHostDir = join(
|
|
21
28
|
userOptions.projectRoot,
|
|
@@ -26,15 +33,20 @@ export async function configurePreviewServer({
|
|
|
26
33
|
if (!req.url) {
|
|
27
34
|
return next();
|
|
28
35
|
}
|
|
29
|
-
const { contentType, filePath } = requestInfo(
|
|
30
|
-
|
|
36
|
+
const { contentType, filePath } = requestInfo(
|
|
37
|
+
req,
|
|
38
|
+
userOptions,
|
|
39
|
+
staticHostDir,
|
|
40
|
+
server.config.logger
|
|
41
|
+
);
|
|
42
|
+
|
|
31
43
|
// Handle static files including CSS
|
|
32
44
|
if (filePath) {
|
|
33
45
|
try {
|
|
34
46
|
const stats = await stat(filePath);
|
|
35
47
|
if (stats.isFile()) {
|
|
36
48
|
res.setHeader("Content-Type", contentType);
|
|
37
|
-
|
|
49
|
+
|
|
38
50
|
// Create abort controller for the stream
|
|
39
51
|
const controller = new AbortController();
|
|
40
52
|
const { signal } = controller;
|
|
@@ -48,7 +60,7 @@ export async function configurePreviewServer({
|
|
|
48
60
|
|
|
49
61
|
try {
|
|
50
62
|
const readStream = createReadStream(filePath);
|
|
51
|
-
readStream.on(
|
|
63
|
+
readStream.on("error", () => {
|
|
52
64
|
if (!res.writable) {
|
|
53
65
|
controller.abort();
|
|
54
66
|
}
|
|
@@ -57,25 +69,33 @@ export async function configurePreviewServer({
|
|
|
57
69
|
} catch (error) {
|
|
58
70
|
const streamError = error as StreamError;
|
|
59
71
|
// Handle different error cases
|
|
60
|
-
if (
|
|
61
|
-
|
|
72
|
+
if (
|
|
73
|
+
streamError.code === "ERR_STREAM_PREMATURE_CLOSE" ||
|
|
74
|
+
streamError.name === "AbortError"
|
|
75
|
+
) {
|
|
62
76
|
// Client closed the connection
|
|
63
77
|
if (res.writable) {
|
|
64
78
|
res.statusCode = 499;
|
|
65
79
|
res.end("Client closed request");
|
|
66
80
|
}
|
|
67
|
-
} else if (streamError.code ===
|
|
81
|
+
} else if (streamError.code === "ENOENT") {
|
|
68
82
|
// File not found
|
|
69
83
|
res.statusCode = 404;
|
|
70
|
-
server.config.logger.error(
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
server.config.logger.error(
|
|
85
|
+
`File not found: ${filePath}. ${streamError.message}`,
|
|
86
|
+
{
|
|
87
|
+
error: streamError,
|
|
88
|
+
}
|
|
89
|
+
);
|
|
73
90
|
res.end("File not found");
|
|
74
91
|
} else {
|
|
75
92
|
// Server error
|
|
76
|
-
server.config.logger.error(
|
|
77
|
-
|
|
78
|
-
|
|
93
|
+
server.config.logger.error(
|
|
94
|
+
`Error loading file: ${filePath}. ${streamError.message}`,
|
|
95
|
+
{
|
|
96
|
+
error: streamError,
|
|
97
|
+
}
|
|
98
|
+
);
|
|
79
99
|
res.statusCode = 500;
|
|
80
100
|
res.end("Internal server error");
|
|
81
101
|
}
|
|
@@ -86,7 +106,7 @@ export async function configurePreviewServer({
|
|
|
86
106
|
} catch (error) {
|
|
87
107
|
const err = error as Error;
|
|
88
108
|
// Handle file system errors
|
|
89
|
-
if ((err as NodeJS.ErrnoException).code ===
|
|
109
|
+
if ((err as NodeJS.ErrnoException).code === "ENOENT") {
|
|
90
110
|
res.statusCode = 404;
|
|
91
111
|
res.end("File not found");
|
|
92
112
|
} else {
|
|
@@ -34,6 +34,8 @@ import type {
|
|
|
34
34
|
RenderPagesResult,
|
|
35
35
|
AutoDiscoveredFiles,
|
|
36
36
|
CssContent,
|
|
37
|
+
PagePropOpt,
|
|
38
|
+
InlineCssOpt,
|
|
37
39
|
} from "../types.js";
|
|
38
40
|
import { type StreamPluginOptions } from "../types.js";
|
|
39
41
|
import { renderPages } from "./renderPages.js";
|
|
@@ -51,6 +53,7 @@ import { tryManifest } from "../helpers/tryManifest.js";
|
|
|
51
53
|
import { performance } from "node:perf_hooks";
|
|
52
54
|
import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
53
55
|
import { baseURL } from "../utils/envUrls.node.js";
|
|
56
|
+
import { readFile } from "node:fs/promises";
|
|
54
57
|
|
|
55
58
|
if (getCondition() !== "react-server") {
|
|
56
59
|
throw new Error(
|
|
@@ -59,16 +62,21 @@ if (getCondition() !== "react-server") {
|
|
|
59
62
|
);
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
let buildLoader: Awaited<ReturnType<typeof createBuildLoader>> | undefined;
|
|
69
|
-
export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
65
|
+
export function reactStaticPlugin<
|
|
66
|
+
T extends PagePropOpt = PagePropOpt,
|
|
67
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
68
|
+
>(
|
|
69
|
+
options: StreamPluginOptions<T, InlineCSS>
|
|
70
|
+
): VitePlugin<{
|
|
70
71
|
meta: ReactStreamPluginMeta;
|
|
71
72
|
}> {
|
|
73
|
+
let worker: Worker;
|
|
74
|
+
let userConfig: ResolvedUserConfig;
|
|
75
|
+
let resolvedConfig: ResolvedConfig;
|
|
76
|
+
let userOptions: ResolvedUserOptions<T, InlineCSS>;
|
|
77
|
+
let autoDiscoveredFiles: AutoDiscoveredFiles | null = null;
|
|
78
|
+
let serverManifest: Manifest | undefined = undefined;
|
|
79
|
+
let buildLoader: Awaited<ReturnType<typeof createBuildLoader>> | undefined;
|
|
72
80
|
const timing: BuildTiming = {
|
|
73
81
|
start: Date.now(),
|
|
74
82
|
configResolved: 0,
|
|
@@ -93,6 +101,10 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
|
93
101
|
if (config.root && config.root !== userOptions.projectRoot) {
|
|
94
102
|
userOptions.projectRoot = config.root;
|
|
95
103
|
}
|
|
104
|
+
if(configEnv.command !== "build") {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Initialize autoDiscoveredFiles for both server and client builds
|
|
96
108
|
const autoDiscoverResult = await resolveAutoDiscover({
|
|
97
109
|
config,
|
|
98
110
|
configEnv,
|
|
@@ -134,7 +146,6 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
|
134
146
|
},
|
|
135
147
|
|
|
136
148
|
async renderStart() {
|
|
137
|
-
|
|
138
149
|
timing.renderStart = Date.now();
|
|
139
150
|
},
|
|
140
151
|
|
|
@@ -165,7 +176,7 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
|
165
176
|
if (!serverManifest) {
|
|
166
177
|
throw new Error("Failed to parse server manifest");
|
|
167
178
|
}
|
|
168
|
-
|
|
179
|
+
|
|
169
180
|
const clientManifestResult = await tryManifest({
|
|
170
181
|
root: userOptions.projectRoot,
|
|
171
182
|
outDir: join(userOptions.build.outDir, userOptions.build.client),
|
|
@@ -175,11 +186,11 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
|
175
186
|
throw clientManifestResult.error;
|
|
176
187
|
}
|
|
177
188
|
const clientManifest = clientManifestResult.manifest;
|
|
178
|
-
|
|
179
|
-
buildLoader = await createBuildLoader(
|
|
189
|
+
|
|
190
|
+
buildLoader = await createBuildLoader<T, InlineCSS>(
|
|
180
191
|
{
|
|
181
192
|
userConfig,
|
|
182
|
-
userOptions,
|
|
193
|
+
userOptions: userOptions as ResolvedUserOptions<T, InlineCSS>,
|
|
183
194
|
serverManifest: serverManifest ?? {},
|
|
184
195
|
staticManifest: autoDiscoveredFiles?.staticManifest ?? {},
|
|
185
196
|
clientManifest: clientManifest ?? {},
|
|
@@ -197,7 +208,7 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
|
197
208
|
userOptions
|
|
198
209
|
);
|
|
199
210
|
|
|
200
|
-
const globalCss: Map<string, CssContent
|
|
211
|
+
const globalCss: Map<string, CssContent<InlineCSS>> = new Map();
|
|
201
212
|
// Collect CSS files for each page and its props
|
|
202
213
|
for (const [url, { page, props }] of autoDiscoveredFiles?.urlMap ??
|
|
203
214
|
[]) {
|
|
@@ -226,17 +237,25 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
|
226
237
|
const pageCssMap: Map<string, CssContent> = new Map();
|
|
227
238
|
// Add global styles if they exist
|
|
228
239
|
if (Object.keys(globalCssInputs).length > 0) {
|
|
229
|
-
for (const [, value] of Object.entries(globalCssInputs)) {
|
|
230
|
-
|
|
231
|
-
|
|
240
|
+
for (const [key, value] of Object.entries(globalCssInputs)) {
|
|
241
|
+
let cssContent = await buildLoader(value + "?inline").then((r) =>
|
|
242
|
+
String(r.default)
|
|
232
243
|
);
|
|
233
|
-
if (cssContent === "undefined") {
|
|
234
|
-
|
|
244
|
+
if (cssContent === "undefined" || !cssContent) {
|
|
245
|
+
cssContent = await readFile(
|
|
246
|
+
join(
|
|
247
|
+
userOptions.projectRoot,
|
|
248
|
+
userOptions.build.outDir,
|
|
249
|
+
userOptions.build.static,
|
|
250
|
+
key + ".css"
|
|
251
|
+
),
|
|
252
|
+
"utf-8"
|
|
253
|
+
) ?? ""
|
|
235
254
|
}
|
|
236
255
|
if (cssContent) {
|
|
237
256
|
globalCss.set(
|
|
238
257
|
value,
|
|
239
|
-
createCssProps({
|
|
258
|
+
createCssProps<T, InlineCSS>({
|
|
240
259
|
id: value,
|
|
241
260
|
code: cssContent,
|
|
242
261
|
userOptions: userOptions,
|
|
@@ -355,6 +374,10 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
|
355
374
|
client: userOptions.build.client,
|
|
356
375
|
},
|
|
357
376
|
globalCss: globalCss,
|
|
377
|
+
css: {
|
|
378
|
+
...handlerOptions.css,
|
|
379
|
+
inlineCss: handlerOptions.css?.inlineCss ?? true,
|
|
380
|
+
},
|
|
358
381
|
},
|
|
359
382
|
cssFilesByPage
|
|
360
383
|
);
|
|
@@ -378,9 +401,9 @@ export function reactStaticPlugin(options: StreamPluginOptions): VitePlugin<{
|
|
|
378
401
|
this.environment.logger.info(
|
|
379
402
|
`Rendered ${finalResult.completedRoutes.size} unique routes in ${finalResult.streamMetrics.duration}ms`
|
|
380
403
|
);
|
|
381
|
-
if(process.env[
|
|
404
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
382
405
|
this.environment.logger.warn(
|
|
383
|
-
`THIS IS BUILD IS NOT INTENDED FOR PRODUCTION (${process.env[
|
|
406
|
+
`THIS IS BUILD IS NOT INTENDED FOR PRODUCTION (${process.env["NODE_ENV"]})`
|
|
384
407
|
);
|
|
385
408
|
}
|
|
386
409
|
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { createRenderMetrics } from "../helpers/metrics.js";
|
|
2
2
|
import { resolvePageAndProps } from "../helpers/resolvePageAndProps.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
CreateHandlerOptions,
|
|
5
|
+
RenderPageResult,
|
|
6
|
+
PagePropOpt,
|
|
7
|
+
} from "../types.js";
|
|
4
8
|
import { renderStreams } from "./renderStreams.js";
|
|
5
9
|
import { collectHtmlWorkerContent } from "./collectHtmlWorkerContent.js";
|
|
6
10
|
import { collectRscContent } from "./collectRscContent.js";
|
|
7
11
|
|
|
8
|
-
export async function* renderPage
|
|
9
|
-
|
|
12
|
+
export async function* renderPage<
|
|
13
|
+
T extends PagePropOpt = PagePropOpt
|
|
14
|
+
>(
|
|
15
|
+
handlerOptions: CreateHandlerOptions<T>
|
|
10
16
|
): AsyncGenerator<RenderPageResult, void, unknown> {
|
|
11
17
|
if (!handlerOptions.pagePath) {
|
|
12
18
|
yield {
|
|
@@ -39,9 +45,9 @@ export async function* renderPage(
|
|
|
39
45
|
|
|
40
46
|
const newHandlerOptions = {
|
|
41
47
|
...handlerOptions,
|
|
42
|
-
PageComponent
|
|
43
|
-
pageProps
|
|
44
|
-
}
|
|
48
|
+
PageComponent,
|
|
49
|
+
pageProps,
|
|
50
|
+
} as CreateHandlerOptions<T>;
|
|
45
51
|
// Create streams with CSS files
|
|
46
52
|
const [rscFull, rscHeadless] = await renderStreams(newHandlerOptions);
|
|
47
53
|
// Handle stream creation errors
|
|
@@ -12,12 +12,23 @@
|
|
|
12
12
|
import { createRenderMetrics } from "../helpers/metrics.js";
|
|
13
13
|
import { renderPage } from "./renderPage.js";
|
|
14
14
|
import { PassThrough } from "node:stream";
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
StreamMetrics,
|
|
17
|
+
RenderPagesResult,
|
|
18
|
+
AutoDiscoveredFiles,
|
|
19
|
+
CssContent,
|
|
20
|
+
MultiPageHandlerOptions,
|
|
21
|
+
PagePropOpt,
|
|
22
|
+
InlineCssOpt,
|
|
23
|
+
} from "../types.js";
|
|
16
24
|
|
|
17
|
-
export async function* renderPages
|
|
25
|
+
export async function* renderPages<
|
|
26
|
+
T extends PagePropOpt = PagePropOpt,
|
|
27
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
28
|
+
>(
|
|
18
29
|
autoDiscoveredFiles: AutoDiscoveredFiles,
|
|
19
|
-
handlerOptions: MultiPageHandlerOptions
|
|
20
|
-
cssFilesByPage: Map<string, Map<string, CssContent
|
|
30
|
+
handlerOptions: MultiPageHandlerOptions<T>,
|
|
31
|
+
cssFilesByPage: Map<string, Map<string, CssContent<InlineCSS>>>
|
|
21
32
|
): AsyncGenerator<RenderPagesResult, RenderPagesResult, unknown> {
|
|
22
33
|
const routes = Array.from(autoDiscoveredFiles.urlMap.keys());
|
|
23
34
|
const completedRoutes = new Set<string>();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* renderStreams.ts
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* PURPOSE: Creates specialized streams for React Server Components (RSC) rendering
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* This module:
|
|
7
7
|
* 1. Creates RSC stream (React.Fragment wrapper) for client-side navigation
|
|
8
8
|
* - This stream is saved to .rsc files and used when navigating between pages
|
|
@@ -17,32 +17,33 @@
|
|
|
17
17
|
import { createHandler } from "../helpers/createHandler.js";
|
|
18
18
|
import type {
|
|
19
19
|
CreateHandlerOptions,
|
|
20
|
+
PagePropOpt
|
|
20
21
|
} from "../types.js";
|
|
21
22
|
import React from "react";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Creates handlers for both document and RSC streams
|
|
25
|
-
*
|
|
26
|
+
*
|
|
26
27
|
* @param handler The handler options for creating streams
|
|
27
28
|
* @param options The render options
|
|
28
29
|
* @returns A tuple containing the document worker result and RSC direct result
|
|
29
30
|
*/
|
|
30
|
-
export function renderStreams
|
|
31
|
-
|
|
32
|
-
) {
|
|
31
|
+
export function renderStreams<
|
|
32
|
+
T extends PagePropOpt = PagePropOpt
|
|
33
|
+
>(handler: CreateHandlerOptions<T>) {
|
|
33
34
|
return Promise.all([
|
|
34
35
|
/**
|
|
35
|
-
* This stream goes to the document worker for client side rendering with full HTML structure,
|
|
36
|
-
* links are already bubbled up in the static document which required us
|
|
36
|
+
* This stream goes to the document worker for client side rendering with full HTML structure,
|
|
37
|
+
* links are already bubbled up in the static document which required us
|
|
37
38
|
* to include the head in the stream as well
|
|
38
39
|
*/
|
|
39
40
|
createHandler(handler),
|
|
40
|
-
|
|
41
|
+
|
|
41
42
|
/**
|
|
42
|
-
* This stream is saved to index.rsc file (if configured) and can be used
|
|
43
|
-
* for navigating to pages (without the Html wrapper, but does contain
|
|
43
|
+
* This stream is saved to index.rsc file (if configured) and can be used
|
|
44
|
+
* for navigating to pages (without the Html wrapper, but does contain
|
|
44
45
|
* css/head information that can bubble up to the browser's dom)
|
|
45
46
|
*/
|
|
46
|
-
createHandler({...handler, Html: React.Fragment}),
|
|
47
|
+
createHandler({ ...handler, Html: React.Fragment }),
|
|
47
48
|
]);
|
|
48
49
|
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// alternative to webpack-sources/lib/helpers/createMappingsSerializer.js
|
|
2
|
+
// unused for now, but it's a dependency of react-server-dom-esm and you may or may not want to download webpack-sources
|
|
3
|
+
export function createMappingsSerializer() {
|
|
4
|
+
let generatedLine = 1;
|
|
5
|
+
let generatedColumn = 0;
|
|
6
|
+
let sourceIndex = 0;
|
|
7
|
+
let originalLine = 1;
|
|
8
|
+
let originalColumn = 0;
|
|
9
|
+
let nameIndex = 0;
|
|
10
|
+
let mappings = "";
|
|
11
|
+
|
|
12
|
+
return function serializeMapping(
|
|
13
|
+
newGeneratedLine: number,
|
|
14
|
+
newGeneratedColumn: number,
|
|
15
|
+
newSourceIndex: number,
|
|
16
|
+
newOriginalLine: number,
|
|
17
|
+
newOriginalColumn: number,
|
|
18
|
+
newNameIndex: number
|
|
19
|
+
) {
|
|
20
|
+
if (newGeneratedLine !== generatedLine) {
|
|
21
|
+
generatedLine = newGeneratedLine;
|
|
22
|
+
generatedColumn = newGeneratedColumn;
|
|
23
|
+
if (mappings) {
|
|
24
|
+
mappings += ";";
|
|
25
|
+
}
|
|
26
|
+
} else if (mappings) {
|
|
27
|
+
mappings += ",";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Encode the generated column.
|
|
31
|
+
let value = newGeneratedColumn - generatedColumn;
|
|
32
|
+
generatedColumn = newGeneratedColumn;
|
|
33
|
+
let isNegative = value < 0;
|
|
34
|
+
if (isNegative) {
|
|
35
|
+
value = -value;
|
|
36
|
+
}
|
|
37
|
+
value = value << 1;
|
|
38
|
+
if (isNegative) {
|
|
39
|
+
value = value | 1;
|
|
40
|
+
}
|
|
41
|
+
while (value > 0) {
|
|
42
|
+
let digit = value & 63;
|
|
43
|
+
value = value >>> 6;
|
|
44
|
+
if (value > 0) {
|
|
45
|
+
digit = digit | 64;
|
|
46
|
+
}
|
|
47
|
+
mappings += String.fromCharCode(
|
|
48
|
+
digit < 26
|
|
49
|
+
? digit + 65
|
|
50
|
+
: digit < 52
|
|
51
|
+
? digit + 97 - 26
|
|
52
|
+
: digit < 62
|
|
53
|
+
? digit + 48 - 52
|
|
54
|
+
: digit === 62
|
|
55
|
+
? 43
|
|
56
|
+
: 47
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Encode the source index.
|
|
61
|
+
value = newSourceIndex - sourceIndex;
|
|
62
|
+
sourceIndex = newSourceIndex;
|
|
63
|
+
isNegative = value < 0;
|
|
64
|
+
if (isNegative) {
|
|
65
|
+
value = -value;
|
|
66
|
+
}
|
|
67
|
+
value = value << 1;
|
|
68
|
+
if (isNegative) {
|
|
69
|
+
value = value | 1;
|
|
70
|
+
}
|
|
71
|
+
while (value > 0) {
|
|
72
|
+
let digit = value & 63;
|
|
73
|
+
value = value >>> 6;
|
|
74
|
+
if (value > 0) {
|
|
75
|
+
digit = digit | 64;
|
|
76
|
+
}
|
|
77
|
+
mappings += String.fromCharCode(
|
|
78
|
+
digit < 26
|
|
79
|
+
? digit + 65
|
|
80
|
+
: digit < 52
|
|
81
|
+
? digit + 97 - 26
|
|
82
|
+
: digit < 62
|
|
83
|
+
? digit + 48 - 52
|
|
84
|
+
: digit === 62
|
|
85
|
+
? 43
|
|
86
|
+
: 47
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Encode the original line.
|
|
91
|
+
value = newOriginalLine - originalLine;
|
|
92
|
+
originalLine = newOriginalLine;
|
|
93
|
+
isNegative = value < 0;
|
|
94
|
+
if (isNegative) {
|
|
95
|
+
value = -value;
|
|
96
|
+
}
|
|
97
|
+
value = value << 1;
|
|
98
|
+
if (isNegative) {
|
|
99
|
+
value = value | 1;
|
|
100
|
+
}
|
|
101
|
+
while (value > 0) {
|
|
102
|
+
let digit = value & 63;
|
|
103
|
+
value = value >>> 6;
|
|
104
|
+
if (value > 0) {
|
|
105
|
+
digit = digit | 64;
|
|
106
|
+
}
|
|
107
|
+
mappings += String.fromCharCode(
|
|
108
|
+
digit < 26
|
|
109
|
+
? digit + 65
|
|
110
|
+
: digit < 52
|
|
111
|
+
? digit + 97 - 26
|
|
112
|
+
: digit < 62
|
|
113
|
+
? digit + 48 - 52
|
|
114
|
+
: digit === 62
|
|
115
|
+
? 43
|
|
116
|
+
: 47
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Encode the original column.
|
|
121
|
+
value = newOriginalColumn - originalColumn;
|
|
122
|
+
originalColumn = newOriginalColumn;
|
|
123
|
+
isNegative = value < 0;
|
|
124
|
+
if (isNegative) {
|
|
125
|
+
value = -value;
|
|
126
|
+
}
|
|
127
|
+
value = value << 1;
|
|
128
|
+
if (isNegative) {
|
|
129
|
+
value = value | 1;
|
|
130
|
+
}
|
|
131
|
+
while (value > 0) {
|
|
132
|
+
let digit = value & 63;
|
|
133
|
+
value = value >>> 6;
|
|
134
|
+
if (value > 0) {
|
|
135
|
+
digit = digit | 64;
|
|
136
|
+
}
|
|
137
|
+
mappings += String.fromCharCode(
|
|
138
|
+
digit < 26
|
|
139
|
+
? digit + 65
|
|
140
|
+
: digit < 52
|
|
141
|
+
? digit + 97 - 26
|
|
142
|
+
: digit < 62
|
|
143
|
+
? digit + 48 - 52
|
|
144
|
+
: digit === 62
|
|
145
|
+
? 43
|
|
146
|
+
: 47
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Encode the name index.
|
|
151
|
+
value = newNameIndex - nameIndex;
|
|
152
|
+
nameIndex = newNameIndex;
|
|
153
|
+
isNegative = value < 0;
|
|
154
|
+
if (isNegative) {
|
|
155
|
+
value = -value;
|
|
156
|
+
}
|
|
157
|
+
value = value << 1;
|
|
158
|
+
if (isNegative) {
|
|
159
|
+
value = value | 1;
|
|
160
|
+
}
|
|
161
|
+
while (value > 0) {
|
|
162
|
+
let digit = value & 63;
|
|
163
|
+
value = value >>> 6;
|
|
164
|
+
if (value > 0) {
|
|
165
|
+
digit = digit | 64;
|
|
166
|
+
}
|
|
167
|
+
mappings += String.fromCharCode(
|
|
168
|
+
digit < 26
|
|
169
|
+
? digit + 65
|
|
170
|
+
: digit < 52
|
|
171
|
+
? digit + 97 - 26
|
|
172
|
+
: digit < 62
|
|
173
|
+
? digit + 48 - 52
|
|
174
|
+
: digit === 62
|
|
175
|
+
? 43
|
|
176
|
+
: 47
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return mappings;
|
|
181
|
+
};
|
|
182
|
+
}
|