complete performance and reliability follow-ups
This commit is contained in:
@@ -99,6 +99,8 @@ export interface ProdOptions {
|
||||
clientModulesDir?: string;
|
||||
/** Absolute path to the pre-built theme stylesheet (`theme.css`). */
|
||||
themePath?: string;
|
||||
/** Pre-built active theme/accent stylesheets, loaded on demand. */
|
||||
themeAssetsDir?: string;
|
||||
/** Absolute path to the pre-built theme runtime (`theme.js`). */
|
||||
themeJsPath?: string;
|
||||
/** Resolved theme config: enables `<html data-theme>` + `theme.css` link. */
|
||||
@@ -366,6 +368,28 @@ function createProdAssetServer(opts: ProdOptions): AssetServer {
|
||||
return new Response(opts.schemasJs ?? "window.__wireSchemas={};", { headers: JS_HEADERS });
|
||||
}
|
||||
if (pathname === "/__wrnexus/theme.css") return serveFile(opts.themePath, CSS_HEADERS);
|
||||
const activeThemeMatch = /^\/__wrnexus\/theme\/([^/]+)\/([^/]+)\.css$/.exec(pathname);
|
||||
if (activeThemeMatch && opts.theme && opts.themeAssetsDir) {
|
||||
try {
|
||||
const themeName = decodeURIComponent(activeThemeMatch[1]!);
|
||||
const accentPart = decodeURIComponent(activeThemeMatch[2]!);
|
||||
if (!opts.theme.names.includes(themeName))
|
||||
return new Response("Not Found", { status: 404 });
|
||||
if (accentPart !== "_" && !opts.theme.accentNames.some((name) => name === accentPart)) {
|
||||
return new Response("Not Found", { status: 404 });
|
||||
}
|
||||
return serveFile(
|
||||
join(
|
||||
opts.themeAssetsDir,
|
||||
encodeURIComponent(themeName),
|
||||
`${accentPart === "_" ? "_" : encodeURIComponent(accentPart)}.css`,
|
||||
),
|
||||
CSS_HEADERS,
|
||||
);
|
||||
} catch {
|
||||
return new Response("Not Found", { status: 404 });
|
||||
}
|
||||
}
|
||||
if (pathname === "/__wrnexus/theme.js") return serveFile(opts.themeJsPath, JS_HEADERS);
|
||||
if (pathname === "/__wrnexus/ui.css") return serveFile(opts.uiCssPath, CSS_HEADERS);
|
||||
if (pathname === "/__wrnexus/framework.css")
|
||||
|
||||
Reference in New Issue
Block a user