vite-plugin-react-server 1.1.19 → 1.2.0-alpha.0
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 +102 -395
- package/dist/_virtual/dynamic-import-helper.js +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -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 +199 -121
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +155 -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.map +1 -1
- package/dist/plugin/config/resolveEnv.js +14 -4
- 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 +228 -206
- 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 +86 -40
- 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 +111 -93
- 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 +47 -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 -4
- 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 +48 -14
- 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 +70 -7
- 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 +5 -2
- 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 +28 -1
- package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
- package/dist/plugin/helpers/requestInfo.js +43 -30
- 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 +137 -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 +97 -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 +11 -0
- package/dist/plugin/loader/directives/analyzeModule.d.ts.map +1 -0
- package/dist/plugin/loader/directives/analyzeModule.js +34 -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 +11 -0
- package/dist/plugin/loader/env-loader.d.ts.map +1 -0
- package/dist/plugin/loader/env-loader.js +65 -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 +11 -2
- package/dist/plugin/loader/parse.d.ts.map +1 -1
- package/dist/plugin/loader/parse.js +29 -6
- 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 +10 -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 +33 -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/transformServerModule.d.ts +11 -0
- package/dist/plugin/loader/transformServerModule.d.ts.map +1 -0
- package/dist/plugin/loader/transformServerModule.js +84 -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 +18 -0
- package/dist/plugin/loader/types.d.ts +59 -12
- 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 +30 -17
- 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 +7 -4
- package/dist/plugin/preserver/plugin.d.ts +2 -2
- package/dist/plugin/preserver/plugin.d.ts.map +1 -1
- package/dist/plugin/preserver/plugin.js +33 -29
- 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 +25 -14
- 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 +59 -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 +12 -10
- 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 +98 -43
- 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 +14 -17
- 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 +38 -31
- 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 +33 -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.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 +43 -44
- 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 +452 -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.js +1 -1
- package/dist/plugin/utils/index.d.ts +1 -0
- package/dist/plugin/utils/index.d.ts.map +1 -1
- package/dist/plugin/utils/index.js +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 +4 -3
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +54 -32
- 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 +16 -4
- package/dist/plugin/worker/rsc/rsc-worker.development.js +77 -11
- package/dist/plugin/worker/rsc/rsc-worker.production.js +1 -1
- 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 +58 -25
- 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 +184 -95
- 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 +5 -10
- package/plugin/config/resolveOptions.ts +415 -299
- 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 +417 -351
- package/plugin/env/plugin.ts +71 -7
- 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 +45 -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 +41 -20
- package/plugin/helpers/createEventHandler.ts +1 -1
- package/plugin/helpers/createHandler.ts +40 -12
- package/plugin/helpers/createRscStream.tsx +97 -35
- package/plugin/helpers/formatMetrics.ts +2 -37
- package/plugin/helpers/getBundleManifest.ts +10 -1
- package/plugin/helpers/getRouteFiles.ts +112 -8
- package/plugin/helpers/handleServerAction.ts +10 -6
- 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 +72 -52
- package/plugin/helpers/requestToRoute.ts +38 -12
- package/plugin/helpers/resolveComponent.ts +173 -0
- package/plugin/helpers/resolveComponents.ts +185 -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 +118 -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 +39 -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.development.ts → env-loader.ts} +8 -22
- package/plugin/loader/index.ts +8 -6
- package/plugin/loader/parse.ts +42 -12
- package/plugin/loader/react-loader.ts +255 -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 +64 -0
- package/plugin/loader/transformModule.ts +54 -0
- package/plugin/loader/transformModuleIfNeeded.ts +40 -40
- package/plugin/loader/transformServerModule.ts +136 -0
- package/plugin/loader/transformWithAcornLoose.ts +27 -0
- package/plugin/loader/types.ts +65 -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 +39 -15
- package/plugin/plugin.server.ts +39 -18
- package/plugin/preserver/plugin.ts +42 -42
- package/plugin/react-client/cleanupWorkerServerAction.ts +33 -0
- package/plugin/react-client/configureWorkerRequestHandler.ts +212 -201
- package/plugin/react-client/createMessageHandlers.ts +17 -3
- package/plugin/react-client/createWorkerStream.ts +55 -51
- package/plugin/react-client/handleWorkerRscStream.ts +141 -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 +75 -70
- package/plugin/react-server/configureReactServer.ts +200 -142
- package/plugin/react-server/handleServerAction.ts +156 -160
- package/plugin/react-server/plugin.ts +18 -25
- package/plugin/react-static/collectHtmlWorkerContent.ts +109 -102
- package/plugin/react-static/collectRscContent.ts +55 -51
- package/plugin/react-static/configurePreviewServer.ts +110 -100
- package/plugin/react-static/createBuildLoader.ts +157 -48
- package/plugin/react-static/plugin.ts +368 -357
- package/plugin/react-static/renderPage.ts +43 -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.server.ts +55 -82
- 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 +685 -309
- package/plugin/utils/createCallServer.ts +5 -5
- package/plugin/utils/createReactFetcher.ts +4 -6
- package/plugin/utils/index.ts +2 -1
- package/plugin/utils/routeToURL.ts +34 -0
- package/plugin/utils/urls.ts +9 -6
- 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 +76 -39
- package/plugin/worker/rsc/handlers.ts +30 -22
- package/plugin/worker/rsc/index.ts +2 -0
- package/plugin/worker/rsc/messageHandler.tsx +17 -10
- package/plugin/worker/rsc/rsc-worker.development.ts +104 -17
- 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 -431
- 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/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/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.client.d.ts +0 -2
- package/dist/plugin/transformer/plugin.client.d.ts.map +0 -1
- 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/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 -596
- package/plugin/source-map/createMappingsSerializer.ts +0 -181
- package/plugin/source-map/readMappings.ts +0 -194
- package/plugin/transformer/plugin.client.ts +0 -0
- /package/dist/plugin/{transformer/plugin.client.js → loader/directives/types.js} +0 -0
|
@@ -1,6 +1,257 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
ResolvedUserOptions,
|
|
3
|
+
SerializedResolvedConfig,
|
|
4
|
+
SerializedUserOptions,
|
|
5
|
+
} from "../types.js";
|
|
6
|
+
import type { ModuleInfo } from "rollup";
|
|
7
|
+
import { MessagePort } from "node:worker_threads";
|
|
8
|
+
import type {
|
|
9
|
+
InitializedReactLoaderMessage,
|
|
10
|
+
ServerModuleMessage,
|
|
11
|
+
} from "../worker/rsc/types.js";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { hydrateUserOptions } from "../helpers/hydrateUserOptions.js";
|
|
15
|
+
import { DEFAULT_LOADER_CONFIG } from "../config/defaults.js";
|
|
16
|
+
import type { LoadHook, ResolveHook } from "node:module";
|
|
17
|
+
import type { RawSourceMap } from "source-map";
|
|
18
|
+
import { createTransformer } from "./createTransformer.js";
|
|
19
|
+
import { getNodeEnv } from "../getNodeEnv.js";
|
|
2
20
|
|
|
3
|
-
|
|
4
|
-
|
|
21
|
+
export type LoaderOptions = {
|
|
22
|
+
id: string;
|
|
23
|
+
resolveDependencies?: boolean;
|
|
24
|
+
format?: string;
|
|
25
|
+
conditions?: string[];
|
|
26
|
+
importAssertions?: Record<string, unknown>;
|
|
27
|
+
importAttributes?: Record<string, unknown>;
|
|
28
|
+
source: string;
|
|
29
|
+
};
|
|
5
30
|
|
|
6
|
-
export
|
|
31
|
+
export type LoaderFunction = (options: LoaderOptions) => Promise<ModuleInfo>;
|
|
32
|
+
|
|
33
|
+
let initialized = false;
|
|
34
|
+
let userOptions: ResolvedUserOptions;
|
|
35
|
+
let loaderPort: MessagePort | undefined;
|
|
36
|
+
let isServerFunction:
|
|
37
|
+
| RegExpMatchArray
|
|
38
|
+
| RegExp
|
|
39
|
+
| ((source: string, url: string) => boolean)
|
|
40
|
+
| null = DEFAULT_LOADER_CONFIG.isServerFunctionCode;
|
|
41
|
+
|
|
42
|
+
let isClientComponent:
|
|
43
|
+
| RegExpMatchArray
|
|
44
|
+
| RegExp
|
|
45
|
+
| ((source: string, url: string) => boolean)
|
|
46
|
+
| null = DEFAULT_LOADER_CONFIG.isClientComponentCode;
|
|
47
|
+
|
|
48
|
+
let transformer: (
|
|
49
|
+
source: string,
|
|
50
|
+
moduleId: string
|
|
51
|
+
) => Promise<{ code: string; map: RawSourceMap | null }>;
|
|
52
|
+
|
|
53
|
+
export function initialize(
|
|
54
|
+
data: {
|
|
55
|
+
id: string;
|
|
56
|
+
port: MessagePort;
|
|
57
|
+
userOptions: SerializedUserOptions | null;
|
|
58
|
+
resolvedConfig: SerializedResolvedConfig | null;
|
|
59
|
+
} = {
|
|
60
|
+
id: "react-loader",
|
|
61
|
+
port: new MessagePort(),
|
|
62
|
+
userOptions: null,
|
|
63
|
+
resolvedConfig: null,
|
|
64
|
+
}
|
|
65
|
+
) {
|
|
66
|
+
if (userOptions?.verbose) {
|
|
67
|
+
console.log("[react-loader] Initializing with options:", data.id);
|
|
68
|
+
}
|
|
69
|
+
loaderPort = data.port;
|
|
70
|
+
if (data.userOptions) {
|
|
71
|
+
// when user options are provided, use the user options using the hydrateUserOptions function
|
|
72
|
+
const resolvedUserOptions = hydrateUserOptions(data.userOptions);
|
|
73
|
+
if (resolvedUserOptions.type === "error") {
|
|
74
|
+
throw new Error(resolvedUserOptions.error.message);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Use the hydrated user options directly (includes recreated functions)
|
|
78
|
+
userOptions = resolvedUserOptions.userOptions;
|
|
79
|
+
|
|
80
|
+
isServerFunction = userOptions.loader.isServerFunctionCode;
|
|
81
|
+
isClientComponent = userOptions.loader.isClientComponentCode;
|
|
82
|
+
transformer = createTransformer({
|
|
83
|
+
options: userOptions,
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
// when no user options are provided, use the default loader config
|
|
87
|
+
transformer = createTransformer({
|
|
88
|
+
options: {
|
|
89
|
+
loader: {
|
|
90
|
+
...DEFAULT_LOADER_CONFIG,
|
|
91
|
+
mode: getNodeEnv(),
|
|
92
|
+
},
|
|
93
|
+
verbose: false,
|
|
94
|
+
panicThreshold: "none",
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (!initialized && loaderPort) {
|
|
99
|
+
loaderPort.postMessage({
|
|
100
|
+
type: "INITIALIZED_REACT_LOADER",
|
|
101
|
+
id: data.id,
|
|
102
|
+
} satisfies InitializedReactLoaderMessage);
|
|
103
|
+
}
|
|
104
|
+
initialized = true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const load: LoadHook = async (url, context, nextLoad) => {
|
|
108
|
+
if (!initialized) {
|
|
109
|
+
initialize(context as never);
|
|
110
|
+
}
|
|
111
|
+
if (userOptions?.verbose) {
|
|
112
|
+
console.log("[react-loader] Attempting to load:", url);
|
|
113
|
+
console.log("[react-loader] Context:", {
|
|
114
|
+
format: context.format,
|
|
115
|
+
conditions: context.conditions,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const { format } = context;
|
|
120
|
+
if (format === "module" || format === "module-typescript") {
|
|
121
|
+
if (userOptions?.verbose) {
|
|
122
|
+
console.log("[react-loader] Loading module:", url);
|
|
123
|
+
}
|
|
124
|
+
const result = await nextLoad(url, context);
|
|
125
|
+
if (userOptions?.verbose) {
|
|
126
|
+
console.log("[react-loader] Next load result:", {
|
|
127
|
+
format: result.format,
|
|
128
|
+
shortCircuit: result.shortCircuit,
|
|
129
|
+
source: typeof result.source,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const source =
|
|
134
|
+
typeof result.source === "string"
|
|
135
|
+
? result.source
|
|
136
|
+
: result.source instanceof Uint8Array
|
|
137
|
+
? new TextDecoder().decode(result.source)
|
|
138
|
+
: String(result.source);
|
|
139
|
+
|
|
140
|
+
// Check for file-level server directive first
|
|
141
|
+
const hasFileLevelServerDirective =
|
|
142
|
+
source.startsWith('"use server"') || source.startsWith("'use server'");
|
|
143
|
+
const hasFileLevelClientDirective =
|
|
144
|
+
source.startsWith('"use client"') || source.startsWith("'use client'");
|
|
145
|
+
|
|
146
|
+
const isServer =
|
|
147
|
+
hasFileLevelServerDirective ||
|
|
148
|
+
(typeof isServerFunction === "function"
|
|
149
|
+
? isServerFunction(source, url)
|
|
150
|
+
: false);
|
|
151
|
+
|
|
152
|
+
const isClient =
|
|
153
|
+
hasFileLevelClientDirective ||
|
|
154
|
+
(typeof isClientComponent === "function"
|
|
155
|
+
? isClientComponent(source, url)
|
|
156
|
+
: false);
|
|
157
|
+
|
|
158
|
+
if (userOptions?.verbose) {
|
|
159
|
+
let startPreviewIndex = 0;
|
|
160
|
+
let startLine = 0;
|
|
161
|
+
let lines = source.split("\n");
|
|
162
|
+
while (
|
|
163
|
+
lines[startLine].trim() === "" || lines[startLine].trim() === "\r" ||
|
|
164
|
+
// comment lines
|
|
165
|
+
lines[startLine].trim().startsWith("//")
|
|
166
|
+
|| lines[startLine].trim().startsWith("/**")
|
|
167
|
+
|| lines[startLine].trim().startsWith("*")
|
|
168
|
+
) {
|
|
169
|
+
startPreviewIndex += lines[startLine].length;
|
|
170
|
+
startLine++;
|
|
171
|
+
}
|
|
172
|
+
console.log("[react-loader] Module analysis:", {
|
|
173
|
+
url,
|
|
174
|
+
isServer,
|
|
175
|
+
isClient,
|
|
176
|
+
hasFileLevelServerDirective,
|
|
177
|
+
hasFileLevelClientDirective,
|
|
178
|
+
sourceLength: source.length,
|
|
179
|
+
sourcePreview: source.slice(startPreviewIndex, startPreviewIndex + 100) + "...",
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (!isServer && !isClient) {
|
|
184
|
+
if (userOptions?.verbose) {
|
|
185
|
+
console.log(
|
|
186
|
+
"[react-loader] Skipping non-server/non-client module:",
|
|
187
|
+
url
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Handle file URLs
|
|
194
|
+
const filePath = url.startsWith("file://") ? fileURLToPath(url) : url;
|
|
195
|
+
if (userOptions?.verbose) {
|
|
196
|
+
console.log("[react-loader] File path:", filePath);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Normalize the URL using the same logic as plugin.server.ts
|
|
200
|
+
let moduleID = filePath;
|
|
201
|
+
let finalID = filePath;
|
|
202
|
+
if (userOptions?.normalizer) {
|
|
203
|
+
const [, value] = userOptions.normalizer(filePath);
|
|
204
|
+
moduleID = join(userOptions.moduleBasePath, value);
|
|
205
|
+
finalID = userOptions.moduleID?.(moduleID) || moduleID;
|
|
206
|
+
if (userOptions?.verbose) {
|
|
207
|
+
console.log("[react-loader] Normalized IDs:", { moduleID, finalID });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const { code: transformed, map } = await transformer(source, finalID);
|
|
212
|
+
|
|
213
|
+
if (userOptions?.verbose) {
|
|
214
|
+
console.log("[react-loader] Transformation result:", {
|
|
215
|
+
originalLength: source.length,
|
|
216
|
+
transformedLength: transformed.length,
|
|
217
|
+
wasTransformed: source !== transformed,
|
|
218
|
+
hasSourceMap: !!map,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (loaderPort) {
|
|
223
|
+
if (userOptions?.verbose) {
|
|
224
|
+
console.log("[react-loader] Sending SERVER_MODULE message");
|
|
225
|
+
}
|
|
226
|
+
loaderPort.postMessage({
|
|
227
|
+
type: "SERVER_MODULE",
|
|
228
|
+
id: finalID,
|
|
229
|
+
url: filePath,
|
|
230
|
+
source: transformed,
|
|
231
|
+
} satisfies ServerModuleMessage);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
...result,
|
|
236
|
+
source: transformed,
|
|
237
|
+
map,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (userOptions?.verbose) {
|
|
242
|
+
console.log("[react-loader] Skipping non-module format:", format);
|
|
243
|
+
}
|
|
244
|
+
return nextLoad(url, context);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export const resolve: ResolveHook = async (specifier, context, nextResolve) => {
|
|
248
|
+
if (userOptions?.verbose) {
|
|
249
|
+
console.log("[react-loader] Resolving:", specifier);
|
|
250
|
+
console.log("[react-loader] Resolve context:", context);
|
|
251
|
+
}
|
|
252
|
+
const result = await nextResolve(specifier, context);
|
|
253
|
+
if (userOptions?.verbose) {
|
|
254
|
+
console.log("[react-loader] Resolve result:", result);
|
|
255
|
+
}
|
|
256
|
+
return result;
|
|
257
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { removeRanges } from "./removeRanges.js";
|
|
2
|
+
|
|
3
|
+
export function removeDirectives(source: string, directiveRanges: Array<{ start: number; end: number }>): string {
|
|
4
|
+
// Sort ranges by start position
|
|
5
|
+
const sortedRanges = directiveRanges.toSorted((a, b) => a.start - b.start);
|
|
6
|
+
|
|
7
|
+
// Remove ranges from source
|
|
8
|
+
if (sortedRanges.length === 0) {
|
|
9
|
+
return source;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Remove directives from source using the provided ranges
|
|
13
|
+
return removeRanges(source, sortedRanges);
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
export function removeRanges(
|
|
3
|
+
source: string,
|
|
4
|
+
ranges: { start: number; end: number }[]
|
|
5
|
+
): string {
|
|
6
|
+
if (!ranges.length) {
|
|
7
|
+
return source;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Sort ranges by start position
|
|
11
|
+
ranges.sort((a, b) => a.start - b.start);
|
|
12
|
+
|
|
13
|
+
// Remove ranges from end to start to avoid position shifts
|
|
14
|
+
let result = source;
|
|
15
|
+
for (let i = ranges.length - 1; i >= 0; i--) {
|
|
16
|
+
const { start, end } = ranges[i];
|
|
17
|
+
result = result.slice(0, start) + result.slice(end);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
@@ -1,118 +1,208 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { SourceMap } from "../types/sourceMap.js";
|
|
3
|
-
import { basename } from "path";
|
|
1
|
+
import type { RawSourceMap } from "source-map";
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
4
|
+
* Source map handling utilities
|
|
7
5
|
*/
|
|
8
|
-
export function createBasicSourceMap(url: string, source: string): SourceMap {
|
|
9
|
-
const createMapping = createMappingsSerializer();
|
|
10
|
-
let mappings = '';
|
|
11
|
-
let lineCount = 1;
|
|
12
|
-
let idx = -1;
|
|
13
|
-
|
|
14
|
-
// Map each line with VLQ encoding
|
|
15
|
-
while ((idx = source.indexOf('\n', idx + 1)) !== -1) {
|
|
16
|
-
createMapping(lineCount, 0, 0, lineCount, 0, -1);
|
|
17
|
-
lineCount++;
|
|
18
|
-
}
|
|
19
|
-
// Add final line
|
|
20
|
-
createMapping(lineCount, 0, 0, lineCount, 0, -1);
|
|
21
6
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
sourcesContent: [source],
|
|
27
|
-
mappings,
|
|
28
|
-
sourceRoot: '',
|
|
29
|
-
names: []
|
|
30
|
-
};
|
|
7
|
+
interface RangeToRemove {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
lineShift: number;
|
|
31
11
|
}
|
|
32
12
|
|
|
33
13
|
/**
|
|
34
|
-
*
|
|
14
|
+
* Creates a source map for the given source code
|
|
35
15
|
*/
|
|
36
|
-
export function
|
|
16
|
+
export function createSourceMap(
|
|
17
|
+
code: string,
|
|
18
|
+
originalSource: string,
|
|
19
|
+
moduleId: string,
|
|
20
|
+
rangesToRemove: RangeToRemove[] = []
|
|
21
|
+
): RawSourceMap {
|
|
22
|
+
// Split code into lines for line-by-line mapping
|
|
23
|
+
const codeLines = code.split("\n");
|
|
24
|
+
const originalLines = originalSource.split("\n");
|
|
25
|
+
|
|
26
|
+
// Track current positions in both original and transformed code
|
|
27
|
+
let currentColumn = 0;
|
|
28
|
+
let sourceLine = 0;
|
|
29
|
+
let sourceColumn = 0;
|
|
30
|
+
const lastSourceIndex = 0;
|
|
31
|
+
const lastNameIndex = -1;
|
|
32
|
+
|
|
33
|
+
// Generate mappings line by line
|
|
34
|
+
const mappings: string[] = [];
|
|
37
35
|
const createMapping = createMappingsSerializer();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
|
|
37
|
+
// First, create a mapping for each line in the original source
|
|
38
|
+
for (let i = 0; i < originalLines.length; i++) {
|
|
39
|
+
const mapping = createMapping(
|
|
40
|
+
i + 1, // generated line
|
|
41
|
+
0, // generated column
|
|
42
|
+
0, // source index
|
|
43
|
+
i + 1, // original line
|
|
44
|
+
0, // original column
|
|
45
|
+
-1 // name index
|
|
46
|
+
);
|
|
47
|
+
mappings.push(mapping);
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
// Then, create mappings for the transformed code
|
|
51
|
+
for (let i = 0; i < codeLines.length; i++) {
|
|
52
|
+
// Check if this line contains any ranges to remove
|
|
53
|
+
const lineRanges = rangesToRemove.filter((range) => {
|
|
54
|
+
const rangeStartLine = originalSource.slice(0, range.start).split("\n").length - 1;
|
|
55
|
+
const rangeEndLine = originalSource.slice(0, range.end).split("\n").length - 1;
|
|
56
|
+
return rangeStartLine <= sourceLine && rangeEndLine >= sourceLine;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (lineRanges.length > 0) {
|
|
60
|
+
// For lines with directives, map to the original line including the directive
|
|
61
|
+
// but skip the directive range in the generated code
|
|
62
|
+
const mapping = createMapping(
|
|
63
|
+
i + 1, // generated line
|
|
64
|
+
currentColumn, // generated column
|
|
65
|
+
lastSourceIndex, // source index
|
|
66
|
+
sourceLine + 1 + (lineRanges[0].lineShift || 0), // original line with shift
|
|
67
|
+
sourceColumn, // original column
|
|
68
|
+
lastNameIndex // name index
|
|
69
|
+
);
|
|
70
|
+
mappings.push(mapping);
|
|
71
|
+
|
|
72
|
+
// Skip the directive range in the generated code
|
|
73
|
+
const directiveRange = lineRanges[0];
|
|
74
|
+
const directiveLength = directiveRange.end - directiveRange.start;
|
|
75
|
+
currentColumn += directiveLength;
|
|
76
|
+
} else {
|
|
77
|
+
// For regular lines, map to the original line
|
|
78
|
+
const mapping = createMapping(
|
|
79
|
+
i + 1, // generated line
|
|
80
|
+
currentColumn, // generated column
|
|
81
|
+
lastSourceIndex, // source index
|
|
82
|
+
sourceLine + 1, // original line
|
|
83
|
+
sourceColumn, // original column
|
|
84
|
+
lastNameIndex // name index
|
|
85
|
+
);
|
|
86
|
+
mappings.push(mapping);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Update positions
|
|
90
|
+
currentColumn = 0;
|
|
91
|
+
sourceLine++;
|
|
92
|
+
sourceColumn = 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Join mappings with semicolons, ensuring empty lines are preserved
|
|
96
|
+
const mappingsString = mappings.join(";");
|
|
97
|
+
|
|
46
98
|
return {
|
|
47
|
-
...sourceMap,
|
|
48
99
|
version: 3,
|
|
49
|
-
|
|
50
|
-
|
|
100
|
+
file: moduleId,
|
|
101
|
+
sources: [moduleId],
|
|
102
|
+
names: [],
|
|
103
|
+
mappings: mappingsString,
|
|
104
|
+
sourceRoot: "",
|
|
105
|
+
sourcesContent: [originalSource], // Keep the original source with directives
|
|
51
106
|
};
|
|
52
107
|
}
|
|
53
108
|
|
|
54
109
|
/**
|
|
55
|
-
*
|
|
110
|
+
* Creates a function that generates VLQ mappings for source maps
|
|
56
111
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
112
|
+
function createMappingsSerializer() {
|
|
113
|
+
return function createMapping(
|
|
114
|
+
_generatedLine: number,
|
|
115
|
+
generatedColumn: number,
|
|
116
|
+
sourceIndex: number,
|
|
117
|
+
originalLine: number,
|
|
118
|
+
originalColumn: number,
|
|
119
|
+
nameIndex: number
|
|
120
|
+
): string {
|
|
121
|
+
const values = [
|
|
122
|
+
generatedColumn,
|
|
123
|
+
sourceIndex,
|
|
124
|
+
originalLine,
|
|
125
|
+
originalColumn,
|
|
126
|
+
nameIndex,
|
|
127
|
+
];
|
|
128
|
+
return encodeVLQ(values);
|
|
62
129
|
};
|
|
63
|
-
return source + '\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
|
|
64
|
-
Buffer.from(JSON.stringify(serializedMap)).toString('base64');
|
|
65
130
|
}
|
|
66
131
|
|
|
67
132
|
/**
|
|
68
|
-
*
|
|
133
|
+
* Encodes a series of integers into a VLQ string
|
|
69
134
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
135
|
+
function encodeVLQ(values: number[]): string {
|
|
136
|
+
const VLQ_BASE_SHIFT = 5;
|
|
137
|
+
const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
138
|
+
const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
139
|
+
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
140
|
+
|
|
141
|
+
let result = "";
|
|
142
|
+
|
|
143
|
+
for (let i = 0; i < values.length; i++) {
|
|
144
|
+
let value = values[i];
|
|
145
|
+
|
|
146
|
+
// Handle negative values
|
|
147
|
+
if (value < 0) {
|
|
148
|
+
value = (-value << 1) | 1;
|
|
149
|
+
} else {
|
|
150
|
+
value = value << 1;
|
|
87
151
|
}
|
|
152
|
+
|
|
153
|
+
// Encode the value
|
|
154
|
+
do {
|
|
155
|
+
let digit = value & VLQ_BASE_MASK;
|
|
156
|
+
value >>>= VLQ_BASE_SHIFT;
|
|
157
|
+
|
|
158
|
+
if (value !== 0) {
|
|
159
|
+
digit |= VLQ_CONTINUATION_BIT;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
result += encodeBase64Digit(digit);
|
|
163
|
+
} while (value !== 0);
|
|
88
164
|
}
|
|
89
165
|
|
|
90
|
-
return
|
|
166
|
+
return result;
|
|
91
167
|
}
|
|
92
168
|
|
|
93
169
|
/**
|
|
94
|
-
*
|
|
170
|
+
* Encodes a single digit into base64
|
|
95
171
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return source.slice(0, sourceMapInfo.start) +
|
|
101
|
-
'\n'.repeat(sourceMapInfo.lines) +
|
|
102
|
-
source.slice(sourceMapInfo.end);
|
|
172
|
+
function encodeBase64Digit(digit: number): string {
|
|
173
|
+
const BASE64_CHARS =
|
|
174
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
175
|
+
return BASE64_CHARS[digit];
|
|
103
176
|
}
|
|
104
177
|
|
|
105
178
|
/**
|
|
106
|
-
*
|
|
179
|
+
* Strips the source map URL from the source string
|
|
107
180
|
*/
|
|
108
|
-
export function
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
181
|
+
export function stripSourceMap(source: string): string {
|
|
182
|
+
return source.replace(
|
|
183
|
+
/\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,[A-Za-z0-9+/=]+$/m,
|
|
184
|
+
""
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Adds a source map URL to the source string
|
|
190
|
+
*/
|
|
191
|
+
export function addSourceMap(source: string, map: RawSourceMap): string {
|
|
192
|
+
const sourceMapString = JSON.stringify(map);
|
|
193
|
+
const sourceMapBase64 = Buffer.from(sourceMapString).toString("base64");
|
|
194
|
+
return `${source}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${sourceMapBase64}`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Parses a source map URL from a source string
|
|
199
|
+
*/
|
|
200
|
+
export function parseSourceMapUrl(source: string): string | null {
|
|
201
|
+
const match = source.match(
|
|
202
|
+
/\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([A-Za-z0-9+/=]+)$/m
|
|
203
|
+
);
|
|
204
|
+
if (!match) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
return match[1];
|
|
208
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ParseResult } from "./directives/types.js";
|
|
2
|
+
import type { ResolvedUserOptions } from "../types.js";
|
|
3
|
+
import { createSourceMap } from "./sourceMap.js";
|
|
4
|
+
import type { TransformResult } from "./types.js";
|
|
5
|
+
import { getNodeEnv } from "../getNodeEnv.js";
|
|
6
|
+
import { DEFAULT_CONFIG } from "../config/defaults.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Transforms a client module by:
|
|
10
|
+
* 1. Removing all original code including imports and directives
|
|
11
|
+
* 2. Registering client components with registerClientReference
|
|
12
|
+
*/
|
|
13
|
+
export async function transformClientModule(
|
|
14
|
+
source: string,
|
|
15
|
+
moduleId: string,
|
|
16
|
+
parseResult: ParseResult,
|
|
17
|
+
loader: Pick<
|
|
18
|
+
ResolvedUserOptions["loader"],
|
|
19
|
+
"registerClientReferenceName" | "importClientPath"
|
|
20
|
+
> = DEFAULT_CONFIG.RSC_LOADER[getNodeEnv()],
|
|
21
|
+
verbose = false
|
|
22
|
+
): Promise<TransformResult> {
|
|
23
|
+
if (!loader) {
|
|
24
|
+
loader = DEFAULT_CONFIG.RSC_LOADER[getNodeEnv()];
|
|
25
|
+
}
|
|
26
|
+
if (parseResult.type !== "success") {
|
|
27
|
+
return { code: "", map: null };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (verbose) {
|
|
31
|
+
console.log(
|
|
32
|
+
`[transformClientModule] Transforming client module: ${moduleId}`
|
|
33
|
+
);
|
|
34
|
+
console.log("Found exports:", parseResult.exports);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Register all exports as client references
|
|
38
|
+
const registrations = [];
|
|
39
|
+
for (const exp of parseResult.exports.exports.values()) {
|
|
40
|
+
if (exp.type === "function" || exp.type === "class") {
|
|
41
|
+
if (verbose) {
|
|
42
|
+
console.log("Found export info:", exp, "for localName:", exp.localName);
|
|
43
|
+
}
|
|
44
|
+
registrations.push(
|
|
45
|
+
`export const ${exp.exportName} = ${loader.registerClientReferenceName}(function() { throw new Error("Attempted to call ${exp.exportName}() on the client"); }, "${moduleId}", "${exp.exportName}");`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const finalCode = `
|
|
51
|
+
import { ${loader.registerClientReferenceName} } from "${
|
|
52
|
+
loader.importClientPath
|
|
53
|
+
}";
|
|
54
|
+
${registrations.join("\n")}
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
// Create source map
|
|
58
|
+
const map = createSourceMap(finalCode, source, moduleId);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
code: finalCode,
|
|
62
|
+
map,
|
|
63
|
+
};
|
|
64
|
+
}
|