vite-plugin-react-server 1.1.20 → 1.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -396
- package/dist/_virtual/dynamic-import-helper.js +1 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -2
- package/dist/index.js +1 -1
- package/dist/package.json +58 -25
- package/dist/plugin/components/{css-collector-elements.d.ts → css.d.ts} +2 -2
- package/dist/plugin/components/css.d.ts.map +1 -0
- package/dist/plugin/components/css.js +33 -0
- 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 +5 -5
- package/dist/plugin/components/index.d.ts +3 -3
- package/dist/plugin/components/index.d.ts.map +1 -1
- package/dist/plugin/components/index.js +9 -3
- package/dist/plugin/components/root.d.ts +7 -0
- package/dist/plugin/components/root.d.ts.map +1 -0
- package/dist/plugin/components/root.js +18 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +1 -1
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js +1 -1
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +5 -4
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +26 -7
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +25 -2
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js +84 -5
- package/dist/plugin/config/createModuleID.d.ts +3 -6
- package/dist/plugin/config/createModuleID.d.ts.map +1 -1
- package/dist/plugin/config/createModuleID.js +42 -32
- package/dist/plugin/config/defaults.d.ts +294 -121
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +156 -89
- package/dist/plugin/config/extMap.d.ts +6 -2
- package/dist/plugin/config/extMap.d.ts.map +1 -1
- package/dist/plugin/config/extMap.js +38 -48
- package/dist/plugin/config/flightBindings.d.ts +4 -0
- package/dist/plugin/config/flightBindings.d.ts.map +1 -0
- package/dist/plugin/config/flightBindings.js +215 -0
- package/dist/plugin/config/getCondition.d.ts +2 -0
- package/dist/plugin/config/getCondition.d.ts.map +1 -1
- package/dist/plugin/config/getCondition.js +4 -2
- package/dist/plugin/config/getPaths.js +1 -1
- package/dist/plugin/config/index.d.ts +17 -4
- package/dist/plugin/config/index.d.ts.map +1 -1
- package/dist/plugin/config/index.js +29 -7
- package/dist/plugin/config/interpolatePattern.d.ts +13 -0
- package/dist/plugin/config/interpolatePattern.d.ts.map +1 -0
- package/dist/plugin/config/interpolatePattern.js +13 -0
- package/dist/plugin/config/mimeTypes.js +1 -1
- package/dist/plugin/config/parsePattern.d.ts +25 -0
- package/dist/plugin/config/parsePattern.d.ts.map +1 -0
- package/dist/plugin/config/parsePattern.js +30 -0
- package/dist/plugin/config/resolveAllowedDirectives.d.ts +26 -0
- package/dist/plugin/config/resolveAllowedDirectives.d.ts.map +1 -0
- package/dist/plugin/config/resolveAllowedDirectives.js +35 -0
- package/dist/plugin/config/resolveDirectiveMatcher.d.ts +25 -0
- package/dist/plugin/config/resolveDirectiveMatcher.d.ts.map +1 -0
- package/dist/plugin/config/resolveDirectiveMatcher.js +33 -0
- package/dist/plugin/config/resolveEnv.d.ts +1 -1
- package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
- package/dist/plugin/config/resolveEnv.js +45 -28
- package/dist/plugin/config/resolveOptions.d.ts +13 -3
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +230 -219
- package/dist/plugin/config/resolvePages.js +1 -1
- package/dist/plugin/config/resolvePatternWithValues.d.ts +39 -0
- package/dist/plugin/config/resolvePatternWithValues.d.ts.map +1 -0
- package/dist/plugin/config/resolvePatternWithValues.js +36 -0
- package/dist/plugin/config/resolveRegExp.d.ts +29 -0
- package/dist/plugin/config/resolveRegExp.d.ts.map +1 -0
- package/dist/plugin/config/resolveRegExp.js +39 -0
- package/dist/plugin/config/resolveUrlOption.d.ts +37 -6
- package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -1
- package/dist/plugin/config/resolveUrlOption.js +42 -12
- package/dist/plugin/config/resolveUserConfig.d.ts +5 -4
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +98 -47
- package/dist/plugin/env/createConfigEnv.d.ts +7 -0
- package/dist/plugin/env/createConfigEnv.d.ts.map +1 -0
- package/dist/plugin/env/createConfigEnv.js +30 -0
- package/dist/plugin/env/getArgValue.d.ts +8 -0
- package/dist/plugin/env/getArgValue.d.ts.map +1 -0
- package/dist/plugin/env/getArgValue.js +32 -0
- package/dist/plugin/env/getEnvKey.d.ts +40 -0
- package/dist/plugin/env/getEnvKey.d.ts.map +1 -0
- package/dist/plugin/env/getEnvKey.js +24 -0
- package/dist/plugin/env/index.d.ts +3 -0
- package/dist/plugin/env/index.d.ts.map +1 -1
- package/dist/plugin/env/index.js +3 -0
- package/dist/plugin/env/plugin.d.ts +6 -0
- package/dist/plugin/env/plugin.d.ts.map +1 -1
- package/dist/plugin/env/plugin.js +69 -93
- package/dist/plugin/env/userConfigEnv.d.ts +2 -0
- package/dist/plugin/env/userConfigEnv.d.ts.map +1 -0
- package/dist/plugin/env/userConfigEnv.js +21 -0
- package/dist/plugin/error/directiveError.d.ts +13 -0
- package/dist/plugin/error/directiveError.d.ts.map +1 -0
- package/dist/plugin/error/directiveError.js +21 -0
- package/dist/plugin/error/enhanceError.d.ts +14 -0
- package/dist/plugin/error/enhanceError.d.ts.map +1 -0
- package/dist/plugin/error/enhanceError.js +24 -0
- package/dist/plugin/error/index.d.ts +4 -0
- package/dist/plugin/error/index.d.ts.map +1 -0
- package/dist/plugin/error/index.js +9 -0
- package/dist/plugin/error/logError.d.ts +3 -0
- package/dist/plugin/error/logError.d.ts.map +1 -0
- package/dist/plugin/error/logError.js +50 -0
- package/dist/plugin/error/serializeError.d.ts +7 -0
- package/dist/plugin/error/serializeError.d.ts.map +1 -0
- package/dist/plugin/error/serializeError.js +37 -0
- package/dist/plugin/error/toError.d.ts +1 -8
- package/dist/plugin/error/toError.d.ts.map +1 -1
- package/dist/plugin/error/toError.js +62 -34
- package/dist/plugin/file-preserver/plugin.js +93 -105
- package/dist/plugin/getNodeEnv.d.ts +11 -0
- package/dist/plugin/getNodeEnv.d.ts.map +1 -0
- package/dist/plugin/getNodeEnv.js +17 -0
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -1
- package/dist/plugin/helpers/cleanObject.js +2 -1
- package/dist/plugin/helpers/collectManifestCss.js +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +6 -4
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +15 -9
- package/dist/plugin/helpers/createCssProps.d.ts +3 -4
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
- package/dist/plugin/helpers/createCssProps.js +16 -15
- package/dist/plugin/helpers/createEventHandler.d.ts +2 -2
- package/dist/plugin/helpers/createEventHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createEventHandler.js +1 -1
- package/dist/plugin/helpers/createHandler.d.ts +10 -8
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +11 -5
- package/dist/plugin/helpers/createRscStream.d.ts +18 -5
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +53 -15
- package/dist/plugin/helpers/formatMetrics.d.ts +1 -5
- package/dist/plugin/helpers/formatMetrics.d.ts.map +1 -1
- package/dist/plugin/helpers/formatMetrics.js +2 -39
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +9 -2
- package/dist/plugin/helpers/getRouteFiles.d.ts +30 -2
- package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -1
- package/dist/plugin/helpers/getRouteFiles.js +100 -8
- package/dist/plugin/helpers/handleServerAction.d.ts +8 -7
- package/dist/plugin/helpers/handleServerAction.d.ts.map +1 -1
- package/dist/plugin/helpers/handleServerAction.js +7 -3
- package/dist/plugin/helpers/hydrateUserOptions.d.ts +9 -0
- package/dist/plugin/helpers/hydrateUserOptions.d.ts.map +1 -0
- package/dist/plugin/helpers/hydrateUserOptions.js +22 -0
- package/dist/plugin/helpers/index.d.ts +2 -0
- package/dist/plugin/helpers/index.d.ts.map +1 -1
- package/dist/plugin/helpers/index.js +31 -31
- package/dist/plugin/helpers/inputNormalizer.d.ts +1 -1
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +33 -20
- package/dist/plugin/helpers/metrics.d.ts +4 -10
- package/dist/plugin/helpers/metrics.d.ts.map +1 -1
- package/dist/plugin/helpers/metrics.js +3 -59
- package/dist/plugin/helpers/moduleRefs.js +1 -1
- package/dist/plugin/helpers/moduleResolver.d.ts +24 -2
- package/dist/plugin/helpers/moduleResolver.d.ts.map +1 -1
- package/dist/plugin/helpers/moduleResolver.js +61 -22
- package/dist/plugin/helpers/requestInfo.d.ts +31 -4
- package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
- package/dist/plugin/helpers/requestInfo.js +62 -35
- package/dist/plugin/helpers/requestToRoute.d.ts +1 -1
- package/dist/plugin/helpers/requestToRoute.d.ts.map +1 -1
- package/dist/plugin/helpers/requestToRoute.js +17 -9
- package/dist/plugin/helpers/resolveComponent.d.ts +57 -0
- package/dist/plugin/helpers/resolveComponent.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveComponent.js +71 -0
- package/dist/plugin/helpers/resolveComponents.d.ts +27 -0
- package/dist/plugin/helpers/resolveComponents.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveComponents.js +146 -0
- package/dist/plugin/helpers/resolvePage.d.ts +15 -11
- package/dist/plugin/helpers/resolvePage.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePage.js +11 -7
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +3 -10
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.js +28 -18
- package/dist/plugin/helpers/resolveProps.d.ts +13 -7
- package/dist/plugin/helpers/resolveProps.d.ts.map +1 -1
- package/dist/plugin/helpers/resolveProps.js +55 -25
- package/dist/plugin/helpers/resolveUserComponents.d.ts +33 -0
- package/dist/plugin/helpers/resolveUserComponents.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveUserComponents.js +163 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts +7 -7
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
- package/dist/plugin/helpers/serializeUserOptions.js +127 -42
- package/dist/plugin/helpers/stashReturnValue.d.ts +2 -1
- package/dist/plugin/helpers/stashReturnValue.d.ts.map +1 -1
- package/dist/plugin/helpers/stashReturnValue.js +6 -3
- package/dist/plugin/helpers/tryManifest.d.ts +1 -2
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +1 -1
- package/dist/plugin/loader/createDefaultLoader.d.ts +19 -8
- package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createDefaultLoader.js +69 -107
- package/dist/plugin/loader/createTransformer.d.ts +6 -0
- package/dist/plugin/loader/createTransformer.d.ts.map +1 -0
- package/dist/plugin/loader/createTransformer.js +92 -0
- package/dist/plugin/loader/{css-loader.development.d.ts → css-loader.d.ts} +6 -8
- package/dist/plugin/loader/css-loader.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.js +134 -0
- package/dist/plugin/loader/directives/addLocalExportedNames.d.ts +4 -0
- package/dist/plugin/loader/directives/addLocalExportedNames.d.ts.map +1 -0
- package/dist/plugin/loader/directives/addLocalExportedNames.js +57 -0
- package/dist/plugin/loader/directives/analyzeDirectives.d.ts +9 -0
- package/dist/plugin/loader/directives/analyzeDirectives.d.ts.map +1 -0
- package/dist/plugin/loader/directives/analyzeDirectives.js +221 -0
- package/dist/plugin/loader/directives/analyzeModule.d.ts +7 -0
- package/dist/plugin/loader/directives/analyzeModule.d.ts.map +1 -0
- package/dist/plugin/loader/directives/analyzeModule.js +48 -0
- package/dist/plugin/loader/directives/collectExports.d.ts +13 -0
- package/dist/plugin/loader/directives/collectExports.d.ts.map +1 -0
- package/dist/plugin/loader/directives/collectExports.js +116 -0
- package/dist/plugin/loader/directives/collectExportsFromModule.d.ts +6 -0
- package/dist/plugin/loader/directives/collectExportsFromModule.d.ts.map +1 -0
- package/dist/plugin/loader/directives/collectExportsFromModule.js +24 -0
- package/dist/plugin/loader/directives/findDirectiveMatches.d.ts +3 -0
- package/dist/plugin/loader/directives/findDirectiveMatches.d.ts.map +1 -0
- package/dist/plugin/loader/directives/findDirectiveMatches.js +46 -0
- package/dist/plugin/loader/directives/getExportedName.d.ts +3 -0
- package/dist/plugin/loader/directives/getExportedName.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getExportedName.js +59 -0
- package/dist/plugin/loader/directives/getExports.d.ts +7 -0
- package/dist/plugin/loader/directives/getExports.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getExports.js +28 -0
- package/dist/plugin/loader/directives/getFunctionBody.d.ts +3 -0
- package/dist/plugin/loader/directives/getFunctionBody.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getFunctionBody.js +31 -0
- package/dist/plugin/loader/directives/getFunctionName.d.ts +10 -0
- package/dist/plugin/loader/directives/getFunctionName.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getFunctionName.js +42 -0
- package/dist/plugin/loader/directives/getQualifiedName.d.ts +3 -0
- package/dist/plugin/loader/directives/getQualifiedName.d.ts.map +1 -0
- package/dist/plugin/loader/directives/getQualifiedName.js +65 -0
- package/dist/plugin/loader/directives/index.d.ts +14 -0
- package/dist/plugin/loader/directives/index.d.ts.map +1 -0
- package/dist/plugin/loader/directives/index.js +18 -0
- package/dist/plugin/loader/directives/processFunctionNode.d.ts +4 -0
- package/dist/plugin/loader/directives/processFunctionNode.d.ts.map +1 -0
- package/dist/plugin/loader/directives/processFunctionNode.js +86 -0
- package/dist/plugin/loader/directives/typeGuards.d.ts +37 -0
- package/dist/plugin/loader/directives/typeGuards.d.ts.map +1 -0
- package/dist/plugin/loader/directives/typeGuards.js +100 -0
- package/dist/plugin/loader/directives/types.d.ts +154 -0
- package/dist/plugin/loader/directives/types.d.ts.map +1 -0
- package/dist/plugin/loader/directives/utils.d.ts +14 -0
- package/dist/plugin/loader/directives/utils.d.ts.map +1 -0
- package/dist/plugin/loader/directives/utils.js +21 -0
- package/dist/plugin/loader/env-loader.d.ts +12 -0
- package/dist/plugin/loader/env-loader.d.ts.map +1 -0
- package/dist/plugin/loader/env-loader.js +88 -0
- package/dist/plugin/loader/index.d.ts +8 -1
- package/dist/plugin/loader/index.d.ts.map +1 -1
- package/dist/plugin/loader/index.js +13 -4
- package/dist/plugin/loader/parse.d.ts +12 -2
- package/dist/plugin/loader/parse.d.ts.map +1 -1
- package/dist/plugin/loader/parse.js +28 -5
- package/dist/plugin/loader/react-loader.d.ts +22 -1
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +169 -6
- package/dist/plugin/loader/removeDirectives.d.ts +5 -0
- package/dist/plugin/loader/removeDirectives.d.ts.map +1 -0
- package/dist/plugin/loader/removeDirectives.js +17 -0
- package/dist/plugin/loader/removeRanges.d.ts +5 -0
- package/dist/plugin/loader/removeRanges.d.ts.map +1 -0
- package/dist/plugin/loader/removeRanges.js +20 -0
- package/dist/plugin/loader/sourceMap.d.ts +16 -24
- package/dist/plugin/loader/sourceMap.d.ts.map +1 -1
- package/dist/plugin/loader/sourceMap.js +125 -97
- package/dist/plugin/loader/transformClientModule.d.ts +9 -0
- package/dist/plugin/loader/transformClientModule.d.ts.map +1 -0
- package/dist/plugin/loader/transformClientModule.js +46 -0
- package/dist/plugin/loader/transformModule.d.ts +6 -0
- package/dist/plugin/loader/transformModule.d.ts.map +1 -0
- package/dist/plugin/loader/transformModule.js +37 -0
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts +12 -1
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -1
- package/dist/plugin/loader/transformModuleIfNeeded.js +9 -20
- package/dist/plugin/loader/transformNonServerEnvironment.d.ts +10 -0
- package/dist/plugin/loader/transformNonServerEnvironment.d.ts.map +1 -0
- package/dist/plugin/loader/transformNonServerEnvironment.js +72 -0
- package/dist/plugin/loader/transformServerModule.d.ts +10 -0
- package/dist/plugin/loader/transformServerModule.d.ts.map +1 -0
- package/dist/plugin/loader/transformServerModule.js +103 -0
- package/dist/plugin/loader/transformWithAcornLoose.d.ts +12 -0
- package/dist/plugin/loader/transformWithAcornLoose.d.ts.map +1 -0
- package/dist/plugin/loader/transformWithAcornLoose.js +16 -0
- package/dist/plugin/loader/types.d.ts +48 -13
- package/dist/plugin/loader/types.d.ts.map +1 -1
- package/dist/plugin/metrics/collectStreamMetrics.d.ts +9 -0
- package/dist/plugin/metrics/collectStreamMetrics.d.ts.map +1 -0
- package/dist/plugin/metrics/collectStreamMetrics.js +35 -0
- package/dist/plugin/metrics/createRenderMetrics.d.ts +3 -0
- package/dist/plugin/metrics/createRenderMetrics.d.ts.map +1 -0
- package/dist/plugin/metrics/createRenderMetrics.js +24 -0
- package/dist/plugin/metrics/createStreamMetrics.d.ts +3 -0
- package/dist/plugin/metrics/createStreamMetrics.d.ts.map +1 -0
- package/dist/plugin/metrics/createStreamMetrics.js +19 -0
- package/dist/plugin/metrics/formatMetrics.d.ts +6 -3
- package/dist/plugin/metrics/formatMetrics.d.ts.map +1 -1
- package/dist/plugin/metrics/formatMetrics.js +5 -2
- package/dist/plugin/metrics/index.d.ts +3 -1
- package/dist/plugin/metrics/index.d.ts.map +1 -1
- package/dist/plugin/metrics/index.js +9 -1
- package/dist/plugin/metrics/types.d.ts +23 -0
- package/dist/plugin/metrics/types.d.ts.map +1 -0
- package/dist/plugin/metrics/types.js +1 -0
- package/dist/plugin/plugin.client.d.ts +23 -2
- package/dist/plugin/plugin.client.d.ts.map +1 -1
- package/dist/plugin/plugin.client.js +14 -9
- package/dist/plugin/plugin.server.d.ts +13 -2
- package/dist/plugin/plugin.server.d.ts.map +1 -1
- package/dist/plugin/plugin.server.js +15 -16
- package/dist/plugin/process-env.d.ts +18 -6
- package/dist/plugin/process-env.d.ts.map +1 -1
- package/dist/plugin/process-env.js +17 -0
- package/dist/plugin/react-client/cleanupWorkerServerAction.d.ts +11 -0
- package/dist/plugin/react-client/cleanupWorkerServerAction.d.ts.map +1 -0
- package/dist/plugin/react-client/cleanupWorkerServerAction.js +18 -0
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts +9 -9
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -1
- package/dist/plugin/react-client/configureWorkerRequestHandler.js +31 -26
- 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 +15 -3
- package/dist/plugin/react-client/createWorkerStream.d.ts +12 -10
- package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.js +27 -29
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts +13 -8
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js +51 -24
- package/dist/plugin/react-client/handleWorkerServerAction.d.ts +2 -1
- package/dist/plugin/react-client/handleWorkerServerAction.d.ts.map +1 -1
- package/dist/plugin/react-client/handleWorkerServerAction.js +43 -28
- package/dist/plugin/react-client/index.d.ts +4 -1
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +10 -1
- package/dist/plugin/react-client/plugin.d.ts +5 -3
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +9 -11
- package/dist/plugin/react-client/restartWorker.d.ts +5 -4
- package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
- package/dist/plugin/react-client/restartWorker.js +14 -13
- package/dist/plugin/react-server/configureReactServer.d.ts +5 -4
- package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -1
- package/dist/plugin/react-server/configureReactServer.js +106 -47
- package/dist/plugin/react-server/handleServerAction.d.ts +3 -2
- package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -1
- package/dist/plugin/react-server/handleServerAction.js +14 -20
- package/dist/plugin/react-server/plugin.d.ts +3 -4
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +30 -31
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +8 -6
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.js +4 -4
- package/dist/plugin/react-static/collectRscContent.d.ts +8 -6
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectRscContent.js +4 -4
- package/dist/plugin/react-static/configurePreviewServer.d.ts +6 -4
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.js +32 -36
- package/dist/plugin/react-static/createBuildLoader.d.ts +5 -5
- package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/react-static/createBuildLoader.js +122 -30
- package/dist/plugin/react-static/fileWriter.js +1 -1
- package/dist/plugin/react-static/plugin.d.ts +3 -4
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +62 -47
- package/dist/plugin/react-static/renderPage.d.ts +4 -2
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPage.js +21 -17
- package/dist/plugin/react-static/renderPages.d.ts +4 -2
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPages.js +7 -6
- package/dist/plugin/react-static/renderStreams.d.ts +5 -22
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
- package/dist/plugin/react-static/renderStreams.js +6 -6
- package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -1
- package/dist/plugin/react-static/rscToHtmlStream.js +1 -1
- package/dist/plugin/react-static/temporaryReferences.js +1 -1
- package/dist/plugin/react-static/types.d.ts +0 -1
- package/dist/plugin/react-static/types.d.ts.map +1 -1
- package/dist/plugin/root.js +1 -1
- package/dist/plugin/transformer/plugin.client.d.ts +29 -1
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.client.js +96 -1
- package/dist/plugin/transformer/plugin.js +1 -1
- package/dist/plugin/transformer/plugin.server.d.ts +5 -3
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.server.js +60 -69
- package/dist/plugin/types/css-tracking.d.ts +2 -2
- package/dist/plugin/types/css-tracking.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +451 -192
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js +2 -1
- package/dist/plugin/utils/callServer.js +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 +1 -1
- package/dist/plugin/utils/createReactFetcher.d.ts +2 -3
- package/dist/plugin/utils/createReactFetcher.d.ts.map +1 -1
- package/dist/plugin/utils/createReactFetcher.js +1 -1
- package/dist/plugin/utils/env.js +1 -1
- package/dist/plugin/utils/envUrls.node.d.ts.map +1 -1
- package/dist/plugin/utils/envUrls.node.js +3 -2
- 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 +12 -5
- package/dist/plugin/utils/routeToURL.d.ts +12 -0
- package/dist/plugin/utils/routeToURL.d.ts.map +1 -0
- package/dist/plugin/utils/routeToURL.js +26 -0
- package/dist/plugin/utils/urls.d.ts.map +1 -1
- package/dist/plugin/utils/urls.js +5 -3
- package/dist/plugin/vendor/index.js +7 -1
- package/dist/plugin/vendor/vendor.client.js +1 -1
- package/dist/plugin/vendor/vendor.js +1 -1
- package/dist/plugin/vendor/vendor.server.js +1 -1
- package/dist/plugin/worker/createWorker.d.ts +31 -17
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +18 -12
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +2 -2
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +5 -2
- package/dist/plugin/worker/html/html-worker.development.js +3 -3
- package/dist/plugin/worker/html/html-worker.production.js +1 -1
- package/dist/plugin/worker/html/index.d.ts +1 -1
- package/dist/plugin/worker/html/index.d.ts.map +1 -1
- package/dist/plugin/worker/html/index.js +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +9 -11
- package/dist/plugin/worker/html/sendHtmlWorkerMessage.d.ts +3 -0
- package/dist/plugin/worker/html/sendHtmlWorkerMessage.d.ts.map +1 -0
- package/dist/plugin/worker/html/sendHtmlWorkerMessage.js +2 -0
- package/dist/plugin/worker/html/types.d.ts +20 -2
- package/dist/plugin/worker/html/types.d.ts.map +1 -1
- package/dist/plugin/worker/index.d.ts +3 -0
- package/dist/plugin/worker/index.d.ts.map +1 -0
- package/dist/plugin/worker/index.js +7 -0
- package/dist/plugin/worker/registerLoaders.js +2 -2
- package/dist/plugin/worker/rsc/handleRender.d.ts +5 -3
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +57 -38
- package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handlers.js +19 -15
- package/dist/plugin/worker/rsc/index.d.ts +1 -1
- package/dist/plugin/worker/rsc/index.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/index.js +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +22 -8
- package/dist/plugin/worker/rsc/rsc-worker.development.js +77 -11
- package/dist/plugin/worker/rsc/rsc-worker.production.js +37 -8
- package/dist/plugin/worker/rsc/sendRscWorkerMessage.d.ts +3 -0
- package/dist/plugin/worker/rsc/sendRscWorkerMessage.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/sendRscWorkerMessage.js +11 -0
- package/dist/plugin/worker/rsc/state.js +1 -1
- package/dist/plugin/worker/rsc/types.d.ts +95 -0
- package/dist/plugin/worker/rsc/types.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/types.js +1 -0
- package/dist/plugin/worker/rsc/userOptions.d.ts +1 -1
- package/dist/plugin/worker/rsc/userOptions.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/userOptions.js +3 -4
- package/dist/plugin/worker/sendMessage.d.ts +3 -4
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
- package/dist/plugin/worker/sendMessage.js +15 -5
- package/dist/plugin/worker/types.d.ts +109 -260
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +59 -26
- package/plugin/components/{css-collector-elements.tsx → css.tsx} +3 -3
- package/plugin/components/html.tsx +4 -4
- package/plugin/components/index.ts +3 -3
- package/plugin/components/root.tsx +20 -0
- package/plugin/config/autoDiscover/resolveAutoDiscover.ts +173 -134
- package/plugin/config/autoDiscover/resolveBuildPages.ts +120 -7
- package/plugin/config/createModuleID.ts +60 -39
- package/plugin/config/defaults.tsx +189 -96
- package/plugin/config/extMap.ts +51 -56
- package/plugin/config/flightBindings.ts +221 -0
- package/plugin/config/getCondition.ts +6 -0
- package/plugin/config/index.ts +17 -4
- package/plugin/config/interpolatePattern.ts +19 -0
- package/plugin/config/parsePattern.ts +81 -0
- package/plugin/config/resolveAllowedDirectives.ts +59 -0
- package/plugin/config/resolveDirectiveMatcher.ts +57 -0
- package/plugin/config/resolveEnv.ts +41 -37
- package/plugin/config/resolveOptions.ts +437 -318
- package/plugin/config/resolvePatternWithValues.ts +70 -0
- package/plugin/config/resolveRegExp.ts +89 -0
- package/plugin/config/resolveUrlOption.ts +92 -20
- package/plugin/config/resolveUserConfig.ts +427 -351
- package/plugin/env/createConfigEnv.ts +40 -0
- package/plugin/env/getArgValue.ts +56 -0
- package/plugin/env/getEnvKey.ts +61 -0
- package/plugin/env/index.ts +4 -1
- package/plugin/env/plugin.ts +13 -18
- package/plugin/env/userConfigEnv.ts +22 -0
- package/plugin/error/directiveError.ts +29 -0
- package/plugin/error/enhanceError.ts +41 -0
- package/plugin/error/index.ts +3 -0
- package/plugin/error/logError.ts +48 -0
- package/plugin/error/serializeError.ts +34 -0
- package/plugin/error/toError.ts +75 -45
- package/plugin/file-preserver/plugin.ts +3 -3
- package/plugin/getNodeEnv.ts +24 -0
- package/plugin/helpers/cleanObject.ts +2 -1
- package/plugin/helpers/collectViteModuleGraphCss.ts +138 -118
- package/plugin/helpers/createCssProps.tsx +29 -30
- package/plugin/helpers/createEventHandler.ts +1 -1
- package/plugin/helpers/createHandler.ts +40 -12
- package/plugin/helpers/createRscStream.tsx +103 -36
- package/plugin/helpers/formatMetrics.ts +2 -37
- package/plugin/helpers/getBundleManifest.ts +10 -1
- package/plugin/helpers/getRouteFiles.ts +154 -9
- package/plugin/helpers/handleServerAction.ts +12 -7
- package/plugin/helpers/hydrateUserOptions.ts +23 -0
- package/plugin/helpers/index.ts +4 -0
- package/plugin/helpers/inputNormalizer.ts +44 -24
- package/plugin/helpers/metrics.ts +4 -64
- package/plugin/helpers/moduleResolver.ts +74 -19
- package/plugin/helpers/requestInfo.ts +95 -61
- package/plugin/helpers/requestToRoute.ts +38 -12
- package/plugin/helpers/resolveComponent.ts +173 -0
- package/plugin/helpers/resolveComponents.ts +202 -0
- package/plugin/helpers/resolvePage.ts +35 -29
- package/plugin/helpers/resolvePageAndProps.ts +82 -61
- package/plugin/helpers/resolveProps.ts +100 -37
- package/plugin/helpers/resolveUserComponents.ts +190 -0
- package/plugin/helpers/serializeUserOptions.ts +190 -69
- package/plugin/helpers/stashReturnValue.ts +7 -4
- package/plugin/helpers/tryManifest.ts +1 -1
- package/plugin/loader/createDefaultLoader.ts +119 -119
- package/plugin/loader/createTransformer.ts +110 -0
- package/plugin/loader/css-loader.ts +206 -0
- package/plugin/loader/directives/addLocalExportedNames.ts +78 -0
- package/plugin/loader/directives/analyzeDirectives.ts +298 -0
- package/plugin/loader/directives/analyzeModule.ts +57 -0
- package/plugin/loader/directives/collectExports.ts +181 -0
- package/plugin/loader/directives/collectExportsFromModule.ts +25 -0
- package/plugin/loader/directives/findDirectiveMatches.ts +58 -0
- package/plugin/loader/directives/getExportedName.ts +73 -0
- package/plugin/loader/directives/getExports.ts +27 -0
- package/plugin/loader/directives/getFunctionBody.ts +32 -0
- package/plugin/loader/directives/getFunctionName.ts +70 -0
- package/plugin/loader/directives/getQualifiedName.ts +76 -0
- package/plugin/loader/directives/index.ts +13 -0
- package/plugin/loader/directives/processFunctionNode.ts +97 -0
- package/plugin/loader/directives/typeGuards.ts +160 -0
- package/plugin/loader/directives/types.ts +174 -0
- package/plugin/loader/directives/utils.ts +35 -0
- package/plugin/loader/env-loader.ts +135 -0
- package/plugin/loader/index.ts +8 -6
- package/plugin/loader/parse.ts +42 -12
- package/plugin/loader/react-loader.ts +256 -4
- package/plugin/loader/removeDirectives.ts +14 -0
- package/plugin/loader/removeRanges.ts +21 -0
- package/plugin/loader/sourceMap.ts +174 -84
- package/plugin/loader/transformClientModule.ts +60 -0
- package/plugin/loader/transformModule.ts +59 -0
- package/plugin/loader/transformModuleIfNeeded.ts +40 -40
- package/plugin/loader/transformNonServerEnvironment.ts +95 -0
- package/plugin/loader/transformServerModule.ts +167 -0
- package/plugin/loader/transformWithAcornLoose.ts +27 -0
- package/plugin/loader/types.ts +58 -13
- package/plugin/metrics/collectStreamMetrics.ts +38 -0
- package/plugin/metrics/createRenderMetrics.ts +17 -0
- package/plugin/metrics/createStreamMetrics.ts +14 -0
- package/plugin/metrics/formatMetrics.ts +7 -3
- package/plugin/metrics/index.ts +3 -1
- package/plugin/metrics/types.ts +24 -0
- package/plugin/plugin.client.ts +43 -16
- package/plugin/plugin.server.ts +41 -21
- package/plugin/process-env.ts +27 -6
- package/plugin/react-client/cleanupWorkerServerAction.ts +33 -0
- package/plugin/react-client/configureWorkerRequestHandler.ts +206 -201
- package/plugin/react-client/createMessageHandlers.ts +17 -3
- package/plugin/react-client/createWorkerStream.ts +55 -51
- package/plugin/react-client/handleWorkerRscStream.ts +130 -61
- package/plugin/react-client/handleWorkerServerAction.ts +59 -37
- package/plugin/react-client/index.ts +4 -1
- package/plugin/react-client/plugin.ts +17 -18
- package/plugin/react-client/restartWorker.ts +74 -70
- package/plugin/react-server/configureReactServer.ts +204 -142
- package/plugin/react-server/handleServerAction.ts +156 -160
- package/plugin/react-server/plugin.ts +150 -157
- package/plugin/react-static/collectHtmlWorkerContent.ts +109 -102
- package/plugin/react-static/collectRscContent.ts +55 -51
- package/plugin/react-static/configurePreviewServer.ts +99 -100
- package/plugin/react-static/createBuildLoader.ts +157 -48
- package/plugin/react-static/plugin.ts +368 -357
- package/plugin/react-static/renderPage.ts +31 -24
- package/plugin/react-static/renderPages.ts +21 -14
- package/plugin/react-static/renderStreams.ts +13 -15
- package/plugin/react-static/rscToHtmlStream.ts +4 -6
- package/plugin/react-static/types.ts +0 -3
- package/plugin/transformer/README.md +82 -8
- package/plugin/transformer/plugin.client.ts +142 -0
- package/plugin/transformer/plugin.server.ts +87 -112
- package/plugin/types/css-tracking.ts +1 -1
- package/plugin/types/global.d.ts +2 -2
- package/plugin/types/react-server-dom-esm.d.ts +12 -13
- package/plugin/types.ts +684 -309
- package/plugin/utils/createCallServer.ts +5 -5
- package/plugin/utils/createReactFetcher.ts +4 -6
- package/plugin/utils/envUrls.node.ts +15 -10
- package/plugin/utils/index.ts +2 -1
- package/plugin/utils/routeToURL.ts +34 -0
- package/plugin/utils/urls.ts +10 -7
- package/plugin/worker/createWorker.ts +67 -34
- package/plugin/worker/html/README.md +10 -0
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +7 -4
- package/plugin/worker/html/html-worker.development.tsx +4 -3
- package/plugin/worker/html/index.ts +3 -1
- package/plugin/worker/html/messageHandler.tsx +10 -16
- package/plugin/worker/html/sendHtmlWorkerMessage.ts +8 -0
- package/plugin/worker/html/types.ts +67 -1
- package/plugin/worker/index.ts +2 -0
- package/plugin/worker/registerLoaders.ts +3 -3
- package/plugin/worker/rsc/README.md +203 -1
- package/plugin/worker/rsc/handleRender.ts +75 -45
- package/plugin/worker/rsc/handlers.ts +30 -22
- package/plugin/worker/rsc/index.ts +2 -0
- package/plugin/worker/rsc/messageHandler.tsx +23 -13
- package/plugin/worker/rsc/rsc-worker.development.ts +104 -17
- package/plugin/worker/rsc/rsc-worker.production.ts +57 -10
- package/plugin/worker/rsc/sendRscWorkerMessage.ts +7 -0
- package/plugin/worker/rsc/state.ts +1 -1
- package/plugin/worker/rsc/types.ts +185 -0
- package/plugin/worker/rsc/userOptions.ts +2 -3
- package/plugin/worker/sendMessage.ts +23 -14
- package/plugin/worker/types.ts +131 -386
- package/scripts/check-react-version.mjs +3 -3
- package/scripts/fix-unused-imports.mjs +77 -0
- package/tsconfig.json +1 -1
- package/dist/_virtual/dynamic-import-helper.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plugin/components/css-collector-elements.d.ts.map +0 -1
- package/dist/plugin/components/css-collector-elements.js +0 -33
- package/dist/plugin/components/css-collector-elements.js.map +0 -1
- package/dist/plugin/components/css-collector.d.ts +0 -7
- package/dist/plugin/components/css-collector.d.ts.map +0 -1
- package/dist/plugin/components/css-collector.js +0 -18
- package/dist/plugin/components/css-collector.js.map +0 -1
- package/dist/plugin/components/html.js.map +0 -1
- package/dist/plugin/components.js +0 -9
- package/dist/plugin/components.js.map +0 -1
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js.map +0 -1
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js.map +0 -1
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js.map +0 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +0 -1
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +0 -1
- package/dist/plugin/config/defaults.js.map +0 -1
- package/dist/plugin/config/extMap.js.map +0 -1
- package/dist/plugin/config/getCondition.js.map +0 -1
- package/dist/plugin/config/getPaths.js.map +0 -1
- package/dist/plugin/config/mimeTypes.js.map +0 -1
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts +0 -5
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts.map +0 -1
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js +0 -25
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js.map +0 -1
- package/dist/plugin/config/resolveEnv.js.map +0 -1
- package/dist/plugin/config/resolveOptions.js.map +0 -1
- package/dist/plugin/config/resolvePages.js.map +0 -1
- package/dist/plugin/config/resolveUrlOption.js.map +0 -1
- package/dist/plugin/config/resolveUserConfig.js.map +0 -1
- package/dist/plugin/config.js +0 -17
- package/dist/plugin/config.js.map +0 -1
- package/dist/plugin/env.js +0 -79
- package/dist/plugin/env.js.map +0 -1
- package/dist/plugin/error/toError.js.map +0 -1
- package/dist/plugin/file-preserver.js +0 -96
- package/dist/plugin/file-preserver.js.map +0 -1
- package/dist/plugin/helpers/cleanObject.js.map +0 -1
- package/dist/plugin/helpers/collectManifestCss.js.map +0 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +0 -1
- package/dist/plugin/helpers/createCssProps.js.map +0 -1
- package/dist/plugin/helpers/createEventHandler.js.map +0 -1
- package/dist/plugin/helpers/createHandler.js.map +0 -1
- package/dist/plugin/helpers/createRscStream.js.map +0 -1
- package/dist/plugin/helpers/formatMetrics.js.map +0 -1
- package/dist/plugin/helpers/getBundleManifest.js.map +0 -1
- package/dist/plugin/helpers/getRouteFiles.js.map +0 -1
- package/dist/plugin/helpers/handleServerAction.js.map +0 -1
- package/dist/plugin/helpers/inputNormalizer.js.map +0 -1
- package/dist/plugin/helpers/metrics.js.map +0 -1
- package/dist/plugin/helpers/moduleRefs.js.map +0 -1
- package/dist/plugin/helpers/requestInfo.js.map +0 -1
- package/dist/plugin/helpers/requestToRoute.js.map +0 -1
- package/dist/plugin/helpers/resolvePage.js.map +0 -1
- package/dist/plugin/helpers/resolvePageAndProps.js.map +0 -1
- package/dist/plugin/helpers/resolveProps.js.map +0 -1
- package/dist/plugin/helpers/serializeUserOptions.js.map +0 -1
- package/dist/plugin/helpers/sourceMap.d.ts +0 -8
- package/dist/plugin/helpers/sourceMap.d.ts.map +0 -1
- package/dist/plugin/helpers/sourceMap.js +0 -136
- package/dist/plugin/helpers/stashReturnValue.js.map +0 -1
- package/dist/plugin/helpers/tryManifest.js.map +0 -1
- package/dist/plugin/helpers.js +0 -27
- package/dist/plugin/helpers.js.map +0 -1
- package/dist/plugin/loader/css-loader.development.d.ts.map +0 -1
- package/dist/plugin/loader/css-loader.development.js +0 -76
- package/dist/plugin/loader/css-loader.development.js.map +0 -1
- package/dist/plugin/loader/css-loader.production.d.ts +0 -31
- package/dist/plugin/loader/css-loader.production.d.ts.map +0 -1
- package/dist/plugin/loader/css-loader.production.js +0 -45
- package/dist/plugin/loader/css-loader.production.js.map +0 -1
- package/dist/plugin/loader/env-loader.development.d.ts +0 -13
- package/dist/plugin/loader/env-loader.development.d.ts.map +0 -1
- package/dist/plugin/loader/env-loader.development.js +0 -68
- package/dist/plugin/loader/handleExports.d.ts +0 -40
- package/dist/plugin/loader/handleExports.d.ts.map +0 -1
- package/dist/plugin/loader/handleExports.js +0 -209
- package/dist/plugin/loader/handleExports.js.map +0 -1
- package/dist/plugin/loader/parse.js.map +0 -1
- package/dist/plugin/loader/react-loader.client.d.ts +0 -2
- package/dist/plugin/loader/react-loader.client.d.ts.map +0 -1
- package/dist/plugin/loader/react-loader.client.js +0 -2
- package/dist/plugin/loader/react-loader.js.map +0 -1
- package/dist/plugin/loader/react-loader.server.d.ts +0 -21
- package/dist/plugin/loader/react-loader.server.d.ts.map +0 -1
- package/dist/plugin/loader/react-loader.server.js +0 -131
- package/dist/plugin/loader/transformModuleIfNeeded.js.map +0 -1
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts +0 -48
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +0 -1
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +0 -428
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +0 -1
- package/dist/plugin/metrics/formatMetrics.js.map +0 -1
- package/dist/plugin/metrics.js +0 -7
- package/dist/plugin/metrics.js.map +0 -1
- package/dist/plugin/plugin.client.js.map +0 -1
- package/dist/plugin/plugin.server.js.map +0 -1
- package/dist/plugin/preserver/index.d.ts +0 -2
- package/dist/plugin/preserver/index.d.ts.map +0 -1
- package/dist/plugin/preserver/index.js +0 -1
- package/dist/plugin/preserver/plugin.d.ts +0 -3
- package/dist/plugin/preserver/plugin.d.ts.map +0 -1
- package/dist/plugin/preserver/plugin.js +0 -130
- package/dist/plugin/preserver/plugin.js.map +0 -1
- package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +0 -1
- package/dist/plugin/react-client/createMessageHandlers.js.map +0 -1
- package/dist/plugin/react-client/createWorkerStream.js.map +0 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js.map +0 -1
- package/dist/plugin/react-client/handleWorkerServerAction.js.map +0 -1
- package/dist/plugin/react-client/plugin.js.map +0 -1
- package/dist/plugin/react-client/restartWorker.js.map +0 -1
- package/dist/plugin/react-server/configureReactServer.js.map +0 -1
- package/dist/plugin/react-server/handleServerAction.js.map +0 -1
- package/dist/plugin/react-server/plugin.js.map +0 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +0 -1
- package/dist/plugin/react-static/collectRscContent.js.map +0 -1
- package/dist/plugin/react-static/configurePreviewServer.js.map +0 -1
- package/dist/plugin/react-static/createBuildLoader.js.map +0 -1
- package/dist/plugin/react-static/fileWriter.js.map +0 -1
- package/dist/plugin/react-static/plugin.js.map +0 -1
- package/dist/plugin/react-static/renderPage.js.map +0 -1
- package/dist/plugin/react-static/renderPages.js.map +0 -1
- package/dist/plugin/react-static/renderStreams.js.map +0 -1
- package/dist/plugin/react-static/rscToHtmlStream.js.map +0 -1
- package/dist/plugin/react-static/streamHandler.d.ts +0 -2
- package/dist/plugin/react-static/streamHandler.d.ts.map +0 -1
- package/dist/plugin/react-static/temporaryReferences.js.map +0 -1
- package/dist/plugin/root.js.map +0 -1
- package/dist/plugin/source-map/createMappingsSerializer.d.ts +0 -2
- package/dist/plugin/source-map/createMappingsSerializer.d.ts.map +0 -1
- package/dist/plugin/source-map/createMappingsSerializer.js +0 -129
- package/dist/plugin/source-map/createMappingsSerializer.js.map +0 -1
- package/dist/plugin/source-map/readMappings.d.ts +0 -2
- package/dist/plugin/source-map/readMappings.d.ts.map +0 -1
- package/dist/plugin/source-map/readMappings.js +0 -200
- package/dist/plugin/transformer/plugin.js.map +0 -1
- package/dist/plugin/transformer/plugin.server.js.map +0 -1
- package/dist/plugin/utils/callServer.js.map +0 -1
- package/dist/plugin/utils/createCallServer.js.map +0 -1
- package/dist/plugin/utils/createReactFetcher.js.map +0 -1
- package/dist/plugin/utils/env.js.map +0 -1
- package/dist/plugin/utils/envUrls.node.js.map +0 -1
- package/dist/plugin/utils/urls.js.map +0 -1
- package/dist/plugin/utils.js +0 -11
- package/dist/plugin/utils.js.map +0 -1
- package/dist/plugin/vendor/vendor.client.js.map +0 -1
- package/dist/plugin/vendor/vendor.js.map +0 -1
- package/dist/plugin/vendor/vendor.server.js.map +0 -1
- package/dist/plugin/vendor.js +0 -7
- package/dist/plugin/vendor.js.map +0 -1
- package/dist/plugin/worker/createWorker.js.map +0 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +0 -1
- package/dist/plugin/worker/html/html-worker.development.js.map +0 -1
- package/dist/plugin/worker/html/html-worker.production.js.map +0 -1
- package/dist/plugin/worker/html/index.js.map +0 -1
- package/dist/plugin/worker/html/messageHandler.js.map +0 -1
- package/dist/plugin/worker/rsc/handleRender.js.map +0 -1
- package/dist/plugin/worker/rsc/handlers.js.map +0 -1
- package/dist/plugin/worker/rsc/index.js.map +0 -1
- package/dist/plugin/worker/rsc/messageHandler.js.map +0 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +0 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +0 -1
- package/dist/plugin/worker/rsc/state.js.map +0 -1
- package/dist/plugin/worker/rsc/userOptions.js.map +0 -1
- package/dist/plugin/worker/sendMessage.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/plugin/components/css-collector.tsx +0 -20
- package/plugin/config/resolveAutoDiscoverMatcher.ts +0 -23
- package/plugin/helpers/sourceMap.ts +0 -182
- package/plugin/loader/css-loader.development.ts +0 -135
- package/plugin/loader/css-loader.production.ts +0 -84
- package/plugin/loader/env-loader.development.ts +0 -107
- package/plugin/loader/handleExports.ts +0 -309
- package/plugin/loader/react-loader.client.ts +0 -1
- package/plugin/loader/react-loader.server.ts +0 -185
- package/plugin/loader/transformModuleWithPreservedFunctions.ts +0 -593
- package/plugin/preserver/index.ts +0 -1
- package/plugin/preserver/plugin.ts +0 -178
- package/plugin/react-static/streamHandler.ts +0 -0
- package/plugin/source-map/createMappingsSerializer.ts +0 -181
- package/plugin/source-map/readMappings.ts +0 -194
- /package/dist/plugin/{react-static/streamHandler.js → loader/directives/types.js} +0 -0
package/plugin/plugin.client.ts
CHANGED
|
@@ -1,19 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
StreamPluginOptions,
|
|
4
|
-
InlineCssOpt,
|
|
5
|
-
PagePropOpt,
|
|
6
|
-
} from "../types.js";
|
|
1
|
+
import type { StreamPluginOptions } from "../types.js";
|
|
7
2
|
import { reactClientPlugin } from "./react-client/plugin.js";
|
|
8
3
|
import { envPlugin } from "./env/plugin.js";
|
|
4
|
+
import type { Plugin } from "vite";
|
|
5
|
+
import { reactTransformPlugin } from "./transformer/plugin.client.js";
|
|
9
6
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
export type VitePluginReactClientFn = <
|
|
8
|
+
Opt extends StreamPluginOptions = StreamPluginOptions
|
|
9
|
+
>(
|
|
10
|
+
options: Opt
|
|
11
|
+
) => Plugin[];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Vite plugin for the React client, use same name to support dynamic import.
|
|
15
|
+
* Includes:
|
|
16
|
+
* - envPlugin
|
|
17
|
+
* - reactClientPlugin
|
|
18
|
+
* - reactPreservePlugin (handles directive removal/preservation)
|
|
19
|
+
* @param options
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export const vitePluginReactServer: VitePluginReactClientFn =
|
|
23
|
+
function _vitePluginReactClient(options) {
|
|
24
|
+
if (options == null) {
|
|
25
|
+
throw new Error("options is required");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const plugins = [
|
|
29
|
+
envPlugin(),
|
|
30
|
+
reactTransformPlugin(options),
|
|
31
|
+
reactClientPlugin(options),
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
return plugins;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Vite plugin for the React client, use specific name to support static import (that doesn't conflict with vitePluginReactServer)
|
|
39
|
+
* Includes:
|
|
40
|
+
* - envPlugin
|
|
41
|
+
* - reactClientPlugin
|
|
42
|
+
* - reactPreservePlugin (handles directive removal/preservation)
|
|
43
|
+
* @param options
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
export const vitePluginReactClient = vitePluginReactServer;
|
package/plugin/plugin.server.ts
CHANGED
|
@@ -1,31 +1,51 @@
|
|
|
1
|
-
import { reactPreservePlugin } from "./preserver/plugin.js";
|
|
2
1
|
import { reactStaticPlugin } from "./react-static/plugin.js";
|
|
3
2
|
import { reactTransformPlugin } from "./transformer/plugin.server.js";
|
|
4
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
StreamPluginOptions,
|
|
5
|
+
} from "./types.js";
|
|
5
6
|
import { reactServerPlugin } from "./react-server/plugin.js";
|
|
6
7
|
import { envPlugin } from "./env/plugin.js";
|
|
8
|
+
import type { Plugin } from "vite";
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
T extends PagePropOpt = PagePropOpt,
|
|
11
|
-
InlineCSS extends InlineCssOpt = InlineCssOpt
|
|
10
|
+
export type VitePluginReactServerFn = <
|
|
11
|
+
Opt extends StreamPluginOptions = StreamPluginOptions
|
|
12
12
|
>(
|
|
13
|
-
options
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
options: Opt
|
|
14
|
+
) => Plugin[];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Vite plugin for the React server, use same name to support dynamic import.
|
|
18
|
+
* Includes:
|
|
19
|
+
* - envPlugin
|
|
20
|
+
* - reactTransformPlugin
|
|
21
|
+
* - reactServerPlugin
|
|
22
|
+
* - reactStaticPlugin (if build.pages is not empty)
|
|
23
|
+
* - reactPreservePlugin (handles directive removal/preservation)
|
|
24
|
+
*/
|
|
25
|
+
export const vitePluginReactServer: VitePluginReactServerFn =
|
|
26
|
+
function _vitePluginReactServer(
|
|
27
|
+
options
|
|
28
|
+
) {
|
|
29
|
+
if(options == null) {
|
|
30
|
+
throw new Error("options is required");
|
|
31
|
+
}
|
|
32
|
+
const basePlugins = [
|
|
18
33
|
envPlugin(),
|
|
19
34
|
reactTransformPlugin(options),
|
|
20
35
|
reactServerPlugin(options),
|
|
21
|
-
reactPreservePlugin(options),
|
|
22
36
|
];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
|
|
38
|
+
if (
|
|
39
|
+
!options.build?.pages ||
|
|
40
|
+
(Array.isArray(options.build.pages) && options.build.pages.length === 0)
|
|
41
|
+
) {
|
|
42
|
+
// in this case we do not need the static plugin at all
|
|
43
|
+
return basePlugins;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Add static plugin for static builds
|
|
47
|
+
return [
|
|
48
|
+
...basePlugins,
|
|
49
|
+
reactStaticPlugin(options),
|
|
50
|
+
];
|
|
51
|
+
};
|
package/plugin/process-env.ts
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
|
+
import { DEFAULT_CONFIG } from "./config/defaults.js";
|
|
2
|
+
import { getEnvKey } from "./env/getEnvKey.js";
|
|
3
|
+
|
|
1
4
|
declare global {
|
|
2
5
|
namespace NodeJS {
|
|
3
6
|
interface ProcessEnv {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
VITE_PROD: string;
|
|
7
|
-
VITE_SSR: string;
|
|
8
|
-
VITE_MODE: string;
|
|
9
|
-
VITE_PUBLIC_ORIGIN: string;
|
|
7
|
+
// Base environment variables (these use the configured prefix)
|
|
8
|
+
[key: string]: string | undefined;
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates a type-safe environment variable accessor for a specific prefix
|
|
15
|
+
* @param prefix The environment prefix (e.g., "VITE_", "CUSTOM_")
|
|
16
|
+
* @returns Object with typed environment variable accessors
|
|
17
|
+
*/
|
|
18
|
+
export function createEnvAccessor(prefix: string = DEFAULT_CONFIG.ENV_PREFIX) {
|
|
19
|
+
return {
|
|
20
|
+
MODE: process.env[getEnvKey("MODE", prefix)],
|
|
21
|
+
DEV: process.env[getEnvKey("DEV", prefix)],
|
|
22
|
+
PROD: process.env[getEnvKey("PROD", prefix)],
|
|
23
|
+
SSR: process.env[getEnvKey("SSR", prefix)],
|
|
24
|
+
BASE_URL: process.env[getEnvKey("BASE_URL", prefix)],
|
|
25
|
+
PUBLIC_ORIGIN: process.env[getEnvKey("PUBLIC_ORIGIN", prefix)]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Type definition for environment variables with a specific prefix
|
|
31
|
+
*/
|
|
32
|
+
export type PrefixedEnv = ReturnType<typeof createEnvAccessor>;
|
|
33
|
+
|
|
13
34
|
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Logger } from "vite";
|
|
2
|
+
import type { Worker } from "node:worker_threads";
|
|
3
|
+
import { logError } from "../error/logError.js";
|
|
4
|
+
import type { MessageHandler } from "../types.js";
|
|
5
|
+
import type { ServerResponse } from "node:http";
|
|
6
|
+
import type { RscChunkOutputMessage } from "../worker/rsc/types.js";
|
|
7
|
+
import type { PassThrough } from "node:stream";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Handles cleanup of worker server action resources
|
|
11
|
+
*/
|
|
12
|
+
export function cleanupWorkerServerAction(
|
|
13
|
+
passThrough: PassThrough,
|
|
14
|
+
worker: Worker,
|
|
15
|
+
messageHandler: MessageHandler<RscChunkOutputMessage>,
|
|
16
|
+
res: ServerResponse,
|
|
17
|
+
error?: unknown,
|
|
18
|
+
logger?: Logger
|
|
19
|
+
) {
|
|
20
|
+
// Remove message handler first to prevent any new messages
|
|
21
|
+
worker.removeListener("message", messageHandler);
|
|
22
|
+
|
|
23
|
+
// End the pass-through stream
|
|
24
|
+
passThrough.end();
|
|
25
|
+
|
|
26
|
+
// Log error if provided
|
|
27
|
+
if (error && logger) {
|
|
28
|
+
logError(error, logger);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// End the response
|
|
32
|
+
res.end();
|
|
33
|
+
}
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import type { ViteDevServer } from "vite";
|
|
2
2
|
import type {
|
|
3
3
|
AutoDiscoveredFiles,
|
|
4
|
-
InlineCssOpt,
|
|
5
|
-
PagePropOpt,
|
|
6
4
|
RenderMetrics,
|
|
7
5
|
RequestHandler,
|
|
8
6
|
ResolvedUserOptions,
|
|
9
7
|
StreamMetrics,
|
|
10
8
|
} from "../types.js";
|
|
11
|
-
import { MessageChannel
|
|
9
|
+
import type { MessageChannel } from "node:worker_threads";
|
|
10
|
+
import { type Worker } from "node:worker_threads";
|
|
12
11
|
import { serializedOptions } from "../helpers/serializeUserOptions.js";
|
|
13
12
|
import { requestInfo } from "../helpers/requestInfo.js";
|
|
14
13
|
import { performance } from "node:perf_hooks";
|
|
15
14
|
import { restartWorker } from "./restartWorker.js";
|
|
16
15
|
import { handleWorkerRscStream } from "./handleWorkerRscStream.js";
|
|
17
16
|
import { getRouteFiles } from "../helpers/getRouteFiles.js";
|
|
18
|
-
import type { RscWorkerInputMessage } from "../worker/types.js";
|
|
17
|
+
import type { RscWorkerInputMessage } from "../worker/rsc/types.js";
|
|
19
18
|
import { Readable } from "node:stream";
|
|
20
19
|
import type { ReadableStream } from "node:stream/web";
|
|
21
20
|
import { handleWorkerServerAction } from "./handleWorkerServerAction.js";
|
|
21
|
+
import { logError } from "../error/logError.js";
|
|
22
|
+
|
|
23
|
+
export type ConfigureWorkerRequestHandlerFn = (props: {
|
|
24
|
+
server: ViteDevServer;
|
|
25
|
+
autoDiscoveredFiles: AutoDiscoveredFiles;
|
|
26
|
+
userOptions: ResolvedUserOptions;
|
|
27
|
+
hmrChannel: MessageChannel;
|
|
28
|
+
}) => void;
|
|
22
29
|
|
|
23
30
|
/**
|
|
24
31
|
* Configures the worker request handler.
|
|
@@ -26,219 +33,217 @@ import { handleWorkerServerAction } from "./handleWorkerServerAction.js";
|
|
|
26
33
|
* @param autoDiscoveredFiles - The auto discovered files
|
|
27
34
|
* @param userOptions - The user options
|
|
28
35
|
*/
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
moduleBaseURL: _moduleBaseURL,
|
|
49
|
-
...handlerUserOptions
|
|
50
|
-
} = _userOptions;
|
|
51
|
-
const handlerOptions = Object.assign({}, handlerUserOptions, {
|
|
52
|
-
moduleBaseURL: server.config.base,
|
|
53
|
-
moduleBasePath: server.config.base,
|
|
54
|
-
projectRoot: server.config.root,
|
|
55
|
-
});
|
|
36
|
+
export const configureWorkerRequestHandler: ConfigureWorkerRequestHandlerFn =
|
|
37
|
+
async function _configureWorkerRequestHandler({
|
|
38
|
+
server,
|
|
39
|
+
autoDiscoveredFiles,
|
|
40
|
+
userOptions: _userOptions,
|
|
41
|
+
hmrChannel,
|
|
42
|
+
}) {
|
|
43
|
+
const logger = server.config.customLogger || server.config.logger;
|
|
44
|
+
const {
|
|
45
|
+
// remove these
|
|
46
|
+
projectRoot: _projectRoot,
|
|
47
|
+
moduleBaseURL: _moduleBaseURL,
|
|
48
|
+
...handlerUserOptions
|
|
49
|
+
} = _userOptions;
|
|
50
|
+
const handlerOptions = Object.assign({}, handlerUserOptions, {
|
|
51
|
+
moduleBaseURL: server.config.base,
|
|
52
|
+
projectRoot: server.config.root,
|
|
53
|
+
logger: logger,
|
|
54
|
+
});
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const logger = server.config.logger;
|
|
56
|
+
// Start the worker
|
|
57
|
+
let currentWorker: Worker | null = null;
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
// Handle server restarts
|
|
60
|
+
server.ws.on("restart", async () => {
|
|
61
|
+
logger.info("[react-client] Server restarting, shutting down worker...");
|
|
62
|
+
if (currentWorker) {
|
|
63
|
+
currentWorker.postMessage({
|
|
64
|
+
type: "SHUTDOWN",
|
|
65
|
+
id: "*",
|
|
66
|
+
} satisfies RscWorkerInputMessage);
|
|
67
|
+
await new Promise((resolve, reject) => {
|
|
68
|
+
currentWorker?.on("message", (message) => {
|
|
69
|
+
if (message.type === "SHUTDOWN_COMPLETE") {
|
|
70
|
+
resolve(true);
|
|
71
|
+
} else {
|
|
72
|
+
reject("Did not receive SHUTDOWN_COMPLETE");
|
|
73
|
+
}
|
|
74
|
+
});
|
|
76
75
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
});
|
|
76
|
+
currentWorker.removeAllListeners();
|
|
77
|
+
currentWorker = null;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
82
80
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
// Create the request handler
|
|
82
|
+
const handler: RequestHandler = async (req, res, next) => {
|
|
83
|
+
if (!req.url) return next();
|
|
86
84
|
|
|
87
|
-
|
|
85
|
+
const info = requestInfo(req, handlerOptions, "");
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
// Serialize user options for worker
|
|
88
|
+
const serializedUserOptions = serializedOptions(
|
|
89
|
+
handlerOptions,
|
|
90
|
+
autoDiscoveredFiles
|
|
91
|
+
);
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
93
|
+
// Handle server action requests
|
|
94
|
+
if (info.isServerActionRequest) {
|
|
95
|
+
if (!currentWorker) {
|
|
96
|
+
currentWorker = await restartWorker({
|
|
97
|
+
server,
|
|
98
|
+
autoDiscoveredFiles,
|
|
99
|
+
userOptions: serializedUserOptions,
|
|
100
|
+
hmrChannel,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (!currentWorker) {
|
|
104
|
+
throw new Error("Failed to start worker");
|
|
105
|
+
}
|
|
106
|
+
return handleWorkerServerAction(req, res, currentWorker, logger);
|
|
107
107
|
}
|
|
108
|
-
return handleWorkerServerAction(req, res, currentWorker, server.config.logger);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Handle RSC requests
|
|
112
|
-
if (!info.isRscRequest) {
|
|
113
|
-
return next();
|
|
114
|
-
}
|
|
115
108
|
|
|
116
|
-
|
|
117
|
-
info.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
);
|
|
121
|
-
if (routeFiles.type === "error") {
|
|
122
|
-
logger.error(routeFiles.error.message);
|
|
123
|
-
return next();
|
|
124
|
-
}
|
|
125
|
-
const pagePath = routeFiles.page;
|
|
126
|
-
const propsPath = routeFiles.props;
|
|
127
|
-
try {
|
|
128
|
-
// Set up response headers for streaming
|
|
129
|
-
res.setHeader("Content-Type", info.contentType);
|
|
130
|
-
res.setHeader("Transfer-Encoding", "chunked");
|
|
131
|
-
res.setHeader("Connection", "keep-alive");
|
|
109
|
+
// Handle RSC requests
|
|
110
|
+
if (!info.isRscRequest) {
|
|
111
|
+
return next();
|
|
112
|
+
}
|
|
132
113
|
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
chunks: metrics.chunks,
|
|
143
|
-
chunkRate: metrics.chunks / (elapsedTime / 1000),
|
|
144
|
-
memoryUsage: process.memoryUsage(),
|
|
145
|
-
streamMetrics: {
|
|
146
|
-
...metrics,
|
|
147
|
-
duration: elapsedTime,
|
|
148
|
-
},
|
|
149
|
-
htmlSizes: new Map(),
|
|
150
|
-
rscSizes: new Map([[info.route, metrics.bytes]]),
|
|
151
|
-
} satisfies RenderMetrics;
|
|
152
|
-
onMetrics(formattedMetrics);
|
|
153
|
-
}
|
|
154
|
-
: () => {};
|
|
155
|
-
const startTime = performance.now();
|
|
156
|
-
if (!currentWorker) {
|
|
157
|
-
currentWorker = await restartWorker({
|
|
158
|
-
server,
|
|
159
|
-
autoDiscoveredFiles,
|
|
160
|
-
userOptions: serializedUserOptions,
|
|
161
|
-
hmrChannel,
|
|
162
|
-
});
|
|
114
|
+
const routeFiles = await getRouteFiles(
|
|
115
|
+
info.route,
|
|
116
|
+
autoDiscoveredFiles,
|
|
117
|
+
handlerOptions,
|
|
118
|
+
logger
|
|
119
|
+
);
|
|
120
|
+
if (routeFiles.type === "error") {
|
|
121
|
+
logError(routeFiles.error, logger);
|
|
122
|
+
return next();
|
|
163
123
|
}
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
124
|
+
const pagePath = routeFiles.page;
|
|
125
|
+
const propsPath = routeFiles.props;
|
|
126
|
+
const rootPath = routeFiles.root;
|
|
127
|
+
const htmlPath = routeFiles.html;
|
|
128
|
+
try {
|
|
129
|
+
// Set up response headers for streaming
|
|
130
|
+
res.setHeader("Content-Type", info.contentType);
|
|
131
|
+
res.setHeader("Transfer-Encoding", "chunked");
|
|
132
|
+
res.setHeader("Connection", "keep-alive");
|
|
133
|
+
|
|
134
|
+
const userOnMetrics =
|
|
135
|
+
typeof handlerOptions.onMetrics === "function"
|
|
136
|
+
? (metrics: StreamMetrics) => {
|
|
137
|
+
const elapsedTime = performance.now() - startTime;
|
|
138
|
+
const formattedMetrics = {
|
|
139
|
+
route: info.route,
|
|
140
|
+
htmlSize: 0,
|
|
141
|
+
rscSize: metrics.bytes,
|
|
142
|
+
processingTime: elapsedTime,
|
|
143
|
+
chunks: metrics.chunks,
|
|
144
|
+
chunkRate: metrics.chunks / (elapsedTime / 1000),
|
|
145
|
+
memoryUsage: process.memoryUsage(),
|
|
146
|
+
streamMetrics: {
|
|
147
|
+
...metrics,
|
|
148
|
+
duration: elapsedTime,
|
|
149
|
+
},
|
|
150
|
+
htmlSizes: new Map(),
|
|
151
|
+
rscSizes: new Map([[info.route, metrics.bytes]]),
|
|
152
|
+
} satisfies RenderMetrics;
|
|
153
|
+
handlerOptions.onMetrics(formattedMetrics);
|
|
154
|
+
}
|
|
155
|
+
: () => {};
|
|
156
|
+
const startTime = performance.now();
|
|
157
|
+
if (!currentWorker) {
|
|
158
|
+
currentWorker = await restartWorker({
|
|
159
|
+
server,
|
|
160
|
+
autoDiscoveredFiles,
|
|
161
|
+
userOptions: serializedUserOptions,
|
|
162
|
+
hmrChannel,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const stream = handleWorkerRscStream({
|
|
166
|
+
worker: currentWorker!,
|
|
167
|
+
message: {
|
|
168
|
+
...serializedUserOptions,
|
|
169
|
+
id: info.route,
|
|
170
|
+
type: "RSC_RENDER",
|
|
171
|
+
// we make the worker stream aware of the route, pagePath, propsPath, rootPath, htmlPath
|
|
172
|
+
route: info.route,
|
|
173
|
+
pagePath: pagePath,
|
|
174
|
+
propsPath: propsPath,
|
|
175
|
+
rootPath: rootPath,
|
|
176
|
+
htmlPath: htmlPath,
|
|
177
|
+
// override these at all times to ensure the settings will work for the dev server
|
|
178
|
+
projectRoot: server.config.root,
|
|
179
|
+
build: {
|
|
180
|
+
...(serializedUserOptions.build || {}),
|
|
181
|
+
pages: Array.isArray(serializedUserOptions.build?.pages)
|
|
182
|
+
? serializedUserOptions.build.pages
|
|
183
|
+
: [],
|
|
184
|
+
},
|
|
185
|
+
manifest: autoDiscoveredFiles.staticManifest,
|
|
186
|
+
cssFiles: new Map(),
|
|
187
|
+
globalCss: new Map(),
|
|
190
188
|
},
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
logger,
|
|
190
|
+
handlers: {
|
|
191
|
+
onMetrics: (id, metrics) => {
|
|
192
|
+
metrics.route = id;
|
|
193
|
+
userOnMetrics(metrics);
|
|
194
|
+
},
|
|
195
|
+
onHmrAccept: () => {
|
|
196
|
+
// TODO: implement
|
|
197
|
+
// console.log("onHmrAccept", routes);
|
|
198
|
+
},
|
|
199
|
+
onHmrUpdate: () => {
|
|
200
|
+
// TODO: implement
|
|
201
|
+
// console.log("onHmrUpdate", routes);
|
|
202
|
+
},
|
|
194
203
|
},
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
204
|
+
verbose: handlerOptions.verbose,
|
|
205
|
+
rscTimeout: handlerOptions.rscTimeout,
|
|
206
|
+
});
|
|
198
207
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
208
|
+
// Pipe the stream to the response
|
|
209
|
+
if (res.writable) {
|
|
210
|
+
Readable.fromWeb(stream as unknown as ReadableStream).pipe(res);
|
|
211
|
+
}
|
|
212
|
+
// wait for timeout
|
|
213
|
+
} catch (error) {
|
|
214
|
+
logError(error, logger);
|
|
202
215
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
let timeout: NodeJS.Timeout;
|
|
217
|
+
try {
|
|
218
|
+
await new Promise((reject) => {
|
|
219
|
+
timeout = setTimeout(() => {
|
|
220
|
+
clearTimeout(timeout);
|
|
221
|
+
reject(new Error("RSC Render timeout"));
|
|
222
|
+
}, handlerOptions.rscTimeout);
|
|
208
223
|
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
id: "*",
|
|
224
|
-
} satisfies RscWorkerInputMessage);
|
|
225
|
-
await new Promise((resolve, reject) => {
|
|
226
|
-
currentWorker?.on("message", (message) => {
|
|
227
|
-
if (message.type === "SHUTDOWN_COMPLETE") {
|
|
228
|
-
resolve(true);
|
|
229
|
-
} else {
|
|
230
|
-
reject("Dit not receive SHUTDOWN_COMPLETE");
|
|
231
|
-
}
|
|
224
|
+
} catch {
|
|
225
|
+
if (currentWorker) {
|
|
226
|
+
currentWorker.postMessage({
|
|
227
|
+
type: "SHUTDOWN",
|
|
228
|
+
id: "*",
|
|
229
|
+
} satisfies RscWorkerInputMessage);
|
|
230
|
+
await new Promise((resolve, reject) => {
|
|
231
|
+
currentWorker?.on("message", (message) => {
|
|
232
|
+
if (message.type === "SHUTDOWN_COMPLETE") {
|
|
233
|
+
resolve(true);
|
|
234
|
+
} else {
|
|
235
|
+
reject("Did not receive SHUTDOWN_COMPLETE");
|
|
236
|
+
}
|
|
237
|
+
});
|
|
232
238
|
});
|
|
233
|
-
|
|
234
|
-
|
|
239
|
+
currentWorker.removeAllListeners();
|
|
240
|
+
}
|
|
241
|
+
logger.error("RSC render timeout.");
|
|
242
|
+
clearTimeout(timeout!);
|
|
243
|
+
res.end();
|
|
235
244
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
245
|
+
};
|
|
246
|
+
// attach handler to the server
|
|
247
|
+
server.middlewares.use(handler);
|
|
248
|
+
// port check, should be handled by strictPort
|
|
240
249
|
};
|
|
241
|
-
// attach handler to the server
|
|
242
|
-
server.middlewares.use(handler);
|
|
243
|
-
// port check, should be handled by strictPort
|
|
244
|
-
}
|