@analogjs/vite-plugin-angular 3.0.0-alpha.23 → 3.0.0-alpha.25

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.
@@ -0,0 +1,88 @@
1
+ import { DEBUG_LOG_DIR, DEBUG_LOG_FILENAME, wrapInstancesForFileLog, wrapInstancesForScopedFileLog } from "./debug-log-file.js";
2
+ import { join } from "node:path";
3
+ import { enable } from "obug";
4
+ //#region packages/vite-plugin-angular/src/lib/utils/debug-harness.ts
5
+ /**
6
+ * Duplicates of this file (keep in sync):
7
+ * packages/platform/src/lib/utils/debug-harness.ts
8
+ * packages/vite-plugin-angular/src/lib/utils/debug-harness.ts
9
+ */
10
+ function resolveNamespaces(scopes, fallback) {
11
+ if (scopes === true || scopes === void 0) return fallback;
12
+ if (Array.isArray(scopes) && scopes.length) return scopes.join(",");
13
+ return null;
14
+ }
15
+ function extractLogFile(debug) {
16
+ if (typeof debug === "boolean") return false;
17
+ if (Array.isArray(debug)) {
18
+ if (debug.length === 0 || typeof debug[0] === "string") return false;
19
+ return debug.find((e) => !!e.logFile)?.logFile ?? false;
20
+ }
21
+ return debug.logFile ?? false;
22
+ }
23
+ function createDebugHarness(config) {
24
+ let pendingDebug = [];
25
+ function installFileWrappers(logFile, root) {
26
+ if (logFile === "scoped") {
27
+ const dirPath = join(root, DEBUG_LOG_DIR);
28
+ for (const group of config.instanceGroups) wrapInstancesForScopedFileLog(group, dirPath);
29
+ } else {
30
+ const filePath = join(root, DEBUG_LOG_DIR, DEBUG_LOG_FILENAME);
31
+ for (const group of config.instanceGroups) wrapInstancesForFileLog(group, filePath);
32
+ }
33
+ }
34
+ function applyEntry(entry, fallback, logFile, root) {
35
+ if (!entry.mode) {
36
+ const ns = resolveNamespaces(entry.scopes ?? true, fallback);
37
+ if (ns) enable(ns);
38
+ if (logFile) installFileWrappers(logFile, root);
39
+ } else pendingDebug.push({
40
+ entry,
41
+ logFile,
42
+ root
43
+ });
44
+ }
45
+ return {
46
+ applyDebugOption(debug, workspaceRoot) {
47
+ if (debug == null || debug === false) return;
48
+ const logFile = extractLogFile(debug);
49
+ const root = workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd();
50
+ if (typeof debug === "boolean") {
51
+ const ns = resolveNamespaces(debug, config.fallbackNamespace);
52
+ if (ns) enable(ns);
53
+ return;
54
+ }
55
+ if (Array.isArray(debug)) {
56
+ if (debug.length === 0) return;
57
+ if (typeof debug[0] === "string") {
58
+ const ns = debug.join(",");
59
+ if (ns) enable(ns);
60
+ return;
61
+ }
62
+ for (const entry of debug) {
63
+ const entryLogFile = entry.logFile ?? false;
64
+ applyEntry(entry, config.fallbackNamespace, entryLogFile || logFile, root);
65
+ }
66
+ return;
67
+ }
68
+ applyEntry(debug, config.fallbackNamespace, logFile, root);
69
+ },
70
+ activateDeferredDebug(command) {
71
+ if (pendingDebug.length === 0) return;
72
+ const currentMode = command === "serve" ? "dev" : "build";
73
+ for (const { entry, logFile, root } of pendingDebug) if (entry.mode === currentMode) {
74
+ const ns = resolveNamespaces(entry.scopes ?? true, config.fallbackNamespace);
75
+ if (ns) enable(ns);
76
+ if (logFile) installFileWrappers(logFile, root);
77
+ }
78
+ pendingDebug = [];
79
+ },
80
+ _resetDeferredDebug() {
81
+ pendingDebug = [];
82
+ }
83
+ };
84
+ }
85
+ //#endregion
86
+ export { createDebugHarness };
87
+
88
+ //# sourceMappingURL=debug-harness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-harness.js","names":[],"sources":["../../../../src/lib/utils/debug-harness.ts"],"sourcesContent":["/**\n * Duplicates of this file (keep in sync):\n * packages/platform/src/lib/utils/debug-harness.ts\n * packages/vite-plugin-angular/src/lib/utils/debug-harness.ts\n */\nimport { join } from 'node:path';\nimport { enable } from 'obug';\nimport type { Debugger } from 'obug';\n\nimport {\n DEBUG_LOG_DIR,\n DEBUG_LOG_FILENAME,\n wrapInstancesForFileLog,\n wrapInstancesForScopedFileLog,\n} from './debug-log-file.js';\n\nexport type DebugMode = 'build' | 'dev';\n\nexport interface DebugModeOptions<S extends string = string> {\n scopes?: boolean | S[];\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<S extends string = string> =\n | boolean\n | S[]\n | DebugModeOptions<S>\n | DebugModeOptions<S>[];\n\nexport interface DebugHarness<S extends string = string> {\n applyDebugOption(\n debug: DebugOption<S> | undefined,\n workspaceRoot?: string,\n ): void;\n activateDeferredDebug(command: 'build' | 'serve'): void;\n /** @internal test-only reset */\n _resetDeferredDebug(): void;\n}\n\nfunction resolveNamespaces(\n scopes: boolean | string[] | undefined,\n fallback: string,\n): string | null {\n if (scopes === true || scopes === undefined) return fallback;\n if (Array.isArray(scopes) && scopes.length) return scopes.join(',');\n return null;\n}\n\nfunction extractLogFile(\n debug: DebugOption,\n): true | 'single' | 'scoped' | false {\n if (typeof debug === 'boolean') return false;\n if (Array.isArray(debug)) {\n if (debug.length === 0 || typeof debug[0] === 'string') return false;\n const entry = (debug as DebugModeOptions[]).find((e) => !!e.logFile);\n return entry?.logFile ?? false;\n }\n return (debug as DebugModeOptions).logFile ?? false;\n}\n\nexport function createDebugHarness<S extends string = string>(config: {\n fallbackNamespace: string;\n instanceGroups: Debugger[][];\n}): DebugHarness<S> {\n interface PendingEntry {\n entry: DebugModeOptions<S>;\n logFile: true | 'single' | 'scoped' | false;\n root: string;\n }\n\n let pendingDebug: PendingEntry[] = [];\n\n function installFileWrappers(\n logFile: true | 'single' | 'scoped',\n root: string,\n ): void {\n if (logFile === 'scoped') {\n const dirPath = join(root, DEBUG_LOG_DIR);\n for (const group of config.instanceGroups) {\n wrapInstancesForScopedFileLog(group, dirPath);\n }\n } else {\n const filePath = join(root, DEBUG_LOG_DIR, DEBUG_LOG_FILENAME);\n for (const group of config.instanceGroups) {\n wrapInstancesForFileLog(group, filePath);\n }\n }\n }\n\n function applyEntry(\n entry: DebugModeOptions<S>,\n fallback: string,\n logFile: true | 'single' | 'scoped' | false,\n root: string,\n ): void {\n if (!entry.mode) {\n const ns = resolveNamespaces(entry.scopes ?? true, fallback);\n if (ns) enable(ns);\n if (logFile) installFileWrappers(logFile, root);\n } else {\n pendingDebug.push({ entry, logFile, root });\n }\n }\n\n return {\n applyDebugOption(\n debug: DebugOption<S> | undefined,\n workspaceRoot?: string,\n ): void {\n if (debug == null || debug === false) return;\n\n const logFile = extractLogFile(debug);\n const root =\n workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd();\n\n if (typeof debug === 'boolean') {\n const ns = resolveNamespaces(debug, config.fallbackNamespace);\n if (ns) enable(ns);\n return;\n }\n\n if (Array.isArray(debug)) {\n if (debug.length === 0) return;\n\n if (typeof debug[0] === 'string') {\n const ns = (debug as string[]).join(',');\n if (ns) enable(ns);\n return;\n }\n\n for (const entry of debug as DebugModeOptions<S>[]) {\n const entryLogFile = entry.logFile ?? false;\n applyEntry(\n entry,\n config.fallbackNamespace,\n entryLogFile || logFile,\n root,\n );\n }\n return;\n }\n\n applyEntry(debug, config.fallbackNamespace, logFile, root);\n },\n\n activateDeferredDebug(command: 'build' | 'serve'): void {\n if (pendingDebug.length === 0) return;\n\n const currentMode = command === 'serve' ? 'dev' : 'build';\n\n for (const { entry, logFile, root } of pendingDebug) {\n if (entry.mode === currentMode) {\n const ns = resolveNamespaces(\n entry.scopes ?? true,\n config.fallbackNamespace,\n );\n if (ns) enable(ns);\n if (logFile) installFileWrappers(logFile, root);\n }\n }\n\n pendingDebug = [];\n },\n\n _resetDeferredDebug(): void {\n pendingDebug = [];\n },\n };\n}\n"],"mappings":";;;;;;;;;AA6CA,SAAS,kBACP,QACA,UACe;AACf,KAAI,WAAW,QAAQ,WAAW,KAAA,EAAW,QAAO;AACpD,KAAI,MAAM,QAAQ,OAAO,IAAI,OAAO,OAAQ,QAAO,OAAO,KAAK,IAAI;AACnE,QAAO;;AAGT,SAAS,eACP,OACoC;AACpC,KAAI,OAAO,UAAU,UAAW,QAAO;AACvC,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,MAAI,MAAM,WAAW,KAAK,OAAO,MAAM,OAAO,SAAU,QAAO;AAE/D,SADe,MAA6B,MAAM,MAAM,CAAC,CAAC,EAAE,QAAQ,EACtD,WAAW;;AAE3B,QAAQ,MAA2B,WAAW;;AAGhD,SAAgB,mBAA8C,QAG1C;CAOlB,IAAI,eAA+B,EAAE;CAErC,SAAS,oBACP,SACA,MACM;AACN,MAAI,YAAY,UAAU;GACxB,MAAM,UAAU,KAAK,MAAM,cAAc;AACzC,QAAK,MAAM,SAAS,OAAO,eACzB,+BAA8B,OAAO,QAAQ;SAE1C;GACL,MAAM,WAAW,KAAK,MAAM,eAAe,mBAAmB;AAC9D,QAAK,MAAM,SAAS,OAAO,eACzB,yBAAwB,OAAO,SAAS;;;CAK9C,SAAS,WACP,OACA,UACA,SACA,MACM;AACN,MAAI,CAAC,MAAM,MAAM;GACf,MAAM,KAAK,kBAAkB,MAAM,UAAU,MAAM,SAAS;AAC5D,OAAI,GAAI,QAAO,GAAG;AAClB,OAAI,QAAS,qBAAoB,SAAS,KAAK;QAE/C,cAAa,KAAK;GAAE;GAAO;GAAS;GAAM,CAAC;;AAI/C,QAAO;EACL,iBACE,OACA,eACM;AACN,OAAI,SAAS,QAAQ,UAAU,MAAO;GAEtC,MAAM,UAAU,eAAe,MAAM;GACrC,MAAM,OACJ,iBAAiB,QAAQ,IAAI,wBAAwB,QAAQ,KAAK;AAEpE,OAAI,OAAO,UAAU,WAAW;IAC9B,MAAM,KAAK,kBAAkB,OAAO,OAAO,kBAAkB;AAC7D,QAAI,GAAI,QAAO,GAAG;AAClB;;AAGF,OAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,QAAI,MAAM,WAAW,EAAG;AAExB,QAAI,OAAO,MAAM,OAAO,UAAU;KAChC,MAAM,KAAM,MAAmB,KAAK,IAAI;AACxC,SAAI,GAAI,QAAO,GAAG;AAClB;;AAGF,SAAK,MAAM,SAAS,OAAgC;KAClD,MAAM,eAAe,MAAM,WAAW;AACtC,gBACE,OACA,OAAO,mBACP,gBAAgB,SAChB,KACD;;AAEH;;AAGF,cAAW,OAAO,OAAO,mBAAmB,SAAS,KAAK;;EAG5D,sBAAsB,SAAkC;AACtD,OAAI,aAAa,WAAW,EAAG;GAE/B,MAAM,cAAc,YAAY,UAAU,QAAQ;AAElD,QAAK,MAAM,EAAE,OAAO,SAAS,UAAU,aACrC,KAAI,MAAM,SAAS,aAAa;IAC9B,MAAM,KAAK,kBACT,MAAM,UAAU,MAChB,OAAO,kBACR;AACD,QAAI,GAAI,QAAO,GAAG;AAClB,QAAI,QAAS,qBAAoB,SAAS,KAAK;;AAInD,kBAAe,EAAE;;EAGnB,sBAA4B;AAC1B,kBAAe,EAAE;;EAEpB"}
@@ -0,0 +1,5 @@
1
+ import type { Debugger } from "obug";
2
+ export declare const DEBUG_LOG_DIR = "tmp/debug";
3
+ export declare const DEBUG_LOG_FILENAME = "analog.log";
4
+ export declare function wrapInstancesForFileLog(instances: Debugger[], filePath: string): void;
5
+ export declare function wrapInstancesForScopedFileLog(instances: Debugger[], dirPath: string): void;
@@ -0,0 +1,56 @@
1
+ import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { format } from "node:util";
4
+ //#region packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts
5
+ /**
6
+ * Duplicates of this file (keep in sync):
7
+ * packages/platform/src/lib/utils/debug-log-file.ts
8
+ * packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts
9
+ */
10
+ var TRUNCATED_KEY = "__analogDebugLogTruncated";
11
+ var WRAPPED_KEY = "__analogFileLogWrapped";
12
+ var ANSI_RE = /\x1B\[[0-9;]*[A-Za-z]|\x1B\].*?\x07/g;
13
+ var DEBUG_LOG_DIR = "tmp/debug";
14
+ var DEBUG_LOG_FILENAME = "analog.log";
15
+ function ensureTruncated(filePath) {
16
+ const g = globalThis;
17
+ const truncated = g[TRUNCATED_KEY] ?? /* @__PURE__ */ new Set();
18
+ g[TRUNCATED_KEY] = truncated;
19
+ if (truncated.has(filePath)) return;
20
+ try {
21
+ mkdirSync(dirname(filePath), { recursive: true });
22
+ writeFileSync(filePath, "", "utf-8");
23
+ } catch {}
24
+ truncated.add(filePath);
25
+ }
26
+ function wrapLog(dbg, filePath) {
27
+ const rec = dbg;
28
+ if (rec[WRAPPED_KEY] === filePath) return;
29
+ const originalLog = rec[WRAPPED_KEY] && rec["__analogOriginalLog"] ? rec["__analogOriginalLog"] : dbg.log;
30
+ rec["__analogOriginalLog"] = originalLog;
31
+ dbg.log = function(...args) {
32
+ originalLog.apply(this, args);
33
+ try {
34
+ appendFileSync(filePath, format(...args).replace(ANSI_RE, "") + "\n", "utf-8");
35
+ } catch {}
36
+ };
37
+ rec[WRAPPED_KEY] = filePath;
38
+ }
39
+ function wrapInstancesForFileLog(instances, filePath) {
40
+ ensureTruncated(filePath);
41
+ for (const dbg of instances) wrapLog(dbg, filePath);
42
+ }
43
+ function scopeToFilename(namespace) {
44
+ return namespace.replace(/:/g, ".") + ".log";
45
+ }
46
+ function wrapInstancesForScopedFileLog(instances, dirPath) {
47
+ for (const dbg of instances) {
48
+ const scopedPath = join(dirPath, scopeToFilename(dbg.namespace));
49
+ ensureTruncated(scopedPath);
50
+ wrapLog(dbg, scopedPath);
51
+ }
52
+ }
53
+ //#endregion
54
+ export { DEBUG_LOG_DIR, DEBUG_LOG_FILENAME, wrapInstancesForFileLog, wrapInstancesForScopedFileLog };
55
+
56
+ //# sourceMappingURL=debug-log-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-log-file.js","names":[],"sources":["../../../../src/lib/utils/debug-log-file.ts"],"sourcesContent":["/**\n * Duplicates of this file (keep in sync):\n * packages/platform/src/lib/utils/debug-log-file.ts\n * packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts\n */\nimport { mkdirSync, writeFileSync, appendFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { format } from 'node:util';\nimport type { Debugger } from 'obug';\n\nconst TRUNCATED_KEY = '__analogDebugLogTruncated';\nconst WRAPPED_KEY = '__analogFileLogWrapped';\n// eslint-disable-next-line no-control-regex\nconst ANSI_RE = /\\x1B\\[[0-9;]*[A-Za-z]|\\x1B\\].*?\\x07/g;\n\nexport const DEBUG_LOG_DIR = 'tmp/debug';\nexport const DEBUG_LOG_FILENAME = 'analog.log';\n\nfunction ensureTruncated(filePath: string): void {\n const g = globalThis as Record<string, unknown>;\n const truncated = (g[TRUNCATED_KEY] as Set<string>) ?? new Set<string>();\n g[TRUNCATED_KEY] = truncated;\n if (truncated.has(filePath)) return;\n try {\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, '', 'utf-8');\n } catch {\n // best-effort: fall through to append mode if truncation fails\n }\n truncated.add(filePath);\n}\n\nfunction wrapLog(dbg: Debugger, filePath: string): void {\n const rec = dbg as Record<string, unknown>;\n if (rec[WRAPPED_KEY] === filePath) return;\n\n const originalLog =\n rec[WRAPPED_KEY] && rec['__analogOriginalLog']\n ? (rec['__analogOriginalLog'] as Debugger['log'])\n : dbg.log;\n\n rec['__analogOriginalLog'] = originalLog;\n dbg.log = function (this: Debugger, ...args: unknown[]) {\n originalLog.apply(this, args);\n try {\n const line = format(...args).replace(ANSI_RE, '') + '\\n';\n appendFileSync(filePath, line, 'utf-8');\n } catch {\n // debug logging must never crash the build\n }\n };\n rec[WRAPPED_KEY] = filePath;\n}\n\nexport function wrapInstancesForFileLog(\n instances: Debugger[],\n filePath: string,\n): void {\n ensureTruncated(filePath);\n for (const dbg of instances) {\n wrapLog(dbg, filePath);\n }\n}\n\nfunction scopeToFilename(namespace: string): string {\n return namespace.replace(/:/g, '.') + '.log';\n}\n\nexport function wrapInstancesForScopedFileLog(\n instances: Debugger[],\n dirPath: string,\n): void {\n for (const dbg of instances) {\n const scopedPath = join(dirPath, scopeToFilename(dbg.namespace));\n ensureTruncated(scopedPath);\n wrapLog(dbg, scopedPath);\n }\n}\n"],"mappings":";;;;;;;;;AAUA,IAAM,gBAAgB;AACtB,IAAM,cAAc;AAEpB,IAAM,UAAU;AAEhB,IAAa,gBAAgB;AAC7B,IAAa,qBAAqB;AAElC,SAAS,gBAAgB,UAAwB;CAC/C,MAAM,IAAI;CACV,MAAM,YAAa,EAAE,kCAAkC,IAAI,KAAa;AACxE,GAAE,iBAAiB;AACnB,KAAI,UAAU,IAAI,SAAS,CAAE;AAC7B,KAAI;AACF,YAAU,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACjD,gBAAc,UAAU,IAAI,QAAQ;SAC9B;AAGR,WAAU,IAAI,SAAS;;AAGzB,SAAS,QAAQ,KAAe,UAAwB;CACtD,MAAM,MAAM;AACZ,KAAI,IAAI,iBAAiB,SAAU;CAEnC,MAAM,cACJ,IAAI,gBAAgB,IAAI,yBACnB,IAAI,yBACL,IAAI;AAEV,KAAI,yBAAyB;AAC7B,KAAI,MAAM,SAA0B,GAAG,MAAiB;AACtD,cAAY,MAAM,MAAM,KAAK;AAC7B,MAAI;AAEF,kBAAe,UADF,OAAO,GAAG,KAAK,CAAC,QAAQ,SAAS,GAAG,GAAG,MACrB,QAAQ;UACjC;;AAIV,KAAI,eAAe;;AAGrB,SAAgB,wBACd,WACA,UACM;AACN,iBAAgB,SAAS;AACzB,MAAK,MAAM,OAAO,UAChB,SAAQ,KAAK,SAAS;;AAI1B,SAAS,gBAAgB,WAA2B;AAClD,QAAO,UAAU,QAAQ,MAAM,IAAI,GAAG;;AAGxC,SAAgB,8BACd,WACA,SACM;AACN,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,aAAa,KAAK,SAAS,gBAAgB,IAAI,UAAU,CAAC;AAChE,kBAAgB,WAAW;AAC3B,UAAQ,KAAK,WAAW"}
@@ -1,39 +1,25 @@
1
+ export declare const debugTailwind: unknown;
1
2
  export declare const debugHmr: unknown;
