@analogjs/vite-plugin-angular 3.0.0-alpha.25 → 3.0.0-alpha.26
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/package.json +1 -1
- package/src/index.d.ts +0 -1
- package/src/index.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +9 -0
- package/src/lib/angular-vite-plugin.js +54 -23
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/host.d.ts +1 -1
- package/src/lib/host.js +20 -6
- package/src/lib/host.js.map +1 -1
- package/src/lib/style-pipeline.d.ts +15 -0
- package/src/lib/style-pipeline.js +31 -0
- package/src/lib/style-pipeline.js.map +1 -0
- package/src/lib/style-preprocessor.d.ts +35 -1
- package/src/lib/style-preprocessor.js +35 -0
- package/src/lib/style-preprocessor.js.map +1 -0
- package/src/lib/stylesheet-registry.d.ts +17 -3
- package/src/lib/stylesheet-registry.js +46 -5
- package/src/lib/stylesheet-registry.js.map +1 -1
- package/src/lib/utils/debug.d.ts +2 -1
- package/src/lib/utils/debug.js +3 -1
- package/src/lib/utils/debug.js.map +1 -1
package/src/lib/host.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from "typescript";
|
|
2
|
-
import type
|
|
2
|
+
import { type StylePreprocessor } from "./style-preprocessor.js";
|
|
3
3
|
import { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
|
|
4
4
|
import type { SourceFileCache } from "./utils/source-file-cache.js";
|
|
5
5
|
export declare function augmentHostWithResources(host: ts.CompilerHost, transform: (code: string, id: string, options?: {
|
package/src/lib/host.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { debugStyles } from "./utils/debug.js";
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeStylesheetDependencies } from "./style-preprocessor.js";
|
|
3
|
+
import { preprocessStylesheetResult, registerStylesheetContent } from "./stylesheet-registry.js";
|
|
3
4
|
import { createHash } from "node:crypto";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import { normalizePath } from "vite";
|
|
@@ -18,10 +19,20 @@ function augmentHostWithResources(host, transform, options) {
|
|
|
18
19
|
resourceHost.transformResource = async function(data, context) {
|
|
19
20
|
if (context.type !== "style") return null;
|
|
20
21
|
const filename = context.resourceFile ?? context.containingFile.replace(".ts", `.${options?.inlineStylesExtension}`);
|
|
21
|
-
const
|
|
22
|
+
const preprocessed = preprocessStylesheetResult(data, filename, options.stylePreprocessor, {
|
|
23
|
+
filename,
|
|
24
|
+
containingFile: context.containingFile,
|
|
25
|
+
resourceFile: context.resourceFile ?? void 0,
|
|
26
|
+
className: context.className,
|
|
27
|
+
order: context.order,
|
|
28
|
+
inline: !context.resourceFile
|
|
29
|
+
});
|
|
22
30
|
if (options.stylesheetRegistry) {
|
|
23
31
|
const stylesheetId = registerStylesheetContent(options.stylesheetRegistry, {
|
|
24
|
-
code:
|
|
32
|
+
code: preprocessed.code,
|
|
33
|
+
dependencies: normalizeStylesheetDependencies(preprocessed.dependencies),
|
|
34
|
+
diagnostics: preprocessed.diagnostics,
|
|
35
|
+
tags: preprocessed.tags,
|
|
25
36
|
containingFile: context.containingFile,
|
|
26
37
|
className: context.className,
|
|
27
38
|
order: context.order,
|
|
@@ -30,18 +41,21 @@ function augmentHostWithResources(host, transform, options) {
|
|
|
30
41
|
});
|
|
31
42
|
debugStyles("NgtscProgram: stylesheet deferred to Vite pipeline", {
|
|
32
43
|
stylesheetId,
|
|
33
|
-
resourceFile: context.resourceFile ?? "(inline)"
|
|
44
|
+
resourceFile: context.resourceFile ?? "(inline)",
|
|
45
|
+
dependencies: preprocessed.dependencies,
|
|
46
|
+
diagnostics: preprocessed.diagnostics,
|
|
47
|
+
tags: preprocessed.tags
|
|
34
48
|
});
|
|
35
49
|
return { content: stylesheetId };
|
|
36
50
|
}
|
|
37
51
|
debugStyles("NgtscProgram: stylesheet processed inline via transform", {
|
|
38
52
|
filename,
|
|
39
53
|
resourceFile: context.resourceFile ?? "(inline)",
|
|
40
|
-
dataLength:
|
|
54
|
+
dataLength: preprocessed.code.length
|
|
41
55
|
});
|
|
42
56
|
let stylesheetResult;
|
|
43
57
|
try {
|
|
44
|
-
stylesheetResult = await transform(
|
|
58
|
+
stylesheetResult = await transform(preprocessed.code, `${filename}?direct`);
|
|
45
59
|
} catch (e) {
|
|
46
60
|
debugStyles("NgtscProgram: stylesheet transform error", {
|
|
47
61
|
filename,
|
package/src/lib/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","names":[],"sources":["../../../src/lib/host.ts"],"sourcesContent":["import type { CompilerHost } from '@angular/compiler-cli';\nimport { normalizePath } from 'vite';\n\nimport * as ts from 'typescript';\n\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\nimport type
|
|
1
|
+
{"version":3,"file":"host.js","names":[],"sources":["../../../src/lib/host.ts"],"sourcesContent":["import type { CompilerHost } from '@angular/compiler-cli';\nimport { normalizePath } from 'vite';\n\nimport * as ts from 'typescript';\n\nimport { createHash } from 'node:crypto';\nimport path from 'node:path';\nimport {\n normalizeStylesheetDependencies,\n type StylePreprocessor,\n} from './style-preprocessor.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n} from './stylesheet-registry.js';\nimport { debugStyles } from './utils/debug.js';\nimport type { SourceFileCache } from './utils/source-file-cache.js';\n\nexport function augmentHostWithResources(\n host: ts.CompilerHost,\n transform: (\n code: string,\n id: string,\n options?: { ssr?: boolean },\n ) => ReturnType<any> | null,\n options: {\n inlineStylesExtension: string;\n isProd?: boolean;\n stylesheetRegistry?: AnalogStylesheetRegistry;\n sourceFileCache?: SourceFileCache;\n stylePreprocessor?: StylePreprocessor;\n },\n): void {\n const resourceHost = host as CompilerHost;\n\n resourceHost.readResource = async function (fileName: string) {\n const filePath = normalizePath(fileName);\n\n const content = (this as any).readFile(filePath);\n\n if (content === undefined) {\n throw new Error('Unable to locate component resource: ' + fileName);\n }\n\n return content;\n };\n\n resourceHost.getModifiedResourceFiles = function () {\n return options?.sourceFileCache?.modifiedFiles;\n };\n\n resourceHost.transformResource = async function (data, context) {\n // Only style resources are supported currently\n if (context.type !== 'style') {\n return null;\n }\n\n const filename =\n context.resourceFile ??\n context.containingFile.replace(\n '.ts',\n `.${options?.inlineStylesExtension}`,\n );\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n options.stylePreprocessor,\n {\n filename,\n containingFile: context.containingFile,\n resourceFile: context.resourceFile ?? undefined,\n className: context.className,\n order: context.order,\n inline: !context.resourceFile,\n },\n );\n\n // Externalized path: store preprocessed CSS for Vite's serve-time pipeline.\n // CSS must NOT be transformed here — the load hook returns it into\n // Vite's transform pipeline where PostCSS / Tailwind process it once.\n if (options.stylesheetRegistry) {\n const stylesheetId = registerStylesheetContent(\n options.stylesheetRegistry,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile: context.containingFile,\n className: context.className,\n order: context.order,\n inlineStylesExtension: options.inlineStylesExtension,\n resourceFile: context.resourceFile ?? undefined,\n },\n );\n debugStyles('NgtscProgram: stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: context.resourceFile ?? '(inline)',\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n });\n return { content: stylesheetId };\n }\n\n // Non-externalized: CSS is returned directly to the Angular compiler\n // and never re-enters Vite's pipeline, so transform eagerly.\n debugStyles('NgtscProgram: stylesheet processed inline via transform', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n let stylesheetResult;\n\n try {\n stylesheetResult = await transform(\n preprocessed.code,\n `${filename}?direct`,\n );\n } catch (e) {\n debugStyles('NgtscProgram: stylesheet transform error', {\n filename,\n resourceFile: context.resourceFile ?? '(inline)',\n error: String(e),\n });\n }\n\n if (!stylesheetResult?.code) {\n return null;\n }\n\n return { content: stylesheetResult.code };\n };\n\n resourceHost.resourceNameToFileName = function (\n resourceName,\n containingFile,\n fallbackResolve,\n ) {\n const resolvedPath = normalizePath(\n fallbackResolve\n ? fallbackResolve(path.dirname(containingFile), resourceName)\n : path.join(path.dirname(containingFile), resourceName),\n );\n\n // All resource names that have template file extensions are assumed to be templates\n if (!options.stylesheetRegistry || !hasStyleExtension(resolvedPath)) {\n return resolvedPath;\n }\n\n // For external stylesheets, create a unique identifier and store the mapping\n const externalId = createHash('sha256').update(resolvedPath).digest('hex');\n const filename = externalId + path.extname(resolvedPath);\n\n options.stylesheetRegistry.registerExternalRequest(filename, resolvedPath);\n debugStyles('NgtscProgram: external stylesheet ID mapped for resolveId', {\n resourceName,\n resolvedPath,\n filename,\n });\n\n return filename;\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] =\n baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n file.version ??= createHash('sha256').update(file.text).digest('hex');\n }\n\n return files;\n };\n}\n\nexport function augmentHostWithCaching(\n host: ts.CompilerHost,\n cache: Map<string, ts.SourceFile>,\n): void {\n const baseGetSourceFile = host.getSourceFile;\n host.getSourceFile = function (\n fileName,\n languageVersion,\n onError,\n shouldCreateNewSourceFile,\n ...parameters\n ) {\n if (!shouldCreateNewSourceFile && cache.has(fileName)) {\n return cache.get(fileName);\n }\n\n const file = baseGetSourceFile.call(\n host,\n fileName,\n languageVersion,\n onError,\n true,\n ...parameters,\n );\n\n if (file) {\n cache.set(fileName, file);\n }\n\n return file;\n };\n}\n\nexport function mergeTransformers(\n first: ts.CustomTransformers,\n second: ts.CustomTransformers,\n): ts.CustomTransformers {\n const result: ts.CustomTransformers = {};\n\n if (first.before || second.before) {\n result.before = [...(first.before || []), ...(second.before || [])];\n }\n\n if (first.after || second.after) {\n result.after = [...(first.after || []), ...(second.after || [])];\n }\n\n if (first.afterDeclarations || second.afterDeclarations) {\n result.afterDeclarations = [\n ...(first.afterDeclarations || []),\n ...(second.afterDeclarations || []),\n ];\n }\n\n return result;\n}\n\nfunction hasStyleExtension(file: string): boolean {\n const extension = path.extname(file).toLowerCase();\n\n switch (extension) {\n case '.css':\n case '.scss':\n return true;\n default:\n return false;\n }\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,yBACd,MACA,WAKA,SAOM;CACN,MAAM,eAAe;AAErB,cAAa,eAAe,eAAgB,UAAkB;EAC5D,MAAM,WAAW,cAAc,SAAS;EAExC,MAAM,UAAW,KAAa,SAAS,SAAS;AAEhD,MAAI,YAAY,KAAA,EACd,OAAM,IAAI,MAAM,0CAA0C,SAAS;AAGrE,SAAO;;AAGT,cAAa,2BAA2B,WAAY;AAClD,SAAO,SAAS,iBAAiB;;AAGnC,cAAa,oBAAoB,eAAgB,MAAM,SAAS;AAE9D,MAAI,QAAQ,SAAS,QACnB,QAAO;EAGT,MAAM,WACJ,QAAQ,gBACR,QAAQ,eAAe,QACrB,OACA,IAAI,SAAS,wBACd;EACH,MAAM,eAAe,2BACnB,MACA,UACA,QAAQ,mBACR;GACE;GACA,gBAAgB,QAAQ;GACxB,cAAc,QAAQ,gBAAgB,KAAA;GACtC,WAAW,QAAQ;GACnB,OAAO,QAAQ;GACf,QAAQ,CAAC,QAAQ;GAClB,CACF;AAKD,MAAI,QAAQ,oBAAoB;GAC9B,MAAM,eAAe,0BACnB,QAAQ,oBACR;IACE,MAAM,aAAa;IACnB,cAAc,gCACZ,aAAa,aACd;IACD,aAAa,aAAa;IAC1B,MAAM,aAAa;IACnB,gBAAgB,QAAQ;IACxB,WAAW,QAAQ;IACnB,OAAO,QAAQ;IACf,uBAAuB,QAAQ;IAC/B,cAAc,QAAQ,gBAAgB,KAAA;IACvC,CACF;AACD,eAAY,sDAAsD;IAChE;IACA,cAAc,QAAQ,gBAAgB;IACtC,cAAc,aAAa;IAC3B,aA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6BAA6B,MAAM,IAAI,SAAS,CACnD,QAAO,MAAM,IAAI,SAAS;EAG5B,MAAM,OAAO,kBAAkB,KAC7B,MACA,UACA,iBACA,SACA,MACA,GAAG,WACJ;AAED,MAAI,KACF,OAAM,IAAI,UAAU,KAAK;AAG3B,SAAO;;;AAIX,SAAgB,kBACd,OACA,QACuB;CACvB,MAAM,SAAgC,EAAE;AAExC,KAAI,MAAM,UAAU,OAAO,OACzB,QAAO,SAAS,CAAC,GAAI,MAAM,UAAU,EAAE,EAAG,GAAI,OAAO,UAAU,EAAE,CAAE;AAGrE,KAAI,MAAM,SAAS,OAAO,MACxB,QAAO,QAAQ,CAAC,GAAI,MAAM,SAAS,EAAE,EAAG,GAAI,OAAO,SAAS,EAAE,CAAE;AAGlE,KAAI,MAAM,qBAAqB,OAAO,kBACpC,QAAO,oBAAoB,CACzB,GAAI,MAAM,qBAAqB,EAAE,EACjC,GAAI,OAAO,qBAAqB,EAAE,CACnC;AAGH,QAAO;;AAGT,SAAS,kBAAkB,MAAuB;AAGhD,SAFkB,KAAK,QAAQ,KAAK,CAAC,aAAa,EAElD;EACE,KAAK;EACL,KAAK,QACH,QAAO;EACT,QACE,QAAO"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AnalogStylesheetRegistry } from "./stylesheet-registry.js";
|
|
2
|
+
import type { StylePipelineStylesheetRegistry, StylePreprocessor, StylesheetTransformContext, StylesheetTransformResult } from "./style-preprocessor.js";
|
|
3
|
+
export interface AngularStylePipelineContext {
|
|
4
|
+
workspaceRoot: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AngularStylePipelinePlugin {
|
|
7
|
+
name: string;
|
|
8
|
+
preprocessStylesheet?: (code: string, context: StylesheetTransformContext) => string | StylesheetTransformResult | undefined;
|
|
9
|
+
configureStylesheetRegistry?: (registry: StylePipelineStylesheetRegistry, context: AngularStylePipelineContext) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface AngularStylePipelineOptions {
|
|
12
|
+
plugins: AngularStylePipelinePlugin[];
|
|
13
|
+
}
|
|
14
|
+
export declare function stylePipelinePreprocessorFromPlugins(options: AngularStylePipelineOptions | undefined): StylePreprocessor | undefined;
|
|
15
|
+
export declare function configureStylePipelineRegistry(options: AngularStylePipelineOptions | undefined, registry: AnalogStylesheetRegistry, context: AngularStylePipelineContext): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { debugStylePipeline } from "./utils/debug.js";
|
|
2
|
+
import { normalizeStylesheetTransformResult } from "./style-preprocessor.js";
|
|
3
|
+
//#region packages/vite-plugin-angular/src/lib/style-pipeline.ts
|
|
4
|
+
function stylePipelinePreprocessorFromPlugins(options) {
|
|
5
|
+
const preprocessors = options?.plugins.map((plugin) => plugin.preprocessStylesheet).filter((preprocessor) => !!preprocessor) ?? [];
|
|
6
|
+
if (!preprocessors.length) return;
|
|
7
|
+
return (code, filename, context) => {
|
|
8
|
+
if (!context) {
|
|
9
|
+
debugStylePipeline("skipping community stylesheet preprocessors because Angular did not provide a stylesheet context", { filename });
|
|
10
|
+
return code;
|
|
11
|
+
}
|
|
12
|
+
let current = normalizeStylesheetTransformResult(void 0, code);
|
|
13
|
+
for (const preprocess of preprocessors) {
|
|
14
|
+
const next = normalizeStylesheetTransformResult(preprocess(current.code, context), current.code);
|
|
15
|
+
current = {
|
|
16
|
+
code: next.code,
|
|
17
|
+
dependencies: [...current.dependencies ?? [], ...next.dependencies ?? []],
|
|
18
|
+
diagnostics: [...current.diagnostics ?? [], ...next.diagnostics ?? []],
|
|
19
|
+
tags: [...current.tags ?? [], ...next.tags ?? []]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return current;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function configureStylePipelineRegistry(options, registry, context) {
|
|
26
|
+
for (const plugin of options?.plugins ?? []) plugin.configureStylesheetRegistry?.(registry, context);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { configureStylePipelineRegistry, stylePipelinePreprocessorFromPlugins };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=style-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-pipeline.js","names":[],"sources":["../../../src/lib/style-pipeline.ts"],"sourcesContent":["import type { AnalogStylesheetRegistry } from './stylesheet-registry.js';\nimport type {\n StylePipelineStylesheetRegistry,\n StylePreprocessor,\n StylesheetTransformContext,\n StylesheetTransformResult,\n} from './style-preprocessor.js';\nimport { normalizeStylesheetTransformResult } from './style-preprocessor.js';\nimport { debugStylePipeline } from './utils/debug.js';\n\nexport interface AngularStylePipelineContext {\n workspaceRoot: string;\n}\n\nexport interface AngularStylePipelinePlugin {\n name: string;\n preprocessStylesheet?: (\n code: string,\n context: StylesheetTransformContext,\n ) => string | StylesheetTransformResult | undefined;\n configureStylesheetRegistry?: (\n registry: StylePipelineStylesheetRegistry,\n context: AngularStylePipelineContext,\n ) => void;\n}\n\nexport interface AngularStylePipelineOptions {\n plugins: AngularStylePipelinePlugin[];\n}\n\nexport function stylePipelinePreprocessorFromPlugins(\n options: AngularStylePipelineOptions | undefined,\n): StylePreprocessor | undefined {\n const preprocessors =\n options?.plugins\n .map((plugin) => plugin.preprocessStylesheet)\n .filter((preprocessor) => !!preprocessor) ?? [];\n\n if (!preprocessors.length) {\n return undefined;\n }\n\n return (code, filename, context) => {\n if (!context) {\n debugStylePipeline(\n 'skipping community stylesheet preprocessors because Angular did not provide a stylesheet context',\n {\n filename,\n },\n );\n return code;\n }\n\n let current = normalizeStylesheetTransformResult(undefined, code);\n for (const preprocess of preprocessors) {\n const next = normalizeStylesheetTransformResult(\n preprocess(current.code, context),\n current.code,\n );\n current = {\n code: next.code,\n dependencies: [\n ...(current.dependencies ?? []),\n ...(next.dependencies ?? []),\n ],\n diagnostics: [\n ...(current.diagnostics ?? []),\n ...(next.diagnostics ?? []),\n ],\n tags: [...(current.tags ?? []), ...(next.tags ?? [])],\n };\n }\n\n return current;\n };\n}\n\nexport function configureStylePipelineRegistry(\n options: AngularStylePipelineOptions | undefined,\n registry: AnalogStylesheetRegistry,\n context: AngularStylePipelineContext,\n): void {\n for (const plugin of options?.plugins ?? []) {\n plugin.configureStylesheetRegistry?.(registry, context);\n }\n}\n"],"mappings":";;;AA8BA,SAAgB,qCACd,SAC+B;CAC/B,MAAM,gBACJ,SAAS,QACN,KAAK,WAAW,OAAO,qBAAqB,CAC5C,QAAQ,iBAAiB,CAAC,CAAC,aAAa,IAAI,EAAE;AAEnD,KAAI,CAAC,cAAc,OACjB;AAGF,SAAQ,MAAM,UAAU,YAAY;AAClC,MAAI,CAAC,SAAS;AACZ,sBACE,oGACA,EACE,UACD,CACF;AACD,UAAO;;EAGT,IAAI,UAAU,mCAAmC,KAAA,GAAW,KAAK;AACjE,OAAK,MAAM,cAAc,eAAe;GACtC,MAAM,OAAO,mCACX,WAAW,QAAQ,MAAM,QAAQ,EACjC,QAAQ,KACT;AACD,aAAU;IACR,MAAM,KAAK;IACX,cAAc,CACZ,GAAI,QAAQ,gBAAgB,EAAE,EAC9B,GAAI,KAAK,gBAAgB,EAAE,CAC5B;IACD,aAAa,CACX,GAAI,QAAQ,eAAe,EAAE,EAC7B,GAAI,KAAK,eAAe,EAAE,CAC3B;IACD,MAAM,CAAC,GAAI,QAAQ,QAAQ,EAAE,EAAG,GAAI,KAAK,QAAQ,EAAE,CAAE;IACtD;;AAGH,SAAO;;;AAIX,SAAgB,+BACd,SACA,UACA,SACM;AACN,MAAK,MAAM,UAAU,SAAS,WAAW,EAAE,CACzC,QAAO,8BAA8B,UAAU,QAAQ"}
|
|
@@ -1 +1,35 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface StylesheetTransformContext {
|
|
2
|
+
filename: string;
|
|
3
|
+
containingFile?: string;
|
|
4
|
+
resourceFile?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
order?: number;
|
|
7
|
+
inline: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface StylesheetDependency {
|
|
10
|
+
id: string;
|
|
11
|
+
kind?: "file" | "virtual" | "token" | "bridge" | "manifest" | "runtime";
|
|
12
|
+
owner?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface StylesheetDiagnostic {
|
|
15
|
+
severity: "warning" | "error";
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
export interface StylesheetTransformResult {
|
|
20
|
+
code: string;
|
|
21
|
+
dependencies?: Array<string | StylesheetDependency>;
|
|
22
|
+
diagnostics?: StylesheetDiagnostic[];
|
|
23
|
+
tags?: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface StylePipelineStylesheetRegistry {
|
|
26
|
+
getPublicIdsForSource(sourcePath: string): string[];
|
|
27
|
+
getRequestIdsForSource(sourcePath: string): string[];
|
|
28
|
+
getDependenciesForSource(sourcePath: string): StylesheetDependency[];
|
|
29
|
+
getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[];
|
|
30
|
+
getTagsForSource(sourcePath: string): string[];
|
|
31
|
+
}
|
|
32
|
+
export type StylePreprocessor = (code: string, filename: string, context?: StylesheetTransformContext) => string | StylesheetTransformResult;
|
|
33
|
+
export declare function normalizeStylesheetTransformResult(value: string | StylesheetTransformResult | undefined, fallbackCode: string): StylesheetTransformResult;
|
|
34
|
+
export declare function normalizeStylesheetDependencies(dependencies: Array<string | StylesheetDependency> | undefined): StylesheetDependency[];
|
|
35
|
+
export declare function composeStylePreprocessors(preprocessors: Array<StylePreprocessor | false | null | undefined>): StylePreprocessor | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region packages/vite-plugin-angular/src/lib/style-preprocessor.ts
|
|
2
|
+
function normalizeStylesheetTransformResult(value, fallbackCode) {
|
|
3
|
+
if (value == null) return { code: fallbackCode };
|
|
4
|
+
if (typeof value === "string") return { code: value };
|
|
5
|
+
return {
|
|
6
|
+
code: value.code ?? fallbackCode,
|
|
7
|
+
dependencies: value.dependencies ?? [],
|
|
8
|
+
diagnostics: value.diagnostics ?? [],
|
|
9
|
+
tags: value.tags ?? []
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function normalizeStylesheetDependencies(dependencies) {
|
|
13
|
+
return (dependencies ?? []).map((dependency) => typeof dependency === "string" ? { id: dependency } : dependency);
|
|
14
|
+
}
|
|
15
|
+
function composeStylePreprocessors(preprocessors) {
|
|
16
|
+
const active = preprocessors.filter((preprocessor) => !!preprocessor);
|
|
17
|
+
if (!active.length) return;
|
|
18
|
+
return (code, filename, context) => {
|
|
19
|
+
let current = normalizeStylesheetTransformResult(void 0, code);
|
|
20
|
+
for (const preprocessor of active) {
|
|
21
|
+
const next = normalizeStylesheetTransformResult(preprocessor(current.code, filename, context), current.code);
|
|
22
|
+
current = {
|
|
23
|
+
code: next.code,
|
|
24
|
+
dependencies: [...current.dependencies ?? [], ...next.dependencies ?? []],
|
|
25
|
+
diagnostics: [...current.diagnostics ?? [], ...next.diagnostics ?? []],
|
|
26
|
+
tags: [...current.tags ?? [], ...next.tags ?? []]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return current;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { composeStylePreprocessors, normalizeStylesheetDependencies, normalizeStylesheetTransformResult };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=style-preprocessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-preprocessor.js","names":[],"sources":["../../../src/lib/style-preprocessor.ts"],"sourcesContent":["export interface StylesheetTransformContext {\n filename: string;\n containingFile?: string;\n resourceFile?: string;\n className?: string;\n order?: number;\n inline: boolean;\n}\n\nexport interface StylesheetDependency {\n id: string;\n kind?: 'file' | 'virtual' | 'token' | 'bridge' | 'manifest' | 'runtime';\n owner?: string;\n}\n\nexport interface StylesheetDiagnostic {\n severity: 'warning' | 'error';\n code: string;\n message: string;\n}\n\nexport interface StylesheetTransformResult {\n code: string;\n dependencies?: Array<string | StylesheetDependency>;\n diagnostics?: StylesheetDiagnostic[];\n tags?: string[];\n}\n\nexport interface StylePipelineStylesheetRegistry {\n getPublicIdsForSource(sourcePath: string): string[];\n getRequestIdsForSource(sourcePath: string): string[];\n getDependenciesForSource(sourcePath: string): StylesheetDependency[];\n getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[];\n getTagsForSource(sourcePath: string): string[];\n}\n\nexport type StylePreprocessor = (\n code: string,\n filename: string,\n context?: StylesheetTransformContext,\n) => string | StylesheetTransformResult;\n\nexport function normalizeStylesheetTransformResult(\n value: string | StylesheetTransformResult | undefined,\n fallbackCode: string,\n): StylesheetTransformResult {\n if (value == null) {\n return { code: fallbackCode };\n }\n\n if (typeof value === 'string') {\n return { code: value };\n }\n\n return {\n code: value.code ?? fallbackCode,\n dependencies: value.dependencies ?? [],\n diagnostics: value.diagnostics ?? [],\n tags: value.tags ?? [],\n };\n}\n\nexport function normalizeStylesheetDependencies(\n dependencies: Array<string | StylesheetDependency> | undefined,\n): StylesheetDependency[] {\n return (dependencies ?? []).map((dependency) =>\n typeof dependency === 'string' ? { id: dependency } : dependency,\n );\n}\n\nexport function composeStylePreprocessors(\n preprocessors: Array<StylePreprocessor | false | null | undefined>,\n): StylePreprocessor | undefined {\n const active = preprocessors.filter(\n (preprocessor): preprocessor is StylePreprocessor => !!preprocessor,\n );\n\n if (!active.length) {\n return undefined;\n }\n\n return (code, filename, context) => {\n let current = normalizeStylesheetTransformResult(undefined, code);\n\n for (const preprocessor of active) {\n const next = normalizeStylesheetTransformResult(\n preprocessor(current.code, filename, context),\n current.code,\n );\n current = {\n code: next.code,\n dependencies: [\n ...(current.dependencies ?? []),\n ...(next.dependencies ?? []),\n ],\n diagnostics: [\n ...(current.diagnostics ?? []),\n ...(next.diagnostics ?? []),\n ],\n tags: [...(current.tags ?? []), ...(next.tags ?? [])],\n };\n }\n\n return current;\n };\n}\n"],"mappings":";AA0CA,SAAgB,mCACd,OACA,cAC2B;AAC3B,KAAI,SAAS,KACX,QAAO,EAAE,MAAM,cAAc;AAG/B,KAAI,OAAO,UAAU,SACnB,QAAO,EAAE,MAAM,OAAO;AAGxB,QAAO;EACL,MAAM,MAAM,QAAQ;EACpB,cAAc,MAAM,gBAAgB,EAAE;EACtC,aAAa,MAAM,eAAe,EAAE;EACpC,MAAM,MAAM,QAAQ,EAAE;EACvB;;AAGH,SAAgB,gCACd,cACwB;AACxB,SAAQ,gBAAgB,EAAE,EAAE,KAAK,eAC/B,OAAO,eAAe,WAAW,EAAE,IAAI,YAAY,GAAG,WACvD;;AAGH,SAAgB,0BACd,eAC+B;CAC/B,MAAM,SAAS,cAAc,QAC1B,iBAAoD,CAAC,CAAC,aACxD;AAED,KAAI,CAAC,OAAO,OACV;AAGF,SAAQ,MAAM,UAAU,YAAY;EAClC,IAAI,UAAU,mCAAmC,KAAA,GAAW,KAAK;AAEjE,OAAK,MAAM,gBAAgB,QAAQ;GACjC,MAAM,OAAO,mCACX,aAAa,QAAQ,MAAM,UAAU,QAAQ,EAC7C,QAAQ,KACT;AACD,aAAU;IACR,MAAM,KAAK;IACX,cAAc,CACZ,GAAI,QAAQ,gBAAgB,EAAE,EAC9B,GAAI,KAAK,gBAAgB,EAAE,CAC5B;IACD,aAAa,CACX,GAAI,QAAQ,eAAe,EAAE,EAC7B,GAAI,KAAK,eAAe,EAAE,CAC3B;IACD,MAAM,CAAC,GAAI,QAAQ,QAAQ,EAAE,EAAG,GAAI,KAAK,QAAQ,EAAE,CAAE;IACtD;;AAGH,SAAO"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { StylePreprocessor } from "./style-preprocessor.js";
|
|
1
|
+
import type { StylePreprocessor, StylesheetDependency, StylesheetDiagnostic, StylesheetTransformResult, StylesheetTransformContext } from "./style-preprocessor.js";
|
|
2
2
|
export interface AnalogStylesheetRecord {
|
|
3
3
|
publicId: string;
|
|
4
4
|
sourcePath?: string;
|
|
5
5
|
originalCode?: string;
|
|
6
6
|
normalizedCode: string;
|
|
7
|
+
dependencies?: StylesheetDependency[];
|
|
8
|
+
diagnostics?: StylesheetDiagnostic[];
|
|
9
|
+
tags?: string[];
|
|
7
10
|
}
|
|
8
11
|
export declare class AnalogStylesheetRegistry {
|
|
9
12
|
private servedById;
|
|
@@ -23,6 +26,9 @@ export declare class AnalogStylesheetRegistry {
|
|
|
23
26
|
* file paths once externalized.
|
|
24
27
|
*/
|
|
25
28
|
private sourceToRequestIds;
|
|
29
|
+
private sourceToDependencies;
|
|
30
|
+
private sourceToDiagnostics;
|
|
31
|
+
private sourceToTags;
|
|
26
32
|
/**
|
|
27
33
|
* Canonicalizes browser-facing stylesheet request ids so Vite timestamp
|
|
28
34
|
* variants (`?t=...`) and path-shape variants (`abc.css?...` vs
|
|
@@ -42,15 +48,23 @@ export declare class AnalogStylesheetRegistry {
|
|
|
42
48
|
resolveExternalSource(requestId: string): string | undefined;
|
|
43
49
|
getPublicIdsForSource(sourcePath: string): string[];
|
|
44
50
|
getRequestIdsForSource(sourcePath: string): string[];
|
|
51
|
+
getDependenciesForSource(sourcePath: string): StylesheetDependency[];
|
|
52
|
+
getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[];
|
|
53
|
+
getTagsForSource(sourcePath: string): string[];
|
|
45
54
|
registerExternalRequest(requestId: string, sourcePath: string): void;
|
|
46
55
|
registerActiveRequest(requestId: string): void;
|
|
47
56
|
registerServedStylesheet(record: AnalogStylesheetRecord, aliases?: string[]): void;
|
|
57
|
+
private recomputeSourceMetadata;
|
|
48
58
|
private resolveServedRecord;
|
|
49
59
|
}
|
|
50
|
-
export declare function preprocessStylesheet(code: string, filename: string, stylePreprocessor?: StylePreprocessor): string;
|
|
60
|
+
export declare function preprocessStylesheet(code: string, filename: string, stylePreprocessor?: StylePreprocessor, context?: StylesheetTransformContext): string;
|
|
61
|
+
export declare function preprocessStylesheetResult(code: string, filename: string, stylePreprocessor?: StylePreprocessor, context?: StylesheetTransformContext): StylesheetTransformResult;
|
|
51
62
|
export declare function rewriteRelativeCssImports(code: string, filename: string): string;
|
|
52
|
-
export declare function registerStylesheetContent(registry: AnalogStylesheetRegistry, { code, containingFile, className, order, inlineStylesExtension, resourceFile }: {
|
|
63
|
+
export declare function registerStylesheetContent(registry: AnalogStylesheetRegistry, { code, dependencies, diagnostics, tags, containingFile, className, order, inlineStylesExtension, resourceFile }: {
|
|
53
64
|
code: string;
|
|
65
|
+
dependencies?: StylesheetDependency[];
|
|
66
|
+
diagnostics?: StylesheetDiagnostic[];
|
|
67
|
+
tags?: string[];
|
|
54
68
|
containingFile: string;
|
|
55
69
|
className?: string;
|
|
56
70
|
order?: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeStylesheetTransformResult } from "./style-preprocessor.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
3
|
import { dirname, normalize, resolve } from "node:path";
|
|
3
4
|
import { normalizePath } from "vite";
|
|
@@ -20,6 +21,9 @@ var AnalogStylesheetRegistry = class {
|
|
|
20
21
|
* file paths once externalized.
|
|
21
22
|
*/
|
|
22
23
|
sourceToRequestIds = /* @__PURE__ */ new Map();
|
|
24
|
+
sourceToDependencies = /* @__PURE__ */ new Map();
|
|
25
|
+
sourceToDiagnostics = /* @__PURE__ */ new Map();
|
|
26
|
+
sourceToTags = /* @__PURE__ */ new Map();
|
|
23
27
|
/**
|
|
24
28
|
* Canonicalizes browser-facing stylesheet request ids so Vite timestamp
|
|
25
29
|
* variants (`?t=...`) and path-shape variants (`abc.css?...` vs
|
|
@@ -63,6 +67,15 @@ var AnalogStylesheetRegistry = class {
|
|
|
63
67
|
getRequestIdsForSource(sourcePath) {
|
|
64
68
|
return [...this.sourceToRequestIds.get(sourcePath) ?? []];
|
|
65
69
|
}
|
|
70
|
+
getDependenciesForSource(sourcePath) {
|
|
71
|
+
return [...this.sourceToDependencies.get(sourcePath) ?? []];
|
|
72
|
+
}
|
|
73
|
+
getDiagnosticsForSource(sourcePath) {
|
|
74
|
+
return [...this.sourceToDiagnostics.get(sourcePath) ?? []];
|
|
75
|
+
}
|
|
76
|
+
getTagsForSource(sourcePath) {
|
|
77
|
+
return [...this.sourceToTags.get(sourcePath) ?? []];
|
|
78
|
+
}
|
|
66
79
|
registerExternalRequest(requestId, sourcePath) {
|
|
67
80
|
this.externalRequestToSource.set(this.normalizeRequestId(requestId), sourcePath);
|
|
68
81
|
}
|
|
@@ -88,16 +101,41 @@ var AnalogStylesheetRegistry = class {
|
|
|
88
101
|
const publicIds = this.sourceToPublicIds.get(record.sourcePath) ?? /* @__PURE__ */ new Set();
|
|
89
102
|
publicIds.add(publicId);
|
|
90
103
|
this.sourceToPublicIds.set(record.sourcePath, publicIds);
|
|
104
|
+
this.recomputeSourceMetadata(record.sourcePath);
|
|
91
105
|
}
|
|
92
106
|
}
|
|
107
|
+
recomputeSourceMetadata(sourcePath) {
|
|
108
|
+
const dependencies = /* @__PURE__ */ new Map();
|
|
109
|
+
const diagnostics = /* @__PURE__ */ new Map();
|
|
110
|
+
const tags = /* @__PURE__ */ new Set();
|
|
111
|
+
for (const publicId of this.sourceToPublicIds.get(sourcePath) ?? []) {
|
|
112
|
+
const record = this.servedById.get(publicId);
|
|
113
|
+
if (!record) continue;
|
|
114
|
+
for (const dependency of record.dependencies ?? []) {
|
|
115
|
+
const key = `${dependency.kind ?? "unknown"}:${dependency.id}:${dependency.owner ?? ""}`;
|
|
116
|
+
dependencies.set(key, dependency);
|
|
117
|
+
}
|
|
118
|
+
for (const diagnostic of record.diagnostics ?? []) {
|
|
119
|
+
const key = `${diagnostic.severity}:${diagnostic.code}:${diagnostic.message}`;
|
|
120
|
+
diagnostics.set(key, diagnostic);
|
|
121
|
+
}
|
|
122
|
+
for (const tag of record.tags ?? []) tags.add(tag);
|
|
123
|
+
}
|
|
124
|
+
this.sourceToDependencies.set(sourcePath, [...dependencies.values()]);
|
|
125
|
+
this.sourceToDiagnostics.set(sourcePath, [...diagnostics.values()]);
|
|
126
|
+
this.sourceToTags.set(sourcePath, [...tags]);
|
|
127
|
+
}
|
|
93
128
|
resolveServedRecord(requestId) {
|
|
94
129
|
const normalizedRequestId = this.normalizeRequestId(requestId);
|
|
95
130
|
const publicId = this.servedAliasToId.get(normalizedRequestId) ?? this.servedAliasToId.get(normalizedRequestId.split("?")[0]) ?? normalizedRequestId.split("?")[0];
|
|
96
131
|
return this.servedById.get(publicId);
|
|
97
132
|
}
|
|
98
133
|
};
|
|
99
|
-
function preprocessStylesheet(code, filename, stylePreprocessor) {
|
|
100
|
-
return
|
|
134
|
+
function preprocessStylesheet(code, filename, stylePreprocessor, context) {
|
|
135
|
+
return preprocessStylesheetResult(code, filename, stylePreprocessor, context).code;
|
|
136
|
+
}
|
|
137
|
+
function preprocessStylesheetResult(code, filename, stylePreprocessor, context) {
|
|
138
|
+
return normalizeStylesheetTransformResult(stylePreprocessor?.(code, filename, context), code);
|
|
101
139
|
}
|
|
102
140
|
function rewriteRelativeCssImports(code, filename) {
|
|
103
141
|
const cssDir = dirname(filename);
|
|
@@ -107,7 +145,7 @@ function rewriteRelativeCssImports(code, filename) {
|
|
|
107
145
|
return `@import ${stringQuote}${absPath}${stringQuote}`;
|
|
108
146
|
});
|
|
109
147
|
}
|
|
110
|
-
function registerStylesheetContent(registry, { code, containingFile, className, order, inlineStylesExtension, resourceFile }) {
|
|
148
|
+
function registerStylesheetContent(registry, { code, dependencies, diagnostics, tags, containingFile, className, order, inlineStylesExtension, resourceFile }) {
|
|
111
149
|
const stylesheetId = `${createHash("sha256").update(containingFile).update(className ?? "").update(String(order ?? 0)).update(code).digest("hex")}.${inlineStylesExtension}`;
|
|
112
150
|
const aliases = [];
|
|
113
151
|
if (resourceFile) {
|
|
@@ -117,11 +155,14 @@ function registerStylesheetContent(registry, { code, containingFile, className,
|
|
|
117
155
|
registry.registerServedStylesheet({
|
|
118
156
|
publicId: stylesheetId,
|
|
119
157
|
sourcePath: resourceFile,
|
|
120
|
-
normalizedCode: code
|
|
158
|
+
normalizedCode: code,
|
|
159
|
+
dependencies,
|
|
160
|
+
diagnostics,
|
|
161
|
+
tags
|
|
121
162
|
}, aliases);
|
|
122
163
|
return stylesheetId;
|
|
123
164
|
}
|
|
124
165
|
//#endregion
|
|
125
|
-
export { AnalogStylesheetRegistry, preprocessStylesheet, registerStylesheetContent, rewriteRelativeCssImports };
|
|
166
|
+
export { AnalogStylesheetRegistry, preprocessStylesheet, preprocessStylesheetResult, registerStylesheetContent, rewriteRelativeCssImports };
|
|
126
167
|
|
|
127
168
|
//# sourceMappingURL=stylesheet-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylesheet-registry.js","names":[],"sources":["../../../src/lib/stylesheet-registry.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { dirname, normalize, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\nimport type { StylePreprocessor } from './style-preprocessor.js';\n\nexport interface AnalogStylesheetRecord {\n publicId: string;\n sourcePath?: string;\n originalCode?: string;\n normalizedCode: string;\n}\n\nexport class AnalogStylesheetRegistry {\n private servedById = new Map<string, AnalogStylesheetRecord>();\n private servedAliasToId = new Map<string, string>();\n private externalRequestToSource = new Map<string, string>();\n /**\n * Maps a real source stylesheet path back to the generated public stylesheet\n * ids Analog serves for Angular. This is stable across requests and lets HMR\n * reason about \"which virtual stylesheet came from this source file?\"\n */\n private sourceToPublicIds = new Map<string, Set<string>>();\n /**\n * Tracks the live request ids Vite/Angular have actually served for a source\n * stylesheet, including both `?direct&ngcomp=...` CSS modules and\n * `?ngcomp=...` JS wrapper modules. HMR must use these live request ids\n * because Angular component styles are no longer addressed by their original\n * file paths once externalized.\n */\n private sourceToRequestIds = new Map<string, Set<string>>();\n\n /**\n * Canonicalizes browser-facing stylesheet request ids so Vite timestamp\n * variants (`?t=...`) and path-shape variants (`abc.css?...` vs\n * `/abc.css?...`) all collapse onto one logical module identity.\n *\n * This is critical for Angular component stylesheet HMR because the browser\n * can keep both timestamped and non-timestamped requests alive for the same\n * externalized stylesheet. If Analog tracks them as distinct resources, HMR\n * can update one module while the browser continues rendering another stale\n * module for the same public stylesheet id.\n */\n private normalizeRequestId(requestId: string): string {\n const [rawPathname, rawSearch = ''] = requestId.split('?');\n const normalizedPathname = rawPathname.replace(/^\\//, '');\n\n if (!rawSearch) {\n return normalizedPathname;\n }\n\n // Preserve bare query flags like `?direct&ngcomp=...` exactly. Using\n // URLSearchParams reserializes `direct` as `direct=`, which changes the\n // module identity and breaks Vite module-graph lookups for Angular's\n // externalized component stylesheet requests.\n const normalizedSearch = rawSearch\n .split('&')\n .filter((segment) => segment.length > 0)\n .filter((segment) => {\n const [key] = segment.split('=');\n return key !== 't';\n })\n .join('&');\n\n return normalizedSearch\n ? `${normalizedPathname}?${normalizedSearch}`\n : normalizedPathname;\n }\n\n get servedCount(): number {\n return this.servedById.size;\n }\n\n get externalCount(): number {\n return this.externalRequestToSource.size;\n }\n\n hasServed(requestId: string): boolean {\n return this.resolveServedRecord(requestId) !== undefined;\n }\n\n getServedContent(requestId: string): string | undefined {\n return this.resolveServedRecord(requestId)?.normalizedCode;\n }\n\n resolveExternalSource(requestId: string): string | undefined {\n const normalizedRequestId = this.normalizeRequestId(requestId);\n return this.externalRequestToSource.get(normalizedRequestId);\n }\n\n getPublicIdsForSource(sourcePath: string): string[] {\n return [...(this.sourceToPublicIds.get(sourcePath) ?? [])];\n }\n\n getRequestIdsForSource(sourcePath: string): string[] {\n return [...(this.sourceToRequestIds.get(sourcePath) ?? [])];\n }\n\n registerExternalRequest(requestId: string, sourcePath: string): void {\n this.externalRequestToSource.set(\n this.normalizeRequestId(requestId),\n sourcePath,\n );\n }\n\n registerActiveRequest(requestId: string): void {\n // Requests arrive in multiple shapes depending on who asked for the\n // stylesheet (`abc123.css?...` vs `/abc123.css?...`). Normalize both back to\n // the source file so later HMR events for `/src/...component.css` can find\n // the currently active virtual requests.\n const normalizedRequestId = this.normalizeRequestId(requestId);\n const requestPath = normalizedRequestId.split('?')[0];\n const sourcePath =\n this.resolveExternalSource(requestPath) ??\n this.resolveExternalSource(requestPath.replace(/^\\//, ''));\n if (!sourcePath) {\n return;\n }\n\n const requestIds = this.sourceToRequestIds.get(sourcePath) ?? new Set();\n requestIds.add(normalizedRequestId);\n // Angular component styles are served through both a direct CSS request\n // (`?direct&ngcomp=...`) and a JS wrapper request (`?ngcomp=...`). The\n // browser can already have the wrapper loaded even when Vite's live module\n // graph only surfaces the direct request during a CSS-only edit. Track the\n // derived wrapper id eagerly so HMR can reason about the browser-visible\n // stylesheet identity without waiting for that wrapper request to be\n // observed later in the session.\n if (normalizedRequestId.includes('?direct&ngcomp=')) {\n requestIds.add(\n normalizedRequestId.replace('?direct&ngcomp=', '?ngcomp='),\n );\n }\n this.sourceToRequestIds.set(sourcePath, requestIds);\n }\n\n registerServedStylesheet(\n record: AnalogStylesheetRecord,\n aliases: string[] = [],\n ): void {\n const publicId = this.normalizeRequestId(record.publicId);\n this.servedById.set(publicId, { ...record, publicId });\n this.servedAliasToId.set(publicId, publicId);\n\n for (const alias of aliases) {\n this.servedAliasToId.set(this.normalizeRequestId(alias), publicId);\n }\n\n if (record.sourcePath) {\n const publicIds =\n this.sourceToPublicIds.get(record.sourcePath) ?? new Set();\n publicIds.add(publicId);\n this.sourceToPublicIds.set(record.sourcePath, publicIds);\n }\n }\n\n private resolveServedRecord(\n requestId: string,\n ): AnalogStylesheetRecord | undefined {\n const normalizedRequestId = this.normalizeRequestId(requestId);\n const publicId =\n this.servedAliasToId.get(normalizedRequestId) ??\n this.servedAliasToId.get(normalizedRequestId.split('?')[0]) ??\n normalizedRequestId.split('?')[0];\n return this.servedById.get(publicId);\n }\n}\n\nexport function preprocessStylesheet(\n code: string,\n filename: string,\n stylePreprocessor?: StylePreprocessor,\n): string {\n return stylePreprocessor ? (stylePreprocessor(code, filename) ?? code) : code;\n}\n\nexport function rewriteRelativeCssImports(\n code: string,\n filename: string,\n): string {\n const cssDir = dirname(filename);\n return code.replace(\n /@import\\s+(?:url\\(\\s*([\"']?)(\\.[^'\")\\s;]+)\\1\\s*\\)|([\"'])(\\.[^'\"]+)\\3)/g,\n (_match, urlQuote, urlPath, stringQuote, stringPath) => {\n const relPath = urlPath ?? stringPath;\n const absPath = resolve(cssDir, relPath);\n\n if (typeof urlPath === 'string') {\n return `@import url(${urlQuote}${absPath}${urlQuote})`;\n }\n\n return `@import ${stringQuote}${absPath}${stringQuote}`;\n },\n );\n}\n\nexport function registerStylesheetContent(\n registry: AnalogStylesheetRegistry,\n {\n code,\n containingFile,\n className,\n order,\n inlineStylesExtension,\n resourceFile,\n }: {\n code: string;\n containingFile: string;\n className?: string;\n order?: number;\n inlineStylesExtension: string;\n resourceFile?: string;\n },\n): string {\n const id = createHash('sha256')\n .update(containingFile)\n .update(className ?? '')\n .update(String(order ?? 0))\n .update(code)\n .digest('hex');\n const stylesheetId = `${id}.${inlineStylesExtension}`;\n\n const aliases: string[] = [];\n\n if (resourceFile) {\n const normalizedResourceFile = normalizePath(normalize(resourceFile));\n // Avoid basename-only aliases here: shared filenames like `index.css`\n // can collide across components and break HMR lookups.\n aliases.push(\n resourceFile,\n normalizedResourceFile,\n resourceFile.replace(/^\\//, ''),\n normalizedResourceFile.replace(/^\\//, ''),\n );\n }\n\n registry.registerServedStylesheet(\n {\n publicId: stylesheetId,\n sourcePath: resourceFile,\n normalizedCode: code,\n },\n aliases,\n );\n\n return stylesheetId;\n}\n"],"mappings":";;;;AAYA,IAAa,2BAAb,MAAsC;CACpC,6BAAqB,IAAI,KAAqC;CAC9D,kCAA0B,IAAI,KAAqB;CACnD,0CAAkC,IAAI,KAAqB;;;;;;CAM3D,oCAA4B,IAAI,KAA0B;;;;;;;;CAQ1D,qCAA6B,IAAI,KAA0B;;;;;;;;;;;;CAa3D,mBAA2B,WAA2B;EACpD,MAAM,CAAC,aAAa,YAAY,MAAM,UAAU,MAAM,IAAI;EAC1D,MAAM,qBAAqB,YAAY,QAAQ,OAAO,GAAG;AAEzD,MAAI,CAAC,UACH,QAAO;EAOT,MAAM,mBAAmB,UACtB,MAA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,KAAK,CACZ,OAAO,MAAM,CACW,GAAG;CAE9B,MAAM,UAAoB,EAAE;AAE5B,KAAI,cAAc;EAChB,MAAM,yBAAyB,cAAc,UAAU,aAAa,CAAC;AAGrE,UAAQ,KACN,cACA,wBACA,aAAa,QAAQ,OAAO,GAAG,EAC/B,uBAAuB,QAAQ,OAAO,GAAG,CAC1C;;AAGH,UAAS,yBACP;EACE,UAAU;EACV,YAAY;EACZ,gBAAgB;EACjB,EACD,QACD;AAED,QAAO"}
|
|
1
|
+
{"version":3,"file":"stylesheet-registry.js","names":[],"sources":["../../../src/lib/stylesheet-registry.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { dirname, normalize, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\nimport type {\n StylePreprocessor,\n StylesheetDependency,\n StylesheetDiagnostic,\n StylesheetTransformResult,\n StylesheetTransformContext,\n} from './style-preprocessor.js';\nimport { normalizeStylesheetTransformResult as normalizeTransformResult } from './style-preprocessor.js';\n\nexport interface AnalogStylesheetRecord {\n publicId: string;\n sourcePath?: string;\n originalCode?: string;\n normalizedCode: string;\n dependencies?: StylesheetDependency[];\n diagnostics?: StylesheetDiagnostic[];\n tags?: string[];\n}\n\nexport class AnalogStylesheetRegistry {\n private servedById = new Map<string, AnalogStylesheetRecord>();\n private servedAliasToId = new Map<string, string>();\n private externalRequestToSource = new Map<string, string>();\n /**\n * Maps a real source stylesheet path back to the generated public stylesheet\n * ids Analog serves for Angular. This is stable across requests and lets HMR\n * reason about \"which virtual stylesheet came from this source file?\"\n */\n private sourceToPublicIds = new Map<string, Set<string>>();\n /**\n * Tracks the live request ids Vite/Angular have actually served for a source\n * stylesheet, including both `?direct&ngcomp=...` CSS modules and\n * `?ngcomp=...` JS wrapper modules. HMR must use these live request ids\n * because Angular component styles are no longer addressed by their original\n * file paths once externalized.\n */\n private sourceToRequestIds = new Map<string, Set<string>>();\n private sourceToDependencies = new Map<string, StylesheetDependency[]>();\n private sourceToDiagnostics = new Map<string, StylesheetDiagnostic[]>();\n private sourceToTags = new Map<string, string[]>();\n\n /**\n * Canonicalizes browser-facing stylesheet request ids so Vite timestamp\n * variants (`?t=...`) and path-shape variants (`abc.css?...` vs\n * `/abc.css?...`) all collapse onto one logical module identity.\n *\n * This is critical for Angular component stylesheet HMR because the browser\n * can keep both timestamped and non-timestamped requests alive for the same\n * externalized stylesheet. If Analog tracks them as distinct resources, HMR\n * can update one module while the browser continues rendering another stale\n * module for the same public stylesheet id.\n */\n private normalizeRequestId(requestId: string): string {\n const [rawPathname, rawSearch = ''] = requestId.split('?');\n const normalizedPathname = rawPathname.replace(/^\\//, '');\n\n if (!rawSearch) {\n return normalizedPathname;\n }\n\n // Preserve bare query flags like `?direct&ngcomp=...` exactly. Using\n // URLSearchParams reserializes `direct` as `direct=`, which changes the\n // module identity and breaks Vite module-graph lookups for Angular's\n // externalized component stylesheet requests.\n const normalizedSearch = rawSearch\n .split('&')\n .filter((segment) => segment.length > 0)\n .filter((segment) => {\n const [key] = segment.split('=');\n return key !== 't';\n })\n .join('&');\n\n return normalizedSearch\n ? `${normalizedPathname}?${normalizedSearch}`\n : normalizedPathname;\n }\n\n get servedCount(): number {\n return this.servedById.size;\n }\n\n get externalCount(): number {\n return this.externalRequestToSource.size;\n }\n\n hasServed(requestId: string): boolean {\n return this.resolveServedRecord(requestId) !== undefined;\n }\n\n getServedContent(requestId: string): string | undefined {\n return this.resolveServedRecord(requestId)?.normalizedCode;\n }\n\n resolveExternalSource(requestId: string): string | undefined {\n const normalizedRequestId = this.normalizeRequestId(requestId);\n return this.externalRequestToSource.get(normalizedRequestId);\n }\n\n getPublicIdsForSource(sourcePath: string): string[] {\n return [...(this.sourceToPublicIds.get(sourcePath) ?? [])];\n }\n\n getRequestIdsForSource(sourcePath: string): string[] {\n return [...(this.sourceToRequestIds.get(sourcePath) ?? [])];\n }\n\n getDependenciesForSource(sourcePath: string): StylesheetDependency[] {\n return [...(this.sourceToDependencies.get(sourcePath) ?? [])];\n }\n\n getDiagnosticsForSource(sourcePath: string): StylesheetDiagnostic[] {\n return [...(this.sourceToDiagnostics.get(sourcePath) ?? [])];\n }\n\n getTagsForSource(sourcePath: string): string[] {\n return [...(this.sourceToTags.get(sourcePath) ?? [])];\n }\n\n registerExternalRequest(requestId: string, sourcePath: string): void {\n this.externalRequestToSource.set(\n this.normalizeRequestId(requestId),\n sourcePath,\n );\n }\n\n registerActiveRequest(requestId: string): void {\n // Requests arrive in multiple shapes depending on who asked for the\n // stylesheet (`abc123.css?...` vs `/abc123.css?...`). Normalize both back to\n // the source file so later HMR events for `/src/...component.css` can find\n // the currently active virtual requests.\n const normalizedRequestId = this.normalizeRequestId(requestId);\n const requestPath = normalizedRequestId.split('?')[0];\n const sourcePath =\n this.resolveExternalSource(requestPath) ??\n this.resolveExternalSource(requestPath.replace(/^\\//, ''));\n if (!sourcePath) {\n return;\n }\n\n const requestIds = this.sourceToRequestIds.get(sourcePath) ?? new Set();\n requestIds.add(normalizedRequestId);\n // Angular component styles are served through both a direct CSS request\n // (`?direct&ngcomp=...`) and a JS wrapper request (`?ngcomp=...`). The\n // browser can already have the wrapper loaded even when Vite's live module\n // graph only surfaces the direct request during a CSS-only edit. Track the\n // derived wrapper id eagerly so HMR can reason about the browser-visible\n // stylesheet identity without waiting for that wrapper request to be\n // observed later in the session.\n if (normalizedRequestId.includes('?direct&ngcomp=')) {\n requestIds.add(\n normalizedRequestId.replace('?direct&ngcomp=', '?ngcomp='),\n );\n }\n this.sourceToRequestIds.set(sourcePath, requestIds);\n }\n\n registerServedStylesheet(\n record: AnalogStylesheetRecord,\n aliases: string[] = [],\n ): void {\n const publicId = this.normalizeRequestId(record.publicId);\n this.servedById.set(publicId, { ...record, publicId });\n this.servedAliasToId.set(publicId, publicId);\n\n for (const alias of aliases) {\n this.servedAliasToId.set(this.normalizeRequestId(alias), publicId);\n }\n\n if (record.sourcePath) {\n const publicIds =\n this.sourceToPublicIds.get(record.sourcePath) ?? new Set();\n publicIds.add(publicId);\n this.sourceToPublicIds.set(record.sourcePath, publicIds);\n this.recomputeSourceMetadata(record.sourcePath);\n }\n }\n\n private recomputeSourceMetadata(sourcePath: string): void {\n const dependencies = new Map<string, StylesheetDependency>();\n const diagnostics = new Map<string, StylesheetDiagnostic>();\n const tags = new Set<string>();\n\n for (const publicId of this.sourceToPublicIds.get(sourcePath) ?? []) {\n const record = this.servedById.get(publicId);\n if (!record) {\n continue;\n }\n\n for (const dependency of record.dependencies ?? []) {\n const key = `${dependency.kind ?? 'unknown'}:${dependency.id}:${dependency.owner ?? ''}`;\n dependencies.set(key, dependency);\n }\n\n for (const diagnostic of record.diagnostics ?? []) {\n const key = `${diagnostic.severity}:${diagnostic.code}:${diagnostic.message}`;\n diagnostics.set(key, diagnostic);\n }\n\n for (const tag of record.tags ?? []) {\n tags.add(tag);\n }\n }\n\n this.sourceToDependencies.set(sourcePath, [...dependencies.values()]);\n this.sourceToDiagnostics.set(sourcePath, [...diagnostics.values()]);\n this.sourceToTags.set(sourcePath, [...tags]);\n }\n\n private resolveServedRecord(\n requestId: string,\n ): AnalogStylesheetRecord | undefined {\n const normalizedRequestId = this.normalizeRequestId(requestId);\n const publicId =\n this.servedAliasToId.get(normalizedRequestId) ??\n this.servedAliasToId.get(normalizedRequestId.split('?')[0]) ??\n normalizedRequestId.split('?')[0];\n return this.servedById.get(publicId);\n }\n}\n\nexport function preprocessStylesheet(\n code: string,\n filename: string,\n stylePreprocessor?: StylePreprocessor,\n context?: StylesheetTransformContext,\n): string {\n return preprocessStylesheetResult(code, filename, stylePreprocessor, context)\n .code;\n}\n\nexport function preprocessStylesheetResult(\n code: string,\n filename: string,\n stylePreprocessor?: StylePreprocessor,\n context?: StylesheetTransformContext,\n): StylesheetTransformResult {\n return normalizeTransformResult(\n stylePreprocessor?.(code, filename, context),\n code,\n );\n}\n\nexport function rewriteRelativeCssImports(\n code: string,\n filename: string,\n): string {\n const cssDir = dirname(filename);\n return code.replace(\n /@import\\s+(?:url\\(\\s*([\"']?)(\\.[^'\")\\s;]+)\\1\\s*\\)|([\"'])(\\.[^'\"]+)\\3)/g,\n (_match, urlQuote, urlPath, stringQuote, stringPath) => {\n const relPath = urlPath ?? stringPath;\n const absPath = resolve(cssDir, relPath);\n\n if (typeof urlPath === 'string') {\n return `@import url(${urlQuote}${absPath}${urlQuote})`;\n }\n\n return `@import ${stringQuote}${absPath}${stringQuote}`;\n },\n );\n}\n\nexport function registerStylesheetContent(\n registry: AnalogStylesheetRegistry,\n {\n code,\n dependencies,\n diagnostics,\n tags,\n containingFile,\n className,\n order,\n inlineStylesExtension,\n resourceFile,\n }: {\n code: string;\n dependencies?: StylesheetDependency[];\n diagnostics?: StylesheetDiagnostic[];\n tags?: string[];\n containingFile: string;\n className?: string;\n order?: number;\n inlineStylesExtension: string;\n resourceFile?: string;\n },\n): string {\n const id = createHash('sha256')\n .update(containingFile)\n .update(className ?? '')\n .update(String(order ?? 0))\n .update(code)\n .digest('hex');\n const stylesheetId = `${id}.${inlineStylesExtension}`;\n\n const aliases: string[] = [];\n\n if (resourceFile) {\n const normalizedResourceFile = normalizePath(normalize(resourceFile));\n // Avoid basename-only aliases here: shared filenames like `index.css`\n // can collide across components and break HMR lookups.\n aliases.push(\n resourceFile,\n normalizedResourceFile,\n resourceFile.replace(/^\\//, ''),\n normalizedResourceFile.replace(/^\\//, ''),\n );\n }\n\n registry.registerServedStylesheet(\n {\n publicId: stylesheetId,\n sourcePath: resourceFile,\n normalizedCode: code,\n dependencies,\n diagnostics,\n tags,\n },\n aliases,\n );\n\n return stylesheetId;\n}\n"],"mappings":";;;;;AAsBA,IAAa,2BAAb,MAAsC;CACpC,6BAAqB,IAAI,KAAqC;CAC9D,kCAA0B,IAAI,KAAqB;CACnD,0CAAkC,IAAI,KAAqB;;;;;;CAM3D,oCAA4B,IAAI,KAA0B;;;;;;;;CAQ1D,qCAA6B,IAAI,KAA0B;CAC3D,uCAA+B,IAAI,KAAqC;CACxE,sCAA8B,IAAI,KAAqC;CACvE,+BAAuB,I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GtD,SAAO,WAAW,cAAc,UAAU;GAE7C;;AAGH,SAAgB,0BACd,UACA,EACE,MACA,cACA,aACA,MACA,gBACA,WACA,OACA,uBACA,gBAYM;CAOR,MAAM,eAAe,GANV,WAAW,SAAS,CAC5B,OAAO,eAAe,CACtB,OAAO,aAAa,GAAG,CACvB,OAAO,OAAO,SAAS,EAAE,CAAC,CAC1B,OAAO,KAAK,CACZ,OAAO,MAAM,CACW,GAAG;CAE9B,MAAM,UAAoB,EAAE;AAE5B,KAAI,cAAc;EAChB,MAAM,yBAAyB,cAAc,UAAU,aAAa,CAAC;AAGrE,UAAQ,KACN,cACA,wBACA,aAAa,QAAQ,OAAO,GAAG,EAC/B,uBAAuB,QAAQ,OAAO,GAAG,CAC1C;;AAGH,UAAS,yBACP;EACE,UAAU;EACV,YAAY;EACZ,gBAAgB;EAChB;EACA;EACA;EACD,EACD,QACD;AAED,QAAO"}
|
package/src/lib/utils/debug.d.ts
CHANGED
|
@@ -3,11 +3,12 @@ export declare const debugHmr: unknown;
|
|
|
3
3
|
export declare const debugStyles: unknown;
|
|
4
4
|
export declare const debugCompiler: unknown;
|
|
5
5
|
export declare const debugCompilationApi: unknown;
|
|
6
|
+
export declare const debugStylePipeline: unknown;
|
|
6
7
|
export declare const debugTailwindV: unknown;
|
|
7
8
|
export declare const debugHmrV: unknown;
|
|
8
9
|
export declare const debugStylesV: unknown;
|
|
9
10
|
export declare const debugCompilerV: unknown;
|
|
10
|
-
export type DebugScope = "analog:angular:*" | "analog:angular:hmr" | "analog:angular:hmr:v" | "analog:angular:styles" | "analog:angular:styles:v" | "analog:angular:compiler" | "analog:angular:compiler:v" | "analog:angular:compilation-api" | "analog:angular:tailwind" | "analog:angular:tailwind:v" | (string & {});
|
|
11
|
+
export type DebugScope = "analog:angular:*" | "analog:angular:hmr" | "analog:angular:hmr:v" | "analog:angular:styles" | "analog:angular:styles:v" | "analog:angular:compiler" | "analog:angular:compiler:v" | "analog:angular:compilation-api" | "analog:angular:style-pipeline" | "analog:angular:tailwind" | "analog:angular:tailwind:v" | (string & {});
|
|
11
12
|
export type DebugMode = "build" | "dev";
|
|
12
13
|
export interface DebugModeOptions {
|
|
13
14
|
scopes?: boolean | DebugScope[];
|
package/src/lib/utils/debug.js
CHANGED
|
@@ -6,6 +6,7 @@ var debugHmr = createDebug("analog:angular:hmr");
|
|
|
6
6
|
var debugStyles = createDebug("analog:angular:styles");
|
|
7
7
|
var debugCompiler = createDebug("analog:angular:compiler");
|
|
8
8
|
var debugCompilationApi = createDebug("analog:angular:compilation-api");
|
|
9
|
+
var debugStylePipeline = createDebug("analog:angular:style-pipeline");
|
|
9
10
|
var debugTailwindV = createDebug("analog:angular:tailwind:v");
|
|
10
11
|
var debugHmrV = createDebug("analog:angular:hmr:v");
|
|
11
12
|
var debugStylesV = createDebug("analog:angular:styles:v");
|
|
@@ -18,6 +19,7 @@ var harness = createDebugHarness({
|
|
|
18
19
|
debugStyles,
|
|
19
20
|
debugCompiler,
|
|
20
21
|
debugCompilationApi,
|
|
22
|
+
debugStylePipeline,
|
|
21
23
|
debugTailwindV,
|
|
22
24
|
debugHmrV,
|
|
23
25
|
debugStylesV,
|
|
@@ -28,6 +30,6 @@ var applyDebugOption = harness.applyDebugOption;
|
|
|
28
30
|
var activateDeferredDebug = harness.activateDeferredDebug;
|
|
29
31
|
harness._resetDeferredDebug;
|
|
30
32
|
//#endregion
|
|
31
|
-
export { activateDeferredDebug, applyDebugOption, debugCompilationApi, debugCompiler, debugCompilerV, debugHmr, debugHmrV, debugStyles, debugStylesV, debugTailwind, debugTailwindV };
|
|
33
|
+
export { activateDeferredDebug, applyDebugOption, debugCompilationApi, debugCompiler, debugCompilerV, debugHmr, debugHmrV, debugStylePipeline, debugStyles, debugStylesV, debugTailwind, debugTailwindV };
|
|
32
34
|
|
|
33
35
|
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","names":[],"sources":["../../../../src/lib/utils/debug.ts"],"sourcesContent":["import { createDebug } from 'obug';\nimport { createDebugHarness } from './debug-harness.js';\n\n// Normal — key decisions, once per startup or per component\nexport const debugTailwind = createDebug('analog:angular:tailwind');\nexport const debugHmr = createDebug('analog:angular:hmr');\nexport const debugStyles = createDebug('analog:angular:styles');\nexport const debugCompiler = createDebug('analog:angular:compiler');\nexport const debugCompilationApi = createDebug(\n 'analog:angular:compilation-api',\n);\n\n// Verbose — per-file detail, enable with :v suffix or parent:*\nexport const debugTailwindV = createDebug('analog:angular:tailwind:v');\nexport const debugHmrV = createDebug('analog:angular:hmr:v');\nexport const debugStylesV = createDebug('analog:angular:styles:v');\nexport const debugCompilerV = createDebug('analog:angular:compiler:v');\n\nconst angularDebugInstances = [\n debugTailwind,\n debugHmr,\n debugStyles,\n debugCompiler,\n debugCompilationApi,\n debugTailwindV,\n debugHmrV,\n debugStylesV,\n debugCompilerV,\n];\n\nexport type DebugScope =\n | 'analog:angular:*'\n | 'analog:angular:hmr'\n | 'analog:angular:hmr:v'\n | 'analog:angular:styles'\n | 'analog:angular:styles:v'\n | 'analog:angular:compiler'\n | 'analog:angular:compiler:v'\n | 'analog:angular:compilation-api'\n | 'analog:angular:tailwind'\n | 'analog:angular:tailwind:v'\n | (string & {});\n\nexport type DebugMode = 'build' | 'dev';\n\nexport interface DebugModeOptions {\n scopes?: boolean | DebugScope[];\n mode?: DebugMode;\n /**\n * Write debug output to log files under `tmp/debug/` in the workspace root.\n * - `true` or `'single'` — all output to `tmp/debug/analog.log`\n * - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`\n */\n logFile?: boolean | 'single' | 'scoped';\n}\n\nexport type DebugOption =\n | boolean\n | DebugScope[]\n | DebugModeOptions\n | DebugModeOptions[];\n\nconst harness = createDebugHarness({\n fallbackNamespace: 'analog:angular:*',\n instanceGroups: [angularDebugInstances],\n});\n\nexport const applyDebugOption: (\n debug: DebugOption | undefined,\n workspaceRoot?: string,\n) => void = harness.applyDebugOption;\nexport const activateDeferredDebug: (command: 'build' | 'serve') => void =\n harness.activateDeferredDebug;\nexport const _resetDeferredDebug: () => void = harness._resetDeferredDebug;\n"],"mappings":";;;AAIA,IAAa,gBAAgB,YAAY,0BAA0B;AACnE,IAAa,WAAW,YAAY,qBAAqB;AACzD,IAAa,cAAc,YAAY,wBAAwB;AAC/D,IAAa,gBAAgB,YAAY,0BAA0B;AACnE,IAAa,sBAAsB,YACjC,iCACD;
|
|
1
|
+
{"version":3,"file":"debug.js","names":[],"sources":["../../../../src/lib/utils/debug.ts"],"sourcesContent":["import { createDebug } from 'obug';\nimport { createDebugHarness } from './debug-harness.js';\n\n// Normal — key decisions, once per startup or per component\nexport const debugTailwind = createDebug('analog:angular:tailwind');\nexport const debugHmr = createDebug('analog:angular:hmr');\nexport const debugStyles = createDebug('analog:angular:styles');\nexport const debugCompiler = createDebug('analog:angular:compiler');\nexport const debugCompilationApi = createDebug(\n 'analog:angular:compilation-api',\n);\nexport const debugStylePipeline = createDebug('analog:angular:style-pipeline');\n\n// Verbose — per-file detail, enable with :v suffix or parent:*\nexport const debugTailwindV = createDebug('analog:angular:tailwind:v');\nexport const debugHmrV = createDebug('analog:angular:hmr:v');\nexport const debugStylesV = createDebug('analog:angular:styles:v');\nexport const debugCompilerV = createDebug('analog:angular:compiler:v');\n\nconst angularDebugInstances = [\n debugTailwind,\n debugHmr,\n debugStyles,\n debugCompiler,\n debugCompilationApi,\n debugStylePipeline,\n debugTailwindV,\n debugHmrV,\n debugStylesV,\n debugCompilerV,\n];\n\nexport type DebugScope =\n | 'analog:angular:*'\n | 'analog:angular:hmr'\n | 'analog:angular:hmr:v'\n | 'analog:angular:styles'\n | 'analog:angular:styles:v'\n | 'analog:angular:compiler'\n | 'analog:angular:compiler:v'\n | 'analog:angular:compilation-api'\n | 'analog:angular:style-pipeline'\n | 'analog:angular:tailwind'\n | 'analog:angular:tailwind:v'\n | (string & {});\n\nexport type DebugMode = 'build' | 'dev';\n\nexport interface DebugModeOptions {\n scopes?: boolean | DebugScope[];\n mode?: DebugMode;\n /**\n * Write debug output to log files under `tmp/debug/` in the workspace root.\n * - `true` or `'single'` — all output to `tmp/debug/analog.log`\n * - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`\n */\n logFile?: boolean | 'single' | 'scoped';\n}\n\nexport type DebugOption =\n | boolean\n | DebugScope[]\n | DebugModeOptions\n | DebugModeOptions[];\n\nconst harness = createDebugHarness({\n fallbackNamespace: 'analog:angular:*',\n instanceGroups: [angularDebugInstances],\n});\n\nexport const applyDebugOption: (\n debug: DebugOption | undefined,\n workspaceRoot?: string,\n) => void = harness.applyDebugOption;\nexport const activateDeferredDebug: (command: 'build' | 'serve') => void =\n harness.activateDeferredDebug;\nexport const _resetDeferredDebug: () => void = harness._resetDeferredDebug;\n"],"mappings":";;;AAIA,IAAa,gBAAgB,YAAY,0BAA0B;AACnE,IAAa,WAAW,YAAY,qBAAqB;AACzD,IAAa,cAAc,YAAY,wBAAwB;AAC/D,IAAa,gBAAgB,YAAY,0BAA0B;AACnE,IAAa,sBAAsB,YACjC,iCACD;AACD,IAAa,qBAAqB,YAAY,gCAAgC;AAG9E,IAAa,iBAAiB,YAAY,4BAA4B;AACtE,IAAa,YAAY,YAAY,uBAAuB;AAC5D,IAAa,eAAe,YAAY,0BAA0B;AAClE,IAAa,iBAAiB,YAAY,4BAA4B;AAgDtE,IAAM,UAAU,mBAAmB;CACjC,mBAAmB;CACnB,gBAAgB,CAhDY;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAqCwC;CACxC,CAAC;AAEF,IAAa,mBAGD,QAAQ;AACpB,IAAa,wBACX,QAAQ;AACqC,QAAQ"}
|