@analogjs/platform 3.0.0-alpha.22 → 3.0.0-alpha.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/platform",
3
- "version": "3.0.0-alpha.22",
3
+ "version": "3.0.0-alpha.23",
4
4
  "description": "The fullstack meta-framework for Angular",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
@@ -34,9 +34,10 @@
34
34
  "front-matter": "^4.0.2",
35
35
  "tinyglobby": "^0.2.15",
36
36
  "nitro": "3.0.260311-beta",
37
- "@analogjs/vite-plugin-angular": "^3.0.0-alpha.22",
38
- "@analogjs/vite-plugin-nitro": "^3.0.0-alpha.22",
37
+ "@analogjs/vite-plugin-angular": "^3.0.0-alpha.23",
38
+ "@analogjs/vite-plugin-nitro": "^3.0.0-alpha.23",
39
39
  "rolldown": "^1.0.0-rc.12",
40
+ "obug": "^2.1.1",
40
41
  "vitefu": "^1.1.2"
41
42
  },
42
43
  "peerDependencies": {
@@ -1,3 +1,4 @@
1
+ import { debugPlatform } from "./utils/debug.js";
1
2
  import { getJsTransformConfigKey } from "./utils/rolldown.js";
2
3
  import { VERSION } from "@angular/compiler-cli";
3
4
  import { crawlFrameworkPkgs } from "vitefu";
@@ -10,6 +11,11 @@ function depsPlugin(options) {
10
11
  config() {
11
12
  const useAngularCompilationAPI = options?.experimental?.useAngularCompilationAPI ?? viteOptions?.experimental?.useAngularCompilationAPI;
12
13
  const transformConfig = options?.vite === false || useAngularCompilationAPI ? {} : { exclude: ["**/*.ts", "**/*.js"] };
14
+ debugPlatform("deps transform config", {
15
+ useAngularCompilationAPI: !!useAngularCompilationAPI,
16
+ jsTransformKey: getJsTransformConfigKey(),
17
+ transformExcluded: "exclude" in transformConfig
18
+ });
13
19
  return {
14
20
  [getJsTransformConfigKey()]: transformConfig,
15
21
  ssr: { noExternal: [
@@ -1 +1 @@
1
- {"version":3,"file":"deps-plugin.js","names":[],"sources":["../../../src/lib/deps-plugin.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport type { Plugin } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nimport { Options } from './options.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function depsPlugin(options?: Options): Plugin[] {\n const workspaceRoot =\n options?.workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd();\n const viteOptions = options?.vite === false ? undefined : options?.vite;\n\n return [\n {\n name: 'analogjs-deps-plugin',\n config() {\n const useAngularCompilationAPI =\n options?.experimental?.useAngularCompilationAPI ??\n viteOptions?.experimental?.useAngularCompilationAPI;\n\n const transformConfig =\n options?.vite === false || useAngularCompilationAPI\n ? {}\n : { exclude: ['**/*.ts', '**/*.js'] };\n\n return {\n [getJsTransformConfigKey()]: transformConfig,\n ssr: {\n noExternal: [\n '@analogjs/**',\n 'firebase/**',\n 'firebase-admin/**',\n 'rxfire',\n '@ng-web-apis/**',\n '@taiga-ui/**',\n '@tanstack/angular-query-experimental',\n ],\n },\n optimizeDeps: {\n include: [\n '@angular/common',\n '@angular/common/http',\n ...(Number(VERSION.major) > 15\n ? ['@angular/core/rxjs-interop']\n : []),\n 'front-matter',\n ],\n exclude: [\n '@angular/platform-server',\n '@analogjs/content',\n '@analogjs/router',\n '@nx/angular',\n '@nx/vite',\n '@nx/devkit',\n '@nx/js',\n '@nx/devkit',\n '@nx/cypress',\n '@nx/jest',\n '@nx/js',\n '@nx/eslint',\n '@nx/webpack',\n '@nx/web',\n '@nx/workspace',\n '@nx/eslint',\n '@nx/module-federation',\n '@nx/rspack',\n 'webpack',\n 'fsevents',\n 'nx',\n ],\n },\n };\n },\n },\n {\n name: 'analogjs-auto-discover-deps',\n async config(config, { command }) {\n const pkgConfig = await crawlFrameworkPkgs({\n root: workspaceRoot,\n isBuild: command === 'build',\n viteUserConfig: config,\n isSemiFrameworkPkgByJson(pkgJson) {\n return pkgJson['module'] && pkgJson['module'].includes('fesm');\n },\n });\n return pkgConfig;\n },\n },\n ];\n}\n"],"mappings":";;;;AAOA,SAAgB,WAAW,SAA6B;CACtD,MAAM,gBACJ,SAAS,iBAAiB,QAAQ,IAAI,wBAAwB,QAAQ,KAAK;CAC7E,MAAM,cAAc,SAAS,SAAS,QAAQ,KAAA,IAAY,SAAS;AAEnE,QAAO,CACL;EACE,MAAM;EACN,SAAS;GACP,MAAM,2BACJ,SAAS,cAAc,4BACvB,aAAa,cAAc;GAE7B,MAAM,kBACJ,SAAS,SAAS,SAAS,2BACvB,EAAE,GACF,EAAE,SAAS,CAAC,WAAW,UAAU,EAAE;AAEzC,UAAO;KACJ,yBAAyB,GAAG;IAC7B,KAAK,EACH,YAAY;KACV;KACA;KACA;KACA;KACA;KACA;KACA;KACD,EACF;IACD,cAAc;KACZ,SAAS;MACP;MACA;MACA,GAAI,OAAO,QAAQ,MAAM,GAAG,KACxB,CAAC,6BAA6B,GAC9B,EAAE;MACN;MACD;KACD,SAAS;MACP;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACD;KACF;IACF;;EAEJ,EACD;EACE,MAAM;EACN,MAAM,OAAO,QAAQ,EAAE,WAAW;AAShC,UARkB,MAAM,mBAAmB;IACzC,MAAM;IACN,SAAS,YAAY;IACrB,gBAAgB;IAChB,yBAAyB,SAAS;AAChC,YAAO,QAAQ,aAAa,QAAQ,UAAU,SAAS,OAAO;;IAEjE,CAAC;;EAGL,CACF"}
1
+ {"version":3,"file":"deps-plugin.js","names":[],"sources":["../../../src/lib/deps-plugin.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport type { Plugin } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nimport { Options } from './options.js';\nimport { debugPlatform } from './utils/debug.js';\nimport { getJsTransformConfigKey } from './utils/rolldown.js';\n\nexport function depsPlugin(options?: Options): Plugin[] {\n const workspaceRoot =\n options?.workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd();\n const viteOptions = options?.vite === false ? undefined : options?.vite;\n\n return [\n {\n name: 'analogjs-deps-plugin',\n config() {\n const useAngularCompilationAPI =\n options?.experimental?.useAngularCompilationAPI ??\n viteOptions?.experimental?.useAngularCompilationAPI;\n\n const transformConfig =\n options?.vite === false || useAngularCompilationAPI\n ? {}\n : { exclude: ['**/*.ts', '**/*.js'] };\n debugPlatform('deps transform config', {\n useAngularCompilationAPI: !!useAngularCompilationAPI,\n jsTransformKey: getJsTransformConfigKey(),\n transformExcluded: 'exclude' in transformConfig,\n });\n\n return {\n [getJsTransformConfigKey()]: transformConfig,\n ssr: {\n noExternal: [\n '@analogjs/**',\n 'firebase/**',\n 'firebase-admin/**',\n 'rxfire',\n '@ng-web-apis/**',\n '@taiga-ui/**',\n '@tanstack/angular-query-experimental',\n ],\n },\n optimizeDeps: {\n include: [\n '@angular/common',\n '@angular/common/http',\n ...(Number(VERSION.major) > 15\n ? ['@angular/core/rxjs-interop']\n : []),\n 'front-matter',\n ],\n exclude: [\n '@angular/platform-server',\n '@analogjs/content',\n '@analogjs/router',\n '@nx/angular',\n '@nx/vite',\n '@nx/devkit',\n '@nx/js',\n '@nx/devkit',\n '@nx/cypress',\n '@nx/jest',\n '@nx/js',\n '@nx/eslint',\n '@nx/webpack',\n '@nx/web',\n '@nx/workspace',\n '@nx/eslint',\n '@nx/module-federation',\n '@nx/rspack',\n 'webpack',\n 'fsevents',\n 'nx',\n ],\n },\n };\n },\n },\n {\n name: 'analogjs-auto-discover-deps',\n async config(config, { command }) {\n const pkgConfig = await crawlFrameworkPkgs({\n root: workspaceRoot,\n isBuild: command === 'build',\n viteUserConfig: config,\n isSemiFrameworkPkgByJson(pkgJson) {\n return pkgJson['module'] && pkgJson['module'].includes('fesm');\n },\n });\n return pkgConfig;\n },\n },\n ];\n}\n"],"mappings":";;;;;AAQA,SAAgB,WAAW,SAA6B;CACtD,MAAM,gBACJ,SAAS,iBAAiB,QAAQ,IAAI,wBAAwB,QAAQ,KAAK;CAC7E,MAAM,cAAc,SAAS,SAAS,QAAQ,KAAA,IAAY,SAAS;AAEnE,QAAO,CACL;EACE,MAAM;EACN,SAAS;GACP,MAAM,2BACJ,SAAS,cAAc,4BACvB,aAAa,cAAc;GAE7B,MAAM,kBACJ,SAAS,SAAS,SAAS,2BACvB,EAAE,GACF,EAAE,SAAS,CAAC,WAAW,UAAU,EAAE;AACzC,iBAAc,yBAAyB;IACrC,0BAA0B,CAAC,CAAC;IAC5B,gBAAgB,yBAAyB;IACzC,mBAAmB,aAAa;IACjC,CAAC;AAEF,UAAO;KACJ,yBAAyB,GAAG;IAC7B,KAAK,EACH,YAAY;KACV;KACA;KACA;KACA;KACA;KACA;KACA;KACD,EACF;IACD,cAAc;KACZ,SAAS;MACP;MACA;MACA,GAAI,OAAO,QAAQ,MAAM,GAAG,KACxB,CAAC,6BAA6B,GAC9B,EAAE;MACN;MACD;KACD,SAAS;MACP;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACD;KACF;IACF;;EAEJ,EACD;EACE,MAAM;EACN,MAAM,OAAO,QAAQ,EAAE,WAAW;AAShC,UARkB,MAAM,mBAAmB;IACzC,MAAM;IACN,SAAS,YAAY;IACrB,gBAAgB;IAChB,yBAAyB,SAAS;AAChC,YAAO,QAAQ,aAAa,QAAQ,UAAU,SAAS,OAAO;;IAEjE,CAAC;;EAGL,CACF"}
@@ -1,9 +1,9 @@
1
1
  export declare const V18_X_NX_DEVKIT = "^20.0.0";
2
2
  export declare const V18_X_NX_ANGULAR = "^20.0.0";
3
- export declare const V18_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.22";
4
- export declare const V18_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.22";
5
- export declare const V18_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.22";
6
- export declare const V18_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.22";
3
+ export declare const V18_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.23";
4
+ export declare const V18_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.23";
5
+ export declare const V18_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.23";
6
+ export declare const V18_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.23";
7
7
  export declare const V18_X_FRONT_MATTER = "^4.0.2";
8
8
  export declare const V18_X_MARKED = "^15.0.7";
9
9
  export declare const V18_X_MARKED_GFM_HEADING_ID = "^4.1.1";
@@ -13,7 +13,7 @@ export declare const V18_X_MERMAID = "^10.2.4";
13
13
  export declare const V18_X_PRISMJS = "^1.29.0";
14
14
  export declare const V18_X_TAILWINDCSS = "^4.2.2";
15
15
  export declare const V18_X_TAILWINDCSS_VITE = "^4.2.2";
16
- export declare const V18_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.22";
16
+ export declare const V18_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.23";
17
17
  export declare const V18_X_ANGULAR_DEVKIT_BUILD_ANGULAR = "^19.0.0";
18
18
  export declare const V18_X_NX_VITE = "^21.0.0";
19
19
  export declare const V18_X_NX_LINTER = "^21.0.0";
@@ -1 +1 @@
1
- {"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../../../../nx-plugin/src/generators/app/versions/nx_18_X/versions.ts"],"sourcesContent":["// V18_X\n// dependencies\nexport const V18_X_NX_DEVKIT = '^20.0.0';\nexport const V18_X_NX_ANGULAR = '^20.0.0';\nexport const V18_X_ANALOG_JS_CONTENT = '^3.0.0-alpha.22';\nexport const V18_X_ANALOG_JS_ROUTER = '^3.0.0-alpha.22';\nexport const V18_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = '^3.0.0-alpha.22';\nexport const V18_X_ANALOG_JS_VITEST_ANGULAR = '^3.0.0-alpha.22';\nexport const V18_X_FRONT_MATTER = '^4.0.2';\nexport const V18_X_MARKED = '^15.0.7';\nexport const V18_X_MARKED_GFM_HEADING_ID = '^4.1.1';\nexport const V18_X_MARKED_HIGHLIGHT = '^2.2.1';\nexport const V18_X_MARKED_MANGLE = '^1.1.10';\nexport const V18_X_MERMAID = '^10.2.4';\nexport const V18_X_PRISMJS = '^1.29.0';\nexport const V18_X_TAILWINDCSS = '^4.2.2';\nexport const V18_X_TAILWINDCSS_VITE = '^4.2.2';\n\n// devDependencies\nexport const V18_X_ANALOG_JS_PLATFORM = '^3.0.0-alpha.22';\nexport const V18_X_ANGULAR_DEVKIT_BUILD_ANGULAR = '^19.0.0';\nexport const V18_X_NX_VITE = '^21.0.0';\nexport const V18_X_NX_LINTER = '^21.0.0';\nexport const V18_X_JSDOM = '^22.1.0';\nexport const V18_X_VITE = '^8.0.0';\nexport const V18_X_VITE_TSCONFIG_PATHS = '^4.2.0';\nexport const V18_X_VITEST = '^4.0.0';\nexport const V18_X_ZOD = '^3.21.4';\n"],"mappings":";AAeA,IAAa,oBAAoB;AACjC,IAAa,yBAAyB"}
1
+ {"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../../../../nx-plugin/src/generators/app/versions/nx_18_X/versions.ts"],"sourcesContent":["// V18_X\n// dependencies\nexport const V18_X_NX_DEVKIT = '^20.0.0';\nexport const V18_X_NX_ANGULAR = '^20.0.0';\nexport const V18_X_ANALOG_JS_CONTENT = '^3.0.0-alpha.23';\nexport const V18_X_ANALOG_JS_ROUTER = '^3.0.0-alpha.23';\nexport const V18_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = '^3.0.0-alpha.23';\nexport const V18_X_ANALOG_JS_VITEST_ANGULAR = '^3.0.0-alpha.23';\nexport const V18_X_FRONT_MATTER = '^4.0.2';\nexport const V18_X_MARKED = '^15.0.7';\nexport const V18_X_MARKED_GFM_HEADING_ID = '^4.1.1';\nexport const V18_X_MARKED_HIGHLIGHT = '^2.2.1';\nexport const V18_X_MARKED_MANGLE = '^1.1.10';\nexport const V18_X_MERMAID = '^10.2.4';\nexport const V18_X_PRISMJS = '^1.29.0';\nexport const V18_X_TAILWINDCSS = '^4.2.2';\nexport const V18_X_TAILWINDCSS_VITE = '^4.2.2';\n\n// devDependencies\nexport const V18_X_ANALOG_JS_PLATFORM = '^3.0.0-alpha.23';\nexport const V18_X_ANGULAR_DEVKIT_BUILD_ANGULAR = '^19.0.0';\nexport const V18_X_NX_VITE = '^21.0.0';\nexport const V18_X_NX_LINTER = '^21.0.0';\nexport const V18_X_JSDOM = '^22.1.0';\nexport const V18_X_VITE = '^8.0.0';\nexport const V18_X_VITE_TSCONFIG_PATHS = '^4.2.0';\nexport const V18_X_VITEST = '^4.0.0';\nexport const V18_X_ZOD = '^3.21.4';\n"],"mappings":";AAeA,IAAa,oBAAoB;AACjC,IAAa,yBAAyB"}
@@ -1,13 +1,13 @@
1
- export declare const V19_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.22";
2
- export declare const V19_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.22";
1
+ export declare const V19_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.23";
2
+ export declare const V19_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.23";
3
3
  export declare const V19_X_MARKED = "^15.0.7";
4
4
  export declare const V19_X_MARKED_GFM_HEADING_ID = "^4.1.1";
5
5
  export declare const V19_X_MARKED_HIGHLIGHT = "^2.2.1";
6
6
  export declare const V19_X_MARKED_MANGLE = "^1.1.10";
7
7
  export declare const V19_X_PRISMJS = "^1.29.0";
8
- export declare const V19_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.22";
9
- export declare const V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.22";
10
- export declare const V19_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.22";
8
+ export declare const V19_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.23";
9
+ export declare const V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.23";
10
+ export declare const V19_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.23";
11
11
  export declare const V19_X_NX_ANGULAR = "^22.0.0";
12
12
  export declare const V19_X_NX_VITE = "^22.0.0";
13
13
  export declare const V19_X_JSDOM = "^22.0.0";
@@ -1,14 +1,14 @@
1
1
  //#region packages/nx-plugin/src/utils/versions/ng_19_X/versions.ts
2
- var V19_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.22";
3
- var V19_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.22";
2
+ var V19_X_ANALOG_JS_ROUTER = "^3.0.0-alpha.23";
3
+ var V19_X_ANALOG_JS_CONTENT = "^3.0.0-alpha.23";
4
4
  var V19_X_MARKED = "^15.0.7";
5
5
  var V19_X_MARKED_GFM_HEADING_ID = "^4.1.1";
6
6
  var V19_X_MARKED_HIGHLIGHT = "^2.2.1";
7
7
  var V19_X_MARKED_MANGLE = "^1.1.10";
8
8
  var V19_X_PRISMJS = "^1.29.0";
9
- var V19_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.22";
10
- var V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.22";
11
- var V19_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.22";
9
+ var V19_X_ANALOG_JS_PLATFORM = "^3.0.0-alpha.23";
10
+ var V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = "^3.0.0-alpha.23";
11
+ var V19_X_ANALOG_JS_VITEST_ANGULAR = "^3.0.0-alpha.23";
12
12
  var V19_X_NX_VITE = "^22.0.0";
13
13
  var V19_X_JSDOM = "^22.0.0";
14
14
  var V19_X_VITE_TSCONFIG_PATHS = "^4.2.0";
@@ -1 +1 @@
1
- {"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../../../nx-plugin/src/utils/versions/ng_19_X/versions.ts"],"sourcesContent":["// V19_X\nexport const V19_X_ANALOG_JS_ROUTER = '^3.0.0-alpha.22';\nexport const V19_X_ANALOG_JS_CONTENT = '^3.0.0-alpha.22';\nexport const V19_X_MARKED = '^15.0.7';\nexport const V19_X_MARKED_GFM_HEADING_ID = '^4.1.1';\nexport const V19_X_MARKED_HIGHLIGHT = '^2.2.1';\nexport const V19_X_MARKED_MANGLE = '^1.1.10';\nexport const V19_X_PRISMJS = '^1.29.0';\n\n// devDependencies\nexport const V19_X_ANALOG_JS_PLATFORM = '^3.0.0-alpha.22';\nexport const V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = '^3.0.0-alpha.22';\nexport const V19_X_ANALOG_JS_VITEST_ANGULAR = '^3.0.0-alpha.22';\nexport const V19_X_NX_ANGULAR = '^22.0.0';\nexport const V19_X_NX_VITE = '^22.0.0';\nexport const V19_X_JSDOM = '^22.0.0';\nexport const V19_X_VITE_TSCONFIG_PATHS = '^4.2.0';\nexport const V19_X_VITEST = '^3.0.0';\nexport const V19_X_VITE = '^6.0.0';\nexport const NX_X_LATEST_VITE = '^8.0.0';\nexport const NX_X_LATEST_VITEST = '^4.0.0';\n"],"mappings":";AACA,IAAa,yBAAyB;AACtC,IAAa,0BAA0B;AACvC,IAAa,eAAe;AAC5B,IAAa,8BAA8B;AAC3C,IAAa,yBAAyB;AACtC,IAAa,sBAAsB;AACnC,IAAa,gBAAgB;AAG7B,IAAa,2BAA2B;AACxC,IAAa,sCAAsC;AACnD,IAAa,iCAAiC;AAE9C,IAAa,gBAAgB;AAC7B,IAAa,cAAc;AAC3B,IAAa,4BAA4B;AACzC,IAAa,eAAe;AAC5B,IAAa,aAAa;AAC1B,IAAa,mBAAmB;AAChC,IAAa,qBAAqB"}
1
+ {"version":3,"file":"versions.js","names":[],"sources":["../../../../../../../../../nx-plugin/src/utils/versions/ng_19_X/versions.ts"],"sourcesContent":["// V19_X\nexport const V19_X_ANALOG_JS_ROUTER = '^3.0.0-alpha.23';\nexport const V19_X_ANALOG_JS_CONTENT = '^3.0.0-alpha.23';\nexport const V19_X_MARKED = '^15.0.7';\nexport const V19_X_MARKED_GFM_HEADING_ID = '^4.1.1';\nexport const V19_X_MARKED_HIGHLIGHT = '^2.2.1';\nexport const V19_X_MARKED_MANGLE = '^1.1.10';\nexport const V19_X_PRISMJS = '^1.29.0';\n\n// devDependencies\nexport const V19_X_ANALOG_JS_PLATFORM = '^3.0.0-alpha.23';\nexport const V19_X_ANALOG_JS_VITE_PLUGIN_ANGULAR = '^3.0.0-alpha.23';\nexport const V19_X_ANALOG_JS_VITEST_ANGULAR = '^3.0.0-alpha.23';\nexport const V19_X_NX_ANGULAR = '^22.0.0';\nexport const V19_X_NX_VITE = '^22.0.0';\nexport const V19_X_JSDOM = '^22.0.0';\nexport const V19_X_VITE_TSCONFIG_PATHS = '^4.2.0';\nexport const V19_X_VITEST = '^3.0.0';\nexport const V19_X_VITE = '^6.0.0';\nexport const NX_X_LATEST_VITE = '^8.0.0';\nexport const NX_X_LATEST_VITEST = '^4.0.0';\n"],"mappings":";AACA,IAAa,yBAAyB;AACtC,IAAa,0BAA0B;AACvC,IAAa,eAAe;AAC5B,IAAa,8BAA8B;AAC3C,IAAa,yBAAyB;AACtC,IAAa,sBAAsB;AACnC,IAAa,gBAAgB;AAG7B,IAAa,2BAA2B;AACxC,IAAa,sCAAsC;AACnD,IAAa,iCAAiC;AAE9C,IAAa,gBAAgB;AAC7B,IAAa,cAAc;AAC3B,IAAa,4BAA4B;AACzC,IAAa,eAAe;AAC5B,IAAa,aAAa;AAC1B,IAAa,mBAAmB;AAChC,IAAa,qBAAqB"}
@@ -2,6 +2,7 @@ import type { PluginOptions } from "@analogjs/vite-plugin-angular";
2
2
  import type { NitroConfig, PrerenderRoute } from "nitro/types";
3
3
  import type { SitemapConfig, SitemapEntry, SitemapExcludeRule, SitemapPriority, SitemapRouteDefinition, SitemapRouteInput, SitemapRouteSource, SitemapTransform, PrerenderContentDir, PrerenderContentFile, PrerenderSitemapConfig, PrerenderRouteConfig } from "@analogjs/vite-plugin-nitro";
4
4
  import type { ContentPluginOptions } from "./content-plugin.js";
5
+ import type { DebugOption } from "./utils/debug.js";
5
6
  declare module "nitro/types" {
6
7
  interface NitroRouteConfig {
7
8
  ssr?: boolean;
@@ -65,6 +66,18 @@ export interface Options {
65
66
  */
66
67
  liveReload?: boolean;
67
68
  /**
69
+ * Enable debug logging for specific scopes.
70
+ *
71
+ * - `true` → enables all `analog:*` scopes (platform + angular + nitro)
72
+ * - `string[]` → enables listed namespaces
73
+ * - `{ scopes?, mode? }` → object form with optional `mode: 'build' | 'dev'`
74
+ * to restrict output to a specific Vite command (omit for both)
75
+ *
76
+ * Also responds to the `DEBUG` env var (Node.js) or `localStorage.debug`
77
+ * (browser), using the `obug` convention.
78
+ */
79
+ debug?: DebugOption;
80
+ /**
68
81
  * Additional page paths to include
69
82
  */
70
83
  additionalPagesDirs?: string[];
@@ -1,3 +1,4 @@
1
+ import { activateDeferredDebug, applyDebugOption, debugPlatform } from "./utils/debug.js";
1
2
  import { discoverLibraryRoutes } from "./discover-library-routes.js";
2
3
  import { routerPlugin } from "./router-plugin.js";
3
4
  import { ssrBuildPlugin } from "./ssr/ssr-build-plugin.js";
@@ -14,6 +15,7 @@ function externalPlugins(plugins) {
14
15
  return plugins;
15
16
  }
16
17
  function platformPlugin(opts = {}) {
18
+ applyDebugOption(opts.debug);
17
19
  const isTest = process.env.NODE_ENV === "test" || !!process.env["VITEST"];
18
20
  const viteOptions = opts?.vite === false ? void 0 : opts?.vite;
19
21
  const { ...platformOptions } = {
@@ -27,6 +29,10 @@ function platformPlugin(opts = {}) {
27
29
  platformOptions.additionalAPIDirs = [...new Set([...platformOptions.additionalAPIDirs ?? [], ...discovered.additionalAPIDirs])];
28
30
  }
29
31
  const useAngularCompilationAPI = platformOptions.experimental?.useAngularCompilationAPI ?? viteOptions?.experimental?.useAngularCompilationAPI;
32
+ debugPlatform("experimental options resolved", {
33
+ useAngularCompilationAPI: !!useAngularCompilationAPI,
34
+ typedRouter: platformOptions.experimental?.typedRouter
35
+ });
30
36
  let nitroOptions = platformOptions?.nitro;
31
37
  if (nitroOptions?.routeRules) nitroOptions = {
32
38
  ...nitroOptions,
@@ -44,6 +50,12 @@ function platformPlugin(opts = {}) {
44
50
  }, nitroOptions.routeRules)
45
51
  };
46
52
  return [
53
+ {
54
+ name: "analogjs-debug-activate",
55
+ config(_, { command }) {
56
+ activateDeferredDebug(command);
57
+ }
58
+ },
47
59
  ...externalPlugins(viteNitroPlugin(platformOptions, nitroOptions)),
48
60
  ...platformOptions.ssr ? [...ssrBuildPlugin(), ...injectHTMLPlugin()] : [],
49
61
  ...!isTest ? depsPlugin(platformOptions) : [],
@@ -59,6 +71,7 @@ function platformPlugin(opts = {}) {
59
71
  liveReload: platformOptions.liveReload,
60
72
  inlineStylesExtension: platformOptions.inlineStylesExtension,
61
73
  fileReplacements: platformOptions.fileReplacements,
74
+ debug: platformOptions.debug,
62
75
  ...viteOptions ?? {},
63
76
  experimental: {
64
77
  ...viteOptions?.experimental ?? {},
@@ -1 +1 @@
1
- {"version":3,"file":"platform-plugin.js","names":[],"sources":["../../../src/lib/platform-plugin.ts"],"sourcesContent":["import { Plugin } from 'vite';\nimport viteNitroPlugin from '@analogjs/vite-plugin-nitro';\nimport angular from '@analogjs/vite-plugin-angular';\n\nimport { Options } from './options.js';\nimport { discoverLibraryRoutes } from './discover-library-routes.js';\nimport { routerPlugin } from './router-plugin.js';\nimport { ssrBuildPlugin } from './ssr/ssr-build-plugin.js';\nimport { contentPlugin } from './content-plugin.js';\nimport { clearClientPageEndpointsPlugin } from './clear-client-page-endpoint.js';\nimport { depsPlugin } from './deps-plugin.js';\nimport { injectHTMLPlugin } from './ssr/inject-html-plugin.js';\nimport { serverModePlugin } from '../server-mode-plugin.js';\nimport { routeGenerationPlugin } from './route-generation-plugin.js';\n\n// Bridge Plugin types from external @analogjs packages that resolve a different vite instance\nfunction externalPlugins(plugins: unknown): Plugin[] {\n return plugins as Plugin[];\n}\n\nexport function platformPlugin(opts: Options = {}): Plugin[] {\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const viteOptions = opts?.vite === false ? undefined : opts?.vite;\n const { ...platformOptions } = {\n ssr: true,\n ...opts,\n };\n if (platformOptions.discoverRoutes) {\n const workspaceRoot =\n platformOptions.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd();\n const discovered = discoverLibraryRoutes(workspaceRoot);\n platformOptions.additionalPagesDirs = [\n ...new Set([\n ...(platformOptions.additionalPagesDirs ?? []),\n ...discovered.additionalPagesDirs,\n ]),\n ];\n platformOptions.additionalContentDirs = [\n ...new Set([\n ...(platformOptions.additionalContentDirs ?? []),\n ...discovered.additionalContentDirs,\n ]),\n ];\n platformOptions.additionalAPIDirs = [\n ...new Set([\n ...(platformOptions.additionalAPIDirs ?? []),\n ...discovered.additionalAPIDirs,\n ]),\n ];\n }\n\n const useAngularCompilationAPI =\n platformOptions.experimental?.useAngularCompilationAPI ??\n viteOptions?.experimental?.useAngularCompilationAPI;\n let nitroOptions = platformOptions?.nitro;\n\n if (nitroOptions?.routeRules) {\n nitroOptions = {\n ...nitroOptions,\n routeRules: Object.keys(nitroOptions.routeRules).reduce(\n (config, curr) => {\n return {\n ...config,\n [curr]: {\n ...config[curr],\n headers: {\n ...config[curr].headers,\n 'x-analog-no-ssr':\n config[curr]?.ssr === false ? 'true' : undefined,\n } as any,\n },\n };\n },\n nitroOptions.routeRules,\n ),\n };\n }\n\n return [\n ...externalPlugins(viteNitroPlugin(platformOptions as any, nitroOptions)),\n ...(platformOptions.ssr\n ? [...ssrBuildPlugin(), ...injectHTMLPlugin()]\n : []),\n ...(!isTest ? depsPlugin(platformOptions) : []),\n ...routerPlugin(platformOptions),\n routeGenerationPlugin(platformOptions),\n ...contentPlugin(platformOptions?.content, platformOptions),\n ...(opts?.vite === false\n ? []\n : externalPlugins(\n angular({\n jit: platformOptions.jit,\n workspaceRoot: platformOptions.workspaceRoot,\n // Let the Angular plugin keep its own dev-friendly default unless the\n // app explicitly opts into stricter serve-time diagnostics.\n disableTypeChecking: platformOptions.disableTypeChecking,\n include: [\n ...(platformOptions.include ?? []),\n ...(platformOptions.additionalPagesDirs ?? []).map(\n (pageDir) => `${pageDir}/**/*.page.ts`,\n ),\n ],\n additionalContentDirs: platformOptions.additionalContentDirs,\n liveReload: platformOptions.liveReload,\n inlineStylesExtension: platformOptions.inlineStylesExtension,\n fileReplacements: platformOptions.fileReplacements,\n ...(viteOptions ?? {}),\n experimental: {\n ...(viteOptions?.experimental ?? {}),\n useAngularCompilationAPI,\n },\n }),\n )),\n ...serverModePlugin(),\n ...clearClientPageEndpointsPlugin(),\n ];\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAS,gBAAgB,SAA4B;AACnD,QAAO;;AAGT,SAAgB,eAAe,OAAgB,EAAE,EAAY;CAC3D,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,cAAc,MAAM,SAAS,QAAQ,KAAA,IAAY,MAAM;CAC7D,MAAM,EAAE,GAAG,oBAAoB;EAC7B,KAAK;EACL,GAAG;EACJ;AACD,KAAI,gBAAgB,gBAAgB;EAKlC,MAAM,aAAa,sBAHjB,gBAAgB,iBAChB,QAAQ,IAAI,wBACZ,QAAQ,KAAK,CACwC;AACvD,kBAAgB,sBAAsB,CACpC,GAAG,IAAI,IAAI,CACT,GAAI,gBAAgB,uBAAuB,EAAE,EAC7C,GAAG,WAAW,oBACf,CAAC,CACH;AACD,kBAAgB,wBAAwB,CACtC,GAAG,IAAI,IAAI,CACT,GAAI,gBAAgB,yBAAyB,EAAE,EAC/C,GAAG,WAAW,sBACf,CAAC,CACH;AACD,kBAAgB,oBAAoB,CAClC,GAAG,IAAI,IAAI,CACT,GAAI,gBAAgB,qBAAqB,EAAE,EAC3C,GAAG,WAAW,kBACf,CAAC,CACH;;CAGH,MAAM,2BACJ,gBAAgB,cAAc,4BAC9B,aAAa,cAAc;CAC7B,IAAI,eAAe,iBAAiB;AAEpC,KAAI,cAAc,WAChB,gBAAe;EACb,GAAG;EACH,YAAY,OAAO,KAAK,aAAa,WAAW,CAAC,QAC9C,QAAQ,SAAS;AAChB,UAAO;IACL,GAAG;KACF,OAAO;KACN,GAAG,OAAO;KACV,SAAS;MACP,GAAG,OAAO,MAAM;MAChB,mBACE,OAAO,OAAO,QAAQ,QAAQ,SAAS,KAAA;MAC1C;KACF;IACF;KAEH,aAAa,WACd;EACF;AAGH,QAAO;EACL,GAAG,gBAAgB,gBAAgB,iBAAwB,aAAa,CAAC;EACzE,GAAI,gBAAgB,MAChB,CAAC,GAAG,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,GAC5C,EAAE;EACN,GAAI,CAAC,SAAS,WAAW,gBAAgB,GAAG,EAAE;EAC9C,GAAG,aAAa,gBAAgB;EAChC,sBAAsB,gBAAgB;EACtC,GAAG,cAAc,iBAAiB,SAAS,gBAAgB;EAC3D,GAAI,MAAM,SAAS,QACf,EAAE,GACF,gBACE,QAAQ;GACN,KAAK,gBAAgB;GACrB,eAAe,gBAAgB;GAG/B,qBAAqB,gBAAgB;GACrC,SAAS,CACP,GAAI,gBAAgB,WAAW,EAAE,EACjC,IAAI,gBAAgB,uBAAuB,EAAE,EAAE,KAC5C,YAAY,GAAG,QAAQ,eACzB,CACF;GACD,uBAAuB,gBAAgB;GACvC,YAAY,gBAAgB;GAC5B,uBAAuB,gBAAgB;GACvC,kBAAkB,gBAAgB;GAClC,GAAI,eAAe,EAAE;GACrB,cAAc;IACZ,GAAI,aAAa,gBAAgB,EAAE;IACnC;IACD;GACF,CAAC,CACH;EACL,GAAG,kBAAkB;EACrB,GAAG,gCAAgC;EACpC"}
1
+ {"version":3,"file":"platform-plugin.js","names":[],"sources":["../../../src/lib/platform-plugin.ts"],"sourcesContent":["import { Plugin } from 'vite';\nimport viteNitroPlugin from '@analogjs/vite-plugin-nitro';\nimport angular from '@analogjs/vite-plugin-angular';\n\nimport { Options } from './options.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugPlatform,\n} from './utils/debug.js';\nimport { discoverLibraryRoutes } from './discover-library-routes.js';\nimport { routerPlugin } from './router-plugin.js';\nimport { ssrBuildPlugin } from './ssr/ssr-build-plugin.js';\nimport { contentPlugin } from './content-plugin.js';\nimport { clearClientPageEndpointsPlugin } from './clear-client-page-endpoint.js';\nimport { depsPlugin } from './deps-plugin.js';\nimport { injectHTMLPlugin } from './ssr/inject-html-plugin.js';\nimport { serverModePlugin } from '../server-mode-plugin.js';\nimport { routeGenerationPlugin } from './route-generation-plugin.js';\n\n// Bridge Plugin types from external @analogjs packages that resolve a different vite instance\nfunction externalPlugins(plugins: unknown): Plugin[] {\n return plugins as Plugin[];\n}\n\nexport function platformPlugin(opts: Options = {}): Plugin[] {\n applyDebugOption(opts.debug);\n\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const viteOptions = opts?.vite === false ? undefined : opts?.vite;\n const { ...platformOptions } = {\n ssr: true,\n ...opts,\n };\n if (platformOptions.discoverRoutes) {\n const workspaceRoot =\n platformOptions.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd();\n const discovered = discoverLibraryRoutes(workspaceRoot);\n platformOptions.additionalPagesDirs = [\n ...new Set([\n ...(platformOptions.additionalPagesDirs ?? []),\n ...discovered.additionalPagesDirs,\n ]),\n ];\n platformOptions.additionalContentDirs = [\n ...new Set([\n ...(platformOptions.additionalContentDirs ?? []),\n ...discovered.additionalContentDirs,\n ]),\n ];\n platformOptions.additionalAPIDirs = [\n ...new Set([\n ...(platformOptions.additionalAPIDirs ?? []),\n ...discovered.additionalAPIDirs,\n ]),\n ];\n }\n\n const useAngularCompilationAPI =\n platformOptions.experimental?.useAngularCompilationAPI ??\n viteOptions?.experimental?.useAngularCompilationAPI;\n debugPlatform('experimental options resolved', {\n useAngularCompilationAPI: !!useAngularCompilationAPI,\n typedRouter: platformOptions.experimental?.typedRouter,\n });\n let nitroOptions = platformOptions?.nitro;\n\n if (nitroOptions?.routeRules) {\n nitroOptions = {\n ...nitroOptions,\n routeRules: Object.keys(nitroOptions.routeRules).reduce(\n (config, curr) => {\n return {\n ...config,\n [curr]: {\n ...config[curr],\n headers: {\n ...config[curr].headers,\n 'x-analog-no-ssr':\n config[curr]?.ssr === false ? 'true' : undefined,\n } as any,\n },\n };\n },\n nitroOptions.routeRules,\n ),\n };\n }\n\n return [\n {\n name: 'analogjs-debug-activate',\n config(_, { command }) {\n activateDeferredDebug(command);\n },\n },\n ...externalPlugins(viteNitroPlugin(platformOptions as any, nitroOptions)),\n ...(platformOptions.ssr\n ? [...ssrBuildPlugin(), ...injectHTMLPlugin()]\n : []),\n ...(!isTest ? depsPlugin(platformOptions) : []),\n ...routerPlugin(platformOptions),\n routeGenerationPlugin(platformOptions),\n ...contentPlugin(platformOptions?.content, platformOptions),\n ...(opts?.vite === false\n ? []\n : externalPlugins(\n angular({\n jit: platformOptions.jit,\n workspaceRoot: platformOptions.workspaceRoot,\n // Let the Angular plugin keep its own dev-friendly default unless the\n // app explicitly opts into stricter serve-time diagnostics.\n disableTypeChecking: platformOptions.disableTypeChecking,\n include: [\n ...(platformOptions.include ?? []),\n ...(platformOptions.additionalPagesDirs ?? []).map(\n (pageDir) => `${pageDir}/**/*.page.ts`,\n ),\n ],\n additionalContentDirs: platformOptions.additionalContentDirs,\n liveReload: platformOptions.liveReload,\n inlineStylesExtension: platformOptions.inlineStylesExtension,\n fileReplacements: platformOptions.fileReplacements,\n debug: platformOptions.debug,\n ...(viteOptions ?? {}),\n experimental: {\n ...(viteOptions?.experimental ?? {}),\n useAngularCompilationAPI,\n },\n }),\n )),\n ...serverModePlugin(),\n ...clearClientPageEndpointsPlugin(),\n ];\n}\n"],"mappings":";;;;;;;;;;;;;AAqBA,SAAS,gBAAgB,SAA4B;AACnD,QAAO;;AAGT,SAAgB,eAAe,OAAgB,EAAE,EAAY;AAC3D,kBAAiB,KAAK,MAAM;CAE5B,MAAM,SAAA,QAAA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,CAAC,GAAG,gBAAgB,EAAE,GAAG,kBAAkB,CAAC,GAC5C,EAAE;EACN,GAAI,CAAC,SAAS,WAAW,gBAAgB,GAAG,EAAE;EAC9C,GAAG,aAAa,gBAAgB;EAChC,sBAAsB,gBAAgB;EACtC,GAAG,cAAc,iBAAiB,SAAS,gBAAgB;EAC3D,GAAI,MAAM,SAAS,QACf,EAAE,GACF,gBACE,QAAQ;GACN,KAAK,gBAAgB;GACrB,eAAe,gBAAgB;GAG/B,qBAAqB,gBAAgB;GACrC,SAAS,CACP,GAAI,gBAAgB,WAAW,EAAE,EACjC,IAAI,gBAAgB,uBAAuB,EAAE,EAAE,KAC5C,YAAY,GAAG,QAAQ,eACzB,CACF;GACD,uBAAuB,gBAAgB;GACvC,YAAY,gBAAgB;GAC5B,uBAAuB,gBAAgB;GACvC,kBAAkB,gBAAgB;GAClC,OAAO,gBAAgB;GACvB,GAAI,eAAe,EAAE;GACrB,cAAc;IACZ,GAAI,aAAa,gBAAgB,EAAE;IACnC;IACD;GACF,CAAC,CACH;EACL,GAAG,kBAAkB;EACrB,GAAG,gCAAgC;EACpC"}
@@ -1,3 +1,4 @@
1
+ import { debugTypedRouter } from "./utils/debug.js";
1
2
  import { typedRoutes } from "./typed-routes-plugin.js";
2
3
  //#region packages/platform/src/lib/route-generation-plugin.ts
3
4
  function resolveTypedRouterOptions(experimental) {
@@ -20,13 +21,23 @@ function resolveTypedRouterOptions(experimental) {
20
21
  }
21
22
  function routeGenerationPlugin(options) {
22
23
  const { enabled, options: typedRouterOptions } = resolveTypedRouterOptions(options?.experimental);
23
- if (!enabled) return { name: "analog-route-generation-disabled" };
24
- return typedRoutes({
24
+ if (!enabled) {
25
+ debugTypedRouter("disabled by experimental.typedRouter === false");
26
+ return { name: "analog-route-generation-disabled" };
27
+ }
28
+ const pluginOptions = {
25
29
  ...typedRouterOptions,
26
30
  workspaceRoot: options?.workspaceRoot,
27
31
  additionalPagesDirs: options?.additionalPagesDirs,
28
32
  additionalContentDirs: options?.additionalContentDirs
33
+ };
34
+ debugTypedRouter("enabled", {
35
+ outFile: pluginOptions.outFile,
36
+ jsonLdManifest: pluginOptions.jsonLdManifest,
37
+ additionalPagesDirs: pluginOptions.additionalPagesDirs,
38
+ additionalContentDirs: pluginOptions.additionalContentDirs
29
39
  });
40
+ return typedRoutes(pluginOptions);
30
41
  }
31
42
  //#endregion
32
43
  export { routeGenerationPlugin };
@@ -1 +1 @@
1
- {"version":3,"file":"route-generation-plugin.js","names":[],"sources":["../../../src/lib/route-generation-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\nimport type { Options, TypedRouterOptions } from './options.js';\nimport {\n typedRoutes,\n type TypedRoutesPluginOptions,\n} from './typed-routes-plugin.js';\n\nfunction resolveTypedRouterOptions(experimental: Options['experimental']): {\n enabled: boolean;\n options: TypedRouterOptions;\n} {\n const typedRouter = experimental?.typedRouter;\n if (typedRouter === false) {\n return { enabled: false, options: {} };\n }\n if (!typedRouter || typedRouter === true) {\n return { enabled: true, options: { jsonLdManifest: true } };\n }\n return {\n enabled: true,\n options: {\n ...typedRouter,\n jsonLdManifest: typedRouter.jsonLdManifest ?? true,\n },\n };\n}\n\nexport function routeGenerationPlugin(options?: Options): Plugin {\n const { enabled, options: typedRouterOptions } = resolveTypedRouterOptions(\n options?.experimental,\n );\n\n if (!enabled) {\n return {\n name: 'analog-route-generation-disabled',\n };\n }\n\n const pluginOptions: TypedRoutesPluginOptions = {\n ...typedRouterOptions,\n workspaceRoot: options?.workspaceRoot,\n additionalPagesDirs: options?.additionalPagesDirs,\n additionalContentDirs: options?.additionalContentDirs,\n };\n\n return typedRoutes(pluginOptions);\n}\n"],"mappings":";;AAQA,SAAS,0BAA0B,cAGjC;CACA,MAAM,cAAc,cAAc;AAClC,KAAI,gBAAgB,MAClB,QAAO;EAAE,SAAS;EAAO,SAAS,EAAE;EAAE;AAExC,KAAI,CAAC,eAAe,gBAAgB,KAClC,QAAO;EAAE,SAAS;EAAM,SAAS,EAAE,gBAAgB,MAAM;EAAE;AAE7D,QAAO;EACL,SAAS;EACT,SAAS;GACP,GAAG;GACH,gBAAgB,YAAY,kBAAkB;GAC/C;EACF;;AAGH,SAAgB,sBAAsB,SAA2B;CAC/D,MAAM,EAAE,SAAS,SAAS,uBAAuB,0BAC/C,SAAS,aACV;AAED,KAAI,CAAC,QACH,QAAO,EACL,MAAM,oCACP;AAUH,QAAO,YAPyC;EAC9C,GAAG;EACH,eAAe,SAAS;EACxB,qBAAqB,SAAS;EAC9B,uBAAuB,SAAS;EACjC,CAEgC"}
1
+ {"version":3,"file":"route-generation-plugin.js","names":[],"sources":["../../../src/lib/route-generation-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\n\nimport type { Options, TypedRouterOptions } from './options.js';\nimport {\n typedRoutes,\n type TypedRoutesPluginOptions,\n} from './typed-routes-plugin.js';\nimport { debugTypedRouter } from './utils/debug.js';\n\nfunction resolveTypedRouterOptions(experimental: Options['experimental']): {\n enabled: boolean;\n options: TypedRouterOptions;\n} {\n const typedRouter = experimental?.typedRouter;\n if (typedRouter === false) {\n return { enabled: false, options: {} };\n }\n if (!typedRouter || typedRouter === true) {\n return { enabled: true, options: { jsonLdManifest: true } };\n }\n return {\n enabled: true,\n options: {\n ...typedRouter,\n jsonLdManifest: typedRouter.jsonLdManifest ?? true,\n },\n };\n}\n\nexport function routeGenerationPlugin(options?: Options): Plugin {\n const { enabled, options: typedRouterOptions } = resolveTypedRouterOptions(\n options?.experimental,\n );\n\n if (!enabled) {\n debugTypedRouter('disabled by experimental.typedRouter === false');\n return {\n name: 'analog-route-generation-disabled',\n };\n }\n\n const pluginOptions: TypedRoutesPluginOptions = {\n ...typedRouterOptions,\n workspaceRoot: options?.workspaceRoot,\n additionalPagesDirs: options?.additionalPagesDirs,\n additionalContentDirs: options?.additionalContentDirs,\n };\n debugTypedRouter('enabled', {\n outFile: pluginOptions.outFile,\n jsonLdManifest: pluginOptions.jsonLdManifest,\n additionalPagesDirs: pluginOptions.additionalPagesDirs,\n additionalContentDirs: pluginOptions.additionalContentDirs,\n });\n\n return typedRoutes(pluginOptions);\n}\n"],"mappings":";;;AASA,SAAS,0BAA0B,cAGjC;CACA,MAAM,cAAc,cAAc;AAClC,KAAI,gBAAgB,MAClB,QAAO;EAAE,SAAS;EAAO,SAAS,EAAE;EAAE;AAExC,KAAI,CAAC,eAAe,gBAAgB,KAClC,QAAO;EAAE,SAAS;EAAM,SAAS,EAAE,gBAAgB,MAAM;EAAE;AAE7D,QAAO;EACL,SAAS;EACT,SAAS;GACP,GAAG;GACH,gBAAgB,YAAY,kBAAkB;GAC/C;EACF;;AAGH,SAAgB,sBAAsB,SAA2B;CAC/D,MAAM,EAAE,SAAS,SAAS,uBAAuB,0BAC/C,SAAS,aACV;AAED,KAAI,CAAC,SAAS;AACZ,mBAAiB,iDAAiD;AAClE,SAAO,EACL,MAAM,oCACP;;CAGH,MAAM,gBAA0C;EAC9C,GAAG;EACH,eAAe,SAAS;EACxB,qBAAqB,SAAS;EAC9B,uBAAuB,SAAS;EACjC;AACD,kBAAiB,WAAW;EAC1B,SAAS,cAAc;EACvB,gBAAgB,cAAc;EAC9B,qBAAqB,cAAc;EACnC,uBAAuB,cAAc;EACtC,CAAC;AAEF,QAAO,YAAY,cAAc"}
@@ -1,3 +1,4 @@
1
+ import { debugTailwind } from "./utils/debug.js";
1
2
  import { readFileSync } from "node:fs";
2
3
  import path from "node:path";
3
4
  //#region packages/platform/src/lib/tailwind-preprocessor.ts
@@ -9,15 +10,38 @@ import path from "node:path";
9
10
  function tailwindPreprocessor(options) {
10
11
  const { tailwindRootCss, mode: modeOption = "auto", shouldInject } = options;
11
12
  let rootPrefix;
13
+ debugTailwind("configured", {
14
+ tailwindRootCss,
15
+ mode: modeOption
16
+ });
12
17
  return (code, filename) => {
13
- if (code.includes("@reference")) return code;
18
+ if (code.includes("@reference")) {
19
+ debugTailwind("skip (already has @reference)", { filename });
20
+ return code;
21
+ }
14
22
  const resolvedMode = typeof modeOption === "function" ? modeOption(filename) : modeOption;
15
- if (resolvedMode === "disabled") return code;
23
+ if (resolvedMode === "disabled") {
24
+ debugTailwind("skip (mode disabled)", { filename });
25
+ return code;
26
+ }
16
27
  const resolvedPrefix = typeof resolvedMode === "object" ? resolvedMode.prefix : getRootPrefix();
17
28
  const isRootFile = path.resolve(filename) === path.resolve(tailwindRootCss) || /@import\s+["']tailwindcss["']/.test(code);
18
29
  const hasTailwindUsage = resolvedPrefix ? code.includes(`${resolvedPrefix}:`) : false;
19
- if (!(shouldInject ? shouldInject(code, filename, resolvedPrefix) : hasTailwindUsage && !isRootFile) || !resolvedPrefix) return code;
20
- return `@reference "${path.relative(path.dirname(filename), tailwindRootCss).replace(/\\/g, "/")}";\n${code}`;
30
+ if (!(shouldInject ? shouldInject(code, filename, resolvedPrefix) : hasTailwindUsage && !isRootFile) || !resolvedPrefix) {
31
+ debugTailwind("skip (no injection needed)", {
32
+ filename,
33
+ resolvedPrefix,
34
+ isRootFile,
35
+ hasTailwindUsage
36
+ });
37
+ return code;
38
+ }
39
+ const refPath = path.relative(path.dirname(filename), tailwindRootCss).replace(/\\/g, "/");
40
+ debugTailwind("injected @reference", {
41
+ filename,
42
+ refPath
43
+ });
44
+ return `@reference "${refPath}";\n${code}`;
21
45
  };
22
46
  function getRootPrefix() {
23
47
  if (rootPrefix === void 0) rootPrefix = extractTailwindPrefix(readFileSync(tailwindRootCss, "utf-8"));
@@ -1 +1 @@
1
- {"version":3,"file":"tailwind-preprocessor.js","names":[],"sources":["../../../src/lib/tailwind-preprocessor.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport path from 'node:path';\n\nimport type { StylePreprocessor } from '@analogjs/vite-plugin-angular';\n\nexport type TailwindPreprocessorMode = 'auto' | 'disabled' | { prefix: string };\n\nexport interface TailwindPreprocessorOptions {\n /** Absolute path to the Tailwind root CSS file that imports `tailwindcss`. */\n tailwindRootCss: string;\n\n /**\n * Controls whether the preprocessor auto-detects, disables, or manually\n * overrides the Tailwind prefix for a given file.\n */\n mode?:\n | TailwindPreprocessorMode\n | ((filename: string) => TailwindPreprocessorMode);\n\n /**\n * Optional predicate to override the default `@reference` injection behavior.\n */\n shouldInject?: (\n code: string,\n filename: string,\n resolvedPrefix: string | null,\n ) => boolean;\n}\n\n/**\n * Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`\n * directives into Angular component styles when needed. The Tailwind prefix is\n * detected from the configured root CSS file.\n */\nexport function tailwindPreprocessor(\n options: TailwindPreprocessorOptions,\n): StylePreprocessor {\n const { tailwindRootCss, mode: modeOption = 'auto', shouldInject } = options;\n let rootPrefix: string | undefined;\n\n return (code: string, filename: string): string => {\n if (code.includes('@reference')) {\n return code;\n }\n\n const resolvedMode =\n typeof modeOption === 'function' ? modeOption(filename) : modeOption;\n\n if (resolvedMode === 'disabled') {\n return code;\n }\n\n const resolvedPrefix =\n typeof resolvedMode === 'object' ? resolvedMode.prefix : getRootPrefix();\n const isRootFile =\n path.resolve(filename) === path.resolve(tailwindRootCss) ||\n /@import\\s+[\"']tailwindcss[\"']/.test(code);\n const hasTailwindUsage = resolvedPrefix\n ? code.includes(`${resolvedPrefix}:`)\n : false;\n const shouldAddReference = shouldInject\n ? shouldInject(code, filename, resolvedPrefix)\n : hasTailwindUsage && !isRootFile;\n\n if (!shouldAddReference || !resolvedPrefix) {\n return code;\n }\n\n const refPath = path\n .relative(path.dirname(filename), tailwindRootCss)\n .replace(/\\\\/g, '/');\n\n return `@reference \"${refPath}\";\\n${code}`;\n };\n\n function getRootPrefix(): string | null {\n if (rootPrefix === undefined) {\n rootPrefix = extractTailwindPrefix(\n readFileSync(tailwindRootCss, 'utf-8'),\n );\n }\n\n return rootPrefix;\n }\n}\n\nfunction extractTailwindPrefix(code: string): string | null {\n const prefixMatch = code.match(\n /@import\\s+[\"']tailwindcss[\"']\\s+prefix\\(\\s*([^)\\s;]+)\\s*\\)/i,\n );\n\n return prefixMatch?.[1]?.trim() ?? null;\n}\n"],"mappings":";;;;;;;;AAkCA,SAAgB,qBACd,SACmB;CACnB,MAAM,EAAE,iBAAiB,MAAM,aAAa,QAAQ,iBAAiB;CACrE,IAAI;AAEJ,SAAQ,MAAc,aAA6B;AACjD,MAAI,KAAK,SAAS,aAAa,CAC7B,QAAO;EAGT,MAAM,eACJ,OAAO,eAAe,aAAa,WAAW,SAAS,GAAG;AAE5D,MAAI,iBAAiB,WACnB,QAAO;EAGT,MAAM,iBACJ,OAAO,iBAAiB,WAAW,aAAa,SAAS,eAAe;EAC1E,MAAM,aACJ,KAAK,QAAQ,SAAS,KAAK,KAAK,QAAQ,gBAAgB,IACxD,gCAAgC,KAAK,KAAK;EAC5C,MAAM,mBAAmB,iBACrB,KAAK,SAAS,GAAG,eAAe,GAAG,GACnC;AAKJ,MAAI,EAJuB,eACvB,aAAa,MAAM,UAAU,eAAe,GAC5C,oBAAoB,CAAC,eAEE,CAAC,eAC1B,QAAO;AAOT,SAAO,eAJS,KACb,SAAS,KAAK,QAAQ,SAAS,EAAE,gBAAgB,CACjD,QAAQ,OAAO,IAAI,CAEQ,MAAM;;CAGtC,SAAS,gBAA+B;AACtC,MAAI,eAAe,KAAA,EACjB,cAAa,sBACX,aAAa,iBAAiB,QAAQ,CACvC;AAGH,SAAO;;;AAIX,SAAS,sBAAsB,MAA6B;AAK1D,QAJoB,KAAK,MACvB,8DACD,GAEoB,IAAI,MAAM,IAAI"}
1
+ {"version":3,"file":"tailwind-preprocessor.js","names":[],"sources":["../../../src/lib/tailwind-preprocessor.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport path from 'node:path';\n\nimport type { StylePreprocessor } from '@analogjs/vite-plugin-angular';\nimport { debugTailwind } from './utils/debug.js';\n\nexport type TailwindPreprocessorMode = 'auto' | 'disabled' | { prefix: string };\n\nexport interface TailwindPreprocessorOptions {\n /** Absolute path to the Tailwind root CSS file that imports `tailwindcss`. */\n tailwindRootCss: string;\n\n /**\n * Controls whether the preprocessor auto-detects, disables, or manually\n * overrides the Tailwind prefix for a given file.\n */\n mode?:\n | TailwindPreprocessorMode\n | ((filename: string) => TailwindPreprocessorMode);\n\n /**\n * Optional predicate to override the default `@reference` injection behavior.\n */\n shouldInject?: (\n code: string,\n filename: string,\n resolvedPrefix: string | null,\n ) => boolean;\n}\n\n/**\n * Creates a stylesheet preprocessor that injects Tailwind v4 `@reference`\n * directives into Angular component styles when needed. The Tailwind prefix is\n * detected from the configured root CSS file.\n */\nexport function tailwindPreprocessor(\n options: TailwindPreprocessorOptions,\n): StylePreprocessor {\n const { tailwindRootCss, mode: modeOption = 'auto', shouldInject } = options;\n let rootPrefix: string | undefined;\n\n debugTailwind('configured', { tailwindRootCss, mode: modeOption });\n\n return (code: string, filename: string): string => {\n if (code.includes('@reference')) {\n debugTailwind('skip (already has @reference)', { filename });\n return code;\n }\n\n const resolvedMode =\n typeof modeOption === 'function' ? modeOption(filename) : modeOption;\n\n if (resolvedMode === 'disabled') {\n debugTailwind('skip (mode disabled)', { filename });\n return code;\n }\n\n const resolvedPrefix =\n typeof resolvedMode === 'object' ? resolvedMode.prefix : getRootPrefix();\n const isRootFile =\n path.resolve(filename) === path.resolve(tailwindRootCss) ||\n /@import\\s+[\"']tailwindcss[\"']/.test(code);\n const hasTailwindUsage = resolvedPrefix\n ? code.includes(`${resolvedPrefix}:`)\n : false;\n const shouldAddReference = shouldInject\n ? shouldInject(code, filename, resolvedPrefix)\n : hasTailwindUsage && !isRootFile;\n\n if (!shouldAddReference || !resolvedPrefix) {\n debugTailwind('skip (no injection needed)', {\n filename,\n resolvedPrefix,\n isRootFile,\n hasTailwindUsage,\n });\n return code;\n }\n\n const refPath = path\n .relative(path.dirname(filename), tailwindRootCss)\n .replace(/\\\\/g, '/');\n debugTailwind('injected @reference', { filename, refPath });\n\n return `@reference \"${refPath}\";\\n${code}`;\n };\n\n function getRootPrefix(): string | null {\n if (rootPrefix === undefined) {\n rootPrefix = extractTailwindPrefix(\n readFileSync(tailwindRootCss, 'utf-8'),\n );\n }\n\n return rootPrefix;\n }\n}\n\nfunction extractTailwindPrefix(code: string): string | null {\n const prefixMatch = code.match(\n /@import\\s+[\"']tailwindcss[\"']\\s+prefix\\(\\s*([^)\\s;]+)\\s*\\)/i,\n );\n\n return prefixMatch?.[1]?.trim() ?? null;\n}\n"],"mappings":";;;;;;;;;AAmCA,SAAgB,qBACd,SACmB;CACnB,MAAM,EAAE,iBAAiB,MAAM,aAAa,QAAQ,iBAAiB;CACrE,IAAI;AAEJ,eAAc,cAAc;EAAE;EAAiB,MAAM;EAAY,CAAC;AAElE,SAAQ,MAAc,aAA6B;AACjD,MAAI,KAAK,SAAS,aAAa,EAAE;AAC/B,iBAAc,iCAAiC,EAAE,UAAU,CAAC;AAC5D,UAAO;;EAGT,MAAM,eACJ,OAAO,eAAe,aAAa,WAAW,SAAS,GAAG;AAE5D,MAAI,iBAAiB,YAAY;AAC/B,iBAAc,wBAAwB,EAAE,UAAU,CAAC;AACnD,UAAO;;EAGT,MAAM,iBACJ,OAAO,iBAAiB,WAAW,aAAa,SAAS,eAAe;EAC1E,MAAM,aACJ,KAAK,QAAQ,SAAS,KAAK,KAAK,QAAQ,gBAAgB,IACxD,gCAAgC,KAAK,KAAK;EAC5C,MAAM,mBAAmB,iBACrB,KAAK,SAAS,GAAG,eAAe,GAAG,GACnC;AAKJ,MAAI,EAJuB,eACvB,aAAa,MAAM,UAAU,eAAe,GAC5C,oBAAoB,CAAC,eAEE,CAAC,gBAAgB;AAC1C,iBAAc,8BAA8B;IAC1C;IACA;IACA;IACA;IACD,CAAC;AACF,UAAO;;EAGT,MAAM,UAAU,KACb,SAAS,KAAK,QAAQ,SAAS,EAAE,gBAAgB,CACjD,QAAQ,OAAO,IAAI;AACtB,gBAAc,uBAAuB;GAAE;GAAU;GAAS,CAAC;AAE3D,SAAO,eAAe,QAAQ,MAAM;;CAGtC,SAAS,gBAA+B;AACtC,MAAI,eAAe,KAAA,EACjB,cAAa,sBACX,aAAa,iBAAiB,QAAQ,CACvC;AAGH,SAAO;;;AAIX,SAAS,sBAAsB,MAA6B;AAK1D,QAJoB,KAAK,MACvB,8DACD,GAEoB,IAAI,MAAM,IAAI"}
@@ -1,3 +1,4 @@
1
+ import { debugTypedRouter } from "./utils/debug.js";
1
2
  import { detectSchemaExports, filenameToRoutePath, formatManifestSummary, generateRouteManifest, generateRouteTableDeclaration, generateRouteTreeDeclaration } from "./route-manifest.js";
2
3
  import { detectJsonLdModuleExports, extractMarkdownJsonLd, generateJsonLdManifestSource } from "./json-ld-manifest-plugin.js";
3
4
  import { createRouteFileDiscovery } from "./route-file-discovery.js";
@@ -83,12 +84,25 @@ function typedRoutes(options = {}) {
83
84
  function generate() {
84
85
  const routeFiles = discovery.getRouteFiles();
85
86
  const contentFiles = discovery.getContentFiles();
87
+ debugTypedRouter("discovered files", {
88
+ routeFiles: routeFiles.length,
89
+ contentFiles: contentFiles.length
90
+ });
86
91
  const manifest = generateRouteManifest([...routeFiles, ...contentFiles], detectSchemas, (filename) => discovery.isAppLocal(filename) ? 0 : 1);
87
92
  const declaration = generateRouteTableDeclaration(manifest);
88
93
  const canonicalFiles = new Set(manifest.routes.map((route) => route.filename));
89
94
  const jsonLdEntries = buildJsonLdEntries(resolveDiscoveredFile, routeFiles.filter((filename) => canonicalFiles.has(filename)), contentFiles.filter((filename) => canonicalFiles.has(filename)));
90
95
  const output = combineGeneratedModules(declaration, generateRouteTreeDeclaration(manifest, { jsonLdFiles: jsonLdEntries.map((entry) => entry.sourceFile) }), resolvedOptions.jsonLdManifest && jsonLdEntries.length > 0 ? generateJsonLdManifestSource(jsonLdEntries, resolvedOptions.outFile) : "");
91
96
  const hardCollisions = manifest.collisions.filter((c) => c.samePriority);
97
+ if (manifest.collisions.length > 0) debugTypedRouter("route collisions", {
98
+ total: manifest.collisions.length,
99
+ hard: hardCollisions.length,
100
+ collisions: manifest.collisions.map((c) => ({
101
+ path: c.fullPath,
102
+ kept: c.keptFile,
103
+ dropped: c.droppedFile
104
+ }))
105
+ });
92
106
  if (hardCollisions.length > 0 && command === "build") {
93
107
  const details = hardCollisions.map((c) => ` '${c.fullPath}': '${c.keptFile}' vs '${c.droppedFile}'`).join("\n");
94
108
  throw new Error(`[analog] Route collisions detected during build:\n${details}\n\nEach route path must be defined by exactly one source file. Remove or rename the conflicting files to resolve the collision.`);
@@ -105,6 +119,13 @@ function typedRoutes(options = {}) {
105
119
  if (output.includes(root)) console.warn(`[analog] Generated route output contains an absolute path prefix (${root}). Route keys and sourceFile values should be workspace-relative.`);
106
120
  const normalizeEndings = (s) => s.replace(/\r\n/g, "\n");
107
121
  if (normalizeEndings(existing) !== normalizeEndings(output)) {
122
+ debugTypedRouter("route file changed", {
123
+ outFile: resolvedOptions.outFile,
124
+ routes: manifest.routes.length,
125
+ verify: resolvedOptions.verify,
126
+ verifyOnBuild: resolvedOptions.verifyOnBuild,
127
+ command
128
+ });
108
129
  if (resolvedOptions.verify) throw new Error(`[analog] Stale route file detected: ${resolvedOptions.outFile}\nThe checked-in generated route file does not match the current route sources.\nRegenerate route files and commit the updated output.`);
109
130
  writeFileSync(outPath, output, "utf-8");
110
131
  if (command === "build" && resolvedOptions.verifyOnBuild && hadExistingOutput) throw new Error(`[analog] Stale route file detected during build: ${resolvedOptions.outFile}\nThe generated route file was updated to match the current route sources.\nReview the updated output, commit it if it is checked in, and rerun the build.`);
@@ -129,6 +150,10 @@ function typedRoutes(options = {}) {
129
150
  configureServer(server) {
130
151
  const regenerate = (path, event) => {
131
152
  if (!discovery.getDiscoveredFileKind(path)) return;
153
+ debugTypedRouter("watch regenerate", {
154
+ event,
155
+ path
156
+ });
132
157
  discovery.updateDiscoveredFile(path, event);
133
158
  generate();
134
159
  };
@@ -1 +1 @@
1
- {"version":3,"file":"typed-routes-plugin.js","names":[],"sources":["../../../src/lib/typed-routes-plugin.ts"],"sourcesContent":["import { normalizePath, type Plugin } from 'vite';\nimport { resolve, join, dirname, relative } from 'node:path';\nimport { writeFileSync, mkdirSync, existsSync, readFileSync } from 'node:fs';\n\nimport {\n generateRouteManifest,\n generateRouteTableDeclaration,\n generateRouteTreeDeclaration,\n detectSchemaExports,\n formatManifestSummary,\n filenameToRoutePath,\n} from './route-manifest.js';\nimport type { RouteSchemaInfo } from './route-manifest.js';\nimport {\n detectJsonLdModuleExports,\n extractMarkdownJsonLd,\n generateJsonLdManifestSource,\n type JsonLdManifestEntry,\n} from './json-ld-manifest-plugin.js';\nimport {\n createRouteFileDiscovery,\n type RouteFileDiscovery,\n} from './route-file-discovery.js';\n\nconst DEFAULT_OUT_FILE = 'src/routeTree.gen.ts';\n\nexport interface TypedRoutesPluginOptions {\n /**\n * Output path for the single generated route module,\n * relative to the app root.\n *\n * @default 'src/routeTree.gen.ts'\n */\n outFile?: string;\n /**\n * Workspace root used to resolve additional route/content directories.\n *\n * @default process.env['NX_WORKSPACE_ROOT'] ?? process.cwd()\n */\n workspaceRoot?: string;\n /**\n * Additional page directories to scan for `.page.ts` files.\n */\n additionalPagesDirs?: string[];\n /**\n * Additional content directories to scan for `.md` files.\n */\n additionalContentDirs?: string[];\n /**\n * Include generated `routeJsonLdManifest` exports in the generated route file.\n *\n * @default true\n */\n jsonLdManifest?: boolean;\n /**\n * When true, compare generated output against the existing file and\n * throw an error if they differ instead of writing. Useful for CI to\n * detect stale checked-in route files.\n *\n * @default false\n */\n verify?: boolean;\n /**\n * When true, production builds fail after regenerating a stale checked-in\n * route file. This preserves self-healing writes in development while making\n * build-time freshness issues visible by default.\n *\n * @default true\n */\n verifyOnBuild?: boolean;\n}\n\nfunction resolvePluginOptions(\n options: TypedRoutesPluginOptions = {},\n): Required<TypedRoutesPluginOptions> {\n return {\n outFile: options.outFile ?? DEFAULT_OUT_FILE,\n workspaceRoot:\n options.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n additionalPagesDirs: options.additionalPagesDirs ?? [],\n additionalContentDirs: options.additionalContentDirs ?? [],\n jsonLdManifest: options.jsonLdManifest ?? true,\n verify: options.verify ?? false,\n verifyOnBuild: options.verifyOnBuild ?? true,\n };\n}\n\n/**\n * Vite plugin that generates a single typed route module for Analog file routes.\n */\nexport function typedRoutes(options: TypedRoutesPluginOptions = {}): Plugin {\n const resolvedOptions = resolvePluginOptions(options);\n const workspaceRoot = normalizePath(resolvedOptions.workspaceRoot);\n let root = '';\n let command: 'build' | 'serve' = 'serve';\n let discovery: RouteFileDiscovery;\n\n function isFreshnessCheck(): boolean {\n return (\n resolvedOptions.verify ||\n (command === 'build' && resolvedOptions.verifyOnBuild)\n );\n }\n\n function resolveDiscoveredFile(filename: string): string {\n const fromRoot = join(root, filename);\n if (existsSync(fromRoot)) return fromRoot;\n return join(workspaceRoot, filename);\n }\n\n function detectSchemas(relativeFilename: string): RouteSchemaInfo {\n if (!relativeFilename.endsWith('.ts')) {\n return { hasParamsSchema: false, hasQuerySchema: false };\n }\n\n try {\n const absPath = resolveDiscoveredFile(relativeFilename);\n const content = readFileSync(absPath, 'utf-8');\n return detectSchemaExports(content);\n } catch {\n return { hasParamsSchema: false, hasQuerySchema: false };\n }\n }\n\n /**\n * Ensures the generated route file is imported from an app entry file\n * so the module augmentation is always part of the TypeScript program.\n */\n function ensureEntryImport(): void {\n const entryFiles = ['src/main.ts', 'src/main.server.ts'];\n\n // Compute the import specifier relative to the entry file\n function importSpecifierFor(entryFile: string): string {\n const rel = relative(dirname(entryFile), resolvedOptions.outFile)\n .replace(/\\.ts$/, '')\n .replace(/\\\\/g, '/');\n return rel.startsWith('.') ? rel : './' + rel;\n }\n\n for (const entryFile of entryFiles) {\n const entryPath = join(root, entryFile);\n if (!existsSync(entryPath)) continue;\n\n const content = readFileSync(entryPath, 'utf-8');\n const specifier = importSpecifierFor(entryFile);\n\n // Check if any variation of the import already exists\n const escaped = specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const pattern = new RegExp(`import\\\\s+['\"]${escaped}(\\\\.ts|\\\\.js)?['\"]`);\n if (pattern.test(content)) {\n return;\n }\n\n if (isFreshnessCheck()) {\n return;\n }\n\n // Insert the import after the last existing import line\n const importLine = `import '${specifier}';`;\n const lines = content.split('\\n');\n let lastImportLine = -1;\n\n for (let i = 0; i < lines.length; i++) {\n if (/^import\\s/.test(lines[i])) {\n lastImportLine = i;\n }\n }\n\n if (lastImportLine >= 0) {\n lines.splice(lastImportLine + 1, 0, importLine);\n } else {\n lines.unshift(importLine);\n }\n\n writeFileSync(entryPath, lines.join('\\n'), 'utf-8');\n console.log(`[analog] Added route tree import to ${entryFile}`);\n return;\n }\n\n // No suitable entry file found\n const specifier = importSpecifierFor('src/main.ts');\n if (isFreshnessCheck()) {\n return;\n }\n console.warn(\n `[analog] Could not find an entry file (src/main.ts or src/main.server.ts) ` +\n `to add the route tree import. Add \\`import '${specifier}';\\` ` +\n `to your app entry file to ensure typed routing is active.`,\n );\n }\n\n function generate(): void {\n const routeFiles = discovery.getRouteFiles();\n const contentFiles = discovery.getContentFiles();\n const allFiles = [...routeFiles, ...contentFiles];\n const manifest = generateRouteManifest(\n allFiles,\n detectSchemas,\n (filename) => (discovery.isAppLocal(filename) ? 0 : 1),\n );\n const declaration = generateRouteTableDeclaration(manifest);\n const canonicalFiles = new Set(\n manifest.routes.map((route) => route.filename),\n );\n const jsonLdEntries = buildJsonLdEntries(\n resolveDiscoveredFile,\n routeFiles.filter((filename) => canonicalFiles.has(filename)),\n contentFiles.filter((filename) => canonicalFiles.has(filename)),\n );\n const routeTree = generateRouteTreeDeclaration(manifest, {\n jsonLdFiles: jsonLdEntries.map((entry) => entry.sourceFile),\n });\n const output = combineGeneratedModules(\n declaration,\n routeTree,\n resolvedOptions.jsonLdManifest && jsonLdEntries.length > 0\n ? generateJsonLdManifestSource(jsonLdEntries, resolvedOptions.outFile)\n : '',\n );\n\n const hardCollisions = manifest.collisions.filter((c) => c.samePriority);\n if (hardCollisions.length > 0 && command === 'build') {\n const details = hardCollisions\n .map((c) => ` '${c.fullPath}': '${c.keptFile}' vs '${c.droppedFile}'`)\n .join('\\n');\n throw new Error(\n `[analog] Route collisions detected during build:\\n${details}\\n\\n` +\n `Each route path must be defined by exactly one source file. ` +\n `Remove or rename the conflicting files to resolve the collision.`,\n );\n }\n\n if (manifest.routes.length > 0) {\n console.log(formatManifestSummary(manifest));\n }\n\n const outPath = join(root, resolvedOptions.outFile);\n const outDir = dirname(outPath);\n const hadExistingOutput = existsSync(outPath);\n\n if (!existsSync(outDir)) {\n mkdirSync(outDir, { recursive: true });\n }\n\n let existing = '';\n\n try {\n existing = readFileSync(outPath, 'utf-8');\n } catch {\n // file does not exist yet\n }\n\n // Build-time guard: detect absolute path leaks in generated output.\n // Machine-specific prefixes must never appear in route keys or sourceFile values.\n if (output.includes(root)) {\n console.warn(\n `[analog] Generated route output contains an absolute path prefix (${root}). ` +\n `Route keys and sourceFile values should be workspace-relative.`,\n );\n }\n\n // Normalize line endings before comparison so that files checked in\n // with LF don't appear stale on Windows where readFileSync may return CRLF.\n const normalizeEndings = (s: string) => s.replace(/\\r\\n/g, '\\n');\n if (normalizeEndings(existing) !== normalizeEndings(output)) {\n if (resolvedOptions.verify) {\n throw new Error(\n `[analog] Stale route file detected: ${resolvedOptions.outFile}\\n` +\n `The checked-in generated route file does not match the current route sources.\\n` +\n `Regenerate route files and commit the updated output.`,\n );\n }\n\n writeFileSync(outPath, output, 'utf-8');\n\n if (\n command === 'build' &&\n resolvedOptions.verifyOnBuild &&\n hadExistingOutput\n ) {\n throw new Error(\n `[analog] Stale route file detected during build: ${resolvedOptions.outFile}\\n` +\n `The generated route file was updated to match the current route sources.\\n` +\n `Review the updated output, commit it if it is checked in, and rerun the build.`,\n );\n }\n }\n }\n\n return {\n name: 'analog-typed-routes',\n config(config, env) {\n command = env.command;\n root = normalizePath(resolve(workspaceRoot, config.root || '.') || '.');\n discovery = createRouteFileDiscovery({\n root,\n workspaceRoot,\n additionalPagesDirs: resolvedOptions.additionalPagesDirs,\n additionalContentDirs: resolvedOptions.additionalContentDirs,\n });\n },\n buildStart() {\n generate();\n if (!isFreshnessCheck()) {\n ensureEntryImport();\n }\n },\n configureServer(server) {\n const regenerate = (path: string, event: 'add' | 'change' | 'unlink') => {\n // Reuse the discovery matcher so watch-time updates stay in sync with\n // the initial scan and don't pull Nitro server routes into routeTree.gen.ts.\n if (!discovery.getDiscoveredFileKind(path)) {\n return;\n }\n\n discovery.updateDiscoveredFile(path, event);\n generate();\n };\n\n server.watcher.on('add', (path) => regenerate(path, 'add'));\n server.watcher.on('change', (path) => regenerate(path, 'change'));\n server.watcher.on('unlink', (path) => regenerate(path, 'unlink'));\n },\n };\n}\n\nfunction buildJsonLdEntries(\n resolveFile: (filename: string) => string,\n routeFiles: string[],\n contentFiles: string[],\n): JsonLdManifestEntry[] {\n const entries: JsonLdManifestEntry[] = [];\n let importIndex = 0;\n\n routeFiles.forEach((filename) => {\n try {\n const source = readFileSync(resolveFile(filename), 'utf-8');\n if (!detectJsonLdModuleExports(source)) {\n return;\n }\n\n entries.push({\n kind: 'module',\n routePath: filenameToRoutePath(filename),\n sourceFile: filename,\n importAlias: `routeModule${importIndex++}`,\n });\n } catch {\n // ignore unreadable route file\n }\n });\n\n contentFiles.forEach((filename) => {\n try {\n const source = readFileSync(resolveFile(filename), 'utf-8');\n const jsonLd = extractMarkdownJsonLd(source);\n\n if (jsonLd.length === 0) {\n return;\n }\n\n entries.push({\n kind: 'content',\n routePath: filenameToRoutePath(filename),\n sourceFile: filename,\n jsonLd,\n });\n } catch {\n // ignore unreadable content file\n }\n });\n\n return entries.sort((a, b) => a.routePath.localeCompare(b.routePath));\n}\n\nfunction combineGeneratedModules(...sources: string[]): string {\n const imports: string[] = [];\n const seenImports = new Set<string>();\n const bodies: string[] = [];\n\n for (const source of sources) {\n const { body, importLines } = splitGeneratedModule(source);\n for (const importLine of importLines) {\n if (!seenImports.has(importLine)) {\n seenImports.add(importLine);\n imports.push(importLine);\n }\n }\n if (body.trim()) {\n bodies.push(body.trim());\n }\n }\n\n return [\n '// This file is auto-generated by @analogjs/platform',\n '// Do not edit manually',\n '',\n ...(imports.length > 0 ? [...imports, ''] : []),\n bodies.join('\\n\\n'),\n '',\n ].join('\\n');\n}\n\nfunction splitGeneratedModule(source: string): {\n importLines: string[];\n body: string;\n} {\n const lines = source.split('\\n');\n let index = 0;\n\n while (index < lines.length && lines[index].startsWith('//')) {\n index++;\n }\n\n while (index < lines.length && lines[index] === '') {\n index++;\n }\n\n const importLines: string[] = [];\n while (index < lines.length && lines[index].startsWith('import ')) {\n importLines.push(lines[index]);\n index++;\n }\n\n while (index < lines.length && lines[index] === '') {\n index++;\n }\n\n return {\n importLines,\n body: lines.slice(index).join('\\n'),\n };\n}\n"],"mappings":";;;;;;;AAwBA,IAAM,mBAAmB;AAgDzB,SAAS,qBACP,UAAoC,EAAE,EACF;AACpC,QAAO;EACL,SAAS,QAAQ,WAAW;EAC5B,eACE,QAAQ,iBACR,QAAQ,IAAI,wBACZ,QAAQ,KAAK;EACf,qBAAqB,QAAQ,uBAAuB,EAAE;EACtD,uBAAuB,QAAQ,yBAAyB,EAAE;EAC1D,gBAAgB,QAAQ,kBAAkB;EAC1C,QAAQ,QAAQ,UAAU;EAC1B,eAAe,QAAQ,iBAAiB;EACzC;;;;;AAMH,SAAgB,YAAY,UAAoC,EAAE,EAAU;CAC1E,MAAM,kBAAkB,qBAAqB,QAAQ;CACrD,MAAM,gBAAgB,cAAc,gBAAgB,cAAc;CAClE,IAAI,OAAO;CACX,IAAI,UAA6B;CACjC,IAAI;CAEJ,SAAS,mBAA4B;AACnC,SACE,gBAAgB,UACf,YAAY,WAAW,gBAAgB;;CAI5C,SAAS,sBAAsB,UAA0B;EACvD,MAAM,WAAW,KAAK,MAAM,SAAS;AACrC,MAAI,WAAW,SAAS,CAAE,QAAO;AACjC,SAAO,KAAK,eAAe,SAAS;;CAGtC,SAAS,cAAc,kBAA2C;AAChE,MAAI,CAAC,iBAAiB,SAAS,MAAM,CACnC,QAAO;GAAE,iBAAiB;GAAO,gBAAgB;GAAO;AAG1D,MAAI;AAGF,UAAO,oBADS,aADA,sBAAs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":"typed-routes-plugin.js","names":[],"sources":["../../../src/lib/typed-routes-plugin.ts"],"sourcesContent":["import { normalizePath, type Plugin } from 'vite';\nimport { resolve, join, dirname, relative } from 'node:path';\nimport { writeFileSync, mkdirSync, existsSync, readFileSync } from 'node:fs';\n\nimport {\n generateRouteManifest,\n generateRouteTableDeclaration,\n generateRouteTreeDeclaration,\n detectSchemaExports,\n formatManifestSummary,\n filenameToRoutePath,\n} from './route-manifest.js';\nimport type { RouteSchemaInfo } from './route-manifest.js';\nimport {\n detectJsonLdModuleExports,\n extractMarkdownJsonLd,\n generateJsonLdManifestSource,\n type JsonLdManifestEntry,\n} from './json-ld-manifest-plugin.js';\nimport {\n createRouteFileDiscovery,\n type RouteFileDiscovery,\n} from './route-file-discovery.js';\nimport { debugTypedRouter } from './utils/debug.js';\n\nconst DEFAULT_OUT_FILE = 'src/routeTree.gen.ts';\n\nexport interface TypedRoutesPluginOptions {\n /**\n * Output path for the single generated route module,\n * relative to the app root.\n *\n * @default 'src/routeTree.gen.ts'\n */\n outFile?: string;\n /**\n * Workspace root used to resolve additional route/content directories.\n *\n * @default process.env['NX_WORKSPACE_ROOT'] ?? process.cwd()\n */\n workspaceRoot?: string;\n /**\n * Additional page directories to scan for `.page.ts` files.\n */\n additionalPagesDirs?: string[];\n /**\n * Additional content directories to scan for `.md` files.\n */\n additionalContentDirs?: string[];\n /**\n * Include generated `routeJsonLdManifest` exports in the generated route file.\n *\n * @default true\n */\n jsonLdManifest?: boolean;\n /**\n * When true, compare generated output against the existing file and\n * throw an error if they differ instead of writing. Useful for CI to\n * detect stale checked-in route files.\n *\n * @default false\n */\n verify?: boolean;\n /**\n * When true, production builds fail after regenerating a stale checked-in\n * route file. This preserves self-healing writes in development while making\n * build-time freshness issues visible by default.\n *\n * @default true\n */\n verifyOnBuild?: boolean;\n}\n\nfunction resolvePluginOptions(\n options: TypedRoutesPluginOptions = {},\n): Required<TypedRoutesPluginOptions> {\n return {\n outFile: options.outFile ?? DEFAULT_OUT_FILE,\n workspaceRoot:\n options.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n additionalPagesDirs: options.additionalPagesDirs ?? [],\n additionalContentDirs: options.additionalContentDirs ?? [],\n jsonLdManifest: options.jsonLdManifest ?? true,\n verify: options.verify ?? false,\n verifyOnBuild: options.verifyOnBuild ?? true,\n };\n}\n\n/**\n * Vite plugin that generates a single typed route module for Analog file routes.\n */\nexport function typedRoutes(options: TypedRoutesPluginOptions = {}): Plugin {\n const resolvedOptions = resolvePluginOptions(options);\n const workspaceRoot = normalizePath(resolvedOptions.workspaceRoot);\n let root = '';\n let command: 'build' | 'serve' = 'serve';\n let discovery: RouteFileDiscovery;\n\n function isFreshnessCheck(): boolean {\n return (\n resolvedOptions.verify ||\n (command === 'build' && resolvedOptions.verifyOnBuild)\n );\n }\n\n function resolveDiscoveredFile(filename: string): string {\n const fromRoot = join(root, filename);\n if (existsSync(fromRoot)) return fromRoot;\n return join(workspaceRoot, filename);\n }\n\n function detectSchemas(relativeFilename: string): RouteSchemaInfo {\n if (!relativeFilename.endsWith('.ts')) {\n return { hasParamsSchema: false, hasQuerySchema: false };\n }\n\n try {\n const absPath = resolveDiscoveredFile(relativeFilename);\n const content = readFileSync(absPath, 'utf-8');\n return detectSchemaExports(content);\n } catch {\n return { hasParamsSchema: false, hasQuerySchema: false };\n }\n }\n\n /**\n * Ensures the generated route file is imported from an app entry file\n * so the module augmentation is always part of the TypeScript program.\n */\n function ensureEntryImport(): void {\n const entryFiles = ['src/main.ts', 'src/main.server.ts'];\n\n // Compute the import specifier relative to the entry file\n function importSpecifierFor(entryFile: string): string {\n const rel = relative(dirname(entryFile), resolvedOptions.outFile)\n .replace(/\\.ts$/, '')\n .replace(/\\\\/g, '/');\n return rel.startsWith('.') ? rel : './' + rel;\n }\n\n for (const entryFile of entryFiles) {\n const entryPath = join(root, entryFile);\n if (!existsSync(entryPath)) continue;\n\n const content = readFileSync(entryPath, 'utf-8');\n const specifier = importSpecifierFor(entryFile);\n\n // Check if any variation of the import already exists\n const escaped = specifier.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const pattern = new RegExp(`import\\\\s+['\"]${escaped}(\\\\.ts|\\\\.js)?['\"]`);\n if (pattern.test(content)) {\n return;\n }\n\n if (isFreshnessCheck()) {\n return;\n }\n\n // Insert the import after the last existing import line\n const importLine = `import '${specifier}';`;\n const lines = content.split('\\n');\n let lastImportLine = -1;\n\n for (let i = 0; i < lines.length; i++) {\n if (/^import\\s/.test(lines[i])) {\n lastImportLine = i;\n }\n }\n\n if (lastImportLine >= 0) {\n lines.splice(lastImportLine + 1, 0, importLine);\n } else {\n lines.unshift(importLine);\n }\n\n writeFileSync(entryPath, lines.join('\\n'), 'utf-8');\n console.log(`[analog] Added route tree import to ${entryFile}`);\n return;\n }\n\n // No suitable entry file found\n const specifier = importSpecifierFor('src/main.ts');\n if (isFreshnessCheck()) {\n return;\n }\n console.warn(\n `[analog] Could not find an entry file (src/main.ts or src/main.server.ts) ` +\n `to add the route tree import. Add \\`import '${specifier}';\\` ` +\n `to your app entry file to ensure typed routing is active.`,\n );\n }\n\n function generate(): void {\n const routeFiles = discovery.getRouteFiles();\n const contentFiles = discovery.getContentFiles();\n debugTypedRouter('discovered files', {\n routeFiles: routeFiles.length,\n contentFiles: contentFiles.length,\n });\n const allFiles = [...routeFiles, ...contentFiles];\n const manifest = generateRouteManifest(\n allFiles,\n detectSchemas,\n (filename) => (discovery.isAppLocal(filename) ? 0 : 1),\n );\n const declaration = generateRouteTableDeclaration(manifest);\n const canonicalFiles = new Set(\n manifest.routes.map((route) => route.filename),\n );\n const jsonLdEntries = buildJsonLdEntries(\n resolveDiscoveredFile,\n routeFiles.filter((filename) => canonicalFiles.has(filename)),\n contentFiles.filter((filename) => canonicalFiles.has(filename)),\n );\n const routeTree = generateRouteTreeDeclaration(manifest, {\n jsonLdFiles: jsonLdEntries.map((entry) => entry.sourceFile),\n });\n const output = combineGeneratedModules(\n declaration,\n routeTree,\n resolvedOptions.jsonLdManifest && jsonLdEntries.length > 0\n ? generateJsonLdManifestSource(jsonLdEntries, resolvedOptions.outFile)\n : '',\n );\n\n const hardCollisions = manifest.collisions.filter((c) => c.samePriority);\n if (manifest.collisions.length > 0) {\n debugTypedRouter('route collisions', {\n total: manifest.collisions.length,\n hard: hardCollisions.length,\n collisions: manifest.collisions.map((c) => ({\n path: c.fullPath,\n kept: c.keptFile,\n dropped: c.droppedFile,\n })),\n });\n }\n if (hardCollisions.length > 0 && command === 'build') {\n const details = hardCollisions\n .map((c) => ` '${c.fullPath}': '${c.keptFile}' vs '${c.droppedFile}'`)\n .join('\\n');\n throw new Error(\n `[analog] Route collisions detected during build:\\n${details}\\n\\n` +\n `Each route path must be defined by exactly one source file. ` +\n `Remove or rename the conflicting files to resolve the collision.`,\n );\n }\n\n if (manifest.routes.length > 0) {\n console.log(formatManifestSummary(manifest));\n }\n\n const outPath = join(root, resolvedOptions.outFile);\n const outDir = dirname(outPath);\n const hadExistingOutput = existsSync(outPath);\n\n if (!existsSync(outDir)) {\n mkdirSync(outDir, { recursive: true });\n }\n\n let existing = '';\n\n try {\n existing = readFileSync(outPath, 'utf-8');\n } catch {\n // file does not exist yet\n }\n\n // Build-time guard: detect absolute path leaks in generated output.\n // Machine-specific prefixes must never appear in route keys or sourceFile values.\n if (output.includes(root)) {\n console.warn(\n `[analog] Generated route output contains an absolute path prefix (${root}). ` +\n `Route keys and sourceFile values should be workspace-relative.`,\n );\n }\n\n // Normalize line endings before comparison so that files checked in\n // with LF don't appear stale on Windows where readFileSync may return CRLF.\n const normalizeEndings = (s: string) => s.replace(/\\r\\n/g, '\\n');\n if (normalizeEndings(existing) !== normalizeEndings(output)) {\n debugTypedRouter('route file changed', {\n outFile: resolvedOptions.outFile,\n routes: manifest.routes.length,\n verify: resolvedOptions.verify,\n verifyOnBuild: resolvedOptions.verifyOnBuild,\n command,\n });\n if (resolvedOptions.verify) {\n throw new Error(\n `[analog] Stale route file detected: ${resolvedOptions.outFile}\\n` +\n `The checked-in generated route file does not match the current route sources.\\n` +\n `Regenerate route files and commit the updated output.`,\n );\n }\n\n writeFileSync(outPath, output, 'utf-8');\n\n if (\n command === 'build' &&\n resolvedOptions.verifyOnBuild &&\n hadExistingOutput\n ) {\n throw new Error(\n `[analog] Stale route file detected during build: ${resolvedOptions.outFile}\\n` +\n `The generated route file was updated to match the current route sources.\\n` +\n `Review the updated output, commit it if it is checked in, and rerun the build.`,\n );\n }\n }\n }\n\n return {\n name: 'analog-typed-routes',\n config(config, env) {\n command = env.command;\n root = normalizePath(resolve(workspaceRoot, config.root || '.') || '.');\n discovery = createRouteFileDiscovery({\n root,\n workspaceRoot,\n additionalPagesDirs: resolvedOptions.additionalPagesDirs,\n additionalContentDirs: resolvedOptions.additionalContentDirs,\n });\n },\n buildStart() {\n generate();\n if (!isFreshnessCheck()) {\n ensureEntryImport();\n }\n },\n configureServer(server) {\n const regenerate = (path: string, event: 'add' | 'change' | 'unlink') => {\n // Reuse the discovery matcher so watch-time updates stay in sync with\n // the initial scan and don't pull Nitro server routes into routeTree.gen.ts.\n if (!discovery.getDiscoveredFileKind(path)) {\n return;\n }\n\n debugTypedRouter('watch regenerate', { event, path });\n discovery.updateDiscoveredFile(path, event);\n generate();\n };\n\n server.watcher.on('add', (path) => regenerate(path, 'add'));\n server.watcher.on('change', (path) => regenerate(path, 'change'));\n server.watcher.on('unlink', (path) => regenerate(path, 'unlink'));\n },\n };\n}\n\nfunction buildJsonLdEntries(\n resolveFile: (filename: string) => string,\n routeFiles: string[],\n contentFiles: string[],\n): JsonLdManifestEntry[] {\n const entries: JsonLdManifestEntry[] = [];\n let importIndex = 0;\n\n routeFiles.forEach((filename) => {\n try {\n const source = readFileSync(resolveFile(filename), 'utf-8');\n if (!detectJsonLdModuleExports(source)) {\n return;\n }\n\n entries.push({\n kind: 'module',\n routePath: filenameToRoutePath(filename),\n sourceFile: filename,\n importAlias: `routeModule${importIndex++}`,\n });\n } catch {\n // ignore unreadable route file\n }\n });\n\n contentFiles.forEach((filename) => {\n try {\n const source = readFileSync(resolveFile(filename), 'utf-8');\n const jsonLd = extractMarkdownJsonLd(source);\n\n if (jsonLd.length === 0) {\n return;\n }\n\n entries.push({\n kind: 'content',\n routePath: filenameToRoutePath(filename),\n sourceFile: filename,\n jsonLd,\n });\n } catch {\n // ignore unreadable content file\n }\n });\n\n return entries.sort((a, b) => a.routePath.localeCompare(b.routePath));\n}\n\nfunction combineGeneratedModules(...sources: string[]): string {\n const imports: string[] = [];\n const seenImports = new Set<string>();\n const bodies: string[] = [];\n\n for (const source of sources) {\n const { body, importLines } = splitGeneratedModule(source);\n for (const importLine of importLines) {\n if (!seenImports.has(importLine)) {\n seenImports.add(importLine);\n imports.push(importLine);\n }\n }\n if (body.trim()) {\n bodies.push(body.trim());\n }\n }\n\n return [\n '// This file is auto-generated by @analogjs/platform',\n '// Do not edit manually',\n '',\n ...(imports.length > 0 ? [...imports, ''] : []),\n bodies.join('\\n\\n'),\n '',\n ].join('\\n');\n}\n\nfunction splitGeneratedModule(source: string): {\n importLines: string[];\n body: string;\n} {\n const lines = source.split('\\n');\n let index = 0;\n\n while (index < lines.length && lines[index].startsWith('//')) {\n index++;\n }\n\n while (index < lines.length && lines[index] === '') {\n index++;\n }\n\n const importLines: string[] = [];\n while (index < lines.length && lines[index].startsWith('import ')) {\n importLines.push(lines[index]);\n index++;\n }\n\n while (index < lines.length && lines[index] === '') {\n index++;\n }\n\n return {\n importLines,\n body: lines.slice(index).join('\\n'),\n };\n}\n"],"mappings":";;;;;;;;AAyBA,IAAM,mBAAmB;AAgDzB,SAAS,qBACP,UAAoC,EAAE,EACF;AACpC,QAAO;EACL,SAAS,QAAQ,WAAW;EAC5B,eACE,QAAQ,iBACR,QAAQ,IAAI,wBACZ,QAAQ,KAAK;EACf,qBAAqB,QAAQ,uBAAuB,EAAE;EACtD,uBAAuB,QAAQ,yBAAyB,EAAE;EAC1D,gBAAgB,QAAQ,kBAAkB;EAC1C,Q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AAG,MAAM,EAAE,UAAU,cAAc,EAAE,UAAU,CAAC;;AAGvE,SAAS,wBAAwB,GAAG,SAA2B;CAC7D,MAAM,UAAoB,EAAE;CAC5B,MAAM,8BAAc,IAAI,KAAa;CACrC,MAAM,SAAmB,EAAE;AAE3B,MAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,EAAE,MAAM,gBAAgB,qBAAqB,OAAO;AAC1D,OAAK,MAAM,cAAc,YACvB,KAAI,CAAC,YAAY,IAAI,WAAW,EAAE;AAChC,eAAY,IAAI,WAAW;AAC3B,WAAQ,KAAK,WAAW;;AAG5B,MAAI,KAAK,MAAM,CACb,QAAO,KAAK,KAAK,MAAM,CAAC;;AAI5B,QAAO;EACL;EACA;EACA;EACA,GAAI,QAAQ,SAAS,IAAI,CAAC,GAAG,SAAS,GAAG,GAAG,EAAE;EAC9C,OAAO,KAAK,OAAO;EACnB;EACD,CAAC,KAAK,KAAK;;AAGd,SAAS,qBAAqB,QAG5B;CACA,MAAM,QAAQ,OAAO,MAAM,KAAK;CAChC,IAAI,QAAQ;AAEZ,QAAO,QAAQ,MAAM,UAAU,MAAM,OAAO,WAAW,KAAK,CAC1D;AAGF,QAAO,QAAQ,MAAM,UAAU,MAAM,WAAW,GAC9C;CAGF,MAAM,cAAwB,EAAE;AAChC,QAAO,QAAQ,MAAM,UAAU,MAAM,OAAO,WAAW,UAAU,EAAE;AACjE,cAAY,KAAK,MAAM,OAAO;AAC9B;;AAGF,QAAO,QAAQ,MAAM,UAAU,MAAM,WAAW,GAC9C;AAGF,QAAO;EACL;EACA,MAAM,MAAM,MAAM,MAAM,CAAC,KAAK,KAAK;EACpC"}
@@ -0,0 +1,40 @@
1
+ export declare const debugPlatform: unknown;
2
+ export declare const debugRoutes: unknown;
3
+ export declare const debugContent: unknown;
4
+ export declare const debugTypedRouter: unknown;
5
+ export declare const debugTailwind: unknown;
6
+ export type DebugScope = "analog:*" | "analog:platform" | "analog:platform:*" | "analog:platform:routes" | "analog:platform:content" | "analog:platform:typed-router" | "analog:platform:tailwind" | "analog:angular:*" | "analog:angular:hmr" | "analog:angular:styles" | "analog:angular:compiler" | "analog:angular:compilation-api" | "analog:angular:tailwind" | "analog:nitro" | "analog:nitro:*" | "analog:nitro:ssr" | "analog:nitro:prerender" | (string & {});
7
+ export type DebugMode = "build" | "dev";
8
+ export interface DebugModeOptions {
9
+ scopes?: boolean | DebugScope[];
10
+ mode?: DebugMode;
11
+ }
12
+ export type DebugOption = boolean | DebugScope[] | DebugModeOptions | DebugModeOptions[];
13
+ /**
14
+ * Translates the user-facing `debug` platform option into obug namespace
15
+ * activations. Called once during the Vite plugin config hook.
16
+ *
17
+ * When `true`, enables all `analog:*` scopes (platform + angular + nitro).
18
+ * Additive — does not replace namespaces already enabled via the DEBUG
19
+ * env var or localStorage.debug.
20
+ *
21
+ * When an object with `mode` is provided, activation is deferred until
22
+ * {@link activateDeferredDebug} is called from a Vite config hook.
23
+ *
24
+ * Accepts an array of objects to enable different scopes per command:
25
+ * ```ts
26
+ * debug: [
27
+ * { scopes: ['analog:angular:hmr'], mode: 'dev' },
28
+ * { scopes: ['analog:platform:typed-router'], mode: 'build' },
29
+ * ]
30
+ * ```
31
+ */
32
+ export declare function applyDebugOption(debug: DebugOption | undefined): void;
33
+ /**
34
+ * Called from a Vite config hook once `command` is known.
35
+ * Maps Vite's `'serve'` to `'dev'` and `'build'` to `'build'`.
36
+ * Idempotent — clears pending state after the first call.
37
+ */
38
+ export declare function activateDeferredDebug(command: "build" | "serve"): void;
39
+ /** @internal test-only reset */
40
+ export declare function _resetDeferredDebug(): void;
@@ -0,0 +1,75 @@
1
+ import { createDebug, enable } from "obug";
2
+ //#region packages/platform/src/lib/utils/debug.ts
3
+ var debugPlatform = createDebug("analog:platform");
4
+ createDebug("analog:platform:routes");
5
+ createDebug("analog:platform:content");
6
+ var debugTypedRouter = createDebug("analog:platform:typed-router");
7
+ var debugTailwind = createDebug("analog:platform:tailwind");
8
+ var pendingDebug = [];
9
+ function resolveNamespaces(scopes, fallback) {
10
+ if (scopes === true || scopes === void 0) return fallback;
11
+ if (Array.isArray(scopes) && scopes.length) return scopes.join(",");
12
+ return null;
13
+ }
14
+ function applyEntry(entry, fallback) {
15
+ if (!entry.mode) {
16
+ const ns = resolveNamespaces(entry.scopes ?? true, fallback);
17
+ if (ns) enable(ns);
18
+ } else pendingDebug.push(entry);
19
+ }
20
+ /**
21
+ * Translates the user-facing `debug` platform option into obug namespace
22
+ * activations. Called once during the Vite plugin config hook.
23
+ *
24
+ * When `true`, enables all `analog:*` scopes (platform + angular + nitro).
25
+ * Additive — does not replace namespaces already enabled via the DEBUG
26
+ * env var or localStorage.debug.
27
+ *
28
+ * When an object with `mode` is provided, activation is deferred until
29
+ * {@link activateDeferredDebug} is called from a Vite config hook.
30
+ *
31
+ * Accepts an array of objects to enable different scopes per command:
32
+ * ```ts
33
+ * debug: [
34
+ * { scopes: ['analog:angular:hmr'], mode: 'dev' },
35
+ * { scopes: ['analog:platform:typed-router'], mode: 'build' },
36
+ * ]
37
+ * ```
38
+ */
39
+ function applyDebugOption(debug) {
40
+ if (debug == null || debug === false) return;
41
+ if (typeof debug === "boolean") {
42
+ const ns = resolveNamespaces(debug, "analog:*");
43
+ if (ns) enable(ns);
44
+ return;
45
+ }
46
+ if (Array.isArray(debug)) {
47
+ if (debug.length === 0) return;
48
+ if (typeof debug[0] === "string") {
49
+ const ns = debug.join(",");
50
+ if (ns) enable(ns);
51
+ return;
52
+ }
53
+ for (const entry of debug) applyEntry(entry, "analog:*");
54
+ return;
55
+ }
56
+ applyEntry(debug, "analog:*");
57
+ }
58
+ /**
59
+ * Called from a Vite config hook once `command` is known.
60
+ * Maps Vite's `'serve'` to `'dev'` and `'build'` to `'build'`.
61
+ * Idempotent — clears pending state after the first call.
62
+ */
63
+ function activateDeferredDebug(command) {
64
+ if (pendingDebug.length === 0) return;
65
+ const currentMode = command === "serve" ? "dev" : "build";
66
+ for (const entry of pendingDebug) if (entry.mode === currentMode) {
67
+ const ns = resolveNamespaces(entry.scopes ?? true, "analog:*");
68
+ if (ns) enable(ns);
69
+ }
70
+ pendingDebug = [];
71
+ }
72
+ //#endregion
73
+ export { activateDeferredDebug, applyDebugOption, debugPlatform, debugTailwind, debugTypedRouter };
74
+
75
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","names":[],"sources":["../../../../src/lib/utils/debug.ts"],"sourcesContent":["import { createDebug, enable } from 'obug';\n\nexport const debugPlatform = createDebug('analog:platform');\nexport const debugRoutes = createDebug('analog:platform:routes');\nexport const debugContent = createDebug('analog:platform:content');\nexport const debugTypedRouter = createDebug('analog:platform:typed-router');\nexport const debugTailwind = createDebug('analog:platform:tailwind');\n\nexport type DebugScope =\n | 'analog:*'\n | 'analog:platform'\n | 'analog:platform:*'\n | 'analog:platform:routes'\n | 'analog:platform:content'\n | 'analog:platform:typed-router'\n | 'analog:platform:tailwind'\n | 'analog:angular:*'\n | 'analog:angular:hmr'\n | 'analog:angular:styles'\n | 'analog:angular:compiler'\n | 'analog:angular:compilation-api'\n | 'analog:angular:tailwind'\n | 'analog:nitro'\n | 'analog:nitro:*'\n | 'analog:nitro:ssr'\n | 'analog:nitro:prerender'\n | (string & {});\n\nexport type DebugMode = 'build' | 'dev';\n\nexport interface DebugModeOptions {\n scopes?: boolean | DebugScope[];\n mode?: DebugMode;\n}\n\nexport type DebugOption =\n | boolean\n | DebugScope[]\n | DebugModeOptions\n | DebugModeOptions[];\n\nlet pendingDebug: DebugModeOptions[] = [];\n\nfunction resolveNamespaces(\n scopes: boolean | string[] | undefined,\n fallback: string,\n): string | null {\n if (scopes === true || scopes === undefined) return fallback;\n if (Array.isArray(scopes) && scopes.length) return scopes.join(',');\n return null;\n}\n\nfunction applyEntry(entry: DebugModeOptions, fallback: string): void {\n if (!entry.mode) {\n const ns = resolveNamespaces(entry.scopes ?? true, fallback);\n if (ns) enable(ns);\n } else {\n pendingDebug.push(entry);\n }\n}\n\n/**\n * Translates the user-facing `debug` platform option into obug namespace\n * activations. Called once during the Vite plugin config hook.\n *\n * When `true`, enables all `analog:*` scopes (platform + angular + nitro).\n * Additive — does not replace namespaces already enabled via the DEBUG\n * env var or localStorage.debug.\n *\n * When an object with `mode` is provided, activation is deferred until\n * {@link activateDeferredDebug} is called from a Vite config hook.\n *\n * Accepts an array of objects to enable different scopes per command:\n * ```ts\n * debug: [\n * { scopes: ['analog:angular:hmr'], mode: 'dev' },\n * { scopes: ['analog:platform:typed-router'], mode: 'build' },\n * ]\n * ```\n */\nexport function applyDebugOption(debug: DebugOption | undefined): void {\n if (debug == null || debug === false) return;\n\n if (typeof debug === 'boolean') {\n const ns = resolveNamespaces(debug, 'analog:*');\n if (ns) enable(ns);\n return;\n }\n\n if (Array.isArray(debug)) {\n if (debug.length === 0) return;\n\n if (typeof debug[0] === 'string') {\n const ns = (debug as string[]).join(',');\n if (ns) enable(ns);\n return;\n }\n\n for (const entry of debug as DebugModeOptions[]) {\n applyEntry(entry, 'analog:*');\n }\n return;\n }\n\n applyEntry(debug, 'analog:*');\n}\n\n/**\n * Called from a Vite config hook once `command` is known.\n * Maps Vite's `'serve'` to `'dev'` and `'build'` to `'build'`.\n * Idempotent — clears pending state after the first call.\n */\nexport function activateDeferredDebug(command: 'build' | 'serve'): void {\n if (pendingDebug.length === 0) return;\n\n const currentMode = command === 'serve' ? 'dev' : 'build';\n\n for (const entry of pendingDebug) {\n if (entry.mode === currentMode) {\n const ns = resolveNamespaces(entry.scopes ?? true, 'analog:*');\n if (ns) enable(ns);\n }\n }\n\n pendingDebug = [];\n}\n\n/** @internal test-only reset */\nexport function _resetDeferredDebug(): void {\n pendingDebug = [];\n}\n"],"mappings":";;AAEA,IAAa,gBAAgB,YAAY,kBAAkB;AAChC,YAAY,yBAAyB;AACpC,YAAY,0BAA0B;AAClE,IAAa,mBAAmB,YAAY,+BAA+B;AAC3E,IAAa,gBAAgB,YAAY,2BAA2B;AAmCpE,IAAI,eAAmC,EAAE;AAEzC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