vite-plugin-react-server 1.1.12 → 1.1.13
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/dist/package.json +10 -8
- package/dist/plugin/components/css-collector-elements.d.ts +4 -2
- package/dist/plugin/components/css-collector-elements.d.ts.map +1 -1
- package/dist/plugin/components/css-collector-elements.js +21 -7
- package/dist/plugin/components/css-collector-elements.js.map +1 -1
- package/dist/plugin/components/css-collector.d.ts +4 -5
- package/dist/plugin/components/css-collector.d.ts.map +1 -1
- package/dist/plugin/components/css-collector.js +5 -9
- package/dist/plugin/components/css-collector.js.map +1 -1
- package/dist/plugin/components/html.d.ts +1 -1
- package/dist/plugin/components/html.d.ts.map +1 -1
- package/dist/plugin/components/html.js +14 -3
- package/dist/plugin/components/html.js.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts +4 -4
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.d.ts.map +1 -1
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js +14 -9
- package/dist/plugin/config/autoDiscover/resolveAutoDiscover.js.map +1 -1
- package/dist/plugin/config/defaults.d.ts +66 -12
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +69 -15
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts +5 -0
- package/dist/plugin/config/resolveAutoDiscoverMatcher.d.ts.map +1 -0
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js +25 -0
- package/dist/plugin/config/resolveAutoDiscoverMatcher.js.map +1 -0
- package/dist/plugin/config/resolveEnv.d.ts.map +1 -1
- package/dist/plugin/config/resolveEnv.js +16 -5
- package/dist/plugin/config/resolveEnv.js.map +1 -1
- package/dist/plugin/config/resolveOptions.d.ts +3 -3
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +59 -87
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/config/resolveUserConfig.d.ts +4 -4
- package/dist/plugin/config/resolveUserConfig.d.ts.map +1 -1
- package/dist/plugin/config/resolveUserConfig.js +8 -1
- package/dist/plugin/config/resolveUserConfig.js.map +1 -1
- package/dist/plugin/error/toError.d.ts +3 -0
- package/dist/plugin/error/toError.d.ts.map +1 -1
- package/dist/plugin/error/toError.js +33 -4
- package/dist/plugin/error/toError.js.map +1 -1
- package/dist/plugin/helpers/cleanObject.d.ts.map +1 -1
- package/dist/plugin/helpers/cleanObject.js +19 -5
- package/dist/plugin/helpers/cleanObject.js.map +1 -1
- 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.map +1 -1
- package/dist/plugin/helpers/createCssProps.d.ts +4 -3
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
- package/dist/plugin/helpers/createCssProps.js +7 -2
- package/dist/plugin/helpers/createCssProps.js.map +1 -1
- package/dist/plugin/helpers/createHandler.d.ts +4 -3
- package/dist/plugin/helpers/createHandler.d.ts.map +1 -1
- package/dist/plugin/helpers/createHandler.js +1 -1
- package/dist/plugin/helpers/createHandler.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts +2 -2
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +15 -5
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/helpers/index.d.ts +2 -2
- package/dist/plugin/helpers/index.d.ts.map +1 -1
- package/dist/plugin/helpers/index.js +2 -2
- package/dist/plugin/helpers/inputNormalizer.d.ts.map +1 -1
- package/dist/plugin/helpers/inputNormalizer.js +4 -1
- package/dist/plugin/helpers/inputNormalizer.js.map +1 -1
- package/dist/plugin/helpers/moduleResolver.d.ts +3 -0
- package/dist/plugin/helpers/moduleResolver.d.ts.map +1 -0
- package/dist/plugin/helpers/moduleResolver.js +25 -0
- package/dist/plugin/helpers/requestInfo.d.ts +18 -3
- package/dist/plugin/helpers/requestInfo.d.ts.map +1 -1
- package/dist/plugin/helpers/requestInfo.js +75 -11
- package/dist/plugin/helpers/requestInfo.js.map +1 -1
- package/dist/plugin/helpers/resolvePage.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePage.js +2 -3
- package/dist/plugin/helpers/resolvePage.js.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.d.ts +4 -3
- package/dist/plugin/helpers/resolvePageAndProps.d.ts.map +1 -1
- package/dist/plugin/helpers/resolvePageAndProps.js.map +1 -1
- package/dist/plugin/helpers/serializeUserOptions.d.ts +3 -2
- package/dist/plugin/helpers/serializeUserOptions.d.ts.map +1 -1
- package/dist/plugin/helpers/serializeUserOptions.js +13 -1
- package/dist/plugin/helpers/serializeUserOptions.js.map +1 -1
- package/dist/plugin/helpers/sourceMap.d.ts +8 -0
- package/dist/plugin/helpers/sourceMap.d.ts.map +1 -0
- package/dist/plugin/helpers/sourceMap.js +136 -0
- package/dist/plugin/helpers.js +1 -1
- package/dist/plugin/loader/createBuildLoader.d.ts +7 -22
- package/dist/plugin/loader/createBuildLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createBuildLoader.js +79 -65
- package/dist/plugin/loader/createBuildLoader.js.map +1 -1
- package/dist/plugin/loader/createDefaultLoader.d.ts +13 -0
- package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -0
- package/dist/plugin/loader/createDefaultLoader.js +47 -0
- package/dist/plugin/loader/css-loader.development.d.ts +1 -0
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.development.js +1 -1
- package/dist/plugin/loader/css-loader.development.js.map +1 -1
- package/dist/plugin/loader/handleExports.d.ts +33 -0
- package/dist/plugin/loader/handleExports.d.ts.map +1 -0
- package/dist/plugin/loader/handleExports.js +174 -0
- package/dist/plugin/loader/handleExports.js.map +1 -0
- package/dist/plugin/loader/index.d.ts +1 -1
- package/dist/plugin/loader/index.d.ts.map +1 -1
- package/dist/plugin/loader/index.js +4 -1
- package/dist/plugin/loader/parse.d.ts +6 -0
- package/dist/plugin/loader/parse.d.ts.map +1 -0
- package/dist/plugin/loader/parse.js +23 -0
- package/dist/plugin/loader/parse.js.map +1 -0
- package/dist/plugin/loader/react-loader.client.d.ts +2 -0
- package/dist/plugin/loader/react-loader.client.d.ts.map +1 -0
- package/dist/plugin/loader/react-loader.client.js +2 -0
- package/dist/plugin/loader/react-loader.d.ts +1 -12
- package/dist/plugin/loader/react-loader.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.js +5 -687
- package/dist/plugin/loader/react-loader.js.map +1 -1
- package/dist/plugin/loader/react-loader.server.d.ts +21 -0
- package/dist/plugin/loader/react-loader.server.d.ts.map +1 -0
- package/dist/plugin/loader/react-loader.server.js +69 -0
- package/dist/plugin/loader/sourceMap.d.ts +35 -0
- package/dist/plugin/loader/sourceMap.d.ts.map +1 -0
- package/dist/plugin/loader/sourceMap.js +105 -0
- package/dist/plugin/loader/temporaryReferences.d.ts +1 -1
- package/dist/plugin/loader/temporaryReferences.d.ts.map +1 -1
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts +2 -0
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -0
- package/dist/plugin/loader/transformModuleIfNeeded.js +27 -0
- package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts +27 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +52 -0
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -0
- package/dist/plugin/loader/types.d.ts +8 -0
- package/dist/plugin/loader/types.d.ts.map +1 -0
- package/dist/plugin/loader/types.js +1 -0
- package/dist/plugin/plugin.client.d.ts +2 -2
- package/dist/plugin/plugin.client.d.ts.map +1 -1
- package/dist/plugin/plugin.client.js +2 -3
- package/dist/plugin/plugin.client.js.map +1 -1
- package/dist/plugin/plugin.server.d.ts +2 -2
- package/dist/plugin/plugin.server.d.ts.map +1 -1
- package/dist/plugin/plugin.server.js +2 -2
- package/dist/plugin/plugin.server.js.map +1 -1
- package/dist/plugin/preserver/plugin.d.ts +2 -2
- package/dist/plugin/preserver/plugin.d.ts.map +1 -1
- package/dist/plugin/preserver/plugin.js +6 -2
- package/dist/plugin/preserver/plugin.js.map +1 -1
- package/dist/plugin/react-client/{server.d.ts → configureWorkerRequestHandler.d.ts} +4 -4
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -0
- package/dist/plugin/react-client/{server.js → configureWorkerRequestHandler.js} +11 -8
- package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -0
- package/dist/plugin/react-client/createMessageHandlers.d.ts +1 -1
- package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
- package/dist/plugin/react-client/createMessageHandlers.js +18 -11
- package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.d.ts +5 -3
- package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.js +61 -27
- package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js +14 -4
- package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
- package/dist/plugin/react-client/plugin.d.ts +2 -2
- package/dist/plugin/react-client/plugin.d.ts.map +1 -1
- package/dist/plugin/react-client/plugin.js +7 -8
- package/dist/plugin/react-client/plugin.js.map +1 -1
- package/dist/plugin/react-client/restartWorker.d.ts +1 -1
- package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
- package/dist/plugin/react-client/restartWorker.js +9 -3
- package/dist/plugin/react-client/restartWorker.js.map +1 -1
- package/dist/plugin/react-server/configureReactServer.d.ts +9 -0
- package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -0
- package/dist/plugin/react-server/{server.js → configureReactServer.js} +26 -8
- package/dist/plugin/react-server/configureReactServer.js.map +1 -0
- package/dist/plugin/react-server/handleServerAction.d.ts +5 -0
- package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -0
- package/dist/plugin/react-server/handleServerAction.js +145 -0
- package/dist/plugin/react-server/handleServerAction.js.map +1 -0
- package/dist/plugin/react-server/plugin.d.ts +2 -2
- package/dist/plugin/react-server/plugin.d.ts.map +1 -1
- package/dist/plugin/react-server/plugin.js +1 -1
- package/dist/plugin/react-server/plugin.js.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts +2 -2
- package/dist/plugin/react-static/collectHtmlWorkerContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectHtmlWorkerContent.js.map +1 -1
- package/dist/plugin/react-static/collectRscContent.d.ts +2 -2
- package/dist/plugin/react-static/collectRscContent.d.ts.map +1 -1
- package/dist/plugin/react-static/collectRscContent.js.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.d.ts +3 -3
- package/dist/plugin/react-static/configurePreviewServer.d.ts.map +1 -1
- package/dist/plugin/react-static/configurePreviewServer.js +18 -7
- package/dist/plugin/react-static/configurePreviewServer.js.map +1 -1
- package/dist/plugin/react-static/plugin.d.ts +2 -2
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +28 -12
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/renderPage.d.ts +2 -2
- package/dist/plugin/react-static/renderPage.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPage.js.map +1 -1
- package/dist/plugin/react-static/renderPages.d.ts +2 -2
- package/dist/plugin/react-static/renderPages.d.ts.map +1 -1
- package/dist/plugin/react-static/renderPages.js.map +1 -1
- package/dist/plugin/react-static/renderStreams.d.ts +2 -2
- package/dist/plugin/react-static/renderStreams.d.ts.map +1 -1
- package/dist/plugin/react-static/renderStreams.js +4 -4
- package/dist/plugin/react-static/renderStreams.js.map +1 -1
- package/dist/plugin/source-map/createMappingsSerializer.d.ts +2 -0
- package/dist/plugin/source-map/createMappingsSerializer.d.ts.map +1 -0
- package/dist/plugin/source-map/createMappingsSerializer.js +159 -0
- package/dist/plugin/source-map/readMappings.d.ts +2 -0
- package/dist/plugin/source-map/readMappings.d.ts.map +1 -0
- package/dist/plugin/source-map/readMappings.js +201 -0
- package/dist/plugin/transformer/index.d.ts +0 -1
- package/dist/plugin/transformer/index.d.ts.map +1 -1
- package/dist/plugin/transformer/index.js +0 -1
- package/dist/plugin/transformer/plugin.client.d.ts +1 -3
- package/dist/plugin/transformer/plugin.client.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.client.js +1 -84
- package/dist/plugin/transformer/plugin.server.d.ts +2 -2
- package/dist/plugin/transformer/plugin.server.d.ts.map +1 -1
- package/dist/plugin/transformer/plugin.server.js +52 -20
- package/dist/plugin/transformer/plugin.server.js.map +1 -1
- package/dist/plugin/types.d.ts +89 -119
- package/dist/plugin/types.d.ts.map +1 -1
- 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 +13 -4
- package/dist/plugin/utils/createCallServer.js.map +1 -1
- package/dist/plugin/utils/index.d.ts +1 -0
- package/dist/plugin/utils/index.d.ts.map +1 -1
- package/dist/plugin/utils/index.js +1 -0
- package/dist/plugin/utils.js +1 -0
- package/dist/plugin/utils.js.map +1 -1
- package/dist/plugin/vendor/vendor.client.d.ts +2 -1
- package/dist/plugin/vendor/vendor.client.d.ts.map +1 -1
- package/dist/plugin/vendor/vendor.client.js +2 -1
- package/dist/plugin/vendor/vendor.client.js.map +1 -1
- package/dist/plugin/vendor/vendor.server.d.ts.map +1 -1
- package/dist/plugin/vendor/vendor.server.js +1 -1
- package/dist/plugin/vendor/vendor.server.js.map +1 -1
- package/dist/plugin/worker/createWorker.d.ts.map +1 -1
- package/dist/plugin/worker/createWorker.js +17 -22
- package/dist/plugin/worker/createWorker.js.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.d.ts.map +1 -1
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js +25 -4
- package/dist/plugin/worker/html/createHtmlWorkerRenderState.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.development.js +15 -13
- package/dist/plugin/worker/html/html-worker.development.js.map +1 -1
- package/dist/plugin/worker/html/html-worker.production.js +2 -12
- package/dist/plugin/worker/html/html-worker.production.js.map +1 -1
- package/dist/plugin/worker/html/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/html/messageHandler.js +2 -2
- package/dist/plugin/worker/html/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.d.ts +2 -1
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +8 -8
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +166 -107
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +112 -52
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.production.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +5 -64
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +5 -1
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/sendMessage.d.ts +2 -0
- package/dist/plugin/worker/sendMessage.d.ts.map +1 -1
- package/dist/plugin/worker/sendMessage.js +2 -1
- package/dist/plugin/worker/sendMessage.js.map +1 -1
- package/dist/plugin/worker/types.d.ts +52 -53
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -8
- package/plugin/components/css-collector-elements.tsx +30 -9
- package/plugin/components/css-collector.tsx +13 -22
- package/plugin/components/html.tsx +12 -5
- package/plugin/config/autoDiscover/resolveAutoDiscover.ts +31 -13
- package/plugin/config/defaults.tsx +72 -16
- package/plugin/config/resolveAutoDiscoverMatcher.ts +23 -0
- package/plugin/config/resolveEnv.ts +20 -12
- package/plugin/config/resolveOptions.ts +152 -155
- package/plugin/config/resolveUserConfig.ts +20 -5
- package/plugin/error/toError.ts +35 -1
- package/plugin/helpers/cleanObject.ts +79 -15
- package/plugin/helpers/collectViteModuleGraphCss.ts +4 -3
- package/plugin/helpers/createCssProps.tsx +26 -9
- package/plugin/helpers/createHandler.ts +7 -4
- package/plugin/helpers/createRscStream.tsx +20 -14
- package/plugin/helpers/index.ts +2 -2
- package/plugin/helpers/inputNormalizer.ts +4 -2
- package/plugin/helpers/moduleResolver.ts +36 -0
- package/plugin/helpers/requestInfo.ts +117 -23
- package/plugin/helpers/resolvePage.ts +2 -3
- package/plugin/helpers/resolvePageAndProps.ts +7 -6
- package/plugin/helpers/serializeUserOptions.ts +20 -2
- package/plugin/helpers/sourceMap.ts +182 -0
- package/plugin/loader/createBuildLoader.ts +124 -104
- package/plugin/loader/createDefaultLoader.ts +62 -0
- package/plugin/loader/css-loader.development.ts +3 -2
- package/plugin/loader/handleExports.ts +276 -0
- package/plugin/loader/index.ts +6 -1
- package/plugin/loader/parse.ts +22 -0
- package/plugin/loader/react-loader.client.ts +1 -0
- package/plugin/loader/react-loader.server.ts +107 -0
- package/plugin/loader/react-loader.ts +4 -1002
- package/plugin/loader/sourceMap.ts +118 -0
- package/plugin/loader/transformModuleIfNeeded.ts +33 -0
- package/plugin/loader/transformModuleWithPreservedFunctions.ts +119 -0
- package/plugin/loader/types.ts +10 -0
- package/plugin/plugin.client.ts +18 -11
- package/plugin/plugin.server.ts +6 -3
- package/plugin/preserver/plugin.ts +37 -17
- package/plugin/react-client/{server.ts → configureWorkerRequestHandler.ts} +22 -12
- package/plugin/react-client/createMessageHandlers.ts +21 -13
- package/plugin/react-client/createWorkerStream.ts +71 -33
- package/plugin/react-client/handleWorkerRscStream.ts +15 -5
- package/plugin/react-client/plugin.ts +18 -13
- package/plugin/react-client/restartWorker.ts +17 -5
- package/plugin/react-server/{server.ts → configureReactServer.ts} +40 -9
- package/plugin/react-server/handleServerAction.ts +177 -0
- package/plugin/react-server/plugin.ts +8 -3
- package/plugin/react-static/collectHtmlWorkerContent.ts +11 -3
- package/plugin/react-static/collectRscContent.ts +17 -9
- package/plugin/react-static/configurePreviewServer.ts +37 -17
- package/plugin/react-static/plugin.ts +45 -22
- package/plugin/react-static/renderPage.ts +12 -6
- package/plugin/react-static/renderPages.ts +15 -4
- package/plugin/react-static/renderStreams.ts +13 -12
- package/plugin/source-map/createMappingsSerializer.ts +182 -0
- package/plugin/source-map/readMappings.ts +195 -0
- package/plugin/transformer/README.md +295 -29
- package/plugin/transformer/index.ts +0 -1
- package/plugin/transformer/plugin.client.ts +0 -111
- package/plugin/transformer/plugin.server.ts +94 -25
- package/plugin/types/react-server-dom-esm.d.ts +183 -24
- package/plugin/types/sourceMap.d.ts +2 -0
- package/plugin/types/webpack-sources.d.ts +24 -0
- package/plugin/types.ts +169 -132
- package/plugin/utils/createCallServer.ts +21 -6
- package/plugin/utils/index.ts +2 -1
- package/plugin/vendor/vendor.client.ts +2 -1
- package/plugin/vendor/vendor.server.ts +1 -1
- package/plugin/worker/createWorker.ts +21 -24
- package/plugin/worker/html/createHtmlWorkerRenderState.tsx +31 -7
- package/plugin/worker/html/html-worker.development.tsx +16 -16
- package/plugin/worker/html/html-worker.production.tsx +3 -19
- package/plugin/worker/html/messageHandler.tsx +2 -4
- package/plugin/worker/rsc/handleRender.ts +15 -12
- package/plugin/worker/rsc/messageHandler.tsx +191 -120
- package/plugin/worker/rsc/rsc-worker.development.ts +148 -77
- package/plugin/worker/rsc/rsc-worker.production.ts +1 -1
- package/plugin/worker/rsc/state.ts +10 -0
- package/plugin/worker/sendMessage.ts +32 -14
- package/plugin/worker/types.ts +99 -64
- package/dist/plugin/react-client/server.d.ts.map +0 -1
- package/dist/plugin/react-client/server.js.map +0 -1
- package/dist/plugin/react-server/server.d.ts +0 -9
- package/dist/plugin/react-server/server.d.ts.map +0 -1
- package/dist/plugin/react-server/server.js.map +0 -1
- package/dist/plugin/transformer/plugin.client.js.map +0 -1
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts +0 -2
- package/dist/plugin/transformer/upgradeCssModuleCode.d.ts.map +0 -1
- package/dist/plugin/transformer/upgradeCssModuleCode.js +0 -40
- package/dist/plugin/worker/loader.d.ts +0 -5
- package/dist/plugin/worker/loader.d.ts.map +0 -1
- package/dist/plugin/worker/loader.js +0 -11
- package/dist/plugin/worker/loader.js.map +0 -1
- package/plugin/transformer/upgradeCssModuleCode.ts +0 -42
- package/plugin/worker/loader.ts +0 -7
|
@@ -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;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;IAC1E,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AA+JF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,cAAc,EACd,mBAA+B,EAC/B,
|
|
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;IAC1E,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AA+JF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,cAAc,EACd,mBAA+B,EAC/B,eAA8D,GAC/D,EAAE,0BAA0B,GAAG,eAAe,CAuE9C"}
|
|
@@ -119,7 +119,7 @@ function createInputNormalizer({
|
|
|
119
119
|
root,
|
|
120
120
|
moduleBasePath,
|
|
121
121
|
preserveModulesRoot = undefined,
|
|
122
|
-
removeExtension = DEFAULT_CONFIG.
|
|
122
|
+
removeExtension = DEFAULT_CONFIG.AUTO_DISCOVER.moduleExtension
|
|
123
123
|
}) {
|
|
124
124
|
if (stashedNormalizer) {
|
|
125
125
|
return stashedNormalizer;
|
|
@@ -167,6 +167,9 @@ function createInputNormalizer({
|
|
|
167
167
|
const normalizedPath = path2.startsWith("/") ? path2.slice(1) : path2;
|
|
168
168
|
const virtualPrefix = key.match(/^\0+/) ?? "";
|
|
169
169
|
const finalPath = virtualPrefix ? virtualPrefix.length && normalizedPath.startsWith(virtualPrefix[0]) ? normalizedPath : virtualPrefix.length ? virtualPrefix[0] + normalizedPath : normalizedPath : normalizedPath;
|
|
170
|
+
if (virtualPrefix) {
|
|
171
|
+
return ["", ""];
|
|
172
|
+
}
|
|
170
173
|
return [key, finalPath];
|
|
171
174
|
};
|
|
172
175
|
return stashedNormalizer;
|
|
@@ -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 path, { join, sep } 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 moduleBasePath?: string | undefined;\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 (\n typeof preserveModulesRoot === \"string\" &&\n typeof root !== \"string\"\n ) {\n return normalizePath(preserveModulesRoot);\n }\n return \"\";\n};\nconst createKeyNormalizer =\n ({\n root: normalizedRoot,\n preserveModulesRoot,\n handleExtension,\n moduleBasePath,\n }: {\n root: string;\n preserveModulesRoot: string | undefined;\n handleExtension: (path: string) => string;\n moduleBasePath: string | undefined;\n }) =>\n (key: string) => {\n if (key.includes(\"?\")) {\n key = key.split(\"?\")[0];\n }\n\n // Handle virtual modules first\n const virtualPrefix = key.match(/^\\0+/) ?? \"\";\n const actualKey = virtualPrefix ? key.slice(virtualPrefix[0].length) : key;\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 if (\n typeof moduleBasePath === \"string\" &&\n moduleBasePath !== \"\" &&\n moduleBasePath !== \"/\"\n ) {\n moduleId = moduleId.startsWith(\n moduleBasePath.endsWith(sep) ? moduleBasePath : moduleBasePath + sep\n )\n ? moduleId.slice(\n moduleBasePath.length +\n (moduleBasePath.endsWith(sep) ? 0 : sep.length)\n )\n : moduleId;\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 moduleBasePath,\n }: {\n root: string;\n preserveModulesRoot: string | undefined;\n moduleBasePath: string | undefined;\n }) =>\n (path: string) => {\n if (typeof path !== \"string\") {\n throw new Error(`Invalid path: ${JSON.stringify(path)}`);\n }\n if (path.includes(\"?\")) {\n path = path.split(\"?\")[0];\n }\n let normalPath = normalizePath(path);\n if (normalPath.startsWith(root)) {\n normalPath = normalPath.slice(root.length);\n }\n if (\n typeof moduleBasePath === \"string\" &&\n moduleBasePath !== \"\" &&\n moduleBasePath !== \"/\"\n ) {\n normalPath = normalPath.startsWith(\n moduleBasePath.endsWith(sep) ? moduleBasePath : moduleBasePath + sep\n )\n ? normalPath.slice(\n moduleBasePath.length +\n (moduleBasePath.endsWith(sep) ? 0 : sep.length)\n )\n : normalPath;\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 moduleBasePath,\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 moduleBasePath,\n });\n const normalizeEntryPath = createPathNormalizer({\n root: root,\n preserveModulesRoot: relativeRoot,\n moduleBasePath,\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+/) ?? \"\";\n // If key has virtual prefix, ensure path has it too\n const finalPath = virtualPrefix\n ? virtualPrefix.length && normalizedPath.startsWith(virtualPrefix[0])\n ? normalizedPath\n : virtualPrefix.length\n ? virtualPrefix[0] + normalizedPath\n : normalizedPath\n : normalizedPath;\n\n return [key, finalPath];\n };\n return stashedNormalizer;\n}\n"],"names":["path"],"mappings":";;;;;;;;;AAKA,IAAI,iBAA4C,GAAA,IAAA;AAShD,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,GAAAA,KAAAA,CAAK,KAAM,CAAA,CAAA,EAAG,cAAc,CAAIA,GAAAA,KAAAA;AAAA,OACjE;AAAA;AAEF,IAAA,OAAO,CAACA,KAAiBA,KAAAA,KAAAA;AAAA;AAE3B,EAAI,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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,aAAgB,GAAA,GAAA,CAAI,KAAM,CAAA,MAAM,CAAK,IAAA,EAAA;AAE3C,IAAA,MAAM,YAAY,aACd,GAAA,aAAA,CAAc,MAAU,IAAA,cAAA,CAAe,WAAW,aAAc,CAAA,CAAC,CAAC,CAAA,GAChE,iBACA,aAAc,CAAA,MAAA,GACd,cAAc,CAAC,CAAA,GAAI,iBACnB,cACF,GAAA,cAAA;AAEJ,IAAO,OAAA,CAAC,KAAK,SAAS,CAAA;AAAA,GACxB;AACA,EAAO,OAAA,iBAAA;AACT;;;;"}
|
|
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, sep } 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 moduleBasePath?: string | undefined;\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 (\n typeof preserveModulesRoot === \"string\" &&\n typeof root !== \"string\"\n ) {\n return normalizePath(preserveModulesRoot);\n }\n return \"\";\n};\nconst createKeyNormalizer =\n ({\n root: normalizedRoot,\n preserveModulesRoot,\n handleExtension,\n moduleBasePath,\n }: {\n root: string;\n preserveModulesRoot: string | undefined;\n handleExtension: (path: string) => string;\n moduleBasePath: string | undefined;\n }) =>\n (key: string) => {\n if (key.includes(\"?\")) {\n key = key.split(\"?\")[0];\n }\n\n // Handle virtual modules first\n const virtualPrefix = key.match(/^\\0+/) ?? \"\";\n const actualKey = virtualPrefix ? key.slice(virtualPrefix[0].length) : key;\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 if (\n typeof moduleBasePath === \"string\" &&\n moduleBasePath !== \"\" &&\n moduleBasePath !== \"/\"\n ) {\n moduleId = moduleId.startsWith(\n moduleBasePath.endsWith(sep) ? moduleBasePath : moduleBasePath + sep\n )\n ? moduleId.slice(\n moduleBasePath.length +\n (moduleBasePath.endsWith(sep) ? 0 : sep.length)\n )\n : moduleId;\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 moduleBasePath,\n }: {\n root: string;\n preserveModulesRoot: string | undefined;\n moduleBasePath: string | undefined;\n }) =>\n (path: string) => {\n if (typeof path !== \"string\") {\n throw new Error(`Invalid path: ${JSON.stringify(path)}`);\n }\n if (path.includes(\"?\")) {\n path = path.split(\"?\")[0];\n }\n let normalPath = normalizePath(path);\n if (normalPath.startsWith(root)) {\n normalPath = normalPath.slice(root.length);\n }\n if (\n typeof moduleBasePath === \"string\" &&\n moduleBasePath !== \"\" &&\n moduleBasePath !== \"/\"\n ) {\n normalPath = normalPath.startsWith(\n moduleBasePath.endsWith(sep) ? moduleBasePath : moduleBasePath + sep\n )\n ? normalPath.slice(\n moduleBasePath.length +\n (moduleBasePath.endsWith(sep) ? 0 : sep.length)\n )\n : normalPath;\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 moduleBasePath,\n preserveModulesRoot = undefined,\n removeExtension = DEFAULT_CONFIG.AUTO_DISCOVER.moduleExtension,\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 moduleBasePath,\n });\n const normalizeEntryPath = createPathNormalizer({\n root: root,\n preserveModulesRoot: relativeRoot,\n moduleBasePath,\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+/) ?? \"\";\n // If key has virtual prefix, ensure path has it too\n const finalPath = virtualPrefix\n ? virtualPrefix.length && normalizedPath.startsWith(virtualPrefix[0])\n ? normalizedPath\n : virtualPrefix.length\n ? virtualPrefix[0] + normalizedPath\n : normalizedPath\n : normalizedPath;\n if(virtualPrefix){\n return ['', ''];\n }\n return [key, finalPath];\n };\n return stashedNormalizer;\n}\n"],"names":["path"],"mappings":";;;;;;;;;AAKA,IAAI,iBAA4C,GAAA,IAAA;AAShD,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,GAAAA,KAAAA,CAAK,KAAM,CAAA,CAAA,EAAG,cAAc,CAAIA,GAAAA,KAAAA;AAAA,OACjE;AAAA;AAEF,IAAA,OAAO,CAACA,KAAiBA,KAAAA,KAAAA;AAAA;AAE3B,EAAI,IAAA,OAAO,oBAAoB,QAAU,EAAA;AACvC,IAAA,OAAO,CAACA,KAAAA,KAAiBA,KAAK,CAAA,OAAA,CAAQ,iBAAiB,EAAE,CAAA;AAAA;AAE3D,EAAA,IAAI,2BAA2B,MAAQ,EAAA;AACrC,IAAO,OAAA,CAACA,KACN,KAAA,eAAA,CAAgB,IAAKA,CAAAA,KAAI,IAAIA,KAAK,CAAA,OAAA,CAAQ,eAAiB,EAAA,EAAE,CAAIA,GAAAA,KAAAA;AAAA;AAErE,EAAI,IAAA,OAAO,oBAAoB,UAAY,EAAA;AACzC,IAAA,OAAO,CAACA,K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,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,aAAgB,GAAA,GAAA,CAAI,KAAM,CAAA,MAAM,CAAK,IAAA,EAAA;AAE3C,IAAA,MAAM,YAAY,aACd,GAAA,aAAA,CAAc,MAAU,IAAA,cAAA,CAAe,WAAW,aAAc,CAAA,CAAC,CAAC,CAAA,GAChE,iBACA,aAAc,CAAA,MAAA,GACd,cAAc,CAAC,CAAA,GAAI,iBACnB,cACF,GAAA,cAAA;AACJ,IAAA,IAAG,aAAc,EAAA;AACf,MAAO,OAAA,CAAC,IAAI,EAAE,CAAA;AAAA;AAEhB,IAAO,OAAA,CAAC,KAAK,SAAS,CAAA;AAAA,GACxB;AACA,EAAO,OAAA,iBAAA;AACT;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleResolver.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/moduleResolver.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,GAAG,QAE7C;AAED,wBAAsB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBA6B7E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
let stashedResolve = null;
|
|
2
|
+
export function setStashedResolve(resolve) {
|
|
3
|
+
stashedResolve = resolve;
|
|
4
|
+
}
|
|
5
|
+
export async function resolveClientImport(specifier, parentURL) {
|
|
6
|
+
const conditions = ["node", "import"];
|
|
7
|
+
if (stashedResolve === null) {
|
|
8
|
+
throw new Error("Expected resolve to have been called before transformSource");
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const result = await stashedResolve(specifier, {
|
|
12
|
+
conditions,
|
|
13
|
+
parentURL,
|
|
14
|
+
}, stashedResolve);
|
|
15
|
+
if (!result) {
|
|
16
|
+
console.warn(`Failed to resolve import: ${specifier}`);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error(`Error resolving import ${specifier}:`, error);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { ResolvedUserOptions } from "../types.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type Connect, type Logger } from "vite";
|
|
3
3
|
/**
|
|
4
4
|
* # Request info
|
|
5
5
|
*
|
|
6
|
-
* Does the initial work to check if the request is for html, rsc, css, or something else not handled by this plugin.
|
|
6
|
+
* Does the initial work to check if the request is for html, rsc, json, js, css, server-action, or something else not handled by this plugin.
|
|
7
7
|
*
|
|
8
8
|
* @param req
|
|
9
9
|
* @param userOptions
|
|
10
10
|
* @param hostDir
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
export declare function requestInfo(req: Connect.IncomingMessage, userOptions: Pick<ResolvedUserOptions, "normalizer" | "build" | "autoDiscover">, hostDir: string): {
|
|
13
|
+
export declare function requestInfo(req: Connect.IncomingMessage, userOptions: Pick<ResolvedUserOptions, "normalizer" | "build" | "autoDiscover" | "verbose">, hostDir: string, logger?: Logger): {
|
|
14
14
|
route: string;
|
|
15
15
|
ext: string;
|
|
16
16
|
isHtmlRequest: boolean;
|
|
@@ -22,5 +22,20 @@ export declare function requestInfo(req: Connect.IncomingMessage, userOptions: P
|
|
|
22
22
|
isFolder: boolean;
|
|
23
23
|
contentType: string;
|
|
24
24
|
filePath: string;
|
|
25
|
+
isJS: boolean;
|
|
26
|
+
isVendor: boolean;
|
|
27
|
+
isVirtual: boolean;
|
|
28
|
+
hasJsHeader: boolean | undefined;
|
|
29
|
+
isJsRequest: boolean | undefined;
|
|
30
|
+
isJson: boolean;
|
|
31
|
+
isJsonRequest: boolean | undefined;
|
|
32
|
+
hasCssHeader: boolean | undefined;
|
|
33
|
+
hasJsonHeader: boolean | undefined;
|
|
34
|
+
hasHtmlHeader: boolean | undefined;
|
|
35
|
+
hasRscHeader: boolean | undefined;
|
|
36
|
+
hasServerActionHeaders: boolean | undefined;
|
|
37
|
+
isServerActionRequest: boolean | undefined;
|
|
38
|
+
isFormContentType: boolean;
|
|
39
|
+
isFormActionRequest: boolean;
|
|
25
40
|
};
|
|
26
41
|
//# sourceMappingURL=requestInfo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestInfo.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/requestInfo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"requestInfo.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/requestInfo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAgB,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAG/D;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,OAAO,CAAC,eAAe,EAC5B,WAAW,EAAE,IAAI,CACf,mBAAmB,EACnB,YAAY,GAAG,OAAO,GAAG,cAAc,GAAG,SAAS,CACpD,EACD,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,MAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkKhC"}
|
|
@@ -3,25 +3,43 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import { join } from 'node:path';
|
|
6
|
+
import { join, resolve } from 'node:path';
|
|
7
|
+
import { createLogger } from 'vite';
|
|
7
8
|
import { MIME_TYPES } from '../config/mimeTypes.js';
|
|
8
9
|
|
|
9
|
-
function requestInfo(req, userOptions, hostDir) {
|
|
10
|
+
function requestInfo(req, userOptions, hostDir, logger = createLogger()) {
|
|
10
11
|
const [, value] = userOptions.normalizer(req.url);
|
|
11
12
|
const dotIndex = value.lastIndexOf(".");
|
|
12
13
|
const ext = dotIndex === -1 ? "" : value.slice(dotIndex);
|
|
14
|
+
const isVendor = userOptions.autoDiscover.vendorPattern(value);
|
|
15
|
+
const isVirtual = userOptions.autoDiscover.virtualPattern(value);
|
|
16
|
+
const isJS = userOptions.autoDiscover.modulePattern(value);
|
|
13
17
|
const isHtml = userOptions.autoDiscover.htmlPattern(value);
|
|
14
|
-
const
|
|
18
|
+
const isCss = userOptions.autoDiscover.cssPattern(value);
|
|
19
|
+
const isJson = userOptions.autoDiscover.jsonPattern(value);
|
|
15
20
|
const isRsc = userOptions.autoDiscover.rscPattern(value);
|
|
21
|
+
const hasJsHeader = req.headers["sec-fetch-dest"] === "script" || req.headers["accept"]?.includes("*/*") || req.headers["accept"]?.includes("text/javascript");
|
|
22
|
+
const hasJsonHeader = req.headers["accept"]?.includes("application/json");
|
|
23
|
+
const hasHtmlHeader = req.headers.accept?.includes("text/html");
|
|
16
24
|
const hasRscHeader = req.headers.accept?.includes("text/x-component");
|
|
25
|
+
const hasCssHeader = req.headers.accept?.includes("text/css");
|
|
17
26
|
const isFolder = !ext;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
27
|
+
const isJsRequest = !isJson && !isHtml && !isCss && !isRsc && (isJS || hasJsHeader);
|
|
28
|
+
const isJsonRequest = isJson || hasJsonHeader && !isJsRequest;
|
|
29
|
+
const isHtmlRequest = isHtml || hasHtmlHeader || isFolder && !hasRscHeader && !isRsc && !isJsRequest;
|
|
30
|
+
const isRscRequest = !isJsRequest && !isHtmlRequest && (isRsc || hasRscHeader);
|
|
31
|
+
const isCssRequest = !isHtmlRequest && !isRscRequest && !isJsRequest && !isJsonRequest && (isCss || hasCssHeader);
|
|
32
|
+
const formContentType = req.headers["content-type"] ?? "";
|
|
33
|
+
const isFormContentType = formContentType.includes("application/x-www-form-urlencoded") || formContentType.includes("multipart/form-data");
|
|
34
|
+
const isFormActionRequest = isFormContentType && req.headers["sec-fetch-dest"] === "document" && req.headers["sec-fetch-mode"] === "navigate";
|
|
35
|
+
const hasServerActionHeaders = isJsonRequest && (req.headers["sec-fetch-dest"] === "empty" || req.headers["sec-fetch-dest"] === "") && req.headers["sec-fetch-mode"] === "cors";
|
|
36
|
+
const isServerActionRequest = hasServerActionHeaders;
|
|
22
37
|
let filePath = join(hostDir, value);
|
|
23
38
|
let contentType;
|
|
24
|
-
if (
|
|
39
|
+
if (isServerActionRequest) {
|
|
40
|
+
filePath = value;
|
|
41
|
+
contentType = "application/json; charset=utf-8";
|
|
42
|
+
} else if (isHtmlRequest) {
|
|
25
43
|
if (!isHtml) {
|
|
26
44
|
filePath = join(hostDir, value, userOptions.build.htmlOutputPath);
|
|
27
45
|
}
|
|
@@ -33,9 +51,19 @@ function requestInfo(req, userOptions, hostDir) {
|
|
|
33
51
|
contentType = "text/x-component; charset=utf-8";
|
|
34
52
|
} else if (isCssRequest) {
|
|
35
53
|
if (!isCss) {
|
|
36
|
-
filePath = join(hostDir, value);
|
|
54
|
+
filePath = join(hostDir, value + ".css");
|
|
37
55
|
}
|
|
38
56
|
contentType = "text/css; charset=utf-8";
|
|
57
|
+
} else if (isJsRequest) {
|
|
58
|
+
if (!isJS) {
|
|
59
|
+
filePath = resolve(hostDir, value + ".js");
|
|
60
|
+
}
|
|
61
|
+
contentType = "application/javascript; charset=utf-8";
|
|
62
|
+
} else if (isJsonRequest) {
|
|
63
|
+
if (!isJson) {
|
|
64
|
+
filePath = join(hostDir, value + ".json");
|
|
65
|
+
}
|
|
66
|
+
contentType = "application/json; charset=utf-8";
|
|
39
67
|
} else {
|
|
40
68
|
const mimeType = MIME_TYPES[ext];
|
|
41
69
|
if (mimeType) {
|
|
@@ -46,7 +74,28 @@ function requestInfo(req, userOptions, hostDir) {
|
|
|
46
74
|
}
|
|
47
75
|
const route = value.replace(userOptions.build.rscOutputPath, "").replace(userOptions.build.htmlOutputPath, "");
|
|
48
76
|
const routeWithoutTrailingSlash = route === "" || route === "/" ? "/" : route.endsWith("/") ? route.slice(0, -1) : route;
|
|
49
|
-
const routeWithLeadingSlash = routeWithoutTrailingSlash.startsWith("/") ? routeWithoutTrailingSlash : `/${routeWithoutTrailingSlash}`;
|
|
77
|
+
const routeWithLeadingSlash = !routeWithoutTrailingSlash ? "/" : routeWithoutTrailingSlash.startsWith("/") ? routeWithoutTrailingSlash : `/${routeWithoutTrailingSlash}`;
|
|
78
|
+
if (userOptions.verbose) {
|
|
79
|
+
if (isFormActionRequest) {
|
|
80
|
+
logger.info(`[react-dev-server] (form-action) ${routeWithLeadingSlash}`);
|
|
81
|
+
} else if (isServerActionRequest) {
|
|
82
|
+
logger.info(
|
|
83
|
+
`[react-dev-server] (server-action) ${routeWithLeadingSlash}`
|
|
84
|
+
);
|
|
85
|
+
} else if (isHtmlRequest) {
|
|
86
|
+
logger.info(`[react-dev-server] (html) ${routeWithLeadingSlash}`);
|
|
87
|
+
} else if (isRscRequest) {
|
|
88
|
+
logger.info(`[react-dev-server] (rsc.) ${routeWithLeadingSlash}`);
|
|
89
|
+
} else if (isCssRequest) {
|
|
90
|
+
logger.info(`[react-dev-server] (css) ${routeWithLeadingSlash}`);
|
|
91
|
+
} else if (isJsRequest) {
|
|
92
|
+
logger.info(`[react-dev-server] (js) ${routeWithLeadingSlash}`);
|
|
93
|
+
} else if (isJsonRequest) {
|
|
94
|
+
logger.info(`[react-dev-server] (json) ${routeWithLeadingSlash}`);
|
|
95
|
+
} else {
|
|
96
|
+
logger.info(`[react-dev-server] (other) ${routeWithLeadingSlash}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
50
99
|
return {
|
|
51
100
|
route: routeWithLeadingSlash,
|
|
52
101
|
ext,
|
|
@@ -58,7 +107,22 @@ function requestInfo(req, userOptions, hostDir) {
|
|
|
58
107
|
isRsc,
|
|
59
108
|
isFolder,
|
|
60
109
|
contentType,
|
|
61
|
-
filePath
|
|
110
|
+
filePath,
|
|
111
|
+
isJS,
|
|
112
|
+
isVendor,
|
|
113
|
+
isVirtual,
|
|
114
|
+
hasJsHeader,
|
|
115
|
+
isJsRequest,
|
|
116
|
+
isJson,
|
|
117
|
+
isJsonRequest,
|
|
118
|
+
hasCssHeader,
|
|
119
|
+
hasJsonHeader,
|
|
120
|
+
hasHtmlHeader,
|
|
121
|
+
hasRscHeader,
|
|
122
|
+
hasServerActionHeaders,
|
|
123
|
+
isServerActionRequest,
|
|
124
|
+
isFormContentType,
|
|
125
|
+
isFormActionRequest
|
|
62
126
|
};
|
|
63
127
|
}
|
|
64
128
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestInfo.js","sources":["../../../plugin/helpers/requestInfo.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport type { ResolvedUserOptions } from \"../types.js\";\nimport type { Connect } from \"vite\";\nimport { MIME_TYPES } from \"../config/mimeTypes.js\";\n\n/**\n * # Request info\n * \n * Does the initial work to check if the request is for html, rsc, css, or something else not handled by this plugin.\n * \n * @param req \n * @param userOptions \n * @param hostDir \n * @returns \n */\nexport function requestInfo(\n req: Connect.IncomingMessage,\n userOptions: Pick<ResolvedUserOptions, \"normalizer\" | \"build\" | \"autoDiscover\">,\n hostDir: string\n) {\n const [, value] = userOptions.normalizer(req.url);\n const dotIndex = value.lastIndexOf(\".\");\n const ext = dotIndex === -1 ? \"\" : value.slice(dotIndex);\n // handle index.html\n const isHtml = userOptions.autoDiscover.htmlPattern(value);\n const hasHtmlHeader = req.headers.accept?.includes(\"text/html\");\n const isRsc = userOptions.autoDiscover.rscPattern(value);\n const hasRscHeader = req.headers.accept?.includes(\"text/x-component\");\n const isFolder = !ext;\n const isHtmlRequest =\n isHtml || hasHtmlHeader || (isFolder && !hasRscHeader && !isRsc);\n const isRscRequest = !isHtmlRequest && (isRsc || hasRscHeader);\n const isCss = userOptions.autoDiscover.cssPattern(value);\n const isCssRequest =\n !isHtmlRequest &&\n !isRscRequest &&\n (isCss || req.headers.accept?.includes(\"text/css\"));\n let filePath = join(hostDir, value);\n let contentType;\n if (isHtmlRequest) {\n if (!isHtml) {\n filePath = join(hostDir, value, userOptions.build.htmlOutputPath);\n }\n contentType = \"text/html; charset=utf-8\";\n } else if (isRscRequest) {\n if (!isRsc) {\n filePath = join(hostDir, value, userOptions.build.rscOutputPath);\n }\n contentType = \"text/x-component; charset=utf-8\";\n } else if (isCssRequest) {\n if (!isCss) {\n filePath = join(hostDir, value);\n }\n contentType = \"text/css; charset=utf-8\";\n } else {\n const mimeType = MIME_TYPES[ext];\n if (mimeType) {\n contentType = mimeType;\n } else {\n contentType = \"application/octet-stream\";\n }\n }\n const route = value\n .replace(userOptions.build.rscOutputPath, \"\")\n .replace(userOptions.build.htmlOutputPath, \"\");\n \n const routeWithoutTrailingSlash =\n route === \"\" || route === \"/\"\n ? \"/\"\n : route.endsWith(\"/\")\n ? route.slice(0, -1)\n : route;\n const routeWithLeadingSlash =\n routeWithoutTrailingSlash.startsWith(\"/\")\n ? routeWithoutTrailingSlash\n : `/${routeWithoutTrailingSlash}`;\n\n return {\n route: routeWithLeadingSlash,\n ext,\n isHtmlRequest,\n isRscRequest,\n isCssRequest,\n isCss,\n isHtml,\n isRsc,\n isFolder,\n contentType,\n filePath,\n };\n}\n"],"names":[],"mappings":";;;;;;;;AAeO,SAAS,WAAA,CACd,GACA,EAAA,WAAA,EACA,OACA,EAAA;AACA,EAAA,MAAM,GAAG,KAAK,IAAI,WAAY,CAAA,UAAA,CAAW,IAAI,GAAG,CAAA;AAChD,EAAM,MAAA,QAAA,GAAW,KAAM,CAAA,WAAA,CAAY,GAAG,CAAA;AACtC,EAAA,MAAM,MAAM,QAAa,KAAA,EAAA,GAAK,EAAK,GAAA,KAAA,CAAM,MAAM,QAAQ,CAAA;AAEvD,EAAA,MAAM,MAAS,GAAA,WAAA,CAAY,YAAa,CA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AACV,MAAW,QAAA,GAAA,IAAA,CAAK,SAAS,KAAK,CAAA;AAAA;AAEhC,IAAc,WAAA,GAAA,yBAAA;AAAA,GACT,MAAA;AACL,IAAM,MAAA,QAAA,GAAW,WAAW,GAAG,CAAA;AAC/B,IAAA,IAAI,QAAU,EAAA;AACZ,MAAc,WAAA,GAAA,QAAA;AAAA,KACT,MAAA;AACL,MAAc,WAAA,GAAA,0BAAA;AAAA;AAChB;AAEF,EAAA,MAAM,KAAQ,GAAA,KAAA,CACX,OAAQ,CAAA,WAAA,CAAY,KAAM,CAAA,aAAA,EAAe,EAAE,CAAA,CAC3C,OAAQ,CAAA,WAAA,CAAY,KAAM,CAAA,cAAA,EAAgB,EAAE,CAAA;AAE/C,EAAA,MAAM,yBACJ,GAAA,KAAA,KAAU,EAAM,IAAA,KAAA,KAAU,MACtB,GACA,GAAA,KAAA,CAAM,QAAS,CAAA,GAAG,CAClB,GAAA,KAAA,CAAM,KAAM,CAAA,CAAA,EAAG,EAAE,CACjB,GAAA,KAAA;AACN,EAAA,MAAM,wBACJ,yBAA0B,CAAA,UAAA,CAAW,GAAG,CACpC,GAAA,yBAAA,GACA,IAAI,yBAAyB,CAAA,CAAA;AAEnC,EAAO,OAAA;AAAA,IACL,KAAO,EAAA,qBAAA;AAAA,IACP,GAAA;AAAA,IACA,aAAA;AAAA,IACA,YAAA;AAAA,IACA,YAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"requestInfo.js","sources":["../../../plugin/helpers/requestInfo.ts"],"sourcesContent":["import { join, resolve } from \"node:path\";\nimport type { ResolvedUserOptions } from \"../types.js\";\nimport { createLogger, type Connect, type Logger } from \"vite\";\nimport { MIME_TYPES } from \"../config/mimeTypes.js\";\n\n/**\n * # Request info\n *\n * Does the initial work to check if the request is for html, rsc, json, js, css, server-action, or something else not handled by this plugin.\n *\n * @param req\n * @param userOptions\n * @param hostDir\n * @returns\n */\nexport function requestInfo(\n req: Connect.IncomingMessage,\n userOptions: Pick<\n ResolvedUserOptions,\n \"normalizer\" | \"build\" | \"autoDiscover\" | \"verbose\"\n >,\n hostDir: string,\n logger: Logger = createLogger()\n) {\n const [, value] = userOptions.normalizer(req.url);\n const dotIndex = value.lastIndexOf(\".\");\n const ext = dotIndex === -1 ? \"\" : value.slice(dotIndex);\n // handle index.html\n const isVendor = userOptions.autoDiscover.vendorPattern(value);\n const isVirtual = userOptions.autoDiscover.virtualPattern(value);\n const isJS = userOptions.autoDiscover.modulePattern(value);\n const isHtml = userOptions.autoDiscover.htmlPattern(value);\n const isCss = userOptions.autoDiscover.cssPattern(value);\n const isJson = userOptions.autoDiscover.jsonPattern(value);\n const isRsc = userOptions.autoDiscover.rscPattern(value);\n const hasJsHeader =\n req.headers[\"sec-fetch-dest\"] === \"script\" ||\n req.headers[\"accept\"]?.includes(\"*/*\") ||\n req.headers[\"accept\"]?.includes(\"text/javascript\");\n const hasJsonHeader = req.headers[\"accept\"]?.includes(\"application/json\");\n const hasHtmlHeader = req.headers.accept?.includes(\"text/html\");\n const hasRscHeader = req.headers.accept?.includes(\"text/x-component\");\n const hasCssHeader = req.headers.accept?.includes(\"text/css\");\n const isFolder = !ext;\n const isJsRequest =\n !isJson && !isHtml && !isCss && !isRsc && (isJS || hasJsHeader);\n const isJsonRequest = isJson || (hasJsonHeader && !isJsRequest);\n const isHtmlRequest =\n isHtml ||\n hasHtmlHeader ||\n (isFolder && !hasRscHeader && !isRsc && !isJsRequest);\n const isRscRequest =\n !isJsRequest && !isHtmlRequest && (isRsc || hasRscHeader);\n const isCssRequest =\n !isHtmlRequest &&\n !isRscRequest &&\n !isJsRequest &&\n !isJsonRequest &&\n (isCss || hasCssHeader);\n\n // Form action detection\n const formContentType = req.headers[\"content-type\"] ?? \"\";\n const isFormContentType =\n formContentType.includes(\"application/x-www-form-urlencoded\") ||\n formContentType.includes(\"multipart/form-data\");\n const isFormActionRequest =\n isFormContentType &&\n req.headers[\"sec-fetch-dest\"] === \"document\" &&\n req.headers[\"sec-fetch-mode\"] === \"navigate\";\n\n // Server action detection\n const hasServerActionHeaders =\n isJsonRequest &&\n (req.headers[\"sec-fetch-dest\"] === \"empty\" ||\n req.headers[\"sec-fetch-dest\"] === \"\") &&\n req.headers[\"sec-fetch-mode\"] === \"cors\";\n const isServerActionRequest = hasServerActionHeaders;\n\n let filePath = join(hostDir, value);\n let contentType;\n if (isServerActionRequest) {\n // For server actions, we'll get the actual file path from the request body\n // The route is just a placeholder\n filePath = value;\n contentType = \"application/json; charset=utf-8\";\n } else if (isHtmlRequest) {\n if (!isHtml) {\n filePath = join(hostDir, value, userOptions.build.htmlOutputPath);\n }\n contentType = \"text/html; charset=utf-8\";\n } else if (isRscRequest) {\n if (!isRsc) {\n filePath = join(hostDir, value, userOptions.build.rscOutputPath);\n }\n contentType = \"text/x-component; charset=utf-8\";\n } else if (isCssRequest) {\n if (!isCss) {\n filePath = join(hostDir, value + \".css\");\n }\n contentType = \"text/css; charset=utf-8\";\n } else if (isJsRequest) {\n if (!isJS) {\n filePath = resolve(hostDir, value + \".js\");\n }\n contentType = \"application/javascript; charset=utf-8\";\n } else if (isJsonRequest) {\n if (!isJson) {\n filePath = join(hostDir, value + \".json\");\n }\n contentType = \"application/json; charset=utf-8\";\n } else {\n const mimeType = MIME_TYPES[ext];\n if (mimeType) {\n contentType = mimeType;\n } else {\n contentType = \"application/octet-stream\";\n }\n }\n const route = value\n .replace(userOptions.build.rscOutputPath, \"\")\n .replace(userOptions.build.htmlOutputPath, \"\");\n\n const routeWithoutTrailingSlash =\n route === \"\" || route === \"/\"\n ? \"/\"\n : route.endsWith(\"/\")\n ? route.slice(0, -1)\n : route;\n\n const routeWithLeadingSlash = !routeWithoutTrailingSlash\n ? \"/\"\n : routeWithoutTrailingSlash.startsWith(\"/\")\n ? routeWithoutTrailingSlash\n : `/${routeWithoutTrailingSlash}`;\n\n if (userOptions.verbose) {\n if (isFormActionRequest) {\n logger.info(`[react-dev-server] (form-action) ${routeWithLeadingSlash}`);\n } else if (isServerActionRequest) {\n logger.info(\n `[react-dev-server] (server-action) ${routeWithLeadingSlash}`\n );\n } else if (isHtmlRequest) {\n logger.info(`[react-dev-server] (html) ${routeWithLeadingSlash}`);\n } else if (isRscRequest) {\n logger.info(`[react-dev-server] (rsc.) ${routeWithLeadingSlash}`);\n } else if (isCssRequest) {\n logger.info(`[react-dev-server] (css) ${routeWithLeadingSlash}`);\n } else if (isJsRequest) {\n logger.info(`[react-dev-server] (js) ${routeWithLeadingSlash}`);\n } else if (isJsonRequest) {\n logger.info(`[react-dev-server] (json) ${routeWithLeadingSlash}`);\n } else {\n logger.info(`[react-dev-server] (other) ${routeWithLeadingSlash}`);\n }\n }\n return {\n route: routeWithLeadingSlash,\n ext,\n isHtmlRequest,\n isRscRequest,\n isCssRequest,\n isCss,\n isHtml,\n isRsc,\n isFolder,\n contentType,\n filePath,\n isJS,\n isVendor,\n isVirtual,\n hasJsHeader,\n isJsRequest,\n isJson,\n isJsonRequest,\n hasCssHeader,\n hasJsonHeader,\n hasHtmlHeader,\n hasRscHeader,\n hasServerActionHeaders,\n isServerActionRequest,\n isFormContentType,\n isFormActionRequest,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAeO,SAAS,YACd,GACA,EAAA,WAAA,EAIA,OACA,EAAA,MAAA,GAAiB,cACjB,EAAA;AACA,EAAA,MAAM,GAAG,KAAK,IAAI,WAAY,CAAA,UAAA,CAAW,IAAI,GAAG,CAAA;AAChD,EAAM,MAAA,QAAA,GAAW,KAAM,CAAA,WAAA,CAAY,GAAG,CAAA;AACtC,EAAA,MAAM,MAAM,QAAa,KAAA,EAAA,GAAK,EAAK,GAAA,KAAA,CAAM,MAAM,QAAQ,CAAA;AAEvD,EAAA,MAAM,QAAW,GAAA,WAAA,CAAY,YAAa,CAAA,aAAA,CAAc,KAAK,CAAA;AAC7D,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AAAA,IACA,YAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,WAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAA;AAAA,IACA,aAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA,aAAA;AAAA,IACA,YAAA;AAAA,IACA,sBAAA;AAAA,IACA,qBAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePage.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/resolvePage.ts"],"names":[],"mappings":"AAEA,KAAK,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,CAAC,CAAC;IACd,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACtC,CAAC;AAEF,KAAK,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IACtC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE;SAAG,GAAG,IAAI,CAAC,GAAG,CAAC;KAAE,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,EAAE,CAAC,SAAS,MAAM,+BAIlD,kBAAkB,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"resolvePage.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/resolvePage.ts"],"names":[],"mappings":"AAEA,KAAK,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,CAAC,CAAC;IACd,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACtC,CAAC;AAEF,KAAK,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IACtC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE;SAAG,GAAG,IAAI,CAAC,GAAG,CAAC;KAAE,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,EAAE,CAAC,SAAS,MAAM,+BAIlD,kBAAkB,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAgEzD,CAAC"}
|
|
@@ -45,11 +45,10 @@ const resolvePage = async ({
|
|
|
45
45
|
error: toError(module.error)
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
+
console.log({ module });
|
|
48
49
|
return {
|
|
49
50
|
type: "error",
|
|
50
|
-
error: new Error(
|
|
51
|
-
`Export "${exportName}" not found in module ${id}.`
|
|
52
|
-
)
|
|
51
|
+
error: new Error(`Export "${exportName}" not found in module ${id}.`)
|
|
53
52
|
};
|
|
54
53
|
} else if (!Page) {
|
|
55
54
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePage.js","sources":["../../../plugin/helpers/resolvePage.ts"],"sourcesContent":["import { toError } from \"../error/toError.js\";\n\ntype ResolvePageOptions<N extends string> = {\n id: string;\n exportName: N;\n loader: (id: string) => Promise<any>;\n};\n\ntype ResolvePageResult<T, N extends string> =\n | { type: \"success\"; Page: T; module: { [key in N]: T } }\n | { type: \"error\"; error: Error }\n | { type: \"skip\" };\n\n/**\n * Resolves a page component from a module.\n *\n * During development (ssrLoadModule):\n * - Real modules have exports available directly on the module object\n * - Virtual modules have exports stored in temporaryReferences\n *\n * @param options.id - The module ID to resolve\n * @param options.exportName - The name of the export to resolve (e.g. 'Page')\n * @param options.loader - The loader function to use for loading the module\n *\n * @returns A result object containing:\n * - type: \"success\" | \"error\" | \"skip\"\n * - Page: The resolved page component if successful\n * - error: Error message if failed\n */\nexport const resolvePage = async <T, N extends string>({\n id,\n exportName,\n loader,\n}: ResolvePageOptions<N>): Promise<ResolvePageResult<T, N>> => {\n // Check if this is a stashed page that needs special handling\n const pageLoadResult = await (async (): Promise<\n | { type: \"success\"; key: string; module: { [key in N]: T } }\n | { type: \"error\"; error: Error; module?: never }\n > => {\n try {\n return {\n type: \"success\",\n key: id,\n module: await loader(id),\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n })();\n\n if (pageLoadResult.type !== \"success\") {\n return pageLoadResult;\n }\n const { module } = pageLoadResult;\n const Page = module[exportName as N];\n if (module instanceof Error) {\n return {\n type: \"error\",\n error: {\n name: module.name,\n message: module.message,\n stack: module.stack,\n },\n };\n } else if (!(exportName in module)) {\n if (\"error\" in module) {\n return {\n type: \"error\",\n error: toError(module.error),\n };\n }\n return {\n type: \"error\",\n error: new Error(
|
|
1
|
+
{"version":3,"file":"resolvePage.js","sources":["../../../plugin/helpers/resolvePage.ts"],"sourcesContent":["import { toError } from \"../error/toError.js\";\n\ntype ResolvePageOptions<N extends string> = {\n id: string;\n exportName: N;\n loader: (id: string) => Promise<any>;\n};\n\ntype ResolvePageResult<T, N extends string> =\n | { type: \"success\"; Page: T; module: { [key in N]: T } }\n | { type: \"error\"; error: Error }\n | { type: \"skip\" };\n\n/**\n * Resolves a page component from a module.\n *\n * During development (ssrLoadModule):\n * - Real modules have exports available directly on the module object\n * - Virtual modules have exports stored in temporaryReferences\n *\n * @param options.id - The module ID to resolve\n * @param options.exportName - The name of the export to resolve (e.g. 'Page')\n * @param options.loader - The loader function to use for loading the module\n *\n * @returns A result object containing:\n * - type: \"success\" | \"error\" | \"skip\"\n * - Page: The resolved page component if successful\n * - error: Error message if failed\n */\nexport const resolvePage = async <T, N extends string>({\n id,\n exportName,\n loader,\n}: ResolvePageOptions<N>): Promise<ResolvePageResult<T, N>> => {\n // Check if this is a stashed page that needs special handling\n const pageLoadResult = await (async (): Promise<\n | { type: \"success\"; key: string; module: { [key in N]: T } }\n | { type: \"error\"; error: Error; module?: never }\n > => {\n try {\n return {\n type: \"success\",\n key: id,\n module: await loader(id),\n };\n } catch (error) {\n return {\n type: \"error\",\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n })();\n\n if (pageLoadResult.type !== \"success\") {\n return pageLoadResult;\n }\n const { module } = pageLoadResult;\n const Page = module[exportName as N];\n if (module instanceof Error) {\n return {\n type: \"error\",\n error: {\n name: module.name,\n message: module.message,\n stack: module.stack,\n },\n };\n } else if (!(exportName in module)) {\n if (\"error\" in module) {\n return {\n type: \"error\",\n error: toError(module.error),\n };\n }\n console.log({ module });\n return {\n type: \"error\",\n error: new Error(`Export \"${exportName}\" not found in module ${id}.`),\n };\n } else if (!Page) {\n return {\n type: \"error\",\n error: new Error(\n `Export \"${exportName}\" is null or undefined in module ${id}.`\n ),\n };\n } else if (Page instanceof Error) {\n return {\n type: \"error\",\n error: Page,\n };\n }\n return {\n type: \"success\",\n Page,\n module: module as { [key in N]: T },\n };\n};\n"],"names":[],"mappings":";;;;;;;AA6BO,MAAM,cAAc,OAA4B;AAAA,EACrD,EAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAA+D,KAAA;AAE7D,EAAM,MAAA,cAAA,GAAiB,OAAO,YAGzB;AACH,IAAI,IAAA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AAM,EAAA,OAAA;AAAA,MACN,OAAO,IAAI,KAAA;AAAA,QACT,CAAA,QAAA,EAAW,UAAU,CAAA,iCAAA,EAAoC,EAAE,CAAA,CAAA;AAAA;AAC7D,KACF;AAAA,GACF,MAAA,IAAW,gBAAgB,KAAO,EAAA;AAChC,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,KAAO,EAAA;AAAA,KACT;AAAA;AAEF,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,SAAA;AAAA,IACN,IAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PageComponentType, PagePropOpt } from "../types.js";
|
|
1
2
|
type ResolvePageAndPropsOptions<N1 extends string, N2 extends string> = {
|
|
2
3
|
pagePath: string;
|
|
3
4
|
pageExportName: N1;
|
|
@@ -6,10 +7,10 @@ type ResolvePageAndPropsOptions<N1 extends string, N2 extends string> = {
|
|
|
6
7
|
route: string;
|
|
7
8
|
loader: (id: string) => Promise<any>;
|
|
8
9
|
};
|
|
9
|
-
type ResolvePageAndPropsResult<T> = {
|
|
10
|
+
type ResolvePageAndPropsResult<T extends PagePropOpt = PagePropOpt> = {
|
|
10
11
|
type: "success";
|
|
11
12
|
error?: never;
|
|
12
|
-
PageComponent:
|
|
13
|
+
PageComponent: PageComponentType<T>;
|
|
13
14
|
pageProps: T;
|
|
14
15
|
} | {
|
|
15
16
|
type: "error";
|
|
@@ -22,6 +23,6 @@ type ResolvePageAndPropsResult<T> = {
|
|
|
22
23
|
PageComponent?: never;
|
|
23
24
|
pageProps?: never;
|
|
24
25
|
};
|
|
25
|
-
export declare function resolvePageAndProps<T, N1 extends string, N2 extends string>(handlerOptions: ResolvePageAndPropsOptions<N1, N2>): Promise<ResolvePageAndPropsResult<T>>;
|
|
26
|
+
export declare function resolvePageAndProps<T extends PagePropOpt = PagePropOpt, N1 extends string = string, N2 extends string = string>(handlerOptions: ResolvePageAndPropsOptions<N1, N2>): Promise<ResolvePageAndPropsResult<T>>;
|
|
26
27
|
export {};
|
|
27
28
|
//# sourceMappingURL=resolvePageAndProps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvePageAndProps.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/resolvePageAndProps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolvePageAndProps.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/resolvePageAndProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIlE,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,SAAS,WAAW,GAAG,WAAW,IAC9D;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,aAAa,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACpC,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,SAAS,WAAW,GAAG,WAAW,EACnC,EAAE,SAAS,MAAM,GAAG,MAAM,EAC1B,EAAE,SAAS,MAAM,GAAG,MAAM,EAE1B,cAAc,EAAE,0BAA0B,CAAC,EAAE,EAAE,EAAE,CAAC,GACjD,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,CA6CvC"}
|
|
@@ -1 +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:
|
|
1
|
+
{"version":3,"file":"resolvePageAndProps.js","sources":["../../../plugin/helpers/resolvePageAndProps.ts"],"sourcesContent":["import type { PageComponentType, PagePropOpt } from \"../types.js\";\nimport { 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 extends PagePropOpt = PagePropOpt> =\n | {\n type: \"success\";\n error?: never;\n PageComponent: PageComponentType<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 extends PagePropOpt = PagePropOpt,\n N1 extends string = string,\n N2 extends string = 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 === \"error\") {\n return resolvePageResult.error\n }\n if (resolvePageResult.type === \"skip\") {\n return null;\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 PageComponentType<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":";;;;;;;;AAiCA,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,SAAS,OAAS,EAAA;AACtC,UAAA,OAAOA,kBAAkB,CAAA,KAAA;AAAA;AAE3B,QAAIA,IAAAA,kBAAAA,CAAkB,SAAS,MAAQ,EAAA;AACrC,UAAO,OAAA,IAAA;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;;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ResolvedConfig, ViteDevServer } from "vite";
|
|
2
|
-
import type { AutoDiscoveredFiles, ResolvedUserOptions } from "../types.js";
|
|
2
|
+
import type { AutoDiscoveredFiles, ResolvedUserOptions, PagePropOpt, InlineCssOpt } from "../types.js";
|
|
3
3
|
export declare function deserializeRegExp(obj: any): any;
|
|
4
4
|
export declare function processForSerialization(obj: any): any;
|
|
5
5
|
export declare function serializeResolvedConfig<T extends ResolvedConfig>(config: T, knownNonSerializableFunctions?: Set<string>): any;
|
|
6
6
|
export declare const serializedDevServerConfig: <T extends ViteDevServer["config"]>(config: T, customNonSerializableFunctions?: Set<string>) => any;
|
|
7
|
-
export declare const serializedOptions: <T extends
|
|
7
|
+
export declare const serializedOptions: <T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt>(userOptions: ResolvedUserOptions<T, InlineCSS>, autoDiscoveredFiles: AutoDiscoveredFiles, customNonSerializableFunctions?: Set<string>) => any;
|
|
8
|
+
export declare function hydrateUserOptions(userOptions: any): any;
|
|
8
9
|
//# sourceMappingURL=serializeUserOptions.d.ts.map
|
|
@@ -1 +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,
|
|
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,EACnB,WAAW,EACX,YAAY,EACb,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,WAAW,gBAAgB,SAAS,SAAS,YAAY,8BACtF,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,uBACzB,mBAAmB,mCACR,GAAG,CAAC,MAAM,CAAC,QA8B5C,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,GAAG,OAclD"}
|
|
@@ -177,6 +177,18 @@ const serializedOptions = (userOptions, autoDiscoveredFiles, customNonSerializab
|
|
|
177
177
|
customNonSerializableFunctions
|
|
178
178
|
));
|
|
179
179
|
};
|
|
180
|
+
function hydrateUserOptions(userOptions) {
|
|
181
|
+
if (!userOptions) return userOptions;
|
|
182
|
+
if (userOptions.autoDiscover) {
|
|
183
|
+
const { autoDiscover } = userOptions;
|
|
184
|
+
for (const key in autoDiscover) {
|
|
185
|
+
if (typeof autoDiscover[key] === "string" && autoDiscover[key].startsWith("__REGEXP__")) {
|
|
186
|
+
autoDiscover[key] = deserializeRegExp(autoDiscover[key]);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return userOptions;
|
|
191
|
+
}
|
|
180
192
|
|
|
181
|
-
export { deserializeRegExp, processForSerialization, serializeResolvedConfig, serializedDevServerConfig, serializedOptions };
|
|
193
|
+
export { deserializeRegExp, hydrateUserOptions, processForSerialization, serializeResolvedConfig, serializedDevServerConfig, serializedOptions };
|
|
182
194
|
//# sourceMappingURL=serializeUserOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeUserOptions.js","sources":["../../../plugin/helpers/serializeUserOptions.ts"],"sourcesContent":["import type { ResolvedConfig, ViteDevServer } from \"vite\";\nimport type {\n AutoDiscoveredFiles,\n ResolvedUserOptions,\n} from \"../types.js\";\nimport { cleanObject } from \"./cleanObject.js\";\n\n// Common non-serializable functions in Vite's resolved config\nconst VITE_NON_SERIALIZABLE_FUNCTIONS = new Set([\n \"renderChunk\",\n \"buildStart\",\n \"buildEnd\",\n \"watchChange\",\n \"resolveId\",\n \"config\",\n \"output[].entryFileNames\",\n \"output[].chunkFileNames\",\n \"output[].assetFileNames\",\n \"transform\",\n \"handler\",\n \"configureServer\",\n \"shouldTransformCachedModule\",\n \"generateBundle\",\n \"renderStart\",\n \"writeBundle\",\n \"hotUpdate\",\n \"configResolved\",\n \"configurePreviewServer\",\n \"handleHotUpdate\",\n \"load\",\n \"augmentChunkHash\",\n \"closeBundle\",\n \"entryFileNames\",\n \"assetFileNames\",\n \"chunkFileNames\",\n \"createEnvironment\",\n \"sourcemapIgnoreList\",\n \"assetsInclude\",\n \"info\",\n \"warn\",\n \"warnOnce\",\n \"error\",\n \"clearScreen\",\n \"hasErrorLogged\",\n \"set\",\n \"plugins\",\n \"getSortedPlugins\",\n \"getSortedPluginHooks\",\n \"createResolver\",\n \"fsDenyGlob\",\n // Nested plugin functions\n \"plugins[].renderChunk\",\n \"plugins[].buildStart\",\n \"plugins[].buildEnd\",\n \"plugins[].watchChange\",\n \"plugins[].resolveId\",\n \"plugins[].config\",\n \"plugins[].transform\",\n \"plugins[].handler\",\n \"plugins[].configureServer\",\n \"plugins[].shouldTransformCachedModule\",\n \"plugins[].generateBundle\",\n \"plugins[].renderStart\",\n \"plugins[].writeBundle\",\n \"plugins[].hotUpdate\",\n \"plugins[].configResolved\",\n \"plugins[].configurePreviewServer\",\n \"plugins[].handleHotUpdate\",\n \"plugins[].load\",\n \"plugins[].augmentChunkHash\",\n \"plugins[].closeBundle\",\n \"plugins[].entryFileNames\",\n \"plugins[].assetFileNames\",\n \"plugins[].chunkFileNames\",\n \"plugins[].createEnvironment\",\n \"plugins[].sourcemapIgnoreList\",\n \"plugins[].assetsInclude\",\n]);\n\n// Common non-serializable functions in our plugin's options\nconst PLUGIN_NON_SERIALIZABLE_FUNCTIONS = new Set([\n \"Page\",\n \"props\",\n \"normalizer\",\n \"CssCollector\",\n \"Html\",\n \"onEvent\",\n \"onMetrics\",\n \"build.entryFile\",\n \"build.chunkFile\",\n \"build.assetFile\",\n \"build.pages\",\n \"autoDiscover\",\n]);\n\n// Helper function to serialize RegExp objects\nfunction serializeRegExp(regex: RegExp) {\n return {\n source: regex.source,\n flags: regex.flags,\n __isRegExp: true\n };\n}\n\n// Helper function to deserialize RegExp objects\nexport function deserializeRegExp(obj: any): any {\n if (obj && obj.__isRegExp) {\n return new RegExp(obj.source, obj.flags);\n }\n if (Array.isArray(obj)) {\n return obj.map(deserializeRegExp);\n }\n if (obj && typeof obj === 'object') {\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = deserializeRegExp(value);\n }\n return result;\n }\n return obj;\n}\n\n// Helper function to recursively process objects for serialization\nexport function processForSerialization(obj: any): any {\n if (obj instanceof RegExp) {\n return serializeRegExp(obj);\n }\n if (Array.isArray(obj)) {\n return obj.map(processForSerialization);\n }\n if (obj && typeof obj === 'object') {\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = processForSerialization(value);\n }\n return result;\n }\n return obj;\n}\n\nexport function serializeResolvedConfig<T extends ResolvedConfig>(\n config: T,\n knownNonSerializableFunctions: Set<string> = VITE_NON_SERIALIZABLE_FUNCTIONS\n) {\n const {\n getSortedPluginHooks,\n getSortedPlugins,\n assetsInclude,\n // extract known vite function properties\n ...handlerOptions\n } = config;\n\n // Clean the object to remove non-serializable properties and process RegExp objects\n return processForSerialization(cleanObject(handlerOptions, knownNonSerializableFunctions));\n}\n\n// For Vite's config\nexport const serializedDevServerConfig = <T extends ViteDevServer[\"config\"]>(\n config: T,\n customNonSerializableFunctions: Set<string> = PLUGIN_NON_SERIALIZABLE_FUNCTIONS\n) => {\n const {\n getSortedPluginHooks,\n getSortedPlugins,\n assetsInclude,\n build,\n ...handlerOptions\n } = config;\n return processForSerialization(cleanObject(\n handlerOptions,\n customNonSerializableFunctions\n ));\n};\n\n// For your own options (if you need custom non-serializable functions)\nexport const serializedOptions = <T extends ResolvedUserOptions>(\n userOptions: T,\n autoDiscoveredFiles: AutoDiscoveredFiles,\n customNonSerializableFunctions: Set<string> = PLUGIN_NON_SERIALIZABLE_FUNCTIONS\n) => {\n const {\n Page,\n props,\n normalizer,\n CssCollector,\n Html,\n onEvent,\n onMetrics,\n build,\n autoDiscover,\n ...handlerOptions\n } = userOptions;\n const { entryFile, chunkFile, assetFile, pages, ...buildOptions } = build ?? {};\n const result = {\n ...handlerOptions,\n build: {\n ...buildOptions,\n pages: autoDiscoveredFiles\n ? Array.from(autoDiscoveredFiles.urlMap.keys())\n : [],\n },\n };\n\n // Clean the object to remove non-serializable properties and process RegExp objects\n return processForSerialization(cleanObject(\n result,\n customNonSerializableFunctions\n ));\n};\n"],"names":[],"mappings":";;;;;;;AAQA,MAAM,+BAAA,uBAAsC,GAAI,CAAA;AAAA,EAC9C,aAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,yBAAA;AAAA,EACA,yBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,iBAAA;AAAA,EACA,6BAAA;AAAA,EACA,gBAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,gBAAA;AAAA,EACA,wBAAA;AAAA,EACA,iBAAA;AAAA,EACA,MAAA;AAAA,EACA,kBAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,qBAAA;AAAA,EACA,eAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,sB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AA;AAAA,IACJ,oBAAA;AAAA,IACA,gBAAA;AAAA,IACA,aAAA;AAAA,IACA,KAAA;AAAA,IACA,GAAG;AAAA,GACD,GAAA,MAAA;AACJ,EAAA,OAAO,uBAAwB,CAAA,WAAA;AAAA,IAC7B,cAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;AAGO,MAAM,iBAAoB,GAAA,CAC/B,WACA,EAAA,mBAAA,EACA,iCAA8C,iCAC3C,KAAA;AACH,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,YAAA;AAAA,IACA,IAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAA;AAAA,IACA,GAAG;AAAA,GACD,GAAA,WAAA;AACJ,EAAM,MAAA,EAAE,WAAW,SAAW,EAAA,SAAA,EAAW,OAAO,GAAG,YAAA,EAAiB,GAAA,KAAA,IAAS,EAAC;AAC9E,EAAA,MAAM,MAAS,GAAA;AAAA,IACb,GAAG,cAAA;AAAA,IACH,KAAO,EAAA;AAAA,MACL,GAAG,YAAA;AAAA,MACH,KAAA,EAAO,sBACH,KAAM,CAAA,IAAA,CAAK,oBAAoB,MAAO,CAAA,IAAA,EAAM,CAAA,GAC5C;AAAC;AACP,GACF;AAGA,EAAA,OAAO,uBAAwB,CAAA,WAAA;AAAA,IAC7B,MAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"serializeUserOptions.js","sources":["../../../plugin/helpers/serializeUserOptions.ts"],"sourcesContent":["import type { ResolvedConfig, ViteDevServer } from \"vite\";\nimport type {\n AutoDiscoveredFiles,\n ResolvedUserOptions,\n PagePropOpt,\n InlineCssOpt,\n} from \"../types.js\";\nimport { cleanObject } from \"./cleanObject.js\";\n\n// Common non-serializable functions in Vite's resolved config\nconst VITE_NON_SERIALIZABLE_FUNCTIONS = new Set([\n \"renderChunk\",\n \"buildStart\",\n \"buildEnd\",\n \"watchChange\",\n \"resolveId\",\n \"config\",\n \"output[].entryFileNames\",\n \"output[].chunkFileNames\",\n \"output[].assetFileNames\",\n \"transform\",\n \"handler\",\n \"configureServer\",\n \"shouldTransformCachedModule\",\n \"generateBundle\",\n \"renderStart\",\n \"writeBundle\",\n \"hotUpdate\",\n \"configResolved\",\n \"configurePreviewServer\",\n \"handleHotUpdate\",\n \"load\",\n \"augmentChunkHash\",\n \"closeBundle\",\n \"entryFileNames\",\n \"assetFileNames\",\n \"chunkFileNames\",\n \"createEnvironment\",\n \"sourcemapIgnoreList\",\n \"assetsInclude\",\n \"info\",\n \"warn\",\n \"warnOnce\",\n \"error\",\n \"clearScreen\",\n \"hasErrorLogged\",\n \"set\",\n \"plugins\",\n \"getSortedPlugins\",\n \"getSortedPluginHooks\",\n \"createResolver\",\n \"fsDenyGlob\",\n // Nested plugin functions\n \"plugins[].renderChunk\",\n \"plugins[].buildStart\",\n \"plugins[].buildEnd\",\n \"plugins[].watchChange\",\n \"plugins[].resolveId\",\n \"plugins[].config\",\n \"plugins[].transform\",\n \"plugins[].handler\",\n \"plugins[].configureServer\",\n \"plugins[].shouldTransformCachedModule\",\n \"plugins[].generateBundle\",\n \"plugins[].renderStart\",\n \"plugins[].writeBundle\",\n \"plugins[].hotUpdate\",\n \"plugins[].configResolved\",\n \"plugins[].configurePreviewServer\",\n \"plugins[].handleHotUpdate\",\n \"plugins[].load\",\n \"plugins[].augmentChunkHash\",\n \"plugins[].closeBundle\",\n \"plugins[].entryFileNames\",\n \"plugins[].assetFileNames\",\n \"plugins[].chunkFileNames\",\n \"plugins[].createEnvironment\",\n \"plugins[].sourcemapIgnoreList\",\n \"plugins[].assetsInclude\",\n]);\n\n// Common non-serializable functions in our plugin's options\nconst PLUGIN_NON_SERIALIZABLE_FUNCTIONS = new Set([\n \"Page\",\n \"props\",\n \"normalizer\",\n \"CssCollector\",\n \"Html\",\n \"onEvent\",\n \"onMetrics\",\n \"build.entryFile\",\n \"build.chunkFile\",\n \"build.assetFile\",\n \"build.pages\",\n \"autoDiscover\",\n]);\n\n// Helper function to serialize RegExp objects\nfunction serializeRegExp(regex: RegExp) {\n return {\n source: regex.source,\n flags: regex.flags,\n __isRegExp: true\n };\n}\n\n// Helper function to deserialize RegExp objects\nexport function deserializeRegExp(obj: any): any {\n if (obj && obj.__isRegExp) {\n return new RegExp(obj.source, obj.flags);\n }\n if (Array.isArray(obj)) {\n return obj.map(deserializeRegExp);\n }\n if (obj && typeof obj === 'object') {\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = deserializeRegExp(value);\n }\n return result;\n }\n return obj;\n}\n\n// Helper function to recursively process objects for serialization\nexport function processForSerialization(obj: any): any {\n if (obj instanceof RegExp) {\n return serializeRegExp(obj);\n }\n if (Array.isArray(obj)) {\n return obj.map(processForSerialization);\n }\n if (obj && typeof obj === 'object') {\n const result: any = {};\n for (const [key, value] of Object.entries(obj)) {\n result[key] = processForSerialization(value);\n }\n return result;\n }\n return obj;\n}\n\nexport function serializeResolvedConfig<T extends ResolvedConfig>(\n config: T,\n knownNonSerializableFunctions: Set<string> = VITE_NON_SERIALIZABLE_FUNCTIONS\n) {\n const {\n getSortedPluginHooks,\n getSortedPlugins,\n assetsInclude,\n // extract known vite function properties\n ...handlerOptions\n } = config;\n\n // Clean the object to remove non-serializable properties and process RegExp objects\n return processForSerialization(cleanObject(handlerOptions, knownNonSerializableFunctions));\n}\n\n// For Vite's config\nexport const serializedDevServerConfig = <T extends ViteDevServer[\"config\"]>(\n config: T,\n customNonSerializableFunctions: Set<string> = PLUGIN_NON_SERIALIZABLE_FUNCTIONS\n) => {\n const {\n getSortedPluginHooks,\n getSortedPlugins,\n assetsInclude,\n build,\n ...handlerOptions\n } = config;\n return processForSerialization(cleanObject(\n handlerOptions,\n customNonSerializableFunctions\n ));\n};\n\n// For your own options (if you need custom non-serializable functions)\nexport const serializedOptions = <T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt>(\n userOptions: ResolvedUserOptions<T, InlineCSS>,\n autoDiscoveredFiles: AutoDiscoveredFiles,\n customNonSerializableFunctions: Set<string> = PLUGIN_NON_SERIALIZABLE_FUNCTIONS\n) => {\n const {\n Page,\n props,\n normalizer,\n CssCollector,\n Html,\n onEvent,\n onMetrics,\n build,\n autoDiscover,\n ...handlerOptions\n } = userOptions;\n const { entryFile, chunkFile, assetFile, pages, ...buildOptions } = build ?? {};\n const result = {\n ...handlerOptions,\n build: {\n ...buildOptions,\n pages: autoDiscoveredFiles\n ? Array.from(autoDiscoveredFiles.urlMap.keys())\n : [],\n },\n };\n\n // Clean the object to remove non-serializable properties and process RegExp objects\n return processForSerialization(cleanObject(\n result,\n customNonSerializableFunctions\n ));\n};\n\nexport function hydrateUserOptions(userOptions: any) {\n if (!userOptions) return userOptions;\n \n // Restore RegExp objects\n if (userOptions.autoDiscover) {\n const { autoDiscover } = userOptions;\n for (const key in autoDiscover) {\n if (typeof autoDiscover[key] === 'string' && autoDiscover[key].startsWith('__REGEXP__')) {\n autoDiscover[key] = deserializeRegExp(autoDiscover[key]);\n }\n }\n }\n \n return userOptions;\n}\n"],"names":[],"mappings":";;;;;;;AAUA,MAAM,+BAAA,uBAAsC,GAAI,CAAA;AAAA,EAC9C,aAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,yBAAA;AAAA,EACA,yBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,iBAAA;AAAA,EACA,6BAAA;AAAA,EACA,gBAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,gBAAA;AAAA,EACA,wBAAA;AAAA,EACA,iBAAA;AAAA,EACA,MAAA;AAAA,EACA,kBAAA;AAAA,EACA,aAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AAAA,EACA,gBAAA;AA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;AAC5B,IAAM,MAAA,EAAE,cAAiB,GAAA,WAAA;AACzB,IAAA,KAAA,MAAW,OAAO,YAAc,EAAA;AAC9B,MAAI,IAAA,OAAO,YAAa,CAAA,GAAG,CAAM,KAAA,QAAA,IAAY,aAAa,GAAG,CAAA,CAAE,UAAW,CAAA,YAAY,CAAG,EAAA;AACvF,QAAA,YAAA,CAAa,GAAG,CAAA,GAAI,iBAAkB,CAAA,YAAA,CAAa,GAAG,CAAC,CAAA;AAAA;AACzD;AACF;AAGF,EAAO,OAAA,WAAA;AACT;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SourceMap } from "../types/sourceMap.js";
|
|
2
|
+
export declare function encodeVLQ(numbers: number[]): string;
|
|
3
|
+
export declare function decodeVLQ(str: string): number[];
|
|
4
|
+
export declare function readMappings(mappings: string, callback: (generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number, originalColumn: number, nameIndex: number) => void): void;
|
|
5
|
+
export declare function createMappingsSerializer(): (generatedLine: number, generatedColumn: number, originalFile: number, originalLine: number, originalColumn: number, nameIndex: number) => string;
|
|
6
|
+
export declare function createSourceMap(originalSource: string): SourceMap;
|
|
7
|
+
export declare function updateSourceMap(sourceMap: SourceMap, originalSource: string): void;
|
|
8
|
+
//# sourceMappingURL=sourceMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceMap.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/sourceMap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AASvD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBnD;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAyB/C;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CACR,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,KACd,IAAI,QA4CV;AAED,wBAAgB,wBAAwB,oBASrB,MAAM,mBACJ,MAAM,gBACT,MAAM,gBACN,MAAM,kBACJ,MAAM,aACX,MAAM,KAChB,MAAM,CAiCV;AAED,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAUjE;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,QAI3E"}
|