vite-plugin-react-server 1.2.0-alpha.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +211 -51
- package/dist/client.d.ts +4 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -10
- package/dist/package.json +102 -27
- package/dist/plugin/bundle/bundles.d.ts +11 -0
- package/dist/plugin/bundle/bundles.d.ts.map +1 -0
- package/dist/plugin/bundle/bundles.js +11 -0
- package/dist/plugin/bundle/deferredStaticGeneration.d.ts +31 -0
- package/dist/plugin/bundle/deferredStaticGeneration.d.ts.map +1 -0
- package/dist/plugin/bundle/deferredStaticGeneration.js +44 -0
- package/dist/plugin/bundle/manifests.d.ts +20 -0
- package/dist/plugin/bundle/manifests.d.ts.map +1 -0
- package/dist/plugin/bundle/manifests.js +54 -0
- package/dist/plugin/components/css.d.ts +2 -5
- package/dist/plugin/components/css.d.ts.map +1 -1
- package/dist/plugin/components/css.js +7 -9
- package/dist/plugin/components/html.d.ts +2 -3
- package/dist/plugin/components/html.d.ts.map +1 -1
- package/dist/plugin/components/html.js +3 -3
- package/dist/plugin/components/index.d.ts +1 -1
- package/dist/plugin/components/index.d.ts.map +1 -1
- package/dist/plugin/components/root.d.ts.map +1 -1
- package/dist/plugin/components/root.js +4 -4
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +6 -6
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +6 -5
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +34 -51
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +5 -1
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js +124 -52
- package/dist/plugin/config/createHandlerOptions.client.d.ts +4 -0
- package/dist/plugin/config/createHandlerOptions.client.d.ts.map +1 -0
- package/dist/plugin/config/createHandlerOptions.client.js +293 -0
- package/dist/plugin/config/createHandlerOptions.d.ts +4 -0
- package/dist/plugin/config/createHandlerOptions.d.ts.map +1 -0
- package/dist/plugin/config/createHandlerOptions.js +13 -0
- package/dist/plugin/config/createHandlerOptions.server.d.ts +4 -0
- package/dist/plugin/config/createHandlerOptions.server.d.ts.map +1 -0
- package/dist/plugin/config/createHandlerOptions.server.js +344 -0
- package/dist/plugin/config/createHandlerOptions.types.d.ts +114 -0
- package/dist/plugin/config/createHandlerOptions.types.d.ts.map +1 -0
- package/dist/plugin/config/createModuleID.d.ts +1 -1
- package/dist/plugin/config/createModuleID.d.ts.map +1 -1
- package/dist/plugin/config/createModuleID.js +121 -8
- package/dist/plugin/config/defaults.d.ts +46 -6
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +54 -11
- package/dist/plugin/config/envPrefixFromConfig.d.ts +3 -0
- package/dist/plugin/config/envPrefixFromConfig.d.ts.map +1 -0
- package/dist/plugin/config/envPrefixFromConfig.js +8 -0
- package/dist/plugin/config/getCondition.d.ts +54 -3
- package/dist/plugin/config/getCondition.d.ts.map +1 -1
- package/dist/plugin/config/getCondition.js +158 -6
- package/dist/plugin/{getNodeEnv.d.ts → config/getNodeEnv.d.ts} +1 -1
- package/dist/plugin/config/getNodeEnv.d.ts.map +1 -0
- package/dist/plugin/config/getNodeEnv.js +17 -0
- package/dist/plugin/config/index.d.ts +43 -1
- package/dist/plugin/config/index.d.ts.map +1 -1
- package/dist/plugin/config/index.js +9 -4
- package/dist/plugin/config/resolveDirectiveMatcher.d.ts +6 -6
- package/dist/plugin/config/resolveDirectiveMatcher.d.ts.map +1 -1
- package/dist/plugin/config/resolveDirectiveMatcher.js +7 -23
- package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
- package/dist/plugin/config/resolveEnv.js +3 -6
- package/dist/plugin/config/resolveOptions.d.ts +3 -2
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +188 -43
- package/dist/plugin/config/resolvePages.d.ts +1 -1
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js +1 -1
- package/dist/plugin/config/resolvePatternWithValues.d.ts.map +1 -1
- package/dist/plugin/config/resolvePatternWithValues.js +7 -26
- package/dist/plugin/config/resolveUrlOption.d.ts +1 -1
- package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -1
- package/dist/plugin/config/resolveUrlOption.js +2 -2
- package/dist/plugin/config/resolveUserConfig.d.ts +5 -3
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +221 -75
- package/dist/plugin/config/stashedOptionsState.d.ts +66 -0
- package/dist/plugin/config/stashedOptionsState.d.ts.map +1 -0
- package/dist/plugin/config/stashedOptionsState.js +25 -0
- package/dist/plugin/dev-server/cleanupServerAction.client.d.ts +6 -0
- package/dist/plugin/dev-server/cleanupServerAction.client.d.ts.map +1 -0
- package/dist/plugin/dev-server/cleanupServerAction.client.js +28 -0
- package/dist/plugin/dev-server/cleanupServerAction.d.ts +2 -0
- package/dist/plugin/dev-server/cleanupServerAction.d.ts.map +1 -0
- package/dist/plugin/dev-server/cleanupServerAction.js +4 -0
- package/dist/plugin/dev-server/cleanupServerAction.server.d.ts +8 -0
- package/dist/plugin/dev-server/cleanupServerAction.server.d.ts.map +1 -0
- package/dist/plugin/dev-server/cleanupServerAction.server.js +15 -0
- package/dist/plugin/dev-server/configureReactServer.client.d.ts +7 -0
- package/dist/plugin/dev-server/configureReactServer.client.d.ts.map +1 -0
- package/dist/plugin/dev-server/configureReactServer.client.js +85 -0
- package/dist/plugin/dev-server/configureReactServer.d.ts +2 -0
- package/dist/plugin/dev-server/configureReactServer.d.ts.map +1 -0
- package/dist/plugin/dev-server/configureReactServer.js +13 -0
- package/dist/plugin/dev-server/configureReactServer.server.d.ts +3 -0
- package/dist/plugin/dev-server/configureReactServer.server.d.ts.map +1 -0
- package/dist/plugin/dev-server/configureReactServer.server.js +444 -0
- package/dist/plugin/dev-server/configureRequestHandler.client.d.ts +13 -0
- package/dist/plugin/dev-server/configureRequestHandler.client.d.ts.map +1 -0
- package/dist/plugin/dev-server/configureRequestHandler.client.js +307 -0
- package/dist/plugin/dev-server/configureRequestHandler.d.ts +2 -0
- package/dist/plugin/dev-server/configureRequestHandler.d.ts.map +1 -0
- package/dist/plugin/dev-server/configureRequestHandler.js +4 -0
- package/dist/plugin/dev-server/configureRequestHandler.server.d.ts +6 -0
- package/dist/plugin/dev-server/configureRequestHandler.server.d.ts.map +1 -0
- package/dist/plugin/dev-server/configureRequestHandler.server.js +44 -0
- package/dist/plugin/dev-server/handleServerAction.client.d.ts +11 -0
- package/dist/plugin/dev-server/handleServerAction.client.d.ts.map +1 -0
- package/dist/plugin/dev-server/handleServerAction.client.js +97 -0
- package/dist/plugin/dev-server/handleServerAction.d.ts +2 -0
- package/dist/plugin/dev-server/handleServerAction.d.ts.map +1 -0
- package/dist/plugin/dev-server/handleServerAction.js +13 -0
- package/dist/plugin/dev-server/handleServerAction.server.d.ts +3 -0
- package/dist/plugin/dev-server/handleServerAction.server.d.ts.map +1 -0
- package/dist/plugin/dev-server/handleServerAction.server.js +15 -0
- package/dist/plugin/dev-server/index.client.d.ts +7 -0
- package/dist/plugin/dev-server/index.client.d.ts.map +1 -0
- package/dist/plugin/dev-server/index.client.js +11 -0
- package/dist/plugin/dev-server/index.d.ts +4 -0
- package/dist/plugin/dev-server/index.d.ts.map +1 -0
- package/dist/plugin/dev-server/index.js +19 -0
- package/dist/plugin/dev-server/index.server.d.ts +7 -0
- package/dist/plugin/dev-server/index.server.d.ts.map +1 -0
- package/dist/plugin/dev-server/index.server.js +11 -0
- package/dist/plugin/dev-server/plugin.client.d.ts +7 -0
- package/dist/plugin/dev-server/plugin.client.d.ts.map +1 -0
- package/dist/plugin/dev-server/plugin.client.js +122 -0
- package/dist/plugin/dev-server/plugin.server.d.ts +8 -0
- package/dist/plugin/dev-server/plugin.server.d.ts.map +1 -0
- package/dist/plugin/dev-server/plugin.server.js +108 -0
- package/dist/plugin/dev-server/restartWorker.client.d.ts +3 -0
- package/dist/plugin/dev-server/restartWorker.client.d.ts.map +1 -0
- package/dist/plugin/dev-server/restartWorker.client.js +131 -0
- package/dist/plugin/dev-server/restartWorker.d.ts +2 -0
- package/dist/plugin/dev-server/restartWorker.d.ts.map +1 -0
- package/dist/plugin/dev-server/restartWorker.js +4 -0
- package/dist/plugin/dev-server/restartWorker.server.d.ts +3 -0
- package/dist/plugin/dev-server/restartWorker.server.d.ts.map +1 -0
- package/dist/plugin/dev-server/restartWorker.server.js +88 -0
- package/dist/plugin/dev-server/types.d.ts +38 -0
- package/dist/plugin/dev-server/types.d.ts.map +1 -0
- package/dist/plugin/dev-server/virtualRscHmrPlugin.d.ts +7 -0
- package/dist/plugin/dev-server/virtualRscHmrPlugin.d.ts.map +1 -0
- package/dist/plugin/dev-server/virtualRscHmrPlugin.js +80 -0
- package/dist/plugin/env/createConfigEnv.d.ts +7 -1
- package/dist/plugin/env/createConfigEnv.d.ts.map +1 -1
- package/dist/plugin/env/createConfigEnv.js +18 -5
- package/dist/plugin/env/createEnvPlugin.d.ts +3 -0
- package/dist/plugin/env/createEnvPlugin.d.ts.map +1 -0
- package/dist/plugin/env/createEnvPlugin.js +59 -0
- package/dist/plugin/env/getArgValue.js +47 -27
- package/dist/plugin/env/getEnvKey.d.ts +6 -0
- package/dist/plugin/env/getEnvKey.d.ts.map +1 -1
- package/dist/plugin/env/getEnvKey.js +11 -3
- package/dist/plugin/env/index.d.ts +2 -0
- package/dist/plugin/env/index.d.ts.map +1 -1
- package/dist/plugin/env/index.js +4 -0
- package/dist/plugin/env/plugin.client.d.ts +2 -0
- package/dist/plugin/env/plugin.client.d.ts.map +1 -0
- package/dist/plugin/env/plugin.client.js +2 -0
- package/dist/plugin/env/plugin.d.ts +4 -34
- package/dist/plugin/env/plugin.d.ts.map +1 -1
- package/dist/plugin/env/plugin.js +31 -64
- package/dist/plugin/env/plugin.server.d.ts +2 -0
- package/dist/plugin/env/plugin.server.d.ts.map +1 -0
- package/dist/plugin/env/plugin.server.js +2 -0
- package/dist/plugin/env/userConfigEnv.js +9 -18
- package/dist/plugin/environments/createBuildEventPlugin.d.ts +4 -0
- package/dist/plugin/environments/createBuildEventPlugin.d.ts.map +1 -0
- package/dist/plugin/environments/createBuildEventPlugin.js +100 -0
- package/dist/plugin/environments/createEnvironmentPlugin.d.ts +19 -0
- package/dist/plugin/environments/createEnvironmentPlugin.d.ts.map +1 -0
- package/dist/plugin/environments/createEnvironmentPlugin.js +257 -0
- package/dist/plugin/environments/hashCoordination.d.ts +14 -0
- package/dist/plugin/environments/hashCoordination.d.ts.map +1 -0
- package/dist/plugin/environments/hashCoordination.js +35 -0
- package/dist/plugin/environments/resolveEnvironmentConfig.d.ts +41 -0
- package/dist/plugin/environments/resolveEnvironmentConfig.d.ts.map +1 -0
- package/dist/plugin/environments/resolveEnvironmentConfig.js +232 -0
- package/dist/plugin/error/assertPanic.d.ts +2 -0
- package/dist/plugin/error/assertPanic.d.ts.map +1 -0
- package/dist/plugin/error/assertPanic.js +15 -0
- package/dist/plugin/error/handleError.d.ts +9 -0
- package/dist/plugin/error/handleError.d.ts.map +1 -0
- package/dist/plugin/error/handleError.js +51 -0
- package/dist/plugin/error/index.d.ts +3 -0
- package/dist/plugin/error/index.d.ts.map +1 -1
- package/dist/plugin/error/index.js +4 -1
- package/dist/plugin/error/logError.d.ts +6 -2
- package/dist/plugin/error/logError.d.ts.map +1 -1
- package/dist/plugin/error/logError.js +34 -36
- package/dist/plugin/error/panicThresholdHandler.d.ts +27 -0
- package/dist/plugin/error/panicThresholdHandler.d.ts.map +1 -0
- package/dist/plugin/error/panicThresholdHandler.js +13 -0
- package/dist/plugin/error/serializeError.d.ts +6 -2
- package/dist/plugin/error/serializeError.d.ts.map +1 -1
- package/dist/plugin/error/serializeError.js +30 -10
- package/dist/plugin/error/serializeErrorInfo.d.ts +5 -0
- package/dist/plugin/error/serializeErrorInfo.d.ts.map +1 -0
- package/dist/plugin/error/serializeErrorInfo.js +19 -0
- package/dist/plugin/error/setupGlobalErrorHandler.d.ts +4 -0
- package/dist/plugin/error/setupGlobalErrorHandler.d.ts.map +1 -0
- package/dist/plugin/error/setupGlobalErrorHandler.js +52 -0
- package/dist/plugin/error/shouldPanic.d.ts +6 -0
- package/dist/plugin/error/shouldPanic.d.ts.map +1 -0
- package/dist/plugin/error/shouldPanic.js +15 -0
- package/dist/plugin/error/toError.d.ts +5 -1
- package/dist/plugin/error/toError.d.ts.map +1 -1
- package/dist/plugin/error/toError.js +43 -19
- package/dist/plugin/error/types.d.ts +28 -0
- package/dist/plugin/error/types.d.ts.map +1 -0
- package/dist/plugin/error/types.js +1 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectManifestCss.js +19 -5
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +3 -3
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +64 -3
- package/dist/plugin/helpers/createBufferedRscStream.d.ts +52 -0
- package/dist/plugin/helpers/createBufferedRscStream.d.ts.map +1 -0
- package/dist/plugin/helpers/createBufferedRscStream.js +147 -0
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
- package/dist/plugin/helpers/createCssProps.js +15 -14
- package/dist/plugin/helpers/createElementWithReact.d.ts +9 -0
- package/dist/plugin/helpers/createElementWithReact.d.ts.map +1 -0
- package/dist/plugin/helpers/createElementWithReact.js +87 -0
- package/dist/plugin/helpers/createPatternMatcher.d.ts +24 -0
- package/dist/plugin/helpers/createPatternMatcher.d.ts.map +1 -0
- package/dist/plugin/helpers/createPatternMatcher.js +50 -0
- package/dist/plugin/helpers/createRscRenderHelpers.d.ts +16 -0
- package/dist/plugin/helpers/createRscRenderHelpers.d.ts.map +1 -0
- package/dist/plugin/helpers/createRscRenderHelpers.js +60 -0
- package/dist/plugin/helpers/createSafePageComponent.d.ts +36 -0
- package/dist/plugin/helpers/createSafePageComponent.d.ts.map +1 -0
- package/dist/plugin/helpers/createSafePageComponent.js +50 -0
- package/dist/plugin/helpers/createSerializableHandlerOptions.d.ts +60 -0
- package/dist/plugin/helpers/createSerializableHandlerOptions.d.ts.map +1 -0
- package/dist/plugin/helpers/createSerializableHandlerOptions.js +94 -0
- package/dist/plugin/helpers/createSharedLoader.d.ts +44 -0
- package/dist/plugin/helpers/createSharedLoader.d.ts.map +1 -0
- package/dist/plugin/helpers/createSharedLoader.js +137 -0
- package/dist/plugin/helpers/createUnifiedCssProcessor.d.ts +70 -0
- package/dist/plugin/helpers/createUnifiedCssProcessor.d.ts.map +1 -0
- package/dist/plugin/helpers/createUnifiedCssProcessor.js +89 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +2 -3
- package/dist/plugin/helpers/getRouteFiles.d.ts +1 -1
- package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -1
- package/dist/plugin/helpers/getRouteFiles.js +43 -41
- package/dist/plugin/helpers/handleServerAction.client.d.ts +29 -0
- package/dist/plugin/helpers/handleServerAction.client.d.ts.map +1 -0
- package/dist/plugin/helpers/handleServerAction.client.js +93 -0
- package/dist/plugin/helpers/handleServerAction.d.ts +2 -34
- package/dist/plugin/helpers/handleServerAction.d.ts.map +1 -1
- package/dist/plugin/helpers/handleServerAction.js +15 -45
- package/dist/plugin/helpers/handleServerAction.server.d.ts +25 -0
- package/dist/plugin/helpers/handleServerAction.server.d.ts.map +1 -0
- package/dist/plugin/helpers/handleServerAction.server.js +80 -0
- package/dist/plugin/helpers/handleServerActionHelper.d.ts +61 -0
- package/dist/plugin/helpers/handleServerActionHelper.d.ts.map +1 -0
- package/dist/plugin/helpers/handleServerActionHelper.js +183 -0
- package/dist/plugin/helpers/headlessStreamReuseHandler.d.ts +12 -0
- package/dist/plugin/helpers/headlessStreamReuseHandler.d.ts.map +1 -0
- package/dist/plugin/helpers/headlessStreamReuseHandler.js +29 -0
- package/dist/plugin/helpers/headlessStreamState.d.ts +71 -0
- package/dist/plugin/helpers/headlessStreamState.d.ts.map +1 -0
- package/dist/plugin/helpers/headlessStreamState.js +81 -0
- package/dist/plugin/helpers/hydrateUserOptions.d.ts +1 -1
- package/dist/plugin/helpers/hydrateUserOptions.d.ts.map +1 -1
- package/dist/plugin/helpers/hydrateUserOptions.js +2 -2
- package/dist/plugin/helpers/index.d.ts +12 -5
- package/dist/plugin/helpers/index.d.ts.map +1 -1
- package/dist/plugin/helpers/index.js +18 -4
- package/dist/plugin/helpers/logRenderStart.d.ts +17 -0
- package/dist/plugin/helpers/logRenderStart.d.ts.map +1 -0
- package/dist/plugin/helpers/logRenderStart.js +13 -0
- package/dist/plugin/helpers/mergeMessageWithDefaults.d.ts +90 -0
- package/dist/plugin/helpers/mergeMessageWithDefaults.d.ts.map +1 -0
- package/dist/plugin/helpers/mergeMessageWithDefaults.js +67 -0
- package/dist/plugin/helpers/pipeToResponse.d.ts +19 -0
- package/dist/plugin/helpers/pipeToResponse.d.ts.map +1 -0
- package/dist/plugin/helpers/pipeToResponse.js +55 -0
- package/dist/plugin/helpers/requestInfo.d.ts +2 -0
- package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
- package/dist/plugin/helpers/requestInfo.js +6 -2
- package/dist/plugin/helpers/resolveComponents.client.d.ts +34 -0
- package/dist/plugin/helpers/resolveComponents.client.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveComponents.client.js +126 -0
- package/dist/plugin/helpers/resolveModuleFromManifest.d.ts +36 -0
- package/dist/plugin/helpers/resolveModuleFromManifest.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveModuleFromManifest.js +60 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +23 -2
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.js +150 -9
- package/dist/plugin/helpers/resolveRenderUrl.d.ts +11 -0
- package/dist/plugin/helpers/resolveRenderUrl.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveRenderUrl.js +19 -0
- package/dist/plugin/helpers/resolveStreamElements.client.d.ts +14 -0
- package/dist/plugin/helpers/resolveStreamElements.client.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveStreamElements.client.js +36 -0
- package/dist/plugin/helpers/resolveStreamElements.d.ts +3 -0
- package/dist/plugin/helpers/resolveStreamElements.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveStreamElements.js +13 -0
- package/dist/plugin/helpers/resolveStreamElements.server.d.ts +15 -0
- package/dist/plugin/helpers/resolveStreamElements.server.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveStreamElements.server.js +35 -0
- package/dist/plugin/helpers/resolveStreamElements.types.d.ts +22 -0
- package/dist/plugin/helpers/resolveStreamElements.types.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveStreamElements.types.js +1 -0
- package/dist/plugin/helpers/resolveVirtualAndNodeModules.d.ts +15 -0
- package/dist/plugin/helpers/resolveVirtualAndNodeModules.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveVirtualAndNodeModules.js +45 -0
- package/dist/plugin/helpers/resolveWithDefaultRootAndHtml.d.ts +18 -0
- package/dist/plugin/helpers/resolveWithDefaultRootAndHtml.d.ts.map +1 -0
- package/dist/plugin/helpers/resolveWithDefaultRootAndHtml.js +17 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts +2 -2
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
- package/dist/plugin/helpers/serializeUserOptions.js +28 -13
- package/dist/plugin/helpers/tryManifest.d.ts +2 -2
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +12 -6
- package/dist/plugin/helpers/validateRscRenderMessage.d.ts +9 -0
- package/dist/plugin/helpers/validateRscRenderMessage.d.ts.map +1 -0
- package/dist/plugin/helpers/validateRscRenderMessage.js +13 -0
- package/dist/plugin/helpers/workerCleanup.d.ts +29 -0
- package/dist/plugin/helpers/workerCleanup.d.ts.map +1 -0
- package/dist/plugin/helpers/workerCleanup.js +28 -0
- package/dist/plugin/helpers/workerManager.d.ts +5 -0
- package/dist/plugin/helpers/workerManager.d.ts.map +1 -0
- package/dist/plugin/helpers/workerManager.js +18 -0
- package/dist/plugin/index.d.ts +4 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +5 -2
- package/dist/plugin/loader/createDefaultLoader.d.ts +1 -1
- package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createDefaultLoader.js +2 -22
- package/dist/plugin/loader/createTransformer.d.ts.map +1 -1
- package/dist/plugin/loader/createTransformer.js +155 -25
- package/dist/plugin/loader/directives/analyzeDirectives.d.ts +3 -2
- package/dist/plugin/loader/directives/analyzeDirectives.d.ts.map +1 -1
- package/dist/plugin/loader/directives/analyzeDirectives.js +53 -26
- package/dist/plugin/loader/directives/analyzeModule.d.ts.map +1 -1
- package/dist/plugin/loader/directives/analyzeModule.js +16 -9
- package/dist/plugin/loader/env-loader.js +2 -2
- package/dist/plugin/loader/react-loader.d.ts +4 -4
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +101 -73
- package/dist/plugin/loader/transformClientModule.d.ts +3 -3
- package/dist/plugin/loader/transformClientModule.d.ts.map +1 -1
- package/dist/plugin/loader/transformClientModule.js +63 -18
- package/dist/plugin/loader/transformModule.d.ts.map +1 -1
- package/dist/plugin/loader/transformModule.js +80 -16
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts +6 -1
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -1
- package/dist/plugin/loader/transformModuleIfNeeded.js +10 -18
- package/dist/plugin/loader/transformNonServerEnvironment.d.ts +1 -1
- package/dist/plugin/loader/transformNonServerEnvironment.d.ts.map +1 -1
- package/dist/plugin/loader/transformNonServerEnvironment.js +14 -12
- package/dist/plugin/loader/transformServerModule.d.ts +1 -1
- package/dist/plugin/loader/transformServerModule.d.ts.map +1 -1
- package/dist/plugin/loader/transformServerModule.js +54 -15
- package/dist/plugin/loader/types.d.ts +24 -7
- package/dist/plugin/loader/types.d.ts.map +1 -1
- package/dist/plugin/metrics/collectStreamMetrics.d.ts +1 -2
- package/dist/plugin/metrics/collectStreamMetrics.d.ts.map +1 -1
- package/dist/plugin/metrics/collectStreamMetrics.js +1 -1
- package/dist/plugin/metrics/convertStreamMetrics.d.ts +3 -0
- package/dist/plugin/metrics/convertStreamMetrics.d.ts.map +1 -0
- package/dist/plugin/metrics/convertStreamMetrics.js +26 -0
- package/dist/plugin/metrics/createModuleResolutionMetrics.d.ts +12 -0
- package/dist/plugin/metrics/createModuleResolutionMetrics.d.ts.map +1 -0
- package/dist/plugin/metrics/createModuleResolutionMetrics.js +32 -0
- package/dist/plugin/metrics/createRenderMetrics.d.ts +2 -2
- package/dist/plugin/metrics/createRenderMetrics.d.ts.map +1 -1
- package/dist/plugin/metrics/createRenderMetrics.js +45 -13
- package/dist/plugin/metrics/createStreamMetrics.d.ts +2 -2
- package/dist/plugin/metrics/createStreamMetrics.d.ts.map +1 -1
- package/dist/plugin/metrics/createStreamMetrics.js +15 -4
- package/dist/plugin/metrics/createWorkerStartupMetrics.d.ts +12 -0
- package/dist/plugin/metrics/createWorkerStartupMetrics.d.ts.map +1 -0
- package/dist/plugin/metrics/createWorkerStartupMetrics.js +14 -0
- package/dist/plugin/metrics/formatMetrics.d.ts +0 -6
- package/dist/plugin/metrics/formatMetrics.d.ts.map +1 -1
- package/dist/plugin/metrics/formatMetrics.js +7 -29
- package/dist/plugin/metrics/index.d.ts +6 -3
- package/dist/plugin/metrics/index.d.ts.map +1 -1
- package/dist/plugin/metrics/index.js +6 -3
- package/dist/plugin/metrics/metricWatcher.d.ts +9 -0
- package/dist/plugin/metrics/metricWatcher.d.ts.map +1 -0
- package/dist/plugin/metrics/metricWatcher.js +141 -0
- package/dist/plugin/metrics/types.d.ts +72 -6
- package/dist/plugin/metrics/types.d.ts.map +1 -1
- package/dist/plugin/orchestrator/createPluginOrchestrator.client.d.ts +3 -0
- package/dist/plugin/orchestrator/createPluginOrchestrator.client.d.ts.map +1 -0
- package/dist/plugin/orchestrator/createPluginOrchestrator.client.js +36 -0
- package/dist/plugin/orchestrator/createPluginOrchestrator.d.ts +19 -0
- package/dist/plugin/orchestrator/createPluginOrchestrator.d.ts.map +1 -0
- package/dist/plugin/orchestrator/createPluginOrchestrator.js +13 -0
- package/dist/plugin/orchestrator/createPluginOrchestrator.server.d.ts +3 -0
- package/dist/plugin/orchestrator/createPluginOrchestrator.server.d.ts.map +1 -0
- package/dist/plugin/orchestrator/createPluginOrchestrator.server.js +44 -0
- package/dist/plugin/orchestrator/index.d.ts +2 -0
- package/dist/plugin/orchestrator/index.d.ts.map +1 -0
- package/dist/plugin/orchestrator/index.js +1 -0
- package/dist/plugin/orchestrator/plugin.js +7 -0
- package/dist/plugin/orchestrator/resolveStrategy.d.ts +19 -0
- package/dist/plugin/orchestrator/resolveStrategy.d.ts.map +1 -0
- package/dist/plugin/orchestrator/resolveStrategy.js +35 -0
- package/dist/plugin/orchestrator/types.d.ts +21 -0
- package/dist/plugin/orchestrator/types.d.ts.map +1 -0
- package/dist/plugin/orchestrator/types.js +1 -0
- package/dist/plugin/plugin.client.d.ts +11 -19
- package/dist/plugin/plugin.client.d.ts.map +1 -1
- package/dist/plugin/plugin.client.js +20 -13
- package/dist/plugin/plugin.d.ts +2 -1
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +4 -2
- package/dist/plugin/plugin.server.d.ts +13 -11
- package/dist/plugin/plugin.server.d.ts.map +1 -1
- package/dist/plugin/plugin.server.js +19 -18
- package/dist/plugin/process-env.d.ts +1 -0
- package/dist/plugin/process-env.d.ts.map +1 -1
- package/dist/plugin/react-client/createMessageHandlers.d.ts +2 -10
- package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
- package/dist/plugin/react-client/createMessageHandlers.js +42 -69
- package/dist/plugin/react-client/index.client.d.ts +2 -0
- package/dist/plugin/react-client/index.client.d.ts.map +1 -0
- package/dist/plugin/react-client/index.client.js +1 -0
- package/dist/plugin/react-client/index.d.ts +3 -4
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +10 -5
- package/dist/plugin/react-client/index.server.d.ts +2 -0
- package/dist/plugin/react-client/index.server.d.ts.map +1 -0
- package/dist/plugin/react-client/index.server.js +1 -0
- package/dist/plugin/react-client/plugin.client.d.ts +15 -0
- package/dist/plugin/react-client/plugin.client.d.ts.map +1 -0
- package/dist/plugin/react-client/plugin.client.js +98 -0
- package/dist/plugin/react-client/plugin.d.ts +2 -5
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +6 -121
- package/dist/plugin/react-client/plugin.server.d.ts +15 -0
- package/dist/plugin/react-client/plugin.server.d.ts.map +1 -0
- package/dist/plugin/react-client/plugin.server.js +93 -0
- package/dist/plugin/react-client/types.d.ts +60 -0
- package/dist/plugin/react-client/types.d.ts.map +1 -0
- package/dist/plugin/react-client/types.js +1 -0
- package/dist/plugin/react-server/index.client.d.ts +2 -0
- package/dist/plugin/react-server/index.client.d.ts.map +1 -0
- package/dist/plugin/react-server/index.client.js +1 -0
- package/dist/plugin/react-server/index.d.ts +3 -1
- package/dist/plugin/react-server/index.d.ts.map +1 -1
- package/dist/plugin/react-server/index.js +13 -1
- package/dist/plugin/react-server/index.server.d.ts +2 -0
- package/dist/plugin/react-server/index.server.d.ts.map +1 -0
- package/dist/plugin/react-server/index.server.js +1 -0
- package/dist/plugin/react-server/plugin.client.d.ts +3 -0
- package/dist/plugin/react-server/plugin.client.d.ts.map +1 -0
- package/dist/plugin/react-server/plugin.client.js +40 -0
- package/dist/plugin/react-server/plugin.d.ts +2 -5
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +5 -143
- package/dist/plugin/react-server/plugin.server.d.ts +3 -0
- package/dist/plugin/react-server/plugin.server.d.ts.map +1 -0
- package/dist/plugin/react-server/plugin.server.js +18 -0
- package/dist/plugin/react-server/types.d.ts +11 -0
- package/dist/plugin/react-server/types.d.ts.map +1 -0
- package/dist/plugin/react-server/types.js +1 -0
- package/dist/plugin/react-static/collectHtmlContent.d.ts +15 -0
- package/dist/plugin/react-static/collectHtmlContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectHtmlContent.js +104 -0
- package/dist/plugin/react-static/collectRscContent.d.ts +10 -15
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectRscContent.js +71 -20
- package/dist/plugin/react-static/configurePreviewServer.d.ts +1 -7
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.js +3 -6
- package/dist/plugin/react-static/createBuildLoader.client.d.ts +2 -0
- package/dist/plugin/react-static/createBuildLoader.client.d.ts.map +1 -0
- package/dist/plugin/react-static/createBuildLoader.client.js +7 -0
- package/dist/plugin/react-static/createBuildLoader.d.ts +3 -19
- package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/react-static/createBuildLoader.js +4 -226
- package/dist/plugin/react-static/createBuildLoader.server.d.ts +9 -0
- package/dist/plugin/react-static/createBuildLoader.server.d.ts.map +1 -0
- package/dist/plugin/react-static/createBuildLoader.server.js +253 -0
- package/dist/plugin/react-static/fileWriter.d.ts +3 -14
- package/dist/plugin/react-static/fileWriter.d.ts.map +1 -1
- package/dist/plugin/react-static/fileWriter.js +233 -42
- package/dist/plugin/react-static/index.client.d.ts +7 -0
- package/dist/plugin/react-static/index.client.d.ts.map +1 -0
- package/dist/plugin/react-static/index.client.js +6 -0
- package/dist/plugin/react-static/index.d.ts +7 -1
- package/dist/plugin/react-static/index.d.ts.map +1 -1
- package/dist/plugin/react-static/index.js +19 -1
- package/dist/plugin/react-static/index.server.d.ts +7 -0
- package/dist/plugin/react-static/index.server.d.ts.map +1 -0
- package/dist/plugin/react-static/index.server.js +6 -0
- package/dist/plugin/react-static/plugin.client.d.ts +32 -0
- package/dist/plugin/react-static/plugin.client.d.ts.map +1 -0
- package/dist/plugin/react-static/plugin.client.js +801 -0
- package/dist/plugin/react-static/plugin.d.ts +3 -20
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +4 -365
- package/dist/plugin/react-static/plugin.server.d.ts +18 -0
- package/dist/plugin/react-static/plugin.server.d.ts.map +1 -0
- package/dist/plugin/react-static/plugin.server.js +615 -0
- package/dist/plugin/react-static/processCssFilesForPages.d.ts +16 -0
- package/dist/plugin/react-static/processCssFilesForPages.d.ts.map +1 -0
- package/dist/plugin/react-static/processCssFilesForPages.js +94 -0
- package/dist/plugin/react-static/renderPage.client.d.ts +49 -0
- package/dist/plugin/react-static/renderPage.client.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPage.client.js +555 -0
- package/dist/plugin/react-static/renderPage.d.ts +3 -4
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPage.js +6 -119
- package/dist/plugin/react-static/renderPage.server.d.ts +24 -0
- package/dist/plugin/react-static/renderPage.server.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPage.server.js +533 -0
- package/dist/plugin/react-static/renderPages.d.ts +11 -3
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPages.js +533 -92
- package/dist/plugin/react-static/renderPagesBatched.d.ts +6 -0
- package/dist/plugin/react-static/renderPagesBatched.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPagesBatched.js +195 -0
- package/dist/plugin/react-static/renderStreams.d.ts +2 -5
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
- package/dist/plugin/react-static/renderStreams.js +36 -24
- package/dist/plugin/react-static/rscToHtmlStream.client.d.ts +12 -0
- package/dist/plugin/react-static/rscToHtmlStream.client.d.ts.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.client.js +32 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts +3 -21
- package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -1
- package/dist/plugin/react-static/rscToHtmlStream.js +4 -53
- package/dist/plugin/react-static/rscToHtmlStream.server.d.ts +3 -0
- package/dist/plugin/react-static/rscToHtmlStream.server.d.ts.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.server.js +39 -0
- package/dist/plugin/react-static/temporaryReferences.client.d.ts +2 -0
- package/dist/plugin/react-static/temporaryReferences.client.d.ts.map +1 -0
- package/dist/plugin/react-static/temporaryReferences.client.js +1 -0
- package/dist/plugin/react-static/temporaryReferences.d.ts +2 -1
- package/dist/plugin/react-static/temporaryReferences.d.ts.map +1 -1
- package/dist/plugin/react-static/temporaryReferences.js +6 -10
- package/dist/plugin/react-static/temporaryReferences.server.d.ts +2 -0
- package/dist/plugin/react-static/temporaryReferences.server.d.ts.map +1 -0
- package/dist/plugin/react-static/temporaryReferences.server.js +3 -0
- package/dist/plugin/react-static/types.d.ts +83 -9
- package/dist/plugin/react-static/types.d.ts.map +1 -1
- package/dist/plugin/root.d.ts.map +1 -1
- package/dist/plugin/root.js +2 -5
- package/dist/plugin/stream/MessagePortReadable.d.ts +22 -0
- package/dist/plugin/stream/MessagePortReadable.d.ts.map +1 -0
- package/dist/plugin/stream/MessagePortReadable.js +101 -0
- package/dist/plugin/stream/MessagePortWritable.d.ts +22 -0
- package/dist/plugin/stream/MessagePortWritable.d.ts.map +1 -0
- package/dist/plugin/stream/MessagePortWritable.js +85 -0
- package/dist/plugin/stream/client.js +12 -0
- package/dist/plugin/stream/createFromNodeStream.client.d.ts +9 -0
- package/dist/plugin/stream/createFromNodeStream.client.d.ts.map +1 -0
- package/dist/plugin/stream/createFromNodeStream.client.js +76 -0
- package/dist/plugin/stream/createFromNodeStream.d.ts +3 -0
- package/dist/plugin/stream/createFromNodeStream.d.ts.map +1 -0
- package/dist/plugin/stream/createFromNodeStream.js +6 -0
- package/dist/plugin/stream/createFromNodeStream.server.d.ts +9 -0
- package/dist/plugin/stream/createFromNodeStream.server.d.ts.map +1 -0
- package/dist/plugin/stream/createFromNodeStream.server.js +27 -0
- package/dist/plugin/stream/createFromNodeStream.types.d.ts +37 -0
- package/dist/plugin/stream/createFromNodeStream.types.d.ts.map +1 -0
- package/dist/plugin/stream/createFromNodeStream.types.js +1 -0
- package/dist/plugin/stream/createHtmlStream.client.d.ts +3 -0
- package/dist/plugin/stream/createHtmlStream.client.d.ts.map +1 -0
- package/dist/plugin/stream/createHtmlStream.client.js +42 -0
- package/dist/plugin/stream/createHtmlStream.d.ts +3 -0
- package/dist/plugin/stream/createHtmlStream.d.ts.map +1 -0
- package/dist/plugin/stream/createHtmlStream.js +6 -0
- package/dist/plugin/stream/createHtmlStream.server.d.ts +6 -0
- package/dist/plugin/stream/createHtmlStream.server.d.ts.map +1 -0
- package/dist/plugin/stream/createHtmlStream.server.js +224 -0
- package/dist/plugin/stream/createHtmlStream.types.d.ts +43 -0
- package/dist/plugin/stream/createHtmlStream.types.d.ts.map +1 -0
- package/dist/plugin/stream/createHtmlStream.types.js +1 -0
- package/dist/plugin/stream/createMainThreadHandlers.d.ts +11 -0
- package/dist/plugin/stream/createMainThreadHandlers.d.ts.map +1 -0
- package/dist/plugin/stream/createMainThreadHandlers.js +32 -0
- package/dist/plugin/stream/createMessageChannels.d.ts +29 -0
- package/dist/plugin/stream/createMessageChannels.d.ts.map +1 -0
- package/dist/plugin/stream/createMessageChannels.js +35 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.client.d.ts +10 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.client.d.ts.map +1 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.client.js +188 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.d.ts +3 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.d.ts.map +1 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.js +6 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.server.d.ts +45 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.server.d.ts.map +1 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.server.js +249 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.types.d.ts +17 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.types.d.ts.map +1 -0
- package/dist/plugin/stream/createRenderToPipeableStreamHandler.types.js +1 -0
- package/dist/plugin/stream/createRscStream.client.d.ts +18 -0
- package/dist/plugin/stream/createRscStream.client.d.ts.map +1 -0
- package/dist/plugin/stream/createRscStream.client.js +79 -0
- package/dist/plugin/stream/createRscStream.d.ts +2 -0
- package/dist/plugin/stream/createRscStream.d.ts.map +1 -0
- package/dist/plugin/stream/createRscStream.js +13 -0
- package/dist/plugin/stream/createRscStream.server.d.ts +46 -0
- package/dist/plugin/stream/createRscStream.server.d.ts.map +1 -0
- package/dist/plugin/stream/createRscStream.server.js +113 -0
- package/dist/plugin/stream/createRscStream.types.d.ts +134 -0
- package/dist/plugin/stream/createRscStream.types.d.ts.map +1 -0
- package/dist/plugin/stream/createRscStream.types.js +1 -0
- package/dist/plugin/stream/createRscStream.utils.d.ts +54 -0
- package/dist/plugin/stream/createRscStream.utils.d.ts.map +1 -0
- package/dist/plugin/stream/createRscStream.utils.js +91 -0
- package/dist/plugin/stream/createRscWorkerStream.d.ts +41 -0
- package/dist/plugin/stream/createRscWorkerStream.d.ts.map +1 -0
- package/dist/plugin/stream/createRscWorkerStream.js +120 -0
- package/dist/plugin/stream/handleRscStream.client.d.ts +17 -0
- package/dist/plugin/stream/handleRscStream.client.d.ts.map +1 -0
- package/dist/plugin/stream/handleRscStream.client.js +163 -0
- package/dist/plugin/stream/handleRscStream.d.ts +3 -0
- package/dist/plugin/stream/handleRscStream.d.ts.map +1 -0
- package/dist/plugin/stream/handleRscStream.js +13 -0
- package/dist/plugin/stream/handleRscStream.server.d.ts +6 -0
- package/dist/plugin/stream/handleRscStream.server.d.ts.map +1 -0
- package/dist/plugin/stream/handleRscStream.server.js +70 -0
- package/dist/plugin/stream/handleRscStream.types.d.ts +28 -0
- package/dist/plugin/stream/handleRscStream.types.d.ts.map +1 -0
- package/dist/plugin/stream/handleRscStream.types.js +1 -0
- package/dist/plugin/stream/index.client.d.ts +7 -0
- package/dist/plugin/stream/index.client.d.ts.map +1 -0
- package/dist/plugin/stream/index.client.js +11 -0
- package/dist/plugin/stream/index.d.ts +95 -0
- package/dist/plugin/stream/index.d.ts.map +1 -0
- package/dist/plugin/stream/index.js +21 -0
- package/dist/plugin/stream/index.server.d.ts +7 -0
- package/dist/plugin/stream/index.server.d.ts.map +1 -0
- package/dist/plugin/stream/index.server.js +11 -0
- package/dist/plugin/stream/renderRscStream.server.d.ts +21 -0
- package/dist/plugin/stream/renderRscStream.server.d.ts.map +1 -0
- package/dist/plugin/stream/renderRscStream.server.js +153 -0
- package/dist/plugin/stream/renderRscStream.types.d.ts +36 -0
- package/dist/plugin/stream/renderRscStream.types.d.ts.map +1 -0
- package/dist/plugin/stream/renderRscStream.types.js +1 -0
- package/dist/plugin/stream/renderRscStreamHelpers.server.d.ts +9 -0
- package/dist/plugin/stream/renderRscStreamHelpers.server.d.ts.map +1 -0
- package/dist/plugin/stream/renderRscStreamHelpers.server.js +63 -0
- package/dist/plugin/stream/server.js +12 -0
- package/dist/plugin/stream/setMaxListeners.d.ts +16 -0
- package/dist/plugin/stream/setMaxListeners.d.ts.map +1 -0
- package/dist/plugin/stream/setMaxListeners.js +16 -0
- package/dist/plugin/transformer/createTransformerPlugin.d.ts +18 -0
- package/dist/plugin/transformer/createTransformerPlugin.d.ts.map +1 -0
- package/dist/plugin/transformer/createTransformerPlugin.js +269 -0
- package/dist/plugin/transformer/plugin.client.d.ts +2 -29
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.client.js +5 -96
- package/dist/plugin/transformer/plugin.server.d.ts +2 -29
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.server.js +5 -96
- package/dist/plugin/transformer/transformerEnv.d.ts +15 -0
- package/dist/plugin/transformer/transformerEnv.d.ts.map +1 -0
- package/dist/plugin/transformer/transformerEnv.js +26 -0
- package/dist/plugin/types.d.ts +366 -140
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js +1 -2
- package/dist/plugin/utils/callServer.d.ts +1 -1
- package/dist/plugin/utils/callServer.d.ts.map +1 -1
- package/dist/plugin/utils/createCallServer.d.ts +1 -1
- package/dist/plugin/utils/createCallServer.d.ts.map +1 -1
- package/dist/plugin/utils/createCallServer.js +4 -9
- package/dist/plugin/utils/createReactFetcher.d.ts +43 -2
- package/dist/plugin/utils/createReactFetcher.d.ts.map +1 -1
- package/dist/plugin/utils/createReactFetcher.js +14 -3
- package/dist/plugin/utils/envUrls.node.js +11 -12
- package/dist/plugin/utils/index.client.d.ts +8 -0
- package/dist/plugin/utils/index.client.d.ts.map +1 -0
- package/dist/plugin/utils/index.client.js +8 -0
- 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 +3 -2
- package/dist/plugin/utils/index.server.d.ts +6 -0
- package/dist/plugin/utils/index.server.d.ts.map +1 -0
- package/dist/plugin/utils/index.server.js +8 -0
- package/dist/plugin/utils/routeToURL.d.ts.map +1 -1
- package/dist/plugin/utils/routeToURL.js +4 -4
- package/dist/plugin/utils/urls.d.ts +1 -1
- package/dist/plugin/utils/urls.d.ts.map +1 -1
- package/dist/plugin/utils/urls.js +29 -8
- package/dist/plugin/utils/useRscHmr.d.ts +39 -0
- package/dist/plugin/utils/useRscHmr.d.ts.map +1 -0
- package/dist/plugin/utils/useRscHmr.js +27 -0
- package/dist/plugin/vendor/vendor.client.d.ts +3 -3
- package/dist/plugin/vendor/vendor.client.d.ts.map +1 -1
- package/dist/plugin/vendor/vendor.client.js +7 -6
- package/dist/plugin/vendor/vendor.d.ts +1 -1
- package/dist/plugin/vendor/vendor.d.ts.map +1 -1
- package/dist/plugin/vendor/vendor.js +4 -6
- package/dist/plugin/vendor/vendor.server.d.ts +4 -2
- package/dist/plugin/vendor/vendor.server.d.ts.map +1 -1
- package/dist/plugin/vendor/vendor.server.js +2 -3
- package/dist/plugin/vendor/vendor.static.d.ts +4 -0
- package/dist/plugin/vendor/vendor.static.d.ts.map +1 -0
- package/dist/plugin/vendor/vendor.static.js +15 -0
- package/dist/plugin/worker/createWorker.d.ts +16 -5
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +207 -30
- package/dist/plugin/worker/html/handleHtmlRender.d.ts +14 -0
- package/dist/plugin/worker/html/handleHtmlRender.d.ts.map +1 -0
- package/dist/plugin/worker/html/handleHtmlRender.js +190 -0
- package/dist/plugin/worker/html/html-worker.development.js +9 -26
- package/dist/plugin/worker/html/html-worker.js +4 -4
- package/dist/plugin/worker/html/html-worker.production.js +7 -13
- package/dist/plugin/worker/html/index.d.ts +1 -1
- package/dist/plugin/worker/html/index.js +6 -2
- 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 +291 -104
- package/dist/plugin/worker/html/state.d.ts +10 -0
- package/dist/plugin/worker/html/state.d.ts.map +1 -0
- package/dist/plugin/worker/html/state.js +28 -0
- package/dist/plugin/worker/html/types.d.ts +52 -23
- package/dist/plugin/worker/html/types.d.ts.map +1 -1
- package/dist/plugin/worker/index.js +1 -1
- package/dist/plugin/worker/rsc/createBundleLoader.d.ts +22 -0
- package/dist/plugin/worker/rsc/createBundleLoader.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/createBundleLoader.js +55 -0
- package/dist/plugin/worker/rsc/createRscWorkerLoader.d.ts +23 -0
- package/dist/plugin/worker/rsc/createRscWorkerLoader.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/createRscWorkerLoader.js +79 -0
- package/dist/plugin/worker/rsc/handleRscRender.d.ts +32 -0
- package/dist/plugin/worker/rsc/handleRscRender.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/handleRscRender.js +349 -0
- package/dist/plugin/worker/rsc/handlers.d.ts +8 -2
- package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handlers.js +137 -200
- package/dist/plugin/worker/rsc/hydrateRscRenderMessage.d.ts +118 -0
- package/dist/plugin/worker/rsc/hydrateRscRenderMessage.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/hydrateRscRenderMessage.js +61 -0
- 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 +927 -49
- package/dist/plugin/worker/rsc/rsc-worker.development.js +153 -148
- package/dist/plugin/worker/rsc/rsc-worker.js +2 -3
- package/dist/plugin/worker/rsc/rsc-worker.production.js +238 -42
- package/dist/plugin/worker/rsc/state.d.ts +6 -0
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +37 -5
- package/dist/plugin/worker/rsc/types.d.ts +73 -12
- package/dist/plugin/worker/rsc/types.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/workerUserOptions.d.ts +10 -0
- package/dist/plugin/worker/rsc/workerUserOptions.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/workerUserOptions.js +39 -0
- package/dist/plugin/worker/sendMessage.d.ts +2 -3
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
- package/dist/plugin/worker/sendMessage.js +24 -38
- package/dist/plugin/worker/types.d.ts +42 -56
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/plugin/worker/worker-handlers.server.d.ts +2 -0
- package/dist/plugin/worker/worker-handlers.server.d.ts.map +1 -0
- package/dist/plugin/worker/worker-handlers.server.js +1 -0
- package/dist/server.d.ts +5 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +4 -6
- package/dist/static.js +11 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +103 -28
- package/plugin/bundle/bundles.ts +22 -0
- package/plugin/bundle/deferredStaticGeneration.ts +48 -0
- package/plugin/bundle/manifests.ts +73 -0
- package/plugin/components/css.tsx +3 -7
- package/plugin/components/html.tsx +4 -3
- package/plugin/components/index.ts +1 -1
- package/plugin/components/root.tsx +3 -3
- package/plugin/config/autoDiscover/createGlobAutoDiscover.ts +10 -5
- package/plugin/config/autoDiscover/pageAndPropFiles.ts +4 -2
- package/plugin/config/autoDiscover/resolveAutoDiscover.ts +64 -79
- package/plugin/config/autoDiscover/resolveBuildPages.ts +181 -69
- package/plugin/config/createHandlerOptions.client.ts +403 -0
- package/plugin/config/createHandlerOptions.server.ts +477 -0
- package/plugin/config/createHandlerOptions.ts +46 -0
- package/plugin/config/createHandlerOptions.types.ts +119 -0
- package/plugin/config/createModuleID.ts +201 -10
- package/plugin/config/defaults.tsx +58 -9
- package/plugin/config/envPrefixFromConfig.ts +10 -0
- package/plugin/config/getCondition.ts +267 -10
- package/plugin/{getNodeEnv.ts → config/getNodeEnv.ts} +4 -2
- package/plugin/config/index.ts +60 -1
- package/plugin/config/resolveDirectiveMatcher.ts +13 -34
- package/plugin/config/resolveEnv.ts +3 -8
- package/plugin/config/resolveOptions.ts +295 -77
- package/plugin/config/resolvePages.ts +1 -1
- package/plugin/config/resolvePatternWithValues.ts +6 -26
- package/plugin/config/resolveUrlOption.ts +2 -2
- package/plugin/config/resolveUserConfig.ts +358 -133
- package/plugin/config/stashedOptionsState.ts +144 -0
- package/plugin/dev-server/cleanupServerAction.client.ts +47 -0
- package/plugin/dev-server/cleanupServerAction.server.ts +24 -0
- package/plugin/dev-server/cleanupServerAction.ts +8 -0
- package/plugin/dev-server/configureReactServer.client.ts +107 -0
- package/plugin/dev-server/configureReactServer.server.ts +558 -0
- package/plugin/dev-server/configureReactServer.ts +8 -0
- package/plugin/dev-server/configureRequestHandler.client.ts +382 -0
- package/plugin/dev-server/configureRequestHandler.server.ts +46 -0
- package/plugin/dev-server/configureRequestHandler.ts +8 -0
- package/plugin/dev-server/handleServerAction.client.ts +126 -0
- package/plugin/dev-server/handleServerAction.server.ts +10 -0
- package/plugin/dev-server/handleServerAction.ts +8 -0
- package/plugin/dev-server/index.client.ts +6 -0
- package/plugin/dev-server/index.server.ts +6 -0
- package/plugin/dev-server/index.ts +20 -0
- package/plugin/dev-server/plugin.client.ts +160 -0
- package/plugin/dev-server/plugin.server.ts +133 -0
- package/plugin/dev-server/restartWorker.client.ts +155 -0
- package/plugin/dev-server/restartWorker.server.ts +108 -0
- package/plugin/dev-server/restartWorker.ts +8 -0
- package/plugin/dev-server/types.ts +78 -0
- package/plugin/dev-server/virtualRscHmrPlugin.ts +82 -0
- package/plugin/env/createConfigEnv.ts +27 -8
- package/plugin/env/createEnvPlugin.ts +76 -0
- package/plugin/env/getArgValue.ts +1 -1
- package/plugin/env/getEnvKey.ts +20 -1
- package/plugin/env/index.ts +10 -0
- package/plugin/env/plugin.client.ts +3 -0
- package/plugin/env/plugin.server.ts +4 -0
- package/plugin/env/plugin.ts +48 -103
- package/plugin/environments/createBuildEventPlugin.ts +117 -0
- package/plugin/environments/createEnvironmentPlugin.ts +332 -0
- package/plugin/environments/hashCoordination.ts +39 -0
- package/plugin/environments/resolveEnvironmentConfig.ts +320 -0
- package/plugin/error/assertPanic.ts +9 -0
- package/plugin/error/handleError.ts +63 -0
- package/plugin/error/index.ts +4 -1
- package/plugin/error/logError.ts +63 -42
- package/plugin/error/panicThresholdHandler.ts +52 -0
- package/plugin/error/serializeError.ts +36 -11
- package/plugin/error/serializeErrorInfo.ts +17 -0
- package/plugin/error/setupGlobalErrorHandler.ts +71 -0
- package/plugin/error/shouldPanic.ts +14 -0
- package/plugin/error/toError.ts +59 -19
- package/plugin/error/types.ts +32 -0
- package/plugin/helpers/README.md +112 -0
- package/plugin/helpers/collectManifestCss.ts +24 -5
- package/plugin/helpers/collectViteModuleGraphCss.ts +83 -9
- package/plugin/helpers/createBufferedRscStream.ts +194 -0
- package/plugin/helpers/createCssProps.tsx +22 -19
- package/plugin/helpers/createElementWithReact.tsx +121 -0
- package/plugin/helpers/createPatternMatcher.ts +100 -0
- package/plugin/helpers/createRscRenderHelpers.ts +77 -0
- package/plugin/helpers/createSafePageComponent.ts +64 -0
- package/plugin/helpers/createSerializableHandlerOptions.ts +183 -0
- package/plugin/helpers/createSharedLoader.ts +207 -0
- package/plugin/helpers/createUnifiedCssProcessor.ts +175 -0
- package/plugin/helpers/getBundleManifest.ts +2 -3
- package/plugin/helpers/getRouteFiles.ts +28 -23
- package/plugin/helpers/handleServerAction.client.ts +145 -0
- package/plugin/helpers/handleServerAction.server.ts +151 -0
- package/plugin/helpers/handleServerAction.ts +19 -79
- package/plugin/helpers/handleServerActionHelper.ts +270 -0
- package/plugin/helpers/headlessStreamReuseHandler.ts +48 -0
- package/plugin/helpers/headlessStreamState.ts +122 -0
- package/plugin/helpers/hydrateUserOptions.ts +2 -2
- package/plugin/helpers/index.ts +32 -5
- package/plugin/helpers/logRenderStart.ts +26 -0
- package/plugin/helpers/mergeMessageWithDefaults.ts +80 -0
- package/plugin/helpers/pipeToResponse.ts +77 -0
- package/plugin/helpers/requestInfo.ts +9 -3
- package/plugin/helpers/resolveComponents.client.ts +183 -0
- package/plugin/helpers/resolveModuleFromManifest.ts +99 -0
- package/plugin/helpers/resolvePageAndProps.ts +237 -50
- package/plugin/helpers/resolveRenderUrl.ts +26 -0
- package/plugin/helpers/resolveStreamElements.client.ts +50 -0
- package/plugin/helpers/resolveStreamElements.server.ts +43 -0
- package/plugin/helpers/resolveStreamElements.ts +13 -0
- package/plugin/helpers/resolveStreamElements.types.ts +29 -0
- package/plugin/helpers/resolveVirtualAndNodeModules.ts +75 -0
- package/plugin/helpers/resolveWithDefaultRootAndHtml.ts +25 -0
- package/plugin/helpers/serializeUserOptions.ts +37 -15
- package/plugin/helpers/tryManifest.ts +15 -6
- package/plugin/helpers/validateRscRenderMessage.ts +13 -0
- package/plugin/helpers/workerCleanup.ts +85 -0
- package/plugin/helpers/workerManager.ts +16 -0
- package/plugin/index.ts +6 -2
- package/plugin/loader/createDefaultLoader.ts +0 -21
- package/plugin/loader/createTransformer.ts +231 -37
- package/plugin/loader/directives/analyzeDirectives.ts +163 -73
- package/plugin/loader/directives/analyzeModule.ts +18 -9
- package/plugin/loader/env-loader.ts +3 -3
- package/plugin/loader/react-loader.ts +133 -86
- package/plugin/loader/transformClientModule.ts +85 -23
- package/plugin/loader/transformModule.ts +101 -21
- package/plugin/loader/transformModuleIfNeeded.ts +20 -23
- package/plugin/loader/transformNonServerEnvironment.ts +21 -13
- package/plugin/loader/transformServerModule.ts +86 -22
- package/plugin/loader/types.ts +22 -7
- package/plugin/metrics/collectStreamMetrics.ts +1 -2
- package/plugin/metrics/convertStreamMetrics.ts +28 -0
- package/plugin/metrics/createModuleResolutionMetrics.ts +38 -0
- package/plugin/metrics/createRenderMetrics.ts +46 -13
- package/plugin/metrics/createStreamMetrics.ts +16 -6
- package/plugin/metrics/createWorkerStartupMetrics.ts +38 -0
- package/plugin/metrics/formatMetrics.ts +5 -33
- package/plugin/metrics/index.ts +6 -3
- package/plugin/metrics/metricWatcher.ts +216 -0
- package/plugin/metrics/types.ts +87 -8
- package/plugin/orchestrator/createPluginOrchestrator.client.ts +47 -0
- package/plugin/orchestrator/createPluginOrchestrator.server.ts +55 -0
- package/plugin/orchestrator/createPluginOrchestrator.ts +29 -0
- package/plugin/orchestrator/index.ts +1 -0
- package/plugin/orchestrator/resolveStrategy.ts +53 -0
- package/plugin/orchestrator/types.ts +24 -0
- package/plugin/plugin.client.ts +29 -34
- package/plugin/plugin.server.ts +36 -42
- package/plugin/plugin.ts +8 -2
- package/plugin/process-env.ts +3 -0
- package/plugin/react-client/createMessageHandlers.ts +9 -34
- package/plugin/react-client/index.client.ts +1 -0
- package/plugin/react-client/index.server.ts +1 -0
- package/plugin/react-client/index.ts +13 -4
- package/plugin/react-client/plugin.client.ts +124 -0
- package/plugin/react-client/plugin.server.ts +108 -0
- package/plugin/react-client/plugin.ts +13 -152
- package/plugin/react-client/types.ts +95 -0
- package/plugin/react-server/index.client.ts +1 -0
- package/plugin/react-server/index.server.ts +1 -0
- package/plugin/react-server/index.ts +13 -1
- package/plugin/react-server/plugin.client.ts +54 -0
- package/plugin/react-server/plugin.server.ts +27 -0
- package/plugin/react-server/plugin.ts +8 -183
- package/plugin/react-server/types.ts +24 -0
- package/plugin/react-static/collectHtmlContent.ts +131 -0
- package/plugin/react-static/collectRscContent.ts +92 -49
- package/plugin/react-static/configurePreviewServer.ts +8 -18
- package/plugin/react-static/createBuildLoader.client.ts +7 -0
- package/plugin/react-static/createBuildLoader.server.ts +333 -0
- package/plugin/react-static/createBuildLoader.ts +8 -300
- package/plugin/react-static/fileWriter.ts +303 -64
- package/plugin/react-static/index.client.ts +6 -0
- package/plugin/react-static/index.server.ts +6 -0
- package/plugin/react-static/index.ts +25 -1
- package/plugin/react-static/plugin.client.ts +932 -0
- package/plugin/react-static/plugin.server.ts +713 -0
- package/plugin/react-static/plugin.ts +8 -446
- package/plugin/react-static/processCssFilesForPages.ts +148 -0
- package/plugin/react-static/renderPage.client.ts +640 -0
- package/plugin/react-static/renderPage.server.ts +655 -0
- package/plugin/react-static/renderPage.ts +10 -160
- package/plugin/react-static/renderPages.ts +736 -139
- package/plugin/react-static/renderPagesBatched.ts +264 -0
- package/plugin/react-static/renderStreams.ts +12 -16
- package/plugin/react-static/rscToHtmlStream.client.ts +61 -0
- package/plugin/react-static/rscToHtmlStream.server.ts +66 -0
- package/plugin/react-static/rscToHtmlStream.ts +8 -80
- package/plugin/react-static/temporaryReferences.client.ts +1 -0
- package/plugin/react-static/temporaryReferences.server.ts +5 -0
- package/plugin/react-static/temporaryReferences.ts +11 -2
- package/plugin/react-static/types.ts +202 -8
- package/plugin/root.ts +1 -3
- package/plugin/stream/MessagePortReadable.ts +131 -0
- package/plugin/stream/MessagePortWritable.ts +104 -0
- package/plugin/stream/createFromNodeStream.client.ts +90 -0
- package/plugin/stream/createFromNodeStream.server.ts +30 -0
- package/plugin/stream/createFromNodeStream.ts +13 -0
- package/plugin/stream/createFromNodeStream.types.ts +53 -0
- package/plugin/stream/createHtmlStream.client.ts +47 -0
- package/plugin/stream/createHtmlStream.server.ts +312 -0
- package/plugin/stream/createHtmlStream.ts +13 -0
- package/plugin/stream/createHtmlStream.types.ts +63 -0
- package/plugin/stream/createMainThreadHandlers.ts +44 -0
- package/plugin/stream/createMessageChannels.ts +52 -0
- package/plugin/stream/createRenderToPipeableStreamHandler.client.ts +224 -0
- package/plugin/stream/createRenderToPipeableStreamHandler.server.ts +358 -0
- package/plugin/stream/createRenderToPipeableStreamHandler.ts +13 -0
- package/plugin/stream/createRenderToPipeableStreamHandler.types.ts +69 -0
- package/plugin/stream/createRscStream.client.ts +122 -0
- package/plugin/stream/createRscStream.server.ts +188 -0
- package/plugin/stream/createRscStream.ts +8 -0
- package/plugin/stream/createRscStream.types.ts +168 -0
- package/plugin/stream/createRscStream.utils.ts +171 -0
- package/plugin/stream/createRscWorkerStream.ts +178 -0
- package/plugin/stream/handleRscStream.client.ts +214 -0
- package/plugin/stream/handleRscStream.server.ts +82 -0
- package/plugin/stream/handleRscStream.ts +11 -0
- package/plugin/stream/handleRscStream.types.ts +70 -0
- package/plugin/stream/index.client.ts +15 -0
- package/plugin/stream/index.server.ts +15 -0
- package/plugin/stream/index.ts +137 -0
- package/plugin/stream/renderRscStream.server.ts +182 -0
- package/plugin/stream/renderRscStream.types.ts +43 -0
- package/plugin/stream/renderRscStreamHelpers.server.ts +88 -0
- package/plugin/stream/setMaxListeners.ts +30 -0
- package/plugin/transformer/README.md +2 -381
- package/plugin/transformer/createTransformerPlugin.ts +388 -0
- package/plugin/transformer/plugin.client.ts +6 -141
- package/plugin/transformer/plugin.server.ts +6 -142
- package/plugin/transformer/transformerEnv.ts +49 -0
- package/plugin/types/react-server-dom-esm.d.ts +269 -110
- package/plugin/types/virtual-rsc-hmr.d.ts +21 -0
- package/plugin/types.ts +636 -223
- package/plugin/utils/createCallServer.ts +8 -18
- package/plugin/utils/createReactFetcher.ts +87 -5
- package/plugin/utils/env.ts +1 -1
- package/plugin/utils/index.client.ts +8 -0
- package/plugin/utils/index.server.ts +8 -0
- package/plugin/utils/index.ts +5 -1
- package/plugin/utils/routeToURL.ts +3 -4
- package/plugin/utils/urls.ts +40 -8
- package/plugin/utils/useRscHmr.ts +72 -0
- package/plugin/vendor/vendor.client.ts +9 -7
- package/plugin/vendor/vendor.server.ts +5 -4
- package/plugin/vendor/vendor.static.ts +12 -0
- package/plugin/vendor/vendor.ts +10 -5
- package/plugin/worker/createWorker.ts +283 -41
- package/plugin/worker/html/README.md +2 -65
- package/plugin/worker/html/handleHtmlRender.ts +245 -0
- package/plugin/worker/html/html-worker.development.tsx +5 -17
- package/plugin/worker/html/html-worker.production.tsx +1 -1
- package/plugin/worker/html/html-worker.ts +5 -5
- package/plugin/worker/html/index.ts +6 -6
- package/plugin/worker/html/messageHandler.tsx +317 -98
- package/plugin/worker/html/state.ts +38 -0
- package/plugin/worker/html/types.ts +108 -35
- package/plugin/worker/rsc/README.md +2 -257
- package/plugin/worker/rsc/createBundleLoader.ts +92 -0
- package/plugin/worker/rsc/createRscWorkerLoader.ts +104 -0
- package/plugin/worker/rsc/handleRscRender.ts +510 -0
- package/plugin/worker/rsc/handlers.ts +159 -238
- package/plugin/worker/rsc/hydrateRscRenderMessage.ts +118 -0
- package/plugin/worker/rsc/messageHandler.tsx +1288 -58
- package/plugin/worker/rsc/rsc-worker.development.ts +198 -185
- package/plugin/worker/rsc/rsc-worker.production.ts +302 -64
- package/plugin/worker/rsc/rsc-worker.tsx +3 -5
- package/plugin/worker/rsc/state.ts +54 -2
- package/plugin/worker/rsc/types.ts +110 -32
- package/plugin/worker/rsc/workerUserOptions.ts +63 -0
- package/plugin/worker/sendMessage.ts +33 -53
- package/plugin/worker/types.ts +94 -91
- package/scripts/generate-toc.mjs +311 -0
- package/scripts/remove-toc.mjs +51 -0
- package/scripts/test-both.sh +82 -0
- package/dist/plugin/config/resolveDevServerConfig.d.ts +0 -2
- package/dist/plugin/config/resolveDevServerConfig.d.ts.map +0 -1
- package/dist/plugin/getNodeEnv.d.ts.map +0 -1
- package/dist/plugin/getNodeEnv.js +0 -17
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts +0 -2
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts.map +0 -1
- package/dist/plugin/helpers/collectBundleManifestCss.js +0 -2
- package/dist/plugin/helpers/createEventHandler.d.ts +0 -22
- package/dist/plugin/helpers/createEventHandler.d.ts.map +0 -1
- package/dist/plugin/helpers/createEventHandler.js +0 -36
- package/dist/plugin/helpers/createHandler.d.ts +0 -14
- package/dist/plugin/helpers/createHandler.d.ts.map +0 -1
- package/dist/plugin/helpers/createHandler.js +0 -75
- package/dist/plugin/helpers/createRscStream.d.ts +0 -26
- package/dist/plugin/helpers/createRscStream.d.ts.map +0 -1
- package/dist/plugin/helpers/createRscStream.js +0 -178
- package/dist/plugin/helpers/defaultFileWriter.d.ts +0 -2
- package/dist/plugin/helpers/defaultFileWriter.d.ts.map +0 -1
- package/dist/plugin/helpers/resolveComponents.d.ts +0 -27
- package/dist/plugin/helpers/resolveComponents.d.ts.map +0 -1
- package/dist/plugin/helpers/resolveComponents.js +0 -146
- package/dist/plugin/helpers/resolveUserComponents.d.ts +0 -33
- package/dist/plugin/helpers/resolveUserComponents.d.ts.map +0 -1
- package/dist/plugin/helpers/resolveUserComponents.js +0 -163
- package/dist/plugin/react-client/cleanupWorkerServerAction.d.ts +0 -11
- package/dist/plugin/react-client/cleanupWorkerServerAction.d.ts.map +0 -1
- package/dist/plugin/react-client/cleanupWorkerServerAction.js +0 -18
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts +0 -17
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +0 -1
- package/dist/plugin/react-client/configureWorkerRequestHandler.js +0 -203
- package/dist/plugin/react-client/createWorkerStream.d.ts +0 -26
- package/dist/plugin/react-client/createWorkerStream.d.ts.map +0 -1
- package/dist/plugin/react-client/createWorkerStream.js +0 -163
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts +0 -24
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +0 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js +0 -91
- package/dist/plugin/react-client/handleWorkerServerAction.d.ts +0 -13
- package/dist/plugin/react-client/handleWorkerServerAction.d.ts.map +0 -1
- package/dist/plugin/react-client/handleWorkerServerAction.js +0 -62
- package/dist/plugin/react-client/restartWorker.d.ts +0 -12
- package/dist/plugin/react-client/restartWorker.d.ts.map +0 -1
- package/dist/plugin/react-client/restartWorker.js +0 -69
- package/dist/plugin/react-server/configureReactServer.d.ts +0 -10
- package/dist/plugin/react-server/configureReactServer.d.ts.map +0 -1
- package/dist/plugin/react-server/configureReactServer.js +0 -209
- package/dist/plugin/react-server/handleServerAction.d.ts +0 -6
- package/dist/plugin/react-server/handleServerAction.d.ts.map +0 -1
- package/dist/plugin/react-server/handleServerAction.js +0 -159
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +0 -25
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +0 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.js +0 -94
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +0 -12
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +0 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +0 -130
- package/dist/plugin/worker/html/sendHtmlWorkerMessage.d.ts +0 -3
- package/dist/plugin/worker/html/sendHtmlWorkerMessage.d.ts.map +0 -1
- package/dist/plugin/worker/html/sendHtmlWorkerMessage.js +0 -2
- package/dist/plugin/worker/rsc/handleRender.d.ts +0 -6
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/handleRender.js +0 -137
- package/dist/plugin/worker/rsc/sendRscWorkerMessage.d.ts +0 -3
- package/dist/plugin/worker/rsc/sendRscWorkerMessage.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/sendRscWorkerMessage.js +0 -11
- package/dist/plugin/worker/rsc/userOptions.d.ts +0 -2
- package/dist/plugin/worker/rsc/userOptions.d.ts.map +0 -1
- package/dist/plugin/worker/rsc/userOptions.js +0 -16
- package/plugin/helpers/collectBundleManifestCss.ts +0 -1
- package/plugin/helpers/createEventHandler.ts +0 -44
- package/plugin/helpers/createHandler.ts +0 -97
- package/plugin/helpers/createRscStream.tsx +0 -226
- package/plugin/helpers/defaultFileWriter.ts +0 -0
- package/plugin/helpers/resolveComponents.ts +0 -202
- package/plugin/helpers/resolveUserComponents.ts +0 -190
- package/plugin/react-client/cleanupWorkerServerAction.ts +0 -33
- package/plugin/react-client/configureWorkerRequestHandler.ts +0 -249
- package/plugin/react-client/createWorkerStream.ts +0 -210
- package/plugin/react-client/handleWorkerRscStream.ts +0 -145
- package/plugin/react-client/handleWorkerServerAction.ts +0 -96
- package/plugin/react-client/restartWorker.ts +0 -90
- package/plugin/react-server/configureReactServer.ts +0 -235
- package/plugin/react-server/handleServerAction.ts +0 -192
- package/plugin/react-static/collectHtmlWorkerContent.ts +0 -147
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +0 -142
- package/plugin/worker/html/sendHtmlWorkerMessage.ts +0 -8
- package/plugin/worker/rsc/handleRender.ts +0 -168
- package/plugin/worker/rsc/sendRscWorkerMessage.ts +0 -7
- package/plugin/worker/rsc/userOptions.ts +0 -7
- /package/dist/plugin/config/{resolveDevServerConfig.js → createHandlerOptions.types.js} +0 -0
- /package/dist/plugin/{helpers/defaultFileWriter.js → dev-server/types.js} +0 -0
- /package/plugin/{config/resolveDevServerConfig.tsx → worker/worker-handlers.server.ts} +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Plugin Helpers
|
|
2
|
+
|
|
3
|
+
This directory contains reusable helper functions that support the `vite-plugin-react-server` architecture across different environments and contexts.
|
|
4
|
+
|
|
5
|
+
## Architecture Overview
|
|
6
|
+
|
|
7
|
+
The plugin supports multiple rendering scenarios:
|
|
8
|
+
|
|
9
|
+
### Environments
|
|
10
|
+
- **Client**: Static generation, build-time rendering
|
|
11
|
+
- **Server**: Runtime rendering, SSR
|
|
12
|
+
|
|
13
|
+
### Contexts
|
|
14
|
+
- **Main Thread**: Direct component access, immediate rendering
|
|
15
|
+
- **Worker Thread**: Message-based communication, component loading
|
|
16
|
+
|
|
17
|
+
### Component Resolution Strategies
|
|
18
|
+
- **Direct**: Components passed directly (main thread)
|
|
19
|
+
- **From Paths**: Components loaded from file paths (worker thread)
|
|
20
|
+
- **Message-based**: Components requested via messages (distributed)
|
|
21
|
+
|
|
22
|
+
## Core Patterns
|
|
23
|
+
|
|
24
|
+
### 1. Main Thread vs. Worker Thread
|
|
25
|
+
- **Main Thread**: Can access React components directly, immediate rendering
|
|
26
|
+
- **Worker Thread**: Must load components from file paths, message-based communication
|
|
27
|
+
|
|
28
|
+
### 2. Stream Piping
|
|
29
|
+
- RSC streams flow from RSC generation to HTML transformation
|
|
30
|
+
- Server: RSC Stream → HTML Worker → HTML Stream
|
|
31
|
+
- Client: RSC Stream → Main Thread HTML Transform → HTML Stream
|
|
32
|
+
|
|
33
|
+
### 3. Dual Consumption
|
|
34
|
+
- Node.js streams can only be consumed once
|
|
35
|
+
- Use `createBufferedRscStream` to allow multiple consumers
|
|
36
|
+
- Pattern: Buffer → Multiple Consumers (RSC file + HTML transform)
|
|
37
|
+
|
|
38
|
+
## Helper Functions
|
|
39
|
+
|
|
40
|
+
### Message Validation & Processing
|
|
41
|
+
- `validateRscRenderMessage()` - Validates RSC render message types
|
|
42
|
+
- `resolveRenderUrl()` - Resolves URLs for render operations
|
|
43
|
+
- `mergeMessageWithDefaults()` - Merges message values with defaults
|
|
44
|
+
- `logRenderStart()` - Consistent logging across render contexts
|
|
45
|
+
|
|
46
|
+
### Component Resolution
|
|
47
|
+
- `resolveComponents()` - Resolves components with fallbacks (main thread)
|
|
48
|
+
|
|
49
|
+
### Stream Handling
|
|
50
|
+
- `createBufferedRscStream()` - Creates buffered streams for dual consumption
|
|
51
|
+
|
|
52
|
+
### Serialization & Communication
|
|
53
|
+
- `createSerializableHandlerOptions()` - Extracts serializable parts for worker communication
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Usage Examples
|
|
57
|
+
|
|
58
|
+
### Main Thread Rendering
|
|
59
|
+
```typescript
|
|
60
|
+
import { createMainThreadRenderHandler } from "../helpers/index.js";
|
|
61
|
+
|
|
62
|
+
const result = await createMainThreadRenderHandler(
|
|
63
|
+
handlerOptions,
|
|
64
|
+
"client", // or "server"
|
|
65
|
+
{ verbose: true, logger }
|
|
66
|
+
);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Worker Thread Rendering
|
|
70
|
+
```typescript
|
|
71
|
+
import { createWorkerThreadRenderHandler } from "../helpers/index.js";
|
|
72
|
+
|
|
73
|
+
const result = await createWorkerThreadRenderHandler(
|
|
74
|
+
handlerOptions,
|
|
75
|
+
"client", // or "server"
|
|
76
|
+
{ verbose: true, logger }
|
|
77
|
+
);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
### Buffered Stream for Dual Consumption
|
|
83
|
+
```typescript
|
|
84
|
+
import { createBufferedRscStream } from "../helpers/index.js";
|
|
85
|
+
|
|
86
|
+
const bufferedStream = createBufferedRscStream(rscStream, {
|
|
87
|
+
route: "/",
|
|
88
|
+
logger,
|
|
89
|
+
verbose: true,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Can be consumed multiple times
|
|
93
|
+
bufferedStream.pipe(rscFileWriter);
|
|
94
|
+
bufferedStream.pipe(htmlTransform);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Key Insights
|
|
98
|
+
|
|
99
|
+
1. **Environment Separation**: Client and server environments have different constraints and capabilities
|
|
100
|
+
2. **Thread Model**: Main thread vs. worker thread determines component access patterns
|
|
101
|
+
3. **Stream Limitations**: Node.js streams are single-consumer, requiring buffering for dual use
|
|
102
|
+
4. **Serialization**: Only serializable data can be passed between threads
|
|
103
|
+
5. **Component Loading**: Workers must load components from file paths, not direct references
|
|
104
|
+
|
|
105
|
+
## Future Improvements
|
|
106
|
+
|
|
107
|
+
- [ ] Add more comprehensive error handling across all helpers
|
|
108
|
+
- [ ] Implement caching for component resolution
|
|
109
|
+
- [ ] Add performance metrics collection
|
|
110
|
+
- [ ] Create more specialized helpers for specific use cases
|
|
111
|
+
- [ ] Improve type safety across all helper functions
|
|
112
|
+
|
|
@@ -13,13 +13,32 @@ export function collectManifestCss(
|
|
|
13
13
|
// Convert startFile to array and ensure we have valid file paths
|
|
14
14
|
const toVisit = Array.isArray(startFile) ? startFile : [startFile];
|
|
15
15
|
|
|
16
|
+
// Helper function to find manifest entry by file property
|
|
17
|
+
const findManifestEntryByFile = (filePath: string) => {
|
|
18
|
+
for (const [key, value] of Object.entries(manifest)) {
|
|
19
|
+
if (value && typeof value === 'object' && 'file' in value && value.file === filePath) {
|
|
20
|
+
return { key, value };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
16
25
|
|
|
17
26
|
while (toVisit.length > 0) {
|
|
18
27
|
const currentFile = toVisit.pop()!;
|
|
19
28
|
if (visited.has(currentFile)) continue;
|
|
20
29
|
visited.add(currentFile);
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
// First try to find by key (for direct matches)
|
|
32
|
+
let fileInfo = manifest[currentFile];
|
|
33
|
+
|
|
34
|
+
// If not found by key, try to find by file property
|
|
35
|
+
if (!fileInfo) {
|
|
36
|
+
const found = findManifestEntryByFile(currentFile);
|
|
37
|
+
if (found) {
|
|
38
|
+
fileInfo = found.value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
if (!fileInfo) {
|
|
24
43
|
continue;
|
|
25
44
|
}
|
|
@@ -42,10 +61,10 @@ export function collectManifestCss(
|
|
|
42
61
|
// Add the import to visit
|
|
43
62
|
toVisit.push(importPath);
|
|
44
63
|
|
|
45
|
-
// Check if the imported file has CSS
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
for (const cssFile of
|
|
64
|
+
// Check if the imported file has CSS by finding it in the manifest
|
|
65
|
+
const importedEntry = findManifestEntryByFile(importPath);
|
|
66
|
+
if (importedEntry?.value.css) {
|
|
67
|
+
for (const cssFile of importedEntry.value.css) {
|
|
49
68
|
cssInputs[cssFile] = cssFile;
|
|
50
69
|
}
|
|
51
70
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
createLogger,
|
|
3
|
+
type EnvironmentModuleGraph,
|
|
4
|
+
type EnvironmentModuleNode,
|
|
5
|
+
type ModuleGraph,
|
|
6
|
+
type ModuleNode,
|
|
6
7
|
} from "vite";
|
|
7
8
|
import type {
|
|
8
9
|
CreateHandlerOptions,
|
|
@@ -22,7 +23,7 @@ type CollectViteModuleGraphCssResult =
|
|
|
22
23
|
}
|
|
23
24
|
| {
|
|
24
25
|
type: "error";
|
|
25
|
-
error:
|
|
26
|
+
error: unknown;
|
|
26
27
|
cssFiles?: never;
|
|
27
28
|
metrics: {
|
|
28
29
|
cssFiles: number;
|
|
@@ -48,6 +49,8 @@ export type CollectViteModuleGraphCssOptions = Pick<
|
|
|
48
49
|
| "normalizer"
|
|
49
50
|
| "moduleID"
|
|
50
51
|
| "publicOrigin"
|
|
52
|
+
| "logger"
|
|
53
|
+
| "verbose"
|
|
51
54
|
>;
|
|
52
55
|
|
|
53
56
|
export type CollectViteModuleGraphCssFn = <
|
|
@@ -78,14 +81,56 @@ export const collectViteModuleGraphCss: CollectViteModuleGraphCssFn =
|
|
|
78
81
|
normalizer,
|
|
79
82
|
moduleID,
|
|
80
83
|
} = handlerOptions;
|
|
81
|
-
|
|
84
|
+
const logger = handlerOptions.logger ?? createLogger ();
|
|
85
|
+
const verbose = handlerOptions.verbose ?? false;
|
|
86
|
+
if(handlerOptions.verbose) {
|
|
87
|
+
logger.info(`Starting CSS collection for pagePath: ${pagePath}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!pagePath) {
|
|
91
|
+
if(verbose) {
|
|
92
|
+
logger.info(`No pagePath, skipping`);
|
|
93
|
+
}
|
|
94
|
+
return { type: "skip" };
|
|
95
|
+
}
|
|
82
96
|
|
|
83
97
|
const cssFiles = new Map<string, CssContent>();
|
|
84
|
-
|
|
98
|
+
if(verbose) {
|
|
99
|
+
logger.info(`Getting module by URL: ${pagePath}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Try multiple path formats since different module graphs use different URL schemes
|
|
103
|
+
let pageModule = await moduleGraph.getModuleByUrl(pagePath, true);
|
|
104
|
+
|
|
105
|
+
// If not found, try with full path (server environment uses full paths)
|
|
106
|
+
if (!pageModule && projectRoot && !pagePath.startsWith('/')) {
|
|
107
|
+
const fullPath = `${projectRoot}/${pagePath}`;
|
|
108
|
+
if(verbose) {
|
|
109
|
+
logger.info(`Trying full path: ${fullPath}`);
|
|
110
|
+
}
|
|
111
|
+
pageModule = await moduleGraph.getModuleByUrl(fullPath, true);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Also try with leading slash
|
|
115
|
+
if (!pageModule && !pagePath.startsWith('/')) {
|
|
116
|
+
const slashPath = `/${pagePath}`;
|
|
117
|
+
if(verbose) {
|
|
118
|
+
logger.info(`Trying slash path: ${slashPath}`);
|
|
119
|
+
}
|
|
120
|
+
pageModule = await moduleGraph.getModuleByUrl(slashPath, true);
|
|
121
|
+
}
|
|
122
|
+
|
|
85
123
|
if (!pageModule) {
|
|
124
|
+
if(verbose) {
|
|
125
|
+
logger.info(`No page module found for any path variant, skipping`);
|
|
126
|
+
}
|
|
86
127
|
return { type: "skip" };
|
|
87
128
|
}
|
|
88
129
|
|
|
130
|
+
if(verbose) {
|
|
131
|
+
logger.info(`Page module found, starting walk`);
|
|
132
|
+
}
|
|
133
|
+
|
|
89
134
|
const seen = new Set<string>();
|
|
90
135
|
const processing = new Set<string>();
|
|
91
136
|
|
|
@@ -106,8 +151,15 @@ export const collectViteModuleGraphCss: CollectViteModuleGraphCssFn =
|
|
|
106
151
|
}
|
|
107
152
|
|
|
108
153
|
processing.add(mod.id);
|
|
154
|
+
if(verbose) {
|
|
155
|
+
logger.info(`Processing module: ${mod.id}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
109
158
|
// Processing module
|
|
110
159
|
if (mod.id.endsWith(".css")) {
|
|
160
|
+
if(verbose) {
|
|
161
|
+
logger.info(`Loading CSS module: ${mod.id}?inline`);
|
|
162
|
+
}
|
|
111
163
|
const string = await loader(`${mod.id}?inline`).then(
|
|
112
164
|
(m) => m?.["default"] ?? ""
|
|
113
165
|
);
|
|
@@ -120,6 +172,9 @@ export const collectViteModuleGraphCss: CollectViteModuleGraphCssFn =
|
|
|
120
172
|
`CSS module ${mod.id}?inline returned an empty string`
|
|
121
173
|
);
|
|
122
174
|
}
|
|
175
|
+
if(verbose) {
|
|
176
|
+
logger.info(`CSS loaded successfully: ${mod.id}`);
|
|
177
|
+
}
|
|
123
178
|
const cssContent = createCssProps({
|
|
124
179
|
id: mod?.id,
|
|
125
180
|
code: string,
|
|
@@ -139,12 +194,18 @@ export const collectViteModuleGraphCss: CollectViteModuleGraphCssFn =
|
|
|
139
194
|
}
|
|
140
195
|
|
|
141
196
|
if (mod.importedModules) {
|
|
197
|
+
if(verbose) {
|
|
198
|
+
logger.info(`Processing imports for module: ${mod.id}`);
|
|
199
|
+
}
|
|
142
200
|
// Processing imports for module
|
|
143
201
|
const importedModules = Array.from(
|
|
144
202
|
mod.importedModules?.values() as Iterable<
|
|
145
203
|
ModuleNode | EnvironmentModuleNode
|
|
146
204
|
>
|
|
147
|
-
);
|
|
205
|
+
);
|
|
206
|
+
if(verbose) {
|
|
207
|
+
logger.info(`Found ${importedModules.length} imported modules`);
|
|
208
|
+
}
|
|
148
209
|
// Found imported modules
|
|
149
210
|
for (const importedMod of importedModules) {
|
|
150
211
|
if (typeof importedMod === "object" && importedMod != null) {
|
|
@@ -168,8 +229,17 @@ export const collectViteModuleGraphCss: CollectViteModuleGraphCssFn =
|
|
|
168
229
|
};
|
|
169
230
|
|
|
170
231
|
try {
|
|
232
|
+
if(verbose) {
|
|
233
|
+
logger.info(`Starting module walk`);
|
|
234
|
+
}
|
|
171
235
|
await walkModule(pageModule);
|
|
236
|
+
if(verbose) {
|
|
237
|
+
logger.info(`Module walk completed successfully`);
|
|
238
|
+
}
|
|
172
239
|
} catch (error) {
|
|
240
|
+
if(verbose) {
|
|
241
|
+
logger.error(`Error during module walk: ${(error as Error)?.message ?? 'no message'}`);
|
|
242
|
+
}
|
|
173
243
|
return {
|
|
174
244
|
type: "error",
|
|
175
245
|
error: error as Error,
|
|
@@ -179,6 +249,10 @@ export const collectViteModuleGraphCss: CollectViteModuleGraphCssFn =
|
|
|
179
249
|
},
|
|
180
250
|
};
|
|
181
251
|
}
|
|
252
|
+
|
|
253
|
+
if(verbose) {
|
|
254
|
+
logger.info(`CSS collection completed, found ${cssFiles.size} CSS files`);
|
|
255
|
+
}
|
|
182
256
|
return {
|
|
183
257
|
type: "success",
|
|
184
258
|
cssFiles,
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createBufferedRscStream.ts
|
|
3
|
+
*
|
|
4
|
+
* PURPOSE: Creates a buffered RSC stream factory that can generate multiple readable streams
|
|
5
|
+
*
|
|
6
|
+
* PROBLEM: Node.js streams can only be consumed once, but in client-side static generation
|
|
7
|
+
* we need to consume the RSC stream twice:
|
|
8
|
+
* 1. Write RSC content to index.rsc file
|
|
9
|
+
* 2. Transform RSC content to HTML for index.html file
|
|
10
|
+
*
|
|
11
|
+
* SOLUTION: Buffer all RSC chunks and create a factory that can generate multiple
|
|
12
|
+
* readable streams from the same buffered data.
|
|
13
|
+
*
|
|
14
|
+
* USAGE:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const bufferedStreamFactory = createBufferedRscStream(rscStream, {
|
|
17
|
+
* route: "/",
|
|
18
|
+
* logger: myLogger,
|
|
19
|
+
* verbose: true
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Create separate streams for each consumer
|
|
23
|
+
* const rscStream = bufferedStreamFactory.createStream();
|
|
24
|
+
* const htmlStream = bufferedStreamFactory.createStream();
|
|
25
|
+
*
|
|
26
|
+
* // Can be piped to different destinations
|
|
27
|
+
* rscStream.pipe(rscFileWriter);
|
|
28
|
+
* htmlStream.pipe(htmlTransform);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import { Readable } from "node:stream";
|
|
33
|
+
|
|
34
|
+
export interface BufferedRscStreamOptions {
|
|
35
|
+
route: string;
|
|
36
|
+
logger?: any;
|
|
37
|
+
verbose?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface BufferedRscStreamFactory {
|
|
41
|
+
createStream(): Readable;
|
|
42
|
+
getBufferInfo(): { chunks: number; bytes: number };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a buffered RSC stream factory that can generate multiple readable streams
|
|
47
|
+
*
|
|
48
|
+
* @param rscStream - The original RSC stream from the worker
|
|
49
|
+
* @param options - Configuration options
|
|
50
|
+
* @returns A factory that can create multiple readable streams from the same buffered data
|
|
51
|
+
*/
|
|
52
|
+
export function createBufferedRscStream(
|
|
53
|
+
rscStream: Readable,
|
|
54
|
+
options: BufferedRscStreamOptions
|
|
55
|
+
): BufferedRscStreamFactory {
|
|
56
|
+
const { route, logger, verbose = false } = options;
|
|
57
|
+
|
|
58
|
+
if (verbose) {
|
|
59
|
+
logger?.info(
|
|
60
|
+
`[createBufferedRscStream:${route}] Creating buffered RSC stream factory for dual consumption`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Buffer to store all RSC chunks
|
|
65
|
+
const rscBuffer: Buffer[] = [];
|
|
66
|
+
let totalBytes = 0;
|
|
67
|
+
let isStreamEnded = false;
|
|
68
|
+
let hasError = false;
|
|
69
|
+
let error: Error | null = null;
|
|
70
|
+
const consumers: Readable[] = [];
|
|
71
|
+
|
|
72
|
+
// Collect all RSC chunks into buffer
|
|
73
|
+
rscStream.on("data", (chunk: Buffer) => {
|
|
74
|
+
if (hasError) return; // Don't buffer if there was an error
|
|
75
|
+
|
|
76
|
+
rscBuffer.push(chunk);
|
|
77
|
+
totalBytes += chunk.length;
|
|
78
|
+
|
|
79
|
+
if (verbose) {
|
|
80
|
+
logger?.info(
|
|
81
|
+
`[createBufferedRscStream:${route}] Buffered chunk: ${chunk.length} bytes, total: ${totalBytes} bytes`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Push the chunk to all existing consumers immediately
|
|
86
|
+
for (const consumer of consumers) {
|
|
87
|
+
if (!consumer.destroyed) {
|
|
88
|
+
consumer.push(chunk);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
rscStream.on("end", () => {
|
|
94
|
+
isStreamEnded = true;
|
|
95
|
+
if (verbose) {
|
|
96
|
+
logger?.info(
|
|
97
|
+
`[createBufferedRscStream:${route}] RSC stream ended, buffered ${rscBuffer.length} chunks (${totalBytes} bytes)`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// End all consumers
|
|
102
|
+
for (const consumer of consumers) {
|
|
103
|
+
if (!consumer.destroyed) {
|
|
104
|
+
consumer.push(null);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
rscStream.on("error", (streamError: Error) => {
|
|
110
|
+
hasError = true;
|
|
111
|
+
error = streamError;
|
|
112
|
+
if (verbose) {
|
|
113
|
+
logger?.error(
|
|
114
|
+
`[createBufferedRscStream:${route}] RSC stream error: ${streamError.message}`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Emit error on all consumers
|
|
119
|
+
for (const consumer of consumers) {
|
|
120
|
+
if (!consumer.destroyed) {
|
|
121
|
+
consumer.emit("error", streamError);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
createStream(): Readable {
|
|
128
|
+
if (hasError && error) {
|
|
129
|
+
// If there was an error, create a stream that immediately emits the error
|
|
130
|
+
const errorStream = new Readable();
|
|
131
|
+
setImmediate(() => {
|
|
132
|
+
errorStream.emit("error", error);
|
|
133
|
+
});
|
|
134
|
+
return errorStream;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const consumer = new Readable({
|
|
138
|
+
read() {
|
|
139
|
+
if (verbose) {
|
|
140
|
+
logger?.info(
|
|
141
|
+
`[createBufferedRscStream:${route}] Read requested, buffered chunks: ${rscBuffer.length}, isStreamEnded: ${isStreamEnded}`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// If the stream has already ended, push all remaining buffered content
|
|
146
|
+
if (isStreamEnded) {
|
|
147
|
+
// Push all buffered content that hasn't been pushed yet
|
|
148
|
+
for (const chunk of rscBuffer) {
|
|
149
|
+
this.push(chunk);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// End the stream
|
|
153
|
+
this.push(null);
|
|
154
|
+
|
|
155
|
+
if (verbose) {
|
|
156
|
+
logger?.info(
|
|
157
|
+
`[createBufferedRscStream:${route}] Pushed ${rscBuffer.length} chunks, ending stream`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// If the stream hasn't ended yet, we'll push chunks as they arrive via the 'data' event
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Add this consumer to the list
|
|
166
|
+
consumers.push(consumer);
|
|
167
|
+
|
|
168
|
+
// If the stream has already ended, push all buffered content immediately
|
|
169
|
+
if (isStreamEnded) {
|
|
170
|
+
for (const chunk of rscBuffer) {
|
|
171
|
+
consumer.push(chunk);
|
|
172
|
+
}
|
|
173
|
+
consumer.push(null);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Clean up when the consumer is destroyed
|
|
177
|
+
consumer.on("close", () => {
|
|
178
|
+
const index = consumers.indexOf(consumer);
|
|
179
|
+
if (index > -1) {
|
|
180
|
+
consumers.splice(index, 1);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
return consumer;
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
getBufferInfo() {
|
|
188
|
+
return {
|
|
189
|
+
chunks: rscBuffer.length,
|
|
190
|
+
bytes: totalBytes
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
@@ -46,7 +46,7 @@ export const createCssProps = ({
|
|
|
46
46
|
let inline =
|
|
47
47
|
css?.inlineCss !== false &&
|
|
48
48
|
typeof code === "string" &&
|
|
49
|
-
code.length
|
|
49
|
+
(css?.inlineThreshold === 0 || code.length <= (css?.inlineThreshold ?? DEFAULT_CONFIG.CSS.inlineThreshold));
|
|
50
50
|
// Normalize the ID to be relative to src/
|
|
51
51
|
const [, value] = userOptions.normalizer(id);
|
|
52
52
|
const moduleID = userOptions?.moduleID?.(value) ?? value;
|
|
@@ -78,7 +78,25 @@ export const createCssProps = ({
|
|
|
78
78
|
: {}),
|
|
79
79
|
} as CssContent<boolean>;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
const normalModuleBaseURL = !moduleID.startsWith(userOptions.moduleBaseURL)
|
|
82
|
+
? userOptions.moduleBaseURL +
|
|
83
|
+
moduleID.slice(
|
|
84
|
+
Number(
|
|
85
|
+
moduleID.startsWith("/") && userOptions.moduleBaseURL.endsWith("/")
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
: moduleID;
|
|
89
|
+
const normalOrigin = !userOptions.moduleBaseURL.startsWith(
|
|
90
|
+
userOptions.publicOrigin
|
|
91
|
+
)
|
|
92
|
+
? userOptions.publicOrigin +
|
|
93
|
+
userOptions.moduleBaseURL.slice(
|
|
94
|
+
Number(
|
|
95
|
+
userOptions.publicOrigin.endsWith("/") &&
|
|
96
|
+
userOptions.moduleBaseURL.startsWith("/")
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
: userOptions.moduleBaseURL;
|
|
82
100
|
// Default case
|
|
83
101
|
return {
|
|
84
102
|
id: moduleID,
|
|
@@ -86,23 +104,8 @@ export const createCssProps = ({
|
|
|
86
104
|
rel: "stylesheet",
|
|
87
105
|
href:
|
|
88
106
|
userOptions.publicOrigin !== ""
|
|
89
|
-
? new URL(
|
|
90
|
-
|
|
91
|
-
moduleID.slice(
|
|
92
|
-
Number(
|
|
93
|
-
moduleID.startsWith("/") &&
|
|
94
|
-
userOptions.moduleBaseURL.endsWith("/")
|
|
95
|
-
)
|
|
96
|
-
),
|
|
97
|
-
userOptions.publicOrigin +
|
|
98
|
-
userOptions.moduleBaseURL.slice(
|
|
99
|
-
Number(
|
|
100
|
-
userOptions.publicOrigin.endsWith("/") &&
|
|
101
|
-
userOptions.moduleBaseURL.startsWith("/")
|
|
102
|
-
)
|
|
103
|
-
)
|
|
104
|
-
).href
|
|
105
|
-
: moduleID,
|
|
107
|
+
? new URL(normalModuleBaseURL, normalOrigin).href
|
|
108
|
+
: normalModuleBaseURL,
|
|
106
109
|
precedence: "high",
|
|
107
110
|
} as CssContent<boolean>;
|
|
108
111
|
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { createLogger } from "vite";
|
|
2
|
+
import type { CreateHandlerOptions } from "../types.js";
|
|
3
|
+
|
|
4
|
+
export type CreateElementWithReactOptions = Pick<
|
|
5
|
+
CreateHandlerOptions,
|
|
6
|
+
| "HtmlComponent"
|
|
7
|
+
| "PageComponent"
|
|
8
|
+
| "RootComponent"
|
|
9
|
+
| "pageProps"
|
|
10
|
+
| "moduleBase"
|
|
11
|
+
| "moduleRootPath"
|
|
12
|
+
| "moduleBasePath"
|
|
13
|
+
| "moduleBaseURL"
|
|
14
|
+
| "cssFiles"
|
|
15
|
+
| "globalCss"
|
|
16
|
+
| "route"
|
|
17
|
+
| "manifest"
|
|
18
|
+
| "projectRoot"
|
|
19
|
+
| "url"
|
|
20
|
+
| "as"
|
|
21
|
+
> &
|
|
22
|
+
Partial<Pick<CreateHandlerOptions, "verbose" | "logger">>;
|
|
23
|
+
|
|
24
|
+
export type CreateElementWithReactFN = <
|
|
25
|
+
R extends {
|
|
26
|
+
Fragment: any;
|
|
27
|
+
use: any;
|
|
28
|
+
isValidElement: (element: any) => boolean;
|
|
29
|
+
},
|
|
30
|
+
ReturnType = React.ReactElement,
|
|
31
|
+
Opt extends CreateElementWithReactOptions = CreateElementWithReactOptions
|
|
32
|
+
>(
|
|
33
|
+
React: R,
|
|
34
|
+
options: Opt
|
|
35
|
+
) => ReturnType;
|
|
36
|
+
|
|
37
|
+
export const createElementWithReact: CreateElementWithReactFN =
|
|
38
|
+
function _createElementWithReact(
|
|
39
|
+
React,
|
|
40
|
+
{
|
|
41
|
+
HtmlComponent,
|
|
42
|
+
PageComponent,
|
|
43
|
+
RootComponent,
|
|
44
|
+
pageProps,
|
|
45
|
+
moduleBase,
|
|
46
|
+
moduleBaseURL,
|
|
47
|
+
moduleBasePath,
|
|
48
|
+
moduleRootPath,
|
|
49
|
+
cssFiles = new Map(),
|
|
50
|
+
globalCss = new Map(),
|
|
51
|
+
route,
|
|
52
|
+
manifest,
|
|
53
|
+
projectRoot,
|
|
54
|
+
url,
|
|
55
|
+
as = "div",
|
|
56
|
+
verbose = false,
|
|
57
|
+
logger = createLogger("info", {
|
|
58
|
+
prefix: "vite:plugin-react-server/helpers/createElementWithReact",
|
|
59
|
+
}),
|
|
60
|
+
}
|
|
61
|
+
) {
|
|
62
|
+
// Add debug logging
|
|
63
|
+
if (verbose) {
|
|
64
|
+
logger?.info(
|
|
65
|
+
`[createElementWithReact] Creating element for route: ${route}`
|
|
66
|
+
);
|
|
67
|
+
logger?.info(
|
|
68
|
+
`[createElementWithReact] CSS files: ${cssFiles?.size || 0} files`
|
|
69
|
+
);
|
|
70
|
+
logger?.info(
|
|
71
|
+
`[createElementWithReact] Global CSS: ${globalCss?.size || 0} files`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (
|
|
76
|
+
HtmlComponent != null &&
|
|
77
|
+
HtmlComponent !== React.Fragment &&
|
|
78
|
+
HtmlComponent !== undefined
|
|
79
|
+
) {
|
|
80
|
+
if (verbose) {
|
|
81
|
+
logger?.info(`[createElementWithReact] Returning Full HTML structure`);
|
|
82
|
+
}
|
|
83
|
+
return (
|
|
84
|
+
<HtmlComponent
|
|
85
|
+
moduleBase={moduleBase}
|
|
86
|
+
moduleBaseURL={moduleBaseURL}
|
|
87
|
+
moduleBasePath={moduleBasePath}
|
|
88
|
+
moduleRootPath={moduleRootPath}
|
|
89
|
+
projectRoot={projectRoot}
|
|
90
|
+
url={url || ""}
|
|
91
|
+
route={route}
|
|
92
|
+
pageProps={pageProps}
|
|
93
|
+
cssFiles={cssFiles}
|
|
94
|
+
globalCss={globalCss}
|
|
95
|
+
Root={RootComponent ? RootComponent : React.Fragment}
|
|
96
|
+
manifest={manifest}
|
|
97
|
+
Page={PageComponent ? PageComponent : React.Fragment}
|
|
98
|
+
as={as}
|
|
99
|
+
/>
|
|
100
|
+
) as never;
|
|
101
|
+
} else if (RootComponent != null && RootComponent !== React.Fragment) {
|
|
102
|
+
if (verbose) {
|
|
103
|
+
logger?.info(`[createElementWithReact] Returning Root only`);
|
|
104
|
+
}
|
|
105
|
+
return (
|
|
106
|
+
<RootComponent
|
|
107
|
+
key={route}
|
|
108
|
+
as={React.Fragment}
|
|
109
|
+
cssFiles={cssFiles}
|
|
110
|
+
pageProps={pageProps}
|
|
111
|
+
Page={PageComponent ? PageComponent : React.Fragment}
|
|
112
|
+
/>
|
|
113
|
+
) as never;
|
|
114
|
+
} else if (PageComponent != null && PageComponent !== React.Fragment) {
|
|
115
|
+
if (verbose) {
|
|
116
|
+
logger?.info(`[createElementWithReact] Returning Page only`);
|
|
117
|
+
}
|
|
118
|
+
return (<PageComponent {...pageProps} />) as never;
|
|
119
|
+
}
|
|
120
|
+
return null as never;
|
|
121
|
+
};
|