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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnvironmentModuleGraph, ModuleGraph } from "vite";
|
|
2
|
-
import type { CreateHandlerOptions, CssContent } from "../types.js";
|
|
2
|
+
import type { CreateHandlerOptions, CssContent, InlineCssOpt, PagePropOpt } from "../types.js";
|
|
3
3
|
import { createCssProps } from "./createCssProps.js";
|
|
4
4
|
|
|
5
5
|
type CollectViteModuleGraphCssResult =
|
|
@@ -29,7 +29,8 @@ type CollectViteModuleGraphCssResult =
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export async function collectViteModuleGraphCss<
|
|
32
|
-
|
|
32
|
+
T extends PagePropOpt = PagePropOpt,
|
|
33
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
33
34
|
>({
|
|
34
35
|
moduleGraph,
|
|
35
36
|
onCss,
|
|
@@ -40,7 +41,7 @@ export async function collectViteModuleGraphCss<
|
|
|
40
41
|
onCss?: (cssContent: CssContent, parentUrl: string) => void;
|
|
41
42
|
parentUrl?: string;
|
|
42
43
|
handlerOptions: Pick<
|
|
43
|
-
CreateHandlerOptions<InlineCSS>,
|
|
44
|
+
CreateHandlerOptions<T, InlineCSS>,
|
|
44
45
|
| "pagePath"
|
|
45
46
|
| "moduleBaseURL"
|
|
46
47
|
| "moduleBasePath"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ResolvedUserOptions, CssContent } from "../types.js";
|
|
2
|
+
import type { InlineCssOpt, PagePropOpt } from "../../server.js";
|
|
2
3
|
import { join, relative } from "node:path";
|
|
3
4
|
import { deserializeRegExp } from "./serializeUserOptions.js";
|
|
4
5
|
|
|
@@ -21,7 +22,10 @@ import { deserializeRegExp } from "./serializeUserOptions.js";
|
|
|
21
22
|
* @param css - The css options
|
|
22
23
|
* @returns A CssContent object
|
|
23
24
|
*/
|
|
24
|
-
export const createCssProps =
|
|
25
|
+
export const createCssProps = <
|
|
26
|
+
T extends PagePropOpt = PagePropOpt,
|
|
27
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
28
|
+
>({
|
|
25
29
|
id,
|
|
26
30
|
code,
|
|
27
31
|
userOptions,
|
|
@@ -29,14 +33,14 @@ export const createCssProps = ({
|
|
|
29
33
|
id: string;
|
|
30
34
|
code: string;
|
|
31
35
|
userOptions: Pick<
|
|
32
|
-
ResolvedUserOptions,
|
|
36
|
+
ResolvedUserOptions<T, InlineCSS>,
|
|
33
37
|
| "css"
|
|
34
38
|
| "moduleBaseURL"
|
|
35
39
|
| "moduleBasePath"
|
|
36
40
|
| "moduleRootPath"
|
|
37
41
|
| "projectRoot"
|
|
38
42
|
>;
|
|
39
|
-
}): CssContent => {
|
|
43
|
+
}): CssContent<InlineCSS> => {
|
|
40
44
|
const { css, moduleBaseURL, moduleBasePath, moduleRootPath, projectRoot } =
|
|
41
45
|
userOptions;
|
|
42
46
|
// If we don't have a bundle entry, create a linked CSS file
|
|
@@ -74,24 +78,37 @@ export const createCssProps = ({
|
|
|
74
78
|
"data-vite-dev-id": join(projectRoot, moduleRootPath, normalizedId),
|
|
75
79
|
}
|
|
76
80
|
: {}),
|
|
77
|
-
} as CssContent<
|
|
81
|
+
} as CssContent<InlineCSS>;
|
|
78
82
|
}
|
|
79
|
-
const joined = normalizedId.startsWith(moduleBasePath)
|
|
83
|
+
const joined = normalizedId.startsWith(moduleBasePath)
|
|
84
|
+
? normalizedId
|
|
85
|
+
: join(moduleBasePath, normalizedId);
|
|
80
86
|
const moduleBaseHasTrailingSlash = moduleBaseURL.endsWith("/");
|
|
81
87
|
const joinedHasLeadingSlash = joined.startsWith("/");
|
|
82
88
|
const safeParseURL = (() => {
|
|
83
|
-
if
|
|
89
|
+
if (
|
|
90
|
+
joined.startsWith(
|
|
91
|
+
moduleBaseHasTrailingSlash ? moduleBaseURL.slice(0, -1) : moduleBaseURL
|
|
92
|
+
)
|
|
93
|
+
) {
|
|
84
94
|
return joined;
|
|
85
95
|
}
|
|
86
96
|
try {
|
|
87
97
|
if (moduleBaseURL.includes("//")) {
|
|
88
98
|
// relative to moduleBaseURL
|
|
89
|
-
return new URL(
|
|
99
|
+
return new URL(
|
|
100
|
+
joinedHasLeadingSlash ? joined.slice(1) : joined,
|
|
101
|
+
moduleBaseURL
|
|
102
|
+
).href;
|
|
90
103
|
}
|
|
91
104
|
} catch (error) {}
|
|
92
105
|
// if the url is not valid, we return the moduleBaseURL + the normalizedId
|
|
93
106
|
// dont make it a argument of join or it will mangle something like http:// into http:/
|
|
94
|
-
return
|
|
107
|
+
return (
|
|
108
|
+
moduleBaseURL +
|
|
109
|
+
(!moduleBaseHasTrailingSlash && !joinedHasLeadingSlash ? "/" : "") +
|
|
110
|
+
(moduleBaseHasTrailingSlash ? joined.slice(1) : joined)
|
|
111
|
+
);
|
|
95
112
|
})();
|
|
96
113
|
// Default case
|
|
97
114
|
return {
|
|
@@ -100,5 +117,5 @@ export const createCssProps = ({
|
|
|
100
117
|
rel: "stylesheet",
|
|
101
118
|
href: safeParseURL,
|
|
102
119
|
precedence: "high",
|
|
103
|
-
} as CssContent<
|
|
120
|
+
} as CssContent<InlineCSS>;
|
|
104
121
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { CreateHandlerOptions } from "../types.js";
|
|
1
|
+
import type { CreateHandlerOptions, InlineCssOpt } from "../types.js";
|
|
2
|
+
import type { PagePropOpt } from "../../server.js";
|
|
2
3
|
import { createRscStream } from "./createRscStream.js";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export function createHandler<
|
|
6
|
+
T extends PagePropOpt = PagePropOpt,
|
|
7
|
+
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
8
|
+
>(handlerOptions: CreateHandlerOptions<T, InlineCSS>) {
|
|
9
|
+
if (!handlerOptions.PageComponent) {
|
|
7
10
|
throw new Error("PageComponent is required");
|
|
8
11
|
}
|
|
9
12
|
try {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { React, ReactDOMServer } from "../vendor/vendor.server.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
CreateHandlerOptions,
|
|
4
|
+
StreamMetrics,
|
|
5
|
+
PagePropOpt,
|
|
6
|
+
} from "../types.js";
|
|
3
7
|
import { performance } from "node:perf_hooks";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
C extends React.ComponentType<T>,
|
|
7
|
-
InlineCSS extends boolean = true
|
|
8
|
-
>({
|
|
8
|
+
|
|
9
|
+
export function createRscStream<T extends PagePropOpt = PagePropOpt>({
|
|
9
10
|
Html = React.Fragment,
|
|
10
11
|
PageComponent,
|
|
11
12
|
pageProps,
|
|
@@ -22,7 +23,7 @@ export function createRscStream<
|
|
|
22
23
|
onEvent,
|
|
23
24
|
projectRoot,
|
|
24
25
|
}: Pick<
|
|
25
|
-
CreateHandlerOptions<T
|
|
26
|
+
CreateHandlerOptions<T>,
|
|
26
27
|
| "Html"
|
|
27
28
|
| "PageComponent"
|
|
28
29
|
| "pageProps"
|
|
@@ -46,7 +47,7 @@ export function createRscStream<
|
|
|
46
47
|
let streamError: Error | null = null;
|
|
47
48
|
const startTime = performance.now();
|
|
48
49
|
try {
|
|
49
|
-
const htmlIsFragment = Html
|
|
50
|
+
const htmlIsFragment = Html === React.Fragment;
|
|
50
51
|
const url = route.startsWith(moduleBaseURL) ? route : moduleBaseURL + route;
|
|
51
52
|
|
|
52
53
|
if (!PageComponent) {
|
|
@@ -64,10 +65,15 @@ export function createRscStream<
|
|
|
64
65
|
},
|
|
65
66
|
};
|
|
66
67
|
}
|
|
68
|
+
|
|
67
69
|
const elements = htmlIsFragment ? (
|
|
68
|
-
<CssCollector
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
<CssCollector
|
|
71
|
+
key={route}
|
|
72
|
+
as={React.Fragment}
|
|
73
|
+
cssFiles={cssFiles}
|
|
74
|
+
pageProps={pageProps}
|
|
75
|
+
Page={PageComponent}
|
|
76
|
+
/>
|
|
71
77
|
) : (
|
|
72
78
|
<Html
|
|
73
79
|
moduleBase={moduleBase}
|
|
@@ -82,9 +88,9 @@ export function createRscStream<
|
|
|
82
88
|
globalCss={globalCss}
|
|
83
89
|
CssCollector={CssCollector}
|
|
84
90
|
manifest={manifest}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
Page={PageComponent}
|
|
92
|
+
as={"div"}
|
|
93
|
+
/>
|
|
88
94
|
);
|
|
89
95
|
const stream = ReactDOMServer.renderToPipeableStream(
|
|
90
96
|
elements,
|
package/plugin/helpers/index.ts
CHANGED
|
@@ -15,10 +15,10 @@ export * from "./inputNormalizer.js";
|
|
|
15
15
|
export * from "./collectBundleManifestCss.js";
|
|
16
16
|
export * from "./collectManifestCss.js";
|
|
17
17
|
export * from "./collectViteModuleGraphCss.js";
|
|
18
|
-
export * from "./createCssProps.
|
|
18
|
+
export * from "./createCssProps.js";
|
|
19
19
|
|
|
20
20
|
// Stream and handler creation
|
|
21
|
-
export * from "./createRscStream.
|
|
21
|
+
export * from "./createRscStream.js";
|
|
22
22
|
export * from "./createHandler.js";
|
|
23
23
|
export * from "./createEventHandler.js";
|
|
24
24
|
|
|
@@ -180,7 +180,7 @@ export function createInputNormalizer({
|
|
|
180
180
|
root,
|
|
181
181
|
moduleBasePath,
|
|
182
182
|
preserveModulesRoot = undefined,
|
|
183
|
-
removeExtension = DEFAULT_CONFIG.
|
|
183
|
+
removeExtension = DEFAULT_CONFIG.AUTO_DISCOVER.moduleExtension,
|
|
184
184
|
}: CreateInputNormalizerProps): InputNormalizer {
|
|
185
185
|
if (stashedNormalizer) {
|
|
186
186
|
return stashedNormalizer;
|
|
@@ -246,7 +246,9 @@ export function createInputNormalizer({
|
|
|
246
246
|
? virtualPrefix[0] + normalizedPath
|
|
247
247
|
: normalizedPath
|
|
248
248
|
: normalizedPath;
|
|
249
|
-
|
|
249
|
+
if(virtualPrefix){
|
|
250
|
+
return ['', ''];
|
|
251
|
+
}
|
|
250
252
|
return [key, finalPath];
|
|
251
253
|
};
|
|
252
254
|
return stashedNormalizer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
let stashedResolve: any = null;
|
|
2
|
+
|
|
3
|
+
export function setStashedResolve(resolve: any) {
|
|
4
|
+
stashedResolve = resolve;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function resolveClientImport(specifier: string, parentURL: string) {
|
|
8
|
+
const conditions = ["node", "import"];
|
|
9
|
+
|
|
10
|
+
if (stashedResolve === null) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
"Expected resolve to have been called before transformSource"
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const result = await stashedResolve(
|
|
18
|
+
specifier,
|
|
19
|
+
{
|
|
20
|
+
conditions,
|
|
21
|
+
parentURL,
|
|
22
|
+
},
|
|
23
|
+
stashedResolve
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (!result) {
|
|
27
|
+
console.warn(`Failed to resolve import: ${specifier}`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return result;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(`Error resolving import ${specifier}:`, error);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,43 +1,89 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
1
|
+
import { join, resolve } from "node:path";
|
|
2
2
|
import type { ResolvedUserOptions } from "../types.js";
|
|
3
|
-
import type
|
|
3
|
+
import { createLogger, type Connect, type Logger } from "vite";
|
|
4
4
|
import { MIME_TYPES } from "../config/mimeTypes.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* # Request info
|
|
8
|
-
*
|
|
9
|
-
* Does the initial work to check if the request is for html, rsc, css, or something else not handled by this plugin.
|
|
10
|
-
*
|
|
11
|
-
* @param req
|
|
12
|
-
* @param userOptions
|
|
13
|
-
* @param hostDir
|
|
14
|
-
* @returns
|
|
8
|
+
*
|
|
9
|
+
* Does the initial work to check if the request is for html, rsc, json, js, css, server-action, or something else not handled by this plugin.
|
|
10
|
+
*
|
|
11
|
+
* @param req
|
|
12
|
+
* @param userOptions
|
|
13
|
+
* @param hostDir
|
|
14
|
+
* @returns
|
|
15
15
|
*/
|
|
16
16
|
export function requestInfo(
|
|
17
17
|
req: Connect.IncomingMessage,
|
|
18
|
-
userOptions: Pick<
|
|
19
|
-
|
|
18
|
+
userOptions: Pick<
|
|
19
|
+
ResolvedUserOptions,
|
|
20
|
+
"normalizer" | "build" | "autoDiscover" | "verbose"
|
|
21
|
+
>,
|
|
22
|
+
hostDir: string,
|
|
23
|
+
logger: Logger = createLogger()
|
|
20
24
|
) {
|
|
21
25
|
const [, value] = userOptions.normalizer(req.url);
|
|
22
26
|
const dotIndex = value.lastIndexOf(".");
|
|
23
27
|
const ext = dotIndex === -1 ? "" : value.slice(dotIndex);
|
|
24
28
|
// handle index.html
|
|
29
|
+
const isVendor = userOptions.autoDiscover.vendorPattern(value);
|
|
30
|
+
const isVirtual = userOptions.autoDiscover.virtualPattern(value);
|
|
31
|
+
const isJS = userOptions.autoDiscover.modulePattern(value);
|
|
25
32
|
const isHtml = userOptions.autoDiscover.htmlPattern(value);
|
|
26
|
-
const
|
|
33
|
+
const isCss = userOptions.autoDiscover.cssPattern(value);
|
|
34
|
+
const isJson = userOptions.autoDiscover.jsonPattern(value);
|
|
27
35
|
const isRsc = userOptions.autoDiscover.rscPattern(value);
|
|
36
|
+
const hasJsHeader =
|
|
37
|
+
req.headers["sec-fetch-dest"] === "script" ||
|
|
38
|
+
req.headers["accept"]?.includes("*/*") ||
|
|
39
|
+
req.headers["accept"]?.includes("text/javascript");
|
|
40
|
+
const hasJsonHeader = req.headers["accept"]?.includes("application/json");
|
|
41
|
+
const hasHtmlHeader = req.headers.accept?.includes("text/html");
|
|
28
42
|
const hasRscHeader = req.headers.accept?.includes("text/x-component");
|
|
43
|
+
const hasCssHeader = req.headers.accept?.includes("text/css");
|
|
29
44
|
const isFolder = !ext;
|
|
45
|
+
const isJsRequest =
|
|
46
|
+
!isJson && !isHtml && !isCss && !isRsc && (isJS || hasJsHeader);
|
|
47
|
+
const isJsonRequest = isJson || (hasJsonHeader && !isJsRequest);
|
|
30
48
|
const isHtmlRequest =
|
|
31
|
-
isHtml ||
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
isHtml ||
|
|
50
|
+
hasHtmlHeader ||
|
|
51
|
+
(isFolder && !hasRscHeader && !isRsc && !isJsRequest);
|
|
52
|
+
const isRscRequest =
|
|
53
|
+
!isJsRequest && !isHtmlRequest && (isRsc || hasRscHeader);
|
|
34
54
|
const isCssRequest =
|
|
35
55
|
!isHtmlRequest &&
|
|
36
56
|
!isRscRequest &&
|
|
37
|
-
|
|
57
|
+
!isJsRequest &&
|
|
58
|
+
!isJsonRequest &&
|
|
59
|
+
(isCss || hasCssHeader);
|
|
60
|
+
|
|
61
|
+
// Form action detection
|
|
62
|
+
const formContentType = req.headers["content-type"] ?? "";
|
|
63
|
+
const isFormContentType =
|
|
64
|
+
formContentType.includes("application/x-www-form-urlencoded") ||
|
|
65
|
+
formContentType.includes("multipart/form-data");
|
|
66
|
+
const isFormActionRequest =
|
|
67
|
+
isFormContentType &&
|
|
68
|
+
req.headers["sec-fetch-dest"] === "document" &&
|
|
69
|
+
req.headers["sec-fetch-mode"] === "navigate";
|
|
70
|
+
|
|
71
|
+
// Server action detection
|
|
72
|
+
const hasServerActionHeaders =
|
|
73
|
+
isJsonRequest &&
|
|
74
|
+
(req.headers["sec-fetch-dest"] === "empty" ||
|
|
75
|
+
req.headers["sec-fetch-dest"] === "") &&
|
|
76
|
+
req.headers["sec-fetch-mode"] === "cors";
|
|
77
|
+
const isServerActionRequest = hasServerActionHeaders;
|
|
78
|
+
|
|
38
79
|
let filePath = join(hostDir, value);
|
|
39
80
|
let contentType;
|
|
40
|
-
if (
|
|
81
|
+
if (isServerActionRequest) {
|
|
82
|
+
// For server actions, we'll get the actual file path from the request body
|
|
83
|
+
// The route is just a placeholder
|
|
84
|
+
filePath = value;
|
|
85
|
+
contentType = "application/json; charset=utf-8";
|
|
86
|
+
} else if (isHtmlRequest) {
|
|
41
87
|
if (!isHtml) {
|
|
42
88
|
filePath = join(hostDir, value, userOptions.build.htmlOutputPath);
|
|
43
89
|
}
|
|
@@ -49,9 +95,19 @@ export function requestInfo(
|
|
|
49
95
|
contentType = "text/x-component; charset=utf-8";
|
|
50
96
|
} else if (isCssRequest) {
|
|
51
97
|
if (!isCss) {
|
|
52
|
-
filePath = join(hostDir, value);
|
|
98
|
+
filePath = join(hostDir, value + ".css");
|
|
53
99
|
}
|
|
54
100
|
contentType = "text/css; charset=utf-8";
|
|
101
|
+
} else if (isJsRequest) {
|
|
102
|
+
if (!isJS) {
|
|
103
|
+
filePath = resolve(hostDir, value + ".js");
|
|
104
|
+
}
|
|
105
|
+
contentType = "application/javascript; charset=utf-8";
|
|
106
|
+
} else if (isJsonRequest) {
|
|
107
|
+
if (!isJson) {
|
|
108
|
+
filePath = join(hostDir, value + ".json");
|
|
109
|
+
}
|
|
110
|
+
contentType = "application/json; charset=utf-8";
|
|
55
111
|
} else {
|
|
56
112
|
const mimeType = MIME_TYPES[ext];
|
|
57
113
|
if (mimeType) {
|
|
@@ -63,18 +119,41 @@ export function requestInfo(
|
|
|
63
119
|
const route = value
|
|
64
120
|
.replace(userOptions.build.rscOutputPath, "")
|
|
65
121
|
.replace(userOptions.build.htmlOutputPath, "");
|
|
66
|
-
|
|
122
|
+
|
|
67
123
|
const routeWithoutTrailingSlash =
|
|
68
124
|
route === "" || route === "/"
|
|
69
125
|
? "/"
|
|
70
126
|
: route.endsWith("/")
|
|
71
127
|
? route.slice(0, -1)
|
|
72
128
|
: route;
|
|
73
|
-
const routeWithLeadingSlash =
|
|
74
|
-
routeWithoutTrailingSlash.startsWith("/")
|
|
75
|
-
? routeWithoutTrailingSlash
|
|
76
|
-
: `/${routeWithoutTrailingSlash}`;
|
|
77
129
|
|
|
130
|
+
const routeWithLeadingSlash = !routeWithoutTrailingSlash
|
|
131
|
+
? "/"
|
|
132
|
+
: routeWithoutTrailingSlash.startsWith("/")
|
|
133
|
+
? routeWithoutTrailingSlash
|
|
134
|
+
: `/${routeWithoutTrailingSlash}`;
|
|
135
|
+
|
|
136
|
+
if (userOptions.verbose) {
|
|
137
|
+
if (isFormActionRequest) {
|
|
138
|
+
logger.info(`[react-dev-server] (form-action) ${routeWithLeadingSlash}`);
|
|
139
|
+
} else if (isServerActionRequest) {
|
|
140
|
+
logger.info(
|
|
141
|
+
`[react-dev-server] (server-action) ${routeWithLeadingSlash}`
|
|
142
|
+
);
|
|
143
|
+
} else if (isHtmlRequest) {
|
|
144
|
+
logger.info(`[react-dev-server] (html) ${routeWithLeadingSlash}`);
|
|
145
|
+
} else if (isRscRequest) {
|
|
146
|
+
logger.info(`[react-dev-server] (rsc.) ${routeWithLeadingSlash}`);
|
|
147
|
+
} else if (isCssRequest) {
|
|
148
|
+
logger.info(`[react-dev-server] (css) ${routeWithLeadingSlash}`);
|
|
149
|
+
} else if (isJsRequest) {
|
|
150
|
+
logger.info(`[react-dev-server] (js) ${routeWithLeadingSlash}`);
|
|
151
|
+
} else if (isJsonRequest) {
|
|
152
|
+
logger.info(`[react-dev-server] (json) ${routeWithLeadingSlash}`);
|
|
153
|
+
} else {
|
|
154
|
+
logger.info(`[react-dev-server] (other) ${routeWithLeadingSlash}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
78
157
|
return {
|
|
79
158
|
route: routeWithLeadingSlash,
|
|
80
159
|
ext,
|
|
@@ -87,5 +166,20 @@ export function requestInfo(
|
|
|
87
166
|
isFolder,
|
|
88
167
|
contentType,
|
|
89
168
|
filePath,
|
|
169
|
+
isJS,
|
|
170
|
+
isVendor,
|
|
171
|
+
isVirtual,
|
|
172
|
+
hasJsHeader,
|
|
173
|
+
isJsRequest,
|
|
174
|
+
isJson,
|
|
175
|
+
isJsonRequest,
|
|
176
|
+
hasCssHeader,
|
|
177
|
+
hasJsonHeader,
|
|
178
|
+
hasHtmlHeader,
|
|
179
|
+
hasRscHeader,
|
|
180
|
+
hasServerActionHeaders,
|
|
181
|
+
isServerActionRequest,
|
|
182
|
+
isFormContentType,
|
|
183
|
+
isFormActionRequest,
|
|
90
184
|
};
|
|
91
185
|
}
|
|
@@ -72,11 +72,10 @@ export const resolvePage = async <T, N extends string>({
|
|
|
72
72
|
error: toError(module.error),
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
+
console.log({ module });
|
|
75
76
|
return {
|
|
76
77
|
type: "error",
|
|
77
|
-
error: new Error(
|
|
78
|
-
`Export "${exportName}" not found in module ${id}.`
|
|
79
|
-
),
|
|
78
|
+
error: new Error(`Export "${exportName}" not found in module ${id}.`),
|
|
80
79
|
};
|
|
81
80
|
} else if (!Page) {
|
|
82
81
|
return {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PageComponentType, PagePropOpt } from "../types.js";
|
|
1
2
|
import { resolvePage } from "./resolvePage.js";
|
|
2
3
|
import { resolveProps } from "./resolveProps.js";
|
|
3
4
|
|
|
@@ -10,11 +11,11 @@ type ResolvePageAndPropsOptions<N1 extends string, N2 extends string> = {
|
|
|
10
11
|
loader: (id: string) => Promise<any>;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
type ResolvePageAndPropsResult<T> =
|
|
14
|
+
type ResolvePageAndPropsResult<T extends PagePropOpt = PagePropOpt> =
|
|
14
15
|
| {
|
|
15
16
|
type: "success";
|
|
16
17
|
error?: never;
|
|
17
|
-
PageComponent:
|
|
18
|
+
PageComponent: PageComponentType<T>;
|
|
18
19
|
pageProps: T;
|
|
19
20
|
}
|
|
20
21
|
| {
|
|
@@ -31,9 +32,9 @@ type ResolvePageAndPropsResult<T> =
|
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
export async function resolvePageAndProps<
|
|
34
|
-
T,
|
|
35
|
-
N1 extends string,
|
|
36
|
-
N2 extends string
|
|
35
|
+
T extends PagePropOpt = PagePropOpt,
|
|
36
|
+
N1 extends string = string,
|
|
37
|
+
N2 extends string = string
|
|
37
38
|
>(
|
|
38
39
|
handlerOptions: ResolvePageAndPropsOptions<N1, N2>
|
|
39
40
|
): Promise<ResolvePageAndPropsResult<T>> {
|
|
@@ -72,7 +73,7 @@ export async function resolvePageAndProps<
|
|
|
72
73
|
const { props } = resolvePropsResult;
|
|
73
74
|
return {
|
|
74
75
|
type: "success",
|
|
75
|
-
PageComponent: Page as
|
|
76
|
+
PageComponent: Page as PageComponentType<T>,
|
|
76
77
|
pageProps: props as T,
|
|
77
78
|
};
|
|
78
79
|
} catch (error) {
|
|
@@ -2,6 +2,8 @@ import type { ResolvedConfig, ViteDevServer } from "vite";
|
|
|
2
2
|
import type {
|
|
3
3
|
AutoDiscoveredFiles,
|
|
4
4
|
ResolvedUserOptions,
|
|
5
|
+
PagePropOpt,
|
|
6
|
+
InlineCssOpt,
|
|
5
7
|
} from "../types.js";
|
|
6
8
|
import { cleanObject } from "./cleanObject.js";
|
|
7
9
|
|
|
@@ -173,8 +175,8 @@ export const serializedDevServerConfig = <T extends ViteDevServer["config"]>(
|
|
|
173
175
|
};
|
|
174
176
|
|
|
175
177
|
// For your own options (if you need custom non-serializable functions)
|
|
176
|
-
export const serializedOptions = <T extends
|
|
177
|
-
userOptions: T,
|
|
178
|
+
export const serializedOptions = <T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt>(
|
|
179
|
+
userOptions: ResolvedUserOptions<T, InlineCSS>,
|
|
178
180
|
autoDiscoveredFiles: AutoDiscoveredFiles,
|
|
179
181
|
customNonSerializableFunctions: Set<string> = PLUGIN_NON_SERIALIZABLE_FUNCTIONS
|
|
180
182
|
) => {
|
|
@@ -207,3 +209,19 @@ export const serializedOptions = <T extends ResolvedUserOptions>(
|
|
|
207
209
|
customNonSerializableFunctions
|
|
208
210
|
));
|
|
209
211
|
};
|
|
212
|
+
|
|
213
|
+
export function hydrateUserOptions(userOptions: any) {
|
|
214
|
+
if (!userOptions) return userOptions;
|
|
215
|
+
|
|
216
|
+
// Restore RegExp objects
|
|
217
|
+
if (userOptions.autoDiscover) {
|
|
218
|
+
const { autoDiscover } = userOptions;
|
|
219
|
+
for (const key in autoDiscover) {
|
|
220
|
+
if (typeof autoDiscover[key] === 'string' && autoDiscover[key].startsWith('__REGEXP__')) {
|
|
221
|
+
autoDiscover[key] = deserializeRegExp(autoDiscover[key]);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return userOptions;
|
|
227
|
+
}
|