@analogjs/vite-plugin-nitro 3.0.0-beta.50 → 3.0.0-beta.52

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/vite-plugin-nitro",
3
- "version": "3.0.0-beta.50",
3
+ "version": "3.0.0-beta.52",
4
4
  "description": "A Vite plugin for adding a nitro API server",
5
5
  "type": "module",
6
6
  "author": "Brandon Roberts <robertsbt@gmail.com>",
@@ -6,7 +6,7 @@ export type PagesJson = {
6
6
  changefreq?: string;
7
7
  priority?: string;
8
8
  };
9
- export declare function buildSitemap(config: UserConfig, sitemapConfig: SitemapConfig, routes: (string | undefined)[] | (() => Promise<(string | undefined)[]>), outputDir: string, routeSitemaps: Record<string, PrerenderSitemapConfig | (() => PrerenderSitemapConfig) | undefined>, i18nOptions?: I18nPrerenderOptions): Promise<void>;
9
+ export declare function buildSitemap(config: UserConfig, sitemapConfig: SitemapConfig, routes: (string | undefined)[] | (() => Promise<(string | undefined)[]>), outputDir: string, routeSitemaps: Record<string, PrerenderSitemapConfig | (() => PrerenderSitemapConfig) | undefined>, i18nOptions?: I18nPrerenderOptions, apiPrefix?: string): Promise<void>;
10
10
  /**
11
11
  * Generates hreflang alternate URLs for a given page URL.
12
12
  * For a URL like `https://example.com/fr/about`, it produces alternates
@@ -2,16 +2,16 @@ import { resolve } from "node:path";
2
2
  import { writeFileSync } from "node:fs";
3
3
  import { create } from "xmlbuilder2";
4
4
  //#region packages/vite-plugin-nitro/src/lib/build-sitemap.ts
5
- async function buildSitemap(config, sitemapConfig, routes, outputDir, routeSitemaps, i18nOptions) {
6
- const routeList = await optionHasRoutes(routes);
5
+ async function buildSitemap(config, sitemapConfig, routes, outputDir, routeSitemaps, i18nOptions, apiPrefix = "/api") {
6
+ const routeList = (await optionHasRoutes(routes)).filter((route) => !route.startsWith(`${apiPrefix}/_analog/pages/`) && !route.includes("?"));
7
7
  if (routeList.length) {
8
8
  const slash = checkSlash(sitemapConfig.host || "");
9
9
  const sitemapData = routeList.map((page) => {
10
- const url = `${slash}${page.replace(/^\/+/g, "")}`;
11
- const config = routeSitemaps[url];
10
+ const path = page.replace(/^\/+/g, "");
11
+ const config = routeSitemaps[`/${path}`] ?? (Object.prototype.hasOwnProperty.call(routeSitemaps, path) ? routeSitemaps[path] : void 0);
12
12
  const props = typeof config === "object" ? config : config?.();
13
13
  return {
14
- page: `${sitemapConfig.host}${url}`,
14
+ page: `${sitemapConfig.host}${slash}${path}`,
15
15
  lastMod: props?.lastmod ?? (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
16
16
  changefreq: props?.changefreq,
17
17
  priority: props?.priority
@@ -1 +1 @@
1
- {"version":3,"file":"build-sitemap.js","names":[],"sources":["../../../src/lib/build-sitemap.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { XMLBuilder } from 'xmlbuilder2/lib/interfaces';\nimport { create } from 'xmlbuilder2';\nimport { UserConfig } from 'vite';\nimport { resolve } from 'node:path';\nimport {\n I18nPrerenderOptions,\n PrerenderContentFile,\n PrerenderSitemapConfig,\n SitemapConfig,\n} from './options';\n\nexport type PagesJson = {\n page: string;\n lastMod: string;\n changefreq?: string;\n priority?: string;\n};\n\nexport async function buildSitemap(\n config: UserConfig,\n sitemapConfig: SitemapConfig,\n routes: (string | undefined)[] | (() => Promise<(string | undefined)[]>),\n outputDir: string,\n routeSitemaps: Record<\n string,\n PrerenderSitemapConfig | (() => PrerenderSitemapConfig) | undefined\n >,\n i18nOptions?: I18nPrerenderOptions,\n): Promise<void> {\n const routeList: string[] = await optionHasRoutes(routes);\n\n if (routeList.length) {\n const slash = checkSlash(sitemapConfig.host || '');\n const sitemapData: PagesJson[] = routeList.map((page: string) => {\n const url = `${slash}${page.replace(/^\\/+/g, '')}`;\n const config = routeSitemaps[url];\n const props = typeof config === 'object' ? config : config?.();\n\n return {\n page: `${sitemapConfig.host}${url}`,\n lastMod: props?.lastmod ?? new Date().toISOString().split('T')[0],\n changefreq: props?.changefreq,\n priority: props?.priority,\n };\n });\n\n const hasI18n = i18nOptions && i18nOptions.locales.length > 1;\n const sitemap = createXml('urlset', hasI18n);\n\n for (const item of sitemapData) {\n const page = sitemap.ele('url');\n page.ele('loc').txt(item.page);\n page.ele('lastmod').txt(item.lastMod);\n\n if (item.changefreq) {\n page.ele('changefreq').txt(item.changefreq);\n }\n\n if (item.priority) {\n page.ele('priority').txt(item.priority);\n }\n\n // Add hreflang alternate links for each locale\n if (hasI18n) {\n const alternates = getHreflangAlternates(\n item.page,\n sitemapConfig.host,\n i18nOptions,\n );\n for (const alt of alternates) {\n page\n .ele('xhtml:link')\n .att('rel', 'alternate')\n .att('hreflang', alt.locale)\n .att('href', alt.href);\n }\n }\n }\n\n const mapPath = `${resolve(outputDir)}/sitemap.xml`;\n try {\n console.log(`Writing sitemap at ${mapPath}`);\n writeFileSync(mapPath, sitemap.end({ prettyPrint: true }));\n } catch (e) {\n console.error(`Unable to write file at ${mapPath}`, e);\n }\n }\n}\n\n/**\n * Generates hreflang alternate URLs for a given page URL.\n * For a URL like `https://example.com/fr/about`, it produces alternates\n * for all configured locales.\n */\nexport function getHreflangAlternates(\n pageUrl: string,\n host: string,\n i18n: I18nPrerenderOptions,\n): { locale: string; href: string }[] {\n const alternates: { locale: string; href: string }[] = [];\n const normalizedHost = host.replace(/\\/+$/, '');\n\n // Extract the path portion after the host\n const path = pageUrl.replace(normalizedHost, '');\n\n // Strip locale prefix to get the base path\n const basePath = stripLocalePrefix(path, i18n.locales);\n\n for (const locale of i18n.locales) {\n const localizedPath =\n basePath === '/' || basePath === ''\n ? `/${locale}`\n : `/${locale}${basePath}`;\n alternates.push({\n locale,\n href: `${normalizedHost}${localizedPath}`,\n });\n }\n\n // Add x-default pointing to the default locale variant\n const defaultPath =\n basePath === '/' || basePath === ''\n ? `/${i18n.defaultLocale}`\n : `/${i18n.defaultLocale}${basePath}`;\n alternates.push({\n locale: 'x-default',\n href: `${normalizedHost}${defaultPath}`,\n });\n\n return alternates;\n}\n\n/**\n * Strips a locale prefix from a URL path.\n * E.g., '/fr/about' -> '/about', '/en' -> '/'\n */\nexport function stripLocalePrefix(path: string, locales: string[]): string {\n const segments = path.split('/').filter(Boolean);\n if (segments.length > 0 && locales.includes(segments[0])) {\n const rest = segments.slice(1).join('/');\n return rest ? `/${rest}` : '/';\n }\n return path || '/';\n}\n\nfunction createXml(\n elementName: 'urlset' | 'sitemapindex',\n includeXhtml = false,\n): XMLBuilder {\n const attrs: Record<string, string> = {\n xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9',\n };\n if (includeXhtml) {\n attrs['xmlns:xhtml'] = 'http://www.w3.org/1999/xhtml';\n }\n\n return create({ version: '1.0', encoding: 'UTF-8' })\n .ele(elementName, attrs)\n .com(`This file was automatically generated by Analog.`);\n}\n\nfunction checkSlash(host: string): string {\n const finalChar = host.slice(-1);\n return finalChar === '/' ? '' : '/';\n}\n\nasync function optionHasRoutes(\n routes: (string | undefined)[] | (() => Promise<(string | undefined)[]>),\n): Promise<string[]> {\n let routeList: (string | undefined)[];\n\n if (typeof routes === 'function') {\n // returns an array or undefined\n routeList = await routes();\n } else if (Array.isArray(routes)) {\n // returns an array of strings\n routeList = routes;\n } else {\n // default it to an empty of array\n routeList = [];\n }\n\n return routeList.filter(Boolean) as string[];\n}\n"],"mappings":";;;;AAmBA,eAAsB,aACpB,QACA,eACA,QACA,WACA,eAIA,aACe;CACf,MAAM,YAAsB,MAAM,gBAAgB,MAAM;CAExD,IAAI,UAAU,QAAQ;EACpB,MAAM,QAAQ,WAAW,cAAc,QAAQ,EAAE;EACjD,MAAM,cAA2B,UAAU,KAAK,SAAiB;GAC/D,MAAM,MAAM,GAAG,QAAQ,KAAK,QAAQ,SAAS,EAAE;GAC/C,MAAM,SAAS,cAAc;GAC7B,MAAM,QAAQ,OAAO,WAAW,WAAW,SAAS,SAAS;GAE7D,OAAO;IACL,MAAM,GAAG,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,KAAK,SAAS;EACjC,MAAM,gBACJ,aAAa,OAAO,aAAa,KAC7B,IAAI,WACJ,IAAI,SAAS;EACnB,WAAW,KAAK;GACd;GACA,MAAM,GAAG,iBAAiB;EAC5B,CAAC;CACH;CAGA,MAAM,cACJ,aAAa,OAAO,aAAa,KAC7B,IAAI,KAAK,kBACT,IAAI,KAAK,gBAAgB;CAC/B,WAAW,KAAK;EACd,QAAQ;EACR,MAAM,GAAG,iBAAiB;CAC5B,CAAC;CAED,OAAO;AACT;;;;;AAMA,SAAgB,kBAAkB,MAAc,SAA2B;CACzE,MAAM,WAAW,KAAK,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAC/C,IAAI,SAAS,SAAS,KAAK,QAAQ,SAAS,SAAS,EAAE,GAAG;EACxD,MAAM,OAAO,SAAS,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG;EACvC,OAAO,OAAO,IAAI,SAAS;CAC7B;CACA,OAAO,QAAQ;AACjB;AAEA,SAAS,UACP,aACA,eAAe,OACH;CACZ,MAAM,QAAgC,EACpC,OAAO,8CACT;CACA,IAAI,cACF,MAAM,iBAAiB;CAGzB,OAAO,OAAO;EAAE,SAAS;EAAO,UAAU;CAAQ,CAAC,CAAC,CACjD,IAAI,aAAa,KAAK,CAAC,CACvB,IAAI,kDAAkD;AAC3D;AAEA,SAAS,WAAW,MAAsB;CAExC,OADkB,KAAK,MAAM,EACtB,MAAc,MAAM,KAAK;AAClC;AAEA,eAAe,gBACb,QACmB;CACnB,IAAI;CAEJ,IAAI,OAAO,WAAW,YAEpB,YAAY,MAAM,OAAO;MACpB,IAAI,MAAM,QAAQ,MAAM,GAE7B,YAAY;MAGZ,YAAY,CAAC;CAGf,OAAO,UAAU,OAAO,OAAO;AACjC"}
1
+ {"version":3,"file":"build-sitemap.js","names":[],"sources":["../../../src/lib/build-sitemap.ts"],"sourcesContent":["import { writeFileSync } from 'node:fs';\nimport { XMLBuilder } from 'xmlbuilder2/lib/interfaces';\nimport { create } from 'xmlbuilder2';\nimport { UserConfig } from 'vite';\nimport { resolve } from 'node:path';\nimport {\n I18nPrerenderOptions,\n PrerenderContentFile,\n PrerenderSitemapConfig,\n SitemapConfig,\n} from './options';\n\nexport type PagesJson = {\n page: string;\n lastMod: string;\n changefreq?: string;\n priority?: string;\n};\n\nexport async function buildSitemap(\n config: UserConfig,\n sitemapConfig: SitemapConfig,\n routes: (string | undefined)[] | (() => Promise<(string | undefined)[]>),\n outputDir: string,\n routeSitemaps: Record<\n string,\n PrerenderSitemapConfig | (() => PrerenderSitemapConfig) | undefined\n >,\n i18nOptions?: I18nPrerenderOptions,\n apiPrefix = '/api',\n): Promise<void> {\n // Internal static-data endpoints and routes with query params are not\n // canonical pages, so they are left out of the sitemap.\n const routeList: string[] = (await optionHasRoutes(routes)).filter(\n (route) =>\n !route.startsWith(`${apiPrefix}/_analog/pages/`) && !route.includes('?'),\n );\n\n if (routeList.length) {\n const slash = checkSlash(sitemapConfig.host || '');\n const sitemapData: PagesJson[] = routeList.map((page: string) => {\n const path = page.replace(/^\\/+/g, '');\n const config =\n routeSitemaps[`/${path}`] ??\n (Object.prototype.hasOwnProperty.call(routeSitemaps, path)\n ? routeSitemaps[path]\n : undefined);\n const props = typeof config === 'object' ? config : config?.();\n\n return {\n page: `${sitemapConfig.host}${slash}${path}`,\n lastMod: props?.lastmod ?? new Date().toISOString().split('T')[0],\n changefreq: props?.changefreq,\n priority: props?.priority,\n };\n });\n\n const hasI18n = i18nOptions && i18nOptions.locales.length > 1;\n const sitemap = createXml('urlset', hasI18n);\n\n for (const item of sitemapData) {\n const page = sitemap.ele('url');\n page.ele('loc').txt(item.page);\n page.ele('lastmod').txt(item.lastMod);\n\n if (item.changefreq) {\n page.ele('changefreq').txt(item.changefreq);\n }\n\n if (item.priority) {\n page.ele('priority').txt(item.priority);\n }\n\n // Add hreflang alternate links for each locale\n if (hasI18n) {\n const alternates = getHreflangAlternates(\n item.page,\n sitemapConfig.host,\n i18nOptions,\n );\n for (const alt of alternates) {\n page\n .ele('xhtml:link')\n .att('rel', 'alternate')\n .att('hreflang', alt.locale)\n .att('href', alt.href);\n }\n }\n }\n\n const mapPath = `${resolve(outputDir)}/sitemap.xml`;\n try {\n console.log(`Writing sitemap at ${mapPath}`);\n writeFileSync(mapPath, sitemap.end({ prettyPrint: true }));\n } catch (e) {\n console.error(`Unable to write file at ${mapPath}`, e);\n }\n }\n}\n\n/**\n * Generates hreflang alternate URLs for a given page URL.\n * For a URL like `https://example.com/fr/about`, it produces alternates\n * for all configured locales.\n */\nexport function getHreflangAlternates(\n pageUrl: string,\n host: string,\n i18n: I18nPrerenderOptions,\n): { locale: string; href: string }[] {\n const alternates: { locale: string; href: string }[] = [];\n const normalizedHost = host.replace(/\\/+$/, '');\n\n // Extract the path portion after the host\n const path = pageUrl.replace(normalizedHost, '');\n\n // Strip locale prefix to get the base path\n const basePath = stripLocalePrefix(path, i18n.locales);\n\n for (const locale of i18n.locales) {\n const localizedPath =\n basePath === '/' || basePath === ''\n ? `/${locale}`\n : `/${locale}${basePath}`;\n alternates.push({\n locale,\n href: `${normalizedHost}${localizedPath}`,\n });\n }\n\n // Add x-default pointing to the default locale variant\n const defaultPath =\n basePath === '/' || basePath === ''\n ? `/${i18n.defaultLocale}`\n : `/${i18n.defaultLocale}${basePath}`;\n alternates.push({\n locale: 'x-default',\n href: `${normalizedHost}${defaultPath}`,\n });\n\n return alternates;\n}\n\n/**\n * Strips a locale prefix from a URL path.\n * E.g., '/fr/about' -> '/about', '/en' -> '/'\n */\nexport function stripLocalePrefix(path: string, locales: string[]): string {\n const segments = path.split('/').filter(Boolean);\n if (segments.length > 0 && locales.includes(segments[0])) {\n const rest = segments.slice(1).join('/');\n return rest ? `/${rest}` : '/';\n }\n return path || '/';\n}\n\nfunction createXml(\n elementName: 'urlset' | 'sitemapindex',\n includeXhtml = false,\n): XMLBuilder {\n const attrs: Record<string, string> = {\n xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9',\n };\n if (includeXhtml) {\n attrs['xmlns:xhtml'] = 'http://www.w3.org/1999/xhtml';\n }\n\n return create({ version: '1.0', encoding: 'UTF-8' })\n .ele(elementName, attrs)\n .com(`This file was automatically generated by Analog.`);\n}\n\nfunction checkSlash(host: string): string {\n const finalChar = host.slice(-1);\n return finalChar === '/' ? '' : '/';\n}\n\nasync function optionHasRoutes(\n routes: (string | undefined)[] | (() => Promise<(string | undefined)[]>),\n): Promise<string[]> {\n let routeList: (string | undefined)[];\n\n if (typeof routes === 'function') {\n // returns an array or undefined\n routeList = await routes();\n } else if (Array.isArray(routes)) {\n // returns an array of strings\n routeList = routes;\n } else {\n // default it to an empty of array\n routeList = [];\n }\n\n return routeList.filter(Boolean) as string[];\n}\n"],"mappings":";;;;AAmBA,eAAsB,aACpB,QACA,eACA,QACA,WACA,eAIA,aACA,YAAY,QACG;CAGf,MAAM,aAAuB,MAAM,gBAAgB,MAAM,EAAA,CAAG,QACzD,UACC,CAAC,MAAM,WAAW,GAAG,UAAU,gBAAgB,KAAK,CAAC,MAAM,SAAS,GAAG,CAC3E;CAEA,IAAI,UAAU,QAAQ;EACpB,MAAM,QAAQ,WAAW,cAAc,QAAQ,EAAE;EACjD,MAAM,cAA2B,UAAU,KAAK,SAAiB;GAC/D,MAAM,OAAO,KAAK,QAAQ,SAAS,EAAE;GACrC,MAAM,SACJ,cAAc,IAAI,YACjB,OAAO,UAAU,eAAe,KAAK,eAAe,IAAI,IACrD,cAAc,QACd,KAAA;GACN,MAAM,QAAQ,OAAO,WAAW,WAAW,SAAS,SAAS;GAE7D,OAAO;IACL,MAAM,GAAG,cAAc,OAAO,QAAQ;IACtC,SAAS,OAAO,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/D,YAAY,OAAO;IACnB,UAAU,OAAO;GACnB;EACF,CAAC;EAED,MAAM,UAAU,eAAe,YAAY,QAAQ,SAAS;EAC5D,MAAM,UAAU,UAAU,UAAU,OAAO;EAE3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KAAK;EACd,QAAQ;EACR,MAAM,GAAG,iBAAiB;CAC5B,CAAC;CAED,OAAO;AACT;;;;;AAMA,SAAgB,kBAAkB,MAAc,SAA2B;CACzE,MAAM,WAAW,KAAK,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAC/C,IAAI,SAAS,SAAS,KAAK,QAAQ,SAAS,SAAS,EAAE,GAAG;EACxD,MAAM,OAAO,SAAS,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG;EACvC,OAAO,OAAO,IAAI,SAAS;CAC7B;CACA,OAAO,QAAQ;AACjB;AAEA,SAAS,UACP,aACA,eAAe,OACH;CACZ,MAAM,QAAgC,EACpC,OAAO,8CACT;CACA,IAAI,cACF,MAAM,iBAAiB;CAGzB,OAAO,OAAO;EAAE,SAAS;EAAO,UAAU;CAAQ,CAAC,CAAC,CACjD,IAAI,aAAa,KAAK,CAAC,CACvB,IAAI,kDAAkD;AAC3D;AAEA,SAAS,WAAW,MAAsB;CAExC,OADkB,KAAK,MAAM,EACtB,MAAc,MAAM,KAAK;AAClC;AAEA,eAAe,gBACb,QACmB;CACnB,IAAI;CAEJ,IAAI,OAAO,WAAW,YAEpB,YAAY,MAAM,OAAO;MACpB,IAAI,MAAM,QAAQ,MAAM,GAE7B,YAAY;MAGZ,YAAY,CAAC;CAGf,OAAO,UAAU,OAAO,OAAO;AACjC"}
@@ -12,9 +12,10 @@ import { I18nPrerenderOptions } from "../options.js";
12
12
  *
13
13
  * @param routes - The original routes to expand
14
14
  * @param i18n - The i18n prerender configuration
15
+ * @param apiPrefix - The API route prefix (default `api`); API routes are not localized
15
16
  * @returns Expanded routes with locale prefixes
16
17
  */
17
- export declare function expandRoutesWithLocales(routes: string[], i18n: I18nPrerenderOptions): string[];
18
+ export declare function expandRoutesWithLocales(routes: string[], i18n: I18nPrerenderOptions, apiPrefix?: string): string[];
18
19
  /**
19
20
  * Creates a post-rendering hook that injects the `lang` attribute
20
21
  * into the `<html>` tag of prerendered pages based on the route's
@@ -11,13 +11,15 @@
11
11
  *
12
12
  * @param routes - The original routes to expand
13
13
  * @param i18n - The i18n prerender configuration
14
+ * @param apiPrefix - The API route prefix (default `api`); API routes are not localized
14
15
  * @returns Expanded routes with locale prefixes
15
16
  */
16
- function expandRoutesWithLocales(routes, i18n) {
17
+ function expandRoutesWithLocales(routes, i18n, apiPrefix = "api") {
17
18
  const expanded = /* @__PURE__ */ new Set();
19
+ const apiRoute = `/${apiPrefix.replace(/^\/+|\/+$/g, "")}`;
18
20
  for (const route of routes) {
19
21
  const firstSegment = route.split("/").filter(Boolean)[0];
20
- if (route.includes("/_analog/") || route.startsWith("/api/") || i18n.locales.includes(firstSegment)) {
22
+ if (route.includes("/_analog/") || route === apiRoute || route.startsWith(`${apiRoute}/`) || i18n.locales.includes(firstSegment)) {
21
23
  expanded.add(route);
22
24
  continue;
23
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"i18n-prerender.js","names":[],"sources":["../../../../src/lib/utils/i18n-prerender.ts"],"sourcesContent":["import { PrerenderRoute } from 'nitropack';\nimport { I18nPrerenderOptions } from '../options.js';\n\n/**\n * Expands a list of routes to include locale-prefixed variants.\n *\n * For each route and each locale, generates a prefixed route:\n * '/' + locale + route\n *\n * The default locale's routes are included both with and without the prefix\n * so that `/about` and `/en/about` both render.\n * Routes that already have a configured locale prefix are kept as-is.\n *\n * @param routes - The original routes to expand\n * @param i18n - The i18n prerender configuration\n * @returns Expanded routes with locale prefixes\n */\nexport function expandRoutesWithLocales(\n routes: string[],\n i18n: I18nPrerenderOptions,\n): string[] {\n const expanded = new Set<string>();\n\n for (const route of routes) {\n // API routes and explicitly localized routes don't need locale prefixes.\n const firstSegment = route.split('/').filter(Boolean)[0];\n if (\n route.includes('/_analog/') ||\n route.startsWith('/api/') ||\n i18n.locales.includes(firstSegment)\n ) {\n expanded.add(route);\n continue;\n }\n\n for (const locale of i18n.locales) {\n const prefix = `/${locale}`;\n const localizedRoute = route === '/' ? prefix : `${prefix}${route}`;\n expanded.add(localizedRoute);\n }\n\n // Keep the unprefixed route for the default locale\n expanded.add(route);\n }\n\n return [...expanded];\n}\n\n/**\n * Creates a post-rendering hook that injects the `lang` attribute\n * into the `<html>` tag of prerendered pages based on the route's\n * locale prefix.\n *\n * @param i18n - The i18n prerender configuration\n * @returns A post-rendering hook function\n */\nexport function createI18nPostRenderingHook(\n i18n: I18nPrerenderOptions,\n): (route: PrerenderRoute) => Promise<void> {\n return async (route: PrerenderRoute) => {\n if (!route.contents || typeof route.contents !== 'string') {\n return;\n }\n\n const locale = detectLocaleFromRoute(route.route, i18n);\n if (!locale) {\n return;\n }\n\n // Inject or replace the lang attribute on <html>\n route.contents = setHtmlLang(route.contents, locale);\n };\n}\n\n/**\n * Detects the locale from a prerendered route path by checking\n * the first path segment against the configured locales.\n */\nexport function detectLocaleFromRoute(\n route: string,\n i18n: I18nPrerenderOptions,\n): string {\n const segments = route.split('/').filter(Boolean);\n const firstSegment = segments[0];\n\n if (firstSegment && i18n.locales.includes(firstSegment)) {\n return firstSegment;\n }\n\n return i18n.defaultLocale;\n}\n\n/**\n * Sets the `lang` attribute on the `<html>` tag in an HTML string.\n * If a `lang` attribute already exists, it is replaced.\n * If no `lang` attribute exists, it is added.\n */\nexport function setHtmlLang(html: string, locale: string): string {\n // Replace existing lang attribute\n if (/<html[^>]*\\slang\\s*=\\s*[\"'][^\"']*[\"']/i.test(html)) {\n return html.replace(\n /(<html[^>]*\\s)lang\\s*=\\s*[\"'][^\"']*[\"']/i,\n `$1lang=\"${locale}\"`,\n );\n }\n\n // Add lang attribute to <html> tag\n return html.replace(/<html/i, `<html lang=\"${locale}\"`);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiBA,SAAgB,wBACd,QACA,MACU;CACV,MAAM,2BAAW,IAAI,IAAY;CAEjC,KAAK,MAAM,SAAS,QAAQ;EAE1B,MAAM,eAAe,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC;EACtD,IACE,MAAM,SAAS,WAAW,KAC1B,MAAM,WAAW,OAAO,KACxB,KAAK,QAAQ,SAAS,YAAY,GAClC;GACA,SAAS,IAAI,KAAK;GAClB;EACF;EAEA,KAAK,MAAM,UAAU,KAAK,SAAS;GACjC,MAAM,SAAS,IAAI;GACnB,MAAM,iBAAiB,UAAU,MAAM,SAAS,GAAG,SAAS;GAC5D,SAAS,IAAI,cAAc;EAC7B;EAGA,SAAS,IAAI,KAAK;CACpB;CAEA,OAAO,CAAC,GAAG,QAAQ;AACrB;;;;;;;;;AAUA,SAAgB,4BACd,MAC0C;CAC1C,OAAO,OAAO,UAA0B;EACtC,IAAI,CAAC,MAAM,YAAY,OAAO,MAAM,aAAa,UAC/C;EAGF,MAAM,SAAS,sBAAsB,MAAM,OAAO,IAAI;EACtD,IAAI,CAAC,QACH;EAIF,MAAM,WAAW,YAAY,MAAM,UAAU,MAAM;CACrD;AACF;;;;;AAMA,SAAgB,sBACd,OACA,MACQ;CAER,MAAM,eADW,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,OACpB,CAAA,CAAS;CAE9B,IAAI,gBAAgB,KAAK,QAAQ,SAAS,YAAY,GACpD,OAAO;CAGT,OAAO,KAAK;AACd;;;;;;AAOA,SAAgB,YAAY,MAAc,QAAwB;CAEhE,IAAI,yCAAyC,KAAK,IAAI,GACpD,OAAO,KAAK,QACV,4CACA,WAAW,OAAO,EACpB;CAIF,OAAO,KAAK,QAAQ,UAAU,eAAe,OAAO,EAAE;AACxD"}
1
+ {"version":3,"file":"i18n-prerender.js","names":[],"sources":["../../../../src/lib/utils/i18n-prerender.ts"],"sourcesContent":["import { PrerenderRoute } from 'nitropack';\nimport { I18nPrerenderOptions } from '../options.js';\n\n/**\n * Expands a list of routes to include locale-prefixed variants.\n *\n * For each route and each locale, generates a prefixed route:\n * '/' + locale + route\n *\n * The default locale's routes are included both with and without the prefix\n * so that `/about` and `/en/about` both render.\n * Routes that already have a configured locale prefix are kept as-is.\n *\n * @param routes - The original routes to expand\n * @param i18n - The i18n prerender configuration\n * @param apiPrefix - The API route prefix (default `api`); API routes are not localized\n * @returns Expanded routes with locale prefixes\n */\nexport function expandRoutesWithLocales(\n routes: string[],\n i18n: I18nPrerenderOptions,\n apiPrefix = 'api',\n): string[] {\n const expanded = new Set<string>();\n const apiRoute = `/${apiPrefix.replace(/^\\/+|\\/+$/g, '')}`;\n\n for (const route of routes) {\n // API routes and explicitly localized routes don't need locale prefixes.\n const firstSegment = route.split('/').filter(Boolean)[0];\n if (\n route.includes('/_analog/') ||\n route === apiRoute ||\n route.startsWith(`${apiRoute}/`) ||\n i18n.locales.includes(firstSegment)\n ) {\n expanded.add(route);\n continue;\n }\n\n for (const locale of i18n.locales) {\n const prefix = `/${locale}`;\n const localizedRoute = route === '/' ? prefix : `${prefix}${route}`;\n expanded.add(localizedRoute);\n }\n\n // Keep the unprefixed route for the default locale\n expanded.add(route);\n }\n\n return [...expanded];\n}\n\n/**\n * Creates a post-rendering hook that injects the `lang` attribute\n * into the `<html>` tag of prerendered pages based on the route's\n * locale prefix.\n *\n * @param i18n - The i18n prerender configuration\n * @returns A post-rendering hook function\n */\nexport function createI18nPostRenderingHook(\n i18n: I18nPrerenderOptions,\n): (route: PrerenderRoute) => Promise<void> {\n return async (route: PrerenderRoute) => {\n if (!route.contents || typeof route.contents !== 'string') {\n return;\n }\n\n const locale = detectLocaleFromRoute(route.route, i18n);\n if (!locale) {\n return;\n }\n\n // Inject or replace the lang attribute on <html>\n route.contents = setHtmlLang(route.contents, locale);\n };\n}\n\n/**\n * Detects the locale from a prerendered route path by checking\n * the first path segment against the configured locales.\n */\nexport function detectLocaleFromRoute(\n route: string,\n i18n: I18nPrerenderOptions,\n): string {\n const segments = route.split('/').filter(Boolean);\n const firstSegment = segments[0];\n\n if (firstSegment && i18n.locales.includes(firstSegment)) {\n return firstSegment;\n }\n\n return i18n.defaultLocale;\n}\n\n/**\n * Sets the `lang` attribute on the `<html>` tag in an HTML string.\n * If a `lang` attribute already exists, it is replaced.\n * If no `lang` attribute exists, it is added.\n */\nexport function setHtmlLang(html: string, locale: string): string {\n // Replace existing lang attribute\n if (/<html[^>]*\\slang\\s*=\\s*[\"'][^\"']*[\"']/i.test(html)) {\n return html.replace(\n /(<html[^>]*\\s)lang\\s*=\\s*[\"'][^\"']*[\"']/i,\n `$1lang=\"${locale}\"`,\n );\n }\n\n // Add lang attribute to <html> tag\n return html.replace(/<html/i, `<html lang=\"${locale}\"`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,SAAgB,wBACd,QACA,MACA,YAAY,OACF;CACV,MAAM,2BAAW,IAAI,IAAY;CACjC,MAAM,WAAW,IAAI,UAAU,QAAQ,cAAc,EAAE;CAEvD,KAAK,MAAM,SAAS,QAAQ;EAE1B,MAAM,eAAe,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC;EACtD,IACE,MAAM,SAAS,WAAW,KAC1B,UAAU,YACV,MAAM,WAAW,GAAG,SAAS,EAAE,KAC/B,KAAK,QAAQ,SAAS,YAAY,GAClC;GACA,SAAS,IAAI,KAAK;GAClB;EACF;EAEA,KAAK,MAAM,UAAU,KAAK,SAAS;GACjC,MAAM,SAAS,IAAI;GACnB,MAAM,iBAAiB,UAAU,MAAM,SAAS,GAAG,SAAS;GAC5D,SAAS,IAAI,cAAc;EAC7B;EAGA,SAAS,IAAI,KAAK;CACpB;CAEA,OAAO,CAAC,GAAG,QAAQ;AACrB;;;;;;;;;AAUA,SAAgB,4BACd,MAC0C;CAC1C,OAAO,OAAO,UAA0B;EACtC,IAAI,CAAC,MAAM,YAAY,OAAO,MAAM,aAAa,UAC/C;EAGF,MAAM,SAAS,sBAAsB,MAAM,OAAO,IAAI;EACtD,IAAI,CAAC,QACH;EAIF,MAAM,WAAW,YAAY,MAAM,UAAU,MAAM;CACrD;AACF;;;;;AAMA,SAAgB,sBACd,OACA,MACQ;CAER,MAAM,eADW,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,OACpB,CAAA,CAAS;CAE9B,IAAI,gBAAgB,KAAK,QAAQ,SAAS,YAAY,GACpD,OAAO;CAGT,OAAO,KAAK;AACd;;;;;;AAOA,SAAgB,YAAY,MAAc,QAAwB;CAEhE,IAAI,yCAAyC,KAAK,IAAI,GACpD,OAAO,KAAK,QACV,4CACA,WAAW,OAAO,EACpB;CAIF,OAAO,KAAK,QAAQ,UAAU,eAAe,OAAO,EAAE;AACxD"}
@@ -171,7 +171,7 @@ function nitro(pluginOptions = {}) {
171
171
  });
172
172
  return prev;
173
173
  }, []);
174
- if (options?.i18n && nitroConfig.prerender?.routes) nitroConfig.prerender.routes = expandRoutesWithLocales(nitroConfig.prerender.routes.filter(Boolean), options.i18n);
174
+ if (options?.i18n && nitroConfig.prerender?.routes) nitroConfig.prerender.routes = expandRoutesWithLocales(nitroConfig.prerender.routes.filter(Boolean), options.i18n, apiPrefix);
175
175
  }
176
176
  if (options?.i18n) {
177
177
  options.prerender = options.prerender ?? {};
@@ -238,7 +238,7 @@ function nitro(pluginOptions = {}) {
238
238
  const publicDir = nitroConfig.output?.publicDir;
239
239
  if (!publicDir) throw new Error("Nitro public output directory is required to build the sitemap.");
240
240
  console.log("Building Sitemap...");
241
- await buildSitemap(config, options.prerender.sitemap, nitroConfig.prerender.routes, publicDir, routeSitemaps, options.i18n);
241
+ await buildSitemap(config, options.prerender.sitemap, nitroConfig.prerender.routes, publicDir, routeSitemaps, options.i18n, apiPrefix);
242
242
  }
243
243
  console.log(`\n\nThe '@analogjs/platform' server has been successfully built.`);
244
244
  }
@@ -282,7 +282,7 @@ function nitro(pluginOptions = {}) {
282
282
  }
283
283
  if (nitroConfig.prerender?.routes?.length && options?.prerender?.sitemap) {
284
284
  console.log("Building Sitemap...");
285
- await buildSitemap(config, options.prerender.sitemap, nitroConfig.prerender.routes, clientOutputPath, routeSitemaps, options.i18n);
285
+ await buildSitemap(config, options.prerender.sitemap, nitroConfig.prerender.routes, clientOutputPath, routeSitemaps, options.i18n, apiPrefix);
286
286
  }
287
287
  let ssrEntryPath = resolve(options?.ssrBuildDir || resolve(workspaceRoot, "dist", rootDir, `ssr`), `main.server${filePrefix ? ".js" : ""}`);
288
288
  if (isWindows && !existsSync(ssrEntryPath)) ssrEntryPath = ssrEntryPath.replace(".js", ".mjs");
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-nitro.js","names":[],"sources":["../../../src/lib/vite-plugin-nitro.ts"],"sourcesContent":["import {\n NitroConfig,\n build,\n createDevServer,\n createNitro,\n loadOptions,\n} from 'nitropack';\nimport { App, toNodeListener } from 'h3';\nimport type { Plugin, UserConfig, ViteDevServer } from 'vite';\nimport { mergeConfig, normalizePath } from 'vite';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { platform } from 'node:os';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { existsSync, readFileSync } from 'node:fs';\n\nimport { buildServer } from './build-server.js';\nimport { buildSSRApp } from './build-ssr.js';\nimport {\n I18N_WORKER_SSR_ENTRY,\n i18nWorkerSsrEntry,\n resolveI18nWorkers,\n} from './utils/i18n-workers.js';\nimport {\n Options,\n PrerenderContentDir,\n PrerenderContentFile,\n PrerenderRouteConfig,\n PrerenderSitemapConfig,\n} from './options.js';\nimport { pageEndpointsPlugin } from './plugins/page-endpoints.js';\nimport { serverFnIdPlugin } from './plugins/server-fn-id-plugin.js';\nimport { getPageHandlers } from './utils/get-page-handlers.js';\nimport { getServerFnHandlers } from './utils/get-server-fn-handlers.js';\nimport {\n buildServerFnDispatchModule,\n getServerFnDispatchHandler,\n SERVER_FN_DISPATCH_PREFIX,\n SERVER_FN_DISPATCH_VIRTUAL,\n} from './utils/server-fn-endpoints.js';\nimport { buildSitemap } from './build-sitemap.js';\nimport { devServerPlugin } from './plugins/dev-server-plugin.js';\nimport { getMatchingContentFilesWithFrontMatter } from './utils/get-content-files.js';\nimport { IncomingMessage, ServerResponse } from 'node:http';\nimport {\n ssrRenderer,\n ssrStreamRenderer,\n clientRenderer,\n} from './utils/renderers.js';\nimport {\n expandRoutesWithLocales,\n createI18nPostRenderingHook,\n} from './utils/i18n-prerender.js';\n\nconst isWindows = platform() === 'win32';\nconst filePrefix = isWindows ? 'file:///' : '';\nlet clientOutputPath = '';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nexport interface NitroPluginOptions extends NitroConfig {\n /**\n * Analog options for apps that don't use `analog()` from\n * `@analogjs/platform`. They override the options passed to `analog()`.\n */\n analog?: Options;\n}\n\nexport function nitro(pluginOptions: NitroPluginOptions = {}): Plugin[] {\n // Nitro's `static` means the same as Analog's: prerender without a server.\n const { analog, static: isStatic, ...pluginNitroOptions } = pluginOptions;\n const nitroOptions = withAnalogRouteRuleHeaders(pluginNitroOptions);\n let options: Options | undefined;\n let workspaceRoot = process.cwd();\n let sourceRoot = 'src';\n let isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const baseURL = process.env['NITRO_APP_BASE_URL'] || '';\n const prefix = baseURL ? baseURL.substring(0, baseURL.length - 1) : '';\n let apiPrefix = '/api';\n\n let i18nWorkers = false;\n let isBuild = false;\n let isServe = false;\n let ssrBuild = false;\n let config: UserConfig;\n let nitroConfig: NitroConfig;\n let environmentBuild = false;\n let hasServerFns = false;\n const routeSitemaps: Record<\n string,\n PrerenderSitemapConfig | (() => PrerenderSitemapConfig)\n > = {};\n const routeSourceFiles: Record<string, string> = {};\n let rootDir = workspaceRoot;\n\n // Options passed to `analog()` are the defaults, so an Analog app configures\n // SSR, prerendering and API routes in one place.\n function resolveOptions(userConfig: UserConfig) {\n options = {\n ...getAnalogOptions(userConfig),\n ...(isStatic === undefined ? {} : { static: isStatic }),\n ...analog,\n };\n workspaceRoot = options.workspaceRoot ?? process.cwd();\n sourceRoot = options.sourceRoot ?? 'src';\n apiPrefix = `/${options.apiPrefix || 'api'}`;\n }\n\n return [\n {\n name: '@analogjs/vite-plugin-nitro',\n async config(userConfig, { mode, command }) {\n resolveOptions(userConfig);\n isServe = command === 'serve';\n isBuild = command === 'build';\n ssrBuild = userConfig.build?.ssr === true;\n config = userConfig;\n isTest = isTest ? isTest : mode === 'test';\n\n rootDir = relative(workspaceRoot, config.root || '.') || '.';\n const buildPreset =\n process.env['BUILD_PRESET'] ??\n (nitroOptions?.preset as string | undefined);\n\n const pageHandlers = getPageHandlers({\n workspaceRoot,\n sourceRoot,\n rootDir,\n additionalPagesDirs: options?.additionalPagesDirs,\n apiPrefix,\n });\n\n // Server functions: discover every `*.server.ts` module, then register a\n // single `/_analog/fn/:id` dispatch handler backed by a generated Nitro\n // virtual module that imports those modules (registration side-effects)\n // and the app provider set. Only wired when server functions exist.\n const serverFnModules = getServerFnHandlers({\n workspaceRoot,\n sourceRoot,\n rootDir,\n additionalServerFnDirs: options?.additionalServerFnDirs,\n });\n const serverFnAppConfigModule = resolveServerFnAppConfigModule(\n workspaceRoot,\n rootDir,\n sourceRoot,\n );\n hasServerFns = serverFnModules.length > 0;\n const serverFnHandlers = hasServerFns\n ? [getServerFnDispatchHandler()]\n : [];\n const serverFnVirtual =\n serverFnModules.length > 0\n ? {\n [SERVER_FN_DISPATCH_VIRTUAL]: buildServerFnDispatchModule({\n modules: serverFnModules,\n appConfigModule: serverFnAppConfigModule,\n root: resolve(workspaceRoot, rootDir),\n }),\n }\n : {};\n\n nitroConfig = {\n rootDir,\n preset: buildPreset,\n compatibilityDate: '2024-11-19',\n logLevel: nitroOptions?.logLevel || 0,\n srcDir: normalizePath(`${sourceRoot}/server`),\n scanDirs: [\n normalizePath(`${rootDir}/${sourceRoot}/server`),\n ...(options?.additionalAPIDirs || []).map((dir) =>\n normalizePath(`${workspaceRoot}${dir}`),\n ),\n ],\n output: {\n dir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, 'analog'),\n ),\n publicDir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, 'analog/public'),\n ),\n },\n buildDir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, '.nitro'),\n ),\n typescript: {\n generateTsConfig: false,\n },\n runtimeConfig: {\n apiPrefix: apiPrefix.substring(1),\n prefix,\n },\n // Fixes support for Rolldown\n imports: {\n autoImport: false,\n },\n // The dispatch module's imports are all bare side-effect imports —\n // the JIT compiler it needs, and each `*.server.ts` whose import is\n // what registers its functions. Nitro treeshakes those away unless\n // the modules are declared side-effectful, which would leave every\n // call 404ing against an empty registry.\n ...(hasServerFns\n ? {\n moduleSideEffects: [\n '@angular/compiler',\n ...serverFnModules.map((m) => normalizePath(m.file)),\n ],\n }\n : {}),\n rollupConfig: {\n onwarn(warning) {\n if (\n warning.message.includes('empty chunk') &&\n warning.message.endsWith('.server')\n ) {\n return;\n }\n },\n plugins: [\n pageEndpointsPlugin(),\n serverFnIdPlugin(normalizePath(resolve(workspaceRoot, rootDir))),\n ],\n },\n handlers: [...pageHandlers, ...serverFnHandlers],\n virtual: {\n '#ANALOG_SSR_RENDERER': options?.experimental?.streaming\n ? ssrStreamRenderer\n : ssrRenderer,\n '#ANALOG_CLIENT_RENDERER': clientRenderer,\n ...serverFnVirtual,\n },\n };\n\n if (isVercelPreset(buildPreset)) {\n nitroConfig = withVercelOutputAPI(nitroConfig, workspaceRoot);\n }\n\n if (isCloudflarePreset(buildPreset)) {\n nitroConfig = withCloudflareOutput(nitroConfig);\n }\n\n if (\n isNetlifyPreset(buildPreset) &&\n rootDir === '.' &&\n !existsSync(resolve(workspaceRoot, 'netlify.toml'))\n ) {\n nitroConfig = withNetlifyOutputAPI(nitroConfig, workspaceRoot);\n }\n\n if (isFirebaseAppHosting()) {\n nitroConfig = withAppHostingOutput(nitroConfig);\n }\n\n if (!ssrBuild && !isTest) {\n // store the client output path for the SSR build config\n clientOutputPath = resolve(\n workspaceRoot,\n rootDir,\n config.build?.outDir || 'dist/client',\n );\n }\n\n const indexEntry = normalizePath(\n resolve(clientOutputPath, 'index.html'),\n );\n nitroConfig.alias = {\n '#analog/index': indexEntry,\n };\n\n if (isBuild) {\n nitroConfig.publicAssets = [{ dir: clientOutputPath }];\n nitroConfig.renderer = options?.ssr\n ? '#ANALOG_SSR_RENDERER'\n : '#ANALOG_CLIENT_RENDERER';\n\n if (isEmptyPrerenderRoutes(options)) {\n nitroConfig.prerender = {};\n nitroConfig.prerender.routes = ['/'];\n }\n\n if (options?.prerender) {\n nitroConfig.prerender = nitroConfig.prerender ?? {};\n nitroConfig.prerender.crawlLinks = options?.prerender?.discover;\n\n let routes: (\n | string\n | PrerenderContentDir\n | PrerenderRouteConfig\n | undefined\n )[] = [];\n\n const prerenderRoutes = options?.prerender?.routes;\n if (\n isArrayWithElements<string | PrerenderContentDir>(prerenderRoutes)\n ) {\n routes = prerenderRoutes;\n } else if (typeof prerenderRoutes === 'function') {\n routes = await prerenderRoutes();\n }\n\n nitroConfig.prerender.routes = routes.reduce<string[]>(\n (prev, current) => {\n if (!current) {\n return prev;\n }\n if (typeof current === 'string') {\n prev.push(current);\n return prev;\n }\n\n if ('route' in current) {\n if (current.sitemap) {\n routeSitemaps[current.route] = current.sitemap;\n }\n\n if (current.outputSourceFile) {\n const sourcePath = resolve(\n workspaceRoot,\n rootDir,\n current.outputSourceFile,\n );\n routeSourceFiles[current.route] = readFileSync(\n sourcePath,\n 'utf8',\n );\n }\n\n prev.push(current.route);\n\n // Add the server-side data fetching endpoint URL\n if ('staticData' in current) {\n prev.push(`${apiPrefix}/_analog/pages/${current.route}`);\n }\n\n return prev;\n }\n\n const affectedFiles: PrerenderContentFile[] =\n getMatchingContentFilesWithFrontMatter(\n workspaceRoot,\n rootDir,\n current.contentDir,\n current.recursive,\n );\n\n affectedFiles.forEach((f) => {\n const result = current.transform(f);\n\n if (result) {\n if (current.sitemap) {\n routeSitemaps[result] =\n current.sitemap && typeof current.sitemap === 'function'\n ? current.sitemap?.(f)\n : current.sitemap;\n }\n\n if (current.outputSourceFile) {\n const sourceContent = current.outputSourceFile(f);\n if (sourceContent) {\n routeSourceFiles[result] = sourceContent;\n }\n }\n\n prev.push(result);\n\n // Add the server-side data fetching endpoint URL\n if ('staticData' in current) {\n prev.push(`${apiPrefix}/_analog/pages/${result}`);\n }\n }\n });\n\n return prev;\n },\n [],\n );\n\n // Expand routes with locale prefixes when i18n is configured\n if (options?.i18n && nitroConfig.prerender?.routes) {\n nitroConfig.prerender.routes = expandRoutesWithLocales(\n nitroConfig.prerender.routes.filter(Boolean) as string[],\n options.i18n,\n );\n }\n }\n\n // Register i18n post-rendering hook for lang attribute injection\n if (options?.i18n) {\n options.prerender = options.prerender ?? {};\n options.prerender.postRenderingHooks =\n options.prerender.postRenderingHooks ?? [];\n options.prerender.postRenderingHooks.push(\n createI18nPostRenderingHook(options.i18n),\n );\n }\n\n if (ssrBuild) {\n if (isWindows) {\n nitroConfig.externals = {\n inline: ['std-env'],\n };\n }\n\n nitroConfig = {\n ...nitroConfig,\n externals: {\n ...nitroConfig.externals,\n external: ['rxjs', 'node-fetch-native/dist/polyfill'],\n },\n moduleSideEffects: [\n 'zone.js/node',\n 'zone.js/fesm2015/zone-node',\n ...(nitroConfig.moduleSideEffects ?? []),\n ],\n handlers: [...pageHandlers, ...serverFnHandlers],\n };\n }\n }\n\n nitroConfig = mergeConfig(\n nitroConfig,\n nitroOptions as Record<string, any>,\n );\n\n i18nWorkers = false;\n if (\n isBuild &&\n options?.i18n &&\n options.i18n.workers !== false &&\n (options.i18n.loader || options.i18n.workers === true)\n ) {\n const resolvedNitro = await loadOptions({\n dev: false,\n preset: process.env['BUILD_PRESET'],\n ...nitroConfig,\n });\n i18nWorkers = resolveI18nWorkers(options, resolvedNitro);\n nitroConfig.preset = resolvedNitro.preset;\n }\n\n return {\n define: {\n ANALOG_I18N_FIXED_LOCALE: i18nWorkers\n ? 'globalThis.process.env.ANALOG_I18N_LOCALE'\n : 'undefined',\n },\n environments: {\n client: {\n build: {\n outDir:\n config?.build?.outDir ||\n resolve(workspaceRoot, 'dist', rootDir, 'client'),\n },\n },\n ssr: {\n consumer: 'server',\n build: {\n ssr: true,\n rollupOptions: {\n input: i18nWorkers\n ? { 'main.server': I18N_WORKER_SSR_ENTRY }\n : options?.entryServer ||\n resolve(\n workspaceRoot,\n rootDir,\n `${sourceRoot}/main.server.ts`,\n ),\n },\n outDir:\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, 'ssr'),\n },\n },\n },\n builder: {\n sharedPlugins: true,\n buildApp: async (builder) => {\n environmentBuild = true;\n const builds = [builder.build(builder.environments['client'])];\n\n if (options?.ssr || nitroConfig.prerender?.routes?.length) {\n builds.push(builder.build(builder.environments['ssr']));\n }\n\n await Promise.all(builds);\n\n let ssrEntryPath = resolve(\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, `ssr`),\n `main.server${filePrefix ? '.js' : ''}`,\n );\n\n // add check for main.server.mjs fallback on Windows\n if (isWindows && !existsSync(ssrEntryPath)) {\n ssrEntryPath = ssrEntryPath.replace('.js', '.mjs');\n }\n\n const ssrEntry = normalizePath(filePrefix + ssrEntryPath);\n\n nitroConfig.alias = {\n ...nitroConfig.alias,\n '#analog/ssr': ssrEntry,\n };\n\n await buildServer(\n options,\n nitroConfig,\n routeSourceFiles,\n i18nWorkers,\n );\n\n if (\n nitroConfig.prerender?.routes?.length &&\n options?.prerender?.sitemap\n ) {\n const publicDir = nitroConfig.output?.publicDir;\n if (!publicDir) {\n throw new Error(\n 'Nitro public output directory is required to build the sitemap.',\n );\n }\n\n console.log('Building Sitemap...');\n // sitemap needs to be built after all directories are built\n await buildSitemap(\n config,\n options.prerender.sitemap,\n nitroConfig.prerender.routes,\n publicDir,\n routeSitemaps,\n options.i18n,\n );\n }\n\n console.log(\n `\\n\\nThe '@analogjs/platform' server has been successfully built.`,\n );\n },\n },\n };\n },\n async configureServer(viteServer: ViteDevServer) {\n if (isServe && !isTest) {\n const nitro = await createNitro({\n dev: true,\n ...nitroConfig,\n });\n const server = createDevServer(nitro);\n await build(nitro);\n const apiHandler = toNodeListener(server.app as unknown as App);\n\n // Server functions dispatch through `/_analog/fn/:id`, outside the\n // API prefix the Nitro dev server is mounted under, so route them\n // explicitly — otherwise a call falls through to the SSR catch-all\n // and the client gets HTML back instead of its result.\n if (hasServerFns) {\n viteServer.middlewares.use(\n (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n ) => {\n if (req.url?.startsWith(SERVER_FN_DISPATCH_PREFIX)) {\n apiHandler(req, res);\n return;\n }\n\n next();\n },\n );\n }\n\n viteServer.middlewares.use(\n (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n ) => {\n if (req.url?.startsWith(`${prefix}${apiPrefix}`)) {\n apiHandler(req, res);\n return;\n }\n\n next();\n },\n );\n\n // handle upgrades if websockets are enabled\n if (nitroOptions?.experimental?.websocket) {\n viteServer.httpServer?.on('upgrade', server.upgrade);\n }\n\n console.log(\n `\\n\\nThe server endpoints are accessible under the \"${prefix}${apiPrefix}\" path.`,\n );\n }\n },\n\n async closeBundle() {\n // Skip when build is triggered by the Environment API\n if (environmentBuild) {\n return;\n }\n\n if (ssrBuild) {\n return;\n }\n\n if (isBuild) {\n if (options?.ssr) {\n console.log('Building SSR application...');\n await buildSSRApp(config, options, i18nWorkers);\n }\n\n if (\n nitroConfig.prerender?.routes?.length &&\n options?.prerender?.sitemap\n ) {\n console.log('Building Sitemap...');\n // sitemap needs to be built after all directories are built\n await buildSitemap(\n config,\n options.prerender.sitemap,\n nitroConfig.prerender.routes,\n clientOutputPath,\n routeSitemaps,\n options.i18n,\n );\n }\n\n let ssrEntryPath = resolve(\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, `ssr`),\n `main.server${filePrefix ? '.js' : ''}`,\n );\n\n // add check for main.server.mjs fallback on Windows\n if (isWindows && !existsSync(ssrEntryPath)) {\n ssrEntryPath = ssrEntryPath.replace('.js', '.mjs');\n }\n\n const ssrEntry = normalizePath(filePrefix + ssrEntryPath);\n\n nitroConfig.alias = {\n ...nitroConfig.alias,\n '#analog/ssr': ssrEntry,\n };\n\n await buildServer(\n options,\n nitroConfig,\n routeSourceFiles,\n i18nWorkers,\n );\n\n console.log(\n `\\n\\nThe '@analogjs/platform' server has been successfully built.`,\n );\n }\n },\n },\n {\n name: 'analog-i18n-worker-entry',\n apply: 'build' as const,\n resolveId(id: string) {\n return id === I18N_WORKER_SSR_ENTRY && options?.i18n?.loader\n ? '\\0' + id\n : undefined;\n },\n load(id: string) {\n if (id !== '\\0' + I18N_WORKER_SSR_ENTRY || !options?.i18n?.loader)\n return;\n return i18nWorkerSsrEntry(\n normalizePath(\n resolve(\n workspaceRoot,\n rootDir,\n options.entryServer || `${sourceRoot}/main.server.ts`,\n ),\n ),\n normalizePath(resolve(workspaceRoot, rootDir, options.i18n.loader)),\n options.i18n,\n );\n },\n },\n devServerPlugin(() => ({\n ...options,\n routeRules: nitroOptions?.routeRules,\n })),\n {\n name: '@analogjs/vite-plugin-nitro-api-prefix',\n config() {\n return {\n define: {\n ANALOG_API_PREFIX: `\"${baseURL.substring(1)}${apiPrefix.substring(1)}\"`,\n ...(options?.i18n\n ? {\n ANALOG_I18N_DEFAULT_LOCALE: JSON.stringify(\n options.i18n.defaultLocale,\n ),\n ANALOG_I18N_LOCALES: JSON.stringify(options.i18n.locales),\n }\n : {}),\n },\n };\n },\n },\n ];\n}\n\nfunction isEmptyPrerenderRoutes(options?: Options): boolean {\n if (!options || isArrayWithElements(options?.prerender?.routes)) {\n return false;\n }\n return !options.prerender?.routes;\n}\n\nfunction isArrayWithElements<T>(arr: unknown): arr is [T, ...T[]] {\n return !!(Array.isArray(arr) && arr.length);\n}\n\nconst isVercelPreset = (buildPreset: string | undefined) =>\n process.env['VERCEL'] ||\n (buildPreset && buildPreset.toLowerCase().includes('vercel'));\n\nconst withVercelOutputAPI = (\n nitroConfig: NitroConfig | undefined,\n workspaceRoot: string,\n) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n dir: normalizePath(resolve(workspaceRoot, '.vercel', 'output')),\n publicDir: normalizePath(\n resolve(workspaceRoot, '.vercel', 'output/static'),\n ),\n },\n});\n\nconst isCloudflarePreset = (buildPreset: string | undefined) =>\n process.env['CF_PAGES'] ||\n (buildPreset && buildPreset.toLowerCase().includes('cloudflare-pages'));\n\nconst withCloudflareOutput = (nitroConfig: NitroConfig | undefined) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n serverDir: '{{ output.publicDir }}/_worker.js',\n },\n});\n\nconst isFirebaseAppHosting = () => !!process.env['NG_BUILD_LOGS_JSON'];\nconst withAppHostingOutput = (nitroConfig: NitroConfig) => {\n let hasOutput = false;\n\n return <NitroConfig>{\n ...nitroConfig,\n serveStatic: true,\n rollupConfig: {\n ...nitroConfig.rollupConfig,\n output: {\n ...nitroConfig.rollupConfig?.output,\n entryFileNames: 'server.mjs',\n },\n },\n hooks: {\n ...nitroConfig.hooks,\n compiled: () => {\n if (!hasOutput) {\n const buildOutput = {\n errors: [],\n warnings: [],\n outputPaths: {\n root: pathToFileURL(`${nitroConfig.output?.dir}`),\n browser: pathToFileURL(`${nitroConfig.output?.publicDir}`),\n server: pathToFileURL(`${nitroConfig.output?.dir}/server`),\n },\n };\n\n // Log the build output for Firebase App Hosting to pick up\n console.log(JSON.stringify(buildOutput, null, 2));\n hasOutput = true;\n }\n },\n },\n };\n};\n\nfunction resolveServerFnAppConfigModule(\n workspaceRoot: string,\n rootDir: string,\n sourceRoot: string,\n): string | undefined {\n // The app's server config (the one `main.server.ts` renders with), exporting\n // `config`. Server-function handlers bootstrap against it, so they resolve the\n // same DI as SSR with no separate provider list to maintain.\n const root = normalizePath(resolve(workspaceRoot, rootDir));\n const candidates = [\n `${root}/${sourceRoot}/app/app.config.server.ts`,\n `${root}/${sourceRoot}/app.config.server.ts`,\n ];\n return candidates.find((candidate) => existsSync(candidate));\n}\n\nconst isNetlifyPreset = (buildPreset: string | undefined) =>\n process.env['NETLIFY'] ||\n (buildPreset && buildPreset.toLowerCase().includes('netlify'));\n\nconst withNetlifyOutputAPI = (\n nitroConfig: NitroConfig | undefined,\n workspaceRoot: string,\n) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n dir: normalizePath(resolve(workspaceRoot, 'netlify/functions')),\n },\n});\n\n/**\n * Reads the options passed to `analog()` from `@analogjs/platform`, which\n * exposes them on its plugin `api`.\n */\nfunction getAnalogOptions(userConfig: UserConfig): Options | undefined {\n const plugins = ((userConfig.plugins ?? []) as unknown[]).flat(Infinity) as (\n | { api?: { analogOptions?: Options } }\n | null\n | undefined\n )[];\n return plugins.find((plugin) => plugin?.api?.analogOptions)?.api\n ?.analogOptions;\n}\n\n/**\n * Stamps `ssr` and `streaming` route rules as response headers, which the\n * renderers read to skip SSR or streaming for matching routes. `true` rules\n * stamp `'false'` so they override a broader `false` rule.\n */\nfunction withAnalogRouteRuleHeaders(nitroOptions: NitroConfig): NitroConfig {\n if (!nitroOptions.routeRules) {\n return nitroOptions;\n }\n\n const routeRules = Object.fromEntries(\n Object.entries(nitroOptions.routeRules).map(([route, rule]) => [\n route,\n {\n ...rule,\n headers: {\n ...rule.headers,\n ...(typeof rule.ssr === 'boolean'\n ? { 'x-analog-no-ssr': String(!rule.ssr) }\n : {}),\n ...(typeof rule.streaming === 'boolean'\n ? { 'x-analog-no-streaming': String(!rule.streaming) }\n : {}),\n },\n },\n ]),\n );\n\n return { ...nitroOptions, routeRules };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqDA,IAAM,YAAY,SAAS,MAAM;AACjC,IAAM,aAAa,YAAY,aAAa;AAC5C,IAAI,mBAAmB;AAEvB,IAAM,aAAa,cAAc,YAAY,GAAG;AAC9B,QAAQ,UAAU;AAUpC,SAAgB,MAAM,gBAAoC,CAAC,GAAa;CAEtE,MAAM,EAAE,QAAQ,QAAQ,UAAU,GAAG,uBAAuB;CAC5D,MAAM,eAAe,2BAA2B,kBAAkB;CAClE,IAAI;CACJ,IAAI,gBAAgB,QAAQ,IAAI;CAChC,IAAI,aAAa;CACjB,IAAI,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CAC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H,QAAQ;EACN,GAAG,aAAa;EAChB,KAAK,cAAc,QAAQ,eAAe,mBAAmB,CAAC;CAChE;AACF;;;;;AAMA,SAAS,iBAAiB,YAA6C;CAMrE,QALkB,WAAW,WAAW,CAAC,EAAA,CAAiB,KAAK,QAKxD,CAAA,CAAQ,MAAM,WAAW,QAAQ,KAAK,aAAa,CAAC,EAAE,KACzD;AACN;;;;;;AAOA,SAAS,2BAA2B,cAAwC;CAC1E,IAAI,CAAC,aAAa,YAChB,OAAO;CAGT,MAAM,aAAa,OAAO,YACxB,OAAO,QAAQ,aAAa,UAAU,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAC7D,OACA;EACE,GAAG;EACH,SAAS;GACP,GAAG,KAAK;GACR,GAAI,OAAO,KAAK,QAAQ,YACpB,EAAE,mBAAmB,OAAO,CAAC,KAAK,GAAG,EAAE,IACvC,CAAC;GACL,GAAI,OAAO,KAAK,cAAc,YAC1B,EAAE,yBAAyB,OAAO,CAAC,KAAK,SAAS,EAAE,IACnD,CAAC;EACP;CACF,CACF,CAAC,CACH;CAEA,OAAO;EAAE,GAAG;EAAc;CAAW;AACvC"}
1
+ {"version":3,"file":"vite-plugin-nitro.js","names":[],"sources":["../../../src/lib/vite-plugin-nitro.ts"],"sourcesContent":["import {\n NitroConfig,\n build,\n createDevServer,\n createNitro,\n loadOptions,\n} from 'nitropack';\nimport { App, toNodeListener } from 'h3';\nimport type { Plugin, UserConfig, ViteDevServer } from 'vite';\nimport { mergeConfig, normalizePath } from 'vite';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { platform } from 'node:os';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { existsSync, readFileSync } from 'node:fs';\n\nimport { buildServer } from './build-server.js';\nimport { buildSSRApp } from './build-ssr.js';\nimport {\n I18N_WORKER_SSR_ENTRY,\n i18nWorkerSsrEntry,\n resolveI18nWorkers,\n} from './utils/i18n-workers.js';\nimport {\n Options,\n PrerenderContentDir,\n PrerenderContentFile,\n PrerenderRouteConfig,\n PrerenderSitemapConfig,\n} from './options.js';\nimport { pageEndpointsPlugin } from './plugins/page-endpoints.js';\nimport { serverFnIdPlugin } from './plugins/server-fn-id-plugin.js';\nimport { getPageHandlers } from './utils/get-page-handlers.js';\nimport { getServerFnHandlers } from './utils/get-server-fn-handlers.js';\nimport {\n buildServerFnDispatchModule,\n getServerFnDispatchHandler,\n SERVER_FN_DISPATCH_PREFIX,\n SERVER_FN_DISPATCH_VIRTUAL,\n} from './utils/server-fn-endpoints.js';\nimport { buildSitemap } from './build-sitemap.js';\nimport { devServerPlugin } from './plugins/dev-server-plugin.js';\nimport { getMatchingContentFilesWithFrontMatter } from './utils/get-content-files.js';\nimport { IncomingMessage, ServerResponse } from 'node:http';\nimport {\n ssrRenderer,\n ssrStreamRenderer,\n clientRenderer,\n} from './utils/renderers.js';\nimport {\n expandRoutesWithLocales,\n createI18nPostRenderingHook,\n} from './utils/i18n-prerender.js';\n\nconst isWindows = platform() === 'win32';\nconst filePrefix = isWindows ? 'file:///' : '';\nlet clientOutputPath = '';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nexport interface NitroPluginOptions extends NitroConfig {\n /**\n * Analog options for apps that don't use `analog()` from\n * `@analogjs/platform`. They override the options passed to `analog()`.\n */\n analog?: Options;\n}\n\nexport function nitro(pluginOptions: NitroPluginOptions = {}): Plugin[] {\n // Nitro's `static` means the same as Analog's: prerender without a server.\n const { analog, static: isStatic, ...pluginNitroOptions } = pluginOptions;\n const nitroOptions = withAnalogRouteRuleHeaders(pluginNitroOptions);\n let options: Options | undefined;\n let workspaceRoot = process.cwd();\n let sourceRoot = 'src';\n let isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const baseURL = process.env['NITRO_APP_BASE_URL'] || '';\n const prefix = baseURL ? baseURL.substring(0, baseURL.length - 1) : '';\n let apiPrefix = '/api';\n\n let i18nWorkers = false;\n let isBuild = false;\n let isServe = false;\n let ssrBuild = false;\n let config: UserConfig;\n let nitroConfig: NitroConfig;\n let environmentBuild = false;\n let hasServerFns = false;\n const routeSitemaps: Record<\n string,\n PrerenderSitemapConfig | (() => PrerenderSitemapConfig)\n > = {};\n const routeSourceFiles: Record<string, string> = {};\n let rootDir = workspaceRoot;\n\n // Options passed to `analog()` are the defaults, so an Analog app configures\n // SSR, prerendering and API routes in one place.\n function resolveOptions(userConfig: UserConfig) {\n options = {\n ...getAnalogOptions(userConfig),\n ...(isStatic === undefined ? {} : { static: isStatic }),\n ...analog,\n };\n workspaceRoot = options.workspaceRoot ?? process.cwd();\n sourceRoot = options.sourceRoot ?? 'src';\n apiPrefix = `/${options.apiPrefix || 'api'}`;\n }\n\n return [\n {\n name: '@analogjs/vite-plugin-nitro',\n async config(userConfig, { mode, command }) {\n resolveOptions(userConfig);\n isServe = command === 'serve';\n isBuild = command === 'build';\n ssrBuild = userConfig.build?.ssr === true;\n config = userConfig;\n isTest = isTest ? isTest : mode === 'test';\n\n rootDir = relative(workspaceRoot, config.root || '.') || '.';\n const buildPreset =\n process.env['BUILD_PRESET'] ??\n (nitroOptions?.preset as string | undefined);\n\n const pageHandlers = getPageHandlers({\n workspaceRoot,\n sourceRoot,\n rootDir,\n additionalPagesDirs: options?.additionalPagesDirs,\n apiPrefix,\n });\n\n // Server functions: discover every `*.server.ts` module, then register a\n // single `/_analog/fn/:id` dispatch handler backed by a generated Nitro\n // virtual module that imports those modules (registration side-effects)\n // and the app provider set. Only wired when server functions exist.\n const serverFnModules = getServerFnHandlers({\n workspaceRoot,\n sourceRoot,\n rootDir,\n additionalServerFnDirs: options?.additionalServerFnDirs,\n });\n const serverFnAppConfigModule = resolveServerFnAppConfigModule(\n workspaceRoot,\n rootDir,\n sourceRoot,\n );\n hasServerFns = serverFnModules.length > 0;\n const serverFnHandlers = hasServerFns\n ? [getServerFnDispatchHandler()]\n : [];\n const serverFnVirtual =\n serverFnModules.length > 0\n ? {\n [SERVER_FN_DISPATCH_VIRTUAL]: buildServerFnDispatchModule({\n modules: serverFnModules,\n appConfigModule: serverFnAppConfigModule,\n root: resolve(workspaceRoot, rootDir),\n }),\n }\n : {};\n\n nitroConfig = {\n rootDir,\n preset: buildPreset,\n compatibilityDate: '2024-11-19',\n logLevel: nitroOptions?.logLevel || 0,\n srcDir: normalizePath(`${sourceRoot}/server`),\n scanDirs: [\n normalizePath(`${rootDir}/${sourceRoot}/server`),\n ...(options?.additionalAPIDirs || []).map((dir) =>\n normalizePath(`${workspaceRoot}${dir}`),\n ),\n ],\n output: {\n dir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, 'analog'),\n ),\n publicDir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, 'analog/public'),\n ),\n },\n buildDir: normalizePath(\n resolve(workspaceRoot, 'dist', rootDir, '.nitro'),\n ),\n typescript: {\n generateTsConfig: false,\n },\n runtimeConfig: {\n apiPrefix: apiPrefix.substring(1),\n prefix,\n },\n // Fixes support for Rolldown\n imports: {\n autoImport: false,\n },\n // The dispatch module's imports are all bare side-effect imports —\n // the JIT compiler it needs, and each `*.server.ts` whose import is\n // what registers its functions. Nitro treeshakes those away unless\n // the modules are declared side-effectful, which would leave every\n // call 404ing against an empty registry.\n ...(hasServerFns\n ? {\n moduleSideEffects: [\n '@angular/compiler',\n ...serverFnModules.map((m) => normalizePath(m.file)),\n ],\n }\n : {}),\n rollupConfig: {\n onwarn(warning) {\n if (\n warning.message.includes('empty chunk') &&\n warning.message.endsWith('.server')\n ) {\n return;\n }\n },\n plugins: [\n pageEndpointsPlugin(),\n serverFnIdPlugin(normalizePath(resolve(workspaceRoot, rootDir))),\n ],\n },\n handlers: [...pageHandlers, ...serverFnHandlers],\n virtual: {\n '#ANALOG_SSR_RENDERER': options?.experimental?.streaming\n ? ssrStreamRenderer\n : ssrRenderer,\n '#ANALOG_CLIENT_RENDERER': clientRenderer,\n ...serverFnVirtual,\n },\n };\n\n if (isVercelPreset(buildPreset)) {\n nitroConfig = withVercelOutputAPI(nitroConfig, workspaceRoot);\n }\n\n if (isCloudflarePreset(buildPreset)) {\n nitroConfig = withCloudflareOutput(nitroConfig);\n }\n\n if (\n isNetlifyPreset(buildPreset) &&\n rootDir === '.' &&\n !existsSync(resolve(workspaceRoot, 'netlify.toml'))\n ) {\n nitroConfig = withNetlifyOutputAPI(nitroConfig, workspaceRoot);\n }\n\n if (isFirebaseAppHosting()) {\n nitroConfig = withAppHostingOutput(nitroConfig);\n }\n\n if (!ssrBuild && !isTest) {\n // store the client output path for the SSR build config\n clientOutputPath = resolve(\n workspaceRoot,\n rootDir,\n config.build?.outDir || 'dist/client',\n );\n }\n\n const indexEntry = normalizePath(\n resolve(clientOutputPath, 'index.html'),\n );\n nitroConfig.alias = {\n '#analog/index': indexEntry,\n };\n\n if (isBuild) {\n nitroConfig.publicAssets = [{ dir: clientOutputPath }];\n nitroConfig.renderer = options?.ssr\n ? '#ANALOG_SSR_RENDERER'\n : '#ANALOG_CLIENT_RENDERER';\n\n if (isEmptyPrerenderRoutes(options)) {\n nitroConfig.prerender = {};\n nitroConfig.prerender.routes = ['/'];\n }\n\n if (options?.prerender) {\n nitroConfig.prerender = nitroConfig.prerender ?? {};\n nitroConfig.prerender.crawlLinks = options?.prerender?.discover;\n\n let routes: (\n | string\n | PrerenderContentDir\n | PrerenderRouteConfig\n | undefined\n )[] = [];\n\n const prerenderRoutes = options?.prerender?.routes;\n if (\n isArrayWithElements<string | PrerenderContentDir>(prerenderRoutes)\n ) {\n routes = prerenderRoutes;\n } else if (typeof prerenderRoutes === 'function') {\n routes = await prerenderRoutes();\n }\n\n nitroConfig.prerender.routes = routes.reduce<string[]>(\n (prev, current) => {\n if (!current) {\n return prev;\n }\n if (typeof current === 'string') {\n prev.push(current);\n return prev;\n }\n\n if ('route' in current) {\n if (current.sitemap) {\n routeSitemaps[current.route] = current.sitemap;\n }\n\n if (current.outputSourceFile) {\n const sourcePath = resolve(\n workspaceRoot,\n rootDir,\n current.outputSourceFile,\n );\n routeSourceFiles[current.route] = readFileSync(\n sourcePath,\n 'utf8',\n );\n }\n\n prev.push(current.route);\n\n // Add the server-side data fetching endpoint URL\n if ('staticData' in current) {\n prev.push(`${apiPrefix}/_analog/pages/${current.route}`);\n }\n\n return prev;\n }\n\n const affectedFiles: PrerenderContentFile[] =\n getMatchingContentFilesWithFrontMatter(\n workspaceRoot,\n rootDir,\n current.contentDir,\n current.recursive,\n );\n\n affectedFiles.forEach((f) => {\n const result = current.transform(f);\n\n if (result) {\n if (current.sitemap) {\n routeSitemaps[result] =\n current.sitemap && typeof current.sitemap === 'function'\n ? current.sitemap?.(f)\n : current.sitemap;\n }\n\n if (current.outputSourceFile) {\n const sourceContent = current.outputSourceFile(f);\n if (sourceContent) {\n routeSourceFiles[result] = sourceContent;\n }\n }\n\n prev.push(result);\n\n // Add the server-side data fetching endpoint URL\n if ('staticData' in current) {\n prev.push(`${apiPrefix}/_analog/pages/${result}`);\n }\n }\n });\n\n return prev;\n },\n [],\n );\n\n // Expand routes with locale prefixes when i18n is configured\n if (options?.i18n && nitroConfig.prerender?.routes) {\n nitroConfig.prerender.routes = expandRoutesWithLocales(\n nitroConfig.prerender.routes.filter(Boolean) as string[],\n options.i18n,\n apiPrefix,\n );\n }\n }\n\n // Register i18n post-rendering hook for lang attribute injection\n if (options?.i18n) {\n options.prerender = options.prerender ?? {};\n options.prerender.postRenderingHooks =\n options.prerender.postRenderingHooks ?? [];\n options.prerender.postRenderingHooks.push(\n createI18nPostRenderingHook(options.i18n),\n );\n }\n\n if (ssrBuild) {\n if (isWindows) {\n nitroConfig.externals = {\n inline: ['std-env'],\n };\n }\n\n nitroConfig = {\n ...nitroConfig,\n externals: {\n ...nitroConfig.externals,\n external: ['rxjs', 'node-fetch-native/dist/polyfill'],\n },\n moduleSideEffects: [\n 'zone.js/node',\n 'zone.js/fesm2015/zone-node',\n ...(nitroConfig.moduleSideEffects ?? []),\n ],\n handlers: [...pageHandlers, ...serverFnHandlers],\n };\n }\n }\n\n nitroConfig = mergeConfig(\n nitroConfig,\n nitroOptions as Record<string, any>,\n );\n\n i18nWorkers = false;\n if (\n isBuild &&\n options?.i18n &&\n options.i18n.workers !== false &&\n (options.i18n.loader || options.i18n.workers === true)\n ) {\n const resolvedNitro = await loadOptions({\n dev: false,\n preset: process.env['BUILD_PRESET'],\n ...nitroConfig,\n });\n i18nWorkers = resolveI18nWorkers(options, resolvedNitro);\n nitroConfig.preset = resolvedNitro.preset;\n }\n\n return {\n define: {\n ANALOG_I18N_FIXED_LOCALE: i18nWorkers\n ? 'globalThis.process.env.ANALOG_I18N_LOCALE'\n : 'undefined',\n },\n environments: {\n client: {\n build: {\n outDir:\n config?.build?.outDir ||\n resolve(workspaceRoot, 'dist', rootDir, 'client'),\n },\n },\n ssr: {\n consumer: 'server',\n build: {\n ssr: true,\n rollupOptions: {\n input: i18nWorkers\n ? { 'main.server': I18N_WORKER_SSR_ENTRY }\n : options?.entryServer ||\n resolve(\n workspaceRoot,\n rootDir,\n `${sourceRoot}/main.server.ts`,\n ),\n },\n outDir:\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, 'ssr'),\n },\n },\n },\n builder: {\n sharedPlugins: true,\n buildApp: async (builder) => {\n environmentBuild = true;\n const builds = [builder.build(builder.environments['client'])];\n\n if (options?.ssr || nitroConfig.prerender?.routes?.length) {\n builds.push(builder.build(builder.environments['ssr']));\n }\n\n await Promise.all(builds);\n\n let ssrEntryPath = resolve(\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, `ssr`),\n `main.server${filePrefix ? '.js' : ''}`,\n );\n\n // add check for main.server.mjs fallback on Windows\n if (isWindows && !existsSync(ssrEntryPath)) {\n ssrEntryPath = ssrEntryPath.replace('.js', '.mjs');\n }\n\n const ssrEntry = normalizePath(filePrefix + ssrEntryPath);\n\n nitroConfig.alias = {\n ...nitroConfig.alias,\n '#analog/ssr': ssrEntry,\n };\n\n await buildServer(\n options,\n nitroConfig,\n routeSourceFiles,\n i18nWorkers,\n );\n\n if (\n nitroConfig.prerender?.routes?.length &&\n options?.prerender?.sitemap\n ) {\n const publicDir = nitroConfig.output?.publicDir;\n if (!publicDir) {\n throw new Error(\n 'Nitro public output directory is required to build the sitemap.',\n );\n }\n\n console.log('Building Sitemap...');\n // sitemap needs to be built after all directories are built\n await buildSitemap(\n config,\n options.prerender.sitemap,\n nitroConfig.prerender.routes,\n publicDir,\n routeSitemaps,\n options.i18n,\n apiPrefix,\n );\n }\n\n console.log(\n `\\n\\nThe '@analogjs/platform' server has been successfully built.`,\n );\n },\n },\n };\n },\n async configureServer(viteServer: ViteDevServer) {\n if (isServe && !isTest) {\n const nitro = await createNitro({\n dev: true,\n ...nitroConfig,\n });\n const server = createDevServer(nitro);\n await build(nitro);\n const apiHandler = toNodeListener(server.app as unknown as App);\n\n // Server functions dispatch through `/_analog/fn/:id`, outside the\n // API prefix the Nitro dev server is mounted under, so route them\n // explicitly — otherwise a call falls through to the SSR catch-all\n // and the client gets HTML back instead of its result.\n if (hasServerFns) {\n viteServer.middlewares.use(\n (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n ) => {\n if (req.url?.startsWith(SERVER_FN_DISPATCH_PREFIX)) {\n apiHandler(req, res);\n return;\n }\n\n next();\n },\n );\n }\n\n viteServer.middlewares.use(\n (\n req: IncomingMessage,\n res: ServerResponse,\n next: (error?: unknown) => void,\n ) => {\n if (req.url?.startsWith(`${prefix}${apiPrefix}`)) {\n apiHandler(req, res);\n return;\n }\n\n next();\n },\n );\n\n // handle upgrades if websockets are enabled\n if (nitroOptions?.experimental?.websocket) {\n viteServer.httpServer?.on('upgrade', server.upgrade);\n }\n\n console.log(\n `\\n\\nThe server endpoints are accessible under the \"${prefix}${apiPrefix}\" path.`,\n );\n }\n },\n\n async closeBundle() {\n // Skip when build is triggered by the Environment API\n if (environmentBuild) {\n return;\n }\n\n if (ssrBuild) {\n return;\n }\n\n if (isBuild) {\n if (options?.ssr) {\n console.log('Building SSR application...');\n await buildSSRApp(config, options, i18nWorkers);\n }\n\n if (\n nitroConfig.prerender?.routes?.length &&\n options?.prerender?.sitemap\n ) {\n console.log('Building Sitemap...');\n // sitemap needs to be built after all directories are built\n await buildSitemap(\n config,\n options.prerender.sitemap,\n nitroConfig.prerender.routes,\n clientOutputPath,\n routeSitemaps,\n options.i18n,\n apiPrefix,\n );\n }\n\n let ssrEntryPath = resolve(\n options?.ssrBuildDir ||\n resolve(workspaceRoot, 'dist', rootDir, `ssr`),\n `main.server${filePrefix ? '.js' : ''}`,\n );\n\n // add check for main.server.mjs fallback on Windows\n if (isWindows && !existsSync(ssrEntryPath)) {\n ssrEntryPath = ssrEntryPath.replace('.js', '.mjs');\n }\n\n const ssrEntry = normalizePath(filePrefix + ssrEntryPath);\n\n nitroConfig.alias = {\n ...nitroConfig.alias,\n '#analog/ssr': ssrEntry,\n };\n\n await buildServer(\n options,\n nitroConfig,\n routeSourceFiles,\n i18nWorkers,\n );\n\n console.log(\n `\\n\\nThe '@analogjs/platform' server has been successfully built.`,\n );\n }\n },\n },\n {\n name: 'analog-i18n-worker-entry',\n apply: 'build' as const,\n resolveId(id: string) {\n return id === I18N_WORKER_SSR_ENTRY && options?.i18n?.loader\n ? '\\0' + id\n : undefined;\n },\n load(id: string) {\n if (id !== '\\0' + I18N_WORKER_SSR_ENTRY || !options?.i18n?.loader)\n return;\n return i18nWorkerSsrEntry(\n normalizePath(\n resolve(\n workspaceRoot,\n rootDir,\n options.entryServer || `${sourceRoot}/main.server.ts`,\n ),\n ),\n normalizePath(resolve(workspaceRoot, rootDir, options.i18n.loader)),\n options.i18n,\n );\n },\n },\n devServerPlugin(() => ({\n ...options,\n routeRules: nitroOptions?.routeRules,\n })),\n {\n name: '@analogjs/vite-plugin-nitro-api-prefix',\n config() {\n return {\n define: {\n ANALOG_API_PREFIX: `\"${baseURL.substring(1)}${apiPrefix.substring(1)}\"`,\n ...(options?.i18n\n ? {\n ANALOG_I18N_DEFAULT_LOCALE: JSON.stringify(\n options.i18n.defaultLocale,\n ),\n ANALOG_I18N_LOCALES: JSON.stringify(options.i18n.locales),\n }\n : {}),\n },\n };\n },\n },\n ];\n}\n\nfunction isEmptyPrerenderRoutes(options?: Options): boolean {\n if (!options || isArrayWithElements(options?.prerender?.routes)) {\n return false;\n }\n return !options.prerender?.routes;\n}\n\nfunction isArrayWithElements<T>(arr: unknown): arr is [T, ...T[]] {\n return !!(Array.isArray(arr) && arr.length);\n}\n\nconst isVercelPreset = (buildPreset: string | undefined) =>\n process.env['VERCEL'] ||\n (buildPreset && buildPreset.toLowerCase().includes('vercel'));\n\nconst withVercelOutputAPI = (\n nitroConfig: NitroConfig | undefined,\n workspaceRoot: string,\n) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n dir: normalizePath(resolve(workspaceRoot, '.vercel', 'output')),\n publicDir: normalizePath(\n resolve(workspaceRoot, '.vercel', 'output/static'),\n ),\n },\n});\n\nconst isCloudflarePreset = (buildPreset: string | undefined) =>\n process.env['CF_PAGES'] ||\n (buildPreset && buildPreset.toLowerCase().includes('cloudflare-pages'));\n\nconst withCloudflareOutput = (nitroConfig: NitroConfig | undefined) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n serverDir: '{{ output.publicDir }}/_worker.js',\n },\n});\n\nconst isFirebaseAppHosting = () => !!process.env['NG_BUILD_LOGS_JSON'];\nconst withAppHostingOutput = (nitroConfig: NitroConfig) => {\n let hasOutput = false;\n\n return <NitroConfig>{\n ...nitroConfig,\n serveStatic: true,\n rollupConfig: {\n ...nitroConfig.rollupConfig,\n output: {\n ...nitroConfig.rollupConfig?.output,\n entryFileNames: 'server.mjs',\n },\n },\n hooks: {\n ...nitroConfig.hooks,\n compiled: () => {\n if (!hasOutput) {\n const buildOutput = {\n errors: [],\n warnings: [],\n outputPaths: {\n root: pathToFileURL(`${nitroConfig.output?.dir}`),\n browser: pathToFileURL(`${nitroConfig.output?.publicDir}`),\n server: pathToFileURL(`${nitroConfig.output?.dir}/server`),\n },\n };\n\n // Log the build output for Firebase App Hosting to pick up\n console.log(JSON.stringify(buildOutput, null, 2));\n hasOutput = true;\n }\n },\n },\n };\n};\n\nfunction resolveServerFnAppConfigModule(\n workspaceRoot: string,\n rootDir: string,\n sourceRoot: string,\n): string | undefined {\n // The app's server config (the one `main.server.ts` renders with), exporting\n // `config`. Server-function handlers bootstrap against it, so they resolve the\n // same DI as SSR with no separate provider list to maintain.\n const root = normalizePath(resolve(workspaceRoot, rootDir));\n const candidates = [\n `${root}/${sourceRoot}/app/app.config.server.ts`,\n `${root}/${sourceRoot}/app.config.server.ts`,\n ];\n return candidates.find((candidate) => existsSync(candidate));\n}\n\nconst isNetlifyPreset = (buildPreset: string | undefined) =>\n process.env['NETLIFY'] ||\n (buildPreset && buildPreset.toLowerCase().includes('netlify'));\n\nconst withNetlifyOutputAPI = (\n nitroConfig: NitroConfig | undefined,\n workspaceRoot: string,\n) => ({\n ...nitroConfig,\n output: {\n ...nitroConfig?.output,\n dir: normalizePath(resolve(workspaceRoot, 'netlify/functions')),\n },\n});\n\n/**\n * Reads the options passed to `analog()` from `@analogjs/platform`, which\n * exposes them on its plugin `api`.\n */\nfunction getAnalogOptions(userConfig: UserConfig): Options | undefined {\n const plugins = ((userConfig.plugins ?? []) as unknown[]).flat(Infinity) as (\n | { api?: { analogOptions?: Options } }\n | null\n | undefined\n )[];\n return plugins.find((plugin) => plugin?.api?.analogOptions)?.api\n ?.analogOptions;\n}\n\n/**\n * Stamps `ssr` and `streaming` route rules as response headers, which the\n * renderers read to skip SSR or streaming for matching routes. `true` rules\n * stamp `'false'` so they override a broader `false` rule.\n */\nfunction withAnalogRouteRuleHeaders(nitroOptions: NitroConfig): NitroConfig {\n if (!nitroOptions.routeRules) {\n return nitroOptions;\n }\n\n const routeRules = Object.fromEntries(\n Object.entries(nitroOptions.routeRules).map(([route, rule]) => [\n route,\n {\n ...rule,\n headers: {\n ...rule.headers,\n ...(typeof rule.ssr === 'boolean'\n ? { 'x-analog-no-ssr': String(!rule.ssr) }\n : {}),\n ...(typeof rule.streaming === 'boolean'\n ? { 'x-analog-no-streaming': String(!rule.streaming) }\n : {}),\n },\n },\n ]),\n );\n\n return { ...nitroOptions, routeRules };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqDA,IAAM,YAAY,SAAS,MAAM;AACjC,IAAM,aAAa,YAAY,aAAa;AAC5C,IAAI,mBAAmB;AAEvB,IAAM,aAAa,cAAc,YAAY,GAAG;AAC9B,QAAQ,UAAU;AAUpC,SAAgB,MAAM,gBAAoC,CAAC,GAAa;CAEtE,MAAM,EAAE,QAAQ,QAAQ,UAAU,GAAG,uBAAuB;CAC5D,MAAM,eAAe,2BAA2B,kBAAkB;CAClE,IAAI;CACJ,IAAI,gBAAgB,QAAQ,IAAI;CAChC,IAAI,aAAa;CACjB,IAAI,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACjE,MAAM,UAAU,QAAQ,IAAI,yBAAyB;CACrD,MAAM,SAAS,UAAU,QAAQ,UAAU,GAAG,QAAQ,SAAS,CAAC,IAAI;CACpE,IAAI,YAAY;CAEhB,IAAI,cAAc;CAClB,IAAI,UAAU;CACd,IAAI,UAAU;CACd,IAAI,WAAW;CACf,IAAI;CACJ,IAAI;CACJ,IAAI,mBAAmB;CACvB,IAAI,eAAe;CACnB,MAAM,gBAGF,CAAC;CACL,MAAM,mBAA2C,CAAC;CAClD,IAAI,UAAU;CAId,SAAS,eAAe,YAAwB;EAC9C,UAAU;GACR,GAAG,iBAAiB,UAAU;GAC9B,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,SAAS;GACrD,GAAG;EACL;EACA,gBAAgB,QAAQ,iBAAiB,QAAQ,IAAI;EACrD,aAAa,QAAQ,cAAc;EACnC,YAAY,IAAI,QAAQ,aAAa;CACvC;CAEA,OAAO;EACL;GACE,MAAM;GACN,MAAM,OAAO,YAAY,EAAE,MAAM,WAAW;IAC1C,eAAe,UAAU;IACzB,U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