@analogjs/vite-plugin-angular 3.0.0-alpha.99 → 3.0.0-beta.1

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.
Files changed (85) hide show
  1. package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
  2. package/migrations/update-3-0-0/migrate-setup-vitest.js +3 -2
  3. package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -1
  4. package/package.json +1 -1
  5. package/src/lib/analog-plugin-interop.js +1 -1
  6. package/src/lib/analog-plugin-interop.js.map +1 -1
  7. package/src/lib/angular-build-optimizer-plugin.js +1 -1
  8. package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
  9. package/src/lib/angular-jit-plugin.js.map +1 -1
  10. package/src/lib/angular-vite-plugin.js +10 -7
  11. package/src/lib/angular-vite-plugin.js.map +1 -1
  12. package/src/lib/angular-vitest-plugin.js +1 -1
  13. package/src/lib/angular-vitest-plugin.js.map +1 -1
  14. package/src/lib/compilation-api/compilation-api-plugin.js +6 -5
  15. package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
  16. package/src/lib/compilation-api/index.js +2 -1
  17. package/src/lib/compiler/angular-version.js +1 -1
  18. package/src/lib/compiler/angular-version.js.map +1 -1
  19. package/src/lib/compiler/class-field-lowering.js.map +1 -1
  20. package/src/lib/compiler/compile.js +22 -19
  21. package/src/lib/compiler/compile.js.map +1 -1
  22. package/src/lib/compiler/constants.js +4 -4
  23. package/src/lib/compiler/constants.js.map +1 -1
  24. package/src/lib/compiler/debug.js.map +1 -1
  25. package/src/lib/compiler/defer.js +1 -1
  26. package/src/lib/compiler/defer.js.map +1 -1
  27. package/src/lib/compiler/dts-reader.js +1 -1
  28. package/src/lib/compiler/dts-reader.js.map +1 -1
  29. package/src/lib/compiler/hmr.js.map +1 -1
  30. package/src/lib/compiler/index.js +9 -8
  31. package/src/lib/compiler/jit-metadata.js.map +1 -1
  32. package/src/lib/compiler/jit-transform.js +3 -5
  33. package/src/lib/compiler/jit-transform.js.map +1 -1
  34. package/src/lib/compiler/js-emitter.js +2 -4
  35. package/src/lib/compiler/js-emitter.js.map +1 -1
  36. package/src/lib/compiler/metadata.js +10 -12
  37. package/src/lib/compiler/metadata.js.map +1 -1
  38. package/src/lib/compiler/registry.js.map +1 -1
  39. package/src/lib/compiler/resource-inliner.js.map +1 -1
  40. package/src/lib/compiler/style-ast.js.map +1 -1
  41. package/src/lib/compiler/type-elision.js +2 -2
  42. package/src/lib/compiler/type-elision.js.map +1 -1
  43. package/src/lib/compiler/utils.js +7 -5
  44. package/src/lib/compiler/utils.js.map +1 -1
  45. package/src/lib/compiler-plugin.js +7 -0
  46. package/src/lib/compiler-plugin.js.map +1 -1
  47. package/src/lib/component-resolvers.js +1 -1
  48. package/src/lib/component-resolvers.js.map +1 -1
  49. package/src/lib/encapsulation-plugin.js +3 -2
  50. package/src/lib/encapsulation-plugin.js.map +1 -1
  51. package/src/lib/fast-compile-plugin.js +3 -2
  52. package/src/lib/fast-compile-plugin.js.map +1 -1
  53. package/src/lib/host.js.map +1 -1
  54. package/src/lib/hot-update-batch.js +1 -1
  55. package/src/lib/hot-update-batch.js.map +1 -1
  56. package/src/lib/live-reload-plugin.js.map +1 -1
  57. package/src/lib/nx-folder-plugin.js.map +1 -1
  58. package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
  59. package/src/lib/router-plugin.js.map +1 -1
  60. package/src/lib/style-preprocessor.js.map +1 -1
  61. package/src/lib/stylesheet-registry.js.map +1 -1
  62. package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -1
  63. package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
  64. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +2 -1
  65. package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
  66. package/src/lib/utils/compilation-shared.js.map +1 -1
  67. package/src/lib/utils/css-extension-resolver.js.map +1 -1
  68. package/src/lib/utils/css-preprocessor-workers.js.map +1 -1
  69. package/src/lib/utils/debug-harness.js.map +1 -1
  70. package/src/lib/utils/debug-log-file.js +2 -1
  71. package/src/lib/utils/debug-log-file.js.map +1 -1
  72. package/src/lib/utils/debug.js.map +1 -1
  73. package/src/lib/utils/devkit.js +1 -1
  74. package/src/lib/utils/devkit.js.map +1 -1
  75. package/src/lib/utils/jit-inline-styles.js.map +1 -1
  76. package/src/lib/utils/plugin-config.js.map +1 -1
  77. package/src/lib/utils/rolldown.js.map +1 -1
  78. package/src/lib/utils/safe-module-paths.js.map +1 -1
  79. package/src/lib/utils/transform-cache.js.map +1 -1
  80. package/src/lib/utils/tsconfig-resolver.js +2 -1
  81. package/src/lib/utils/tsconfig-resolver.js.map +1 -1
  82. package/src/lib/utils/virtual-ids.js.map +1 -1
  83. package/src/lib/utils/virtual-resources.js.map +1 -1
  84. package/src/lib/virtual-modules-plugin.js +4 -1
  85. package/src/lib/virtual-modules-plugin.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"dev-server.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteDevServerSchema } from './schema';\n\nasync function viteDevServerBuilder(\n options: ViteDevServerSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createServer } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const buildTargetSpecifier = options.buildTarget ?? `::development`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n const serverConfig: InlineConfig = {\n configFile: buildOptions.configFile as string,\n root: projectConfig.root as string,\n // An explicit mode from the build options wins over an ambient NODE_ENV.\n // See #2458.\n mode: (buildOptions.mode ??\n process.env.NODE_ENV ??\n 'development') as string,\n build: {\n sourcemap: !!buildOptions.sourcemap,\n },\n server: {\n hmr: options?.hmr,\n port: options?.port,\n },\n };\n\n try {\n const server = await createServer(serverConfig);\n await server.listen();\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n const processOnExit = async () => {\n await server.close();\n };\n\n // Use process.once to avoid listener accumulation when Nx invokes\n // multiple builders in the same process during a large build graph.\n await new Promise<void>((resolve) => {\n const shutdown = () => {\n processOnExit().then(\n () => resolve(),\n () => resolve(),\n );\n };\n process.once('SIGINT', shutdown);\n process.once('SIGTERM', shutdown);\n process.once('exit', shutdown);\n });\n\n return {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n baseUrl: '',\n };\n }\n}\n\nexport default createBuilder(viteDevServerBuilder) as any;\n"],"mappings":";;AASA,eAAe,qBACb,SACA,SACwB;CACxB,MAAM,EAAE,iBAAiB,MAAM,SAAS,0BAAwB,EAAE;AAClE,KAAI,CAAC,QAAQ,OACX,OAAM,IAAI,MAAM,yCAAyC;CAE3D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,OAAO;CACtE,MAAM,cAAc,QAAQ,OAAO;CAEnC,MAAM,eAAA,GAAA,0BAAA,wBADuB,QAAQ,eAAe,iBAGlD,aACA,QACD;CAED,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,YAAY;CAC7E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,YAAY;CACnE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,mBACD;CAED,MAAM,eAA6B;EACjC,YAAY,aAAa;EACzB,MAAM,cAAc;EAGpB,MAAO,aAAa,QAAA,QAAA,IAAA,YAElB;EACF,OAAO,EACL,WAAW,CAAC,CAAC,aAAa,WAC3B;EACD,QAAQ;GACN,KAAK,SAAS;GACd,MAAM,SAAS;GAChB;EACF;AAED,KAAI;EACF,MAAM,SAAS,MAAM,aAAa,aAAa;AAC/C,QAAM,OAAO,QAAQ;AACrB,SAAO,WAAW;EAElB,MAAM,eAAe,CACnB,GAAG,OAAO,aAAa,OACvB,GAAG,OAAO,aAAa,QACxB;EAED,MAAM,gBAAgB,YAAY;AAChC,SAAM,OAAO,OAAO;;AAKtB,QAAM,IAAI,SAAe,YAAY;GACnC,MAAM,iBAAiB;AACrB,mBAAe,CAAC,WACR,SAAS,QACT,SAAS,CAChB;;AAEH,WAAQ,KAAK,UAAU,SAAS;AAChC,WAAQ,KAAK,WAAW,SAAS;AACjC,WAAQ,KAAK,QAAQ,SAAS;IAC9B;AAEF,SAAO;GACL,SAAS;GACT,SAAS,aAAa,MAAM;GAC7B;UACM,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,SAAO;GACL,SAAS;GACT,SAAS;GACV;;;AAIL,IAAA,2BAAA,GAAA,0BAAA,eAA6B,qBAAqB"}