2
3
  export declare const debugStyles: unknown;
3
4
  export declare const debugCompiler: unknown;
4
5
  export declare const debugCompilationApi: unknown;
5
- export declare const debugTailwind: unknown;
6
- export type DebugScope = "analog:angular:*" | "analog:angular:hmr" | "analog:angular:styles" | "analog:angular:compiler" | "analog:angular:compilation-api" | "analog:angular:tailwind" | (string & {});
6
+ export declare const debugTailwindV: unknown;
7
+ export declare const debugHmrV: unknown;
8
+ export declare const debugStylesV: unknown;
9
+ 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 & {});
7
11
  export type DebugMode = "build" | "dev";
8
12
  export interface DebugModeOptions {
9
13
  scopes?: boolean | DebugScope[];
10
14
  mode?: DebugMode;
15
+ /**
16
+ * Write debug output to log files under `tmp/debug/` in the workspace root.
17
+ * - `true` or `'single'` — all output to `tmp/debug/analog.log`
18
+ * - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`
19
+ */
20
+ logFile?: boolean | "single" | "scoped";
11
21
  }
12
22
  export type DebugOption = boolean | DebugScope[] | DebugModeOptions | DebugModeOptions[];
13
- /**
14
- * Translates the user-facing `debug` plugin option into obug namespace
15
- * activations. Called once during the Vite plugin config hook.
16
- *
17
- * Additive — does not replace namespaces already enabled via the DEBUG
18
- * env var or localStorage.debug.
19
- *
20
- * When an object with `mode` is provided, activation is deferred until
21
- * {@link activateDeferredDebug} is called from a Vite config hook.
22
- *
23
- * Accepts an array of objects to enable different scopes per command:
24
- * ```ts
25
- * debug: [
26
- * { scopes: ['analog:angular:hmr'], mode: 'dev' },
27
- * { scopes: ['analog:angular:compiler'], mode: 'build' },
28
- * ]
29
- * ```
30
- */
31
- export declare function applyDebugOption(debug: DebugOption | undefined): void;
32
- /**
33
- * Called from a Vite config hook once `command` is known.
34
- * Maps Vite's `'serve'` to `'dev'` and `'build'` to `'build'`.
35
- * Idempotent — clears pending state after the first call.
36
- */
37
- export declare function activateDeferredDebug(command: "build" | "serve"): void;
38
- /** @internal test-only reset */
39
- export declare function _resetDeferredDebug(): void;
23
+ export declare const applyDebugOption: (debug: DebugOption | undefined, workspaceRoot?: string) => void;
24
+ export declare const activateDeferredDebug: (command: "build" | "serve") => void;
25
+ export declare const _resetDeferredDebug: () => void;
@@ -1,74 +1,33 @@
1
- import { createDebug, enable } from "obug";
1
+ import { createDebugHarness } from "./debug-harness.js";
2
+ import { createDebug } from "obug";
2
3
  //#region packages/vite-plugin-angular/src/lib/utils/debug.ts
