vite-plugin-react-server 1.1.13 → 1.1.14
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 +3 -1
- package/dist/plugin/config/defaults.d.ts +2 -2
- package/dist/plugin/config/defaults.d.ts.map +1 -1
- package/dist/plugin/config/defaults.js +2 -2
- package/dist/plugin/config/defaults.js.map +1 -1
- package/dist/plugin/config/resolveOptions.d.ts.map +1 -1
- package/dist/plugin/config/resolveOptions.js +98 -61
- package/dist/plugin/config/resolveOptions.js.map +1 -1
- package/dist/plugin/error/toError.d.ts.map +1 -1
- package/dist/plugin/error/toError.js +0 -1
- package/dist/plugin/error/toError.js.map +1 -1
- package/dist/plugin/helpers/collectManifestCss.d.ts +1 -2
- package/dist/plugin/helpers/collectManifestCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectManifestCss.js +3 -5
- package/dist/plugin/helpers/collectManifestCss.js.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.d.ts.map +1 -1
- package/dist/plugin/helpers/collectViteModuleGraphCss.js +6 -2
- package/dist/plugin/helpers/collectViteModuleGraphCss.js.map +1 -1
- package/dist/plugin/helpers/createCssProps.d.ts +1 -1
- package/dist/plugin/helpers/createCssProps.d.ts.map +1 -1
- package/dist/plugin/helpers/createCssProps.js +11 -32
- package/dist/plugin/helpers/createCssProps.js.map +1 -1
- package/dist/plugin/helpers/createRscStream.d.ts.map +1 -1
- package/dist/plugin/helpers/createRscStream.js +1 -0
- package/dist/plugin/helpers/createRscStream.js.map +1 -1
- package/dist/plugin/loader/createDefaultLoader.d.ts.map +1 -1
- package/dist/plugin/loader/createDefaultLoader.js +68 -4
- package/dist/plugin/loader/css-loader.development.d.ts +2 -15
- package/dist/plugin/loader/css-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.development.js +16 -15
- package/dist/plugin/loader/css-loader.development.js.map +1 -1
- package/dist/plugin/loader/css-loader.production.d.ts +1 -1
- package/dist/plugin/loader/css-loader.production.d.ts.map +1 -1
- package/dist/plugin/loader/css-loader.production.js +1 -1
- package/dist/plugin/loader/css-loader.production.js.map +1 -1
- package/dist/plugin/loader/env-loader.development.d.ts +1 -0
- package/dist/plugin/loader/env-loader.development.d.ts.map +1 -1
- package/dist/plugin/loader/env-loader.development.js +17 -9
- package/dist/plugin/loader/handleExports.d.ts +1 -0
- package/dist/plugin/loader/handleExports.d.ts.map +1 -1
- package/dist/plugin/loader/handleExports.js +27 -8
- package/dist/plugin/loader/handleExports.js.map +1 -1
- package/dist/plugin/loader/react-loader.server.d.ts +2 -2
- package/dist/plugin/loader/react-loader.server.d.ts.map +1 -1
- package/dist/plugin/loader/react-loader.server.js +88 -26
- package/dist/plugin/loader/transformModuleIfNeeded.d.ts.map +1 -1
- package/dist/plugin/loader/transformModuleIfNeeded.js +1 -1
- package/dist/plugin/loader/transformModuleIfNeeded.js.map +1 -1
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.d.ts.map +1 -1
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js +86 -13
- package/dist/plugin/loader/transformModuleWithPreservedFunctions.js.map +1 -1
- package/dist/plugin/plugin.client.d.ts.map +1 -1
- package/dist/plugin/plugin.client.js +0 -1
- package/dist/plugin/plugin.client.js.map +1 -1
- package/dist/plugin/react-client/configureWorkerRequestHandler.d.ts.map +1 -1
- package/dist/plugin/react-client/configureWorkerRequestHandler.js +85 -6
- package/dist/plugin/react-client/configureWorkerRequestHandler.js.map +1 -1
- package/dist/plugin/react-client/createMessageHandlers.d.ts.map +1 -1
- package/dist/plugin/react-client/createMessageHandlers.js +3 -0
- package/dist/plugin/react-client/createMessageHandlers.js.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.d.ts +2 -2
- package/dist/plugin/react-client/createWorkerStream.d.ts.map +1 -1
- package/dist/plugin/react-client/createWorkerStream.js +13 -2
- package/dist/plugin/react-client/createWorkerStream.js.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.d.ts.map +1 -1
- package/dist/plugin/react-client/handleWorkerRscStream.js +10 -3
- package/dist/plugin/react-client/handleWorkerRscStream.js.map +1 -1
- package/dist/plugin/react-client/restartWorker.d.ts.map +1 -1
- package/dist/plugin/react-client/restartWorker.js +2 -1
- package/dist/plugin/react-client/restartWorker.js.map +1 -1
- package/dist/plugin/react-server/configureReactServer.d.ts.map +1 -1
- package/dist/plugin/react-server/configureReactServer.js +1 -2
- package/dist/plugin/react-server/configureReactServer.js.map +1 -1
- package/dist/plugin/react-server/handleServerAction.d.ts.map +1 -1
- package/dist/plugin/react-server/handleServerAction.js +0 -16
- package/dist/plugin/react-server/handleServerAction.js.map +1 -1
- package/dist/plugin/react-static/createBuildLoader.d.ts.map +1 -0
- package/dist/plugin/react-static/createBuildLoader.js.map +1 -0
- package/dist/plugin/react-static/plugin.d.ts.map +1 -1
- package/dist/plugin/react-static/plugin.js +9 -12
- package/dist/plugin/react-static/plugin.js.map +1 -1
- package/dist/plugin/react-static/temporaryReferences.d.ts.map +1 -0
- package/dist/plugin/react-static/temporaryReferences.js.map +1 -0
- package/dist/plugin/transformer/plugin.server.js +2 -2
- package/dist/plugin/transformer/plugin.server.js.map +1 -1
- package/dist/plugin/types.d.ts +14 -3
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/handleRender.js +1 -0
- package/dist/plugin/worker/rsc/handleRender.js.map +1 -1
- package/dist/plugin/worker/rsc/handlers.d.ts +3 -0
- package/dist/plugin/worker/rsc/handlers.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/handlers.js +223 -0
- package/dist/plugin/worker/rsc/handlers.js.map +1 -0
- package/dist/plugin/worker/rsc/messageHandler.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/messageHandler.js +5 -110
- package/dist/plugin/worker/rsc/messageHandler.js.map +1 -1
- package/dist/plugin/worker/rsc/rsc-worker.development.js +13 -16
- package/dist/plugin/worker/rsc/rsc-worker.development.js.map +1 -1
- package/dist/plugin/worker/rsc/state.d.ts +1 -2
- package/dist/plugin/worker/rsc/state.d.ts.map +1 -1
- package/dist/plugin/worker/rsc/state.js +1 -2
- package/dist/plugin/worker/rsc/state.js.map +1 -1
- package/dist/plugin/worker/rsc/userOptions.d.ts +2 -0
- package/dist/plugin/worker/rsc/userOptions.d.ts.map +1 -0
- package/dist/plugin/worker/rsc/userOptions.js +17 -0
- package/dist/plugin/worker/rsc/userOptions.js.map +1 -0
- package/dist/plugin/worker/types.d.ts +2 -1
- package/dist/plugin/worker/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -1
- package/plugin/config/defaults.tsx +5 -2
- package/plugin/config/resolveOptions.ts +101 -67
- package/plugin/error/toError.ts +0 -2
- package/plugin/helpers/collectManifestCss.ts +2 -6
- package/plugin/helpers/collectViteModuleGraphCss.ts +6 -0
- package/plugin/helpers/createCssProps.tsx +17 -46
- package/plugin/helpers/createRscStream.tsx +1 -0
- package/plugin/loader/createDefaultLoader.ts +80 -4
- package/plugin/loader/css-loader.development.ts +17 -34
- package/plugin/loader/css-loader.production.ts +2 -4
- package/plugin/loader/env-loader.development.ts +38 -15
- package/plugin/loader/handleExports.ts +36 -13
- package/plugin/loader/react-loader.server.ts +110 -32
- package/plugin/loader/transformModuleIfNeeded.ts +2 -2
- package/plugin/loader/transformModuleWithPreservedFunctions.ts +128 -21
- package/plugin/plugin.client.ts +0 -2
- package/plugin/react-client/configureWorkerRequestHandler.ts +107 -4
- package/plugin/react-client/createMessageHandlers.ts +3 -0
- package/plugin/react-client/createWorkerStream.ts +15 -1
- package/plugin/react-client/handleWorkerRscStream.ts +12 -3
- package/plugin/react-client/restartWorker.ts +1 -0
- package/plugin/react-server/configureReactServer.ts +1 -2
- package/plugin/react-server/handleServerAction.ts +1 -19
- package/plugin/react-static/plugin.ts +9 -12
- package/plugin/transformer/plugin.server.ts +2 -2
- package/plugin/types.ts +25 -2
- package/plugin/worker/rsc/handleRender.ts +1 -0
- package/plugin/worker/rsc/handlers.ts +243 -0
- package/plugin/worker/rsc/messageHandler.tsx +4 -118
- package/plugin/worker/rsc/rsc-worker.development.ts +17 -20
- package/plugin/worker/rsc/state.ts +2 -6
- package/plugin/worker/rsc/userOptions.ts +8 -0
- package/plugin/worker/types.ts +2 -0
- package/dist/plugin/loader/createBuildLoader.d.ts.map +0 -1
- package/dist/plugin/loader/createBuildLoader.js.map +0 -1
- package/dist/plugin/loader/plugin.d.ts +0 -22
- package/dist/plugin/loader/plugin.d.ts.map +0 -1
- package/dist/plugin/loader/plugin.js +0 -27
- package/dist/plugin/loader/temporaryReferences.d.ts.map +0 -1
- package/dist/plugin/loader/temporaryReferences.js.map +0 -1
- package/plugin/loader/plugin.ts +0 -33
- /package/dist/plugin/{loader → react-static}/createBuildLoader.d.ts +0 -0
- /package/dist/plugin/{loader → react-static}/createBuildLoader.js +0 -0
- /package/dist/plugin/{loader → react-static}/temporaryReferences.d.ts +0 -0
- /package/dist/plugin/{loader → react-static}/temporaryReferences.js +0 -0
- /package/plugin/{loader → react-static}/createBuildLoader.ts +0 -0
- /package/plugin/{loader → react-static}/temporaryReferences.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectViteModuleGraphCss.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/collectViteModuleGraphCss.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAG,YAAY,EAAG,WAAW,EAAE,MAAM,aAAa,CAAC;AAGjG,KAAK,+BAA+B,GAChC;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,CAAC;AAEN,wBAAsB,yBAAyB,CAC7C,CAAC,SAAS,WAAW,GAAG,WAAW,EACnC,SAAS,SAAS,YAAY,GAAG,YAAY,EAC7C,EACA,WAAW,EACX,KAAK,EACL,SAAS,EACT,cAAc,GACf,EAAE;IACD,WAAW,EAAE,WAAW,GAAG,sBAAsB,CAAC;IAClD,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,IAAI,CAClB,oBAAoB,CAAC,CAAC,EAAE,SAAS,CAAC,EAChC,UAAU,GACV,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,aAAa,GACb,KAAK,GACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"collectViteModuleGraphCss.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/collectViteModuleGraphCss.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAG,YAAY,EAAG,WAAW,EAAE,MAAM,aAAa,CAAC;AAGjG,KAAK,+BAA+B,GAChC;IACE,IAAI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
|
-
loader
|
|
21
|
+
loader,
|
|
22
|
+
normalizer,
|
|
23
|
+
moduleID
|
|
22
24
|
} = handlerOptions;
|
|
23
25
|
if (!pagePath) return { type: "skip" };
|
|
24
26
|
const cssFiles = /* @__PURE__ */ new Map();
|
|
@@ -56,7 +58,9 @@ async function collectViteModuleGraphCss({
|
|
|
56
58
|
moduleBasePath,
|
|
57
59
|
moduleRootPath,
|
|
58
60
|
projectRoot,
|
|
59
|
-
css
|
|
61
|
+
css,
|
|
62
|
+
normalizer,
|
|
63
|
+
moduleID
|
|
60
64
|
}
|
|
61
65
|
});
|
|
62
66
|
cssFiles.set(mod?.url, cssContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectViteModuleGraphCss.js","sources":["../../../plugin/helpers/collectViteModuleGraphCss.ts"],"sourcesContent":["import type { EnvironmentModuleGraph, ModuleGraph } from \"vite\";\nimport type { CreateHandlerOptions, CssContent, InlineCssOpt, PagePropOpt } from \"../types.js\";\nimport { createCssProps } from \"./createCssProps.js\";\n\ntype CollectViteModuleGraphCssResult =\n | {\n type: \"success\";\n cssFiles: Map<string, CssContent>;\n error?: never;\n metrics: {\n cssFiles: number;\n processing: number;\n };\n }\n | {\n type: \"error\";\n error: Error;\n cssFiles?: never;\n metrics: {\n cssFiles: number;\n processing: number;\n };\n }\n | {\n type: \"skip\";\n cssFiles?: never;\n error?: never;\n metrics?: never;\n };\n\nexport async function collectViteModuleGraphCss<\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n>({\n moduleGraph,\n onCss,\n parentUrl,\n handlerOptions,\n}: {\n moduleGraph: ModuleGraph | EnvironmentModuleGraph;\n onCss?: (cssContent: CssContent, parentUrl: string) => void;\n parentUrl?: string;\n handlerOptions: Pick<\n CreateHandlerOptions<T, InlineCSS>,\n | \"pagePath\"\n | \"moduleBaseURL\"\n | \"moduleBasePath\"\n | \"moduleRootPath\"\n | \"projectRoot\"\n | \"css\"\n | \"loader\"\n >;\n}): Promise<CollectViteModuleGraphCssResult> {\n const {\n pagePath,\n moduleBaseURL,\n moduleBasePath,\n moduleRootPath,\n projectRoot,\n css,\n loader,\n } = handlerOptions;\n if (!pagePath) return { type: \"skip\" };\n\n const cssFiles = new Map<string, CssContent>();\n const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);\n if (!pageModule) {\n return { type: \"skip\" };\n }\n\n const seen = new Set<string>();\n const processing = new Set<string>();\n\n const walkModule = async (mod: any) => {\n if (!mod?.id) {\n // Module has no id\n return;\n }\n\n if (seen.has(mod.id)) {\n // Already processed module\n return;\n }\n\n if (processing.has(mod.id)) {\n // Circular dependency detected for module\n return;\n }\n\n processing.add(mod.id);\n // Processing module\n if (mod.id.endsWith(\".css\")) {\n const string = await loader(mod.id + \"?inline\").then(\n (m) => m?.[\"default\"] ?? \"\"\n );\n if (typeof string !== \"string\") {\n throw new Error(`CSS module ${mod.id}?inline did not return a string`);\n } else if (string === \"\") {\n throw new Error(`CSS module ${mod.id}?inline returned an empty string`);\n }\n const cssContent = createCssProps({\n id: mod?.url,\n code: string,\n userOptions: {\n moduleBaseURL: moduleBaseURL,\n moduleBasePath: moduleBasePath,\n moduleRootPath: moduleRootPath,\n projectRoot: projectRoot,\n css: css,\n },\n });\n cssFiles.set(mod?.url, cssContent);\n onCss?.(cssContent, parentUrl ?? pagePath);\n }\n\n if (mod.importedModules) {\n // Processing imports for module\n const importedModules = Array.from(mod.importedModules);\n // Found imported modules\n for (const importedMod of importedModules) {\n if (typeof importedMod === \"object\" && importedMod != null) {\n if (\n \"id\" in importedMod &&\n importedMod.id &&\n typeof importedMod.id === \"string\"\n ) {\n await walkModule(importedMod);\n } else {\n throw new Error(`Imported module has no id`);\n }\n } else {\n throw new Error(`Imported module is not an object`);\n }\n }\n }\n\n processing.delete(mod.id);\n seen.add(mod.id);\n };\n\n try {\n await walkModule(pageModule);\n } catch (error) {\n return {\n type: \"error\",\n error: error as Error,\n metrics: {\n cssFiles: cssFiles.size,\n processing: processing.size,\n },\n };\n }\n return {\n type: \"success\",\n cssFiles,\n metrics: {\n cssFiles: cssFiles.size,\n processing: processing.size,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;AA8BA,eAAsB,yBAGpB,CAAA;AAAA,EACA,WAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA;AACF,
|
|
1
|
+
{"version":3,"file":"collectViteModuleGraphCss.js","sources":["../../../plugin/helpers/collectViteModuleGraphCss.ts"],"sourcesContent":["import type { EnvironmentModuleGraph, ModuleGraph } from \"vite\";\nimport type { CreateHandlerOptions, CssContent, InlineCssOpt, PagePropOpt } from \"../types.js\";\nimport { createCssProps } from \"./createCssProps.js\";\n\ntype CollectViteModuleGraphCssResult =\n | {\n type: \"success\";\n cssFiles: Map<string, CssContent>;\n error?: never;\n metrics: {\n cssFiles: number;\n processing: number;\n };\n }\n | {\n type: \"error\";\n error: Error;\n cssFiles?: never;\n metrics: {\n cssFiles: number;\n processing: number;\n };\n }\n | {\n type: \"skip\";\n cssFiles?: never;\n error?: never;\n metrics?: never;\n };\n\nexport async function collectViteModuleGraphCss<\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n>({\n moduleGraph,\n onCss,\n parentUrl,\n handlerOptions,\n}: {\n moduleGraph: ModuleGraph | EnvironmentModuleGraph;\n onCss?: (cssContent: CssContent, parentUrl: string) => void;\n parentUrl?: string;\n handlerOptions: Pick<\n CreateHandlerOptions<T, InlineCSS>,\n | \"pagePath\"\n | \"moduleBaseURL\"\n | \"moduleBasePath\"\n | \"moduleRootPath\"\n | \"projectRoot\"\n | \"css\"\n | \"loader\"\n | \"normalizer\"\n | \"moduleID\"\n >;\n}): Promise<CollectViteModuleGraphCssResult> {\n const {\n pagePath,\n moduleBaseURL,\n moduleBasePath,\n moduleRootPath,\n projectRoot,\n css,\n loader,\n normalizer,\n moduleID,\n } = handlerOptions;\n if (!pagePath) return { type: \"skip\" };\n\n const cssFiles = new Map<string, CssContent>();\n const pageModule = await moduleGraph.getModuleByUrl(pagePath, true);\n if (!pageModule) {\n return { type: \"skip\" };\n }\n\n const seen = new Set<string>();\n const processing = new Set<string>();\n\n const walkModule = async (mod: any) => {\n if (!mod?.id) {\n // Module has no id\n return;\n }\n\n if (seen.has(mod.id)) {\n // Already processed module\n return;\n }\n\n if (processing.has(mod.id)) {\n // Circular dependency detected for module\n return;\n }\n\n processing.add(mod.id);\n // Processing module\n if (mod.id.endsWith(\".css\")) {\n const string = await loader(mod.id + \"?inline\").then(\n (m) => m?.[\"default\"] ?? \"\"\n );\n if (typeof string !== \"string\") {\n throw new Error(`CSS module ${mod.id}?inline did not return a string`);\n } else if (string === \"\") {\n throw new Error(`CSS module ${mod.id}?inline returned an empty string`);\n }\n const cssContent = createCssProps({\n id: mod?.url,\n code: string,\n userOptions: {\n moduleBaseURL: moduleBaseURL,\n moduleBasePath: moduleBasePath,\n moduleRootPath: moduleRootPath,\n projectRoot: projectRoot,\n css: css,\n normalizer: normalizer,\n moduleID: moduleID,\n },\n });\n cssFiles.set(mod?.url, cssContent);\n onCss?.(cssContent, parentUrl ?? pagePath);\n }\n\n if (mod.importedModules) {\n // Processing imports for module\n const importedModules = Array.from(mod.importedModules);\n // Found imported modules\n for (const importedMod of importedModules) {\n if (typeof importedMod === \"object\" && importedMod != null) {\n if (\n \"id\" in importedMod &&\n importedMod.id &&\n typeof importedMod.id === \"string\"\n ) {\n await walkModule(importedMod);\n } else {\n throw new Error(`Imported module has no id`);\n }\n } else {\n throw new Error(`Imported module is not an object`);\n }\n }\n }\n\n processing.delete(mod.id);\n seen.add(mod.id);\n };\n\n try {\n await walkModule(pageModule);\n } catch (error) {\n return {\n type: \"error\",\n error: error as Error,\n metrics: {\n cssFiles: cssFiles.size,\n processing: processing.size,\n },\n };\n }\n return {\n type: \"success\",\n cssFiles,\n metrics: {\n cssFiles: cssFiles.size,\n processing: processing.size,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;A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,IAAW,UAAA,CAAA,MAAA,CAAO,IAAI,EAAE,CAAA;AACxB,IAAK,IAAA,CAAA,GAAA,CAAI,IAAI,EAAE,CAAA;AAAA,GACjB;AAEA,EAAI,IAAA;AACF,IAAA,MAAM,WAAW,UAAU,CAAA;AAAA,WACpB,KAAO,EAAA;AACd,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,KAAA;AAAA,MACA,OAAS,EAAA;AAAA,QACP,UAAU,QAAS,CAAA,IAAA;AAAA,QACnB,YAAY,UAAW,CAAA;AAAA;AACzB,KACF;AAAA;AAEF,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,SAAA;AAAA,IACN,QAAA;AAAA,IACA,OAAS,EAAA;AAAA,MACP,UAAU,QAAS,CAAA,IAAA;AAAA,MACnB,YAAY,UAAW,CAAA;AAAA;AACzB,GACF;AACF;;;;"}
|
|
@@ -22,6 +22,6 @@ import type { InlineCssOpt, PagePropOpt } from "../../server.js";
|
|
|
22
22
|
export declare const createCssProps: <T extends PagePropOpt = PagePropOpt, InlineCSS extends InlineCssOpt = InlineCssOpt>({ id, code, userOptions, }: {
|
|
23
23
|
id: string;
|
|
24
24
|
code: string;
|
|
25
|
-
userOptions: Pick<ResolvedUserOptions<T, InlineCSS>, "css" | "moduleBaseURL" | "moduleBasePath" | "moduleRootPath" | "projectRoot">;
|
|
25
|
+
userOptions: Pick<ResolvedUserOptions<T, InlineCSS>, "css" | "moduleBaseURL" | "moduleBasePath" | "moduleRootPath" | "projectRoot" | "normalizer" | "moduleID">;
|
|
26
26
|
}) => CssContent<InlineCSS>;
|
|
27
27
|
//# sourceMappingURL=createCssProps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCssProps.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createCssProps.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAIjE;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,GACzB,CAAC,SAAS,WAAW,gBACrB,SAAS,SAAS,YAAY,6CAK7B;IACD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,IAAI,CACf,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,EAC/B,KAAK,GACL,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,aAAa,
|
|
1
|
+
{"version":3,"file":"createCssProps.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createCssProps.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAIjE;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,GACzB,CAAC,SAAS,WAAW,gBACrB,SAAS,SAAS,YAAY,6CAK7B;IACD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,IAAI,CACf,mBAAmB,CAAC,CAAC,EAAE,SAAS,CAAC,EAC/B,KAAK,GACL,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,aAAa,GACb,YAAY,GACZ,UAAU,CACb,CAAC;CACH,KAAG,UAAU,CAAC,SAAS,CA+CvB,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright (c) Nico Brinkkemper
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { join } from 'node:path';
|
|
7
7
|
import { deserializeRegExp } from './serializeUserOptions.js';
|
|
8
8
|
|
|
9
9
|
const createCssProps = ({
|
|
@@ -11,14 +11,13 @@ const createCssProps = ({
|
|
|
11
11
|
code,
|
|
12
12
|
userOptions
|
|
13
13
|
}) => {
|
|
14
|
-
const { css,
|
|
14
|
+
const { css, moduleRootPath } = userOptions;
|
|
15
15
|
let inline = typeof code === "string" && code.length > css.inlineThreshold;
|
|
16
|
-
const
|
|
16
|
+
const [, value] = userOptions.normalizer(id);
|
|
17
|
+
const moduleID = userOptions.moduleID(value);
|
|
17
18
|
if (css.inlinePatterns?.length) {
|
|
18
|
-
const inlinePatterns = css.inlinePatterns
|
|
19
|
-
|
|
20
|
-
);
|
|
21
|
-
if (inlinePatterns.some((pattern) => pattern.test?.(normalizedId))) {
|
|
19
|
+
const inlinePatterns = css.inlinePatterns;
|
|
20
|
+
if (inlinePatterns.some((pattern) => pattern.test?.(id))) {
|
|
22
21
|
inline = true;
|
|
23
22
|
}
|
|
24
23
|
}
|
|
@@ -26,46 +25,26 @@ const createCssProps = ({
|
|
|
26
25
|
const linkPatterns = css.linkPatterns?.map(
|
|
27
26
|
(pattern) => typeof pattern === "string" ? deserializeRegExp(pattern) : pattern
|
|
28
27
|
);
|
|
29
|
-
if (linkPatterns.some((pattern) => pattern.test?.(
|
|
28
|
+
if (linkPatterns.some((pattern) => pattern.test?.(id))) {
|
|
30
29
|
inline = false;
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
if (inline) {
|
|
34
33
|
return {
|
|
35
34
|
type: "text/css",
|
|
36
|
-
id:
|
|
35
|
+
id: moduleID,
|
|
37
36
|
as: "style",
|
|
38
37
|
children: code.trim(),
|
|
39
38
|
...process.env["NODE_ENV"] !== "production" ? {
|
|
40
|
-
"data-vite-dev-id": join(
|
|
39
|
+
"data-vite-dev-id": join(moduleRootPath, moduleID)
|
|
41
40
|
} : {}
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
|
-
const joined = normalizedId.startsWith(moduleBasePath) ? normalizedId : join(moduleBasePath, normalizedId);
|
|
45
|
-
const moduleBaseHasTrailingSlash = moduleBaseURL.endsWith("/");
|
|
46
|
-
const joinedHasLeadingSlash = joined.startsWith("/");
|
|
47
|
-
const safeParseURL = (() => {
|
|
48
|
-
if (joined.startsWith(
|
|
49
|
-
moduleBaseHasTrailingSlash ? moduleBaseURL.slice(0, -1) : moduleBaseURL
|
|
50
|
-
)) {
|
|
51
|
-
return joined;
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
if (moduleBaseURL.includes("//")) {
|
|
55
|
-
return new URL(
|
|
56
|
-
joinedHasLeadingSlash ? joined.slice(1) : joined,
|
|
57
|
-
moduleBaseURL
|
|
58
|
-
).href;
|
|
59
|
-
}
|
|
60
|
-
} catch (error) {
|
|
61
|
-
}
|
|
62
|
-
return moduleBaseURL + (!moduleBaseHasTrailingSlash && !joinedHasLeadingSlash ? "/" : "") + (moduleBaseHasTrailingSlash ? joined.slice(1) : joined);
|
|
63
|
-
})();
|
|
64
43
|
return {
|
|
65
|
-
id:
|
|
44
|
+
id: moduleID,
|
|
66
45
|
as: "link",
|
|
67
46
|
rel: "stylesheet",
|
|
68
|
-
href:
|
|
47
|
+
href: typeof process.env.VITE_PUBLIC_ORIGIN === "string" && process.env.VITE_PUBLIC_ORIGIN !== "" ? new URL(moduleID, process.env.VITE_PUBLIC_ORIGIN).href : moduleID,
|
|
69
48
|
precedence: "high"
|
|
70
49
|
};
|
|
71
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCssProps.js","sources":["../../../plugin/helpers/createCssProps.tsx"],"sourcesContent":["import type { ResolvedUserOptions, CssContent } from \"../types.js\";\nimport type { InlineCssOpt, PagePropOpt } from \"../../server.js\";\nimport { join
|
|
1
|
+
{"version":3,"file":"createCssProps.js","sources":["../../../plugin/helpers/createCssProps.tsx"],"sourcesContent":["import type { ResolvedUserOptions, CssContent } from \"../types.js\";\nimport type { InlineCssOpt, PagePropOpt } from \"../../server.js\";\nimport { join } from \"node:path\";\nimport { deserializeRegExp } from \"./serializeUserOptions.js\";\n\n/**\n * Creates a CssContent object for a given path and css options\n *\n * Requirements:\n * - path is a string\n * - css is an object with the following properties:\n * - inlineCss: boolean\n * - purgeCss: boolean\n * - inlineThreshold: number\n * - inlinePatterns: RegExp[]\n * - linkPatterns: RegExp[]\n * based on the bundle, we retrieve the css content and check if it should be inlined or linked\n * inlined tags get the as:style and the children are the css content\n * linked tags get the as:link and the href is the path\n *\n * @param path - The path to the css file\n * @param css - The css options\n * @returns A CssContent object\n */\nexport const createCssProps = <\n T extends PagePropOpt = PagePropOpt,\n InlineCSS extends InlineCssOpt = InlineCssOpt\n>({\n id,\n code,\n userOptions,\n}: {\n id: string;\n code: string;\n userOptions: Pick<\n ResolvedUserOptions<T, InlineCSS>,\n | \"css\"\n | \"moduleBaseURL\"\n | \"moduleBasePath\"\n | \"moduleRootPath\"\n | \"projectRoot\"\n | \"normalizer\"\n | \"moduleID\"\n >;\n}): CssContent<InlineCSS> => {\n const { css, moduleRootPath } = userOptions;\n // If we don't have a bundle entry, create a linked CSS file\n let inline = typeof code === \"string\" && code.length > css.inlineThreshold;\n // Normalize the ID to be relative to src/\n const [, value] = userOptions.normalizer(id);\n const moduleID = userOptions.moduleID(value);\n if (css.inlinePatterns?.length) {\n // Deserialize RegExp patterns if they exist\n const inlinePatterns = css.inlinePatterns;\n if (inlinePatterns.some((pattern) => pattern.test?.(id))) {\n inline = true;\n }\n }\n if (css.linkPatterns?.length) {\n const linkPatterns = css.linkPatterns?.map((pattern) =>\n typeof pattern === \"string\" ? deserializeRegExp(pattern) : pattern\n );\n if (linkPatterns.some((pattern) => pattern.test?.(id))) {\n inline = false;\n }\n }\n if (inline) {\n return {\n type: \"text/css\",\n id: moduleID,\n as: \"style\",\n children: code.trim(),\n ...(process.env[\"NODE_ENV\"] !== \"production\"\n ? {\n \"data-vite-dev-id\": join(moduleRootPath, moduleID),\n }\n : {}),\n } as CssContent<InlineCSS>;\n }\n // Default case\n return {\n id: moduleID,\n as: \"link\",\n rel: \"stylesheet\",\n href:\n typeof process.env.VITE_PUBLIC_ORIGIN === \"string\" &&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ACJ,EAAI,EAAA,OAAA;AAAA,MACJ,QAAA,EAAU,KAAK,IAAK,EAAA;AAAA,MACpB,GAAI,OAAA,CAAQ,GAAI,CAAA,UAAU,MAAM,YAC5B,GAAA;AAAA,QACE,kBAAA,EAAoB,IAAK,CAAA,cAAA,EAAgB,QAAQ;AAAA,UAEnD;AAAC,KACP;AAAA;AAGF,EAAO,OAAA;AAAA,IACL,EAAI,EAAA,QAAA;AAAA,IACJ,EAAI,EAAA,MAAA;AAAA,IACJ,GAAK,EAAA,YAAA;AAAA,IACL,MACE,OAAO,OAAA,CAAQ,GAAI,CAAA,kBAAA,KAAuB,YAC1C,OAAQ,CAAA,GAAA,CAAI,kBAAuB,KAAA,EAAA,GAC/B,IAAI,GAAI,CAAA,QAAA,EAAU,QAAQ,GAAI,CAAA,kBAAkB,EAAE,IAClD,GAAA,QAAA;AAAA,IACN,UAAY,EAAA;AAAA,GACd;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRscStream.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createRscStream.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,WAAW,EACZ,MAAM,aAAa,CAAC;AAGrB,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAAE,EACnE,IAAqB,EACrB,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,QAAoB,EACpB,SAAqB,EACrB,KAAK,EACL,qBAAqB,EACrB,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,WAAW,GACZ,EAAE,IAAI,CACL,oBAAoB,CAAC,CAAC,CAAC,EACrB,MAAM,GACN,eAAe,GACf,WAAW,GACX,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,UAAU,GACV,OAAO,GACP,uBAAuB,GACvB,cAAc,GACd,WAAW,GACX,UAAU,GACV,aAAa,CAChB,GAAG;IACF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAC5D,GACG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"createRscStream.d.ts","sourceRoot":"","sources":["../../../plugin/helpers/createRscStream.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,WAAW,EACZ,MAAM,aAAa,CAAC;AAGrB,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAAE,EACnE,IAAqB,EACrB,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,QAAoB,EACpB,SAAqB,EACrB,KAAK,EACL,qBAAqB,EACrB,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,WAAW,GACZ,EAAE,IAAI,CACL,oBAAoB,CAAC,CAAC,CAAC,EACrB,MAAM,GACN,eAAe,GACf,WAAW,GACX,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,UAAU,GACV,OAAO,GACP,uBAAuB,GACvB,cAAc,GACd,WAAW,GACX,UAAU,GACV,aAAa,CAChB,GAAG;IACF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAC5D,GACG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAkH1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRscStream.js","sources":["../../../plugin/helpers/createRscStream.tsx"],"sourcesContent":["import { React, ReactDOMServer } from \"../vendor/vendor.server.js\";\nimport type {\n CreateHandlerOptions,\n StreamMetrics,\n PagePropOpt,\n} from \"../types.js\";\nimport { performance } from \"node:perf_hooks\";\n\nexport function createRscStream<T extends PagePropOpt = PagePropOpt>({\n Html = React.Fragment,\n PageComponent,\n pageProps,\n moduleBase,\n moduleRootPath,\n moduleBasePath,\n moduleBaseURL,\n cssFiles = new Map(),\n globalCss = new Map(),\n route,\n pipeableStreamOptions,\n CssCollector,\n manifest,\n onEvent,\n projectRoot,\n}: Pick<\n CreateHandlerOptions<T>,\n | \"Html\"\n | \"PageComponent\"\n | \"pageProps\"\n | \"moduleBase\"\n | \"moduleRootPath\"\n | \"moduleBasePath\"\n | \"moduleBaseURL\"\n | \"cssFiles\"\n | \"route\"\n | \"pipeableStreamOptions\"\n | \"CssCollector\"\n | \"globalCss\"\n | \"manifest\"\n | \"projectRoot\"\n> & {\n onEvent?: (event: \"error\" | \"postpone\", data: any) => void;\n}):\n | { type: \"success\"; stream: any; metrics: StreamMetrics }\n | { type: \"error\"; error: Error; metrics: StreamMetrics } {\n let errorCount = 0;\n let streamError: Error | null = null;\n const startTime = performance.now();\n try {\n const htmlIsFragment = Html === React.Fragment;\n const url = route.startsWith(moduleBaseURL) ? route : moduleBaseURL + route;\n\n if (!PageComponent) {\n return {\n type: \"error\",\n error: new Error(\"PageComponent is required\"),\n metrics: {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount: 0,\n duration: 0,\n startTime: 0,\n },\n };\n }\n\n const elements = htmlIsFragment ? (\n <CssCollector\n key={route}\n as={React.Fragment}\n cssFiles={cssFiles}\n pageProps={pageProps}\n Page={PageComponent}\n />\n ) : (\n <Html\n moduleBase={moduleBase}\n moduleBaseURL={moduleBaseURL}\n moduleBasePath={moduleBasePath}\n moduleRootPath={moduleRootPath}\n projectRoot={projectRoot}\n url={url}\n route={route}\n pageProps={pageProps}\n cssFiles={cssFiles}\n globalCss={globalCss}\n CssCollector={CssCollector}\n manifest={manifest}\n Page={PageComponent}\n as={\"div\"}\n />\n );\n const stream = ReactDOMServer.renderToPipeableStream(\n elements,\n moduleBasePath,\n {\n ...pipeableStreamOptions,\n onError(error: Error, errorInfo: any) {\n const err = error instanceof Error ? error : new Error(String(error));\n streamError = err;\n onEvent?.(\"error\", { route, error: err, errorInfo });\n errorCount++;\n },\n onPostpone(reason: string) {\n onEvent?.(\"postpone\", { route, reason });\n },\n }\n );\n // If we have a stream error, return it immediately\n if (streamError) {\n return {\n type: \"error\",\n error: streamError,\n metrics: {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount,\n duration: Date.now() - startTime,\n startTime: startTime,\n },\n };\n }\n\n return {\n type: \"success\",\n stream,\n metrics: {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount,\n duration: Date.now() - startTime,\n startTime: startTime,\n },\n };\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n onEvent?.(\"error\", { route, error: err });\n return {\n type: \"error\",\n error: err,\n metrics: {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount: errorCount + 1,\n duration: Date.now() - startTime,\n startTime: startTime,\n },\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAQO,SAAS,eAAqD,CAAA;AAAA,EACnE,OAAO,KAAM,CAAA,QAAA;AAAA,EACb,aAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAA,uBAAe,GAAI,EAAA;AAAA,EACnB,SAAA,uBAAgB,GAAI,EAAA;AAAA,EACpB,KAAA;AAAA,EACA,qBAAA;AAAA,E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AAA,EAAQ,GAAA,SAAA;AAAA,QACvB;AAAA;AACF,KACF;AAAA,WACO,KAAO,EAAA;AACd,IAAM,MAAA,GAAA,GAAM,iBAAiB,KAAQ,GAAA,KAAA,GAAQ,IAAI,KAAM,CAAA,MAAA,CAAO,KAAK,CAAC,CAAA;AACpE,IAAA,OAAA,GAAU,OAAS,EAAA,EAAE,KAAO,EAAA,KAAA,EAAO,KAAK,CAAA;AACxC,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,OAAA;AAAA,MACN,KAAO,EAAA,GAAA;AAAA,MACP,OAAS,EAAA;AAAA,QACP,MAAQ,EAAA,CAAA;AAAA,QACR,KAAO,EAAA,CAAA;AAAA,QACP,iBAAmB,EAAA,CAAA;AAAA,QACnB,UAAY,EAAA,CAAA;AAAA,QACZ,YAAY,UAAa,GAAA,CAAA;AAAA,QACzB,QAAA,EAAU,IAAK,CAAA,GAAA,EAAQ,GAAA,SAAA;AAAA,QACvB;AAAA;AACF,KACF;AAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"createRscStream.js","sources":["../../../plugin/helpers/createRscStream.tsx"],"sourcesContent":["import { React, ReactDOMServer } from \"../vendor/vendor.server.js\";\nimport type {\n CreateHandlerOptions,\n StreamMetrics,\n PagePropOpt,\n} from \"../types.js\";\nimport { performance } from \"node:perf_hooks\";\n\nexport function createRscStream<T extends PagePropOpt = PagePropOpt>({\n Html = React.Fragment,\n PageComponent,\n pageProps,\n moduleBase,\n moduleRootPath,\n moduleBasePath,\n moduleBaseURL,\n cssFiles = new Map(),\n globalCss = new Map(),\n route,\n pipeableStreamOptions,\n CssCollector,\n manifest,\n onEvent,\n projectRoot,\n}: Pick<\n CreateHandlerOptions<T>,\n | \"Html\"\n | \"PageComponent\"\n | \"pageProps\"\n | \"moduleBase\"\n | \"moduleRootPath\"\n | \"moduleBasePath\"\n | \"moduleBaseURL\"\n | \"cssFiles\"\n | \"route\"\n | \"pipeableStreamOptions\"\n | \"CssCollector\"\n | \"globalCss\"\n | \"manifest\"\n | \"projectRoot\"\n> & {\n onEvent?: (event: \"error\" | \"postpone\", data: any) => void;\n}):\n | { type: \"success\"; stream: any; metrics: StreamMetrics }\n | { type: \"error\"; error: Error; metrics: StreamMetrics } {\n let errorCount = 0;\n let streamError: Error | null = null;\n const startTime = performance.now();\n try {\n const htmlIsFragment = Html === React.Fragment;\n const url = route.startsWith(moduleBaseURL) ? route : moduleBaseURL + route;\n\n if (!PageComponent) {\n return {\n type: \"error\",\n error: new Error(\"PageComponent is required\"),\n metrics: {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount: 0,\n duration: 0,\n startTime: 0,\n },\n };\n }\n\n const elements = htmlIsFragment ? (\n <CssCollector\n key={route}\n as={React.Fragment}\n cssFiles={cssFiles}\n pageProps={pageProps}\n Page={PageComponent}\n />\n ) : (\n <Html\n moduleBase={moduleBase}\n moduleBaseURL={moduleBaseURL}\n moduleBasePath={moduleBasePath}\n moduleRootPath={moduleRootPath}\n projectRoot={projectRoot}\n url={url}\n route={route}\n pageProps={pageProps}\n cssFiles={cssFiles}\n globalCss={globalCss}\n CssCollector={CssCollector}\n manifest={manifest}\n Page={PageComponent}\n as={\"div\"}\n />\n );\n const stream = ReactDOMServer.renderToPipeableStream(\n elements,\n moduleBasePath,\n {\n ...pipeableStreamOptions,\n moduleBaseURL: moduleBaseURL,\n onError(error: Error, errorInfo: any) {\n const err = error instanceof Error ? error : new Error(String(error));\n streamError = err;\n onEvent?.(\"error\", { route, error: err, errorInfo });\n errorCount++;\n },\n onPostpone(reason: string) {\n onEvent?.(\"postpone\", { route, reason });\n },\n }\n );\n // If we have a stream error, return it immediately\n if (streamError) {\n return {\n type: \"error\",\n error: streamError,\n metrics: {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount,\n duration: Date.now() - startTime,\n startTime: startTime,\n },\n };\n }\n\n return {\n type: \"success\",\n stream,\n metrics: {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount,\n duration: Date.now() - startTime,\n startTime: startTime,\n },\n };\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n onEvent?.(\"error\", { route, error: err });\n return {\n type: \"error\",\n error: err,\n metrics: {\n chunks: 0,\n bytes: 0,\n backpressureCount: 0,\n drainCount: 0,\n errorCount: errorCount + 1,\n duration: Date.now() - startTime,\n startTime: startTime,\n },\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAQO,SAAS,eAAqD,CAAA;AAAA,EACnE,OAAO,KAAM,CAAA,QAAA;AAAA,EACb,aAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAA,uBAAe,GAAI,EAAA;AAAA,EACnB,SAAA,uBAAgB,GAAI,EAAA;AAAA,EACpB,KAAA;AAAA,EACA,qBAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAoB4D,EAAA;AAC1D,EAAA,IAAI,UAAa,GAAA,CAAA;AACjB,EAAA,IAAI,WAA4B,GAAA,IAAA;AAChC,EAAM,MAAA,SAAA,GAAY,YAAY,GAAI,EAAA;AAClC,EAAI,IAAA;AACF,IAAM,MAAA,cAAA,GAAiB,SAAS,KAAM,CAAA,QAAA;AACtC,IAAA,MAAM,MAAM,KAAM,CAAA,UAAA,CAAW,aAAa,CAAA,GAAI,QAAQ,aAAgB,GAAA,KAAA;AAEtE,IAAA,IAAI,CAAC,aAAe,EAAA;AAClB,MAAO,OAAA;AAAA,QACL,IAAM,EAAA,OAAA;AAAA,QACN,KAAA,EAAO,IAAI,KAAA,CAAM,2BAA2B,CAAA;AAAA,QAC5C,OAAS,EAAA;AAAA,UACP,MAAQ,EAAA,CAAA;AAAA,UACR,KAAO,EAAA,CAAA;AAAA,UACP,iBAAmB,EAAA,CAAA;AAAA,UACnB,UAAY,EAAA,CAA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}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDefaultLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createDefaultLoader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"createDefaultLoader.d.ts","sourceRoot":"","sources":["../../../plugin/loader/createDefaultLoader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,YAAY,CAAC;CACrE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAuH3D"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "fs";
|
|
2
2
|
import * as esbuild from "esbuild";
|
|
3
|
+
import { transformModuleIfNeeded } from "./transformModuleIfNeeded.js";
|
|
4
|
+
import { createMappingsSerializer } from "../source-map/createMappingsSerializer.js";
|
|
3
5
|
/**
|
|
4
6
|
* Creates a default loader function that either uses provided source or reads from file
|
|
5
7
|
*/
|
|
@@ -14,9 +16,40 @@ export function createDefaultLoader(source) {
|
|
|
14
16
|
sourcemap: true,
|
|
15
17
|
sourcefile: id,
|
|
16
18
|
});
|
|
19
|
+
// Transform the code for RSC boundaries
|
|
20
|
+
const transformed = transformModuleIfNeeded(result.code, id, null, // isServerFunction
|
|
21
|
+
null, // isClientComponent
|
|
22
|
+
true // isServerEnvironment
|
|
23
|
+
);
|
|
24
|
+
// Create a new source map with proper mappings
|
|
25
|
+
const map = result.map ? {
|
|
26
|
+
version: 3,
|
|
27
|
+
sources: [id],
|
|
28
|
+
sourcesContent: [transformed],
|
|
29
|
+
mappings: (() => {
|
|
30
|
+
const serializer = createMappingsSerializer();
|
|
31
|
+
let mappings = '';
|
|
32
|
+
// Map each line of the transformed code to its corresponding line in the original source
|
|
33
|
+
const transformedLines = transformed.split('\n');
|
|
34
|
+
for (let i = 0; i < transformedLines.length; i++) {
|
|
35
|
+
if (i > 0)
|
|
36
|
+
mappings += ';';
|
|
37
|
+
// For the import and registration lines, map to the first line of the original source
|
|
38
|
+
if (transformedLines[i].includes('import {') || transformedLines[i].includes('registerServerReference')) {
|
|
39
|
+
mappings += serializer(i + 1, 0, 0, 1, 0, 0);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// For the actual code, map to the corresponding line in the original source
|
|
43
|
+
const originalLine = Math.max(1, i - 1); // Adjust for the import line
|
|
44
|
+
mappings += serializer(i + 1, 0, 0, originalLine, 0, 0);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return mappings;
|
|
48
|
+
})()
|
|
49
|
+
} : null;
|
|
17
50
|
return {
|
|
18
|
-
source:
|
|
19
|
-
map
|
|
51
|
+
source: transformed,
|
|
52
|
+
map
|
|
20
53
|
};
|
|
21
54
|
};
|
|
22
55
|
}
|
|
@@ -32,9 +65,40 @@ export function createDefaultLoader(source) {
|
|
|
32
65
|
sourcemap: true,
|
|
33
66
|
sourcefile: id,
|
|
34
67
|
});
|
|
68
|
+
// Transform the code for RSC boundaries
|
|
69
|
+
const transformed = transformModuleIfNeeded(result.code, id, null, // isServerFunction
|
|
70
|
+
null, // isClientComponent
|
|
71
|
+
true // isServerEnvironment
|
|
72
|
+
);
|
|
73
|
+
// Create a new source map with proper mappings
|
|
74
|
+
const map = result.map ? {
|
|
75
|
+
version: 3,
|
|
76
|
+
sources: [id],
|
|
77
|
+
sourcesContent: [transformed],
|
|
78
|
+
mappings: (() => {
|
|
79
|
+
const serializer = createMappingsSerializer();
|
|
80
|
+
let mappings = '';
|
|
81
|
+
// Map each line of the transformed code to its corresponding line in the original source
|
|
82
|
+
const transformedLines = transformed.split('\n');
|
|
83
|
+
for (let i = 0; i < transformedLines.length; i++) {
|
|
84
|
+
if (i > 0)
|
|
85
|
+
mappings += ';';
|
|
86
|
+
// For the import and registration lines, map to the first line of the original source
|
|
87
|
+
if (transformedLines[i].includes('import {') || transformedLines[i].includes('registerServerReference')) {
|
|
88
|
+
mappings += serializer(i + 1, 0, 0, 1, 0, 0);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// For the actual code, map to the corresponding line in the original source
|
|
92
|
+
const originalLine = Math.max(1, i - 1); // Adjust for the import line
|
|
93
|
+
mappings += serializer(i + 1, 0, 0, originalLine, 0, 0);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return mappings;
|
|
97
|
+
})()
|
|
98
|
+
} : null;
|
|
35
99
|
return {
|
|
36
|
-
source:
|
|
37
|
-
map
|
|
100
|
+
source: transformed,
|
|
101
|
+
map
|
|
38
102
|
};
|
|
39
103
|
};
|
|
40
104
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MessagePort } from "node:worker_threads";
|
|
2
2
|
import type { LoadHookContext } from "node:module";
|
|
3
|
-
import type { LoaderContext, SerializedUserConfig } from "../types.js";
|
|
3
|
+
import type { LoaderContext, SerializedUserConfig, SerializedUserOptions } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Global port for communication between the main thread and the CSS loader.
|
|
6
6
|
* This port is used to send CSS file requests and receive responses.
|
|
@@ -17,21 +17,8 @@ export declare function initialize(data: {
|
|
|
17
17
|
id: string;
|
|
18
18
|
port: MessagePort;
|
|
19
19
|
resolvedConfig: SerializedUserConfig;
|
|
20
|
+
userOptions: SerializedUserOptions;
|
|
20
21
|
}): Promise<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Sets the current page being processed.
|
|
23
|
-
* Used to track which CSS files are associated with which pages.
|
|
24
|
-
*
|
|
25
|
-
* @param page - The URL of the current page, or null if no page is active
|
|
26
|
-
*/
|
|
27
|
-
export declare function setCurrentPage(page: string | null): void;
|
|
28
|
-
/**
|
|
29
|
-
* Retrieves all CSS files associated with a specific page.
|
|
30
|
-
*
|
|
31
|
-
* @param page - The URL of the page
|
|
32
|
-
* @returns An array of CSS file paths used by the page
|
|
33
|
-
*/
|
|
34
|
-
export declare function getCssFilesForPage(page: string): string[];
|
|
35
22
|
/**
|
|
36
23
|
* Vite's load hook implementation for CSS files.
|
|
37
24
|
* Handles CSS file loading requests and returns a placeholder module.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"css-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAuB,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAUnH;;;GAGG;AACH,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAK/C;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,cAAc,EAAE,oBAAoB,CAAC;IAAC,WAAW,EAAE,qBAAqB,CAAA;CAAE,iBASjJ;AA+DD;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,GAAG;IAAE,cAAc,EAAE,oBAAoB,CAAA;CAAE,EACnF,WAAW,EAAE,GAAG,gBAQjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,OAE3E"}
|
|
@@ -7,28 +7,32 @@ import 'node:worker_threads';
|
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import { preprocessCSS } from 'vite';
|
|
9
9
|
import { readFile } from 'node:fs/promises';
|
|
10
|
-
import { join } from 'node:path';
|
|
11
10
|
import { env } from '../utils/env.js';
|
|
11
|
+
import { resolveOptions } from '../config/resolveOptions.js';
|
|
12
|
+
import { hydrateUserOptions } from '../helpers/serializeUserOptions.js';
|
|
12
13
|
|
|
13
14
|
let loaderPort;
|
|
14
|
-
const cssFilesByPage = /* @__PURE__ */ new Map();
|
|
15
|
-
let currentPage = null;
|
|
16
15
|
let resolvedConfig;
|
|
16
|
+
let userOptions;
|
|
17
17
|
async function initialize(data) {
|
|
18
18
|
loaderPort = data.port;
|
|
19
19
|
resolvedConfig = data.resolvedConfig;
|
|
20
|
+
const resolvedUserOptions = resolveOptions(hydrateUserOptions(data.userOptions));
|
|
21
|
+
if (resolvedUserOptions.type === "error") {
|
|
22
|
+
throw new Error(resolvedUserOptions.error.message);
|
|
23
|
+
}
|
|
24
|
+
userOptions = resolvedUserOptions.userOptions;
|
|
20
25
|
data.port.postMessage({ type: "INITIALIZED_CSS_LOADER", id: data.id });
|
|
21
26
|
}
|
|
22
|
-
function setCurrentPage(page) {
|
|
23
|
-
currentPage = page;
|
|
24
|
-
}
|
|
25
|
-
function getCssFilesForPage(page) {
|
|
26
|
-
return Array.from(cssFilesByPage.get(page) || []);
|
|
27
|
-
}
|
|
28
27
|
async function processCssFile(filePath, config, inline) {
|
|
29
28
|
try {
|
|
30
29
|
const path = filePath.startsWith("file://") ? fileURLToPath(filePath) : filePath;
|
|
31
30
|
const source = await readFile(path, "utf-8");
|
|
31
|
+
let moduleID = path;
|
|
32
|
+
if (userOptions?.normalizer) {
|
|
33
|
+
let [, value] = userOptions.normalizer(path);
|
|
34
|
+
moduleID = userOptions.moduleID(value || path);
|
|
35
|
+
}
|
|
32
36
|
const processed = await preprocessCSS(source, path, {
|
|
33
37
|
...config,
|
|
34
38
|
env
|
|
@@ -36,11 +40,8 @@ async function processCssFile(filePath, config, inline) {
|
|
|
36
40
|
if (loaderPort) {
|
|
37
41
|
loaderPort.postMessage({
|
|
38
42
|
type: "CSS_FILE",
|
|
39
|
-
id:
|
|
40
|
-
|
|
41
|
-
content: processed.code,
|
|
42
|
-
modules: processed.modules || {},
|
|
43
|
-
inline
|
|
43
|
+
id: moduleID,
|
|
44
|
+
content: processed.code
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
if (inline) {
|
|
@@ -71,5 +72,5 @@ function resolve(specifier, context, defaultResolve) {
|
|
|
71
72
|
return defaultResolve(specifier, context, defaultResolve);
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
export {
|
|
75
|
+
export { initialize, load, loaderPort, resolve };
|
|
75
76
|
//# sourceMappingURL=css-loader.development.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-loader.development.js","sources":["../../../plugin/loader/css-loader.development.ts"],"sourcesContent":["import { type MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext, SerializedUserConfig } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { preprocessCSS } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { readFile } from \"node:fs/promises\";\nimport {
|
|
1
|
+
{"version":3,"file":"css-loader.development.js","sources":["../../../plugin/loader/css-loader.development.ts"],"sourcesContent":["import { type MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext, ResolvedUserOptions, SerializedUserConfig, SerializedUserOptions } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { preprocessCSS } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { readFile } from \"node:fs/promises\";\nimport { env } from \"../utils/env.js\";\nimport type { InitializedCssLoaderMessage } from \"../worker/types.js\";\nimport { resolveOptions } from \"../config/resolveOptions.js\";\nimport { hydrateUserOptions } from \"../helpers/index.js\";\n\n/**\n * Global port for communication between the main thread and the CSS loader.\n * This port is used to send CSS file requests and receive responses.\n */\nexport let loaderPort: MessagePort | undefined;\n\nlet resolvedConfig: ResolvedConfig | undefined;\nlet userOptions: ResolvedUserOptions | undefined; \n\n/**\n * Initializes the CSS loader with the necessary communication channels.\n * Sets up message handlers for CSS file requests and responses.\n *\n * @param data - Configuration data for the CSS loader\n * @param data.port - The message port for communication\n */\nexport async function initialize(data: { id: string, port: MessagePort, resolvedConfig: SerializedUserConfig, userOptions: SerializedUserOptions }) {\n loaderPort = data.port;\n resolvedConfig = data.resolvedConfig;\n const resolvedUserOptions = resolveOptions(hydrateUserOptions(data.userOptions));\n if(resolvedUserOptions.type === \"error\") {\n throw new Error(resolvedUserOptions.error.message);\n }\n userOptions = resolvedUserOptions.userOptions;\n data.port.postMessage({ type: \"INITIALIZED_CSS_LOADER\", id: data.id } satisfies InitializedCssLoaderMessage);\n}\n\n\n\n/**\n * Processes a CSS file request.\n * Sends a request to the main thread and waits for the processed CSS.\n *\n * @param filePath - The file system path of the CSS file\n * @param config - The Vite config\n * @returns A promise that resolves to the processed CSS content\n */\nasync function processCssFile(\n filePath: string,\n config: ResolvedConfig,\n inline: boolean\n): Promise<{ format: string; source: string; shortCircuit: boolean }> {\n try {\n // Convert file URL to path if needed\n const path = filePath.startsWith(\"file://\")\n ? fileURLToPath(filePath)\n : filePath;\n\n // Process CSS using Vite's preprocessCSS\n const source = await readFile(path, \"utf-8\");\n let moduleID = path;\n if(userOptions?.normalizer) {\n let [,value] = userOptions.normalizer(path);\n moduleID = userOptions.moduleID(value || path);\n }\n const processed = await preprocessCSS(source, path, {\n ...config,\n env: env\n });\n\n // If we're processing CSS for a specific page, notify the message handler\n if (loaderPort) {\n loaderPort.postMessage({\n type: \"CSS_FILE\",\n id: moduleID,\n content: processed.code\n });\n }\n\n // Return a module that can be used by React components\n if (inline) {\n return {\n format: \"module\",\n source: processed.code,\n shortCircuit: true,\n };\n }\n return {\n format: \"module\",\n source: `export default ${JSON.stringify(processed.modules || {})};`,\n shortCircuit: true,\n };\n } catch (error) {\n console.error(`[css-loader] Error processing CSS file: ${error}`);\n throw error;\n }\n}\n\n/**\n * Vite's load hook implementation for CSS files.\n * Handles CSS file loading requests and returns a placeholder module.\n * The actual CSS content is processed in the main thread.\n *\n * @param url - The URL of the module to load\n * @param context - The load hook context\n * @param defaultLoad - The default load function\n * @returns A promise that resolves to the module content\n */\nexport async function load(\n url: string,\n context: LoadHookContext & LoaderContext & { resolvedConfig: SerializedUserConfig },\n defaultLoad: any\n) {\n const [name, query] = url.split(\"?\");\n if (name.endsWith(\".css\")) {\n return processCssFile(url, resolvedConfig as ResolvedConfig, query === \"inline\");\n }\n\n return defaultLoad(url, context, defaultLoad);\n}\n\n/**\n * Vite's resolve hook implementation.\n * Handles module resolution during development.\n *\n * @param specifier - The module specifier to resolve\n * @param context - The resolve hook context\n * @param defaultResolve - The default resolve function\n * @returns A promise that resolves to the resolved module\n */\nexport function resolve(specifier: string, context: any, defaultResolve: any) {\n return defaultResolve(specifier, context, defaultResolve);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAgBW,IAAA;AAEX,IAAI,cAAA;AACJ,IAAI,WAAA;AASJ,eAAsB,WAAW,IAAmH,EAAA;AAClJ,EAAA,UAAA,GAAa,IAAK,CAAA,IAAA;AAClB,EAAA,cAAA,GAAiB,IAAK,CAAA,cAAA;AACtB,EAAA,MAAM,mBAAsB,GAAA,cAAA,CAAe,kBAAmB,CAAA,IAAA,CAAK,WAAW,CAAC,CAAA;AAC/E,EAAG,IAAA,mBAAA,CAAoB,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AAA,QAAA;AAAA,MACR,MAAA,EAAQ,kBAAkB,IAAK,CAAA,SAAA,CAAU,UAAU,OAAW,IAAA,EAAE,CAAC,CAAA,CAAA,CAAA;AAAA,MACjE,YAAc,EAAA;AAAA,KAChB;AAAA,WACO,KAAO,EAAA;AACd,IAAQ,OAAA,CAAA,KAAA,CAAM,CAA2C,wCAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAChE,IAAM,MAAA,KAAA;AAAA;AAEV;AAYA,eAAsB,IAAA,CACpB,GACA,EAAA,OAAA,EACA,WACA,EAAA;AACA,EAAA,MAAM,CAAC,IAAM,EAAA,KAAK,CAAI,GAAA,GAAA,CAAI,MAAM,GAAG,CAAA;AACnC,EAAI,IAAA,IAAA,CAAK,QAAS,CAAA,MAAM,CAAG,EAAA;AACzB,IAAA,OAAO,cAAe,CAAA,GAAA,EAAK,cAAkC,EAAA,KAAA,KAAU,QAAQ,CAAA;AAAA;AAGjF,EAAO,OAAA,WAAA,CAAY,GAAK,EAAA,OAAA,EAAS,WAAW,CAAA;AAC9C;AAWO,SAAS,OAAA,CAAQ,SAAmB,EAAA,OAAA,EAAc,cAAqB,EAAA;AAC5E,EAAO,OAAA,cAAA,CAAe,SAAW,EAAA,OAAA,EAAS,cAAc,CAAA;AAC1D;;;;"}
|
|
@@ -12,9 +12,9 @@ export declare let loaderPort: MessagePort | undefined;
|
|
|
12
12
|
*
|
|
13
13
|
* @param data - Configuration data for the CSS loader
|
|
14
14
|
* @param data.port - The message port for communication
|
|
15
|
-
* @param data.server - The Vite dev server instance
|
|
16
15
|
*/
|
|
17
16
|
export declare function initialize(data: {
|
|
17
|
+
id: string;
|
|
18
18
|
port: MessagePort;
|
|
19
19
|
}): Promise<void>;
|
|
20
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-loader.production.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.production.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAI/C
|
|
1
|
+
{"version":3,"file":"css-loader.production.d.ts","sourceRoot":"","sources":["../../../plugin/loader/css-loader.production.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;;GAGG;AACH,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAI/C;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,iBAGvE;AAqCD;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,EACxC,WAAW,EAAE,GAAG,gBASjB"}
|
|
@@ -10,7 +10,7 @@ let loaderPort;
|
|
|
10
10
|
let stashedCssFiles = /* @__PURE__ */ new Map();
|
|
11
11
|
async function initialize(data) {
|
|
12
12
|
loaderPort = data.port;
|
|
13
|
-
data.port.postMessage({ type: "INITIALIZED_CSS_LOADER" });
|
|
13
|
+
data.port.postMessage({ type: "INITIALIZED_CSS_LOADER", id: data.id });
|
|
14
14
|
}
|
|
15
15
|
async function processCssFile(filePath) {
|
|
16
16
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-loader.production.js","sources":["../../../plugin/loader/css-loader.production.ts"],"sourcesContent":["import type { MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { readFile } from \"node:fs/promises\";\n\n/**\n * Global port for communication between the main thread and the CSS loader.\n * This port is used to send CSS file requests and receive responses.\n */\nexport let loaderPort: MessagePort | undefined;\n\nlet stashedCssFiles = new Map();\n\n/**\n * Initializes the CSS loader with the necessary communication channels.\n * Sets up message handlers for CSS file requests and responses.\n *\n * @param data - Configuration data for the CSS loader\n * @param data.port - The message port for communication\n
|
|
1
|
+
{"version":3,"file":"css-loader.production.js","sources":["../../../plugin/loader/css-loader.production.ts"],"sourcesContent":["import type { MessagePort } from \"node:worker_threads\";\nimport type { LoadHookContext } from \"node:module\";\nimport type { LoaderContext } from \"../types.js\";\nimport { fileURLToPath } from \"node:url\";\nimport { readFile } from \"node:fs/promises\";\n\n/**\n * Global port for communication between the main thread and the CSS loader.\n * This port is used to send CSS file requests and receive responses.\n */\nexport let loaderPort: MessagePort | undefined;\n\nlet stashedCssFiles = new Map();\n\n/**\n * Initializes the CSS loader with the necessary communication channels.\n * Sets up message handlers for CSS file requests and responses.\n *\n * @param data - Configuration data for the CSS loader\n * @param data.port - The message port for communication\n */\nexport async function initialize(data: { id: string, port: MessagePort }) {\n loaderPort = data.port;\n data.port.postMessage({ type: \"INITIALIZED_CSS_LOADER\", id: data.id });\n}\n\n/**\n * Processes a CSS file request.\n * Sends a request to the main thread and waits for the processed CSS.\n *\n * @param filePath - The file system path of the CSS file\n * @returns A promise that resolves to the processed CSS content\n */\nasync function processCssFile(\n filePath: string\n): Promise<{ format: string; source: string; shortCircuit: boolean }> {\n try {\n // Convert file URL to path if needed\n const path = filePath.startsWith(\"file://\")\n ? fileURLToPath(filePath)\n : filePath;\n if (stashedCssFiles.has(filePath)) {\n return {\n format: \"module\",\n source: stashedCssFiles.get(filePath),\n shortCircuit: true,\n };\n }\n // Process CSS using Vite's preprocessCSS\n const source = await readFile(path, \"utf-8\");\n stashedCssFiles.set(path, source);\n return {\n format: \"module\",\n source: source,\n shortCircuit: true,\n };\n } catch (error) {\n throw error;\n }\n}\n\n/**\n * Vite's load hook implementation for CSS files.\n * Handles CSS file loading requests and returns a placeholder module.\n * The actual CSS content is processed in the main thread.\n *\n * @param url - The URL of the module to load\n * @param context - The load hook context\n * @param defaultLoad - The default load function\n * @returns A promise that resolves to the module content\n */\nexport async function load(\n url: string,\n context: LoadHookContext & LoaderContext,\n defaultLoad: any\n) {\n // Handle CSS files\n const [name] = url.split(\"?\");\n if (name.endsWith(\".css\")) {\n return processCssFile(url);\n }\n\n return defaultLoad(url, context, defaultLoad);\n}\n"],"names":[],"mappings":";;;;;;;;AAUW,IAAA;AAEX,IAAI,eAAA,uBAAsB,GAAI,EAAA;AAS9B,eAAsB,WAAW,IAAyC,EAAA;AACxE,EAAA,UAAA,GAAa,IAAK,CAAA,IAAA;AAClB,EAAK,IAAA,CAAA,IAAA,CAAK,YAAY,EAAE,IAAA,EAAM,0BAA0B,EAAI,EAAA,IAAA,CAAK,IAAI,CAAA;AACvE;AASA,eAAe,eACb,QACoE,EAAA;AACpE,EAAI,IAAA;AAEF,IAAA,MAAM,OAAO,QAAS,CAAA,UAAA,CAAW,SAAS,CACtC,GAAA,aAAA,CAAc,QAAQ,CACtB,GAAA,QAAA;AACJ,IAAI,IAAA,eAAA,CAAgB,GAAI,CAAA,QAAQ,CAAG,EAAA;AACjC,MAAO,OAAA;AAAA,QACL,MAAQ,EAAA,QAAA;AAAA,QACR,MAAA,EAAQ,eAAgB,CAAA,GAAA,CAAI,QAAQ,CAAA;AAAA,QACpC,YAAc,EAAA;AAAA,OAChB;AAAA;AAGF,IAAA,MAAM,MAAS,GAAA,MAAM,QAAS,CAAA,IAAA,EAAM,OAAO,CAAA;AAC3C,IAAgB,eAAA,CAAA,GAAA,CAAI,MAAM,MAAM,CAAA;AAChC,IAAO,OAAA;AAAA,MACL,MAAQ,EAAA,QAAA;AAAA,MACR,MAAA;AAAA,MACA,YAAc,EAAA;AAAA,KAChB;AAAA,WACO,KAAO,EAAA;AACd,IAAM,MAAA,KAAA;AAAA;AAEV;AAYA,eAAsB,IAAA,CACpB,GACA,EAAA,OAAA,EACA,WACA,EAAA;AAEA,EAAA,MAAM,CAAC,IAAI,CAAI,GAAA,GAAA,CAAI,MAAM,GAAG,CAAA;AAC5B,EAAI,IAAA,IAAA,CAAK,QAAS,CAAA,MAAM,CAAG,EAAA;AACzB,IAAA,OAAO,eAAe,GAAG,CAAA;AAAA;AAG3B,EAAO,OAAA,WAAA,CAAY,GAAK,EAAA,OAAA,EAAS,WAAW,CAAA;AAC9C;;;;"}
|
|
@@ -4,6 +4,7 @@ import type { MessagePort } from "node:worker_threads";
|
|
|
4
4
|
import type { ResolvedConfig } from "vite";
|
|
5
5
|
export declare let loaderPort: MessagePort | undefined;
|
|
6
6
|
export declare function initialize(data: {
|
|
7
|
+
id: string;
|
|
7
8
|
port: MessagePort;
|
|
8
9
|
resolvedConfig: ResolvedConfig;
|
|
9
10
|
}): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/env-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"env-loader.development.d.ts","sourceRoot":"","sources":["../../../plugin/loader/env-loader.development.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAG3C,eAAO,IAAI,UAAU,EAAE,WAAW,GAAG,SAAS,CAAC;AAI/C,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;CAChC,iBAQA;AAGD,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,eAAe,GAAG,aAAa,EACxC,QAAQ,EAAE,GAAG,gBAgEd;AAGD,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EACZ,sBAAsB,EAAE,GAAG,gBAQ5B"}
|