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
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
InputNormalizer,
|
|
5
5
|
NormalizerInput,
|
|
6
6
|
} from "../types.js";
|
|
7
|
-
import path, { join, sep } from "path";
|
|
7
|
+
import path, { join, relative, resolve, sep } from "path";
|
|
8
8
|
import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
9
9
|
|
|
10
10
|
let stashedNormalizer: InputNormalizer | null = null;
|
|
@@ -72,15 +72,17 @@ const resolveRootOption = (
|
|
|
72
72
|
|
|
73
73
|
const createKeyNormalizer =
|
|
74
74
|
({
|
|
75
|
-
root
|
|
75
|
+
root,
|
|
76
76
|
preserveModulesRoot,
|
|
77
77
|
handleExtension,
|
|
78
78
|
moduleBasePath,
|
|
79
|
+
moduleBaseURL,
|
|
79
80
|
}: {
|
|
80
81
|
root: string;
|
|
81
82
|
preserveModulesRoot: string | undefined;
|
|
82
83
|
handleExtension: (path: string) => string;
|
|
83
84
|
moduleBasePath: string | undefined;
|
|
85
|
+
moduleBaseURL: string | undefined;
|
|
84
86
|
}) =>
|
|
85
87
|
(key: string) => {
|
|
86
88
|
if (key.includes("?")) {
|
|
@@ -93,10 +95,18 @@ const createKeyNormalizer =
|
|
|
93
95
|
|
|
94
96
|
let moduleId = normalizePath(actualKey);
|
|
95
97
|
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
if
|
|
99
|
-
moduleId = moduleId
|
|
98
|
+
// Only treat as file system path if it actually contains the root path
|
|
99
|
+
// URL paths like "/" should not be resolved relative to file system root
|
|
100
|
+
if(moduleId.startsWith("/") && moduleId.startsWith(root)) {
|
|
101
|
+
moduleId = relative(root, moduleId);
|
|
102
|
+
} else if (moduleId.startsWith(".")) {
|
|
103
|
+
moduleId = relative(root, resolve(root, moduleId));
|
|
104
|
+
} else if (moduleId.startsWith("/")) {
|
|
105
|
+
// This is a URL path like "/" or "/about", remove leading slash for consistency
|
|
106
|
+
moduleId = moduleId.slice(1);
|
|
107
|
+
}
|
|
108
|
+
if(moduleBaseURL && moduleBaseURL !== "/" && moduleBaseURL !== "" && moduleId.startsWith(moduleBaseURL)) {
|
|
109
|
+
moduleId = moduleId.slice(moduleBaseURL.length);
|
|
100
110
|
}
|
|
101
111
|
if (
|
|
102
112
|
typeof moduleBasePath === "string" &&
|
|
@@ -114,10 +124,7 @@ const createKeyNormalizer =
|
|
|
114
124
|
}
|
|
115
125
|
|
|
116
126
|
moduleId = handleExtension(moduleId);
|
|
117
|
-
while (moduleId.
|
|
118
|
-
moduleId = moduleId.slice(1);
|
|
119
|
-
}
|
|
120
|
-
while (moduleId.endsWith("/")) {
|
|
127
|
+
while (moduleId.endsWith("/") || moduleId.startsWith(".")) {
|
|
121
128
|
moduleId = moduleId.slice(0, -1);
|
|
122
129
|
}
|
|
123
130
|
if (typeof preserveModulesRoot === "string" && preserveModulesRoot !== "") {
|
|
@@ -135,10 +142,12 @@ const createPathNormalizer =
|
|
|
135
142
|
root,
|
|
136
143
|
preserveModulesRoot,
|
|
137
144
|
moduleBasePath,
|
|
145
|
+
moduleBaseURL,
|
|
138
146
|
}: {
|
|
139
147
|
root: string;
|
|
140
148
|
preserveModulesRoot: string | undefined;
|
|
141
149
|
moduleBasePath: string | undefined;
|
|
150
|
+
moduleBaseURL: string | undefined;
|
|
142
151
|
}) =>
|
|
143
152
|
(path: string) => {
|
|
144
153
|
if (typeof path !== "string") {
|
|
@@ -148,8 +157,20 @@ const createPathNormalizer =
|
|
|
148
157
|
path = path.split("?")[0];
|
|
149
158
|
}
|
|
150
159
|
let normalPath = normalizePath(path);
|
|
151
|
-
|
|
152
|
-
|
|
160
|
+
|
|
161
|
+
// Only treat as file system path if it actually contains the root path
|
|
162
|
+
// URL paths like "/" should not be resolved relative to file system root
|
|
163
|
+
if(normalPath.startsWith("/") && normalPath.startsWith(root)) {
|
|
164
|
+
normalPath = relative(root, normalPath);
|
|
165
|
+
} else if (normalPath.startsWith(".")) {
|
|
166
|
+
normalPath = relative(root, normalPath);
|
|
167
|
+
} else if (normalPath.startsWith("/")) {
|
|
168
|
+
// This is a URL path like "/" or "/about", remove leading slash for consistency
|
|
169
|
+
normalPath = normalPath.slice(1);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if(moduleBaseURL && moduleBaseURL !== "/" && moduleBaseURL !== "" && normalPath.startsWith(moduleBaseURL)) {
|
|
173
|
+
normalPath = normalPath.slice(moduleBaseURL.length);
|
|
153
174
|
}
|
|
154
175
|
if (
|
|
155
176
|
typeof moduleBasePath === "string" &&
|
|
@@ -185,8 +206,9 @@ const createPathNormalizer =
|
|
|
185
206
|
export function createInputNormalizer({
|
|
186
207
|
root,
|
|
187
208
|
moduleBasePath = DEFAULT_CONFIG.MODULE_BASE_PATH,
|
|
209
|
+
moduleBaseURL = DEFAULT_CONFIG.MODULE_BASE_URL,
|
|
188
210
|
preserveModulesRoot = undefined,
|
|
189
|
-
removeExtension = DEFAULT_CONFIG.AUTO_DISCOVER.
|
|
211
|
+
removeExtension = DEFAULT_CONFIG.AUTO_DISCOVER.modulePattern,
|
|
190
212
|
}: CreateInputNormalizerProps): InputNormalizer {
|
|
191
213
|
if (stashedNormalizer) {
|
|
192
214
|
return stashedNormalizer;
|
|
@@ -198,11 +220,13 @@ export function createInputNormalizer({
|
|
|
198
220
|
preserveModulesRoot: preserveModulesRoot,
|
|
199
221
|
handleExtension,
|
|
200
222
|
moduleBasePath,
|
|
223
|
+
moduleBaseURL,
|
|
201
224
|
});
|
|
202
225
|
const normalizeEntryPath = createPathNormalizer({
|
|
203
226
|
root: root,
|
|
204
227
|
preserveModulesRoot: relativeRoot,
|
|
205
228
|
moduleBasePath,
|
|
229
|
+
moduleBaseURL,
|
|
206
230
|
});
|
|
207
231
|
function normalizeInput(id: NormalizerInput): [string, string] {
|
|
208
232
|
// Normalize both paths to use POSIX separators
|
|
@@ -241,21 +265,17 @@ export function createInputNormalizer({
|
|
|
241
265
|
|
|
242
266
|
stashedNormalizer = (input: NormalizerInput): [string, string] => {
|
|
243
267
|
const [key, path] = normalizeInput(input);
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
: path;
|
|
247
|
-
normalizedPath = normalizedPath.startsWith("/")
|
|
248
|
-
? normalizedPath.slice(1)
|
|
249
|
-
: normalizedPath;
|
|
268
|
+
|
|
269
|
+
|
|
250
270
|
const virtualPrefix = key.match(/^\0+/) ?? "";
|
|
251
271
|
// If key has virtual prefix, ensure path has it too
|
|
252
272
|
const finalPath = virtualPrefix
|
|
253
|
-
? virtualPrefix.length &&
|
|
254
|
-
?
|
|
273
|
+
? virtualPrefix.length && path.startsWith(virtualPrefix[0])
|
|
274
|
+
? path
|
|
255
275
|
: virtualPrefix.length
|
|
256
|
-
? virtualPrefix[0] +
|
|
257
|
-
:
|
|
258
|
-
:
|
|
276
|
+
? virtualPrefix[0] + path
|
|
277
|
+
: path
|
|
278
|
+
: path;
|
|
259
279
|
return [key, finalPath];
|
|
260
280
|
};
|
|
261
281
|
return stashedNormalizer;
|
|
@@ -1,64 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function createStreamMetrics(): StreamMetrics {
|
|
6
|
-
return {
|
|
7
|
-
chunks: 0,
|
|
8
|
-
bytes: 0,
|
|
9
|
-
backpressureCount: 0,
|
|
10
|
-
drainCount: 0,
|
|
11
|
-
errorCount: 0,
|
|
12
|
-
duration: 0,
|
|
13
|
-
startTime: performance.now()
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function createRenderMetrics(route: string): RenderMetrics {
|
|
18
|
-
return {
|
|
19
|
-
route,
|
|
20
|
-
htmlSize: 0,
|
|
21
|
-
rscSize: 0,
|
|
22
|
-
processingTime: 0,
|
|
23
|
-
chunks: 0,
|
|
24
|
-
chunkRate: 0,
|
|
25
|
-
memoryUsage: process.memoryUsage(),
|
|
26
|
-
streamMetrics: createStreamMetrics(),
|
|
27
|
-
htmlSizes: new Map(),
|
|
28
|
-
rscSizes: new Map(),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Creates a transform stream that collects metrics from the input stream
|
|
34
|
-
* @param stream The stream to collect metrics from
|
|
35
|
-
* @returns A promise that resolves with the metrics when the stream ends
|
|
36
|
-
*/
|
|
37
|
-
export function collectStreamMetrics(stream: PipeableStream | NodeJS.ReadableStream): Promise<StreamMetrics> {
|
|
38
|
-
const metrics = createStreamMetrics();
|
|
39
|
-
const startTime = performance.now()
|
|
40
|
-
|
|
41
|
-
return new Promise<StreamMetrics>((resolve, reject) => {
|
|
42
|
-
const transform = new Transform({
|
|
43
|
-
transform(chunk, _encoding, callback) {
|
|
44
|
-
metrics.chunks++;
|
|
45
|
-
metrics.bytes += chunk.length;
|
|
46
|
-
callback(null, chunk);
|
|
47
|
-
},
|
|
48
|
-
flush(callback) {
|
|
49
|
-
metrics.duration = Date.now() - startTime;
|
|
50
|
-
callback();
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
stream.pipe(transform);
|
|
55
|
-
|
|
56
|
-
transform.on("error", (error) => {
|
|
57
|
-
reject(error);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
transform.on("end", () => {
|
|
61
|
-
resolve(metrics);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
1
|
+
export { createStreamMetrics } from "../metrics/createStreamMetrics.js";
|
|
2
|
+
export { createRenderMetrics } from "../metrics/createRenderMetrics.js";
|
|
3
|
+
export { collectStreamMetrics } from "../metrics/collectStreamMetrics.js";
|
|
4
|
+
export type { StreamMetrics, RenderMetrics } from "../metrics/types.js";
|
|
@@ -1,9 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ResolveHookContext } from "node:module";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type ResolveFunction = (
|
|
4
|
+
specifier: string,
|
|
5
|
+
context: ResolveHookContext,
|
|
6
|
+
nextResolve?: ResolveFunction
|
|
7
|
+
) => Promise<{ url: string; shortCircuit: boolean }>;
|
|
8
|
+
|
|
9
|
+
type GetSourceHookContext = {
|
|
10
|
+
format: string;
|
|
11
|
+
url: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type GetSourceFunction = (
|
|
15
|
+
url: string,
|
|
16
|
+
context: GetSourceHookContext,
|
|
17
|
+
defaultGetSource: GetSourceFunction
|
|
18
|
+
) => Promise<{ source: string | ArrayBuffer | SharedArrayBuffer | Uint8Array }>;
|
|
19
|
+
|
|
20
|
+
let stashedResolve: ResolveFunction | null = null;
|
|
21
|
+
let stashedGetSource: GetSourceFunction | null = null;
|
|
22
|
+
|
|
23
|
+
export function setStashedResolve(resolve: ResolveFunction) {
|
|
4
24
|
stashedResolve = resolve;
|
|
5
25
|
}
|
|
6
26
|
|
|
27
|
+
export function setStashedGetSource(getSource: GetSourceFunction) {
|
|
28
|
+
stashedGetSource = getSource;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function resolve(specifier: string, context: ResolveHookContext, defaultResolve: ResolveFunction) {
|
|
32
|
+
// We stash this in case we end up needing to resolve export * statements later.
|
|
33
|
+
stashedResolve = defaultResolve;
|
|
34
|
+
|
|
35
|
+
// Add react-server condition if not present
|
|
36
|
+
if (!context.conditions.includes('react-server')) {
|
|
37
|
+
context = {
|
|
38
|
+
...context,
|
|
39
|
+
conditions: [...context.conditions, 'react-server']
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return await defaultResolve(specifier, context, defaultResolve);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function getSource(url: string, context: GetSourceHookContext, defaultGetSource: GetSourceFunction) {
|
|
47
|
+
// We stash this in case we end up needing to resolve export * statements later.
|
|
48
|
+
stashedGetSource = defaultGetSource;
|
|
49
|
+
return defaultGetSource(url, context, defaultGetSource);
|
|
50
|
+
}
|
|
51
|
+
|
|
7
52
|
export async function resolveClientImport(specifier: string, parentURL: string) {
|
|
8
53
|
const conditions = ["node", "import"];
|
|
9
54
|
|
|
@@ -13,24 +58,34 @@ export async function resolveClientImport(specifier: string, parentURL: string)
|
|
|
13
58
|
);
|
|
14
59
|
}
|
|
15
60
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
61
|
+
const result = await stashedResolve(
|
|
62
|
+
specifier,
|
|
63
|
+
{
|
|
64
|
+
conditions,
|
|
65
|
+
parentURL,
|
|
66
|
+
importAttributes: {}
|
|
67
|
+
},
|
|
68
|
+
stashedResolve
|
|
69
|
+
);
|
|
25
70
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
71
|
+
return result.url;
|
|
72
|
+
}
|
|
30
73
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
74
|
+
export async function loadClientSource(url: string) {
|
|
75
|
+
if (stashedGetSource === null) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
"Expected getSource to have been called before loadClientSource"
|
|
78
|
+
);
|
|
35
79
|
}
|
|
80
|
+
|
|
81
|
+
const result = await stashedGetSource(
|
|
82
|
+
url,
|
|
83
|
+
{
|
|
84
|
+
format: "module",
|
|
85
|
+
url
|
|
86
|
+
},
|
|
87
|
+
stashedGetSource
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return result.source;
|
|
36
91
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import type { CreateHandlerOptions } from "../types.js";
|
|
3
|
+
import { type Connect } from "vite";
|
|
4
4
|
import { MIME_TYPES } from "../config/mimeTypes.js";
|
|
5
|
+
import { requestToRoute } from "./requestToRoute.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* # Request info
|
|
@@ -9,30 +10,63 @@ import { MIME_TYPES } from "../config/mimeTypes.js";
|
|
|
9
10
|
* 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
|
*
|
|
11
12
|
* @param req
|
|
12
|
-
* @param
|
|
13
|
+
* @param handlerOptions
|
|
13
14
|
* @param hostDir
|
|
14
15
|
* @returns
|
|
15
16
|
*/
|
|
16
17
|
export function requestInfo(
|
|
17
18
|
req: Connect.IncomingMessage,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
handlerOptions: Pick<
|
|
20
|
+
CreateHandlerOptions,
|
|
21
|
+
| "normalizer"
|
|
22
|
+
| "build"
|
|
23
|
+
| "autoDiscover"
|
|
24
|
+
| "verbose"
|
|
25
|
+
| "moduleBasePath"
|
|
26
|
+
| "moduleBaseURL"
|
|
27
|
+
| "verbose"
|
|
28
|
+
| "logger"
|
|
21
29
|
>,
|
|
22
30
|
hostDir: string,
|
|
23
|
-
logger: Logger = createLogger()
|
|
24
31
|
) {
|
|
25
|
-
const
|
|
32
|
+
const route = requestToRoute(req, {
|
|
33
|
+
moduleBasePath: handlerOptions.moduleBasePath,
|
|
34
|
+
moduleBaseURL: handlerOptions.moduleBaseURL,
|
|
35
|
+
build: handlerOptions.build,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (!route) {
|
|
39
|
+
return {
|
|
40
|
+
route: "/",
|
|
41
|
+
ext: "",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Use the cleaned route for normalization, not the raw req.url
|
|
46
|
+
// This ensures base URL is properly stripped before normalization
|
|
47
|
+
const [, value] = handlerOptions.normalizer(route);
|
|
48
|
+
if (handlerOptions.verbose) {
|
|
49
|
+
if (value && value !== "") {
|
|
50
|
+
handlerOptions.logger.info(`[requestInfo] Value: \"${value}\"`);
|
|
51
|
+
}
|
|
52
|
+
if (hostDir && hostDir !== "") {
|
|
53
|
+
handlerOptions.logger.info(`[requestInfo] Host Dir: \"${hostDir}\"`);
|
|
54
|
+
}
|
|
55
|
+
if (req.url && req.url !== "") {
|
|
56
|
+
handlerOptions.logger.info(`[requestInfo] Request URL: \"${req.url}\"`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
26
60
|
const dotIndex = value.lastIndexOf(".");
|
|
27
61
|
const ext = dotIndex === -1 ? "" : value.slice(dotIndex);
|
|
28
62
|
// handle index.html
|
|
29
|
-
const isVendor =
|
|
30
|
-
const isVirtual =
|
|
31
|
-
const isJS =
|
|
32
|
-
const isHtml =
|
|
33
|
-
const isCss =
|
|
34
|
-
const isJson =
|
|
35
|
-
const isRsc =
|
|
63
|
+
const isVendor = handlerOptions.autoDiscover.vendorPattern.test(value);
|
|
64
|
+
const isVirtual = handlerOptions.autoDiscover.virtualPattern.test(value);
|
|
65
|
+
const isJS = handlerOptions.autoDiscover.modulePattern.test(value);
|
|
66
|
+
const isHtml = handlerOptions.autoDiscover.htmlPattern.test(value);
|
|
67
|
+
const isCss = handlerOptions.autoDiscover.cssPattern.test(value);
|
|
68
|
+
const isJson = handlerOptions.autoDiscover.jsonPattern.test(value);
|
|
69
|
+
const isRsc = handlerOptions.autoDiscover.rscPattern.test(value);
|
|
36
70
|
const hasJsHeader =
|
|
37
71
|
req.headers["sec-fetch-dest"] === "script" ||
|
|
38
72
|
req.headers["accept"]?.includes("*/*") ||
|
|
@@ -46,7 +80,7 @@ export function requestInfo(
|
|
|
46
80
|
req.headers["content-type"]?.includes(
|
|
47
81
|
"application/x-www-form-urlencoded"
|
|
48
82
|
) || !!req.headers["content-type"]?.includes("multipart/form-data");
|
|
49
|
-
|
|
83
|
+
|
|
50
84
|
// Server action detection
|
|
51
85
|
const hasServerActionHeaders =
|
|
52
86
|
req.method === "POST" &&
|
|
@@ -55,18 +89,23 @@ export function requestInfo(
|
|
|
55
89
|
req.headers["sec-fetch-mode"] === "cors";
|
|
56
90
|
const isServerActionRequest = hasServerActionHeaders;
|
|
57
91
|
|
|
58
|
-
const isFormActionRequest =
|
|
59
|
-
|
|
60
|
-
(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
92
|
+
const isFormActionRequest =
|
|
93
|
+
!isServerActionRequest &&
|
|
94
|
+
(req.method === "POST" ||
|
|
95
|
+
(isFormContentType &&
|
|
96
|
+
req.headers["sec-fetch-dest"] === "document" &&
|
|
97
|
+
req.headers["sec-fetch-mode"] === "navigate"));
|
|
64
98
|
|
|
65
99
|
const isJsRequest =
|
|
66
|
-
!isFormActionRequest &&
|
|
100
|
+
!isFormActionRequest &&
|
|
101
|
+
!isJson &&
|
|
102
|
+
!isHtml &&
|
|
103
|
+
!isCss &&
|
|
104
|
+
!isRsc &&
|
|
105
|
+
(isJS || hasJsHeader);
|
|
67
106
|
const isJsonRequest = isJson || (hasJsonHeader && !isJsRequest);
|
|
68
107
|
// Form action detection
|
|
69
|
-
|
|
108
|
+
|
|
70
109
|
const isHtmlRequest =
|
|
71
110
|
isHtml ||
|
|
72
111
|
hasHtmlHeader ||
|
|
@@ -84,36 +123,49 @@ export function requestInfo(
|
|
|
84
123
|
!isJsonRequest &&
|
|
85
124
|
(isCss || hasCssHeader);
|
|
86
125
|
|
|
87
|
-
|
|
126
|
+
// Use the normalized value for file path construction
|
|
127
|
+
// The normalizer should have already stripped base URLs properly
|
|
128
|
+
const routeForFilePath = value;
|
|
129
|
+
|
|
130
|
+
let filePath = resolve(hostDir, routeForFilePath);
|
|
88
131
|
let contentType;
|
|
89
132
|
if (isServerActionRequest) {
|
|
90
133
|
// For server actions, we'll get the actual file path from the request body
|
|
91
134
|
// The route is just a placeholder
|
|
92
|
-
filePath =
|
|
135
|
+
filePath = resolve(hostDir, routeForFilePath);
|
|
93
136
|
contentType = "application/json; charset=utf-8";
|
|
94
137
|
} else if (isHtmlRequest) {
|
|
95
138
|
if (!isHtml) {
|
|
96
|
-
filePath =
|
|
139
|
+
filePath = resolve(
|
|
140
|
+
hostDir,
|
|
141
|
+
routeForFilePath,
|
|
142
|
+
handlerOptions.build.htmlOutputPath
|
|
143
|
+
);
|
|
97
144
|
}
|
|
98
145
|
contentType = "text/html; charset=utf-8";
|
|
99
146
|
} else if (isRscRequest) {
|
|
100
147
|
if (!isRsc) {
|
|
101
|
-
|
|
148
|
+
// Value doesn't end with .rsc, append the rsc output path
|
|
149
|
+
filePath = resolve(
|
|
150
|
+
hostDir,
|
|
151
|
+
routeForFilePath,
|
|
152
|
+
handlerOptions.build.rscOutputPath
|
|
153
|
+
);
|
|
102
154
|
}
|
|
103
155
|
contentType = "text/x-component; charset=utf-8";
|
|
104
156
|
} else if (isCssRequest) {
|
|
105
157
|
if (!isCss) {
|
|
106
|
-
filePath =
|
|
158
|
+
filePath = resolve(hostDir, routeForFilePath + ".css");
|
|
107
159
|
}
|
|
108
160
|
contentType = "text/css; charset=utf-8";
|
|
109
161
|
} else if (isJsRequest) {
|
|
110
162
|
if (!isJS) {
|
|
111
|
-
filePath = resolve(hostDir,
|
|
163
|
+
filePath = resolve(hostDir, routeForFilePath + ".js");
|
|
112
164
|
}
|
|
113
165
|
contentType = "application/javascript; charset=utf-8";
|
|
114
166
|
} else if (isJsonRequest) {
|
|
115
167
|
if (!isJson) {
|
|
116
|
-
filePath =
|
|
168
|
+
filePath = resolve(hostDir, routeForFilePath + ".json");
|
|
117
169
|
}
|
|
118
170
|
contentType = "application/json; charset=utf-8";
|
|
119
171
|
} else {
|
|
@@ -121,49 +173,31 @@ export function requestInfo(
|
|
|
121
173
|
if (mimeType) {
|
|
122
174
|
contentType = mimeType + "; charset=utf-8";
|
|
123
175
|
} else {
|
|
124
|
-
contentType = "application/octet-stream";
|
|
176
|
+
contentType = "application/octet-stream; charset=utf-8";
|
|
125
177
|
}
|
|
126
178
|
}
|
|
127
|
-
const route = value
|
|
128
|
-
.replace(userOptions.build.rscOutputPath, "")
|
|
129
|
-
.replace(userOptions.build.htmlOutputPath, "");
|
|
130
|
-
|
|
131
|
-
const routeWithoutTrailingSlash =
|
|
132
|
-
route === "" || route === "/"
|
|
133
|
-
? "/"
|
|
134
|
-
: route.endsWith("/")
|
|
135
|
-
? route.slice(0, -1)
|
|
136
|
-
: route;
|
|
137
179
|
|
|
138
|
-
|
|
139
|
-
? "/"
|
|
140
|
-
: routeWithoutTrailingSlash.startsWith("/")
|
|
141
|
-
? routeWithoutTrailingSlash
|
|
142
|
-
: `/${routeWithoutTrailingSlash}`;
|
|
143
|
-
|
|
144
|
-
if (userOptions.verbose) {
|
|
180
|
+
if (handlerOptions.verbose) {
|
|
145
181
|
if (isFormActionRequest) {
|
|
146
|
-
logger.info(`[react-dev-server] (form-action) ${
|
|
182
|
+
handlerOptions.logger.info(`[react-dev-server] (form-action) ${route}`);
|
|
147
183
|
} else if (isServerActionRequest) {
|
|
148
|
-
logger.info(
|
|
149
|
-
`[react-dev-server] (server-action) ${routeWithLeadingSlash}`
|
|
150
|
-
);
|
|
184
|
+
handlerOptions.logger.info(`[react-dev-server] (server-action) ${route}`);
|
|
151
185
|
} else if (isHtmlRequest) {
|
|
152
|
-
logger.info(`[react-dev-server] (html) ${
|
|
186
|
+
handlerOptions.logger.info(`[react-dev-server] (html) ${route}`);
|
|
153
187
|
} else if (isRscRequest) {
|
|
154
|
-
logger.info(`[react-dev-server] (rsc) ${
|
|
188
|
+
handlerOptions.logger.info(`[react-dev-server] (rsc) ${route}`);
|
|
155
189
|
} else if (isCssRequest) {
|
|
156
|
-
logger.info(`[react-dev-server] (css) ${
|
|
190
|
+
handlerOptions.logger.info(`[react-dev-server] (css) ${route}`);
|
|
157
191
|
} else if (isJsRequest) {
|
|
158
|
-
logger.info(`[react-dev-server] (js) ${
|
|
192
|
+
handlerOptions.logger.info(`[react-dev-server] (js) ${route}`);
|
|
159
193
|
} else if (isJsonRequest) {
|
|
160
|
-
logger.info(`[react-dev-server] (json) ${
|
|
194
|
+
handlerOptions.logger.info(`[react-dev-server] (json) ${route}`);
|
|
161
195
|
} else {
|
|
162
|
-
logger.info(`[react-dev-server] (other) ${
|
|
196
|
+
handlerOptions.logger.info(`[react-dev-server] (other) ${route}`);
|
|
163
197
|
}
|
|
164
198
|
}
|
|
165
199
|
return {
|
|
166
|
-
route
|
|
200
|
+
route,
|
|
167
201
|
ext,
|
|
168
202
|
isHtmlRequest,
|
|
169
203
|
isRscRequest,
|
|
@@ -1,23 +1,49 @@
|
|
|
1
1
|
import type { CreateHandlerOptions } from "../types.js";
|
|
2
2
|
|
|
3
3
|
export function requestToRoute(
|
|
4
|
-
req: {url?: string},
|
|
5
|
-
handlerOptions: Pick<
|
|
4
|
+
req: { url?: string },
|
|
5
|
+
handlerOptions: Pick<
|
|
6
|
+
CreateHandlerOptions,
|
|
7
|
+
"moduleBasePath" | "moduleBaseURL" | "build"
|
|
8
|
+
>
|
|
6
9
|
) {
|
|
7
|
-
let route = req.url
|
|
10
|
+
let route = req.url
|
|
11
|
+
?.replace(
|
|
12
|
+
handlerOptions.moduleBaseURL + handlerOptions.build.rscOutputPath,
|
|
13
|
+
""
|
|
14
|
+
)
|
|
15
|
+
.replace(
|
|
16
|
+
handlerOptions.moduleBaseURL + handlerOptions.build.htmlOutputPath,
|
|
17
|
+
""
|
|
18
|
+
)
|
|
19
|
+
.replace(/^\/index$/, "/");
|
|
8
20
|
if (typeof route !== "string") {
|
|
9
21
|
return route;
|
|
10
22
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
) {
|
|
14
|
-
route = route.slice(handlerOptions.
|
|
23
|
+
|
|
24
|
+
// Strip moduleBaseURL from the beginning of the route
|
|
25
|
+
if (route.startsWith(handlerOptions.moduleBaseURL)) {
|
|
26
|
+
route = route.slice(handlerOptions.moduleBaseURL.length);
|
|
15
27
|
}
|
|
16
|
-
if
|
|
17
|
-
route =
|
|
28
|
+
if(route.endsWith(handlerOptions.build.rscOutputPath)) {
|
|
29
|
+
route = route.slice(0, -handlerOptions.build.rscOutputPath.length);
|
|
18
30
|
}
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
|
|
32
|
+
if (route.startsWith(handlerOptions.moduleBasePath)) {
|
|
33
|
+
route = route.slice(handlerOptions.moduleBasePath.length);
|
|
21
34
|
}
|
|
22
|
-
|
|
35
|
+
|
|
36
|
+
const routeWithoutTrailingSlash =
|
|
37
|
+
route === "" || route === "/"
|
|
38
|
+
? "/"
|
|
39
|
+
: route.endsWith("/")
|
|
40
|
+
? route.slice(0, -1)
|
|
41
|
+
: route;
|
|
42
|
+
|
|
43
|
+
const routeWithLeadingSlash = !routeWithoutTrailingSlash
|
|
44
|
+
? "/"
|
|
45
|
+
: routeWithoutTrailingSlash.startsWith("/")
|
|
46
|
+
? routeWithoutTrailingSlash
|
|
47
|
+
: `/${routeWithoutTrailingSlash}`;
|
|
48
|
+
return routeWithLeadingSlash;
|
|
23
49
|
}
|