4
+ var debugTailwind = createDebug("analog:angular:tailwind");
3
5
  var debugHmr = createDebug("analog:angular:hmr");
4
6
  var debugStyles = createDebug("analog:angular:styles");
5
7
  var debugCompiler = createDebug("analog:angular:compiler");
6
8
  var debugCompilationApi = createDebug("analog:angular:compilation-api");
7
- var debugTailwind = createDebug("analog:angular:tailwind");
8
- var pendingDebug = [];
9
- function resolveNamespaces(scopes, fallback) {
10
- if (scopes === true || scopes === void 0) return fallback;
11
- if (Array.isArray(scopes) && scopes.length) return scopes.join(",");
12
- return null;
13
- }
14
- function applyEntry(entry, fallback) {
15
- if (!entry.mode) {
16
- const ns = resolveNamespaces(entry.scopes ?? true, fallback);
17
- if (ns) enable(ns);
18
- } else pendingDebug.push(entry);
19
- }
20
- /**
21
- * Translates the user-facing `debug` plugin option into obug namespace
22
- * activations. Called once during the Vite plugin config hook.
23
- *
24
- * Additive — does not replace namespaces already enabled via the DEBUG
25
- * env var or localStorage.debug.
26
- *
27
- * When an object with `mode` is provided, activation is deferred until
28
- * {@link activateDeferredDebug} is called from a Vite config hook.
29
- *
30
- * Accepts an array of objects to enable different scopes per command:
31
- * ```ts
32
- * debug: [
33
- * { scopes: ['analog:angular:hmr'], mode: 'dev' },
34
- * { scopes: ['analog:angular:compiler'], mode: 'build' },
35
- * ]
36
- * ```
37
- */
38
- function applyDebugOption(debug) {
39
- if (debug == null || debug === false) return;
40
- if (typeof debug === "boolean") {
41
- const ns = resolveNamespaces(debug, "analog:angular:*");
42
- if (ns) enable(ns);
43
- return;
44
- }
45
- if (Array.isArray(debug)) {
46
- if (debug.length === 0) return;
47
- if (typeof debug[0] === "string") {
48
- const ns = debug.join(",");
49
- if (ns) enable(ns);
50
- return;
51
- }
52
- for (const entry of debug) applyEntry(entry, "analog:angular:*");
53
- return;
54
- }
55
- applyEntry(debug, "analog:angular:*");
56
- }
57
- /**
58
- * Called from a Vite config hook once `command` is known.
59
- * Maps Vite's `'serve'` to `'dev'` and `'build'` to `'build'`.
60
- * Idempotent — clears pending state after the first call.
61
- */
62
- function activateDeferredDebug(command) {
63
- if (pendingDebug.length === 0) return;
64
- const currentMode = command === "serve" ? "dev" : "build";
65
- for (const entry of pendingDebug) if (entry.mode === currentMode) {
66
- const ns = resolveNamespaces(entry.scopes ?? true, "analog:angular:*");
67
- if (ns) enable(ns);
68
- }
69
- pendingDebug = [];
70
- }
9
+ var debugTailwindV = createDebug("analog:angular:tailwind:v");
10
+ var debugHmrV = createDebug("analog:angular:hmr:v");
11
+ var debugStylesV = createDebug("analog:angular:styles:v");
12
+ var debugCompilerV = createDebug("analog:angular:compiler:v");
13
+ var harness = createDebugHarness({
14
+ fallbackNamespace: "analog:angular:*",
15
+ instanceGroups: [[
16
+ debugTailwind,
17
+ debugHmr,
18
+ debugStyles,
19
+ debugCompiler,
20
+ debugCompilationApi,
21
+ debugTailwindV,
22
+ debugHmrV,
23
+ debugStylesV,
24
+ debugCompilerV
25
+ ]]
26
+ });
27
+ var applyDebugOption = harness.applyDebugOption;
28
+ var activateDeferredDebug = harness.activateDeferredDebug;
29
+ harness._resetDeferredDebug;
71
30
  //#endregion
