vite-plugin-react-server 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -76
- package/bin/patch.mjs +27 -20
- package/dist/_virtual/dynamic-import-helper.js +24 -0
- package/dist/_virtual/dynamic-import-helper.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -26
- package/dist/index.js.map +1 -1
- package/dist/package.json +24 -14
- package/dist/plugin/components.d.ts +1 -1
- package/dist/plugin/components.d.ts.map +1 -1
- package/dist/plugin/components.js +1 -1
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js +30 -0
- package/dist/plugin/config/autoDiscover/createGlobAutoDiscover.js.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts +13 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js +24 -0
- package/dist/plugin/config/autoDiscover/customWorkerFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts +11 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js +29 -0
- package/dist/plugin/config/autoDiscover/pageAndPropFiles.js.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts +6 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.d.ts.map +1 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js +83 -0
- package/dist/plugin/config/autoDiscover/resolveBuildPages.js.map +1 -0
- package/dist/plugin/config/defaults.d.ts +18 -14
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +42 -21
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/getCondition.d.ts +1 -1
- package/dist/plugin/config/getCondition.d.ts.map +1 -1
- package/dist/plugin/config/getCondition.js +2 -2
- package/dist/plugin/config/getCondition.js.map +1 -1
- package/dist/plugin/config/getPaths.d.ts +0 -1
- package/dist/plugin/config/getPaths.d.ts.map +1 -1
- package/dist/plugin/config/getPaths.js.map +1 -1
- package/dist/plugin/config/index.d.ts +0 -1
- package/dist/plugin/config/index.d.ts.map +1 -1
- package/dist/plugin/config/index.js +0 -1
- package/dist/plugin/config/resolveAutoDiscover.d.ts +20 -0
- package/dist/plugin/config/resolveAutoDiscover.d.ts.map +1 -0
- package/dist/plugin/config/resolveAutoDiscover.js +128 -0
- package/dist/plugin/config/resolveAutoDiscover.js.map +1 -0
- package/dist/plugin/config/resolveOptions.d.ts +1 -1
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +109 -77
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolvePages.d.ts +0 -1
- package/dist/plugin/config/resolvePages.d.ts.map +1 -1
- package/dist/plugin/config/resolvePages.js +6 -8
- package/dist/plugin/config/resolvePages.js.map +1 -1
- package/dist/plugin/config/resolveUrlOption.d.ts +16 -0
- package/dist/plugin/config/resolveUrlOption.d.ts.map +1 -0
- package/dist/plugin/config/resolveUrlOption.js +37 -0
- package/dist/plugin/config/resolveUrlOption.js.map +1 -0
- package/dist/plugin/config/resolveUserConfig.d.ts +4 -5
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +80 -132
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/copy.d.ts +7 -0
- package/dist/plugin/copy.d.ts.map +1 -0
- package/dist/plugin/copy.js +30 -0
- package/dist/plugin/css-collector-elements.d.ts +4 -0
- package/dist/plugin/css-collector-elements.d.ts.map +1 -0
- package/dist/plugin/css-collector-elements.js +19 -0
- package/dist/plugin/css-collector-elements.js.map +1 -0
- package/dist/plugin/css-collector.d.ts +2 -8
- package/dist/plugin/css-collector.d.ts.map +1 -1
- package/dist/plugin/css-collector.js +9 -36
- package/dist/plugin/css-collector.js.map +1 -1
- package/dist/plugin/helpers/cleanObject.d.ts +3 -0
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -0
- package/dist/plugin/helpers/cleanObject.js +47 -0
- package/dist/plugin/helpers/cleanObject.js.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts +8 -0
- package/dist/plugin/helpers/collectBundleManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectBundleManifestCss.js +110 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts +7 -0
- package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectManifestCss.js +44 -0
- package/dist/plugin/helpers/collectManifestCss.js.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +31 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +104 -0
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -0
- package/dist/plugin/helpers/createCssProps.d.ts +25 -0
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -0
- package/dist/plugin/helpers/createCssProps.js +57 -0
- package/dist/plugin/helpers/createCssProps.js.map +1 -0
- package/dist/plugin/helpers/createEventHandler.d.ts +22 -0
- package/dist/plugin/helpers/createEventHandler.d.ts.map +1 -0
- package/dist/plugin/helpers/createEventHandler.js +36 -0
- package/dist/plugin/helpers/createEventHandler.js.map +1 -0
- package/dist/plugin/helpers/createHandler.d.ts +7 -13
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +54 -96
- package/dist/plugin/helpers/createHandler.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts +12 -26
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +105 -51
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/helpers/defaultFileWriter.d.ts +2 -0
- package/dist/plugin/helpers/defaultFileWriter.d.ts.map +1 -0
- package/dist/plugin/helpers/defaultFileWriter.js +1 -0
- package/dist/plugin/helpers/getBundleManifest.d.ts +10 -16
- package/dist/plugin/helpers/getBundleManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/getBundleManifest.js +30 -22
- package/dist/plugin/helpers/getBundleManifest.js.map +1 -1
- package/dist/plugin/helpers/getRouteFiles.d.ts +14 -0
- package/dist/plugin/helpers/getRouteFiles.d.ts.map +1 -0
- package/dist/plugin/helpers/getRouteFiles.js +36 -0
- package/dist/plugin/helpers/getRouteFiles.js.map +1 -0
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +38 -32
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/metrics.d.ts +11 -0
- package/dist/plugin/helpers/metrics.d.ts.map +1 -0
- package/dist/plugin/helpers/metrics.js +35 -0
- package/dist/plugin/helpers/metrics.js.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +27 -0
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -0
- package/dist/plugin/helpers/resolvePageAndProps.js +51 -0
- package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts +8 -0
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -0
- package/dist/plugin/helpers/serializeUserOptions.js +182 -0
- package/dist/plugin/helpers/serializeUserOptions.js.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts +2 -0
- package/dist/plugin/helpers/stashReturnValue.d.ts.map +1 -0
- package/dist/plugin/helpers/stashReturnValue.js +14 -0
- package/dist/plugin/helpers/tryManifest.d.ts +5 -3
- package/dist/plugin/helpers/tryManifest.d.ts.map +1 -1
- package/dist/plugin/helpers/tryManifest.js +16 -7
- package/dist/plugin/helpers/tryManifest.js.map +1 -1
- package/dist/plugin/html.d.ts +2 -3
- package/dist/plugin/html.d.ts.map +1 -1
- package/dist/plugin/html.js +7 -1
- package/dist/plugin/html.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +3 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +26 -4
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +98 -33
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/css-loader.development.d.ts +57 -0
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.development.js +81 -0
- package/dist/plugin/loader/css-loader.development.js.map +1 -0
- package/dist/plugin/loader/css-loader.production.d.ts +31 -0
- package/dist/plugin/loader/css-loader.production.d.ts.map +1 -0
- package/dist/plugin/loader/css-loader.production.js +45 -0
- package/dist/plugin/loader/css-loader.production.js.map +1 -0
- package/dist/plugin/loader/index.d.ts +2 -0
- package/dist/plugin/loader/index.d.ts.map +1 -0
- package/dist/plugin/loader/index.js +1 -0
- package/dist/plugin/loader/plugin.d.ts +22 -0
- package/dist/plugin/loader/plugin.d.ts.map +1 -0
- package/dist/plugin/loader/plugin.js +27 -0
- package/dist/plugin/loader/react-loader.d.ts +3 -7
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +85 -30
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/loader/temporaryReferences.d.ts +2 -0
- package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -0
- package/dist/plugin/loader/temporaryReferences.js +11 -0
- package/dist/plugin/loader/temporaryReferences.js.map +1 -0
- package/dist/plugin/moduleRefs.d.ts +7 -0
- package/dist/plugin/moduleRefs.d.ts.map +1 -0
- package/dist/plugin/moduleRefs.js +17 -0
- package/dist/plugin/moduleRefs.js.map +1 -0
- package/dist/plugin/plugin.client.d.ts +3 -0
- package/dist/plugin/plugin.client.d.ts.map +1 -0
- package/dist/plugin/plugin.client.js +19 -0
- package/dist/plugin/plugin.client.js.map +1 -0
- package/dist/plugin/plugin.d.ts +1 -5
- package/dist/plugin/plugin.d.ts.map +1 -1
- package/dist/plugin/plugin.js +3 -9
- package/dist/plugin/plugin.server.d.ts +3 -0
- package/dist/plugin/plugin.server.d.ts.map +1 -0
- package/dist/plugin/plugin.server.js +28 -0
- package/dist/plugin/plugin.server.js.map +1 -0
- package/dist/plugin/preserver/plugin.js +1 -1
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/index.d.ts +1 -2
- package/dist/plugin/react-client/index.d.ts.map +1 -1
- package/dist/plugin/react-client/index.js +1 -19
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +60 -219
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-client/server.d.ts +27 -0
- package/dist/plugin/react-client/server.d.ts.map +1 -0
- package/dist/plugin/react-client/server.js +197 -0
- package/dist/plugin/react-client/server.js.map +1 -0
- package/dist/plugin/react-server/index.d.ts +1 -2
- package/dist/plugin/react-server/index.d.ts.map +1 -1
- package/dist/plugin/react-server/index.js +1 -21
- package/dist/plugin/react-server/plugin.d.ts +0 -1
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +60 -186
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-server/server.d.ts +9 -0
- package/dist/plugin/react-server/server.d.ts.map +1 -0
- package/dist/plugin/react-server/server.js +120 -0
- package/dist/plugin/react-server/server.js.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +23 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js +85 -0
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -0
- package/dist/plugin/react-static/collectRscContent.d.ts +24 -0
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -0
- package/dist/plugin/react-static/collectRscContent.js +49 -0
- package/dist/plugin/react-static/collectRscContent.js.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts +7 -0
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -0
- package/dist/plugin/react-static/configurePreviewServer.js +67 -0
- package/dist/plugin/react-static/configurePreviewServer.js.map +1 -0
- package/dist/plugin/react-static/fileWriter.d.ts +23 -0
- package/dist/plugin/react-static/fileWriter.d.ts.map +1 -0
- package/dist/plugin/react-static/fileWriter.js +65 -0
- package/dist/plugin/react-static/fileWriter.js.map +1 -0
- package/dist/plugin/react-static/plugin.d.ts +15 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +248 -149
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/renderPage.d.ts +3 -0
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPage.js +116 -0
- package/dist/plugin/react-static/renderPage.js.map +1 -0
- package/dist/plugin/react-static/renderPages.d.ts +3 -0
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -0
- package/dist/plugin/react-static/renderPages.js +125 -0
- package/dist/plugin/react-static/renderPages.js.map +1 -0
- package/dist/plugin/react-static/renderStreams.d.ts +26 -0
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -0
- package/dist/plugin/react-static/renderStreams.js +27 -0
- package/dist/plugin/react-static/renderStreams.js.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts +22 -0
- package/dist/plugin/react-static/rscToHtmlStream.d.ts.map +1 -0
- package/dist/plugin/react-static/rscToHtmlStream.js +54 -0
- package/dist/plugin/react-static/rscToHtmlStream.js.map +1 -0
- package/dist/plugin/react-static/streamHandler.d.ts +2 -0
- package/dist/plugin/react-static/streamHandler.d.ts.map +1 -0
- package/dist/plugin/react-static/streamHandler.js +1 -0
- package/dist/plugin/react-static/types.d.ts +11 -0
- package/dist/plugin/react-static/types.d.ts.map +1 -1
- package/dist/plugin/resolvePage.d.ts +26 -9
- package/dist/plugin/resolvePage.d.ts.map +1 -1
- package/dist/plugin/resolvePage.js +41 -39
- package/dist/plugin/resolvePage.js.map +1 -1
- package/dist/plugin/resolveProps.d.ts +40 -7
- package/dist/plugin/resolveProps.d.ts.map +1 -1
- package/dist/plugin/resolveProps.js +100 -75
- package/dist/plugin/resolveProps.js.map +1 -1
- package/dist/plugin/root.d.ts +1 -0
- package/dist/plugin/root.d.ts.map +1 -1
- package/dist/plugin/root.js +1 -0
- package/dist/plugin/root.js.map +1 -1
- package/dist/plugin/transformer/index.d.ts +2 -1
- package/dist/plugin/transformer/index.d.ts.map +1 -1
- package/dist/plugin/transformer/index.js +2 -1
- package/dist/plugin/transformer/plugin.client.d.ts +4 -0
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.client.js +83 -0
- package/dist/plugin/transformer/plugin.client.js.map +1 -0
- package/dist/plugin/transformer/plugin.d.ts +1 -27
- package/dist/plugin/transformer/plugin.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.js +3 -87
- package/dist/plugin/transformer/plugin.js.map +1 -1
- package/dist/plugin/transformer/plugin.server.d.ts +4 -0
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -0
- package/dist/plugin/transformer/plugin.server.js +76 -0
- package/dist/plugin/transformer/plugin.server.js.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +11 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +1 -0
- package/dist/plugin/transformer/upgradeCssModuleCode.js +38 -0
- package/dist/plugin/types/css-tracking.d.ts +6 -0
- package/dist/plugin/types/css-tracking.d.ts.map +1 -0
- package/dist/plugin/types/css-tracking.js +1 -0
- package/dist/plugin/types.d.ts +372 -86
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/types.js +1 -1
- package/dist/plugin/vendor.client.d.ts +4 -0
- package/dist/plugin/vendor.client.d.ts.map +1 -0
- package/dist/plugin/vendor.client.js +16 -0
- package/dist/plugin/vendor.client.js.map +1 -0
- package/dist/plugin/vendor.server.d.ts +4 -0
- package/dist/plugin/vendor.server.d.ts.map +1 -0
- package/dist/plugin/vendor.server.js +16 -0
- package/dist/plugin/vendor.server.js.map +1 -0
- package/dist/plugin/worker/createWorker.d.ts +25 -7
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +108 -33
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts +12 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +103 -0
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -0
- package/dist/plugin/worker/html/html-worker.development.d.ts +0 -30
- package/dist/plugin/worker/html/html-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +3 -17
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +12 -5
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +87 -84
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/html/types.d.ts +18 -0
- package/dist/plugin/worker/html/types.d.ts.map +1 -0
- package/dist/plugin/worker/html/types.js +1 -0
- package/dist/plugin/worker/registerLoaders.d.ts +9 -0
- package/dist/plugin/worker/registerLoaders.d.ts.map +1 -0
- package/dist/plugin/worker/registerLoaders.js +45 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts +4 -0
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/handleRender.js +147 -0
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts +2 -2
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +47 -112
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts +0 -30
- package/dist/plugin/worker/rsc/rsc-worker.development.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +29 -4
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +3 -3
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +73 -2
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +40 -3
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/sendMessage.d.ts +3 -0
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -0
- package/dist/plugin/worker/sendMessage.js +48 -0
- package/dist/plugin/worker/types.d.ts +218 -76
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -14
- package/plugin/components.ts +1 -1
- package/plugin/config/autoDiscover/createGlobAutoDiscover.ts +29 -0
- package/plugin/config/autoDiscover/customWorkerFiles.ts +27 -0
- package/plugin/config/autoDiscover/pageAndPropFiles.ts +36 -0
- package/plugin/config/autoDiscover/resolveBuildPages.ts +98 -0
- package/plugin/config/defaults.tsx +38 -29
- package/plugin/config/getCondition.ts +7 -3
- package/plugin/config/getPaths.ts +1 -7
- package/plugin/config/index.ts +0 -1
- package/plugin/config/resolveAutoDiscover.ts +177 -0
- package/plugin/config/resolveOptions.ts +220 -118
- package/plugin/config/resolvePages.ts +5 -7
- package/plugin/config/resolveUrlOption.ts +43 -0
- package/plugin/config/resolveUserConfig.ts +116 -166
- package/plugin/copy.ts +39 -0
- package/plugin/css-collector-elements.tsx +21 -0
- package/plugin/css-collector.tsx +20 -53
- package/plugin/helpers/cleanObject.ts +50 -0
- package/plugin/helpers/collectBundleManifestCss.ts +160 -0
- package/plugin/helpers/collectManifestCss.ts +61 -0
- package/plugin/helpers/collectViteModuleGraphCss.ts +158 -0
- package/plugin/helpers/createCssProps.tsx +85 -0
- package/plugin/helpers/createEventHandler.ts +44 -0
- package/plugin/helpers/createHandler.ts +57 -126
- package/plugin/helpers/createRscStream.tsx +156 -0
- package/plugin/helpers/defaultFileWriter.ts +0 -0
- package/plugin/helpers/getBundleManifest.ts +42 -37
- package/plugin/helpers/getRouteFiles.ts +47 -0
- package/plugin/helpers/inputNormalizer.ts +16 -10
- package/plugin/helpers/metrics.ts +64 -0
- package/plugin/helpers/resolvePageAndProps.ts +81 -0
- package/plugin/helpers/serializeUserOptions.ts +209 -0
- package/plugin/helpers/stashReturnValue.ts +16 -0
- package/plugin/helpers/tryManifest.ts +35 -18
- package/plugin/html.tsx +14 -3
- package/plugin/index.ts +5 -2
- package/plugin/loader/createBuildLoader.ts +152 -47
- package/plugin/loader/css-loader.development.ts +157 -0
- package/plugin/loader/css-loader.production.ts +86 -0
- package/plugin/loader/index.ts +1 -0
- package/plugin/loader/plugin.ts +33 -0
- package/plugin/loader/react-loader.ts +109 -41
- package/plugin/loader/temporaryReferences.ts +3 -0
- package/plugin/moduleRefs.ts +11 -0
- package/plugin/plugin.client.ts +12 -0
- package/plugin/plugin.server.ts +25 -0
- package/plugin/plugin.ts +5 -9
- package/plugin/preserver/plugin.ts +1 -1
- package/plugin/react-client/index.ts +1 -12
- package/plugin/react-client/plugin.ts +70 -259
- package/plugin/react-client/server.ts +276 -0
- package/plugin/react-server/index.ts +1 -14
- package/plugin/react-server/plugin.ts +69 -220
- package/plugin/react-server/server.ts +128 -0
- package/plugin/react-static/collectHtmlWorkerContent.ts +120 -0
- package/plugin/react-static/collectRscContent.ts +77 -0
- package/plugin/react-static/configurePreviewServer.ts +68 -0
- package/plugin/react-static/fileWriter.ts +103 -0
- package/plugin/react-static/plugin.ts +308 -181
- package/plugin/react-static/renderPage.ts +151 -0
- package/plugin/react-static/renderPages.ts +154 -0
- package/plugin/react-static/renderStreams.ts +48 -0
- package/plugin/react-static/rscToHtmlStream.ts +85 -0
- package/plugin/react-static/streamHandler.ts +0 -0
- package/plugin/react-static/types.ts +10 -0
- package/plugin/resolvePage.ts +67 -57
- package/plugin/resolveProps.ts +148 -104
- package/plugin/root.ts +1 -1
- package/plugin/transformer/index.ts +2 -1
- package/plugin/transformer/plugin.client.ts +109 -0
- package/plugin/transformer/plugin.server.ts +98 -0
- package/plugin/transformer/plugin.ts +2 -115
- package/plugin/transformer/upgradeCssModuleCode.ts +42 -0
- package/plugin/types/css-tracking.ts +5 -0
- package/plugin/types/react-server-dom-esm.d.ts +54 -0
- package/plugin/types.ts +508 -97
- package/plugin/vendor.client.ts +12 -0
- package/plugin/vendor.server.ts +12 -0
- package/plugin/worker/createWorker.ts +158 -53
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +112 -0
- package/plugin/worker/html/html-worker.development.tsx +5 -75
- package/plugin/worker/html/html-worker.production.tsx +18 -7
- package/plugin/worker/html/messageHandler.tsx +126 -0
- package/plugin/worker/html/types.ts +19 -0
- package/plugin/worker/registerLoaders.ts +54 -0
- package/plugin/worker/rsc/handleRender.ts +180 -0
- package/plugin/worker/rsc/messageHandler.tsx +58 -132
- package/plugin/worker/rsc/rsc-worker.development.ts +49 -63
- package/plugin/worker/rsc/rsc-worker.production.ts +5 -5
- package/plugin/worker/rsc/state.ts +79 -2
- package/plugin/worker/sendMessage.ts +49 -0
- package/plugin/worker/types.ts +299 -100
- package/scripts/check-react-version.mjs +60 -48
- package/scripts/react+0.0.0-experimental-0ca8420f-20250504.patch +57 -0
- package/scripts/react-dom+0.0.0-experimental-0ca8420f-20250504.patch +819 -0
- package/scripts/{react-server-dom-esm+0.0.0-experimental-eda36a1c-20250228.patch → react-server-dom-esm+0.0.0-experimental-0ca8420f-20250504.patch} +1702 -2820
- package/tsconfig.json +7 -2
- package/dist/plugin/assertServerCondition.d.ts +0 -6
- package/dist/plugin/assertServerCondition.d.ts.map +0 -1
- package/dist/plugin/assertServerCondition.js +0 -13
- package/dist/plugin/checkFilesExist.d.ts +0 -3
- package/dist/plugin/checkFilesExist.d.ts.map +0 -1
- package/dist/plugin/checkFilesExist.js +0 -67
- package/dist/plugin/checkFilesExist.js.map +0 -1
- package/dist/plugin/collect-manifest-client-files.d.ts +0 -23
- package/dist/plugin/collect-manifest-client-files.d.ts.map +0 -1
- package/dist/plugin/collect-manifest-client-files.js +0 -131
- package/dist/plugin/collect-manifest-client-files.js.map +0 -1
- package/dist/plugin/config/getWorkerPath.d.ts +0 -2
- package/dist/plugin/config/getWorkerPath.d.ts.map +0 -1
- package/dist/plugin/config/getWorkerPath.js +0 -4
- package/dist/plugin/copy-dir.d.ts +0 -4
- package/dist/plugin/copy-dir.d.ts.map +0 -1
- package/dist/plugin/copy-dir.js +0 -25
- package/dist/plugin/copy-dir.js.map +0 -1
- package/dist/plugin/css-collector-inline.d.ts +0 -10
- package/dist/plugin/css-collector-inline.d.ts.map +0 -1
- package/dist/plugin/css-collector-inline.js +0 -55
- package/dist/plugin/css-collector-inline.js.map +0 -1
- package/dist/plugin/loader/css-loader.d.ts +0 -16
- package/dist/plugin/loader/css-loader.d.ts.map +0 -1
- package/dist/plugin/loader/css-loader.js +0 -70
- package/dist/plugin/loader/css-loader.js.map +0 -1
- package/dist/plugin/react-client/index.js.map +0 -1
- package/dist/plugin/react-server/index.js.map +0 -1
- package/dist/plugin/worker/html/renderPages.d.ts +0 -26
- package/dist/plugin/worker/html/renderPages.d.ts.map +0 -1
- package/dist/plugin/worker/html/renderPages.js +0 -241
- package/dist/plugin/worker/html/renderPages.js.map +0 -1
- package/plugin/assertServerCondition.ts +0 -12
- package/plugin/checkFilesExist.ts +0 -66
- package/plugin/collect-manifest-client-files.ts +0 -167
- package/plugin/config/getWorkerPath.ts +0 -5
- package/plugin/copy-dir.ts +0 -27
- package/plugin/css-collector-inline.tsx +0 -60
- package/plugin/helpers/createRscStream.ts +0 -109
- package/plugin/loader/css-loader.ts +0 -94
- package/plugin/worker/html/messageHandler.ts +0 -130
- package/plugin/worker/html/renderPages.ts +0 -293
- package/scripts/react+0.0.0-experimental-eda36a1c-20250228.patch +0 -159
- package/scripts/react-dom+0.0.0-experimental-eda36a1c-20250228.patch +0 -12508
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBundleManifest.js","sources":["../../../plugin/helpers/getBundleManifest.ts"],"sourcesContent":["import type {\n OutputBundle,\n
|
|
1
|
+
{"version":3,"file":"getBundleManifest.js","sources":["../../../plugin/helpers/getBundleManifest.ts"],"sourcesContent":["import type {\n OutputBundle,\n OutputChunk,\n} from \"rollup\";\nimport type { ManifestChunk } from \"vite\";\nimport type { InputNormalizer } from \"../types.js\";\n\n\n/**\n * Get the bundle manifest from the plugin context. Will only work during production build\n * @param pluginContext - The plugin context\n * @param bundle - The bundle\n * @param preserveModulesRoot - The preserve modules root\n * @returns The bundle manifest\n */\nexport function getBundleManifest<SSR extends boolean>({\n bundle,\n normalizer,\n}: {\n bundle: OutputBundle,\n normalizer: InputNormalizer,\n}): SSR extends true ? Record<string, string[]> : {\n [key: string]: ManifestChunk & {\n source: string,\n }\n} {\n\n if (!bundle) return {};\n\n // Track virtual modules to prevent duplicates\n const virtualModules = new Map<string, string>();\n\n const bundleManifest = Object.fromEntries(\n Object.entries(bundle)\n .map(([originalFileName, chunk]) => {\n if(!originalFileName && 'file' in chunk) {\n return [\n chunk.file,\n {\n file: chunk.file,\n source: 'source' in chunk ? chunk.source : undefined,\n }\n ]\n }\n if (chunk.type === \"asset\") {\n return [\n originalFileName,\n {\n file: chunk.fileName,\n name: chunk.names[0],\n src: originalFileName,\n source: chunk.source,\n isEntry: chunk.needsCodeReference,\n }\n ]\n }\n const chunkWithFacade = chunk as OutputChunk;\n \n // Get the module ID, preferring facadeModuleId\n const moduleId = chunkWithFacade.facadeModuleId || chunkWithFacade.moduleIds[0] || originalFileName;\n \n // Handle commonjs helpers specially - must be done before normalization\n if (moduleId.includes('commonjsHelpers')) {\n return [\n moduleId,\n {\n file: 'commonjs-runtime.js',\n name: 'commonjsHelpers',\n src: moduleId,\n isEntry: false\n }\n ];\n }\n \n // Normalize both paths, removing the root prefix\n let [normalizedId, sourcePath] = normalizer(moduleId);\n\n // For virtual modules, use a consistent naming scheme\n let finalFileName = originalFileName;\n if (moduleId.includes('?')) {\n const [basePath, query] = moduleId.split('?');\n const virtualPath = basePath.includes('node_modules') \n ? basePath.split('node_modules/')[1] \n : basePath;\n \n // Create a unique key for this virtual module\n const virtualKey = `${virtualPath}?${query}`;\n \n if (!virtualModules.has(virtualKey)) {\n // First time seeing this virtual module\n const virtualFileName = query === 'inline' ? virtualPath : `${virtualPath}.${query}.js`;\n virtualModules.set(virtualKey, virtualFileName);\n }\n \n finalFileName = virtualModules.get(virtualKey)!;\n }\n\n // handle preserveModulesRoot\n if(normalizedId.startsWith('\\x00')){\n normalizedId = normalizedId.slice(1);\n }\n if(sourcePath.startsWith('/')){\n sourcePath = sourcePath.slice(1);\n }\n\n \n const withCss = chunk.viteMetadata?.importedCss?.size ? {\n css: Array.from(chunk.viteMetadata.importedCss),\n } : {};\n const bundleManifestEntry = [\n sourcePath,\n {\n file: finalFileName,\n name: normalizedId,\n src: sourcePath,\n isEntry: chunk.isEntry,\n ...(chunk.imports?.length > 0 ? { imports: chunk.imports } : {}),\n ...(chunk.dynamicImports?.length > 0 ? { dynamicImports: chunk.dynamicImports } : {}),\n ...withCss,\n },\n ];\n return bundleManifestEntry;\n })\n .filter(Boolean)\n );\n return bundleManifest;\n}\n"],"names":[],"mappings":";;;;;AAeO,SAAS,iBAAuC,CAAA;AAAA,EACrD,MAAA;AAAA,EACA;AACF,CAOE,EAAA;AAEA,EAAI,IAAA,CAAC,MAAQ,EAAA,OAAO,EAAC;AAGrB,EAAM,MAAA,cAAA,uBAAqB,GAAoB,EAAA;AAE/C,EAAA,MAAM,iBAAiB,MAAO,CAAA,WAAA;AAAA,IAC5B,MAAA,CAAO,QAAQ,MAAM,CAAA,CAClB,IAAI,CAAC,CAAC,gBAAkB,EAAA,KAAK,CAAM,KAAA;AAClC,MAAG,IAAA,CAAC,gBAAoB,IAAA,MAAA,IAAU,KAAO,EAAA;AACvC,QAAO,OAAA;AAAA,UACL,KAAM,CAAA,IAAA;AAAA,UACN;AAAA,YACE,MAAM,KAAM,CAAA,IAAA;AAAA,YACZ,MAAQ,EAAA,QAAA,IAAY,KAAQ,GAAA,KAAA,CAAM,MAAS,GAAA;AAAA;AAC7C,SACF;AAAA;AAEF,MAAI,IAAA,KAAA,CAAM,SAAS,OAAS,EAAA;AAC1B,QAAO,OAAA;AAAA,UACL,gBAAA;AAAA,UACA;AAAA,YACE,MAAM,KAAM,CAAA,QAAA;AAAA,YACZ,IAAA,EAAM,KAAM,CAAA,KAAA,CAAM,CAAC,CAAA;AAAA,YACnB,GAAK,EAAA,gBAAA;AAAA,YACL,QAAQ,KAAM,CAAA,MAAA;AAAA,YACd,SAAS,KAAM,CAAA;AAAA;AACjB,SACF;AAAA;AAEF,MAAA,MAAM,eAAkB,GAAA,KAAA;AAGxB,MAAA,MAAM,WAAW,eAAgB,CAAA,cAAA,IAAkB,eAAgB,CAAA,SAAA,CAAU,CAAC,CAAK,IAAA,gBAAA;AAGnF,MAAI,IAAA,QAAA,CAAS,QAAS,CAAA,iBAAiB,CAAG,EA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AAA,CAAM,YAAc,EAAA,WAAA,EAAa,IAAO,GAAA;AAAA,QACtD,GAAK,EAAA,KAAA,CAAM,IAAK,CAAA,KAAA,CAAM,aAAa,WAAW;AAAA,UAC5C,EAAC;AACL,MAAA,MAAM,mBAAsB,GAAA;AAAA,QAC1B,UAAA;AAAA,QACA;AAAA,UACE,IAAM,EAAA,aAAA;AAAA,UACN,IAAM,EAAA,YAAA;AAAA,UACN,GAAK,EAAA,UAAA;AAAA,UACL,SAAS,KAAM,CAAA,OAAA;AAAA,UACf,GAAI,KAAM,CAAA,OAAA,EAAS,MAAS,GAAA,CAAA,GAAI,EAAE,OAAS,EAAA,KAAA,CAAM,OAAQ,EAAA,GAAI,EAAC;AAAA,UAC9D,GAAI,KAAM,CAAA,cAAA,EAAgB,MAAS,GAAA,CAAA,GAAI,EAAE,cAAgB,EAAA,KAAA,CAAM,cAAe,EAAA,GAAI,EAAC;AAAA,UACnF,GAAG;AAAA;AACL,OACF;AACA,MAAO,OAAA,mBAAA;AAAA,KACR,CACA,CAAA,MAAA,CAAO,OAAO;AAAA,GACnB;AACA,EAAO,OAAA,cAAA;AACT;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ResolvedUserOptions } from "../types.js";
|
|
2
|
+
import type { AutoDiscoveredFiles } from "../types.js";
|
|
3
|
+
type GetRouteFilesSuccess = {
|
|
4
|
+
type: "success";
|
|
5
|
+
page: string;
|
|
6
|
+
props?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
type GetRouteFilesError = {
|
|
9
|
+
type: "error";
|
|
10
|
+
error: Error;
|
|
11
|
+
};
|
|
12
|
+
export declare const getRouteFiles: (route: string, autoDiscoveredFiles: AutoDiscoveredFiles, userOptions: ResolvedUserOptions) => Promise<GetRouteFilesSuccess | GetRouteFilesError>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=getRouteFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRouteFiles.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/getRouteFiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,aAAa,UACjB,MAAM,uBACQ,mBAAmB,eAC3B,mBAAmB,KAC/B,OAAO,CAAC,oBAAoB,GAAG,kBAAkB,CA0BnD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { resolveUrlOption } from '../config/resolveUrlOption.js';
|
|
7
|
+
|
|
8
|
+
const getRouteFiles = async (route, autoDiscoveredFiles, userOptions) => {
|
|
9
|
+
if (autoDiscoveredFiles.urlMap.has(route)) {
|
|
10
|
+
const { page, props: props2 } = autoDiscoveredFiles.urlMap.get(route);
|
|
11
|
+
return { type: "success", page, props: props2 };
|
|
12
|
+
}
|
|
13
|
+
const { type, error, Page } = await resolveUrlOption(
|
|
14
|
+
userOptions,
|
|
15
|
+
"Page",
|
|
16
|
+
route
|
|
17
|
+
);
|
|
18
|
+
if (type === "error") {
|
|
19
|
+
return { type: "error", error };
|
|
20
|
+
}
|
|
21
|
+
if (!userOptions.props) {
|
|
22
|
+
return { type: "success", page: Page, props: undefined };
|
|
23
|
+
}
|
|
24
|
+
const {
|
|
25
|
+
type: propsType,
|
|
26
|
+
error: propsError,
|
|
27
|
+
props
|
|
28
|
+
} = await resolveUrlOption(userOptions, "props", route);
|
|
29
|
+
if (propsType === "error") {
|
|
30
|
+
return { type: "error", error: propsError };
|
|
31
|
+
}
|
|
32
|
+
return { type: "success", page: Page, props };
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { getRouteFiles };
|
|
36
|
+
//# sourceMappingURL=getRouteFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRouteFiles.js","sources":["../../../plugin/helpers/getRouteFiles.ts"],"sourcesContent":["import type { ResolvedUserOptions } from \"../types.js\";\n\nimport { resolveUrlOption } from \"../config/resolveUrlOption.js\";\nimport type { AutoDiscoveredFiles } from \"../types.js\";\n\ntype GetRouteFilesSuccess = {\n type: \"success\";\n page: string;\n props?: string | undefined;\n};\n\ntype GetRouteFilesError = {\n type: \"error\";\n error: Error;\n};\n\nexport const getRouteFiles = async (\n route: string,\n autoDiscoveredFiles: AutoDiscoveredFiles,\n userOptions: ResolvedUserOptions\n): Promise<GetRouteFilesSuccess | GetRouteFilesError> => {\n if (autoDiscoveredFiles.urlMap.has(route)) {\n const { page, props } = autoDiscoveredFiles.urlMap.get(route)!;\n return { type: \"success\", page, props };\n }\n const { type, error, Page } = await resolveUrlOption(\n userOptions,\n \"Page\",\n route\n );\n if(type === \"error\") {\n return { type: \"error\", error };\n }\n if (!userOptions.props) {\n return { type: \"success\", page: Page, props: undefined };\n }\n const {\n type: propsType,\n error: propsError,\n props,\n } = await resolveUrlOption(userOptions, \"props\", route);\n\n if (propsType === \"error\") {\n return { type: \"error\", error: propsError };\n }\n return { type: \"success\", page: Page, props };\n};\n"],"names":["props"],"mappings":";;;;;;;AAgBO,MAAM,aAAgB,GAAA,OAC3B,KACA,EAAA,mBAAA,EACA,WACuD,KAAA;AACvD,EAAA,IAAI,mBAAoB,CAAA,MAAA,CAAO,GAAI,CAAA,KAAK,CAAG,EAAA;AACzC,IAAM,MAAA,EAAE,MAAM,KAAAA,EAAAA,MAAAA,KAAU,mBAAoB,CAAA,MAAA,CAAO,IAAI,KAAK,CAAA;AAC5D,IAAA,OAAO,EAAE,IAAA,EAAM,SAAW,EAAA,IAAA,EAAM,OAAAA,MAAM,EAAA;AAAA;AAExC,EAAA,MAAM,EAAE,IAAA,EAAM,KAAO,EAAA,IAAA,KAAS,MAAM,gBAAA;AAAA,IAClC,WAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,IAAG,SAAS,OAAS,EAAA;AACnB,IAAO,OAAA,EAAE,IAAM,EAAA,OAAA,EAAS,KAAM,EAAA;AAAA;AAEhC,EAAI,IAAA,CAAC,YAAY,KAAO,EAAA;AACtB,IAAA,OAAO,EAAE,IAAM,EAAA,SAAA,EAAW,IAAM,EAAA,IAAA,EAAM,OAAO,SAAU,EAAA;AAAA;AAEzD,EAAM,MAAA;AAAA,IACJ,IAAM,EAAA,SAAA;AAAA,IACN,KAAO,EAAA,UAAA;AAAA,IACP;AAAA,GACE,GAAA,MAAM,gBAAiB,CAAA,WAAA,EAAa,SAAS,KAAK,CAAA;AAEtD,EAAA,IAAI,cAAc,OAAS,EAAA;AACzB,IAAA,OAAO,EAAE,IAAA,EAAM,OAAS,EAAA,KAAA,EAAO,UAAW,EAAA;AAAA;AAE5C,EAAA,OAAO,EAAE,IAAA,EAAM,SAAW,EAAA,IAAA,EAAM,MAAM,KAAM,EAAA;AAC9C;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/inputNormalizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"inputNormalizer.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/inputNormalizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAMpE,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;CAC3E,CAAC;AAqHF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,mBAA+B,EAC/B,eAAiD,GAClD,EAAE,0BAA0B,GAAG,eAAe,CAgE9C"}
|
|
@@ -4,43 +4,44 @@
|
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
6
|
import { normalizePath } from 'vite';
|
|
7
|
-
import { join } from 'path';
|
|
7
|
+
import path, { join } from 'path';
|
|
8
8
|
import { DEFAULT_CONFIG } from '../config/defaults.js';
|
|
9
9
|
|
|
10
|
+
let stashedNormalizer = null;
|
|
10
11
|
const resolveExtensionOptions = (removeExtension) => {
|
|
11
12
|
if (typeof removeExtension === "boolean") {
|
|
12
13
|
if (removeExtension) {
|
|
13
|
-
return (
|
|
14
|
-
const extensionIndex =
|
|
15
|
-
return extensionIndex !== -1 ?
|
|
14
|
+
return (path2) => {
|
|
15
|
+
const extensionIndex = path2.lastIndexOf(".");
|
|
16
|
+
return extensionIndex !== -1 ? path2.slice(0, extensionIndex) : path2;
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
return (
|
|
19
|
+
return (path2) => path2;
|
|
19
20
|
}
|
|
20
21
|
if (typeof removeExtension === "string") {
|
|
21
|
-
return (
|
|
22
|
+
return (path2) => path2.replace(removeExtension, "");
|
|
22
23
|
}
|
|
23
24
|
if (removeExtension instanceof RegExp) {
|
|
24
|
-
return (
|
|
25
|
+
return (path2) => removeExtension.test(path2) ? path2.replace(removeExtension, "") : path2;
|
|
25
26
|
}
|
|
26
27
|
if (typeof removeExtension === "function") {
|
|
27
|
-
return (
|
|
28
|
-
const extIndex =
|
|
28
|
+
return (path2) => {
|
|
29
|
+
const extIndex = path2.lastIndexOf(".");
|
|
29
30
|
if (extIndex !== -1) {
|
|
30
|
-
const extension =
|
|
31
|
+
const extension = path2.slice(extIndex);
|
|
31
32
|
if (removeExtension(extension)) {
|
|
32
|
-
return
|
|
33
|
+
return path2.slice(0, extIndex);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
return
|
|
36
|
+
return path2;
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
|
-
return (
|
|
39
|
+
return (path2) => path2;
|
|
39
40
|
};
|
|
40
41
|
const resolveRootOption = (root, preserveModulesRoot) => {
|
|
41
42
|
if (typeof preserveModulesRoot === "string" && typeof root === "string") {
|
|
42
43
|
const normalizedPreserveModulesRoot = normalizePath(preserveModulesRoot);
|
|
43
|
-
if (normalizedPreserveModulesRoot.startsWith(root)) {
|
|
44
|
+
if (root !== "" && normalizedPreserveModulesRoot.startsWith(root)) {
|
|
44
45
|
return normalizedPreserveModulesRoot.slice(root.length + 1);
|
|
45
46
|
}
|
|
46
47
|
return "";
|
|
@@ -57,8 +58,9 @@ const createKeyNormalizer = ({
|
|
|
57
58
|
const virtualPrefix = key.match(/^\0+/)?.[0] || "";
|
|
58
59
|
const actualKey = key.slice(virtualPrefix.length);
|
|
59
60
|
let moduleId = normalizePath(actualKey);
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
const normalizedRootPath = normalizePath(normalizedRoot);
|
|
62
|
+
if (moduleId.startsWith(normalizedRootPath)) {
|
|
63
|
+
moduleId = moduleId.slice(normalizedRootPath.length);
|
|
62
64
|
}
|
|
63
65
|
moduleId = handleExtension(moduleId);
|
|
64
66
|
while (moduleId.startsWith("/") || moduleId.startsWith(".")) {
|
|
@@ -68,18 +70,18 @@ const createKeyNormalizer = ({
|
|
|
68
70
|
moduleId = moduleId.slice(0, -1);
|
|
69
71
|
}
|
|
70
72
|
if (typeof preserveModulesRoot === "string" && preserveModulesRoot !== "") {
|
|
71
|
-
moduleId = moduleId.startsWith(preserveModulesRoot) ? moduleId.slice(preserveModulesRoot.length) : moduleId;
|
|
73
|
+
moduleId = moduleId.startsWith(preserveModulesRoot) ? moduleId.slice(preserveModulesRoot.length + path.sep.length) : moduleId;
|
|
72
74
|
}
|
|
73
75
|
return virtualPrefix + moduleId;
|
|
74
76
|
};
|
|
75
77
|
const createPathNormalizer = ({
|
|
76
78
|
root,
|
|
77
79
|
preserveModulesRoot
|
|
78
|
-
}) => (
|
|
79
|
-
if (typeof
|
|
80
|
-
throw new Error(`Invalid path: ${JSON.stringify(
|
|
80
|
+
}) => (path2) => {
|
|
81
|
+
if (typeof path2 !== "string") {
|
|
82
|
+
throw new Error(`Invalid path: ${JSON.stringify(path2)}`);
|
|
81
83
|
}
|
|
82
|
-
let normalPath = normalizePath(
|
|
84
|
+
let normalPath = normalizePath(path2);
|
|
83
85
|
if (normalPath.startsWith(root)) {
|
|
84
86
|
normalPath = normalPath.slice(root.length);
|
|
85
87
|
}
|
|
@@ -94,13 +96,16 @@ const createPathNormalizer = ({
|
|
|
94
96
|
function createInputNormalizer({
|
|
95
97
|
root,
|
|
96
98
|
preserveModulesRoot = undefined,
|
|
97
|
-
removeExtension = DEFAULT_CONFIG.
|
|
99
|
+
removeExtension = DEFAULT_CONFIG.MODULE_EXTENSION
|
|
98
100
|
}) {
|
|
101
|
+
if (stashedNormalizer) {
|
|
102
|
+
return stashedNormalizer;
|
|
103
|
+
}
|
|
99
104
|
const relativeRoot = resolveRootOption(root, preserveModulesRoot);
|
|
100
105
|
const handleExtension = resolveExtensionOptions(removeExtension);
|
|
101
106
|
const normalizeEntryKey = createKeyNormalizer({
|
|
102
107
|
root,
|
|
103
|
-
preserveModulesRoot
|
|
108
|
+
preserveModulesRoot,
|
|
104
109
|
handleExtension
|
|
105
110
|
});
|
|
106
111
|
const normalizeEntryPath = createPathNormalizer({
|
|
@@ -109,18 +114,18 @@ function createInputNormalizer({
|
|
|
109
114
|
});
|
|
110
115
|
function normalizeInput(id) {
|
|
111
116
|
if (Array.isArray(id)) {
|
|
112
|
-
const [key,
|
|
113
|
-
if (typeof key === "string" && Array.isArray(
|
|
117
|
+
const [key, path2] = id;
|
|
118
|
+
if (typeof key === "string" && Array.isArray(path2) && path2.length === 2) {
|
|
114
119
|
const isNumber = !isNaN(Number(key));
|
|
115
120
|
if (isNumber) {
|
|
116
|
-
return normalizeInput([
|
|
121
|
+
return normalizeInput([path2[0], path2[1]]);
|
|
117
122
|
}
|
|
118
|
-
return normalizeInput([join(key,
|
|
123
|
+
return normalizeInput([join(key, path2[0]), path2[1]]);
|
|
119
124
|
}
|
|
120
|
-
if (typeof key !== "string" || typeof
|
|
125
|
+
if (typeof key !== "string" || typeof path2 !== "string") {
|
|
121
126
|
throw new Error(`Invalid input: ${JSON.stringify(id)}`);
|
|
122
127
|
}
|
|
123
|
-
return [normalizeEntryKey(key), normalizeEntryPath(
|
|
128
|
+
return [normalizeEntryKey(key), normalizeEntryPath(path2)];
|
|
124
129
|
} else if (typeof id === "string") {
|
|
125
130
|
return [normalizeEntryKey(id), normalizeEntryPath(id)];
|
|
126
131
|
} else if (typeof id === "object" && id !== null && "$$typeof" in id && "$$id" in id && typeof id.$$id === "string") {
|
|
@@ -132,13 +137,14 @@ function createInputNormalizer({
|
|
|
132
137
|
}
|
|
133
138
|
throw new Error(`Invalid input type: ${typeof id}`);
|
|
134
139
|
}
|
|
135
|
-
|
|
136
|
-
const [key,
|
|
137
|
-
const normalizedPath =
|
|
140
|
+
stashedNormalizer = (input) => {
|
|
141
|
+
const [key, path2] = normalizeInput(input);
|
|
142
|
+
const normalizedPath = path2.startsWith("/") ? path2.slice(1) : path2;
|
|
138
143
|
const virtualPrefix = key.match(/^\0+/)?.[0] || "";
|
|
139
144
|
const finalPath = virtualPrefix ? normalizedPath.startsWith(virtualPrefix) ? normalizedPath : virtualPrefix + normalizedPath : normalizedPath;
|
|
140
145
|
return [key, finalPath];
|
|
141
146
|
};
|
|
147
|
+
return stashedNormalizer;
|
|
142
148
|
}
|
|
143
149
|
|
|
144
150
|
export { createInputNormalizer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputNormalizer.js","sources":["../../../plugin/helpers/inputNormalizer.ts"],"sourcesContent":["import { normalizePath } from \"vite\";\nimport type { InputNormalizer, NormalizerInput } from \"../types.js\";\nimport { join } from \"path\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\n\ntype CreateInputNormalizerProps = {\n root: string;\n preserveModulesRoot?: string | undefined;\n removeExtension?: boolean | RegExp | string | ((path: string) => boolean);\n};\n\nconst resolveExtensionOptions = (\n removeExtension: CreateInputNormalizerProps[\"removeExtension\"]\n) => {\n if (typeof removeExtension === \"boolean\") {\n if (removeExtension) {\n return (path: string) => {\n const extensionIndex = path.lastIndexOf(\".\");\n return extensionIndex !== -1 ? path.slice(0, extensionIndex) : path;\n };\n }\n return (path: string) => path;\n }\n if (typeof removeExtension === \"string\") {\n return (path: string) => path.replace(removeExtension, \"\");\n }\n if (removeExtension instanceof RegExp) {\n return (path: string) =>\n removeExtension.test(path) ? path.replace(removeExtension, \"\") : path;\n }\n if (typeof removeExtension === \"function\") {\n return (path: string) => {\n const extIndex = path.lastIndexOf(\".\");\n if (extIndex !== -1) {\n const extension = path.slice(extIndex);\n if (removeExtension(extension)) {\n return path.slice(0, extIndex);\n }\n }\n return path;\n };\n }\n return (path: string) => path;\n};\n\nconst resolveRootOption = (\n root: CreateInputNormalizerProps[\"root\"],\n preserveModulesRoot: CreateInputNormalizerProps[\"preserveModulesRoot\"]\n) => {\n if (typeof preserveModulesRoot === \"string\" && typeof root === \"string\") {\n const normalizedPreserveModulesRoot = normalizePath(preserveModulesRoot);\n if (normalizedPreserveModulesRoot.startsWith(root)) {\n return normalizedPreserveModulesRoot.slice(root.length + 1);\n }\n return \"\";\n } else if (typeof preserveModulesRoot === \"string\" && typeof root !== \"string\") {\n return normalizePath(preserveModulesRoot);\n }\n return \"\";\n};\nconst createKeyNormalizer =\n ({\n root: normalizedRoot,\n preserveModulesRoot,\n handleExtension,\n }: {\n root: string;\n preserveModulesRoot: string | undefined;\n handleExtension: (path: string) => string;\n }) =>\n (key: string) => {\n // Handle virtual modules first\n const virtualPrefix = key.match(/^\\0+/)?.[0] || '';\n const actualKey = key.slice(virtualPrefix.length);\n \n let moduleId = normalizePath(actualKey);\n \n if (moduleId.startsWith(normalizedRoot)) {\n moduleId = moduleId.slice(normalizedRoot.length);\n }\n\n moduleId = handleExtension(moduleId);\n while (moduleId.startsWith(\"/\") || moduleId.startsWith(\".\")) {\n moduleId = moduleId.slice(1);\n }\n while (moduleId.endsWith(\"/\")) {\n moduleId = moduleId.slice(0, -1);\n }\n if (typeof preserveModulesRoot === \"string\" && preserveModulesRoot !== \"\") {\n moduleId = moduleId.startsWith(preserveModulesRoot)\n ? moduleId.slice(preserveModulesRoot.length)\n : moduleId;\n }\n \n // Add virtual prefix back\n return virtualPrefix + moduleId;\n };\n\nconst createPathNormalizer =\n ({\n root,\n preserveModulesRoot,\n }: {\n root: string;\n preserveModulesRoot: string | undefined;\n }) =>\n (path: string) => {\n if (typeof path !== \"string\") {\n throw new Error(`Invalid path: ${JSON.stringify(path)}`);\n }\n let normalPath = normalizePath(path);\n if(normalPath.startsWith(root)) {\n normalPath = normalPath.slice(root.length);\n }\n if (typeof preserveModulesRoot === \"string\" && preserveModulesRoot !== \"\") {\n normalPath = normalPath.startsWith(preserveModulesRoot)\n ? normalPath.slice(preserveModulesRoot.length)\n : normalPath;\n }\n while (normalPath.endsWith(\"/\")) {\n normalPath = normalPath.slice(0, -1);\n }\n return normalPath;\n };\n/**\n * @description Create a function that normalizes the input\n * @param root - The root of the project\n * @param preserveModulesRoot - The root of the preserve modules\n * @param removeExtension - Whether to remove the extension of the file\n * @returns A function that normalizes the input\n */\nexport function createInputNormalizer({\n root,\n preserveModulesRoot = undefined,\n removeExtension = DEFAULT_CONFIG.FILE_REGEX,\n}: CreateInputNormalizerProps): InputNormalizer {\n const relativeRoot = resolveRootOption(root, preserveModulesRoot);\n const handleExtension = resolveExtensionOptions(removeExtension);\n\n const normalizeEntryKey = createKeyNormalizer({\n root: root,\n preserveModulesRoot: relativeRoot,\n handleExtension,\n });\n\n const normalizeEntryPath = createPathNormalizer({\n root: root,\n preserveModulesRoot: relativeRoot,\n });\n function normalizeInput(id: NormalizerInput): [string, string] {\n // Normalize both paths to use POSIX separators\n if (Array.isArray(id)) {\n const [key, path] = id;\n if (typeof key === \"string\" && Array.isArray(path) && path.length === 2) {\n const isNumber = !isNaN(Number(key));\n if (isNumber) {\n // ignore it\n return normalizeInput([path[0], path[1]]);\n }\n return normalizeInput([join(key, path[0]), path[1]]);\n }\n if (typeof key !== \"string\" || typeof path !== \"string\") {\n throw new Error(`Invalid input: ${JSON.stringify(id)}`);\n }\n return [normalizeEntryKey(key), normalizeEntryPath(path)];\n } else if (typeof id === \"string\") {\n // Return both the normalized ID and original normalized path\n return [normalizeEntryKey(id), normalizeEntryPath(id)];\n } else if (\n typeof id === \"object\" &&\n id !== null &&\n \"$$typeof\" in id &&\n \"$$id\" in id &&\n typeof id.$$id === \"string\"\n ) {\n const normalized: [string, string] = [\n normalizeEntryKey(id.$$id),\n normalizeEntryPath(id.$$id),\n ];\n return normalized;\n }\n throw new Error(`Invalid input type: ${typeof id}`);\n };\n\n return (input: NormalizerInput): [string, string] => {\n const [key, path] = normalizeInput(input);\n // Apply the same normalization to both key and path\n const normalizedPath = path.startsWith('/') ? path.slice(1) : path;\n const virtualPrefix = key.match(/^\\0+/)?.[0] || '';\n \n // If key has virtual prefix, ensure path has it too\n const finalPath = virtualPrefix ? \n (normalizedPath.startsWith(virtualPrefix) ? normalizedPath : virtualPrefix + normalizedPath) : \n normalizedPath;\n \n return [key, finalPath];\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAWA,MAAM,uBAAA,GAA0B,CAC9B,eACG,KAAA;AACH,EAAI,IAAA,OAAO,oBAAoB,SAAW,EAAA;AACxC,IAAA,IAAI,eAAiB,EAAA;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,CAAG,EAAA,kBAAA,CAAmB,EAAE,CAAC,CAAA;AAAA,KAErD,MAAA,IAAA,OAAO,EAAO,KAAA,QAAA,IACd,EAAO,KAAA,IAAA,IACP,UAAc,IAAA,EAAA,IACd,MAAU,IAAA,EAAA,IACV,OAAO,EAAA,CAAG,SAAS,QACnB,EAAA;AACA,MAAA,MAAM,UAA+B,GAAA;AAAA,QACnC,iBAAA,CAAkB,GAAG,IAAI,CAAA;AAAA,QACzB,kBAAA,CAAmB,GAAG,IAAI;AAAA,OAC5B;AACA,MAAO,OAAA,UAAA;AAAA;AAET,IAAA,MAAM,IAAI,KAAA,CAAM,CAAuB,oBAAA,EAAA,OAAO,EAAE,CAAE,CAAA,CAAA;AAAA;AAGpD,EAAA,OAAO,CAAC,KAA6C,KAAA;AACnD,IAAA,MAAM,CAAC,GAAA,EAAK,IAAI,CAAA,GAAI,eAAe,KAAK,CAAA;AAExC,IAAM,MAAA,cAAA,GAAiB,KAAK,UAAW,CAAA,GAAG,IAAI,IAAK,CAAA,KAAA,CAAM,CAAC,CAAI,GAAA,IAAA;AAC9D,IAAA,MAAM,gBAAgB,GAAI,CAAA,KAAA,CAAM,MAAM,CAAA,GAAI,CAAC,CAAK,IAAA,EAAA;AAGhD,IAAM,MAAA,SAAA,GAAY,gBACf,cAAe,CAAA,UAAA,CAAW,aAAa,CAAI,GAAA,cAAA,GAAiB,gBAAgB,cAC7E,GAAA,cAAA;AAEF,IAAO,OAAA,CAAC,KAAK,SAAS,CAAA;AAAA,GACxB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"inputNormalizer.js","sources":["../../../plugin/helpers/inputNormalizer.ts"],"sourcesContent":["import { normalizePath } from \"vite\";\nimport type { InputNormalizer, NormalizerInput } from \"../types.js\";\nimport path, { join } from \"path\";\nimport { DEFAULT_CONFIG } from \"../config/defaults.js\";\n\nlet stashedNormalizer: InputNormalizer | null = null;\n\ntype CreateInputNormalizerProps = {\n root: string;\n preserveModulesRoot?: string | undefined;\n removeExtension?: boolean | RegExp | string | ((path: string) => boolean);\n};\n\nconst resolveExtensionOptions = (\n removeExtension: CreateInputNormalizerProps[\"removeExtension\"]\n) => {\n if (typeof removeExtension === \"boolean\") {\n if (removeExtension) {\n return (path: string) => {\n const extensionIndex = path.lastIndexOf(\".\");\n return extensionIndex !== -1 ? path.slice(0, extensionIndex) : path;\n };\n }\n return (path: string) => path;\n }\n if (typeof removeExtension === \"string\") {\n return (path: string) => path.replace(removeExtension, \"\");\n }\n if (removeExtension instanceof RegExp) {\n return (path: string) =>\n removeExtension.test(path) ? path.replace(removeExtension, \"\") : path;\n }\n if (typeof removeExtension === \"function\") {\n return (path: string) => {\n const extIndex = path.lastIndexOf(\".\");\n if (extIndex !== -1) {\n const extension = path.slice(extIndex);\n if (removeExtension(extension)) {\n return path.slice(0, extIndex);\n }\n }\n return path;\n };\n }\n return (path: string) => path;\n};\n\nconst resolveRootOption = (\n root: CreateInputNormalizerProps[\"root\"],\n preserveModulesRoot: CreateInputNormalizerProps[\"preserveModulesRoot\"]\n) => {\n if (typeof preserveModulesRoot === \"string\" && typeof root === \"string\") {\n const normalizedPreserveModulesRoot = normalizePath(preserveModulesRoot);\n if (root !== \"\" && normalizedPreserveModulesRoot.startsWith(root)) {\n return normalizedPreserveModulesRoot.slice(root.length + 1);\n }\n return \"\";\n } else if (typeof preserveModulesRoot === \"string\" && typeof root !== \"string\") {\n return normalizePath(preserveModulesRoot);\n }\n return \"\";\n};\nconst createKeyNormalizer =\n ({\n root: normalizedRoot,\n preserveModulesRoot,\n handleExtension,\n }: {\n root: string;\n preserveModulesRoot: string | undefined;\n handleExtension: (path: string) => string;\n }) =>\n (key: string) => {\n // Handle virtual modules first\n const virtualPrefix = key.match(/^\\0+/)?.[0] || '';\n const actualKey = key.slice(virtualPrefix.length);\n \n let moduleId = normalizePath(actualKey);\n \n // Normalize root path to handle both absolute and relative paths\n const normalizedRootPath = normalizePath(normalizedRoot);\n if (moduleId.startsWith(normalizedRootPath)) {\n moduleId = moduleId.slice(normalizedRootPath.length);\n }\n\n moduleId = handleExtension(moduleId);\n while (moduleId.startsWith(\"/\") || moduleId.startsWith(\".\")) {\n moduleId = moduleId.slice(1);\n }\n while (moduleId.endsWith(\"/\")) {\n moduleId = moduleId.slice(0, -1);\n }\n if (typeof preserveModulesRoot === \"string\" && preserveModulesRoot !== \"\") {\n moduleId = moduleId.startsWith(preserveModulesRoot)\n ? moduleId.slice(preserveModulesRoot.length + path.sep.length)\n : moduleId;\n }\n \n // Add virtual prefix back\n return virtualPrefix + moduleId;\n };\n\nconst createPathNormalizer =\n ({\n root,\n preserveModulesRoot,\n }: {\n root: string;\n preserveModulesRoot: string | undefined;\n }) =>\n (path: string) => {\n if (typeof path !== \"string\") {\n throw new Error(`Invalid path: ${JSON.stringify(path)}`);\n }\n let normalPath = normalizePath(path);\n if(normalPath.startsWith(root)) {\n normalPath = normalPath.slice(root.length);\n }\n if (typeof preserveModulesRoot === \"string\" && preserveModulesRoot !== \"\") {\n normalPath = normalPath.startsWith(preserveModulesRoot)\n ? normalPath.slice(preserveModulesRoot.length)\n : normalPath;\n }\n while (normalPath.endsWith(\"/\")) {\n normalPath = normalPath.slice(0, -1);\n }\n return normalPath;\n };\n/**\n * @description Create a function that normalizes the input\n * @param root - The root of the project\n * @param preserveModulesRoot - The root of the preserve modules\n * @param removeExtension - Whether to remove the extension of the file\n * @returns A function that normalizes the input\n */\nexport function createInputNormalizer({\n root,\n preserveModulesRoot = undefined,\n removeExtension = DEFAULT_CONFIG.MODULE_EXTENSION,\n}: CreateInputNormalizerProps): InputNormalizer {\n if(stashedNormalizer) {\n return stashedNormalizer;\n }\n const relativeRoot = resolveRootOption(root, preserveModulesRoot);\n const handleExtension = resolveExtensionOptions(removeExtension);\n const normalizeEntryKey = createKeyNormalizer({\n root: root,\n preserveModulesRoot: preserveModulesRoot,\n handleExtension,\n });\n const normalizeEntryPath = createPathNormalizer({\n root: root,\n preserveModulesRoot: relativeRoot,\n });\n function normalizeInput(id: NormalizerInput): [string, string] {\n // Normalize both paths to use POSIX separators\n if (Array.isArray(id)) {\n const [key, path] = id;\n if (typeof key === \"string\" && Array.isArray(path) && path.length === 2) {\n const isNumber = !isNaN(Number(key));\n if (isNumber) {\n // ignore it\n return normalizeInput([path[0], path[1]]);\n }\n return normalizeInput([join(key, path[0]), path[1]]);\n }\n if (typeof key !== \"string\" || typeof path !== \"string\") {\n throw new Error(`Invalid input: ${JSON.stringify(id)}`);\n }\n return [normalizeEntryKey(key), normalizeEntryPath(path)];\n } else if (typeof id === \"string\") {\n // Return both the normalized ID and original normalized path\n return [normalizeEntryKey(id), normalizeEntryPath(id)];\n } else if (\n typeof id === \"object\" &&\n id !== null &&\n \"$$typeof\" in id &&\n \"$$id\" in id &&\n typeof id.$$id === \"string\"\n ) {\n const normalized: [string, string] = [\n normalizeEntryKey(id.$$id),\n normalizeEntryPath(id.$$id),\n ];\n return normalized;\n }\n throw new Error(`Invalid input type: ${typeof id}`);\n };\n\n stashedNormalizer = (input: NormalizerInput): [string, string] => {\n const [key, path] = normalizeInput(input);\n // Apply the same normalization to both key and path\n const normalizedPath = path.startsWith('/') ? path.slice(1) : path;\n const virtualPrefix = key.match(/^\\0+/)?.[0] || '';\n \n // If key has virtual prefix, ensure path has it too\n const finalPath = virtualPrefix ? \n (normalizedPath.startsWith(virtualPrefix) ? normalizedPath : virtualPrefix + normalizedPath) : \n normalizedPath;\n \n return [key, finalPath];\n };\n return stashedNormalizer;\n}\n"],"names":["path"],"mappings":";;;;;;;;;AAKA,IAAI,iBAA4C,GAAA,IAAA;AAQhD,MAAM,uBAAA,GAA0B,CAC9B,eACG,KAAA;AACH,EAAI,IAAA,OAAO,oBAAoB,SAAW,EAAA;AACxC,IAAA,IAAI,eAAiB,EAAA;AACnB,MAAA,OAAO,CAACA,KAAiB,KAAA;AACvB,QAAM,MAAA,cAAA,GAAiBA,KAAK,CAAA,WAAA,CAAY,GAAG,CAAA;AAC3C,QAAA,OAAO,mBAAmB,EAAKA,G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1D,MAAA,IAAW,OAAO,EAAA,KAAO,QAAU,EAAA;AAEjC,MAAA,OAAO,CAAC,iBAAkB,CAAA,EAAE,CAAG,EAAA,kBAAA,CAAmB,EAAE,CAAC,CAAA;AAAA,KAErD,MAAA,IAAA,OAAO,EAAO,KAAA,QAAA,IACd,EAAO,KAAA,IAAA,IACP,UAAc,IAAA,EAAA,IACd,MAAU,IAAA,EAAA,IACV,OAAO,EAAA,CAAG,SAAS,QACnB,EAAA;AACA,MAAA,MAAM,UAA+B,GAAA;AAAA,QACnC,iBAAA,CAAkB,GAAG,IAAI,CAAA;AAAA,QACzB,kBAAA,CAAmB,GAAG,IAAI;AAAA,OAC5B;AACA,MAAO,OAAA,UAAA;AAAA;AAET,IAAA,MAAM,IAAI,KAAA,CAAM,CAAuB,oBAAA,EAAA,OAAO,EAAE,CAAE,CAAA,CAAA;AAAA;AAGpD,EAAA,iBAAA,GAAoB,CAAC,KAA6C,KAAA;AAChE,IAAA,MAAM,CAAC,GAAA,EAAKA,KAAI,CAAA,GAAI,eAAe,KAAK,CAAA;AAExC,IAAM,MAAA,cAAA,GAAiBA,MAAK,UAAW,CAAA,GAAG,IAAIA,KAAK,CAAA,KAAA,CAAM,CAAC,CAAIA,GAAAA,KAAAA;AAC9D,IAAA,MAAM,gBAAgB,GAAI,CAAA,KAAA,CAAM,MAAM,CAAA,GAAI,CAAC,CAAK,IAAA,EAAA;AAGhD,IAAM,MAAA,SAAA,GAAY,gBACf,cAAe,CAAA,UAAA,CAAW,aAAa,CAAI,GAAA,cAAA,GAAiB,gBAAgB,cAC7E,GAAA,cAAA;AAEF,IAAO,OAAA,CAAC,KAAK,SAAS,CAAA;AAAA,GACxB;AACA,EAAO,OAAA,iBAAA;AACT;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StreamMetrics, RenderMetrics } from "../types.js";
|
|
2
|
+
import type { PipeableStream } from "react-dom/server";
|
|
3
|
+
export declare function createStreamMetrics(): StreamMetrics;
|
|
4
|
+
export declare function createRenderMetrics(route: string): RenderMetrics;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a transform stream that collects metrics from the input stream
|
|
7
|
+
* @param stream The stream to collect metrics from
|
|
8
|
+
* @returns A promise that resolves with the metrics when the stream ends
|
|
9
|
+
*/
|
|
10
|
+
export declare function collectStreamMetrics(stream: PipeableStream | NodeJS.ReadableStream): Promise<StreamMetrics>;
|
|
11
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/metrics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,wBAAgB,mBAAmB,IAAI,aAAa,CAUnD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAahE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CA2B3G"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import 'node:stream';
|
|
7
|
+
|
|
8
|
+
function createStreamMetrics() {
|
|
9
|
+
return {
|
|
10
|
+
chunks: 0,
|
|
11
|
+
bytes: 0,
|
|
12
|
+
backpressureCount: 0,
|
|
13
|
+
drainCount: 0,
|
|
14
|
+
errorCount: 0,
|
|
15
|
+
duration: 0,
|
|
16
|
+
startTime: performance.now()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function createRenderMetrics(route) {
|
|
20
|
+
return {
|
|
21
|
+
route,
|
|
22
|
+
htmlSize: 0,
|
|
23
|
+
rscSize: 0,
|
|
24
|
+
processingTime: 0,
|
|
25
|
+
chunks: 0,
|
|
26
|
+
chunkRate: 0,
|
|
27
|
+
memoryUsage: process.memoryUsage(),
|
|
28
|
+
streamMetrics: createStreamMetrics(),
|
|
29
|
+
htmlSizes: /* @__PURE__ */ new Map(),
|
|
30
|
+
rscSizes: /* @__PURE__ */ new Map()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { createRenderMetrics, createStreamMetrics };
|
|
35
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sources":["../../../plugin/helpers/metrics.ts"],"sourcesContent":["import { Transform } from \"node:stream\";\nimport type { StreamMetrics, RenderMetrics } from \"../types.js\";\nimport type { PipeableStream } from \"react-dom/server\";\n\nexport function createStreamMetrics(): StreamMetrics {\n return {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount: 0,\n duration: 0,\n startTime: performance.now()\n };\n}\n\nexport function createRenderMetrics(route: string): RenderMetrics {\n return {\n route,\n htmlSize: 0,\n rscSize: 0,\n processingTime: 0,\n chunks: 0,\n chunkRate: 0,\n memoryUsage: process.memoryUsage(),\n streamMetrics: createStreamMetrics(),\n htmlSizes: new Map(),\n rscSizes: new Map(),\n };\n}\n\n/**\n * Creates a transform stream that collects metrics from the input stream\n * @param stream The stream to collect metrics from\n * @returns A promise that resolves with the metrics when the stream ends\n */\nexport function collectStreamMetrics(stream: PipeableStream | NodeJS.ReadableStream): Promise<StreamMetrics> {\n const metrics = createStreamMetrics();\n const startTime = performance.now()\n\n return new Promise<StreamMetrics>((resolve, reject) => {\n const transform = new Transform({\n transform(chunk, _encoding, callback) {\n metrics.chunks++;\n metrics.bytes += chunk.length;\n callback(null, chunk);\n },\n flush(callback) {\n metrics.duration = Date.now() - startTime;\n callback();\n }\n });\n\n stream.pipe(transform);\n\n transform.on(\"error\", (error) => {\n reject(error);\n });\n\n transform.on(\"end\", () => {\n resolve(metrics);\n });\n });\n} "],"names":[],"mappings":";;;;;;;AAIO,SAAS,mBAAqC,GAAA;AACnD,EAAO,OAAA;AAAA,IACL,MAAQ,EAAA,CAAA;AAAA,IACR,KAAO,EAAA,CAAA;AAAA,IACP,iBAAmB,EAAA,CAAA;AAAA,IACnB,UAAY,EAAA,CAAA;AAAA,IACZ,UAAY,EAAA,CAAA;AAAA,IACZ,QAAU,EAAA,CAAA;AAAA,IACV,SAAA,EAAW,YAAY,GAAI;AAAA,GAC7B;AACF;AAEO,SAAS,oBAAoB,KAA8B,EAAA;AAChE,EAAO,OAAA;AAAA,IACL,KAAA;AAAA,IACA,QAAU,EAAA,CAAA;AAAA,IACV,OAAS,EAAA,CAAA;AAAA,IACT,cAAgB,EAAA,CAAA;AAAA,IAChB,MAAQ,EAAA,CAAA;AAAA,IACR,SAAW,EAAA,CAAA;AAAA,IACX,WAAA,EAAa,QAAQ,WAAY,EAAA;AAAA,IACjC,eAAe,mBAAoB,EAAA;AAAA,IACnC,SAAA,sBAAe,GAAI,EAAA;AAAA,IACnB,QAAA,sBAAc,GAAI;AAAA,GACpB;AACF;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type ResolvePageAndPropsOptions<N1 extends string, N2 extends string> = {
|
|
2
|
+
pagePath: string;
|
|
3
|
+
pageExportName: N1;
|
|
4
|
+
propsPath?: string;
|
|
5
|
+
propsExportName?: N2;
|
|
6
|
+
route: string;
|
|
7
|
+
loader: (id: string) => Promise<any>;
|
|
8
|
+
};
|
|
9
|
+
type ResolvePageAndPropsResult<T> = {
|
|
10
|
+
type: "success";
|
|
11
|
+
error?: never;
|
|
12
|
+
PageComponent: React.ComponentType<T>;
|
|
13
|
+
pageProps: T;
|
|
14
|
+
} | {
|
|
15
|
+
type: "error";
|
|
16
|
+
error: Error;
|
|
17
|
+
PageComponent?: never;
|
|
18
|
+
pageProps?: never;
|
|
19
|
+
} | {
|
|
20
|
+
type: "skip";
|
|
21
|
+
error?: never;
|
|
22
|
+
PageComponent?: never;
|
|
23
|
+
pageProps?: never;
|
|
24
|
+
};
|
|
25
|
+
export declare function resolvePageAndProps<T, N1 extends string, N2 extends string>(handlerOptions: ResolvePageAndPropsOptions<N1, N2>): Promise<ResolvePageAndPropsResult<T>>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=resolvePageAndProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvePageAndProps.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/resolvePageAndProps.ts"],"names":[],"mappings":"AAGA,KAAK,0BAA0B,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,IAAI;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACtC,CAAC;AAEF,KAAK,yBAAyB,CAAC,CAAC,IAC5B;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACtC,SAAS,EAAE,CAAC,CAAC;CACd,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,aAAa,CAAC,EAAE,KAAK,CAAC;IACtB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,CAAC;AAEN,wBAAsB,mBAAmB,CACvC,CAAC,EACD,EAAE,SAAS,MAAM,EACjB,EAAE,SAAS,MAAM,EAEjB,cAAc,EAAE,0BAA0B,CAAC,EAAE,EAAE,EAAE,CAAC,GACjD,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CA0CvC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vite-plugin-react-server
|
|
3
|
+
* Copyright (c) Nico Brinkkemper
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
import { resolvePage } from '../resolvePage.js';
|
|
7
|
+
import { resolveProps } from '../resolveProps.js';
|
|
8
|
+
|
|
9
|
+
async function resolvePageAndProps(handlerOptions) {
|
|
10
|
+
try {
|
|
11
|
+
const resolvePagePromise = resolvePage({
|
|
12
|
+
id: handlerOptions.pagePath,
|
|
13
|
+
exportName: handlerOptions.pageExportName,
|
|
14
|
+
loader: handlerOptions.loader
|
|
15
|
+
});
|
|
16
|
+
const resolvePropsPromise = resolveProps({
|
|
17
|
+
url: handlerOptions.route,
|
|
18
|
+
id: handlerOptions.propsPath ?? handlerOptions.pagePath,
|
|
19
|
+
exportName: handlerOptions.propsExportName ?? "default",
|
|
20
|
+
loader: handlerOptions.propsPath ? handlerOptions.loader : async () => {
|
|
21
|
+
const resolvePageResult2 = await resolvePagePromise;
|
|
22
|
+
if (resolvePageResult2.type != "success") {
|
|
23
|
+
return resolvePageResult2;
|
|
24
|
+
}
|
|
25
|
+
return resolvePageResult2.module;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const [resolvePageResult, resolvePropsResult] = await Promise.all([resolvePagePromise, resolvePropsPromise]);
|
|
29
|
+
if (resolvePageResult.type != "success") {
|
|
30
|
+
return resolvePageResult;
|
|
31
|
+
}
|
|
32
|
+
if (resolvePropsResult.type != "success") {
|
|
33
|
+
return resolvePropsResult;
|
|
34
|
+
}
|
|
35
|
+
const { Page } = resolvePageResult;
|
|
36
|
+
const { props } = resolvePropsResult;
|
|
37
|
+
return {
|
|
38
|
+
type: "success",
|
|
39
|
+
PageComponent: Page,
|
|
40
|
+
pageProps: props
|
|
41
|
+
};
|
|
42
|
+
} catch (error) {
|
|
43
|
+
return {
|
|
44
|
+
type: "error",
|
|
45
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { resolvePageAndProps };
|
|
51
|
+
//# sourceMappingURL=resolvePageAndProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvePageAndProps.js","sources":["../../../plugin/helpers/resolvePageAndProps.ts"],"sourcesContent":["import { resolvePage } from \"../resolvePage.js\";\nimport { resolveProps } from \"../resolveProps.js\";\n\ntype ResolvePageAndPropsOptions<N1 extends string, N2 extends string> = {\n pagePath: string;\n pageExportName: N1;\n propsPath?: string;\n propsExportName?: N2;\n route: string;\n loader: (id: string) => Promise<any>;\n};\n\ntype ResolvePageAndPropsResult<T> =\n | {\n type: \"success\";\n error?: never;\n PageComponent: React.ComponentType<T>;\n pageProps: T;\n }\n | {\n type: \"error\";\n error: Error;\n PageComponent?: never;\n pageProps?: never;\n }\n | {\n type: \"skip\";\n error?: never;\n PageComponent?: never;\n pageProps?: never;\n };\n\nexport async function resolvePageAndProps<\n T,\n N1 extends string,\n N2 extends string\n>(\n handlerOptions: ResolvePageAndPropsOptions<N1, N2>\n): Promise<ResolvePageAndPropsResult<T>> {\n try {\n // Load the page component\n const resolvePagePromise = resolvePage({\n id: handlerOptions.pagePath,\n exportName: handlerOptions.pageExportName,\n loader: handlerOptions.loader,\n });\n const resolvePropsPromise = resolveProps({\n url: handlerOptions.route,\n id: handlerOptions.propsPath ?? handlerOptions.pagePath,\n exportName: handlerOptions.propsExportName ?? \"default\",\n loader: handlerOptions.propsPath \n ? handlerOptions.loader\n : async () => {\n const resolvePageResult = await resolvePagePromise;\n if (resolvePageResult.type != \"success\") {\n return resolvePageResult;\n }\n return resolvePageResult.module;\n },\n });\n const [resolvePageResult, resolvePropsResult] = await Promise.all([resolvePagePromise, resolvePropsPromise]);\n if (resolvePageResult.type != \"success\") {\n return resolvePageResult;\n }\n if (resolvePropsResult.type != \"success\") {\n return resolvePropsResult;\n }\n const { Page } = resolvePageResult;\n const { props } = resolvePropsResult;\n return {\n type: \"success\",\n PageComponent: Page as React.ComponentType<T>,\n pageProps: props as T,\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n}\n"],"names":["resolvePageResult"],"mappings":";;;;;;;;AAgCA,eAAsB,oBAKpB,cACuC,EAAA;AACvC,EAAI,IAAA;AAEF,IAAA,MAAM,qBAAqB,WAAY,CAAA;AAAA,MACrC,IAAI,cAAe,CAAA,QAAA;AAAA,MACnB,YAAY,cAAe,CAAA,cAAA;AAAA,MAC3B,QAAQ,cAAe,CAAA;AAAA,KACxB,CAAA;AACD,IAAA,MAAM,sBAAsB,YAAa,CAAA;AAAA,MACvC,KAAK,cAAe,CAAA,KAAA;AAAA,MACpB,EAAA,EAAI,cAAe,CAAA,SAAA,IAAa,cAAe,CAAA,QAAA;AAAA,MAC/C,UAAA,EAAY,eAAe,eAAmB,IAAA,SAAA;AAAA,MAC9C,MAAQ,EAAA,cAAA,CAAe,SACnB,GAAA,cAAA,CAAe,SACf,YAAY;AACV,QAAA,MAAMA,qBAAoB,MAAM,kBAAA;AAChC,QAAIA,IAAAA,kBAAAA,CAAkB,QAAQ,SAAW,EAAA;AACvC,UAAOA,OAAAA,kBAAAA;AAAA;AAET,QAAA,OAAOA,kBAAkB,CAAA,MAAA;AAAA;AAC3B,KACL,CAAA;AACD,IAAM,MAAA,CAAC,iBAAmB,EAAA,kBAAkB,CAAI,GAAA,MAAM,QAAQ,GAAI,CAAA,CAAC,kBAAoB,EAAA,mBAAmB,CAAC,CAAA;AAC3G,IAAI,IAAA,iBAAA,CAAkB,QAAQ,SAAW,EAAA;AACvC,MAAO,OAAA,iBAAA;AAAA;AAET,IAAI,IAAA,kBAAA,CAAmB,QAAQ,SAAW,EAAA;AACxC,MAAO,OAAA,kBAAA;AAAA;AAET,IAAM,MAAA,EAAE,MAAS,GAAA,iBAAA;AACjB,IAAM,MAAA,EAAE,OAAU,GAAA,kBAAA;AAClB,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,SAAA;AAAA,MACN,aAAe,EAAA,IAAA;AAAA,MACf,SAAW,EAAA;AAAA,KACb;AAAA,WACO,KAAO,EAAA;AACd,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,KAAA,EAAO,iBAAiB,KAAQ,GAAA,KAAA,GAAQ,IAAI,KAAM,CAAA,MAAA,CAAO,KAAK,CAAC;AAAA,KACjE;AAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResolvedConfig, ViteDevServer } from "vite";
|
|
2
|
+
import type { AutoDiscoveredFiles, ResolvedUserOptions } from "../types.js";
|
|
3
|
+
export declare function deserializeRegExp(obj: any): any;
|
|
4
|
+
export declare function processForSerialization(obj: any): any;
|
|
5
|
+
export declare function serializeResolvedConfig<T extends ResolvedConfig>(config: T, knownNonSerializableFunctions?: Set<string>): any;
|
|
6
|
+
export declare const serializedDevServerConfig: <T extends ViteDevServer["config"]>(config: T, customNonSerializableFunctions?: Set<string>) => any;
|
|
7
|
+
export declare const serializedOptions: <T extends ResolvedUserOptions>(userOptions: T, autoDiscoveredFiles: AutoDiscoveredFiles, customNonSerializableFunctions?: Set<string>) => any;
|
|
8
|
+
//# sourceMappingURL=serializeUserOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeUserOptions.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/serializeUserOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAqGrB,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAe/C;AAGD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAerD;AAED,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,cAAc,EAC9D,MAAM,EAAE,CAAC,EACT,6BAA6B,GAAE,GAAG,CAAC,MAAM,CAAmC,OAY7E;AAGD,eAAO,MAAM,yBAAyB,GAAI,CAAC,SAAS,aAAa,CAAC,QAAQ,CAAC,UACjE,CAAC,mCACuB,GAAG,CAAC,MAAM,CAAC,QAa5C,CAAC;AAGF,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,mBAAmB,eAChD,CAAC,uBACO,mBAAmB,mCACR,GAAG,CAAC,MAAM,CAAC,QA8B5C,CAAC"}
|