1
+ {"version":3,"file":"dev-server.impl.js","names":[],"sources":["../../../../../../../../vite-plugin-angular-tools/src/builders/vite-dev-server/dev-server.impl.ts"],"sourcesContent":["import {\n BuilderContext,\n BuilderOutput,\n createBuilder,\n targetFromTargetString,\n} from '@angular-devkit/architect';\nimport type { InlineConfig } from 'vite';\nimport { ViteDevServerSchema } from './schema';\n\nasync function viteDevServerBuilder(\n options: ViteDevServerSchema,\n context: BuilderContext,\n): Promise<BuilderOutput> {\n const { createServer } = await Function('return import(\"vite\")')();\n if (!context.target) {\n throw new Error('Builder must be executed with a target');\n }\n const projectConfig = await context.getProjectMetadata(context.target);\n const projectName = context.target.project;\n const buildTargetSpecifier = options.buildTarget ?? `::development`;\n const buildTarget = targetFromTargetString(\n buildTargetSpecifier,\n projectName,\n 'build',\n );\n\n const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);\n const rawBuildOptions = await context.getTargetOptions(buildTarget);\n const buildOptions = await context.validateOptions(\n rawBuildOptions,\n browserBuilderName,\n );\n\n const serverConfig: InlineConfig = {\n configFile: buildOptions.configFile as string,\n root: projectConfig.root as string,\n // An explicit mode from the build options wins over an ambient NODE_ENV.\n // See #2458.\n mode: (buildOptions.mode ??\n process.env.NODE_ENV ??\n 'development') as string,\n build: {\n sourcemap: !!buildOptions.sourcemap,\n },\n server: {\n hmr: options?.hmr,\n port: options?.port,\n },\n };\n\n try {\n const server = await createServer(serverConfig);\n await server.listen();\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n const processOnExit = async () => {\n await server.close();\n };\n\n // Use process.once to avoid listener accumulation when Nx invokes\n // multiple builders in the same process during a large build graph.\n await new Promise<void>((resolve) => {\n const shutdown = () => {\n processOnExit().then(\n () => resolve(),\n () => resolve(),\n );\n };\n process.once('SIGINT', shutdown);\n process.once('SIGTERM', shutdown);\n process.once('exit', shutdown);\n });\n\n return {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n return {\n success: false,\n baseUrl: '',\n };\n }\n}\n\nexport default createBuilder(viteDevServerBuilder) as any;\n"],"mappings":";;AASA,eAAe,qBACb,SACA,SACwB;CACxB,MAAM,EAAE,iBAAiB,MAAM,SAAS,yBAAuB,CAAC,CAAC;CACjE,IAAI,CAAC,QAAQ,QACX,MAAM,IAAI,MAAM,wCAAwC;CAE1D,MAAM,gBAAgB,MAAM,QAAQ,mBAAmB,QAAQ,MAAM;CACrE,MAAM,cAAc,QAAQ,OAAO;CACnC,MAAM,uBAAuB,QAAQ,eAAe;CACpD,MAAM,eAAA,GAAc,0BAAA,uBAAA,CAClB,sBACA,aACA,OACF;CAEA,MAAM,qBAAqB,MAAM,QAAQ,wBAAwB,WAAW;CAC5E,MAAM,kBAAkB,MAAM,QAAQ,iBAAiB,WAAW;CAClE,MAAM,eAAe,MAAM,QAAQ,gBACjC,iBACA,kBACF;CAEA,MAAM,eAA6B;EACjC,YAAY,aAAa;EACzB,MAAM,cAAc;EAGpB,MAAO,aAAa,QAAA,QAAA,IAAA,YAElB;EACF,OAAO,EACL,WAAW,CAAC,CAAC,aAAa,UAC5B;EACA,QAAQ;GACN,KAAK,SAAS;GACd,MAAM,SAAS;EACjB;CACF;CAEA,IAAI;EACF,MAAM,SAAS,MAAM,aAAa,YAAY;EAC9C,MAAM,OAAO,OAAO;EACpB,OAAO,UAAU;EAEjB,MAAM,eAAe,CACnB,GAAG,OAAO,aAAa,OACvB,GAAG,OAAO,aAAa,OACzB;EAEA,MAAM,gBAAgB,YAAY;GAChC,MAAM,OAAO,MAAM;EACrB;EAIA,MAAM,IAAI,SAAe,YAAY;GACnC,MAAM,iBAAiB;IACrB,cAAc,CAAC,CAAC,WACR,QAAQ,SACR,QAAQ,CAChB;GACF;GACA,QAAQ,KAAK,UAAU,QAAQ;GAC/B,QAAQ,KAAK,WAAW,QAAQ;GAChC,QAAQ,KAAK,QAAQ,QAAQ;EAC/B,CAAC;EAED,OAAO;GACL,SAAS;GACT,SAAS,aAAa,MAAM;EAC9B;CACF,SAAS,GAAG;EACV,QAAQ,MAAM,CAAC;EACf,OAAO;GACL,SAAS;GACT,SAAS;EACX;CACF;AACF;AAEA,IAAA,2BAAA,GAAe,0BAAA,cAAA,CAAc,oBAAoB"}
@@ -1 +1 @@
1
- {"version":3,"file":"compilation-shared.js","names":[],"sources":["../../../../src/lib/utils/compilation-shared.ts"],"sourcesContent":["/**\n * Shared utilities used by both angular-vite-plugin.ts and\n * compilation-api/compilation-api-plugin.ts.\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { basename, isAbsolute, resolve } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport { normalizePath } from 'vite';\n\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport type { FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport { debugStylesV } from './debug.js';\n\nexport enum DiagnosticModes {\n None = 0,\n Option = 1 << 0,\n Syntactic = 1 << 1,\n Semantic = 1 << 2,\n All = Option | Syntactic | Semantic,\n}\n\nexport function injectViteIgnoreForHmrMetadata(code: string): string {\n let patched = code.replace(\n /\\bimport\\(([a-zA-Z_$][\\w$]*\\.\\u0275\\u0275getReplaceMetadataURL)/g,\n 'import(/* @vite-ignore */ $1',\n );\n\n if (patched === code) {\n patched = patched.replace(\n /import\\((\\S+getReplaceMetadataURL)/g,\n 'import(/* @vite-ignore */ $1',\n );\n }\n\n return patched;\n}\n\nexport function isIgnoredHmrFile(file: string): boolean {\n return file.endsWith('.tsbuildinfo');\n}\n\n/**\n * Convert Analog/Angular CLI-style file replacements into the flat record\n * expected by `AngularHostOptions.fileReplacements`.\n *\n * Only browser replacements (`{ replace, with }`) are converted. SSR-only\n * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to\n * handle — they should not be baked into the Angular compilation host because\n * that would apply them to both browser and server builds.\n *\n * Relative paths are resolved against `workspaceRoot` so that the host\n * receives the same absolute paths it would get from the Angular CLI.\n */\nexport function toAngularCompilationFileReplacements(\n replacements: FileReplacement[],\n workspaceRoot: string,\n): Record<string, string> | undefined {\n const mappedReplacements = replacements.flatMap((replacement) => {\n if (!('with' in replacement)) {\n return [];\n }\n\n return [\n [\n isAbsolute(replacement.replace)\n ? replacement.replace\n : resolve(workspaceRoot, replacement.replace),\n isAbsolute(replacement.with)\n ? replacement.with\n : resolve(workspaceRoot, replacement.with),\n ] as const,\n ];\n });\n\n return mappedReplacements.length\n ? Object.fromEntries(mappedReplacements)\n : undefined;\n}\n\n/**\n * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)\n * back to absolute file paths with their associated HMR code and component\n * class name.\n *\n * Angular's private Compilation API emits template update keys in the form\n * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve\n * them so the caller can look up updates by the same normalized absolute path\n * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).\n */\nexport function mapTemplateUpdatesToFiles(\n templateUpdates: ReadonlyMap<string, string> | undefined,\n): Map<\n string,\n {\n className: string;\n code: string;\n }\n> {\n const updatesByFile = new Map<string, { className: string; code: string }>();\n\n templateUpdates?.forEach((code, encodedUpdateId) => {\n const [file, className = ''] =\n decodeURIComponent(encodedUpdateId).split('@');\n const resolvedFile = normalizePath(resolve(process.cwd(), file));\n\n updatesByFile.set(resolvedFile, {\n className,\n code,\n });\n });\n\n return updatesByFile;\n}\n\nexport function describeStylesheetContent(code: string): {\n length: number;\n digest: string;\n preview: string;\n} {\n return {\n length: code.length,\n digest: createHash('sha256').update(code).digest('hex').slice(0, 12),\n preview: code.replace(/\\s+/g, ' ').trim().slice(0, 160),\n };\n}\n\n/**\n * Refreshes any already-served stylesheet records that map back to a changed\n * source file.\n *\n * This is the critical bridge for externalized Angular component styles during\n * HMR. Angular's resource watcher can notice that `/src/...component.css`\n * changed before Angular recompilation has had a chance to repopulate the\n * stylesheet registry. If we emit a CSS update against the existing virtual\n * stylesheet id without first refreshing the registry content, the browser gets\n * a hot update containing stale CSS. By rewriting the existing served records\n * from disk up front, HMR always pushes the latest source content.\n */\nexport function refreshStylesheetRegistryForFile(\n file: string,\n stylesheetRegistry?: AnalogStylesheetRegistry,\n stylePreprocessor?: StylePreprocessor,\n): void {\n const normalizedFile = normalizePath(file.split('?')[0]);\n if (!stylesheetRegistry || !existsSync(normalizedFile)) {\n return;\n }\n\n const publicIds = stylesheetRegistry.getPublicIdsForSource(normalizedFile);\n if (publicIds.length === 0) {\n return;\n }\n\n const rawCss = readFileSync(normalizedFile, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n normalizedFile,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(\n preprocessed.code,\n normalizedFile,\n );\n\n for (const publicId of publicIds) {\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId,\n sourcePath: normalizedFile,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [\n normalizedFile,\n normalizePath(normalizedFile),\n basename(normalizedFile),\n normalizedFile.replace(/^\\//, ''),\n ],\n );\n }\n\n debugStylesV('stylesheet registry refreshed from source file', {\n file: normalizedFile,\n publicIds,\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n source: describeStylesheetContent(rawCss),\n served: describeStylesheetContent(servedCss),\n });\n}\n\n/**\n * Checks for vitest run from the command line\n * @returns boolean\n */\nexport function isTestWatchMode(args = process.argv): boolean {\n // vitest --run\n const hasRun = args.find((arg) => arg.includes('--run'));\n if (hasRun) {\n return false;\n }\n\n // vitest run\n if (args.includes('run')) {\n return false;\n }\n\n // vitest --no-run\n const hasNoRun = args.find((arg) => arg.includes('--no-run'));\n if (hasNoRun) {\n return true;\n }\n\n // check for --watch=false or --no-watch\n const hasWatch = args.find((arg) => arg.includes('watch'));\n if (hasWatch && ['false', 'no'].some((neg) => hasWatch.includes(neg))) {\n return false;\n }\n\n // check for --watch false\n const watchIndex = args.findIndex((arg) => arg.includes('watch'));\n const watchArg = args[watchIndex + 1];\n if (watchArg && watchArg === 'false') {\n return false;\n }\n\n return true;\n}\n\nexport function getBrowserModeCliOverride(\n args = process.argv.slice(2),\n): boolean | undefined {\n let enabled: boolean | undefined;\n\n for (let i = 0; i < args.length; i++) {\n if (args[i] === '--') {\n break;\n }\n\n const [flag, inlineValue] = args[i].split('=', 2);\n if (flag === '--no-browser' || flag === '--no-browser.enabled') {\n enabled = false;\n } else if (flag === '--browser' || flag === '--browser.enabled') {\n const value = inlineValue ?? args[i + 1];\n if (value === 'false' || (flag === '--browser' && value === 'no')) {\n enabled = false;\n } else if (\n flag === '--browser.enabled' ||\n value === undefined ||\n value.startsWith('-') ||\n value === 'true' ||\n value === 'yes'\n ) {\n enabled = true;\n }\n }\n }\n\n return enabled;\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAY,kBAAL,yBAAA,iBAAA;AACL,iBAAA,gBAAA,UAAA,KAAA;AACA,iBAAA,gBAAA,YAAA,KAAA;AACA,iBAAA,gBAAA,eAAA,KAAA;AACA,iBAAA,gBAAA,cAAA,KAAA;AACA,iBAAA,gBAAA,SAAA,KAAA;;KACD;AAED,SAAgB,+BAA+B,MAAsB;CACnE,IAAI,UAAU,KAAK,QACjB,oEACA,+BACD;AAED,KAAI,YAAY,KACd,WAAU,QAAQ,QAChB,uCACA,+BACD;AAGH,QAAO;;AAGT,SAAgB,iBAAiB,MAAuB;AACtD,QAAO,KAAK,SAAS,eAAe;;;;;;;;;;;;;;AAetC,SAAgB,qCACd,cACA,eACoC;CACpC,MAAM,qBAAqB,aAAa,SAAS,gBAAgB;AAC/D,MAAI,EAAE,UAAU,aACd,QAAO,EAAE;AAGX,SAAO,CACL,CACE,WAAW,YAAY,QAAQ,GAC3B,YAAY,UACZ,QAAQ,eAAe,YAAY,QAAQ,EAC/C,WAAW,YAAY,KAAK,GACxB,YAAY,OACZ,QAAQ,eAAe,YAAY,KAAK,CAC7C,CACF;GACD;AAEF,QAAO,mBAAmB,SACtB,OAAO,YAAY,mBAAmB,GACtC,KAAA;;;;;;;;;;;;AAaN,SAAgB,0BACd,iBAOA;CACA,MAAM,gCAAgB,IAAI,KAAkD;AAE5E,kBAAiB,SAAS,MAAM,oBAAoB;EAClD,MAAM,CAAC,MAAM,YAAY,MACvB,mBAAmB,gBAAgB,CAAC,MAAM,IAAI;EAChD,MAAM,eAAe,cAAc,QAAQ,QAAQ,KAAK,EAAE,KAAK,CAAC;AAEhE,gBAAc,IAAI,cAAc;GAC9B;GACA;GACD,CAAC;GACF;AAEF,QAAO;;AAGT,SAAgB,0BAA0B,MAIxC;AACA,QAA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AC;AAC1D,KAAI,YAAY,CAAC,SAAS,KAAK,CAAC,MAAM,QAAQ,SAAS,SAAS,IAAI,CAAC,CACnE,QAAO;CAKT,MAAM,WAAW,KADE,KAAK,WAAW,QAAQ,IAAI,SAAS,QAAQ,CAAC,GAC9B;AACnC,KAAI,YAAY,aAAa,QAC3B,QAAO;AAGT,QAAO;;AAGT,SAAgB,0BACd,OAAO,QAAQ,KAAK,MAAM,EAAE,EACP;CACrB,IAAI;AAEJ,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,MAAI,KAAK,OAAO,KACd;EAGF,MAAM,CAAC,MAAM,eAAe,KAAK,GAAG,MAAM,KAAK,EAAE;AACjD,MAAI,SAAS,kBAAkB,SAAS,uBACtC,WAAU;WACD,SAAS,eAAe,SAAS,qBAAqB;GAC/D,MAAM,QAAQ,eAAe,KAAK,IAAI;AACtC,OAAI,UAAU,WAAY,SAAS,eAAe,UAAU,KAC1D,WAAU;YAEV,SAAS,uBACT,UAAU,KAAA,KACV,MAAM,WAAW,IAAI,IACrB,UAAU,UACV,UAAU,MAEV,WAAU;;;AAKhB,QAAO"}
1
+ {"version":3,"file":"compilation-shared.js","names":[],"sources":["../../../../src/lib/utils/compilation-shared.ts"],"sourcesContent":["/**\n * Shared utilities used by both angular-vite-plugin.ts and\n * compilation-api/compilation-api-plugin.ts.\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { basename, isAbsolute, resolve } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport { normalizePath } from 'vite';\n\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport type { FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport { debugStylesV } from './debug.js';\n\nexport enum DiagnosticModes {\n None = 0,\n Option = 1 << 0,\n Syntactic = 1 << 1,\n Semantic = 1 << 2,\n All = Option | Syntactic | Semantic,\n}\n\nexport function injectViteIgnoreForHmrMetadata(code: string): string {\n let patched = code.replace(\n /\\bimport\\(([a-zA-Z_$][\\w$]*\\.\\u0275\\u0275getReplaceMetadataURL)/g,\n 'import(/* @vite-ignore */ $1',\n );\n\n if (patched === code) {\n patched = patched.replace(\n /import\\((\\S+getReplaceMetadataURL)/g,\n 'import(/* @vite-ignore */ $1',\n );\n }\n\n return patched;\n}\n\nexport function isIgnoredHmrFile(file: string): boolean {\n return file.endsWith('.tsbuildinfo');\n}\n\n/**\n * Convert Analog/Angular CLI-style file replacements into the flat record\n * expected by `AngularHostOptions.fileReplacements`.\n *\n * Only browser replacements (`{ replace, with }`) are converted. SSR-only\n * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to\n * handle — they should not be baked into the Angular compilation host because\n * that would apply them to both browser and server builds.\n *\n * Relative paths are resolved against `workspaceRoot` so that the host\n * receives the same absolute paths it would get from the Angular CLI.\n */\nexport function toAngularCompilationFileReplacements(\n replacements: FileReplacement[],\n workspaceRoot: string,\n): Record<string, string> | undefined {\n const mappedReplacements = replacements.flatMap((replacement) => {\n if (!('with' in replacement)) {\n return [];\n }\n\n return [\n [\n isAbsolute(replacement.replace)\n ? replacement.replace\n : resolve(workspaceRoot, replacement.replace),\n isAbsolute(replacement.with)\n ? replacement.with\n : resolve(workspaceRoot, replacement.with),\n ] as const,\n ];\n });\n\n return mappedReplacements.length\n ? Object.fromEntries(mappedReplacements)\n : undefined;\n}\n\n/**\n * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)\n * back to absolute file paths with their associated HMR code and component\n * class name.\n *\n * Angular's private Compilation API emits template update keys in the form\n * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve\n * them so the caller can look up updates by the same normalized absolute path\n * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).\n */\nexport function mapTemplateUpdatesToFiles(\n templateUpdates: ReadonlyMap<string, string> | undefined,\n): Map<\n string,\n {\n className: string;\n code: string;\n }\n> {\n const updatesByFile = new Map<string, { className: string; code: string }>();\n\n templateUpdates?.forEach((code, encodedUpdateId) => {\n const [file, className = ''] =\n decodeURIComponent(encodedUpdateId).split('@');\n const resolvedFile = normalizePath(resolve(process.cwd(), file));\n\n updatesByFile.set(resolvedFile, {\n className,\n code,\n });\n });\n\n return updatesByFile;\n}\n\nexport function describeStylesheetContent(code: string): {\n length: number;\n digest: string;\n preview: string;\n} {\n return {\n length: code.length,\n digest: createHash('sha256').update(code).digest('hex').slice(0, 12),\n preview: code.replace(/\\s+/g, ' ').trim().slice(0, 160),\n };\n}\n\n/**\n * Refreshes any already-served stylesheet records that map back to a changed\n * source file.\n *\n * This is the critical bridge for externalized Angular component styles during\n * HMR. Angular's resource watcher can notice that `/src/...component.css`\n * changed before Angular recompilation has had a chance to repopulate the\n * stylesheet registry. If we emit a CSS update against the existing virtual\n * stylesheet id without first refreshing the registry content, the browser gets\n * a hot update containing stale CSS. By rewriting the existing served records\n * from disk up front, HMR always pushes the latest source content.\n */\nexport function refreshStylesheetRegistryForFile(\n file: string,\n stylesheetRegistry?: AnalogStylesheetRegistry,\n stylePreprocessor?: StylePreprocessor,\n): void {\n const normalizedFile = normalizePath(file.split('?')[0]);\n if (!stylesheetRegistry || !existsSync(normalizedFile)) {\n return;\n }\n\n const publicIds = stylesheetRegistry.getPublicIdsForSource(normalizedFile);\n if (publicIds.length === 0) {\n return;\n }\n\n const rawCss = readFileSync(normalizedFile, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n normalizedFile,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(\n preprocessed.code,\n normalizedFile,\n );\n\n for (const publicId of publicIds) {\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId,\n sourcePath: normalizedFile,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [\n normalizedFile,\n normalizePath(normalizedFile),\n basename(normalizedFile),\n normalizedFile.replace(/^\\//, ''),\n ],\n );\n }\n\n debugStylesV('stylesheet registry refreshed from source file', {\n file: normalizedFile,\n publicIds,\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n source: describeStylesheetContent(rawCss),\n served: describeStylesheetContent(servedCss),\n });\n}\n\n/**\n * Checks for vitest run from the command line\n * @returns boolean\n */\nexport function isTestWatchMode(args = process.argv): boolean {\n // vitest --run\n const hasRun = args.find((arg) => arg.includes('--run'));\n if (hasRun) {\n return false;\n }\n\n // vitest run\n if (args.includes('run')) {\n return false;\n }\n\n // vitest --no-run\n const hasNoRun = args.find((arg) => arg.includes('--no-run'));\n if (hasNoRun) {\n return true;\n }\n\n // check for --watch=false or --no-watch\n const hasWatch = args.find((arg) => arg.includes('watch'));\n if (hasWatch && ['false', 'no'].some((neg) => hasWatch.includes(neg))) {\n return false;\n }\n\n // check for --watch false\n const watchIndex = args.findIndex((arg) => arg.includes('watch'));\n const watchArg = args[watchIndex + 1];\n if (watchArg && watchArg === 'false') {\n return false;\n }\n\n return true;\n}\n\nexport function getBrowserModeCliOverride(\n args = process.argv.slice(2),\n): boolean | undefined {\n let enabled: boolean | undefined;\n\n for (let i = 0; i < args.length; i++) {\n if (args[i] === '--') {\n break;\n }\n\n const [flag, inlineValue] = args[i].split('=', 2);\n if (flag === '--no-browser' || flag === '--no-browser.enabled') {\n enabled = false;\n } else if (flag === '--browser' || flag === '--browser.enabled') {\n const value = inlineValue ?? args[i + 1];\n if (value === 'false' || (flag === '--browser' && value === 'no')) {\n enabled = false;\n } else if (\n flag === '--browser.enabled' ||\n value === undefined ||\n value.startsWith('-') ||\n value === 'true' ||\n value === 'yes'\n ) {\n enabled = true;\n }\n }\n }\n\n return enabled;\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAY,kBAAL,yBAAA,iBAAA;CACL,gBAAA,gBAAA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T,MAAM,WAAW,KADE,KAAK,WAAW,QAAQ,IAAI,SAAS,OAAO,CACzC,IAAa;CACnC,IAAI,YAAY,aAAa,SAC3B,OAAO;CAGT,OAAO;AACT;AAEA,SAAgB,0BACd,OAAO,QAAQ,KAAK,MAAM,CAAC,GACN;CACrB,IAAI;CAEJ,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,IAAI,KAAK,OAAO,MACd;EAGF,MAAM,CAAC,MAAM,eAAe,KAAK,EAAE,CAAC,MAAM,KAAK,CAAC;EAChD,IAAI,SAAS,kBAAkB,SAAS,wBACtC,UAAU;OACL,IAAI,SAAS,eAAe,SAAS,qBAAqB;GAC/D,MAAM,QAAQ,eAAe,KAAK,IAAI;GACtC,IAAI,UAAU,WAAY,SAAS,eAAe,UAAU,MAC1D,UAAU;QACL,IACL,SAAS,uBACT,UAAU,KAAA,KACV,MAAM,WAAW,GAAG,KACpB,UAAU,UACV,UAAU,OAEV,UAAU;EAEd;CACF;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"css-extension-resolver.js","names":[],"sources":["../../../../src/lib/utils/css-extension-resolver.ts"],"sourcesContent":["import * as vite from 'vite';\n\ntype CssResolver = (\n id: string,\n importer: string | undefined,\n environment?: { name: string } | undefined,\n) => Promise<string | undefined>;\n\n/**\n * Resolves bare-specifier `.css` imports with the `style` package-export\n * condition in scope, without leaking `style` into Vite's global\n * `resolve.conditions`.\n *\n * Two real cases pull in opposite directions on this condition:\n *\n * 1. `import '@angular/material/prebuilt-themes/azure-blue.css'` from TS:\n * Material's prebuilt theme entries are gated *only* under the `style`\n * condition (no `default`, no `import`), so without `style` in scope\n * the request fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`.\n *\n * 2. `@plugin 'tailwindcss-primeui'` from a CSS file: Tailwind v4's JS\n * plugin resolver inherits Vite's global conditions. If `style` is\n * injected globally, that resolver matches the package's `style`\n * export (a `.css` file) and feeds it to Node's ESM loader, which\n * can't load `.css` and throws\n * `Internal server error: Unknown file extension \".css\"`.\n *\n * The fix: scope the `style` condition to requests that *look* like CSS\n * assets — bare specifiers ending in `.css` (with optional query suffix\n * for `?inline`, `?module`, etc.). Non-CSS bare specifiers fall through\n * to Vite's normal resolver chain, so packages with mixed exports\n * (`tailwindcss-primeui` exposes both `style` and `import`) resolve to\n * their JS surface.\n *\n * Vite 7 exposes `ResolvedConfig.createResolver(options)`; Vite 8 exposes\n * `vite.createIdResolver(config, options)`. Their resolver-call signatures\n * differ — this plugin normalizes both.\n */\nexport function cssExtensionStyleResolverPlugin(): vite.Plugin {\n let resolveCss: CssResolver | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular:css-style-resolver',\n enforce: 'pre',\n\n configResolved(config) {\n const styleResolveOptions = {\n ...config.resolve,\n conditions: [...(config.resolve.conditions ?? []), 'style'],\n };\n\n const createIdResolver = (\n vite as unknown as {\n createIdResolver?: (\n c: vite.ResolvedConfig,\n o: typeof styleResolveOptions,\n ) => (\n environment: { name: string },\n id: string,\n importer: string | undefined,\n ssr: boolean,\n ) => Promise<string | undefined>;\n }\n ).createIdResolver;\n\n if (typeof createIdResolver === 'function') {\n const r = createIdResolver(config, styleResolveOptions);\n resolveCss = async (id, importer, environment) => {\n return await r(\n environment ?? { name: 'client' },\n id,\n importer,\n false,\n );\n };\n return;\n }\n\n const legacyCreateResolver = (\n config as unknown as {\n createResolver?: (\n o: typeof styleResolveOptions,\n ) => (\n id: string,\n importer: string | undefined,\n aliasOnly: boolean,\n ssr: boolean,\n ) => Promise<string | undefined>;\n }\n ).createResolver;\n\n if (typeof legacyCreateResolver === 'function') {\n const r = legacyCreateResolver(styleResolveOptions);\n resolveCss = async (id, importer) => {\n return await r(id, importer, false, false);\n };\n return;\n }\n\n // Both APIs have been stable across the supported Vite range\n // (7.x via `ResolvedConfig.createResolver`, 8.x via\n // `vite.createIdResolver`). If neither is present, fail loudly\n // rather than silently regressing CSS imports of `style`-only\n // package exports such as `@angular/material/prebuilt-themes/*`.\n throw new Error(\n '[@analogjs/vite-plugin-angular]: neither vite.createIdResolver ' +\n '(Vite 8) nor ResolvedConfig.createResolver (Vite 7) is available. ' +\n 'Unsupported Vite version.',\n );\n },\n\n async resolveId(id, importer) {\n if (!resolveCss) return null;\n\n // Skip non-bare specifiers — relative, absolute, virtual, and\n // data-URI imports don't consult package exports, so the `style`\n // condition is irrelevant for them.\n if (\n id.startsWith('.') ||\n id.startsWith('/') ||\n /^[A-Za-z]:\\//.test(id) ||\n id.startsWith('\\0') ||\n id.startsWith('data:') ||\n id.startsWith('virtual:')\n ) {\n return null;\n }\n\n // Only fire on `.css` requests (with optional query, e.g. `?inline`,\n // `?module`). Non-CSS bare specifiers go through Vite's normal\n // resolver chain unchanged, which is critical for packages whose\n // exports include both `style` and `import`/`default` — e.g.\n // `tailwindcss-primeui`, where `@plugin` resolution must land on\n // the JS file, not the CSS file.\n if (!/\\.css(?:\\?|$)/.test(id)) return null;\n\n const env = (this as unknown as { environment?: { name: string } })\n .environment;\n const resolved = await resolveCss(id, importer, env);\n return resolved ?? null;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,kCAA+C;CAC7D,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;EAET,eAAe,QAAQ;GACrB,MAAM,sBAAsB;IAC1B,GAAG,OAAO;IACV,YAAY,CAAC,GAAI,OAAO,QAAQ,cAAc,EAAE,EAAG,QAAQ;IAC5D;GAED,MAAM,mBACJ,KAWA;AAEF,OAAI,OAAO,qBAAqB,YAAY;IAC1C,MAAM,IAAI,iBAAiB,QAAQ,oBAAoB;AACvD,iBAAa,OAAO,IAAI,UAAU,gBAAgB;AAChD,YAAO,MAAM,EACX,eAAe,EAAE,MAAM,UAAU,EACjC,IACA,UACA,MACD;;AAEH;;GAGF,MAAM,uBACJ,OAUA;AAEF,OAAI,OAAO,yBAAyB,YAAY;IAC9C,MAAM,IAAI,qBAAqB,oBAAoB;AACnD,iBAAa,OAAO,IAAI,aAAa;AACnC,YAAO,MAAM,EAAE,IAAI,UAAU,OAAO,MAAM;;AAE5C;;AAQF,SAAM,IAAI,MACR,6JAGD;;EAGH,MAAM,UAAU,IAAI,UAAU;AAC5B,OAAI,CAAC,WAAY,QAAO;AAKxB,OACE,GAAG,WAAW,IAAI,IAClB,GAAG,WAAW,IAAI,IAClB,eAAe,KAAK,GAAG,IACvB,GAAG,WAAW,KAAK,IACnB,GAAG,WAAW,QAAQ,IACtB,GAAG,WAAW,WAAW,CAEzB,QAAO;AAST,OAAI,CAAC,gBAAgB,KAAK,GAAG,CAAE,QAAO;GAEtC,MAAM,MAAO,KACV;AAEH,UADiB,MAAM,WAAW,IAAI,UAAU,IAAI,IACjC;;EAEtB"}
1
+ {"version":3,"file":"css-extension-resolver.js","names":[],"sources":["../../../../src/lib/utils/css-extension-resolver.ts"],"sourcesContent":["import * as vite from 'vite';\n\ntype CssResolver = (\n id: string,\n importer: string | undefined,\n environment?: { name: string } | undefined,\n) => Promise<string | undefined>;\n\n/**\n * Resolves bare-specifier `.css` imports with the `style` package-export\n * condition in scope, without leaking `style` into Vite's global\n * `resolve.conditions`.\n *\n * Two real cases pull in opposite directions on this condition:\n *\n * 1. `import '@angular/material/prebuilt-themes/azure-blue.css'` from TS:\n * Material's prebuilt theme entries are gated *only* under the `style`\n * condition (no `default`, no `import`), so without `style` in scope\n * the request fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`.\n *\n * 2. `@plugin 'tailwindcss-primeui'` from a CSS file: Tailwind v4's JS\n * plugin resolver inherits Vite's global conditions. If `style` is\n * injected globally, that resolver matches the package's `style`\n * export (a `.css` file) and feeds it to Node's ESM loader, which\n * can't load `.css` and throws\n * `Internal server error: Unknown file extension \".css\"`.\n *\n * The fix: scope the `style` condition to requests that *look* like CSS\n * assets — bare specifiers ending in `.css` (with optional query suffix\n * for `?inline`, `?module`, etc.). Non-CSS bare specifiers fall through\n * to Vite's normal resolver chain, so packages with mixed exports\n * (`tailwindcss-primeui` exposes both `style` and `import`) resolve to\n * their JS surface.\n *\n * Vite 7 exposes `ResolvedConfig.createResolver(options)`; Vite 8 exposes\n * `vite.createIdResolver(config, options)`. Their resolver-call signatures\n * differ — this plugin normalizes both.\n */\nexport function cssExtensionStyleResolverPlugin(): vite.Plugin {\n let resolveCss: CssResolver | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular:css-style-resolver',\n enforce: 'pre',\n\n configResolved(config) {\n const styleResolveOptions = {\n ...config.resolve,\n conditions: [...(config.resolve.conditions ?? []), 'style'],\n };\n\n const createIdResolver = (\n vite as unknown as {\n createIdResolver?: (\n c: vite.ResolvedConfig,\n o: typeof styleResolveOptions,\n ) => (\n environment: { name: string },\n id: string,\n importer: string | undefined,\n ssr: boolean,\n ) => Promise<string | undefined>;\n }\n ).createIdResolver;\n\n if (typeof createIdResolver === 'function') {\n const r = createIdResolver(config, styleResolveOptions);\n resolveCss = async (id, importer, environment) => {\n return await r(\n environment ?? { name: 'client' },\n id,\n importer,\n false,\n );\n };\n return;\n }\n\n const legacyCreateResolver = (\n config as unknown as {\n createResolver?: (\n o: typeof styleResolveOptions,\n ) => (\n id: string,\n importer: string | undefined,\n aliasOnly: boolean,\n ssr: boolean,\n ) => Promise<string | undefined>;\n }\n ).createResolver;\n\n if (typeof legacyCreateResolver === 'function') {\n const r = legacyCreateResolver(styleResolveOptions);\n resolveCss = async (id, importer) => {\n return await r(id, importer, false, false);\n };\n return;\n }\n\n // Both APIs have been stable across the supported Vite range\n // (7.x via `ResolvedConfig.createResolver`, 8.x via\n // `vite.createIdResolver`). If neither is present, fail loudly\n // rather than silently regressing CSS imports of `style`-only\n // package exports such as `@angular/material/prebuilt-themes/*`.\n throw new Error(\n '[@analogjs/vite-plugin-angular]: neither vite.createIdResolver ' +\n '(Vite 8) nor ResolvedConfig.createResolver (Vite 7) is available. ' +\n 'Unsupported Vite version.',\n );\n },\n\n async resolveId(id, importer) {\n if (!resolveCss) return null;\n\n // Skip non-bare specifiers — relative, absolute, virtual, and\n // data-URI imports don't consult package exports, so the `style`\n // condition is irrelevant for them.\n if (\n id.startsWith('.') ||\n id.startsWith('/') ||\n /^[A-Za-z]:\\//.test(id) ||\n id.startsWith('\\0') ||\n id.startsWith('data:') ||\n id.startsWith('virtual:')\n ) {\n return null;\n }\n\n // Only fire on `.css` requests (with optional query, e.g. `?inline`,\n // `?module`). Non-CSS bare specifiers go through Vite's normal\n // resolver chain unchanged, which is critical for packages whose\n // exports include both `style` and `import`/`default` — e.g.\n // `tailwindcss-primeui`, where `@plugin` resolution must land on\n // the JS file, not the CSS file.\n if (!/\\.css(?:\\?|$)/.test(id)) return null;\n\n const env = (this as unknown as { environment?: { name: string } })\n .environment;\n const resolved = await resolveCss(id, importer, env);\n return resolved ?? null;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,kCAA+C;CAC7D,IAAI;CAEJ,OAAO;EACL,MAAM;EACN,SAAS;EAET,eAAe,QAAQ;GACrB,MAAM,sBAAsB;IAC1B,GAAG,OAAO;IACV,YAAY,CAAC,GAAI,OAAO,QAAQ,cAAc,CAAC,GAAI,OAAO;GAC5D;GAEA,MAAM,mBACJ,KAWA;GAEF,IAAI,OAAO,qBAAqB,YAAY;IAC1C,MAAM,IAAI,iBAAiB,QAAQ,mBAAmB;IACtD,aAAa,OAAO,IAAI,UAAU,gBAAgB;KAChD,OAAO,MAAM,EACX,eAAe,EAAE,MAAM,SAAS,GAChC,IACA,UACA,KACF;IACF;IACA;GACF;GAEA,MAAM,uBACJ,OAUA;GAEF,IAAI,OAAO,yBAAyB,YAAY;IAC9C,MAAM,IAAI,qBAAqB,mBAAmB;IAClD,aAAa,OAAO,IAAI,aAAa;KACnC,OAAO,MAAM,EAAE,IAAI,UAAU,OAAO,KAAK;IAC3C;IACA;GACF;GAOA,MAAM,IAAI,MACR,4JAGF;EACF;EAEA,MAAM,UAAU,IAAI,UAAU;GAC5B,IAAI,CAAC,YAAY,OAAO;GAKxB,IACE,GAAG,WAAW,GAAG,KACjB,GAAG,WAAW,GAAG,KACjB,eAAe,KAAK,EAAE,KACtB,GAAG,WAAW,IAAI,KAClB,GAAG,WAAW,OAAO,KACrB,GAAG,WAAW,UAAU,GAExB,OAAO;GAST,IAAI,CAAC,gBAAgB,KAAK,EAAE,GAAG,OAAO;GAEtC,MAAM,MAAO,KACV;GAEH,OAAO,MADgB,WAAW,IAAI,UAAU,GAAG,KAChC;EACrB;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"css-preprocessor-workers.js","names":[],"sources":["../../../../src/lib/utils/css-preprocessor-workers.ts"],"sourcesContent":["type ProcessHandle = {\n spawnfile?: string;\n spawnargs?: string[];\n stdin?: { unref?: () => void };\n stdout?: { unref?: () => void };\n stderr?: { unref?: () => void };\n stdio?: Array<{ unref?: () => void } | null | undefined>;\n unref?: () => void;\n};\n\nconst PREPROCESSOR_PROCESS_RE =\n /sass-embedded|dart-sass|sass\\.snapshot|[\\\\/]lessc(?:$|[\\s])|[\\\\/]stylus(?:$|[\\s])/i;\n\nfunction getActiveHandles(): ProcessHandle[] {\n const getHandles = (\n process as NodeJS.Process & { _getActiveHandles?: () => ProcessHandle[] }\n )._getActiveHandles;\n return typeof getHandles === 'function' ? getHandles.call(process) : [];\n}\n\nfunction isCssPreprocessorProcess(handle: ProcessHandle): boolean {\n const haystack = `${handle.spawnfile ?? ''} ${(handle.spawnargs ?? []).join(\n ' ',\n )}`;\n return PREPROCESSOR_PROCESS_RE.test(haystack);\n}\n\n/**\n * Vite's `preprocessCSS` may spawn a fallback Sass/Less/Stylus compiler\n * (`alwaysFakeWorkerWorkerControllerCache`) that is never closed. Unref those\n * child processes so a one-off `vite build` can return the shell.\n */\nexport function releaseCssPreprocessorWorkers(): void {\n for (const handle of getActiveHandles()) {\n if (!isCssPreprocessorProcess(handle)) {\n continue;\n }\n\n for (const stream of handle.stdio ?? []) {\n stream?.unref?.();\n }\n handle.stdin?.unref?.();\n handle.stdout?.unref?.();\n handle.stderr?.unref?.();\n handle.unref?.();\n }\n}\n"],"mappings":";AAUA,IAAM,0BACJ;AAEF,SAAS,mBAAoC;CAC3C,MAAM,aACJ,QACA;AACF,QAAO,OAAO,eAAe,aAAa,WAAW,KAAK,QAAQ,GAAG,EAAE;;AAGzE,SAAS,yBAAyB,QAAgC;CAChE,MAAM,WAAW,GAAG,OAAO,aAAa,GAAG,IAAI,OAAO,aAAa,EAAE,EAAE,KACrE,IACD;AACD,QAAO,wBAAwB,KAAK,SAAS;;;;;;;AAQ/C,SAAgB,gCAAsC;AACpD,MAAK,MAAM,UAAU,kBAAkB,EAAE;AACvC,MAAI,CAAC,yBAAyB,OAAO,CACnC;AAGF,OAAK,MAAM,UAAU,OAAO,SAAS,EAAE,CACrC,SAAQ,SAAS;AAEnB,SAAO,OAAO,SAAS;AACvB,SAAO,QAAQ,SAAS;AACxB,SAAO,QAAQ,SAAS;AACxB,SAAO,SAAS"}
1
+ {"version":3,"file":"css-preprocessor-workers.js","names":[],"sources":["../../../../src/lib/utils/css-preprocessor-workers.ts"],"sourcesContent":["type ProcessHandle = {\n spawnfile?: string;\n spawnargs?: string[];\n stdin?: { unref?: () => void };\n stdout?: { unref?: () => void };\n stderr?: { unref?: () => void };\n stdio?: Array<{ unref?: () => void } | null | undefined>;\n unref?: () => void;\n};\n\nconst PREPROCESSOR_PROCESS_RE =\n /sass-embedded|dart-sass|sass\\.snapshot|[\\\\/]lessc(?:$|[\\s])|[\\\\/]stylus(?:$|[\\s])/i;\n\nfunction getActiveHandles(): ProcessHandle[] {\n const getHandles = (\n process as NodeJS.Process & { _getActiveHandles?: () => ProcessHandle[] }\n )._getActiveHandles;\n return typeof getHandles === 'function' ? getHandles.call(process) : [];\n}\n\nfunction isCssPreprocessorProcess(handle: ProcessHandle): boolean {\n const haystack = `${handle.spawnfile ?? ''} ${(handle.spawnargs ?? []).join(\n ' ',\n )}`;\n return PREPROCESSOR_PROCESS_RE.test(haystack);\n}\n\n/**\n * Vite's `preprocessCSS` may spawn a fallback Sass/Less/Stylus compiler\n * (`alwaysFakeWorkerWorkerControllerCache`) that is never closed. Unref those\n * child processes so a one-off `vite build` can return the shell.\n */\nexport function releaseCssPreprocessorWorkers(): void {\n for (const handle of getActiveHandles()) {\n if (!isCssPreprocessorProcess(handle)) {\n continue;\n }\n\n for (const stream of handle.stdio ?? []) {\n stream?.unref?.();\n }\n handle.stdin?.unref?.();\n handle.stdout?.unref?.();\n handle.stderr?.unref?.();\n handle.unref?.();\n }\n}\n"],"mappings":";AAUA,IAAM,0BACJ;AAEF,SAAS,mBAAoC;CAC3C,MAAM,aACJ,QACA;CACF,OAAO,OAAO,eAAe,aAAa,WAAW,KAAK,OAAO,IAAI,CAAC;AACxE;AAEA,SAAS,yBAAyB,QAAgC;CAChE,MAAM,WAAW,GAAG,OAAO,aAAa,GAAG,IAAI,OAAO,aAAa,CAAC,EAAA,CAAG,KACrE,GACF;CACA,OAAO,wBAAwB,KAAK,QAAQ;AAC9C;;;;;;AAOA,SAAgB,gCAAsC;CACpD,KAAK,MAAM,UAAU,iBAAiB,GAAG;EACvC,IAAI,CAAC,yBAAyB,MAAM,GAClC;EAGF,KAAK,MAAM,UAAU,OAAO,SAAS,CAAC,GACpC,QAAQ,QAAQ;EAElB,OAAO,OAAO,QAAQ;EACtB,OAAO,QAAQ,QAAQ;EACvB,OAAO,QAAQ,QAAQ;EACvB,OAAO,QAAQ;CACjB;AACF"}
@@ -1 +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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,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"}
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;CACf,IAAI,WAAW,QAAQ,WAAW,KAAA,GAAW,OAAO;CACpD,IAAI,MAAM,QAAQ,MAAM,KAAK,OAAO,QAAQ,OAAO,OAAO,KAAK,GAAG;CAClE,OAAO;AACT;AAEA,SAAS,eACP,OACoC;CACpC,IAAI,OAAO,UAAU,WAAW,OAAO;CACvC,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,IAAI,MAAM,WAAW,KAAK,OAAO,MAAM,OAAO,UAAU,OAAO;EAE/D,OADe,MAA6B,MAAM,MAAM,CAAC,CAAC,EAAE,OAC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W,OAAO,OAAO,mBAAmB,SAAS,IAAI;EAC3D;EAEA,sBAAsB,SAAkC;GACtD,IAAI,aAAa,WAAW,GAAG;GAE/B,MAAM,cAAc,YAAY,UAAU,QAAQ;GAElD,KAAK,MAAM,EAAE,OAAO,SAAS,UAAU,cACrC,IAAI,MAAM,SAAS,aAAa;IAC9B,MAAM,KAAK,kBACT,MAAM,UAAU,MAChB,OAAO,iBACT;IACA,IAAI,IAAI,OAAO,EAAE;IACjB,IAAI,SAAS,oBAAoB,SAAS,IAAI;GAChD;GAGF,eAAe,CAAC;EAClB;EAEA,sBAA4B;GAC1B,eAAe,CAAC;EAClB;CACF;AACF"}
@@ -31,7 +31,8 @@ function wrapLog(dbg, filePath) {
31
31
  dbg.log = function(...args) {
32
32
  originalLog.apply(this, args);
33
33
  try {
34
- appendFileSync(filePath, format(...args).replace(ANSI_RE, "") + "\n", "utf-8");
34
+ const line = format(...args).replace(ANSI_RE, "") + "\n";
35
+ appendFileSync(filePath, line, "utf-8");
35
36
  } catch {}
36
37
  };
37
38
  rec[WRAPPED_KEY] = filePath;
@@ -1 +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
+ {"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,IAAY;CACvE,EAAE,iBAAiB;CACnB,IAAI,UAAU,IAAI,QAAQ,GAAG;CAC7B,IAAI;EACF,UAAU,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;EAChD,cAAc,UAAU,IAAI,OAAO;CACrC,QAAQ,CAER;CACA,UAAU,IAAI,QAAQ;AACxB;AAEA,SAAS,QAAQ,KAAe,UAAwB;CACtD,MAAM,MAAM;CACZ,IAAI,IAAI,iBAAiB,UAAU;CAEnC,MAAM,cACJ,IAAI,gBAAgB,IAAI,yBACnB,IAAI,yBACL,IAAI;CAEV,IAAI,yBAAyB;CAC7B,IAAI,MAAM,SAA0B,GAAG,MAAiB;EACtD,YAAY,MAAM,MAAM,IAAI;EAC5B,IAAI;GACF,MAAM,OAAO,OAAO,GAAG,IAAI,CAAC,CAAC,QAAQ,SAAS,EAAE,IAAI;GACpD,eAAe,UAAU,MAAM,OAAO;EACxC,QAAQ,CAER;CACF;CACA,IAAI,eAAe;AACrB;AAEA,SAAgB,wBACd,WACA,UACM;CACN,gBAAgB,QAAQ;CACxB,KAAK,MAAM,OAAO,WAChB,QAAQ,KAAK,QAAQ;AAEzB;AAEA,SAAS,gBAAgB,WAA2B;CAClD,OAAO,UAAU,QAAQ,MAAM,GAAG,IAAI;AACxC;AAEA,SAAgB,8BACd,WACA,SACM;CACN,KAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,aAAa,KAAK,SAAS,gBAAgB,IAAI,SAAS,CAAC;EAC/D,gBAAgB,UAAU;EAC1B,QAAQ,KAAK,UAAU;CACzB;AACF"}
@@ -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 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 debugEmit = createDebug('analog:angular:emit');\nexport const debugStylePipeline = createDebug('analog:angular:style-pipeline');\n\n// Verbose — per-file detail, enable with :v suffix or parent:*\nexport const debugHmrV = createDebug('analog:angular:hmr:v');\nexport const debugStylesV = createDebug('analog:angular:styles:v');\nexport const debugCompilerV = createDebug('analog:angular:compiler:v');\nexport const debugEmitV = createDebug('analog:angular:emit:v');\n\nconst angularDebugInstances = [\n debugHmr,\n debugStyles,\n debugCompiler,\n debugCompilationApi,\n debugEmit,\n debugStylePipeline,\n debugHmrV,\n debugStylesV,\n debugCompilerV,\n debugEmitV,\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:emit'\n | 'analog:angular:emit:v'\n | 'analog:angular:style-pipeline'\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,WAAW,YAAY,qBAAqB;AACzD,IAAa,cAAc,YAAY,wBAAwB;AAC/D,IAAa,gBAAgB,YAAY,0BAA0B;AACnE,IAAa,sBAAsB,YACjC,iCACD;AACD,IAAa,YAAY,YAAY,sBAAsB;AAC3D,IAAa,qBAAqB,YAAY,gCAAgC;AAG9E,IAAa,YAAY,YAAY,uBAAuB;AAC5D,IAAa,eAAe,YAAY,0BAA0B;AAClE,IAAa,iBAAiB,YAAY,4BAA4B;AACtE,IAAa,aAAa,YAAY,wBAAwB;AAgD9D,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"}
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 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 debugEmit = createDebug('analog:angular:emit');\nexport const debugStylePipeline = createDebug('analog:angular:style-pipeline');\n\n// Verbose — per-file detail, enable with :v suffix or parent:*\nexport const debugHmrV = createDebug('analog:angular:hmr:v');\nexport const debugStylesV = createDebug('analog:angular:styles:v');\nexport const debugCompilerV = createDebug('analog:angular:compiler:v');\nexport const debugEmitV = createDebug('analog:angular:emit:v');\n\nconst angularDebugInstances = [\n debugHmr,\n debugStyles,\n debugCompiler,\n debugCompilationApi,\n debugEmit,\n debugStylePipeline,\n debugHmrV,\n debugStylesV,\n debugCompilerV,\n debugEmitV,\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:emit'\n | 'analog:angular:emit:v'\n | 'analog:angular:style-pipeline'\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,WAAW,YAAY,oBAAoB;AACxD,IAAa,cAAc,YAAY,uBAAuB;AAC9D,IAAa,gBAAgB,YAAY,yBAAyB;AAClE,IAAa,sBAAsB,YACjC,gCACF;AACA,IAAa,YAAY,YAAY,qBAAqB;AAC1D,IAAa,qBAAqB,YAAY,+BAA+B;AAG7E,IAAa,YAAY,YAAY,sBAAsB;AAC3D,IAAa,eAAe,YAAY,yBAAyB;AACjE,IAAa,iBAAiB,YAAY,2BAA2B;AACrE,IAAa,aAAa,YAAY,uBAAuB;AAgD7D,IAAM,UAAU,mBAAmB;CACjC,mBAAmB;CACnB,gBAAgB,CAAC;EA/CjB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAsCiB,CAAqB;AACxC,CAAC;AAED,IAAa,mBAGD,QAAQ;AACpB,IAAa,wBACX,QAAQ;AACqC,QAAQ"}
@@ -52,6 +52,6 @@ var JavaScriptTransformer = class extends AngularJavaScriptTransformerClass {
52
52
  }
53
53
  };
54
54
  //#endregion
55
- export { JavaScriptTransformer, SourceFileCache, angularFullVersion, createAngularCompilation, createJitResourceTransformer };
55
+ export { JavaScriptTransformer, SourceFileCache, angularFullVersion, angularMajor, angularMinor, angularPatch, createAngularCompilation, createJitResourceTransformer };
56
56
 
57
57
  //# sourceMappingURL=devkit.js.map
@@ -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 { dirname, join } from 'node:path';\nimport type { JavaScriptTransformer as AngularJavaScriptTransformer } from '@angular/build/private';\nimport type { CompilerPluginOptions } from './compiler-plugin-options.js';\nimport type { TransformCacheStore } from './transform-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);\nconst usesTransformOptions = angularFullVersion >= 220200;\nlet initializeHash: (() => Promise<void>) | undefined;\n\nif (angularMajor < 20) {\n throw new Error('AnalogJS is not compatible with Angular v19 and lower');\n}\n\nconst {\n createJitResourceTransformer,\n JavaScriptTransformer: AngularJavaScriptTransformerClass,\n SourceFileCache,\n createAngularCompilation: createAngularCompilationFn,\n} = require('@angular/build/private');\n\n// `@angular/build` exports `createAngularCompilation` from v20.2.\nconst createAngularCompilation =\n createAngularCompilationFn &&\n (async (...args: unknown[]) => {\n await initializeHash?.();\n return createAngularCompilationFn(...args);\n });\n\nif (usesTransformOptions) {\n ({ initializeHash } = require(\n join(\n dirname(require.resolve('@angular/build/package.json')),\n 'src/utils/hash.js',\n ),\n ));\n}\n\n// Keep Angular's private transformer API differences at the compatibility boundary.\nclass JavaScriptTransformer extends AngularJavaScriptTransformerClass {\n constructor(\n options: Partial<\n ConstructorParameters<typeof AngularJavaScriptTransformer>[0]\n >,\n maxThreads: number,\n cache?: TransformCacheStore,\n ) {\n if (usesTransformOptions) {\n super({ ...options, maxConcurrency: maxThreads }, cache);\n } else {\n super(options, maxThreads, cache);\n }\n }\n\n async transformFile(\n filename: string,\n skipLinker?: boolean,\n sideEffects?: boolean,\n instrumentForCoverage?: boolean,\n ): Promise<Uint8Array> {\n if (usesTransformOptions) {\n await initializeHash!();\n return super.transformFile(filename, {\n skipLinker,\n sideEffects:\n sideEffects === undefined ? undefined : async () => sideEffects,\n instrumentForCoverage,\n });\n }\n return super.transformFile(\n filename,\n skipLinker,\n sideEffects,\n instrumentForCoverage,\n );\n }\n\n async transformData(\n filename: string,\n data: string,\n skipLinker: boolean,\n sideEffects?: boolean,\n instrumentForCoverage?: boolean,\n ): Promise<Uint8Array> {\n if (usesTransformOptions) {\n await initializeHash!();\n return super.transformData(filename, data, {\n skipLinker,\n sideEffects:\n sideEffects === undefined ? undefined : async () => sideEffects,\n instrumentForCoverage,\n });\n }\n return super.transformData(\n filename,\n data,\n skipLinker,\n sideEffects,\n instrumentForCoverage,\n );\n }\n\n close(): Promise<void> {\n return super.close();\n }\n}\n\nexport {\n createJitResourceTransformer,\n JavaScriptTransformer,\n SourceFileCache,\n CompilerPluginOptions,\n angularMajor,\n angularMinor,\n angularPatch,\n createAngularCompilation,\n angularFullVersion,\n};\n"],"mappings":";;;;AAOA,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,IAAM,uBAAuB,sBAAsB;AACnD,IAAI;AAEJ,IAAI,eAAe,GACjB,OAAM,IAAI,MAAM,wDAAwD;AAG1E,IAAM,EACJ,8BACA,uBAAuB,mCACvB,iBACA,0BAA0B,+BACxB,QAAQ,yBAAyB;AAGrC,IAAM,2BACJ,+BACC,OAAO,GAAG,SAAoB;AAC7B,OAAM,kBAAkB;AACxB,QAAO,2BAA2B,GAAG,KAAK;;AAG9C,IAAI,qBACF,EAAC,CAAE,kBAAmB,QACpB,KACE,QAAQ,QAAQ,QAAQ,8BAA8B,CAAC,EACvD,oBACD,CACF;AAIH,IAAM,wBAAN,cAAoC,kCAAkC;CACpE,YACE,SAGA,YACA,OACA;AACA,MAAI,qBACF,OAAM;GAAE,GAAG;GAAS,gBAAgB;GAAY,EAAE,MAAM;MAExD,OAAM,SAAS,YAAY,MAAM;;CAIrC,MAAM,cACJ,UACA,YACA,aACA,uBACqB;AACrB,MAAI,sBAAsB;AACxB,SAAM,gBAAiB;AACvB,UAAO,MAAM,cAAc,UAAU;IACnC;IACA,aACE,gBAAgB,KAAA,IAAY,KAAA,IAAY,YAAY;IACtD;IACD,CAAC;;AAEJ,SAAO,MAAM,cACX,UACA,YACA,aACA,sBACD;;CAGH,MAAM,cACJ,UACA,MACA,YACA,aACA,uBACqB;AACrB,MAAI,sBAAsB;AACxB,SAAM,gBAAiB;AACvB,UAAO,MAAM,cAAc,UAAU,MAAM;IACzC;IACA,aACE,gBAAgB,KAAA,IAAY,KAAA,IAAY,YAAY;IACtD;IACD,CAAC;;AAEJ,SAAO,MAAM,cACX,UACA,MACA,YACA,aACA,sBACD;;CAGH,QAAuB;AACrB,SAAO,MAAM,OAAO"}
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 { dirname, join } from 'node:path';\nimport type { JavaScriptTransformer as AngularJavaScriptTransformer } from '@angular/build/private';\nimport type { CompilerPluginOptions } from './compiler-plugin-options.js';\nimport type { TransformCacheStore } from './transform-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);\nconst usesTransformOptions = angularFullVersion >= 220200;\nlet initializeHash: (() => Promise<void>) | undefined;\n\nif (angularMajor < 20) {\n throw new Error('AnalogJS is not compatible with Angular v19 and lower');\n}\n\nconst {\n createJitResourceTransformer,\n JavaScriptTransformer: AngularJavaScriptTransformerClass,\n SourceFileCache,\n createAngularCompilation: createAngularCompilationFn,\n} = require('@angular/build/private');\n\n// `@angular/build` exports `createAngularCompilation` from v20.2.\nconst createAngularCompilation =\n createAngularCompilationFn &&\n (async (...args: unknown[]) => {\n await initializeHash?.();\n return createAngularCompilationFn(...args);\n });\n\nif (usesTransformOptions) {\n ({ initializeHash } = require(\n join(\n dirname(require.resolve('@angular/build/package.json')),\n 'src/utils/hash.js',\n ),\n ));\n}\n\n// Keep Angular's private transformer API differences at the compatibility boundary.\nclass JavaScriptTransformer extends AngularJavaScriptTransformerClass {\n constructor(\n options: Partial<\n ConstructorParameters<typeof AngularJavaScriptTransformer>[0]\n >,\n maxThreads: number,\n cache?: TransformCacheStore,\n ) {\n if (usesTransformOptions) {\n super({ ...options, maxConcurrency: maxThreads }, cache);\n } else {\n super(options, maxThreads, cache);\n }\n }\n\n async transformFile(\n filename: string,\n skipLinker?: boolean,\n sideEffects?: boolean,\n instrumentForCoverage?: boolean,\n ): Promise<Uint8Array> {\n if (usesTransformOptions) {\n await initializeHash!();\n return super.transformFile(filename, {\n skipLinker,\n sideEffects:\n sideEffects === undefined ? undefined : async () => sideEffects,\n instrumentForCoverage,\n });\n }\n return super.transformFile(\n filename,\n skipLinker,\n sideEffects,\n instrumentForCoverage,\n );\n }\n\n async transformData(\n filename: string,\n data: string,\n skipLinker: boolean,\n sideEffects?: boolean,\n instrumentForCoverage?: boolean,\n ): Promise<Uint8Array> {\n if (usesTransformOptions) {\n await initializeHash!();\n return super.transformData(filename, data, {\n skipLinker,\n sideEffects:\n sideEffects === undefined ? undefined : async () => sideEffects,\n instrumentForCoverage,\n });\n }\n return super.transformData(\n filename,\n data,\n skipLinker,\n sideEffects,\n instrumentForCoverage,\n );\n }\n\n close(): Promise<void> {\n return super.close();\n }\n}\n\nexport {\n createJitResourceTransformer,\n JavaScriptTransformer,\n SourceFileCache,\n CompilerPluginOptions,\n angularMajor,\n angularMinor,\n angularPatch,\n createAngularCompilation,\n angularFullVersion,\n};\n"],"mappings":";;;;AAOA,IAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,IAAM,eAAe,OAAO,QAAQ,KAAK;AACzC,IAAM,eAAe,OAAO,QAAQ,KAAK;AACzC,IAAM,eAAe,OAAO,QAAQ,KAAK;AACzC,IAAM,cAAc,YAAoB,OAAO,OAAO,CAAC,CAAC,SAAS,GAAG,GAAG;AACvE,IAAM,qBAAqB,OACzB,GAAG,eAAe,WAAW,YAAY,IAAI,WAAW,YAAY,GACtE;AACA,IAAM,uBAAuB,sBAAsB;AACnD,IAAI;AAEJ,IAAI,eAAe,IACjB,MAAM,IAAI,MAAM,uDAAuD;AAGzE,IAAM,EACJ,8BACA,uBAAuB,mCACvB,iBACA,0BAA0B,+BACxB,QAAQ,wBAAwB;AAGpC,IAAM,2BACJ,+BACC,OAAO,GAAG,SAAoB;CAC7B,MAAM,iBAAiB;CACvB,OAAO,2BAA2B,GAAG,IAAI;AAC3C;AAEF,IAAI,sBACF,CAAC,CAAE,kBAAmB,QACpB,KACE,QAAQ,QAAQ,QAAQ,6BAA6B,CAAC,GACtD,mBACF,CACF;AAIF,IAAM,wBAAN,cAAoC,kCAAkC;CACpE,YACE,SAGA,YACA,OACA;EACA,IAAI,sBACF,MAAM;GAAE,GAAG;GAAS,gBAAgB;EAAW,GAAG,KAAK;OAEvD,MAAM,SAAS,YAAY,KAAK;CAEpC;CAEA,MAAM,cACJ,UACA,YACA,aACA,uBACqB;EACrB,IAAI,sBAAsB;GACxB,MAAM,eAAgB;GACtB,OAAO,MAAM,cAAc,UAAU;IACnC;IACA,aACE,gBAAgB,KAAA,IAAY,KAAA,IAAY,YAAY;IACtD;GACF,CAAC;EACH;EACA,OAAO,MAAM,cACX,UACA,YACA,aACA,qBACF;CACF;CAEA,MAAM,cACJ,UACA,MACA,YACA,aACA,uBACqB;EACrB,IAAI,sBAAsB;GACxB,MAAM,eAAgB;GACtB,OAAO,MAAM,cAAc,UAAU,MAAM;IACzC;IACA,aACE,gBAAgB,KAAA,IAAY,KAAA,IAAY,YAAY;IACtD;GACF,CAAC;EACH;EACA,OAAO,MAAM,cACX,UACA,MACA,YACA,aACA,qBACF;CACF;CAEA,QAAuB;EACrB,OAAO,MAAM,MAAM;CACrB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"jit-inline-styles.js","names":[],"sources":["../../../../src/lib/utils/jit-inline-styles.ts"],"sourcesContent":["// Angular's JIT resource transformer emits inline component styles as\n// `angular:jit:style:inline;<base64 of the whole stylesheet>`. Keeping that\n// payload in the module id makes the emitted chunk name grow with the\n// stylesheet, so a large inline style blows past the 255-byte filename\n// limit and the build fails with ENAMETOOLONG. Hash the payload into the\n// id and keep the base64 in a lookup table instead. (#2459)\n\nimport { createHash } from 'node:crypto';\n\nexport const JIT_INLINE_STYLE_PREFIX = 'virtual:angular:jit:style:inline;';\n\nconst inlineStyles = new Map<string, string>();\n\nexport function toJitInlineStyleId(\n encodedStyles: string,\n isTest: boolean,\n): string {\n if (isTest) {\n return `${JIT_INLINE_STYLE_PREFIX}${encodedStyles}`;\n }\n\n const hash = hashJitInlineStyles(encodedStyles);\n inlineStyles.set(hash, encodedStyles);\n return `${JIT_INLINE_STYLE_PREFIX}${hash}`;\n}\n\nexport function getJitInlineStyles(idSuffix: string): string {\n return inlineStyles.get(idSuffix) ?? idSuffix;\n}\n\nexport function hashJitInlineStyles(encodedStyles: string): string {\n return createHash('sha256').update(encodedStyles).digest('hex').slice(0, 16);\n}\n"],"mappings":";;AASA,IAAa,0BAA0B;AAEvC,IAAM,+BAAe,IAAI,KAAqB;AAE9C,SAAgB,mBACd,eACA,QACQ;AACR,KAAI,OACF,QAAO,GAAG,0BAA0B;CAGtC,MAAM,OAAO,oBAAoB,cAAc;AAC/C,cAAa,IAAI,MAAM,cAAc;AACrC,QAAO,GAAG,0BAA0B;;AAGtC,SAAgB,mBAAmB,UAA0B;AAC3D,QAAO,aAAa,IAAI,SAAS,IAAI;;AAGvC,SAAgB,oBAAoB,eAA+B;AACjE,QAAO,WAAW,SAAS,CAAC,OAAO,cAAc,CAAC,OAAO,MAAM,CAAC,MAAM,GAAG,GAAG"}
1
+ {"version":3,"file":"jit-inline-styles.js","names":[],"sources":["../../../../src/lib/utils/jit-inline-styles.ts"],"sourcesContent":["// Angular's JIT resource transformer emits inline component styles as\n// `angular:jit:style:inline;<base64 of the whole stylesheet>`. Keeping that\n// payload in the module id makes the emitted chunk name grow with the\n// stylesheet, so a large inline style blows past the 255-byte filename\n// limit and the build fails with ENAMETOOLONG. Hash the payload into the\n// id and keep the base64 in a lookup table instead. (#2459)\n\nimport { createHash } from 'node:crypto';\n\nexport const JIT_INLINE_STYLE_PREFIX = 'virtual:angular:jit:style:inline;';\n\nconst inlineStyles = new Map<string, string>();\n\nexport function toJitInlineStyleId(\n encodedStyles: string,\n isTest: boolean,\n): string {\n if (isTest) {\n return `${JIT_INLINE_STYLE_PREFIX}${encodedStyles}`;\n }\n\n const hash = hashJitInlineStyles(encodedStyles);\n inlineStyles.set(hash, encodedStyles);\n return `${JIT_INLINE_STYLE_PREFIX}${hash}`;\n}\n\nexport function getJitInlineStyles(idSuffix: string): string {\n return inlineStyles.get(idSuffix) ?? idSuffix;\n}\n\nexport function hashJitInlineStyles(encodedStyles: string): string {\n return createHash('sha256').update(encodedStyles).digest('hex').slice(0, 16);\n}\n"],"mappings":";;AASA,IAAa,0BAA0B;AAEvC,IAAM,+BAAe,IAAI,IAAoB;AAE7C,SAAgB,mBACd,eACA,QACQ;CACR,IAAI,QACF,OAAO,GAAG,0BAA0B;CAGtC,MAAM,OAAO,oBAAoB,aAAa;CAC9C,aAAa,IAAI,MAAM,aAAa;CACpC,OAAO,GAAG,0BAA0B;AACtC;AAEA,SAAgB,mBAAmB,UAA0B;CAC3D,OAAO,aAAa,IAAI,QAAQ,KAAK;AACvC;AAEA,SAAgB,oBAAoB,eAA+B;CACjE,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,aAAa,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;AAC7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-config.js","names":[],"sources":["../../../../src/lib/utils/plugin-config.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport * as vite from 'vite';\n\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n createPersistentTransformCache,\n resolveTransformCacheDir,\n} from './transform-cache.js';\n\n/**\n * TypeScript file extension regex\n * Match .ts / .cts / .mts extensions with an optional ?query suffix.\n * Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via\n * a negative-lookahead on a following ASCII letter, so only genuine TS\n * files pass.\n *\n * Previous form `/\\.[cm]?(ts)[^x]?\\??/` was intended to exclude `.tsx`\n * specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows\n * zero characters, and any non-`x` letter was admitted — so `.tsrx`\n * and similar extensions matched by accident.\n */\nexport const TS_EXT_REGEX = /\\.[cm]?ts(?![a-z])/;\n\n// Spec files stay included — a newly added spec must join the program's\n// root names in Vitest watch mode.\nexport const EXCLUDED_TS_EXT_REGEX = /\\.d\\.[cm]?ts$/;\n\n/**\n * Resolves whether Angular should be compiled for production. An explicit\n * `development` mode wins over an ambient production `NODE_ENV` (e.g. set by\n * `storybook build` at CLI entry), so a build can opt into Angular's\n * development compilation. See #2458 and #2462.\n */\nexport function isProdMode(mode: string | undefined): boolean {\n if (mode === 'development') {\n return false;\n }\n\n return mode === 'production' || process.env['NODE_ENV'] === 'production';\n}\n\nexport interface TsConfigResolutionContext {\n root: string;\n isProd: boolean;\n isLib: boolean;\n}\n\nexport function getTsConfigPath(\n root: string,\n tsconfig: string,\n isProd: boolean,\n isTest: boolean,\n isLib: boolean,\n workspaceRoot?: string,\n) {\n if (tsconfig && isAbsolute(tsconfig)) {\n if (!existsSync(tsconfig)) {\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n }\n\n return tsconfig;\n }\n\n let tsconfigFilePath = './tsconfig.app.json';\n\n if (isLib) {\n tsconfigFilePath = isProd\n ? './tsconfig.lib.prod.json'\n : './tsconfig.lib.json';\n }\n\n if (isTest) {\n tsconfigFilePath = './tsconfig.spec.json';\n }\n\n if (tsconfig) {\n tsconfigFilePath = tsconfig;\n }\n\n const resolvedPath = resolve(root, tsconfigFilePath);\n\n if (existsSync(resolvedPath)) {\n return resolvedPath;\n }\n\n // Callers such as Storybook's Angular builder document their `tsConfig` as\n // workspace-relative while setting the Vite root to the project directory,\n // so the path joins onto the project root twice. Fall back to the workspace\n // root before failing.\n const workspacePath = workspaceRoot\n ? resolve(workspaceRoot, tsconfigFilePath)\n : undefined;\n\n if (workspacePath && existsSync(workspacePath)) {\n return workspacePath;\n }\n\n const attemptedPaths =\n workspacePath && workspacePath !== resolvedPath\n ? `${resolvedPath} or ${workspacePath}`\n : resolvedPath;\n\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${attemptedPaths}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n\n return resolvedPath;\n}\n\nexport function createTsConfigGetter(\n tsconfigOrGetter?: string | (() => string),\n) {\n if (typeof tsconfigOrGetter === 'function') {\n return tsconfigOrGetter;\n }\n\n return () => tsconfigOrGetter || '';\n}\n\nexport interface DepOptimizerOptions {\n tsconfig: string;\n isProd: boolean;\n jit: boolean;\n watchMode: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n}\n\nexport function createDepOptimizerConfig(opts: DepOptimizerOptions) {\n const defineOptions = {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ...(opts.watchMode ? {} : { ngDevMode: 'false' }),\n };\n\n // Persist linked dependency output across dep-optimizer runs. The\n // transformer's own key covers file bytes + options, and the directory\n // is namespaced by Angular version, so entries never go stale.\n const transformCacheDir = resolveTransformCacheDir(dirname(opts.tsconfig));\n const transformCache = transformCacheDir\n ? createPersistentTransformCache(transformCacheDir)\n : undefined;\n\n const rolldownOptions: vite.DepOptimizationOptions['rolldownOptions'] = {\n plugins: [\n createRolldownCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n };\n\n const esbuildOptions: vite.DepOptimizationOptions['esbuildOptions'] = {\n plugins: [\n createCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n define: defineOptions,\n };\n\n // No top-level `resolve` block: the `style` package-export condition\n // is now scoped to `.css`-extension requests via\n // `cssExtensionStyleResolverPlugin`, so this dep optimizer config no\n // longer needs to leak it into Vite's global `resolve.conditions`.\n return {\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs'],\n exclude: ['@angular/platform-server'],\n ...(vite.rolldownVers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uBAAuB,KAAK;EAC5B,KAAK,KAAK;EACV,aAAa,KAAK;EACnB,EACD,KAAK,QACL,CAAC,KAAK,oBACN,eACD,CACF,EACF;CAED,MAAM,iBAAgE;EACpE,SAAS,CACP,qBACE;GACE,UAAU,KAAK;GACf,WAAW,CAAC,KAAK;GACjB,uBAAuB,KAAK;GAC5B,KAAK,KAAK;GACV,aAAa,KAAK;GACnB,EACD,KAAK,QACL,CAAC,KAAK,oBACN,eACD,CACF;EACD,QAAQ;EACT;AAMD,QAAO,EACL,cAAc;EACZ,SAAS,CAAC,kBAAkB,OAAO;EACnC,SAAS,CAAC,2BAA2B;EACrC,GAAI,KAAK,kBAAkB,EAAE,iBAAiB,GAAG,EAAE,gBAAgB;EACpE,EACF"}
1
+ {"version":3,"file":"plugin-config.js","names":[],"sources":["../../../../src/lib/utils/plugin-config.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport * as vite from 'vite';\n\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n createPersistentTransformCache,\n resolveTransformCacheDir,\n} from './transform-cache.js';\n\n/**\n * TypeScript file extension regex\n * Match .ts / .cts / .mts extensions with an optional ?query suffix.\n * Reject .tsx — and any other `.ts<letter>…` extension like .tsrx — via\n * a negative-lookahead on a following ASCII letter, so only genuine TS\n * files pass.\n *\n * Previous form `/\\.[cm]?(ts)[^x]?\\??/` was intended to exclude `.tsx`\n * specifically (`[^x]?` = not-an-x), but the `?` quantifier also allows\n * zero characters, and any non-`x` letter was admitted — so `.tsrx`\n * and similar extensions matched by accident.\n */\nexport const TS_EXT_REGEX = /\\.[cm]?ts(?![a-z])/;\n\n// Spec files stay included — a newly added spec must join the program's\n// root names in Vitest watch mode.\nexport const EXCLUDED_TS_EXT_REGEX = /\\.d\\.[cm]?ts$/;\n\n/**\n * Resolves whether Angular should be compiled for production. An explicit\n * `development` mode wins over an ambient production `NODE_ENV` (e.g. set by\n * `storybook build` at CLI entry), so a build can opt into Angular's\n * development compilation. See #2458 and #2462.\n */\nexport function isProdMode(mode: string | undefined): boolean {\n if (mode === 'development') {\n return false;\n }\n\n return mode === 'production' || process.env['NODE_ENV'] === 'production';\n}\n\nexport interface TsConfigResolutionContext {\n root: string;\n isProd: boolean;\n isLib: boolean;\n}\n\nexport function getTsConfigPath(\n root: string,\n tsconfig: string,\n isProd: boolean,\n isTest: boolean,\n isLib: boolean,\n workspaceRoot?: string,\n) {\n if (tsconfig && isAbsolute(tsconfig)) {\n if (!existsSync(tsconfig)) {\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${tsconfig}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n }\n\n return tsconfig;\n }\n\n let tsconfigFilePath = './tsconfig.app.json';\n\n if (isLib) {\n tsconfigFilePath = isProd\n ? './tsconfig.lib.prod.json'\n : './tsconfig.lib.json';\n }\n\n if (isTest) {\n tsconfigFilePath = './tsconfig.spec.json';\n }\n\n if (tsconfig) {\n tsconfigFilePath = tsconfig;\n }\n\n const resolvedPath = resolve(root, tsconfigFilePath);\n\n if (existsSync(resolvedPath)) {\n return resolvedPath;\n }\n\n // Callers such as Storybook's Angular builder document their `tsConfig` as\n // workspace-relative while setting the Vite root to the project directory,\n // so the path joins onto the project root twice. Fall back to the workspace\n // root before failing.\n const workspacePath = workspaceRoot\n ? resolve(workspaceRoot, tsconfigFilePath)\n : undefined;\n\n if (workspacePath && existsSync(workspacePath)) {\n return workspacePath;\n }\n\n const attemptedPaths =\n workspacePath && workspacePath !== resolvedPath\n ? `${resolvedPath} or ${workspacePath}`\n : resolvedPath;\n\n console.error(\n `[@analogjs/vite-plugin-angular]: Unable to resolve tsconfig at ${attemptedPaths}. This causes compilation issues. Check the path or set the \"tsconfig\" property with an absolute path.`,\n );\n\n return resolvedPath;\n}\n\nexport function createTsConfigGetter(\n tsconfigOrGetter?: string | (() => string),\n) {\n if (typeof tsconfigOrGetter === 'function') {\n return tsconfigOrGetter;\n }\n\n return () => tsconfigOrGetter || '';\n}\n\nexport interface DepOptimizerOptions {\n tsconfig: string;\n isProd: boolean;\n jit: boolean;\n watchMode: boolean;\n isTest: boolean;\n isAstroIntegration: boolean;\n}\n\nexport function createDepOptimizerConfig(opts: DepOptimizerOptions) {\n const defineOptions = {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ...(opts.watchMode ? {} : { ngDevMode: 'false' }),\n };\n\n // Persist linked dependency output across dep-optimizer runs. The\n // transformer's own key covers file bytes + options, and the directory\n // is namespaced by Angular version, so entries never go stale.\n const transformCacheDir = resolveTransformCacheDir(dirname(opts.tsconfig));\n const transformCache = transformCacheDir\n ? createPersistentTransformCache(transformCacheDir)\n : undefined;\n\n const rolldownOptions: vite.DepOptimizationOptions['rolldownOptions'] = {\n plugins: [\n createRolldownCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n };\n\n const esbuildOptions: vite.DepOptimizationOptions['esbuildOptions'] = {\n plugins: [\n createCompilerPlugin(\n {\n tsconfig: opts.tsconfig,\n sourcemap: !opts.isProd,\n advancedOptimizations: opts.isProd,\n jit: opts.jit,\n incremental: opts.watchMode,\n },\n opts.isTest,\n !opts.isAstroIntegration,\n transformCache,\n ),\n ],\n define: defineOptions,\n };\n\n // No top-level `resolve` block: the `style` package-export condition\n // is now scoped to `.css`-extension requests via\n // `cssExtensionStyleResolverPlugin`, so this dep optimizer config no\n // longer needs to leak it into Vite's global `resolve.conditions`.\n return {\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs'],\n exclude: ['@angular/platform-server'],\n ...(vite.rolldownVersion ? { rolldownOptions } : { esbuildOptions }),\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,IAAa,eAAe;AA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AAC,KAAK,oBACN,cACF,CACF,EACF;CAEA,MAAM,iBAAgE;EACpE,SAAS,CACP,qBACE;GACE,UAAU,KAAK;GACf,WAAW,CAAC,KAAK;GACjB,uBAAuB,KAAK;GAC5B,KAAK,KAAK;GACV,aAAa,KAAK;EACpB,GACA,KAAK,QACL,CAAC,KAAK,oBACN,cACF,CACF;EACA,QAAQ;CACV;CAMA,OAAO,EACL,cAAc;EACZ,SAAS,CAAC,kBAAkB,MAAM;EAClC,SAAS,CAAC,0BAA0B;EACpC,GAAI,KAAK,kBAAkB,EAAE,gBAAgB,IAAI,EAAE,eAAe;CACpE,EACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"rolldown.js","names":[],"sources":["../../../../src/lib/utils/rolldown.ts"],"sourcesContent":["import * as vite from 'vite';\n\nexport function isRolldown(): boolean {\n return !!vite.rolldownVersion;\n}\n\nexport function getJsTransformConfigKey(): 'oxc' | 'esbuild' {\n return isRolldown() ? 'oxc' : 'esbuild';\n}\n"],"mappings":";;AAEA,SAAgB,aAAsB;AACpC,QAAO,CAAC,CAAC,KAAK;;AAGhB,SAAgB,0BAA6C;AAC3D,QAAO,YAAY,GAAG,QAAQ"}
1
+ {"version":3,"file":"rolldown.js","names":[],"sources":["../../../../src/lib/utils/rolldown.ts"],"sourcesContent":["import * as vite from 'vite';\n\nexport function isRolldown(): boolean {\n return !!vite.rolldownVersion;\n}\n\nexport function getJsTransformConfigKey(): 'oxc' | 'esbuild' {\n return isRolldown() ? 'oxc' : 'esbuild';\n}\n"],"mappings":";;AAEA,SAAgB,aAAsB;CACpC,OAAO,CAAC,CAAC,KAAK;AAChB;AAEA,SAAgB,0BAA6C;CAC3D,OAAO,WAAW,IAAI,QAAQ;AAChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"safe-module-paths.js","names":[],"sources":["../../../../src/lib/utils/safe-module-paths.ts"],"sourcesContent":["import { normalizePath, type ResolvedConfig } from 'vite';\n\n/**\n * Mark a style file path as safe in Vite's `safeModulePaths` set so the\n * `?inline` import passes the Denied ID security check without needing\n * the plugin to intercept the load.\n *\n * Vite's own import-analysis transform does the same thing (adds the clean\n * URL to `safeModulePaths` during transform). We additionally add the\n * `?inline` form because `isServerAccessDeniedForTransform` checks *both*\n * `cleanUrl(id)` and the full `id` (with query) against the allow list.\n *\n * This lets `?inline` CSS flow through Vite's native CSS pipeline, which\n * handles preprocessing, `test.css` semantics, and browser-vs-node\n * differences without the plugin having to reimplement any of it.\n */\nexport function markStylePathSafe(\n config: ResolvedConfig | undefined,\n absPath: string,\n): void {\n if (!config) return;\n const normalized = normalizePath(absPath);\n const safeModulePaths = (config as any).safeModulePaths as\n | Set<string>\n | undefined;\n if (safeModulePaths) {\n safeModulePaths.add(normalized);\n safeModulePaths.add(normalized + '?inline');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,kBACd,QACA,SACM;AACN,KAAI,CAAC,OAAQ;CACb,MAAM,aAAa,cAAc,QAAQ;CACzC,MAAM,kBAAmB,OAAe;AAGxC,KAAI,iBAAiB;AACnB,kBAAgB,IAAI,WAAW;AAC/B,kBAAgB,IAAI,aAAa,UAAU"}
1
+ {"version":3,"file":"safe-module-paths.js","names":[],"sources":["../../../../src/lib/utils/safe-module-paths.ts"],"sourcesContent":["import { normalizePath, type ResolvedConfig } from 'vite';\n\n/**\n * Mark a style file path as safe in Vite's `safeModulePaths` set so the\n * `?inline` import passes the Denied ID security check without needing\n * the plugin to intercept the load.\n *\n * Vite's own import-analysis transform does the same thing (adds the clean\n * URL to `safeModulePaths` during transform). We additionally add the\n * `?inline` form because `isServerAccessDeniedForTransform` checks *both*\n * `cleanUrl(id)` and the full `id` (with query) against the allow list.\n *\n * This lets `?inline` CSS flow through Vite's native CSS pipeline, which\n * handles preprocessing, `test.css` semantics, and browser-vs-node\n * differences without the plugin having to reimplement any of it.\n */\nexport function markStylePathSafe(\n config: ResolvedConfig | undefined,\n absPath: string,\n): void {\n if (!config) return;\n const normalized = normalizePath(absPath);\n const safeModulePaths = (config as any).safeModulePaths as\n | Set<string>\n | undefined;\n if (safeModulePaths) {\n safeModulePaths.add(normalized);\n safeModulePaths.add(normalized + '?inline');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,kBACd,QACA,SACM;CACN,IAAI,CAAC,QAAQ;CACb,MAAM,aAAa,cAAc,OAAO;CACxC,MAAM,kBAAmB,OAAe;CAGxC,IAAI,iBAAiB;EACnB,gBAAgB,IAAI,UAAU;EAC9B,gBAAgB,IAAI,aAAa,SAAS;CAC5C;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"transform-cache.js","names":[],"sources":["../../../../src/lib/utils/transform-cache.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as crypto from 'node:crypto';\nimport { VERSION } from '@angular/compiler';\nimport { createDebug } from 'obug';\n\nconst debugCache = createDebug('analog-transform-cache');\n\n/**\n * The `{ get, put }` shape `@angular/build`'s `JavaScriptTransformer`\n * accepts. Keys are content hashes the\n * transformer derives from the file bytes plus every option that affects\n * output, so entries are immutable and never need invalidation — but the\n * digest does NOT cover the linker version, so stores must be namespaced\n * by Angular version (see {@link resolveTransformCacheDir}).\n */\nexport interface TransformCacheStore {\n get(key: string): Promise<Uint8Array | undefined> | Uint8Array | undefined;\n put(key: string, value: Uint8Array): Promise<void> | void;\n}\n\ninterface TransformCacheStats {\n hits: number;\n misses: number;\n writes: number;\n /** Approximate total ms spent in the linker worker for cache misses. */\n workerMs: number;\n}\n\n/**\n * Disk-backed content-addressed store for linked/transformed dependency\n * output. Entries are written atomically (temp + rename) so concurrent\n * dev servers can share a directory; all failures degrade to a miss.\n */\nexport function createPersistentTransformCache(\n baseDir: string,\n): TransformCacheStore & { stats: TransformCacheStats } {\n const stats: TransformCacheStats = {\n hits: 0,\n misses: 0,\n writes: 0,\n workerMs: 0,\n };\n // Miss timestamps by key: with the transformer's serialized worker, the\n // gap between a missed get and its put approximates linker time per file.\n const missedAt = new Map<string, number>();\n\n const entryPath = (key: string) => path.join(baseDir, key.slice(0, 2), key);\n\n return {\n stats,\n async get(key: string): Promise<Uint8Array | undefined> {\n try {\n const value = await fs.promises.readFile(entryPath(key));\n stats.hits++;\n debugCache('hit %s (hits=%d misses=%d)', key, stats.hits, stats.misses);\n return value;\n } catch {\n stats.misses++;\n missedAt.set(key, performance.now());\n debugCache(\n 'miss %s (hits=%d misses=%d)',\n key,\n stats.hits,\n stats.misses,\n );\n return undefined;\n }\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n const startedAt = missedAt.get(key);\n if (startedAt !== undefined) {\n missedAt.delete(key);\n stats.workerMs += performance.now() - startedAt;\n }\n try {\n const file = entryPath(key);\n await fs.promises.mkdir(path.dirname(file), { recursive: true });\n const tmp = `${file}.${process.pid}.${crypto.randomBytes(4).toString('hex')}`;\n await fs.promises.writeFile(tmp, value);\n await fs.promises.rename(tmp, file);\n stats.writes++;\n debugCache(\n 'put %s (writes=%d workerMs=%d)',\n key,\n stats.writes,\n Math.round(stats.workerMs),\n );\n } catch (e) {\n debugCache('put failed %s: %s', key, (e as Error)?.message);\n }\n },\n };\n}\n\n/**\n * Layer an unbounded in-memory map over a persistent store so repeat\n * transforms in the same session never touch the disk.\n */\nexport function withMemoryLayer(\n store: TransformCacheStore,\n): TransformCacheStore {\n const memory = new Map<string, Uint8Array>();\n return {\n async get(key: string): Promise<Uint8Array | undefined> {\n const cached = memory.get(key) ?? (await store.get(key));\n if (cached) memory.set(key, cached);\n return cached;\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n memory.set(key, value);\n await store.put(key, value);\n },\n };\n}\n\n/**\n * Resolve the shared on-disk cache directory: `node_modules/.cache` at the\n * nearest `node_modules` above `startDir` — the conventional tool-cache\n * location, so installs and `node_modules` cleans evict it without a\n * separate eviction pass. Namespaced by the installed Angular version\n * because the transformer's cache key does not cover the linker version.\n * Returns `null` (caching disabled) when no `node_modules` exists or the\n * `ANALOG_TRANSFORM_CACHE=0` kill switch is set.\n */\nexport function resolveTransformCacheDir(startDir: string): string | null {\n if (process.env['ANALOG_TRANSFORM_CACHE'] === '0') return null;\n let dir = path.resolve(startDir);\n for (;;) {\n if (fs.existsSync(path.join(dir, 'node_modules'))) {\n return path.join(\n dir,\n 'node_modules',\n '.cache',\n 'analog',\n 'transform-cache',\n VERSION.full,\n );\n }\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,YAAY,yBAAyB;;;;;;AA4BxD,SAAgB,+BACd,SACsD;CACtD,MAAM,QAA6B;EACjC,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,UAAU;EACX;CAGD,MAAM,2BAAW,IAAI,KAAqB;CAE1C,MAAM,aAAa,QAAgB,OAAK,KAAK,SAAS,IAAI,MAAM,GAAG,EAAE,EAAE,IAAI;AAE3E,QAAO;EACL;EACA,MAAM,IAAI,KAA8C;AACtD,OAAI;IACF,MAAM,QAAQ,MAAM,GAAG,SAAS,SAAS,UAAU,IAAI,CAAC;AACxD,UAAM;AACN,eAAW,8BAA8B,KAAK,MAAM,MAAM,MAAM,OAAO;AACvE,WAAO;WACD;AACN,UAAM;AACN,aAAS,IAAI,KAAK,YAAY,KAAK,CAAC;AACpC,eACE,+BACA,KACA,MAAM,MACN,MAAM,OACP;AACD;;;EAGJ,MAAM,IAAI,KAAa,OAAkC;GACvD,MAAM,YAAY,SAAS,IAAI,IAAI;AACnC,OAAI,cAAc,KAAA,GAAW;AAC3B,aAAS,OAAO,IAAI;AACpB,UAAM,YAAY,YAAY,KAAK,GAAG;;AAExC,OAAI;IACF,MAAM,OAAO,UAAU,IAAI;AAC3B,UAAM,GAAG,SAAS,MAAM,OAAK,QAAQ,KAAK,EAAE,EAAE,WAAW,MAAM,CAAC;IAChE,MAAM,MAAM,GAAG,KAAK,GAAG,QAAQ,IAAI,GAAG,OAAO,YAAY,EAAE,CAAC,SAAS,MAAM;AAC3E,UAAM,GAAG,SAAS,UAAU,KAAK,MAAM;AACvC,UAAM,GAAG,SAAS,OAAO,KAAK,KAAK;AACnC,UAAM;AACN,eACE,kCACA,KACA,MAAM,QACN,KAAK,MAAM,MAAM,SAAS,CAC3B;YACM,GAAG;AACV,eAAW,qBAAqB,KAAM,GAAa,QAAQ;;;EAGhE;;;;;;AAOH,SAAgB,gBACd,OACqB;CACrB,MAAM,yBAAS,IAAI,KAAyB;AAC5C,QAAO;EACL,MAAM,IAAI,KAA8C;GACtD,MAAM,SAAS,OAAO,IAAI,IAAI,IAAK,MAAM,MAAM,IAAI,IAAI;AACvD,OAAI,OAAQ,QAAO,IAAI,KAAK,OAAO;AACnC,UAAO;;EAET,MAAM,IAAI,KAAa,OAAkC;AACvD,UAAO,IAAI,KAAK,MAAM;AACtB,SAAM,MAAM,IAAI,KAAK,MAAM;;EAE9B;;;;;;;;;;;AAYH,SAAgB,yBAAyB,UAAiC;AACxE,KAAI,QAAQ,IAAI,8BAA8B,IAAK,QAAO;CAC1D,IAAI,MAAM,OAAK,QAAQ,SAAS;AAChC,UAAS;AACP,MAAI,GAAG,WAAW,OAAK,KAAK,KAAK,eAAe,CAAC,CAC/C,QAAO,OAAK,KACV,KACA,gBACA,UACA,UACA,mBACA,QAAQ,KACT;EAEH,MAAM,SAAS,OAAK,QAAQ,IAAI;AAChC,MAAI,WAAW,IAAK,QAAO;AAC3B,QAAM"}
1
+ {"version":3,"file":"transform-cache.js","names":[],"sources":["../../../../src/lib/utils/transform-cache.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as crypto from 'node:crypto';\nimport { VERSION } from '@angular/compiler';\nimport { createDebug } from 'obug';\n\nconst debugCache = createDebug('analog-transform-cache');\n\n/**\n * The `{ get, put }` shape `@angular/build`'s `JavaScriptTransformer`\n * accepts. Keys are content hashes the\n * transformer derives from the file bytes plus every option that affects\n * output, so entries are immutable and never need invalidation — but the\n * digest does NOT cover the linker version, so stores must be namespaced\n * by Angular version (see {@link resolveTransformCacheDir}).\n */\nexport interface TransformCacheStore {\n get(key: string): Promise<Uint8Array | undefined> | Uint8Array | undefined;\n put(key: string, value: Uint8Array): Promise<void> | void;\n}\n\ninterface TransformCacheStats {\n hits: number;\n misses: number;\n writes: number;\n /** Approximate total ms spent in the linker worker for cache misses. */\n workerMs: number;\n}\n\n/**\n * Disk-backed content-addressed store for linked/transformed dependency\n * output. Entries are written atomically (temp + rename) so concurrent\n * dev servers can share a directory; all failures degrade to a miss.\n */\nexport function createPersistentTransformCache(\n baseDir: string,\n): TransformCacheStore & { stats: TransformCacheStats } {\n const stats: TransformCacheStats = {\n hits: 0,\n misses: 0,\n writes: 0,\n workerMs: 0,\n };\n // Miss timestamps by key: with the transformer's serialized worker, the\n // gap between a missed get and its put approximates linker time per file.\n const missedAt = new Map<string, number>();\n\n const entryPath = (key: string) => path.join(baseDir, key.slice(0, 2), key);\n\n return {\n stats,\n async get(key: string): Promise<Uint8Array | undefined> {\n try {\n const value = await fs.promises.readFile(entryPath(key));\n stats.hits++;\n debugCache('hit %s (hits=%d misses=%d)', key, stats.hits, stats.misses);\n return value;\n } catch {\n stats.misses++;\n missedAt.set(key, performance.now());\n debugCache(\n 'miss %s (hits=%d misses=%d)',\n key,\n stats.hits,\n stats.misses,\n );\n return undefined;\n }\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n const startedAt = missedAt.get(key);\n if (startedAt !== undefined) {\n missedAt.delete(key);\n stats.workerMs += performance.now() - startedAt;\n }\n try {\n const file = entryPath(key);\n await fs.promises.mkdir(path.dirname(file), { recursive: true });\n const tmp = `${file}.${process.pid}.${crypto.randomBytes(4).toString('hex')}`;\n await fs.promises.writeFile(tmp, value);\n await fs.promises.rename(tmp, file);\n stats.writes++;\n debugCache(\n 'put %s (writes=%d workerMs=%d)',\n key,\n stats.writes,\n Math.round(stats.workerMs),\n );\n } catch (e) {\n debugCache('put failed %s: %s', key, (e as Error)?.message);\n }\n },\n };\n}\n\n/**\n * Layer an unbounded in-memory map over a persistent store so repeat\n * transforms in the same session never touch the disk.\n */\nexport function withMemoryLayer(\n store: TransformCacheStore,\n): TransformCacheStore {\n const memory = new Map<string, Uint8Array>();\n return {\n async get(key: string): Promise<Uint8Array | undefined> {\n const cached = memory.get(key) ?? (await store.get(key));\n if (cached) memory.set(key, cached);\n return cached;\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n memory.set(key, value);\n await store.put(key, value);\n },\n };\n}\n\n/**\n * Resolve the shared on-disk cache directory: `node_modules/.cache` at the\n * nearest `node_modules` above `startDir` — the conventional tool-cache\n * location, so installs and `node_modules` cleans evict it without a\n * separate eviction pass. Namespaced by the installed Angular version\n * because the transformer's cache key does not cover the linker version.\n * Returns `null` (caching disabled) when no `node_modules` exists or the\n * `ANALOG_TRANSFORM_CACHE=0` kill switch is set.\n */\nexport function resolveTransformCacheDir(startDir: string): string | null {\n if (process.env['ANALOG_TRANSFORM_CACHE'] === '0') return null;\n let dir = path.resolve(startDir);\n for (;;) {\n if (fs.existsSync(path.join(dir, 'node_modules'))) {\n return path.join(\n dir,\n 'node_modules',\n '.cache',\n 'analog',\n 'transform-cache',\n VERSION.full,\n );\n }\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,YAAY,wBAAwB;;;;;;AA4BvD,SAAgB,+BACd,SACsD;CACtD,MAAM,QAA6B;EACjC,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,UAAU;CACZ;CAGA,MAAM,2BAAW,IAAI,IAAoB;CAEzC,MAAM,aAAa,QAAgB,OAAK,KAAK,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,GAAG;CAE1E,OAAO;EACL;EACA,MAAM,IAAI,KAA8C;GACtD,IAAI;IACF,MAAM,QAAQ,MAAM,GAAG,SAAS,SAAS,UAAU,GAAG,CAAC;IACvD,MAAM;IACN,WAAW,8BAA8B,KAAK,MAAM,MAAM,MAAM,MAAM;IACtE,OAAO;GACT,QAAQ;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AK,KAAK,KAAK,cAAc,CAAC,GAC9C,OAAO,OAAK,KACV,KACA,gBACA,UACA,UACA,mBACA,QAAQ,IACV;EAEF,MAAM,SAAS,OAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK,OAAO;EAC3B,MAAM;CACR;AACF"}
@@ -14,6 +14,7 @@ import { globSync } from "tinyglobby";
14
14
  */
15
15
  var ts = createRequire(import.meta.url)("typescript");
16
16
  var TsconfigResolver = class {
17
+ options;
17
18
  includeCache = [];
18
19
  tsconfigOptionsCache = /* @__PURE__ */ new Map();
19
20
  tsconfigGraphRootCache = /* @__PURE__ */ new Map();
@@ -200,6 +201,6 @@ function collectTsconfigPathRoots(resolvedTsConfigPath, options, rawTsconfig) {
200
201
  return [...discoveredRoots];
201
202
  }
202
203
  //#endregion
203
- export { TsconfigResolver };
204
+ export { TsconfigResolver, normalizeIncludeGlob };
204
205
 
205
206
  //# sourceMappingURL=tsconfig-resolver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tsconfig-resolver.js","names":[],"sources":["../../../../src/lib/utils/tsconfig-resolver.ts"],"sourcesContent":["/**\n * Shared tsconfig resolution logic used by both the ngtsc and compilation-api\n * compilation plugins. Encapsulates the caching, include-glob discovery,\n * tsconfig-graph expansion, and path-root resolution that were previously\n * duplicated across angular-vite-plugin.ts and compilation-api-plugin.ts.\n */\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { existsSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport { normalizePath, ResolvedConfig } from 'vite';\nimport { globSync } from 'tinyglobby';\nimport { debugEmit, debugEmitV } from './debug.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\nexport interface TsconfigResolverOptions {\n workspaceRoot: string;\n include: string[];\n liveReload: boolean;\n isTest: boolean;\n}\n\nexport class TsconfigResolver {\n private includeCache: string[] = [];\n private tsconfigOptionsCache = new Map<\n string,\n { options: any; rootNames: string[] }\n >();\n private tsconfigGraphRootCache = new Map<string, string[]>();\n private integrationIncludes: string[] = [];\n\n constructor(private options: TsconfigResolverOptions) {}\n\n /**\n * Replaces the include globs contributed by Vite plugins through\n * `analog.setup()`. Invalidates the include cache when the set changes.\n */\n setIntegrationIncludes(globs: string[]): void {\n if (\n globs.length === this.integrationIncludes.length &&\n globs.every((glob, index) => glob === this.integrationIncludes[index])\n ) {\n return;\n }\n this.integrationIncludes = [...globs];\n this.invalidateIncludeCache();\n }\n\n private get includeGlobs(): string[] {\n return [...this.options.include, ...this.integrationIncludes];\n }\n\n invalidateIncludeCache(): void {\n this.includeCache = [];\n }\n\n invalidateTsconfigCaches(): void {\n this.tsconfigOptionsCache.clear();\n this.tsconfigGraphRootCache.clear();\n }\n\n invalidateAll(): void {\n this.invalidateIncludeCache();\n this.invalidateTsconfigCaches();\n }\n\n ensureIncludeCache(): string[] {\n if (this.includeGlobs.length > 0 && this.includeCache.length === 0) {\n this.includeCache = this.findIncludes();\n debugEmit('include cache populated', {\n fileCount: this.includeCache.length,\n });\n }\n return this.includeCache;\n }\n\n readAngularTsconfigConfiguration(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ) {\n const isProd = config.mode === 'production';\n const emitSourceMaps = !isProd || !!config.build?.sourcemap;\n return compilerCli.readConfiguration(resolvedTsConfigPath, {\n suppressOutputPathCheck: true,\n outDir: undefined,\n sourceMap: emitSourceMaps,\n inlineSourceMap: false,\n inlineSources: emitSourceMaps,\n declaration: false,\n declarationMap: false,\n allowEmptyCodegenFiles: false,\n annotationsAs: 'decorators',\n enableResourceInlining: false,\n noEmitOnError: false,\n mapRoot: '',\n sourceRoot: '',\n supportTestBed: false,\n supportJitMode: false,\n });\n }\n\n getCachedTsconfigOptions(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): { options: any; rootNames: string[] } {\n const tsconfigKey = this.getTsconfigCacheKey(resolvedTsConfigPath, config);\n let cached = this.tsconfigOptionsCache.get(tsconfigKey);\n\n if (!cached) {\n const read = this.readAngularTsconfigConfiguration(\n resolvedTsConfigPath,\n config,\n );\n cached = { options: read.options, rootNames: read.rootNames };\n this.tsconfigOptionsCache.set(tsconfigKey, cached);\n debugEmit('tsconfig root names loaded', {\n resolvedTsConfigPath,\n rootNameCount: read.rootNames.length,\n });\n debugEmitV('tsconfig root names', {\n resolvedTsConfigPath,\n rootNames: read.rootNames.map((file: string) => normalizePath(file)),\n });\n }\n\n return cached;\n }\n\n collectExpandedTsconfigRoots(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n visited = new Set<string>(),\n ): string[] {\n const normalizedTsConfigPath = normalizePath(resolvedTsConfigPath);\n if (visited.has(normalizedTsConfigPath)) {\n return [];\n }\n\n const tsconfigKey = `${this.getTsconfigCacheKey(normalizedTsConfigPath, config)}|graph`;\n const cached = this.tsconfigGraphRootCache.get(tsconfigKey);\n if (cached) {\n return cached;\n }\n\n visited.add(normalizedTsConfigPath);\n\n const read = this.readAngularTsconfigConfiguration(\n normalizedTsConfigPath,\n config,\n );\n const rawTsconfig = (ts.readConfigFile(\n normalizedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n references?: Array<{ path?: unknown }>;\n };\n\n const expandedRoots = new Set(\n read.rootNames.map((file: string) => normalizePath(file)),\n );\n const pathRoots = collectTsconfigPathRoots(\n normalizedTsConfigPath,\n read.options,\n rawTsconfig,\n );\n for (const pathRoot of pathRoots) {\n expandedRoots.add(pathRoot);\n }\n\n const referenceConfigs = (rawTsconfig.references ?? [])\n .flatMap((reference) =>\n typeof reference.path === 'string'\n ? [\n resolveReferenceTsconfigPath(\n reference.path,\n normalizedTsConfigPath,\n ),\n ]\n : [],\n )\n .filter((reference): reference is string => !!reference);\n\n for (const referenceConfig of referenceConfigs) {\n for (const referenceRoot of this.collectExpandedTsconfigRoots(\n referenceConfig,\n config,\n visited,\n )) {\n expandedRoots.add(referenceRoot);\n }\n }\n\n const expandedRootList = [...expandedRoots];\n this.tsconfigGraphRootCache.set(tsconfigKey, expandedRootList);\n debugEmit('expanded tsconfig graph roots', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n directRootNameCount: read.rootNames.length,\n pathRootCount: pathRoots.length,\n referenceConfigCount: referenceConfigs.length,\n expandedRootCount: expandedRootList.length,\n });\n debugEmitV('expanded tsconfig graph root files', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n pathRoots,\n referenceConfigs,\n rootNames: expandedRootList,\n });\n\n return expandedRootList;\n }\n\n private getTsconfigCacheKey(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const isProd = config.mode === 'production';\n return [\n resolvedTsConfigPath,\n isProd ? 'prod' : 'dev',\n this.options.isTest ? 'test' : 'app',\n config.build?.lib ? 'lib' : 'nolib',\n !isProd || config.build?.sourcemap ? 'maps' : 'nomaps',\n this.options.liveReload ? 'live-reload' : 'no-live-reload',\n ].join('|');\n }\n\n private findIncludes(): string[] {\n const globs = this.includeGlobs.map((glob) =>\n normalizeIncludeGlob(this.options.workspaceRoot, glob),\n );\n const files = globSync(globs, { dot: true, absolute: true });\n debugEmit('include discovery', {\n patternCount: globs.length,\n fileCount: files.length,\n });\n debugEmitV('include discovery files', {\n globs,\n files: files.map((file) => normalizePath(file)),\n });\n return files;\n }\n}\n\nexport function normalizeIncludeGlob(\n workspaceRoot: string,\n glob: string,\n): string {\n const normalizedWorkspaceRoot = normalizePath(resolve(workspaceRoot));\n const normalizedGlob = normalizePath(glob);\n\n if (\n normalizedGlob === normalizedWorkspaceRoot ||\n normalizedGlob.startsWith(`${normalizedWorkspaceRoot}/`)\n ) {\n return normalizedGlob;\n }\n\n if (normalizedGlob.startsWith('/')) {\n return `${normalizedWorkspaceRoot}${normalizedGlob}`;\n }\n\n return normalizePath(resolve(normalizedWorkspaceRoot, normalizedGlob));\n}\n\nfunction resolveReferenceTsconfigPath(\n referencePath: string,\n ownerTsconfigPath: string,\n): string | undefined {\n const ownerDir = dirname(ownerTsconfigPath);\n const resolvedReference = normalizePath(\n isAbsolute(referencePath)\n ? referencePath\n : resolve(ownerDir, referencePath),\n );\n\n if (existsSync(resolvedReference)) {\n try {\n if (statSync(resolvedReference).isDirectory()) {\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n return existsSync(nestedTsconfig)\n ? normalizePath(nestedTsconfig)\n : undefined;\n }\n } catch {\n return undefined;\n }\n return resolvedReference;\n }\n\n if (!resolvedReference.endsWith('.json')) {\n const asJson = `${resolvedReference}.json`;\n if (existsSync(asJson)) {\n return normalizePath(asJson);\n }\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n if (existsSync(nestedTsconfig)) {\n return normalizePath(nestedTsconfig);\n }\n }\n\n return undefined;\n}\n\nfunction collectTsconfigPathRoots(\n resolvedTsConfigPath: string,\n options: any,\n rawTsconfig: {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n },\n): string[] {\n const tsPaths = rawTsconfig.compilerOptions?.paths ?? options.paths;\n if (!tsPaths) {\n return [];\n }\n\n const tsconfigDir = dirname(resolvedTsConfigPath);\n const configuredBaseUrl =\n typeof options.baseUrl === 'string'\n ? options.baseUrl\n : typeof rawTsconfig.compilerOptions?.baseUrl === 'string'\n ? rawTsconfig.compilerOptions.baseUrl\n : undefined;\n const resolvedBaseUrl = configuredBaseUrl\n ? isAbsolute(configuredBaseUrl)\n ? configuredBaseUrl\n : resolve(tsconfigDir, configuredBaseUrl)\n : tsconfigDir;\n const discoveredRoots = new Set<string>();\n\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n const resolvedTarget = normalizePath(\n isAbsolute(target) ? target : resolve(resolvedBaseUrl, target),\n );\n\n if (target.includes('*')) {\n for (const match of globSync(resolvedTarget, {\n dot: true,\n absolute: true,\n })) {\n discoveredRoots.add(normalizePath(match));\n }\n continue;\n }\n\n if (existsSync(resolvedTarget)) {\n discoveredRoots.add(resolvedTarget);\n }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ACL,UAAU;IACX,CAAC,CACA,iBAAgB,IAAI,cAAc,MAAM,CAAC;AAE3C;;AAGF,MAAI,WAAW,eAAe,CAC5B,iBAAgB,IAAI,eAAe;;AAKzC,QAAO,CAAC,GAAG,gBAAgB"}
1
+ {"version":3,"file":"tsconfig-resolver.js","names":[],"sources":["../../../../src/lib/utils/tsconfig-resolver.ts"],"sourcesContent":["/**\n * Shared tsconfig resolution logic used by both the ngtsc and compilation-api\n * compilation plugins. Encapsulates the caching, include-glob discovery,\n * tsconfig-graph expansion, and path-root resolution that were previously\n * duplicated across angular-vite-plugin.ts and compilation-api-plugin.ts.\n */\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { existsSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport { normalizePath, ResolvedConfig } from 'vite';\nimport { globSync } from 'tinyglobby';\nimport { debugEmit, debugEmitV } from './debug.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\nexport interface TsconfigResolverOptions {\n workspaceRoot: string;\n include: string[];\n liveReload: boolean;\n isTest: boolean;\n}\n\nexport class TsconfigResolver {\n private includeCache: string[] = [];\n private tsconfigOptionsCache = new Map<\n string,\n { options: any; rootNames: string[] }\n >();\n private tsconfigGraphRootCache = new Map<string, string[]>();\n private integrationIncludes: string[] = [];\n\n constructor(private options: TsconfigResolverOptions) {}\n\n /**\n * Replaces the include globs contributed by Vite plugins through\n * `analog.setup()`. Invalidates the include cache when the set changes.\n */\n setIntegrationIncludes(globs: string[]): void {\n if (\n globs.length === this.integrationIncludes.length &&\n globs.every((glob, index) => glob === this.integrationIncludes[index])\n ) {\n return;\n }\n this.integrationIncludes = [...globs];\n this.invalidateIncludeCache();\n }\n\n private get includeGlobs(): string[] {\n return [...this.options.include, ...this.integrationIncludes];\n }\n\n invalidateIncludeCache(): void {\n this.includeCache = [];\n }\n\n invalidateTsconfigCaches(): void {\n this.tsconfigOptionsCache.clear();\n this.tsconfigGraphRootCache.clear();\n }\n\n invalidateAll(): void {\n this.invalidateIncludeCache();\n this.invalidateTsconfigCaches();\n }\n\n ensureIncludeCache(): string[] {\n if (this.includeGlobs.length > 0 && this.includeCache.length === 0) {\n this.includeCache = this.findIncludes();\n debugEmit('include cache populated', {\n fileCount: this.includeCache.length,\n });\n }\n return this.includeCache;\n }\n\n readAngularTsconfigConfiguration(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ) {\n const isProd = config.mode === 'production';\n const emitSourceMaps = !isProd || !!config.build?.sourcemap;\n return compilerCli.readConfiguration(resolvedTsConfigPath, {\n suppressOutputPathCheck: true,\n outDir: undefined,\n sourceMap: emitSourceMaps,\n inlineSourceMap: false,\n inlineSources: emitSourceMaps,\n declaration: false,\n declarationMap: false,\n allowEmptyCodegenFiles: false,\n annotationsAs: 'decorators',\n enableResourceInlining: false,\n noEmitOnError: false,\n mapRoot: '',\n sourceRoot: '',\n supportTestBed: false,\n supportJitMode: false,\n });\n }\n\n getCachedTsconfigOptions(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): { options: any; rootNames: string[] } {\n const tsconfigKey = this.getTsconfigCacheKey(resolvedTsConfigPath, config);\n let cached = this.tsconfigOptionsCache.get(tsconfigKey);\n\n if (!cached) {\n const read = this.readAngularTsconfigConfiguration(\n resolvedTsConfigPath,\n config,\n );\n cached = { options: read.options, rootNames: read.rootNames };\n this.tsconfigOptionsCache.set(tsconfigKey, cached);\n debugEmit('tsconfig root names loaded', {\n resolvedTsConfigPath,\n rootNameCount: read.rootNames.length,\n });\n debugEmitV('tsconfig root names', {\n resolvedTsConfigPath,\n rootNames: read.rootNames.map((file: string) => normalizePath(file)),\n });\n }\n\n return cached;\n }\n\n collectExpandedTsconfigRoots(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n visited = new Set<string>(),\n ): string[] {\n const normalizedTsConfigPath = normalizePath(resolvedTsConfigPath);\n if (visited.has(normalizedTsConfigPath)) {\n return [];\n }\n\n const tsconfigKey = `${this.getTsconfigCacheKey(normalizedTsConfigPath, config)}|graph`;\n const cached = this.tsconfigGraphRootCache.get(tsconfigKey);\n if (cached) {\n return cached;\n }\n\n visited.add(normalizedTsConfigPath);\n\n const read = this.readAngularTsconfigConfiguration(\n normalizedTsConfigPath,\n config,\n );\n const rawTsconfig = (ts.readConfigFile(\n normalizedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n references?: Array<{ path?: unknown }>;\n };\n\n const expandedRoots = new Set(\n read.rootNames.map((file: string) => normalizePath(file)),\n );\n const pathRoots = collectTsconfigPathRoots(\n normalizedTsConfigPath,\n read.options,\n rawTsconfig,\n );\n for (const pathRoot of pathRoots) {\n expandedRoots.add(pathRoot);\n }\n\n const referenceConfigs = (rawTsconfig.references ?? [])\n .flatMap((reference) =>\n typeof reference.path === 'string'\n ? [\n resolveReferenceTsconfigPath(\n reference.path,\n normalizedTsConfigPath,\n ),\n ]\n : [],\n )\n .filter((reference): reference is string => !!reference);\n\n for (const referenceConfig of referenceConfigs) {\n for (const referenceRoot of this.collectExpandedTsconfigRoots(\n referenceConfig,\n config,\n visited,\n )) {\n expandedRoots.add(referenceRoot);\n }\n }\n\n const expandedRootList = [...expandedRoots];\n this.tsconfigGraphRootCache.set(tsconfigKey, expandedRootList);\n debugEmit('expanded tsconfig graph roots', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n directRootNameCount: read.rootNames.length,\n pathRootCount: pathRoots.length,\n referenceConfigCount: referenceConfigs.length,\n expandedRootCount: expandedRootList.length,\n });\n debugEmitV('expanded tsconfig graph root files', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n pathRoots,\n referenceConfigs,\n rootNames: expandedRootList,\n });\n\n return expandedRootList;\n }\n\n private getTsconfigCacheKey(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const isProd = config.mode === 'production';\n return [\n resolvedTsConfigPath,\n isProd ? 'prod' : 'dev',\n this.options.isTest ? 'test' : 'app',\n config.build?.lib ? 'lib' : 'nolib',\n !isProd || config.build?.sourcemap ? 'maps' : 'nomaps',\n this.options.liveReload ? 'live-reload' : 'no-live-reload',\n ].join('|');\n }\n\n private findIncludes(): string[] {\n const globs = this.includeGlobs.map((glob) =>\n normalizeIncludeGlob(this.options.workspaceRoot, glob),\n );\n const files = globSync(globs, { dot: true, absolute: true });\n debugEmit('include discovery', {\n patternCount: globs.length,\n fileCount: files.length,\n });\n debugEmitV('include discovery files', {\n globs,\n files: files.map((file) => normalizePath(file)),\n });\n return files;\n }\n}\n\nexport function normalizeIncludeGlob(\n workspaceRoot: string,\n glob: string,\n): string {\n const normalizedWorkspaceRoot = normalizePath(resolve(workspaceRoot));\n const normalizedGlob = normalizePath(glob);\n\n if (\n normalizedGlob === normalizedWorkspaceRoot ||\n normalizedGlob.startsWith(`${normalizedWorkspaceRoot}/`)\n ) {\n return normalizedGlob;\n }\n\n if (normalizedGlob.startsWith('/')) {\n return `${normalizedWorkspaceRoot}${normalizedGlob}`;\n }\n\n return normalizePath(resolve(normalizedWorkspaceRoot, normalizedGlob));\n}\n\nfunction resolveReferenceTsconfigPath(\n referencePath: string,\n ownerTsconfigPath: string,\n): string | undefined {\n const ownerDir = dirname(ownerTsconfigPath);\n const resolvedReference = normalizePath(\n isAbsolute(referencePath)\n ? referencePath\n : resolve(ownerDir, referencePath),\n );\n\n if (existsSync(resolvedReference)) {\n try {\n if (statSync(resolvedReference).isDirectory()) {\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n return existsSync(nestedTsconfig)\n ? normalizePath(nestedTsconfig)\n : undefined;\n }\n } catch {\n return undefined;\n }\n return resolvedReference;\n }\n\n if (!resolvedReference.endsWith('.json')) {\n const asJson = `${resolvedReference}.json`;\n if (existsSync(asJson)) {\n return normalizePath(asJson);\n }\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n if (existsSync(nestedTsconfig)) {\n return normalizePath(nestedTsconfig);\n }\n }\n\n return undefined;\n}\n\nfunction collectTsconfigPathRoots(\n resolvedTsConfigPath: string,\n options: any,\n rawTsconfig: {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n },\n): string[] {\n const tsPaths = rawTsconfig.compilerOptions?.paths ?? options.paths;\n if (!tsPaths) {\n return [];\n }\n\n const tsconfigDir = dirname(resolvedTsConfigPath);\n const configuredBaseUrl =\n typeof options.baseUrl === 'string'\n ? options.baseUrl\n : typeof rawTsconfig.compilerOptions?.baseUrl === 'string'\n ? rawTsconfig.compilerOptions.baseUrl\n : undefined;\n const resolvedBaseUrl = configuredBaseUrl\n ? isAbsolute(configuredBaseUrl)\n ? configuredBaseUrl\n : resolve(tsconfigDir, configuredBaseUrl)\n : tsconfigDir;\n const discoveredRoots = new Set<string>();\n\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n const resolvedTarget = normalizePath(\n isAbsolute(target) ? target : resolve(resolvedBaseUrl, target),\n );\n\n if (target.includes('*')) {\n for (const match of globSync(resolvedTarget, {\n dot: true,\n absolute: true,\n })) {\n discoveredRoots.add(normalizePath(match));\n }\n continue;\n }\n\n if (existsSync(resolvedTarget)) {\n discoveredRoots.add(resolvedTarget);\n }\n }\n }\n\n return [...discoveredRoots];\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAM,KADU,cAAc,YAAY,GAC/B,CAAA,CAAQ,YAAY;AAS/B,IAAa,mBAAb,MAA8B;CASR;CARpB,eAAiC,CAAC;CAClC,uCAA+B,IAAI,IAGjC;CACF,yCAAiC,IAAI,IAAsB;CAC3D,sBAAwC,CAAC;CAEzC,YAAY,SAA0C;EAAlC,KAAA,UAAA;CAAmC;;;;;CAMvD,uBAAuB,OAAuB;EAC5C,IACE,MAAM,WAAW,KAAK,oBAAoB,UAC1C,MAAM,OAAO,MAAM,UAAU,SAAS,KAAK,oBAAoB,MAAM,GAErE;EAEF,KAAK,sBAAsB,CAAC,GAAG,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ACF,QAAQ;GACN;EACF;EACA,OAAO;CACT;CAEA,IAAI,CAAC,kBAAkB,SAAS,OAAO,GAAG;EACxC,MAAM,SAAS,GAAG,kBAAkB;EACpC,IAAI,WAAW,MAAM,GACnB,OAAO,cAAc,MAAM;EAE7B,MAAM,iBAAiB,KAAK,mBAAmB,eAAe;EAC9D,IAAI,WAAW,cAAc,GAC3B,OAAO,cAAc,cAAc;CAEvC;AAGF;AAEA,SAAS,yBACP,sBACA,SACA,aAMU;CACV,MAAM,UAAU,YAAY,iBAAiB,SAAS,QAAQ;CAC9D,IAAI,CAAC,SACH,OAAO,CAAC;CAGV,MAAM,cAAc,QAAQ,oBAAoB;CAChD,MAAM,oBACJ,OAAO,QAAQ,YAAY,WACvB,QAAQ,UACR,OAAO,YAAY,iBAAiB,YAAY,WAC9C,YAAY,gBAAgB,UAC5B,KAAA;CACR,MAAM,kBAAkB,oBACpB,WAAW,iBAAiB,IAC1B,oBACA,QAAQ,aAAa,iBAAiB,IACxC;CACJ,MAAM,kCAAkB,IAAI,IAAY;CAExC,KAAK,MAAM,WAAW,OAAO,OAAO,OAAO,GACzC,KAAK,MAAM,UAAU,SAAqB;EACxC,MAAM,iBAAiB,cACrB,WAAW,MAAM,IAAI,SAAS,QAAQ,iBAAiB,MAAM,CAC/D;EAEA,IAAI,OAAO,SAAS,GAAG,GAAG;GACxB,KAAK,MAAM,SAAS,SAAS,gBAAgB;IAC3C,KAAK;IACL,UAAU;GACZ,CAAC,GACC,gBAAgB,IAAI,cAAc,KAAK,CAAC;GAE1C;EACF;EAEA,IAAI,WAAW,cAAc,GAC3B,gBAAgB,IAAI,cAAc;CAEtC;CAGF,OAAO,CAAC,GAAG,eAAe;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-ids.js","names":[],"sources":["../../../../src/lib/utils/virtual-ids.ts"],"sourcesContent":["// Virtual module id helpers for external component resources (template files).\n// Routing through virtual ids keeps Vite's built-in plugins (vite:asset, the\n// server.fs Denied ID check) out of the picture: the id Vite sees has no\n// file extension, so extension-based matchers never fire, and it does not\n// match the /[?&](raw|inline)\\b/ security regex.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids. See #2263 / #2283 / #2310.\n\nexport const VIRTUAL_RAW_PREFIX = 'virtual:@analogjs/vite-plugin-angular:raw:';\n\nfunction encode(absPath: string): string {\n return Buffer.from(absPath, 'utf-8').toString('base64url');\n}\n\nfunction decode(encoded: string): string {\n return Buffer.from(encoded, 'base64url').toString('utf-8');\n}\n\nexport function toVirtualRawId(absPath: string): string {\n return `${VIRTUAL_RAW_PREFIX}${encode(absPath)}`;\n}\n\nexport function isVirtualRawId(id: string): boolean {\n const stripped = id.startsWith('\\0') ? id.slice(1) : id;\n return stripped.startsWith(VIRTUAL_RAW_PREFIX);\n}\n\nexport function fromVirtualRawId(id: string): string {\n const normalizedId = id.startsWith('\\0') ? id.slice(1) : id;\n if (!normalizedId.startsWith(VIRTUAL_RAW_PREFIX)) {\n throw new Error(`Invalid virtual raw id: ${id}`);\n }\n return decode(normalizedId.slice(VIRTUAL_RAW_PREFIX.length));\n}\n"],"mappings":";AAUA,IAAa,qBAAqB;AAElC,SAAS,OAAO,SAAyB;AACvC,QAAO,OAAO,KAAK,SAAS,QAAQ,CAAC,SAAS,YAAY;;AAG5D,SAAS,OAAO,SAAyB;AACvC,QAAO,OAAO,KAAK,SAAS,YAAY,CAAC,SAAS,QAAQ;;AAG5D,SAAgB,eAAe,SAAyB;AACtD,QAAO,GAAG,qBAAqB,OAAO,QAAQ;;AAGhD,SAAgB,eAAe,IAAqB;AAElD,SADiB,GAAG,WAAW,KAAK,GAAG,GAAG,MAAM,EAAE,GAAG,IACrC,WAAW,mBAAmB;;AAGhD,SAAgB,iBAAiB,IAAoB;CACnD,MAAM,eAAe,GAAG,WAAW,KAAK,GAAG,GAAG,MAAM,EAAE,GAAG;AACzD,KAAI,CAAC,aAAa,WAAA,6CAA8B,CAC9C,OAAM,IAAI,MAAM,2BAA2B,KAAK;AAElD,QAAO,OAAO,aAAa,MAAM,GAA0B,CAAC"}
1
+ {"version":3,"file":"virtual-ids.js","names":[],"sources":["../../../../src/lib/utils/virtual-ids.ts"],"sourcesContent":["// Virtual module id helpers for external component resources (template files).\n// Routing through virtual ids keeps Vite's built-in plugins (vite:asset, the\n// server.fs Denied ID check) out of the picture: the id Vite sees has no\n// file extension, so extension-based matchers never fire, and it does not\n// match the /[?&](raw|inline)\\b/ security regex.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids. See #2263 / #2283 / #2310.\n\nexport const VIRTUAL_RAW_PREFIX = 'virtual:@analogjs/vite-plugin-angular:raw:';\n\nfunction encode(absPath: string): string {\n return Buffer.from(absPath, 'utf-8').toString('base64url');\n}\n\nfunction decode(encoded: string): string {\n return Buffer.from(encoded, 'base64url').toString('utf-8');\n}\n\nexport function toVirtualRawId(absPath: string): string {\n return `${VIRTUAL_RAW_PREFIX}${encode(absPath)}`;\n}\n\nexport function isVirtualRawId(id: string): boolean {\n const stripped = id.startsWith('\\0') ? id.slice(1) : id;\n return stripped.startsWith(VIRTUAL_RAW_PREFIX);\n}\n\nexport function fromVirtualRawId(id: string): string {\n const normalizedId = id.startsWith('\\0') ? id.slice(1) : id;\n if (!normalizedId.startsWith(VIRTUAL_RAW_PREFIX)) {\n throw new Error(`Invalid virtual raw id: ${id}`);\n }\n return decode(normalizedId.slice(VIRTUAL_RAW_PREFIX.length));\n}\n"],"mappings":";AAUA,IAAa,qBAAqB;AAElC,SAAS,OAAO,SAAyB;CACvC,OAAO,OAAO,KAAK,SAAS,OAAO,CAAC,CAAC,SAAS,WAAW;AAC3D;AAEA,SAAS,OAAO,SAAyB;CACvC,OAAO,OAAO,KAAK,SAAS,WAAW,CAAC,CAAC,SAAS,OAAO;AAC3D;AAEA,SAAgB,eAAe,SAAyB;CACtD,OAAO,GAAG,qBAAqB,OAAO,OAAO;AAC/C;AAEA,SAAgB,eAAe,IAAqB;CAElD,QADiB,GAAG,WAAW,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,GAAA,CACrC,WAAW,kBAAkB;AAC/C;AAEA,SAAgB,iBAAiB,IAAoB;CACnD,MAAM,eAAe,GAAG,WAAW,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI;CACzD,IAAI,CAAC,aAAa,WAAA,4CAA6B,GAC7C,MAAM,IAAI,MAAM,2BAA2B,IAAI;CAEjD,OAAO,OAAO,aAAa,MAAM,EAAyB,CAAC;AAC7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-resources.js","names":[],"sources":["../../../../src/lib/utils/virtual-resources.ts"],"sourcesContent":["// Shared Vite plugin helpers for routing component resources (templates)\n// through virtual module ids. Both angular-vite-plugin and fast-compile-plugin\n// use these so the rewriting + loading behavior stays in sync between them.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids.\n\nimport { promises as fsPromises } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\n\nimport {\n fromVirtualRawId,\n isVirtualRawId,\n toVirtualRawId,\n} from './virtual-ids.js';\n\ninterface PluginContextLike {\n addWatchFile(path: string): void;\n}\n\nfunction resolveImportPath(\n id: string,\n importer: string | undefined,\n): string | undefined {\n const filePath = id.split('?')[0];\n return isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n}\n\n/**\n * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined\n * when the id doesn't match, so callers can fall through to the next check.\n *\n * Routed through a virtual id (rather than `?analog-raw`) so the path Vite\n * sees has no file extension — keeps vite:asset / vite:css from re-tagging\n * the id before our load hook runs.\n */\nexport function rewriteHtmlRawImport(\n id: string,\n importer: string | undefined,\n): string | undefined {\n if (!id.includes('.html?raw')) return undefined;\n const resolved = resolveImportPath(id, importer);\n return resolved ? toVirtualRawId(resolved) : undefined;\n}\n\n/**\n * Load a virtual raw module: reads the backing file, registers it for HMR\n * watching, and returns its content as a default-exported string. Returns\n * undefined when the id is not a virtual raw id.\n */\nexport async function loadVirtualRawModule(\n ctx: PluginContextLike,\n id: string,\n): Promise<string | undefined> {\n if (!isVirtualRawId(id)) return undefined;\n const filePath = fromVirtualRawId(id);\n ctx.addWatchFile(filePath);\n const content = await fsPromises.readFile(filePath, 'utf-8');\n return `export default ${JSON.stringify(content)}`;\n}\n"],"mappings":";;;;;AAsBA,SAAS,kBACP,IACA,UACoB;CACpB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAC/B,QAAO,WAAW,SAAS,GACvB,cAAc,SAAS,GACvB,WACE,cAAc,QAAQ,QAAQ,SAAS,EAAE,SAAS,CAAC,GACnD,KAAA;;;;;;;;;;AAWR,SAAgB,qBACd,IACA,UACoB;AACpB,KAAI,CAAC,GAAG,SAAS,YAAY,CAAE,QAAO,KAAA;CACtC,MAAM,WAAW,kBAAkB,IAAI,SAAS;AAChD,QAAO,WAAW,eAAe,SAAS,GAAG,KAAA;;;;;;;AAQ/C,eAAsB,qBACpB,KACA,IAC6B;AAC7B,KAAI,CAAC,eAAe,GAAG,CAAE,QAAO,KAAA;CAChC,MAAM,WAAW,iBAAiB,GAAG;AACrC,KAAI,aAAa,SAAS;CAC1B,MAAM,UAAU,MAAM,SAAW,SAAS,UAAU,QAAQ;AAC5D,QAAO,kBAAkB,KAAK,UAAU,QAAQ"}
1
+ {"version":3,"file":"virtual-resources.js","names":[],"sources":["../../../../src/lib/utils/virtual-resources.ts"],"sourcesContent":["// Shared Vite plugin helpers for routing component resources (templates)\n// through virtual module ids. Both angular-vite-plugin and fast-compile-plugin\n// use these so the rewriting + loading behavior stays in sync between them.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids.\n\nimport { promises as fsPromises } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\n\nimport {\n fromVirtualRawId,\n isVirtualRawId,\n toVirtualRawId,\n} from './virtual-ids.js';\n\ninterface PluginContextLike {\n addWatchFile(path: string): void;\n}\n\nfunction resolveImportPath(\n id: string,\n importer: string | undefined,\n): string | undefined {\n const filePath = id.split('?')[0];\n return isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n}\n\n/**\n * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined\n * when the id doesn't match, so callers can fall through to the next check.\n *\n * Routed through a virtual id (rather than `?analog-raw`) so the path Vite\n * sees has no file extension — keeps vite:asset / vite:css from re-tagging\n * the id before our load hook runs.\n */\nexport function rewriteHtmlRawImport(\n id: string,\n importer: string | undefined,\n): string | undefined {\n if (!id.includes('.html?raw')) return undefined;\n const resolved = resolveImportPath(id, importer);\n return resolved ? toVirtualRawId(resolved) : undefined;\n}\n\n/**\n * Load a virtual raw module: reads the backing file, registers it for HMR\n * watching, and returns its content as a default-exported string. Returns\n * undefined when the id is not a virtual raw id.\n */\nexport async function loadVirtualRawModule(\n ctx: PluginContextLike,\n id: string,\n): Promise<string | undefined> {\n if (!isVirtualRawId(id)) return undefined;\n const filePath = fromVirtualRawId(id);\n ctx.addWatchFile(filePath);\n const content = await fsPromises.readFile(filePath, 'utf-8');\n return `export default ${JSON.stringify(content)}`;\n}\n"],"mappings":";;;;;AAsBA,SAAS,kBACP,IACA,UACoB;CACpB,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC;CAC/B,OAAO,WAAW,QAAQ,IACtB,cAAc,QAAQ,IACtB,WACE,cAAc,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,CAAC,IAClD,KAAA;AACR;;;;;;;;;AAUA,SAAgB,qBACd,IACA,UACoB;CACpB,IAAI,CAAC,GAAG,SAAS,WAAW,GAAG,OAAO,KAAA;CACtC,MAAM,WAAW,kBAAkB,IAAI,QAAQ;CAC/C,OAAO,WAAW,eAAe,QAAQ,IAAI,KAAA;AAC/C;;;;;;AAOA,eAAsB,qBACpB,KACA,IAC6B;CAC7B,IAAI,CAAC,eAAe,EAAE,GAAG,OAAO,KAAA;CAChC,MAAM,WAAW,iBAAiB,EAAE;CACpC,IAAI,aAAa,QAAQ;CACzB,MAAM,UAAU,MAAM,SAAW,SAAS,UAAU,OAAO;CAC3D,OAAO,kBAAkB,KAAK,UAAU,OAAO;AACjD"}
@@ -8,7 +8,10 @@ function virtualModulesPlugin(pluginOptions) {
8
8
  enforce: "pre",
9
9
  resolveId(id, importer) {
10
10
  if (id.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) return `\0${id}`;
11
- if (pluginOptions.jit && id.startsWith("angular:jit:")) return toVirtualRawId(normalizePath(resolve(dirname(importer), id.split(";")[1])));
11
+ if (pluginOptions.jit && id.startsWith("angular:jit:")) {
12
+ const filePath = normalizePath(resolve(dirname(importer), id.split(";")[1]));
13
+ return toVirtualRawId(filePath);
14
+ }
12
15
  if (id.includes(".html?raw")) {
13
16
  const filePath = id.split("?")[0];
14
17
  const resolved = isAbsolute(filePath) ? normalizePath(filePath) : importer ? normalizePath(resolve(dirname(importer), filePath)) : void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, Plugin } from 'vite';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\n\nexport interface VirtualModulesPluginOptions {\n jit: boolean;\n}\n\nexport function virtualModulesPlugin(\n pluginOptions: VirtualModulesPluginOptions,\n): Plugin {\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n resolveId(id, importer) {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (pluginOptions.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n if (id.includes('.html?raw')) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n if (resolved) {\n return toVirtualRawId(resolved);\n }\n }\n\n return undefined;\n },\n };\n}\n"],"mappings":";;;;AAQA,SAAgB,qBACd,eACQ;AACR,QAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,IAAI,UAAU;AACtB,OAAI,GAAG,WAAA,6CAA8B,CACnC,QAAO,KAAK;AAGd,OAAI,cAAc,OAAO,GAAG,WAAW,eAAe,CAIpD,QAAO,eAHU,cACf,QAAQ,QAAQ,SAAmB,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,CACvD,CAC8B;AAIjC,OAAI,GAAG,SAAS,YAAY,EAAE;IAC5B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;IAC/B,MAAM,WAAW,WAAW,SAAS,GACjC,cAAc,SAAS,GACvB,WACE,cAAc,QAAQ,QAAQ,SAAS,EAAE,SAAS,CAAC,GACnD,KAAA;AACN,QAAI,SACF,QAAO,eAAe,SAAS;;;EAMtC"}
1
+ {"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, Plugin } from 'vite';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\n\nexport interface VirtualModulesPluginOptions {\n jit: boolean;\n}\n\nexport function virtualModulesPlugin(\n pluginOptions: VirtualModulesPluginOptions,\n): Plugin {\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n resolveId(id, importer) {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (pluginOptions.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n if (id.includes('.html?raw')) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n if (resolved) {\n return toVirtualRawId(resolved);\n }\n }\n\n return undefined;\n },\n };\n}\n"],"mappings":";;;;AAQA,SAAgB,qBACd,eACQ;CACR,OAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,IAAI,UAAU;GACtB,IAAI,GAAG,WAAA,4CAA6B,GAClC,OAAO,KAAK;GAGd,IAAI,cAAc,OAAO,GAAG,WAAW,cAAc,GAAG;IACtD,MAAM,WAAW,cACf,QAAQ,QAAQ,QAAkB,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,CACvD;IACA,OAAO,eAAe,QAAQ;GAChC;GAGA,IAAI,GAAG,SAAS,WAAW,GAAG;IAC5B,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC;IAC/B,MAAM,WAAW,WAAW,QAAQ,IAChC,cAAc,QAAQ,IACtB,WACE,cAAc,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,CAAC,IAClD,KAAA;IACN,IAAI,UACF,OAAO,eAAe,QAAQ;GAElC;EAGF;CACF;AACF"}