72
- export { activateDeferredDebug, applyDebugOption, debugCompilationApi, debugCompiler, debugHmr, debugStyles, debugTailwind };
31
+ export { activateDeferredDebug, applyDebugOption, debugCompilationApi, debugCompiler, debugCompilerV, debugHmr, debugHmrV, debugStyles, debugStylesV, debugTailwind, debugTailwindV };
73
32
 
74
33
  //# sourceMappingURL=debug.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug.js","names":[],"sources":["../../../../src/lib/utils/debug.ts"],"sourcesContent":["import { createDebug, enable } from 'obug';\n\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 debugTailwind = createDebug('analog:angular:tailwind');\n\nexport type DebugScope =\n | 'analog:angular:*'\n | 'analog:angular:hmr'\n | 'analog:angular:styles'\n | 'analog:angular:compiler'\n | 'analog:angular:compilation-api'\n | 'analog:angular:tailwind'\n | (string & {});\n\nexport type DebugMode = 'build' | 'dev';\n\nexport interface DebugModeOptions {\n scopes?: boolean | DebugScope[];\n mode?: DebugMode;\n}\n\nexport type DebugOption =\n | boolean\n | DebugScope[]\n | DebugModeOptions\n | DebugModeOptions[];\n\nlet pendingDebug: DebugModeOptions[] = [];\n\nfunction resolveNamespaces(\n scopes: boolean | string[] | undefined,\n fallback: string,\n): string | null {\n if (scopes === true || scopes === undefined) return fallback;\n if (Array.isArray(scopes) && scopes.length) return scopes.join(',');\n return null;\n}\n\nfunction applyEntry(entry: DebugModeOptions, fallback: string): void {\n if (!entry.mode) {\n const ns = resolveNamespaces(entry.scopes ?? true, fallback);\n if (ns) enable(ns);\n } else {\n pendingDebug.push(entry);\n }\n}\n\n/**\n * Translates the user-facing `debug` plugin option into obug namespace\n * activations. Called once during the Vite plugin config hook.\n *\n * Additive does not replace namespaces already enabled via the DEBUG\n * env var or localStorage.debug.\n *\n * When an object with `mode` is provided, activation is deferred until\n * {@link activateDeferredDebug} is called from a Vite config hook.\n *\n * Accepts an array of objects to enable different scopes per command:\n * ```ts\n * debug: [\n * { scopes: ['analog:angular:hmr'], mode: 'dev' },\n * { scopes: ['analog:angular:compiler'], mode: 'build' },\n * ]\n * ```\n */\nexport function applyDebugOption(debug: DebugOption | undefined): void {\n if (debug == null || debug === false) return;\n\n if (typeof debug === 'boolean') {\n const ns = resolveNamespaces(debug, 'analog:angular:*');\n if (ns) enable(ns);\n return;\n }\n\n if (Array.isArray(debug)) {\n if (debug.length === 0) return;\n\n if (typeof debug[0] === 'string') {\n const ns = (debug as string[]).join(',');\n if (ns) enable(ns);\n return;\n }\n\n for (const entry of debug as DebugModeOptions[]) {\n applyEntry(entry, 'analog:angular:*');\n }\n return;\n }\n\n applyEntry(debug, 'analog:angular:*');\n}\n\n/**\n * Called from a Vite config hook once `command` is known.\n * Maps Vite's `'serve'` to `'dev'` and `'build'` to `'build'`.\n * Idempotent clears pending state after the first call.\n */\nexport function activateDeferredDebug(command: 'build' | 'serve'): void {\n if (pendingDebug.length === 0) return;\n\n const currentMode = command === 'serve' ? 'dev' : 'build';\n\n for (const entry of pendingDebug) {\n if (entry.mode === currentMode) {\n const ns = resolveNamespaces(entry.scopes ?? true, 'analog:angular:*');\n if (ns) enable(ns);\n }\n }\n\n pendingDebug = [];\n}\n\n/** @internal test-only reset */\nexport function _resetDeferredDebug(): void {\n pendingDebug = [];\n}\n"],"mappings":";;AAEA,IAAa,WAAW,YAAY,qBAAqB;AACzD,IAAa,cAAc,YAAY,wBAAwB;AAC/D,IAAa,gBAAgB,YAAY,0BAA0B;AACnE,IAAa,sBAAsB,YACjC,iCACD;AACD,IAAa,gBAAgB,YAAY,0BAA0B;AAwBnE,IAAI,eAAmC,EAAE;AAEzC,SAAS,kBACP,QACA,UACe;AACf,KAAI,WAAW,QAAQ,WAAW,KAAA,EAAW,QAAO;AACpD,KAAI,MAAM,QAAQ,OAAO,IAAI,OAAO,OAAQ,QAAO,OAAO,KAAK,IAAI;AACnE,QAAO;;AAGT,SAAS,WAAW,OAAyB,UAAwB;AACnE,KAAI,CAAC,MAAM,MAAM;EACf,MAAM,KAAK,kBAAkB,MAAM,UAAU,MAAM,SAAS;AAC5D,MAAI,GAAI,QAAO,GAAG;OAElB,cAAa,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;AAsB5B,SAAgB,iBAAiB,OAAsC;AACrE,KAAI,SAAS,QAAQ,UAAU,MAAO;AAEtC,KAAI,OAAO,UAAU,WAAW;EAC9B,MAAM,KAAK,kBAAkB,OAAO,mBAAmB;AACvD,MAAI,GAAI,QAAO,GAAG;AAClB;;AAGF,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,MAAI,MAAM,WAAW,EAAG;AAExB,MAAI,OAAO,MAAM,OAAO,UAAU;GAChC,MAAM,KAAM,MAAmB,KAAK,IAAI;AACxC,OAAI,GAAI,QAAO,GAAG;AAClB;;AAGF,OAAK,MAAM,SAAS,MAClB,YAAW,OAAO,mBAAmB;AAEvC;;AAGF,YAAW,OAAO,mBAAmB;;;;;;;AAQvC,SAAgB,sBAAsB,SAAkC;AACtE,KAAI,aAAa,WAAW,EAAG;CAE/B,MAAM,cAAc,YAAY,UAAU,QAAQ;AAElD,MAAK,MAAM,SAAS,aAClB,KAAI,MAAM,SAAS,aAAa;EAC9B,MAAM,KAAK,kBAAkB,MAAM,UAAU,MAAM,mBAAmB;AACtE,MAAI,GAAI,QAAO,GAAG;;AAItB,gBAAe,EAAE"}
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;AAGD,IAAa,iBAAiB,YAAY,4BAA4B;AACtE,IAAa,YAAY,YAAY,uBAAuB;AAC5D,IAAa,eAAe,YAAY,0BAA0B;AAClE,IAAa,iBAAiB,YAAY,4BAA4B;AA8CtE,IAAM,UAAU,mBAAmB;CACjC,mBAAmB;CACnB,gBAAgB,CA9CY;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAoCwC;CACxC,CAAC;AAEF,IAAa,mBAGD,QAAQ;AACpB,IAAa,wBACX,QAAQ;AACqC,QAAQ"}
@@ -1,8 +1,8 @@
1
1
  import type { CompilerPluginOptions } from "./compiler-plugin-options.js";
