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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { parse } from "../parse.js";
|
|
2
|
+
import { analyzeDirectives } from "./analyzeDirectives.js";
|
|
3
|
+
import { getExports } from "./getExports.js";
|
|
4
|
+
import type { ParseResult, Program } from "./types.js";
|
|
5
|
+
import type { DirectiveOptions } from "../../types.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Analyzes a module for directives and returns the parse result with directive info.
|
|
9
|
+
*/
|
|
10
|
+
export async function analyzeModule(
|
|
11
|
+
source: string,
|
|
12
|
+
options?: DirectiveOptions,
|
|
13
|
+
parseFn: (source: string) => Promise<{ ast: Program; code: string; map?: any }> = parse
|
|
14
|
+
): Promise<ParseResult> {
|
|
15
|
+
const { ast, code } = await parseFn(source);
|
|
16
|
+
|
|
17
|
+
// Collect exports from the AST first
|
|
18
|
+
const exports = await getExports(ast);
|
|
19
|
+
if(options?.verbose) {
|
|
20
|
+
if(exports.exports.size > 0) {
|
|
21
|
+
console.log('[analyzeModule] exports', Array.from(exports.exports.values()));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const directiveInfo = analyzeDirectives(ast, source, options);
|
|
26
|
+
if(options?.verbose) {
|
|
27
|
+
if(directiveInfo.warnings.length > 0) {
|
|
28
|
+
console.log('[analyzeModule] warnings', directiveInfo.warnings);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
type: 'success',
|
|
34
|
+
ast,
|
|
35
|
+
code,
|
|
36
|
+
exports,
|
|
37
|
+
directiveInfo
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnonymousClassDeclaration,
|
|
3
|
+
AnonymousFunctionDeclaration,
|
|
4
|
+
ClassDeclaration,
|
|
5
|
+
Declaration,
|
|
6
|
+
ExportSpecifier,
|
|
7
|
+
Expression,
|
|
8
|
+
FunctionDeclaration,
|
|
9
|
+
Program,
|
|
10
|
+
} from "acorn";
|
|
11
|
+
import type { ExportInfo } from "./types.js";
|
|
12
|
+
import {
|
|
13
|
+
isArrowFunctionExpression,
|
|
14
|
+
isFunctionExpression,
|
|
15
|
+
} from "./typeGuards.js";
|
|
16
|
+
import { addLocalExportedNames } from "./addLocalExportedNames.js";
|
|
17
|
+
|
|
18
|
+
function createExportInfo(
|
|
19
|
+
localName: string,
|
|
20
|
+
exportName: string,
|
|
21
|
+
type: "function" | "class" | "variable" | null,
|
|
22
|
+
range: [number, number],
|
|
23
|
+
originalModuleId?: string
|
|
24
|
+
): ExportInfo {
|
|
25
|
+
return {
|
|
26
|
+
localName,
|
|
27
|
+
exportName,
|
|
28
|
+
type,
|
|
29
|
+
range,
|
|
30
|
+
originalModuleId,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function handleTypedExport(
|
|
35
|
+
id: { name: string } | null,
|
|
36
|
+
exportName: string,
|
|
37
|
+
type: "function" | "class",
|
|
38
|
+
range: [number, number]
|
|
39
|
+
): ExportInfo {
|
|
40
|
+
return createExportInfo(
|
|
41
|
+
id?.name || "anonymous",
|
|
42
|
+
exportName,
|
|
43
|
+
type,
|
|
44
|
+
range
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function handleDefaultExport(
|
|
49
|
+
declaration:
|
|
50
|
+
| AnonymousFunctionDeclaration
|
|
51
|
+
| FunctionDeclaration
|
|
52
|
+
| AnonymousClassDeclaration
|
|
53
|
+
| ClassDeclaration
|
|
54
|
+
| Expression,
|
|
55
|
+
range: [number, number]
|
|
56
|
+
): ExportInfo | null {
|
|
57
|
+
if (declaration.type === "Identifier") {
|
|
58
|
+
return createExportInfo(declaration.name, "default", null, range);
|
|
59
|
+
} else if (declaration.type === "FunctionDeclaration") {
|
|
60
|
+
return handleTypedExport(declaration.id, "default", "function", range);
|
|
61
|
+
} else if (declaration.type === "ClassDeclaration") {
|
|
62
|
+
return handleTypedExport(declaration.id, "default", "class", range);
|
|
63
|
+
} else if (declaration.type === "ArrowFunctionExpression") {
|
|
64
|
+
return handleTypedExport(null, "default", "function", range);
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function handleNamedExport(
|
|
70
|
+
declaration: Declaration | Expression,
|
|
71
|
+
range: [number, number]
|
|
72
|
+
): ExportInfo[] {
|
|
73
|
+
const exports: ExportInfo[] = [];
|
|
74
|
+
|
|
75
|
+
if (declaration.type === "VariableDeclaration") {
|
|
76
|
+
for (const decl of declaration.declarations) {
|
|
77
|
+
if (decl.init) {
|
|
78
|
+
if (
|
|
79
|
+
isArrowFunctionExpression(decl.init) ||
|
|
80
|
+
isFunctionExpression(decl.init)
|
|
81
|
+
) {
|
|
82
|
+
if (decl.id.type === "Identifier") {
|
|
83
|
+
exports.push(handleTypedExport(decl.id, decl.id.name, "function", range));
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
addLocalExportedNames(exports, decl.id, range);
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
addLocalExportedNames(exports, decl.id, range);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} else if (declaration.type === "FunctionDeclaration" && declaration.id) {
|
|
93
|
+
exports.push(
|
|
94
|
+
handleTypedExport(declaration.id, declaration.id.name, "function", range)
|
|
95
|
+
);
|
|
96
|
+
} else if (declaration.type === "ClassDeclaration" && declaration.id) {
|
|
97
|
+
exports.push(handleTypedExport(declaration.id, declaration.id.name, "class", range));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return exports;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function handleReExports(
|
|
104
|
+
specifiers: ExportSpecifier[],
|
|
105
|
+
range: [number, number],
|
|
106
|
+
sourceModuleId?: string
|
|
107
|
+
): Promise<ExportInfo[]> {
|
|
108
|
+
const exports: ExportInfo[] = [];
|
|
109
|
+
|
|
110
|
+
for (const specifier of specifiers) {
|
|
111
|
+
if (
|
|
112
|
+
specifier.local.type === "Identifier" &&
|
|
113
|
+
specifier.exported.type === "Identifier"
|
|
114
|
+
) {
|
|
115
|
+
// For re-exports from another module, use exported name for function reference
|
|
116
|
+
// For local exports with aliases, use local name for function reference
|
|
117
|
+
const functionName = sourceModuleId ? specifier.exported.name : specifier.local.name;
|
|
118
|
+
|
|
119
|
+
exports.push(
|
|
120
|
+
createExportInfo(
|
|
121
|
+
functionName, // Function reference name
|
|
122
|
+
specifier.exported.name, // Export name
|
|
123
|
+
"function",
|
|
124
|
+
range,
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return exports;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Collects all exports from a module, including:
|
|
135
|
+
* - Named exports
|
|
136
|
+
* - Default exports
|
|
137
|
+
* - Re-exports
|
|
138
|
+
* - Object method exports
|
|
139
|
+
* - Class method exports
|
|
140
|
+
* - Export * declarations
|
|
141
|
+
*/
|
|
142
|
+
export async function collectExports(program: Program): Promise<ExportInfo[]> {
|
|
143
|
+
const exports: ExportInfo[] = [];
|
|
144
|
+
|
|
145
|
+
for (const node of program.body) {
|
|
146
|
+
switch (node.type) {
|
|
147
|
+
case "ExportDefaultDeclaration": {
|
|
148
|
+
const exportInfo = handleDefaultExport(node.declaration, [
|
|
149
|
+
node.start,
|
|
150
|
+
node.end,
|
|
151
|
+
]);
|
|
152
|
+
if (exportInfo) {
|
|
153
|
+
exports.push(exportInfo);
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
case "ExportAllDeclaration":
|
|
159
|
+
// If export * is used, the other file needs to explicitly opt into "use server" too.
|
|
160
|
+
// This matches React's loader behavior - we ignore export * declarations
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
case "ExportNamedDeclaration":
|
|
164
|
+
if (node.declaration) {
|
|
165
|
+
exports.push(
|
|
166
|
+
...handleNamedExport(node.declaration, [node.start, node.end])
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
if (node.specifiers) {
|
|
170
|
+
const sourceModuleId = node.source && typeof node.source.value === "string"
|
|
171
|
+
? node.source.value
|
|
172
|
+
: undefined;
|
|
173
|
+
const reExports = await handleReExports(node.specifiers, [node.start, node.end], sourceModuleId);
|
|
174
|
+
exports.push(...reExports);
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return exports;
|
|
181
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { parse } from "../parse.js";
|
|
2
|
+
import type { ExportInfo } from "./types.js";
|
|
3
|
+
import { getExports } from "./getExports.js";
|
|
4
|
+
import { loadClientSource } from "../../helpers/moduleResolver.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Recursively collects exports from a module that uses export *
|
|
8
|
+
*/
|
|
9
|
+
export async function collectExportsFromModule(moduleId: string): Promise<ExportInfo[]> {
|
|
10
|
+
const source = await loadClientSource(moduleId);
|
|
11
|
+
|
|
12
|
+
if (typeof source !== 'string') {
|
|
13
|
+
throw new Error('Expected source to be a string');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Use our existing parse function
|
|
17
|
+
const { ast } = await parse(source);
|
|
18
|
+
const exports = await getExports(ast);
|
|
19
|
+
|
|
20
|
+
// Set originalModuleId for local exports, preserve it for re-exports
|
|
21
|
+
return Array.from(exports.exports.values()).map(exp => ({
|
|
22
|
+
...exp,
|
|
23
|
+
originalModuleId: exp.originalModuleId || moduleId
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { DirectiveMatch, DirectiveMatches, DirectiveWarning } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export function findDirectiveMatches(
|
|
4
|
+
source: string,
|
|
5
|
+
): DirectiveMatches {
|
|
6
|
+
const matches: DirectiveMatch[] = [];
|
|
7
|
+
const warnings: DirectiveWarning[] = [];
|
|
8
|
+
|
|
9
|
+
// Find all directive matches in order
|
|
10
|
+
const serverMatches = findServerDirectives(source);
|
|
11
|
+
const clientMatches = findClientDirectives(source);
|
|
12
|
+
|
|
13
|
+
// Sort all matches by their position in the source
|
|
14
|
+
const allMatches = [...serverMatches, ...clientMatches].sort((a, b) => a.range[0] - b.range[0]);
|
|
15
|
+
|
|
16
|
+
// If no directives found, return early
|
|
17
|
+
if (allMatches.length === 0) {
|
|
18
|
+
return { matches, warnings };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Add all matches as function-level for now
|
|
22
|
+
// analyzeDirectives will determine if they're file-level
|
|
23
|
+
for (const match of allMatches) {
|
|
24
|
+
matches.push(match);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return { matches, warnings };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function findServerDirectives(source: string): DirectiveMatch[] {
|
|
31
|
+
const matches: DirectiveMatch[] = [];
|
|
32
|
+
const regex = /"use server"|'use server'/g;
|
|
33
|
+
let match;
|
|
34
|
+
|
|
35
|
+
while ((match = regex.exec(source)) !== null) {
|
|
36
|
+
matches.push({
|
|
37
|
+
type: "server",
|
|
38
|
+
range: [match.index, match.index + match[0].length]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return matches;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function findClientDirectives(source: string): DirectiveMatch[] {
|
|
46
|
+
const matches: DirectiveMatch[] = [];
|
|
47
|
+
const regex = /"use client"|'use client'/g;
|
|
48
|
+
let match;
|
|
49
|
+
|
|
50
|
+
while ((match = regex.exec(source)) !== null) {
|
|
51
|
+
matches.push({
|
|
52
|
+
type: "client",
|
|
53
|
+
range: [match.index, match.index + match[0].length]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return matches;
|
|
58
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Node, FunctionDeclaration, FunctionExpression, MethodDefinition, PropertyDefinition, VariableDeclarator, ClassBody, ClassDeclaration } from "acorn";
|
|
2
|
+
|
|
3
|
+
export function getExportedName(node: Node): string | undefined {
|
|
4
|
+
// If not in export map, try to get the name based on node type
|
|
5
|
+
if (node.type === "FunctionDeclaration") {
|
|
6
|
+
const funcDecl = node as FunctionDeclaration;
|
|
7
|
+
return funcDecl.id?.name;
|
|
8
|
+
} else if (node.type === "FunctionExpression") {
|
|
9
|
+
const funcExpr = node as FunctionExpression;
|
|
10
|
+
// For anonymous functions in default exports, use "default"
|
|
11
|
+
if (funcExpr.parent?.type === "ExportDefaultDeclaration") {
|
|
12
|
+
return "default";
|
|
13
|
+
}
|
|
14
|
+
// For other anonymous functions, try to get the name from the parent
|
|
15
|
+
if (funcExpr.parent?.type === "VariableDeclarator") {
|
|
16
|
+
const varDecl = funcExpr.parent as VariableDeclarator;
|
|
17
|
+
return varDecl.id.type === "Identifier" ? varDecl.id.name : undefined;
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
} else if (node.type === "MethodDefinition") {
|
|
21
|
+
const method = node as MethodDefinition;
|
|
22
|
+
const methodName =
|
|
23
|
+
method.key.type === "Identifier"
|
|
24
|
+
? method.key.name
|
|
25
|
+
: method.key.type === "Literal" &&
|
|
26
|
+
typeof method.key.value === "string"
|
|
27
|
+
? method.key.value
|
|
28
|
+
: undefined;
|
|
29
|
+
if (methodName) {
|
|
30
|
+
// Get the class name from the parent
|
|
31
|
+
const classBody = method.parent as ClassBody;
|
|
32
|
+
const classDecl = classBody.parent as ClassDeclaration;
|
|
33
|
+
const className = classDecl.id?.name;
|
|
34
|
+
if (className) {
|
|
35
|
+
return method.static
|
|
36
|
+
? `${className}.${methodName}`
|
|
37
|
+
: `${className}.prototype.${methodName}`;
|
|
38
|
+
}
|
|
39
|
+
return methodName;
|
|
40
|
+
}
|
|
41
|
+
} else if (node.type === "Property") {
|
|
42
|
+
const prop = node as PropertyDefinition;
|
|
43
|
+
const propName =
|
|
44
|
+
prop.key.type === "Identifier"
|
|
45
|
+
? prop.key.name
|
|
46
|
+
: prop.key.type === "Literal" && typeof prop.key.value === "string"
|
|
47
|
+
? prop.key.value
|
|
48
|
+
: undefined;
|
|
49
|
+
if (propName) {
|
|
50
|
+
// Get the full path for nested objects
|
|
51
|
+
let current = prop.parent;
|
|
52
|
+
let path = propName;
|
|
53
|
+
while (current && current.type === "Property") {
|
|
54
|
+
const parentProp = current as PropertyDefinition;
|
|
55
|
+
const parentName = parentProp.key.type === "Identifier" ? parentProp.key.name :
|
|
56
|
+
parentProp.key.type === "Literal" ? String(parentProp.key.value) : "";
|
|
57
|
+
if (parentName) {
|
|
58
|
+
path = `${parentName}.${path}`;
|
|
59
|
+
}
|
|
60
|
+
current = current.parent;
|
|
61
|
+
}
|
|
62
|
+
// If this is part of an exported object, add the export name
|
|
63
|
+
if (current?.type === "VariableDeclarator") {
|
|
64
|
+
const varDecl = current as VariableDeclarator;
|
|
65
|
+
if (varDecl.id.type === "Identifier") {
|
|
66
|
+
path = `${varDecl.id.name}.${path}`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return path;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { collectExports } from "./collectExports.js";
|
|
2
|
+
import type { ParsedExports } from "./types.js";
|
|
3
|
+
import type { Program } from "acorn";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Returns the exports from the given AST (program).
|
|
7
|
+
*/
|
|
8
|
+
export async function getExports(program: Program): Promise<ParsedExports> {
|
|
9
|
+
const exports = await collectExports(program);
|
|
10
|
+
const exportNames = exports.map(e => e.exportName);
|
|
11
|
+
const exportsMap = new Map();
|
|
12
|
+
|
|
13
|
+
for (const exp of exports) {
|
|
14
|
+
exportsMap.set(exp.exportName, {
|
|
15
|
+
localName: exp.localName,
|
|
16
|
+
exportName: exp.exportName,
|
|
17
|
+
type: exp.type,
|
|
18
|
+
range: exp.range,
|
|
19
|
+
loc: exp.loc
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
exportNames,
|
|
25
|
+
exports: exportsMap
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Node, BlockStatement } from "acorn";
|
|
2
|
+
import {
|
|
3
|
+
isFunctionDeclaration,
|
|
4
|
+
isVariableDeclaration,
|
|
5
|
+
isArrowFunctionExpression,
|
|
6
|
+
isBlockStatement,
|
|
7
|
+
isMethodDefinition,
|
|
8
|
+
isProperty,
|
|
9
|
+
isFunctionNode
|
|
10
|
+
} from "./typeGuards.js";
|
|
11
|
+
|
|
12
|
+
export function getFunctionBody(node: Node): BlockStatement | null {
|
|
13
|
+
if (isFunctionDeclaration(node)) {
|
|
14
|
+
return isBlockStatement(node.body) ? node.body : null;
|
|
15
|
+
}
|
|
16
|
+
if (isMethodDefinition(node)) {
|
|
17
|
+
return isBlockStatement(node.value.body) ? node.value.body : null;
|
|
18
|
+
}
|
|
19
|
+
if (isProperty(node) && isFunctionNode(node.value)) {
|
|
20
|
+
return isBlockStatement(node.value.body) ? node.value.body : null;
|
|
21
|
+
}
|
|
22
|
+
if (isVariableDeclaration(node)) {
|
|
23
|
+
const init = node.declarations[0]?.init;
|
|
24
|
+
if (init && isArrowFunctionExpression(init)) {
|
|
25
|
+
return isBlockStatement(init.body) ? init.body : null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (isFunctionNode(node)) {
|
|
29
|
+
return isBlockStatement(node.body) ? node.body : null;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Node } from "acorn";
|
|
2
|
+
import { getQualifiedName } from "./getQualifiedName.js";
|
|
3
|
+
import {
|
|
4
|
+
isNodeWithParent,
|
|
5
|
+
isVariableDeclarator,
|
|
6
|
+
isIdentifier,
|
|
7
|
+
isMethodDefinition,
|
|
8
|
+
isArrowFunctionExpression,
|
|
9
|
+
isFunctionExpression,
|
|
10
|
+
isFunctionDeclaration,
|
|
11
|
+
isProperty
|
|
12
|
+
} from "./typeGuards.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the local name of a function node.
|
|
16
|
+
* For function declarations: returns the function's id name
|
|
17
|
+
* For methods: returns the method's key name
|
|
18
|
+
* For variable declarations: returns the variable's id name
|
|
19
|
+
* For anonymous functions: returns the qualified local name
|
|
20
|
+
*/
|
|
21
|
+
export function getFunctionName(node: Node): string {
|
|
22
|
+
// For function declarations, use the function name
|
|
23
|
+
if (isFunctionDeclaration(node) && node.id) {
|
|
24
|
+
return node.id.name;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// For function expressions and arrow functions, try to get the name from the parent
|
|
28
|
+
if ((isFunctionExpression(node) || isArrowFunctionExpression(node)) && isNodeWithParent(node)) {
|
|
29
|
+
const parent = node.parent;
|
|
30
|
+
|
|
31
|
+
// If parent is a variable declarator, use the variable name
|
|
32
|
+
if (isVariableDeclarator(parent) && isIdentifier(parent.id)) {
|
|
33
|
+
return parent.id.name;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// If parent is a method definition, use the method name
|
|
37
|
+
if (isMethodDefinition(parent) && isIdentifier(parent.key)) {
|
|
38
|
+
return parent.key.name;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// If parent is a property, use the property name
|
|
42
|
+
if (isProperty(parent) && isIdentifier(parent.key)) {
|
|
43
|
+
return parent.key.name;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// For anonymous functions, try to get a name from the parent
|
|
48
|
+
if (isNodeWithParent(node)) {
|
|
49
|
+
const parent = node.parent;
|
|
50
|
+
|
|
51
|
+
// If parent is a variable declarator, use the variable name
|
|
52
|
+
if (isVariableDeclarator(parent) && isIdentifier(parent.id)) {
|
|
53
|
+
return parent.id.name;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// If parent is a method definition, use the method name
|
|
57
|
+
if (isMethodDefinition(parent) && isIdentifier(parent.key)) {
|
|
58
|
+
return parent.key.name;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// If parent is a property, use the property name
|
|
62
|
+
if (isProperty(parent) && isIdentifier(parent.key)) {
|
|
63
|
+
return parent.key.name;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// If we can't find a name, try to get a qualified name
|
|
68
|
+
const qualifiedName = getQualifiedName(node);
|
|
69
|
+
return qualifiedName || "anonymous";
|
|
70
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Node } from "acorn";
|
|
2
|
+
import {
|
|
3
|
+
isFunctionDeclaration,
|
|
4
|
+
isMethodDefinition,
|
|
5
|
+
isVariableDeclarator,
|
|
6
|
+
isClassDeclaration,
|
|
7
|
+
isObjectExpression,
|
|
8
|
+
isIdentifier,
|
|
9
|
+
isClassBody,
|
|
10
|
+
isNodeWithParent,
|
|
11
|
+
isFunctionNode,
|
|
12
|
+
isExportNamedDeclaration,
|
|
13
|
+
isExportDefaultDeclaration
|
|
14
|
+
} from "./typeGuards.js";
|
|
15
|
+
|
|
16
|
+
export function getQualifiedName(node: Node): string {
|
|
17
|
+
const parts: string[] = [];
|
|
18
|
+
let current: Node | undefined = node;
|
|
19
|
+
|
|
20
|
+
while (current) {
|
|
21
|
+
if (isFunctionDeclaration(current)) {
|
|
22
|
+
if (current.id) {
|
|
23
|
+
parts.unshift(current.id.name);
|
|
24
|
+
} else if (isNodeWithParent(current) && current.parent) {
|
|
25
|
+
// For anonymous function declarations, try to find a name from the parent
|
|
26
|
+
if (isExportNamedDeclaration(current.parent)) {
|
|
27
|
+
parts.unshift("default");
|
|
28
|
+
} else if (isExportDefaultDeclaration(current.parent)) {
|
|
29
|
+
parts.unshift("default");
|
|
30
|
+
} else if (isVariableDeclarator(current.parent) && isIdentifier(current.parent.id)) {
|
|
31
|
+
parts.unshift(current.parent.id.name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (isMethodDefinition(current)) {
|
|
37
|
+
parts.unshift(current.key.type === "Identifier" ? current.key.name : "method");
|
|
38
|
+
// Look for the containing object/class name
|
|
39
|
+
if (isNodeWithParent(current) && current.parent) {
|
|
40
|
+
if (isClassBody(current.parent)) {
|
|
41
|
+
const classDecl = current.parent.parent;
|
|
42
|
+
if (classDecl && isClassDeclaration(classDecl) && classDecl.id) {
|
|
43
|
+
parts.unshift(classDecl.id.name);
|
|
44
|
+
}
|
|
45
|
+
} else if (isObjectExpression(current.parent)) {
|
|
46
|
+
// For object methods, try to find the variable name
|
|
47
|
+
let objNode: Node = current.parent;
|
|
48
|
+
while (isNodeWithParent(objNode) && objNode.parent) {
|
|
49
|
+
if (isVariableDeclarator(objNode.parent) && isIdentifier(objNode.parent.id)) {
|
|
50
|
+
parts.unshift(objNode.parent.id.name);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
objNode = objNode.parent;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
if (isVariableDeclarator(current) && isIdentifier(current.id)) {
|
|
60
|
+
parts.unshift(current.id.name);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
if (isFunctionNode(current)) {
|
|
64
|
+
// For anonymous functions, try to find a name from the parent
|
|
65
|
+
if (isNodeWithParent(current) && current.parent) {
|
|
66
|
+
if (isVariableDeclarator(current.parent) && isIdentifier(current.parent.id)) {
|
|
67
|
+
parts.unshift(current.parent.id.name);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
current = isNodeWithParent(current) ? current.parent : undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return parts.length > 0 ? parts.join(".") : "anonymous";
|
|
76
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./addLocalExportedNames.js";
|
|
2
|
+
export * from "./getExports.js";
|
|
3
|
+
export * from "./collectExportsFromModule.js";
|
|
4
|
+
export * from "./analyzeDirectives.js";
|
|
5
|
+
export * from "./analyzeModule.js";
|
|
6
|
+
export * from "./collectExports.js";
|
|
7
|
+
export * from "./getFunctionBody.js";
|
|
8
|
+
export * from "./getFunctionName.js";
|
|
9
|
+
export * from "./getQualifiedName.js";
|
|
10
|
+
export * from "./processFunctionNode.js";
|
|
11
|
+
export * from "./typeGuards.js";
|
|
12
|
+
export * from "./utils.js";
|
|
13
|
+
export * from "./types.js";
|