@analogjs/platform 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.
- package/migrations/migrate-setup-testbed-browser-mode/migrate-setup-testbed-browser-mode.js +8 -6
- package/migrations/migrate-setup-testbed-browser-mode/migrate-setup-testbed-browser-mode.js.map +1 -1
- package/migrations/migrate-to-separated-plugins/migrate-to-separated-plugins.js.map +1 -1
- package/migrations/migrate-vitest-builder-aliases/migrate-vitest-builder-aliases.js.map +1 -1
- package/migrations/utils/source-edits.js.map +1 -1
- package/package.json +2 -2
- package/src/lib/analog-integration-plugin.js.map +1 -1
- package/src/lib/clear-client-page-endpoint.js.map +1 -1
- package/src/lib/content/marked/index.js.map +1 -1
- package/src/lib/content/marked/marked-content-highlighter.js.map +1 -1
- package/src/lib/content/marked/marked-setup.service.js.map +1 -1
- package/src/lib/content/prism/angular.js.map +1 -1
- package/src/lib/content/prism/index.js +1 -1
- package/src/lib/content/prism/index.js.map +1 -1
- package/src/lib/content/prism/prism-highlighter.js.map +1 -1
- package/src/lib/content/shiki/index.js +6 -4
- package/src/lib/content/shiki/index.js.map +1 -1
- package/src/lib/content/shiki/shiki-highlighter.js.map +1 -1
- package/src/lib/content/utils/escape-html.js.map +1 -1
- package/src/lib/content-plugin.js +18 -16
- package/src/lib/content-plugin.js.map +1 -1
- package/src/lib/deps-plugin.js.map +1 -1
- package/src/lib/discover-library-routes.js.map +1 -1
- package/src/lib/inject-server-fn-ids.js.map +1 -1
- package/src/lib/nitro/analog-nitro-plugin.js +8 -4
- package/src/lib/nitro/analog-nitro-plugin.js.map +1 -1
- package/src/lib/nitro/angular-linker-plugin.js +2 -1
- package/src/lib/nitro/angular-linker-plugin.js.map +1 -1
- package/src/lib/nitro/build-sitemap.js.map +1 -1
- package/src/lib/nitro/debug.js +8 -4
- package/src/lib/nitro/debug.js.map +1 -1
- package/src/lib/nitro/get-content-files.js +2 -1
- package/src/lib/nitro/get-content-files.js.map +1 -1
- package/src/lib/nitro/get-page-handlers.js +2 -1
- package/src/lib/nitro/get-page-handlers.js.map +1 -1
- package/src/lib/nitro/get-server-fn-handlers.js.map +1 -1
- package/src/lib/nitro/i18n-prerender.js +1 -1
- package/src/lib/nitro/i18n-prerender.js.map +1 -1
- package/src/lib/nitro/page-endpoints-plugin.js.map +1 -1
- package/src/lib/nitro/post-rendering-hook.js.map +1 -1
- package/src/lib/nitro/server-fn-endpoints.js +1 -1
- package/src/lib/nitro/server-fn-endpoints.js.map +1 -1
- package/src/lib/nx-plugin/_virtual/_rolldown/runtime.js +1 -1
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/camelCase.js.map +1 -1
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/capitalize.js.map +1 -1
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/words.js +1 -0
- package/src/lib/nx-plugin/node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/string/words.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js +0 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js +0 -1
- package/src/lib/nx-plugin/src/executors/vite-dev-server/vite-dev-server.impl.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/compat.js +0 -1
- package/src/lib/nx-plugin/src/generators/app/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/generator.js +0 -1
- package/src/lib/nx-plugin/src/generators/app/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-agent-context.js +0 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-agent-context.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js +48 -47
- package/src/lib/nx-plugin/src/generators/app/lib/add-analog-project-config.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js +0 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-angular-app.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-files.js +0 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-files.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js +0 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-home-page.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-config.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js +0 -1
- package/src/lib/nx-plugin/src/generators/app/lib/add-tailwind-helpers.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/cleanup-files.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js +0 -1
- package/src/lib/nx-plugin/src/generators/app/lib/update-index-html.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js +0 -1
- package/src/lib/nx-plugin/src/generators/app/versions/minimum-supported-versions.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/app/versions/tailwind-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/compat.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/generator.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/lib/add-analog-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-app-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-build-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-git-ignore.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-index-html.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-main.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-main.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js +2 -2
- package/src/lib/nx-plugin/src/generators/init/lib/update-package-json.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-serve-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-target.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js +0 -1
- package/src/lib/nx-plugin/src/generators/init/lib/update-test-tsconfig.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/page/compat.js +0 -1
- package/src/lib/nx-plugin/src/generators/page/compat.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/page/generator.js +2 -2
- package/src/lib/nx-plugin/src/generators/page/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/generators/preset/generator.js +0 -1
- package/src/lib/nx-plugin/src/generators/preset/generator.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/version-utils.js +0 -1
- package/src/lib/nx-plugin/src/utils/version-utils.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dependencies.js +0 -1
- package/src/lib/nx-plugin/src/utils/versions/dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js +2 -2
- package/src/lib/nx-plugin/src/utils/versions/dev-dependencies.js.map +1 -1
- package/src/lib/nx-plugin/src/utils/versions/versions.d.ts +5 -5
- package/src/lib/nx-plugin/src/utils/versions/versions.js +5 -5
- package/src/lib/nx-plugin/src/utils/versions/versions.js.map +1 -1
- package/src/lib/platform-plugin.js.map +1 -1
- package/src/lib/route-file-discovery.js.map +1 -1
- package/src/lib/route-idiom-diagnostics.js +2 -1
- package/src/lib/route-idiom-diagnostics.js.map +1 -1
- package/src/lib/route-manifest.js +1 -1
- package/src/lib/route-manifest.js.map +1 -1
- package/src/lib/router-plugin.js +18 -2
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/server-fn-client-transform.js.map +1 -1
- package/src/lib/server-fn-id.js.map +1 -1
- package/src/lib/ssr/defer-streaming-plugin.js.map +1 -1
- package/src/lib/ssr/inject-html-plugin.js.map +1 -1
- package/src/lib/ssr/ssr-build-plugin.js.map +1 -1
- package/src/lib/typed-routes-plugin.js.map +1 -1
- package/src/lib/utils/debug-harness.js.map +1 -1
- package/src/lib/utils/debug-log-file.js +2 -1
- package/src/lib/utils/debug-log-file.js.map +1 -1
- package/src/lib/utils/debug.js +7 -4
- package/src/lib/utils/debug.js.map +1 -1
- package/src/lib/utils/rolldown.js.map +1 -1
- package/src/server-mode-plugin.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-html-plugin.js","names":[],"sources":["../../../../src/lib/ssr/inject-html-plugin.ts"],"sourcesContent":["import { Plugin } from 'vite';\nimport { readFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\n\nconst require = createRequire(import.meta.url);\n\nfunction eventReplayPlugin(): Plugin {\n return {\n name: 'analogjs-event-replay-plugin',\n async transformIndexHtml() {\n const eventReplayScript = await readFile(\n require.resolve('@angular/core/event-dispatch-contract.min.js'),\n 'utf-8',\n );\n\n return [\n {\n tag: 'script',\n attrs: {\n type: 'text/javascript',\n id: 'ng-event-dispatch-contract',\n },\n children: eventReplayScript,\n injectTo: 'body',\n },\n ];\n },\n };\n}\n\nexport function injectHTMLPlugin(): Plugin[] {\n return [eventReplayPlugin()];\n}\n"],"mappings":";;;AAIA,IAAM,UAAU,cAAc,
|
|
1
|
+
{"version":3,"file":"inject-html-plugin.js","names":[],"sources":["../../../../src/lib/ssr/inject-html-plugin.ts"],"sourcesContent":["import { Plugin } from 'vite';\nimport { readFile } from 'node:fs/promises';\nimport { createRequire } from 'node:module';\n\nconst require = createRequire(import.meta.url);\n\nfunction eventReplayPlugin(): Plugin {\n return {\n name: 'analogjs-event-replay-plugin',\n async transformIndexHtml() {\n const eventReplayScript = await readFile(\n require.resolve('@angular/core/event-dispatch-contract.min.js'),\n 'utf-8',\n );\n\n return [\n {\n tag: 'script',\n attrs: {\n type: 'text/javascript',\n id: 'ng-event-dispatch-contract',\n },\n children: eventReplayScript,\n injectTo: 'body',\n },\n ];\n },\n };\n}\n\nexport function injectHTMLPlugin(): Plugin[] {\n return [eventReplayPlugin()];\n}\n"],"mappings":";;;AAIA,IAAM,UAAU,cAAc,YAAY,GAAG;AAE7C,SAAS,oBAA4B;CACnC,OAAO;EACL,MAAM;EACN,MAAM,qBAAqB;GAMzB,OAAO,CACL;IACE,KAAK;IACL,OAAO;KACL,MAAM;KACN,IAAI;IACN;IACA,UAAU,MAZkB,SAC9B,QAAQ,QAAQ,8CAA8C,GAC9D,OACF;IAUI,UAAU;GACZ,CACF;EACF;CACF;AACF;AAEA,SAAgB,mBAA6B;CAC3C,OAAO,CAAC,kBAAkB,CAAC;AAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-build-plugin.js","names":[],"sources":["../../../../src/lib/ssr/ssr-build-plugin.ts"],"sourcesContent":["import * as vite from 'vite';\n\n/**\n * SSR build patches for Angular platform-server, Zone.js, and Domino.\n *\n * **Why each patch exists:**\n * - zone-node: removes a `const global = globalThis` alias that shadows the\n * real global in strict mode.\n * - platform-server: rewrites `xhr2.XMLHttpRequest` for CJS/ESM compat and\n * replaces bare `global` references with `globalThis`.\n * - xhr2: strips Node-specific `os`/`process` references for SSR bundling.\n * - domino/sloppy.js: replaces `with()` statements that are illegal in ESM.\n */\nexport function ssrBuildPlugin(): vite.Plugin[] {\n const plugins: vite.Plugin[] = [\n {\n name: 'analogjs-ssr-build-plugin',\n apply: 'build',\n config() {\n return {\n ssr: {\n noExternal: ['xhr2'],\n },\n };\n },\n transform: {\n filter: {\n id: /zone-node|platform-server|xhr2\\.js|domino\\/lib\\/sloppy\\.js/,\n },\n handler(code, id) {\n if (\n id.includes('zone-node') &&\n code.includes('const global = globalThis;')\n ) {\n return {\n code: code.replace('const global = globalThis;', ''),\n };\n }\n\n if (id.includes('platform-server')) {\n let result = code.replace(\n 'new xhr2.XMLHttpRequest',\n 'new (xhr2.default.XMLHttpRequest || xhr2.default)',\n );\n\n // Narrowly scoped text replacement of the bare `global`\n // identifier. Matching `global.`, `global,` and ` global[`\n // targets the known occurrences in the @angular/platform-server\n // bundle while leaving strings, comments and asset paths that\n // merely contain the word `global` untouched (see #2426).\n result = result\n .replaceAll('global.', 'globalThis.')\n .replaceAll('global,', 'globalThis,')\n .replaceAll(' global[', ' globalThis[');\n\n return { code: result };\n }\n\n if (id.includes(vite.normalizePath('xhr2.js'))) {\n return {\n code: code\n .replace('os.type()', `''`)\n .replace('os.arch()', `''`)\n .replace('process.versions.node', `'node'`)\n .replace('process.versions.v8', `'v8'`),\n };\n }\n\n if (id.includes(vite.normalizePath('domino/lib/sloppy.js'))) {\n return {\n code: code.replace(/with\\(/gi, 'if('),\n };\n }\n\n return;\n },\n },\n },\n ];\n\n return plugins;\n}\n\n/**\n * Vite plugin that patches `@angular/core`'s `getComponentId()` to\n * mirror every compiled component definition to a global Set, bypassing\n * the `ngServerMode` guard that normally prevents registration on the\n * server. The set lives at `globalThis.__ngComponentDefs` and is read by\n * `@analogjs/router`'s SSR render function to null cached `tView`\n * objects between requests so that `$localize` tagged templates in\n * `consts()` re-evaluate with the freshly loaded translations.\n *\n * Only active when the platform's `i18n` option is configured.\n * Only transforms `@angular/core` modules in SSR builds.\n */\nexport function i18nDefRegistryPlugin(): vite.Plugin {\n let fixedLocale = false;\n const DETECT_MARKER = 'GENERATED_COMP_IDS.set(compId, componentDef.type);';\n const RETURN_STMT = 'return compId;\\n}';\n\n return {\n name: 'analogjs-i18n-def-registry',\n enforce: 'post',\n configResolved(config) {\n const locale = config.define?.['ANALOG_I18N_FIXED_LOCALE'];\n fixedLocale =\n config.command === 'build' && !!locale && locale !== 'undefined';\n },\n\n transform: {\n filter: {\n id: /\\/@angular\\/core\\//,\n },\n handler(code, id, options) {\n if (fixedLocale || !options?.ssr) return;\n if (!code.includes(DETECT_MARKER)) return;\n\n return {\n code: code.replace(\n RETURN_STMT,\n '(globalThis.__ngComponentDefs ??= new Set()).add(componentDef);\\n' +\n RETURN_STMT,\n ),\n };\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,iBAAgC;
|
|
1
|
+
{"version":3,"file":"ssr-build-plugin.js","names":[],"sources":["../../../../src/lib/ssr/ssr-build-plugin.ts"],"sourcesContent":["import * as vite from 'vite';\n\n/**\n * SSR build patches for Angular platform-server, Zone.js, and Domino.\n *\n * **Why each patch exists:**\n * - zone-node: removes a `const global = globalThis` alias that shadows the\n * real global in strict mode.\n * - platform-server: rewrites `xhr2.XMLHttpRequest` for CJS/ESM compat and\n * replaces bare `global` references with `globalThis`.\n * - xhr2: strips Node-specific `os`/`process` references for SSR bundling.\n * - domino/sloppy.js: replaces `with()` statements that are illegal in ESM.\n */\nexport function ssrBuildPlugin(): vite.Plugin[] {\n const plugins: vite.Plugin[] = [\n {\n name: 'analogjs-ssr-build-plugin',\n apply: 'build',\n config() {\n return {\n ssr: {\n noExternal: ['xhr2'],\n },\n };\n },\n transform: {\n filter: {\n id: /zone-node|platform-server|xhr2\\.js|domino\\/lib\\/sloppy\\.js/,\n },\n handler(code, id) {\n if (\n id.includes('zone-node') &&\n code.includes('const global = globalThis;')\n ) {\n return {\n code: code.replace('const global = globalThis;', ''),\n };\n }\n\n if (id.includes('platform-server')) {\n let result = code.replace(\n 'new xhr2.XMLHttpRequest',\n 'new (xhr2.default.XMLHttpRequest || xhr2.default)',\n );\n\n // Narrowly scoped text replacement of the bare `global`\n // identifier. Matching `global.`, `global,` and ` global[`\n // targets the known occurrences in the @angular/platform-server\n // bundle while leaving strings, comments and asset paths that\n // merely contain the word `global` untouched (see #2426).\n result = result\n .replaceAll('global.', 'globalThis.')\n .replaceAll('global,', 'globalThis,')\n .replaceAll(' global[', ' globalThis[');\n\n return { code: result };\n }\n\n if (id.includes(vite.normalizePath('xhr2.js'))) {\n return {\n code: code\n .replace('os.type()', `''`)\n .replace('os.arch()', `''`)\n .replace('process.versions.node', `'node'`)\n .replace('process.versions.v8', `'v8'`),\n };\n }\n\n if (id.includes(vite.normalizePath('domino/lib/sloppy.js'))) {\n return {\n code: code.replace(/with\\(/gi, 'if('),\n };\n }\n\n return;\n },\n },\n },\n ];\n\n return plugins;\n}\n\n/**\n * Vite plugin that patches `@angular/core`'s `getComponentId()` to\n * mirror every compiled component definition to a global Set, bypassing\n * the `ngServerMode` guard that normally prevents registration on the\n * server. The set lives at `globalThis.__ngComponentDefs` and is read by\n * `@analogjs/router`'s SSR render function to null cached `tView`\n * objects between requests so that `$localize` tagged templates in\n * `consts()` re-evaluate with the freshly loaded translations.\n *\n * Only active when the platform's `i18n` option is configured.\n * Only transforms `@angular/core` modules in SSR builds.\n */\nexport function i18nDefRegistryPlugin(): vite.Plugin {\n let fixedLocale = false;\n const DETECT_MARKER = 'GENERATED_COMP_IDS.set(compId, componentDef.type);';\n const RETURN_STMT = 'return compId;\\n}';\n\n return {\n name: 'analogjs-i18n-def-registry',\n enforce: 'post',\n configResolved(config) {\n const locale = config.define?.['ANALOG_I18N_FIXED_LOCALE'];\n fixedLocale =\n config.command === 'build' && !!locale && locale !== 'undefined';\n },\n\n transform: {\n filter: {\n id: /\\/@angular\\/core\\//,\n },\n handler(code, id, options) {\n if (fixedLocale || !options?.ssr) return;\n if (!code.includes(DETECT_MARKER)) return;\n\n return {\n code: code.replace(\n RETURN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AAQ,EACN,IAAI,qBACN;GACA,QAAQ,MAAM,IAAI,SAAS;IACzB,IAAI,eAAe,CAAC,SAAS,KAAK;IAClC,IAAI,CAAC,KAAK,SAAS,aAAa,GAAG;IAEnC,OAAO,EACL,MAAM,KAAK,QACT,aACA,sEACE,WACJ,EACF;GACF;EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed-routes-plugin.js","names":[],"sources":["../../../src/lib/typed-routes-plugin.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { readConfiguration } from '@angular/compiler-cli';\nimport { parseSync } from 'oxc-parser';\nimport { normalizePath, type Plugin } from 'vite';\n\nimport {\n createRouteFileDiscovery,\n type RouteFileDiscovery,\n} from './route-file-discovery.js';\nimport {\n generateRouteManifest,\n generateRouteTableDeclaration,\n} from './route-manifest.js';\n\nexport interface TypedRoutingOptions {\n /** Generated declaration path (.d.ts), relative to the app root. */\n outFile?: string;\n /** Fail builds when a checked-in route table is stale. Defaults to true. */\n verifyOnBuild?: boolean;\n}\n\nexport interface TypedRoutesPluginOptions extends TypedRoutingOptions {\n workspaceRoot?: string;\n additionalPagesDirs?: string[];\n additionalContentDirs?: string[];\n}\n\nexport function typedRoutes(options: TypedRoutesPluginOptions = {}): Plugin {\n const workspaceRoot = normalizePath(options.workspaceRoot ?? process.cwd());\n const outFile = options.outFile ?? 'src/routeTree.gen.d.ts';\n if (!outFile.endsWith('.d.ts')) {\n throw new Error(\n '[analog] Typed routing outFile must end in .d.ts. Include this declaration in your application tsconfig.',\n );\n }\n let root: string;\n let command: 'build' | 'serve';\n let discovery: RouteFileDiscovery;\n\n let getTsConfigPath: (() => string) | undefined;\n\n function verifyTypeInclusion(): void {\n if (!getTsConfigPath) return;\n const tsconfig = getTsConfigPath();\n const { rootNames, errors } = readConfiguration(tsconfig);\n if (errors.length) {\n throw new Error(\n `[analog] Cannot verify typed routing: unable to read ${tsconfig}.`,\n );\n }\n const outputPath = normalizePath(resolve(root, outFile));\n if (\n !rootNames.some((file) => normalizePath(resolve(file)) === outputPath)\n ) {\n const declaration = normalizePath(\n relative(dirname(tsconfig), outputPath),\n );\n throw new Error(\n `[analog] Typed route declaration is not included in ${tsconfig}. Add \"${declaration}\" to its \"files\" or \"include\" list so typed routing is available to the compiler and editor.`,\n );\n }\n }\n\n function generate(): void {\n const manifest = generateRouteManifest(\n [...discovery.getRouteFiles(), ...discovery.getContentFiles()],\n (filename) => (discovery.isAppLocal(filename) ? 0 : 1),\n );\n const collisions = manifest.collisions.filter(\n (collision) => collision.samePriority,\n );\n if (command === 'build' && collisions.length) {\n throw new Error(\n `[analog] Route collisions detected: ${collisions.map((c) => `${c.fullPath}: ${c.keptFile}, ${c.droppedFile}`).join('; ')}`,\n );\n }\n const outputPath = join(root, outFile);\n const output = generateRouteTableDeclaration(manifest, (filename) => {\n const pageFile = [\n join(root, filename),\n join(workspaceRoot, filename),\n filename,\n ].find((file) => existsSync(file));\n if (!pageFile) return undefined;\n const serverFile = pageFile.replace(/\\.page\\.ts$/, '.server.ts');\n return {\n routeMeta: hasNamedExport(pageFile, 'routeMeta')\n ? toImportSpecifier(dirname(outputPath), pageFile)\n : undefined,\n load:\n serverFile !== pageFile &&\n existsSync(serverFile) &&\n hasNamedExport(serverFile, 'load')\n ? toImportSpecifier(dirname(outputPath), serverFile)\n : undefined,\n };\n });\n const exists = existsSync(outputPath);\n const current = exists ? readFileSync(outputPath, 'utf8') : '';\n if (current !== output && !sameDeclarations(current, output)) {\n if (exists && command === 'build' && (options.verifyOnBuild ?? true)) {\n throw new Error(\n `[analog] Stale route file: ${outFile}. Run the dev server to regenerate it before building.`,\n );\n }\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, output);\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: options.additionalPagesDirs ?? [],\n additionalContentDirs: options.additionalContentDirs ?? [],\n });\n // Generate before Angular reads the application tsconfig.\n generate();\n },\n configResolved(config) {\n const compiler = config.plugins.find(\n (plugin) =>\n plugin.name === '@analogjs/vite-plugin-angular' ||\n plugin.name === '@analogjs/vite-plugin-angular-fast-compile' ||\n plugin.name === '@analogjs/vite-plugin-angular-compilation-api',\n );\n getTsConfigPath = compiler?.api?.getTsConfigPath;\n if (compiler && !getTsConfigPath) {\n throw new Error(\n '[analog] Typed routing requires a matching @analogjs/vite-plugin-angular version to verify the application tsconfig.',\n );\n }\n verifyTypeInclusion();\n },\n buildStart() {\n discovery.reset();\n generate();\n verifyTypeInclusion();\n },\n configureServer(server) {\n server.watcher.add(join(root, outFile));\n for (const event of ['add', 'change', 'unlink'] as const) {\n server.watcher.on(event, (path) => {\n if (!discovery.getDiscoveredFileKind(path)) return;\n discovery.updateDiscoveredFile(path, event);\n generate();\n });\n }\n },\n };\n}\n\nfunction toImportSpecifier(fromDir: string, file: string): string {\n const specifier = normalizePath(relative(fromDir, file)).replace(/\\.ts$/, '');\n return specifier.startsWith('.') ? specifier : `./${specifier}`;\n}\n\nfunction hasNamedExport(file: string, name: string): boolean {\n const source = readFileSync(file, 'utf8');\n if (!source.includes(name)) return false;\n const { program, errors } = parseSync(file, source);\n if (errors.length) return false;\n return program.body.some((statement) => {\n if (\n statement.type !== 'ExportNamedDeclaration' ||\n statement.exportKind === 'type'\n ) {\n return false;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'VariableDeclaration') {\n return declaration.declarations.some(\n (item) => item.id.type === 'Identifier' && item.id.name === name,\n );\n }\n if (declaration?.type === 'FunctionDeclaration') {\n return declaration.id?.name === name;\n }\n return statement.specifiers.some(\n (specifier) =>\n specifier.exportKind !== 'type' &&\n (specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value) === name,\n );\n });\n}\n\nfunction sameDeclarations(current: string, output: string): boolean {\n const left = parseSync('routeTree.gen.d.ts', current);\n const right = parseSync('routeTree.gen.d.ts', output);\n if (left.errors.length || right.errors.length) return false;\n const withoutFormatting = (key: string, value: unknown) =>\n key === 'start' || key === 'end' || key === 'raw' ? undefined : value;\n return (\n JSON.stringify(left.program, withoutFormatting) ===\n JSON.stringify(right.program, withoutFormatting)\n );\n}\n"],"mappings":";;;;;;;;AA4BA,SAAgB,YAAY,UAAoC,EAAE,EAAU;CAC1E,MAAM,gBAAgB,cAAc,QAAQ,iBAAiB,QAAQ,KAAK,CAAC;CAC3E,MAAM,UAAU,QAAQ,WAAW;AACnC,KAAI,CAAC,QAAQ,SAAS,QAAQ,CAC5B,OAAM,IAAI,MACR,2GACD;CAEH,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,IAAI;CAEJ,SAAS,sBAA4B;AACnC,MAAI,CAAC,gBAAiB;EACtB,MAAM,WAAW,iBAAiB;EAClC,MAAM,EAAE,WAAW,WAAW,kBAAkB,SAAS;AACzD,MAAI,OAAO,OACT,OAAM,IAAI,MACR,wDAAwD,SAAS,GAClE;EAEH,MAAM,aAAa,cAAc,QAAQ,MAAM,QAAQ,CAAC;AACxD,MACE,CAAC,UAAU,MAAM,SAAS,cAAc,QAAQ,KAAK,CAAC,KAAK,WAAW,EACtE;GACA,MAAM,cAAc,cAClB,SAAS,QAAQ,SAAS,EAAE,WAAW,CACxC;AACD,SAAM,IAAI,MACR,uDAAuD,SAAS,SAAS,YAAY,8FACtF;;;CAIL,SAAS,WAAiB;EACxB,MAAM,WAAW,sBACf,CAAC,GAAG,UAAU,eAAe,EAAE,GAAG,UAAU,iBAAiB,CAAC,GAC7D,aAAc,UAAU,WAAW,SAAS,GAAG,IAAI,EACrD;EACD,MAAM,aAAa,SAAS,WAAW,QACpC,cAAc,UAAU,aAC1B;AACD,MAAI,YAAY,WAAW,WAAW,OACpC,OAAM,IAAI,MACR,uCAAuC,WAAW,KAAK,MAAM,GAAG,EAA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AAM,OAAO,UAAU,sBAAsB,QAAQ;CACrD,MAAM,QAAQ,UAAU,sBAAsB,OAAO;AACrD,KAAI,KAAK,OAAO,UAAU,MAAM,OAAO,OAAQ,QAAO;CACtD,MAAM,qBAAqB,KAAa,UACtC,QAAQ,WAAW,QAAQ,SAAS,QAAQ,QAAQ,KAAA,IAAY;AAClE,QACE,KAAK,UAAU,KAAK,SAAS,kBAAkB,KAC/C,KAAK,UAAU,MAAM,SAAS,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"typed-routes-plugin.js","names":[],"sources":["../../../src/lib/typed-routes-plugin.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { readConfiguration } from '@angular/compiler-cli';\nimport { parseSync } from 'oxc-parser';\nimport { normalizePath, type Plugin } from 'vite';\n\nimport {\n createRouteFileDiscovery,\n type RouteFileDiscovery,\n} from './route-file-discovery.js';\nimport {\n generateRouteManifest,\n generateRouteTableDeclaration,\n} from './route-manifest.js';\n\nexport interface TypedRoutingOptions {\n /** Generated declaration path (.d.ts), relative to the app root. */\n outFile?: string;\n /** Fail builds when a checked-in route table is stale. Defaults to true. */\n verifyOnBuild?: boolean;\n}\n\nexport interface TypedRoutesPluginOptions extends TypedRoutingOptions {\n workspaceRoot?: string;\n additionalPagesDirs?: string[];\n additionalContentDirs?: string[];\n}\n\nexport function typedRoutes(options: TypedRoutesPluginOptions = {}): Plugin {\n const workspaceRoot = normalizePath(options.workspaceRoot ?? process.cwd());\n const outFile = options.outFile ?? 'src/routeTree.gen.d.ts';\n if (!outFile.endsWith('.d.ts')) {\n throw new Error(\n '[analog] Typed routing outFile must end in .d.ts. Include this declaration in your application tsconfig.',\n );\n }\n let root: string;\n let command: 'build' | 'serve';\n let discovery: RouteFileDiscovery;\n\n let getTsConfigPath: (() => string) | undefined;\n\n function verifyTypeInclusion(): void {\n if (!getTsConfigPath) return;\n const tsconfig = getTsConfigPath();\n const { rootNames, errors } = readConfiguration(tsconfig);\n if (errors.length) {\n throw new Error(\n `[analog] Cannot verify typed routing: unable to read ${tsconfig}.`,\n );\n }\n const outputPath = normalizePath(resolve(root, outFile));\n if (\n !rootNames.some((file) => normalizePath(resolve(file)) === outputPath)\n ) {\n const declaration = normalizePath(\n relative(dirname(tsconfig), outputPath),\n );\n throw new Error(\n `[analog] Typed route declaration is not included in ${tsconfig}. Add \"${declaration}\" to its \"files\" or \"include\" list so typed routing is available to the compiler and editor.`,\n );\n }\n }\n\n function generate(): void {\n const manifest = generateRouteManifest(\n [...discovery.getRouteFiles(), ...discovery.getContentFiles()],\n (filename) => (discovery.isAppLocal(filename) ? 0 : 1),\n );\n const collisions = manifest.collisions.filter(\n (collision) => collision.samePriority,\n );\n if (command === 'build' && collisions.length) {\n throw new Error(\n `[analog] Route collisions detected: ${collisions.map((c) => `${c.fullPath}: ${c.keptFile}, ${c.droppedFile}`).join('; ')}`,\n );\n }\n const outputPath = join(root, outFile);\n const output = generateRouteTableDeclaration(manifest, (filename) => {\n const pageFile = [\n join(root, filename),\n join(workspaceRoot, filename),\n filename,\n ].find((file) => existsSync(file));\n if (!pageFile) return undefined;\n const serverFile = pageFile.replace(/\\.page\\.ts$/, '.server.ts');\n return {\n routeMeta: hasNamedExport(pageFile, 'routeMeta')\n ? toImportSpecifier(dirname(outputPath), pageFile)\n : undefined,\n load:\n serverFile !== pageFile &&\n existsSync(serverFile) &&\n hasNamedExport(serverFile, 'load')\n ? toImportSpecifier(dirname(outputPath), serverFile)\n : undefined,\n };\n });\n const exists = existsSync(outputPath);\n const current = exists ? readFileSync(outputPath, 'utf8') : '';\n if (current !== output && !sameDeclarations(current, output)) {\n if (exists && command === 'build' && (options.verifyOnBuild ?? true)) {\n throw new Error(\n `[analog] Stale route file: ${outFile}. Run the dev server to regenerate it before building.`,\n );\n }\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, output);\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: options.additionalPagesDirs ?? [],\n additionalContentDirs: options.additionalContentDirs ?? [],\n });\n // Generate before Angular reads the application tsconfig.\n generate();\n },\n configResolved(config) {\n const compiler = config.plugins.find(\n (plugin) =>\n plugin.name === '@analogjs/vite-plugin-angular' ||\n plugin.name === '@analogjs/vite-plugin-angular-fast-compile' ||\n plugin.name === '@analogjs/vite-plugin-angular-compilation-api',\n );\n getTsConfigPath = compiler?.api?.getTsConfigPath;\n if (compiler && !getTsConfigPath) {\n throw new Error(\n '[analog] Typed routing requires a matching @analogjs/vite-plugin-angular version to verify the application tsconfig.',\n );\n }\n verifyTypeInclusion();\n },\n buildStart() {\n discovery.reset();\n generate();\n verifyTypeInclusion();\n },\n configureServer(server) {\n server.watcher.add(join(root, outFile));\n for (const event of ['add', 'change', 'unlink'] as const) {\n server.watcher.on(event, (path) => {\n if (!discovery.getDiscoveredFileKind(path)) return;\n discovery.updateDiscoveredFile(path, event);\n generate();\n });\n }\n },\n };\n}\n\nfunction toImportSpecifier(fromDir: string, file: string): string {\n const specifier = normalizePath(relative(fromDir, file)).replace(/\\.ts$/, '');\n return specifier.startsWith('.') ? specifier : `./${specifier}`;\n}\n\nfunction hasNamedExport(file: string, name: string): boolean {\n const source = readFileSync(file, 'utf8');\n if (!source.includes(name)) return false;\n const { program, errors } = parseSync(file, source);\n if (errors.length) return false;\n return program.body.some((statement) => {\n if (\n statement.type !== 'ExportNamedDeclaration' ||\n statement.exportKind === 'type'\n ) {\n return false;\n }\n const declaration = statement.declaration;\n if (declaration?.type === 'VariableDeclaration') {\n return declaration.declarations.some(\n (item) => item.id.type === 'Identifier' && item.id.name === name,\n );\n }\n if (declaration?.type === 'FunctionDeclaration') {\n return declaration.id?.name === name;\n }\n return statement.specifiers.some(\n (specifier) =>\n specifier.exportKind !== 'type' &&\n (specifier.exported.type === 'Identifier'\n ? specifier.exported.name\n : specifier.exported.value) === name,\n );\n });\n}\n\nfunction sameDeclarations(current: string, output: string): boolean {\n const left = parseSync('routeTree.gen.d.ts', current);\n const right = parseSync('routeTree.gen.d.ts', output);\n if (left.errors.length || right.errors.length) return false;\n const withoutFormatting = (key: string, value: unknown) =>\n key === 'start' || key === 'end' || key === 'raw' ? undefined : value;\n return (\n JSON.stringify(left.program, withoutFormatting) ===\n JSON.stringify(right.program, withoutFormatting)\n );\n}\n"],"mappings":";;;;;;;;AA4BA,SAAgB,YAAY,UAAoC,CAAC,GAAW;CAC1E,MAAM,gBAAgB,cAAc,QAAQ,iBAAiB,QAAQ,IAAI,CAAC;CAC1E,MAAM,UAAU,QAAQ,WAAW;CACnC,IAAI,CAAC,QAAQ,SAAS,OAAO,GAC3B,MAAM,IAAI,MACR,0GACF;CAEF,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,IAAI;CAEJ,SAAS,sBAA4B;EACnC,IAAI,CAAC,iBAAiB;EACtB,MAAM,WAAW,gBAAgB;EACjC,MAAM,EAAE,WAAW,WAAW,kBAAkB,QAAQ;EACxD,IAAI,OAAO,QACT,MAAM,IAAI,MACR,wDAAwD,SAAS,EACnE;EAEF,MAAM,aAAa,cAAc,QAAQ,MAAM,OAAO,CAAC;EACvD,IACE,CAAC,UAAU,MAAM,SAAS,cAAc,QAAQ,IAAI,CAAC,MAAM,UAAU,GACrE;GACA,MAAM,cAAc,cAClB,SAAS,QAAQ,QAAQ,GAAG,UAAU,CACxC;GACA,MAAM,IAAI,MACR,uDAAuD,SAAS,SAAS,YAAY,6FACvF;EACF;CACF;CAEA,SAAS,WAAiB;EACxB,MAAM,WAAW,sBACf,CAAC,GAAG,UAAU,cAAc,GAAG,GAAG,UAAU,gBAAgB,CAAC,IAC5D,aAAc,UAAU,WAAW,QAAQ,IAAI,IAAI,CACtD;EACA,MAAM,aAAa,SAAS,WAAW,QACpC,cAAc,UAAU,YAC3B;EACA,IAAI,Y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UAAU,eAAe,WACxB,UAAU,SAAS,SAAS,eACzB,UAAU,SAAS,OACnB,UAAU,SAAS,WAAW,IACtC;CACF,CAAC;AACH;AAEA,SAAS,iBAAiB,SAAiB,QAAyB;CAClE,MAAM,OAAO,UAAU,sBAAsB,OAAO;CACpD,MAAM,QAAQ,UAAU,sBAAsB,MAAM;CACpD,IAAI,KAAK,OAAO,UAAU,MAAM,OAAO,QAAQ,OAAO;CACtD,MAAM,qBAAqB,KAAa,UACtC,QAAQ,WAAW,QAAQ,SAAS,QAAQ,QAAQ,KAAA,IAAY;CAClE,OACE,KAAK,UAAU,KAAK,SAAS,iBAAiB,MAC9C,KAAK,UAAU,MAAM,SAAS,iBAAiB;AAEnD"}
|
|
@@ -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;
|
|
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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MAAM,eAAe,MAAM,WAAW;KACtC,WACE,OACA,OAAO,mBACP,gBAAgB,SAChB,IACF;IACF;IACA;GACF;GAEA,WAAW,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
|
-
|
|
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,
|
|
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"}
|
package/src/lib/utils/debug.js
CHANGED
|
@@ -3,19 +3,22 @@ import { createDebugHarness } from "./debug-harness.js";
|
|
|
3
3
|
import { createDebug } from "obug";
|
|
4
4
|
//#region packages/platform/src/lib/utils/debug.ts
|
|
5
5
|
var debugPlatform = createDebug("analog:platform");
|
|
6
|
+
var debugRoutes = createDebug("analog:platform:routes");
|
|
7
|
+
var debugContent = createDebug("analog:platform:content");
|
|
8
|
+
var debugTypedRouter = createDebug("analog:platform:typed-router");
|
|
6
9
|
var harness = createDebugHarness({
|
|
7
10
|
fallbackNamespace: "analog:*",
|
|
8
11
|
instanceGroups: [[
|
|
9
12
|
debugPlatform,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
debugRoutes,
|
|
14
|
+
debugContent,
|
|
15
|
+
debugTypedRouter
|
|
13
16
|
], nitroDebugInstances]
|
|
14
17
|
});
|
|
15
18
|
var applyDebugOption = harness.applyDebugOption;
|
|
16
19
|
var activateDeferredDebug = harness.activateDeferredDebug;
|
|
17
20
|
harness._resetDeferredDebug;
|
|
18
21
|
//#endregion
|
|
19
|
-
export { activateDeferredDebug, applyDebugOption, debugPlatform };
|
|
22
|
+
export { activateDeferredDebug, applyDebugOption, debugContent, debugPlatform, debugRoutes, debugTypedRouter };
|
|
20
23
|
|
|
21
24
|
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","names":[],"sources":["../../../../src/lib/utils/debug.ts"],"sourcesContent":["import { createDebug } from 'obug';\nimport { nitroDebugInstances } from '../nitro/debug.js';\nimport { createDebugHarness } from './debug-harness.js';\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');\n\nconst platformDebugInstances = [\n debugPlatform,\n debugRoutes,\n debugContent,\n debugTypedRouter,\n];\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:angular:*'\n | 'analog:angular:hmr'\n | 'analog:angular:styles'\n | 'analog:angular:compiler'\n | 'analog:angular:compilation-api'\n | 'analog:angular:style-pipeline'\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 * 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:*',\n instanceGroups: [platformDebugInstances, nitroDebugInstances],\n});\n\nexport const applyDebugOption: (\n debug: DebugOption | undefined,\n workspaceRoot?: string,\n) => void = harness.applyDebugOption;\nexport const activateDeferredDebug: (command: 'build' | 'serve') => void =\n harness.activateDeferredDebug;\nexport const _resetDeferredDebug: () => void = harness._resetDeferredDebug;\n"],"mappings":";;;;AAIA,IAAa,gBAAgB,YAAY,
|
|
1
|
+
{"version":3,"file":"debug.js","names":[],"sources":["../../../../src/lib/utils/debug.ts"],"sourcesContent":["import { createDebug } from 'obug';\nimport { nitroDebugInstances } from '../nitro/debug.js';\nimport { createDebugHarness } from './debug-harness.js';\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');\n\nconst platformDebugInstances = [\n debugPlatform,\n debugRoutes,\n debugContent,\n debugTypedRouter,\n];\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:angular:*'\n | 'analog:angular:hmr'\n | 'analog:angular:styles'\n | 'analog:angular:compiler'\n | 'analog:angular:compilation-api'\n | 'analog:angular:style-pipeline'\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 * 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:*',\n instanceGroups: [platformDebugInstances, nitroDebugInstances],\n});\n\nexport const applyDebugOption: (\n debug: DebugOption | undefined,\n workspaceRoot?: string,\n) => void = harness.applyDebugOption;\nexport const activateDeferredDebug: (command: 'build' | 'serve') => void =\n harness.activateDeferredDebug;\nexport const _resetDeferredDebug: () => void = harness._resetDeferredDebug;\n"],"mappings":";;;;AAIA,IAAa,gBAAgB,YAAY,iBAAiB;AAC1D,IAAa,cAAc,YAAY,wBAAwB;AAC/D,IAAa,eAAe,YAAY,yBAAyB;AACjE,IAAa,mBAAmB,YAAY,8BAA8B;AA+C1E,IAAM,UAAU,mBAAmB;CACjC,mBAAmB;CACnB,gBAAgB,CAAC;EA9CjB;EACA;EACA;EACA;CA2CiB,GAAwB,mBAAmB;AAC9D,CAAC;AAED,IAAa,mBAGD,QAAQ;AACpB,IAAa,wBACX,QAAQ;AACqC,QAAQ"}
|
|
@@ -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\nexport function getBundleOptionsKey(): 'rolldownOptions' | 'rollupOptions' {\n return isRolldown() ? 'rolldownOptions' : 'rollupOptions';\n}\n"],"mappings":";;AAEA,SAAgB,aAAsB;
|
|
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\nexport function getBundleOptionsKey(): 'rolldownOptions' | 'rollupOptions' {\n return isRolldown() ? 'rolldownOptions' : 'rollupOptions';\n}\n"],"mappings":";;AAEA,SAAgB,aAAsB;CACpC,OAAO,CAAC,CAAC,KAAK;AAChB;AAEA,SAAgB,0BAA6C;CAC3D,OAAO,WAAW,IAAI,QAAQ;AAChC;AAEA,SAAgB,sBAA2D;CACzE,OAAO,WAAW,IAAI,oBAAoB;AAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-mode-plugin.js","names":[],"sources":["../../src/server-mode-plugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { Plugin, normalizePath } from 'vite';\n\nexport const SERVER_MODE_ID = 'virtual:@analogjs/platform/server-mode';\nconst RESOLVED_SERVER_MODE_ID = `\\0${SERVER_MODE_ID}`;\n\n/**\n * Serves a module that sets `globalThis.ngServerMode = true`.\n *\n * Angular decides at provider-creation time whether browser-only features\n * such as event replay apply, and `provideClientHydration()` runs while the\n * app config module evaluates, before `platformServer()` or\n * `provideServerRendering()` set the flag. The SSR entry imports this module\n * first so the flag is set before any application module evaluates. A text\n * replacement cannot do this because Angular is pre-bundled for SSR.\n */\nexport function serverModePlugin(entryServer?: string): Plugin[] {\n let entryServerPath = '';\n\n return [\n {\n name: 'analogjs-server-mode-plugin',\n configResolved(config) {\n entryServerPath = normalizePath(\n resolve(config.root, entryServer ?? 'src/main.server.ts'),\n );\n },\n // Nitro v2 builds `main.server.ts` as the SSR entry directly, so set the\n // flag there too.\n transform(code, id, options) {\n if (options?.ssr && normalizePath(id) === entryServerPath) {\n return {\n code: `import ${JSON.stringify(SERVER_MODE_ID)};\\n${code}`,\n map: null,\n };\n }\n return undefined;\n },\n resolveId(id) {\n return id === SERVER_MODE_ID ? RESOLVED_SERVER_MODE_ID : undefined;\n },\n load(id) {\n return id === RESOLVED_SERVER_MODE_ID\n ? 'globalThis.ngServerMode = true;\\nexport {};\\n'\n : undefined;\n },\n },\n ];\n}\n"],"mappings":";;;AAGA,IAAa,iBAAiB;AAC9B,IAAM,0BAA0B,KAAK;;;;;;;;;;;AAYrC,SAAgB,iBAAiB,aAAgC;CAC/D,IAAI,kBAAkB;
|
|
1
|
+
{"version":3,"file":"server-mode-plugin.js","names":[],"sources":["../../src/server-mode-plugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { Plugin, normalizePath } from 'vite';\n\nexport const SERVER_MODE_ID = 'virtual:@analogjs/platform/server-mode';\nconst RESOLVED_SERVER_MODE_ID = `\\0${SERVER_MODE_ID}`;\n\n/**\n * Serves a module that sets `globalThis.ngServerMode = true`.\n *\n * Angular decides at provider-creation time whether browser-only features\n * such as event replay apply, and `provideClientHydration()` runs while the\n * app config module evaluates, before `platformServer()` or\n * `provideServerRendering()` set the flag. The SSR entry imports this module\n * first so the flag is set before any application module evaluates. A text\n * replacement cannot do this because Angular is pre-bundled for SSR.\n */\nexport function serverModePlugin(entryServer?: string): Plugin[] {\n let entryServerPath = '';\n\n return [\n {\n name: 'analogjs-server-mode-plugin',\n configResolved(config) {\n entryServerPath = normalizePath(\n resolve(config.root, entryServer ?? 'src/main.server.ts'),\n );\n },\n // Nitro v2 builds `main.server.ts` as the SSR entry directly, so set the\n // flag there too.\n transform(code, id, options) {\n if (options?.ssr && normalizePath(id) === entryServerPath) {\n return {\n code: `import ${JSON.stringify(SERVER_MODE_ID)};\\n${code}`,\n map: null,\n };\n }\n return undefined;\n },\n resolveId(id) {\n return id === SERVER_MODE_ID ? RESOLVED_SERVER_MODE_ID : undefined;\n },\n load(id) {\n return id === RESOLVED_SERVER_MODE_ID\n ? 'globalThis.ngServerMode = true;\\nexport {};\\n'\n : undefined;\n },\n },\n ];\n}\n"],"mappings":";;;AAGA,IAAa,iBAAiB;AAC9B,IAAM,0BAA0B,KAAK;;;;;;;;;;;AAYrC,SAAgB,iBAAiB,aAAgC;CAC/D,IAAI,kBAAkB;CAEtB,OAAO,CACL;EACE,MAAM;EACN,eAAe,QAAQ;GACrB,kBAAkB,cAChB,QAAQ,OAAO,MAAM,eAAe,oBAAoB,CAC1D;EACF;EAGA,UAAU,MAAM,IAAI,SAAS;GAC3B,IAAI,SAAS,OAAO,cAAc,EAAE,MAAM,iBACxC,OAAO;IACL,MAAM,UAAU,KAAK,UAAU,cAAc,EAAE,KAAK;IACpD,KAAK;GACP;EAGJ;EACA,UAAU,IAAI;GACZ,OAAO,OAAA,2CAAwB,0BAA0B,KAAA;EAC3D;EACA,KAAK,IAAI;GACP,OAAO,OAAO,0BACV,kDACA,KAAA;EACN;CACF,CACF;AACF"}
|