2
- declare const angularMajor: number;
3
- declare const angularMinor: number;
4
- declare const angularPatch: number;
5
- declare const angularFullVersion: number;
2
+ declare const angularMajor: unknown;
3
+ declare const angularMinor: unknown;
4
+ declare const angularPatch: unknown;
5
+ declare const angularFullVersion: unknown;
6
6
  declare let sourceFileCache: any;
7
7
  declare let cjt: (...args: any[]) => any;
8
8
  declare let jt: any;
@@ -1 +1 @@
1
- {"version":3,"file":"devkit.js","names":[],"sources":["../../../../src/lib/utils/devkit.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport { createRequire } from 'node:module';\nimport type { CompilerPluginOptions } from './compiler-plugin-options.js';\nimport * as sfc from './source-file-cache.js';\n\nconst require = createRequire(import.meta.url);\n\nconst angularMajor: number = Number(VERSION.major);\nconst angularMinor: number = Number(VERSION.minor);\nconst angularPatch: number = Number(VERSION.patch);\nconst padVersion = (version: number) => String(version).padStart(2, '0');\nconst angularFullVersion: number = Number(\n `${angularMajor}${padVersion(angularMinor)}${padVersion(angularPatch)}`,\n);\nlet sourceFileCache: any;\nlet cjt: (...args: any[]) => any;\nlet jt: any;\nlet createAngularCompilation: (...args: any[]) => any;\n\nif (angularMajor < 17) {\n throw new Error('AnalogJS is not compatible with Angular v16 and lower');\n} else if (angularMajor >= 17 && angularMajor < 18) {\n const cp = require('@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js');\n const {\n createJitResourceTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/angular/jit-resource-transformer.js');\n const {\n JavaScriptTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/javascript-transformer.js');\n\n /**\n * Workaround for compatibility with Angular 17.0+\n */\n if (typeof cp['SourceFileCache'] !== 'undefined') {\n sourceFileCache = cp.SourceFileCache;\n } else {\n sourceFileCache = sfc.SourceFileCache;\n }\n\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n} else {\n const {\n createJitResourceTransformer,\n JavaScriptTransformer,\n SourceFileCache,\n createAngularCompilation: createAngularCompilationFn,\n } = require('@angular/build/private');\n\n sourceFileCache = SourceFileCache;\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n createAngularCompilation = createAngularCompilationFn;\n}\n\nexport {\n cjt as createJitResourceTransformer,\n jt as JavaScriptTransformer,\n sourceFileCache as SourceFileCache,\n CompilerPluginOptions,\n angularMajor,\n angularMinor,\n angularPatch,\n createAngularCompilation,\n angularFullVersion,\n};\n"],"mappings":";;;;AAKA,IAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,IAAM,eAAuB,OAAO,QAAQ,MAAM;AAClD,IAAM,eAAuB,OAAO,QAAQ,MAAM;AAClD,IAAM,eAAuB,OAAO,QAAQ,MAAM;AAClD,IAAM,cAAc,YAAoB,OAAO,QAAQ,CAAC,SAAS,GAAG,IAAI;AACxE,IAAM,qBAA6B,OACjC,GAAG,eAAe,WAAW,aAAa,GAAG,WAAW,aAAa,GACtE;AACD,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,IAAI,eAAe,GACjB,OAAM,IAAI,MAAM,wDAAwD;SAC/D,gBAAgB,MAAM,eAAe,IAAI;CAClD,MAAM,KAAK,QAAQ,6EAA6E;CAChG,MAAM,EACJ,iCACE,QAAQ,sFAAsF;CAClG,MAAM,EACJ,0BACE,QAAQ,4EAA4E;;;;AAKxF,KAAI,OAAO,GAAG,uBAAuB,YACnC,mBAAkB,GAAG;KAErB,mBAAkB;AAGpB,OAAM;AACN,MAAK;OACA;CACL,MAAM,EACJ,8BACA,uBACA,iBACA,0BAA0B,+BACxB,QAAQ,yBAAyB;AAErC,mBAAkB;AAClB,OAAM;AACN,MAAK;AACL,4BAA2B"}
1
+ {"version":3,"file":"devkit.js","names":[],"sources":["../../../../src/lib/utils/devkit.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport { createRequire } from 'node:module';\nimport type { CompilerPluginOptions } from './compiler-plugin-options.js';\nimport * as sfc from './source-file-cache.js';\n\nconst require = createRequire(import.meta.url);\n\nconst angularMajor = Number(VERSION.major);\nconst angularMinor = Number(VERSION.minor);\nconst angularPatch = Number(VERSION.patch);\nconst padVersion = (version: number) => String(version).padStart(2, '0');\nconst angularFullVersion = Number(\n `${angularMajor}${padVersion(angularMinor)}${padVersion(angularPatch)}`,\n);\nlet sourceFileCache: any;\nlet cjt: (...args: any[]) => any;\nlet jt: any;\nlet createAngularCompilation: (...args: any[]) => any;\n\nif (angularMajor < 17) {\n throw new Error('AnalogJS is not compatible with Angular v16 and lower');\n} else if (angularMajor >= 17 && angularMajor < 18) {\n const cp = require('@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js');\n const {\n createJitResourceTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/angular/jit-resource-transformer.js');\n const {\n JavaScriptTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/javascript-transformer.js');\n\n /**\n * Workaround for compatibility with Angular 17.0+\n */\n if (typeof cp['SourceFileCache'] !== 'undefined') {\n sourceFileCache = cp.SourceFileCache;\n } else {\n sourceFileCache = sfc.SourceFileCache;\n }\n\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n} else {\n const {\n createJitResourceTransformer,\n JavaScriptTransformer,\n SourceFileCache,\n createAngularCompilation: createAngularCompilationFn,\n } = require('@angular/build/private');\n\n sourceFileCache = SourceFileCache;\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n createAngularCompilation = createAngularCompilationFn;\n}\n\nexport {\n cjt as createJitResourceTransformer,\n jt as JavaScriptTransformer,\n sourceFileCache as SourceFileCache,\n CompilerPluginOptions,\n angularMajor,\n angularMinor,\n angularPatch,\n createAngularCompilation,\n angularFullVersion,\n};\n"],"mappings":";;;;AAKA,IAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,cAAc,YAAoB,OAAO,QAAQ,CAAC,SAAS,GAAG,IAAI;AACxE,IAAM,qBAAqB,OACzB,GAAG,eAAe,WAAW,aAAa,GAAG,WAAW,aAAa,GACtE;AACD,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,IAAI,eAAe,GACjB,OAAM,IAAI,MAAM,wDAAwD;SAC/D,gBAAgB,MAAM,eAAe,IAAI;CAClD,MAAM,KAAK,QAAQ,6EAA6E;CAChG,MAAM,EACJ,iCACE,QAAQ,sFAAsF;CAClG,MAAM,EACJ,0BACE,QAAQ,4EAA4E;;;;AAKxF,KAAI,OAAO,GAAG,uBAAuB,YACnC,mBAAkB,GAAG;KAErB,mBAAkB;AAGpB,OAAM;AACN,MAAK;OACA;CACL,MAAM,EACJ,8BACA,uBACA,iBACA,0BAA0B,+BACxB,QAAQ,yBAAyB;AAErC,mBAAkB;AAClB,OAAM;AACN,MAAK;AACL,4BAA2B"}