@intlayer/core 8.5.2 → 8.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/cjs/formatters/compact.cjs +1 -1
  2. package/dist/cjs/formatters/compact.cjs.map +1 -1
  3. package/dist/cjs/formatters/currency.cjs +1 -1
  4. package/dist/cjs/formatters/currency.cjs.map +1 -1
  5. package/dist/cjs/formatters/date.cjs +1 -1
  6. package/dist/cjs/formatters/date.cjs.map +1 -1
  7. package/dist/cjs/formatters/index.cjs +1 -1
  8. package/dist/cjs/formatters/list.cjs +1 -1
  9. package/dist/cjs/formatters/list.cjs.map +1 -1
  10. package/dist/cjs/formatters/number.cjs +1 -1
  11. package/dist/cjs/formatters/number.cjs.map +1 -1
  12. package/dist/cjs/formatters/percentage.cjs +2 -2
  13. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  14. package/dist/cjs/formatters/relativeTime.cjs +1 -1
  15. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  16. package/dist/cjs/formatters/units.cjs +1 -1
  17. package/dist/cjs/formatters/units.cjs.map +1 -1
  18. package/dist/cjs/index.cjs +17 -9
  19. package/dist/cjs/interpreter/getContent/getContent.cjs +1 -1
  20. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  21. package/dist/cjs/interpreter/getContent/index.cjs +1 -0
  22. package/dist/cjs/interpreter/getContent/plugins.cjs +20 -9
  23. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  24. package/dist/cjs/interpreter/index.cjs +1 -0
  25. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +10 -35
  26. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  27. package/dist/cjs/localization/generateSitemap.cjs +111 -0
  28. package/dist/cjs/localization/generateSitemap.cjs.map +1 -0
  29. package/dist/cjs/localization/getBrowserLocale.cjs +1 -1
  30. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  31. package/dist/cjs/localization/getLocale.cjs +2 -2
  32. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  33. package/dist/cjs/localization/getLocalizedUrl.cjs +1 -1
  34. package/dist/cjs/localization/getPrefix.cjs +1 -1
  35. package/dist/cjs/localization/index.cjs +8 -7
  36. package/dist/cjs/localization/localeMapper.cjs +1 -1
  37. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +2 -3
  38. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  39. package/dist/cjs/utils/index.cjs +9 -3
  40. package/dist/cjs/utils/intl.cjs +88 -72
  41. package/dist/cjs/utils/intl.cjs.map +1 -1
  42. package/dist/cjs/utils/localeStorage.cjs +191 -64
  43. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  44. package/dist/esm/formatters/compact.mjs +2 -2
  45. package/dist/esm/formatters/compact.mjs.map +1 -1
  46. package/dist/esm/formatters/currency.mjs +2 -2
  47. package/dist/esm/formatters/currency.mjs.map +1 -1
  48. package/dist/esm/formatters/date.mjs +2 -2
  49. package/dist/esm/formatters/date.mjs.map +1 -1
  50. package/dist/esm/formatters/index.mjs +2 -2
  51. package/dist/esm/formatters/list.mjs +2 -2
  52. package/dist/esm/formatters/list.mjs.map +1 -1
  53. package/dist/esm/formatters/number.mjs +2 -2
  54. package/dist/esm/formatters/number.mjs.map +1 -1
  55. package/dist/esm/formatters/percentage.mjs +3 -3
  56. package/dist/esm/formatters/percentage.mjs.map +1 -1
  57. package/dist/esm/formatters/relativeTime.mjs +2 -2
  58. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  59. package/dist/esm/formatters/units.mjs +2 -2
  60. package/dist/esm/formatters/units.mjs.map +1 -1
  61. package/dist/esm/index.mjs +11 -11
  62. package/dist/esm/interpreter/getContent/getContent.mjs +1 -1
  63. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  64. package/dist/esm/interpreter/getContent/index.mjs +2 -2
  65. package/dist/esm/interpreter/getContent/plugins.mjs +20 -10
  66. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  67. package/dist/esm/interpreter/index.mjs +2 -2
  68. package/dist/esm/interpreter/splitAndJoinInsertion.mjs +10 -35
  69. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  70. package/dist/esm/localization/generateSitemap.mjs +109 -0
  71. package/dist/esm/localization/generateSitemap.mjs.map +1 -0
  72. package/dist/esm/localization/getBrowserLocale.mjs +2 -2
  73. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  74. package/dist/esm/localization/getLocale.mjs +3 -3
  75. package/dist/esm/localization/getLocale.mjs.map +1 -1
  76. package/dist/esm/localization/getLocalizedUrl.mjs +1 -1
  77. package/dist/esm/localization/getPrefix.mjs +1 -1
  78. package/dist/esm/localization/index.mjs +7 -7
  79. package/dist/esm/localization/localeMapper.mjs +1 -1
  80. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +2 -4
  81. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  82. package/dist/esm/utils/index.mjs +4 -4
  83. package/dist/esm/utils/intl.mjs +87 -72
  84. package/dist/esm/utils/intl.mjs.map +1 -1
  85. package/dist/esm/utils/localeStorage.mjs +186 -65
  86. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  87. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +10 -10
  88. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
  89. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +10 -10
  90. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
  91. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +10 -10
  92. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
  93. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +2 -2
  94. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
  95. package/dist/types/formatters/index.d.ts +2 -2
  96. package/dist/types/formatters/number.d.ts +4 -1
  97. package/dist/types/formatters/number.d.ts.map +1 -1
  98. package/dist/types/formatters/percentage.d.ts +4 -1
  99. package/dist/types/formatters/percentage.d.ts.map +1 -1
  100. package/dist/types/index.d.ts +5 -5
  101. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  102. package/dist/types/interpreter/getContent/index.d.ts +2 -2
  103. package/dist/types/interpreter/getContent/plugins.d.ts +7 -1
  104. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  105. package/dist/types/interpreter/index.d.ts +2 -2
  106. package/dist/types/interpreter/splitAndJoinInsertion.d.ts +0 -17
  107. package/dist/types/interpreter/splitAndJoinInsertion.d.ts.map +1 -1
  108. package/dist/types/localization/generateSitemap.d.ts +93 -0
  109. package/dist/types/localization/generateSitemap.d.ts.map +1 -0
  110. package/dist/types/localization/getBrowserLocale.d.ts +2 -2
  111. package/dist/types/localization/getBrowserLocale.d.ts.map +1 -1
  112. package/dist/types/localization/index.d.ts +2 -2
  113. package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts.map +1 -1
  114. package/dist/types/utils/index.d.ts +3 -3
  115. package/dist/types/utils/intl.d.ts +15 -11
  116. package/dist/types/utils/intl.d.ts.map +1 -1
  117. package/dist/types/utils/localeStorage.d.ts +85 -68
  118. package/dist/types/utils/localeStorage.d.ts.map +1 -1
  119. package/package.json +8 -8
  120. package/dist/cjs/getStorageAttributes.cjs +0 -135
  121. package/dist/cjs/getStorageAttributes.cjs.map +0 -1
  122. package/dist/esm/getStorageAttributes.mjs +0 -133
  123. package/dist/esm/getStorageAttributes.mjs.map +0 -1
  124. package/dist/types/getStorageAttributes.d.ts +0 -29
  125. package/dist/types/getStorageAttributes.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"splitAndJoinInsertion.cjs","names":[],"sources":["../../../src/interpreter/splitAndJoinInsertion.ts"],"sourcesContent":["/**\n * Check if a value is a complex object (not a primitive)\n * Used to determine if values need to be wrapped in fragments\n */\nconst isComplexValue = (value: any): boolean => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Core logic for splitting insertion strings and joining with values.\n * Returns an array of parts that can be wrapped by framework-specific Fragment implementations.\n *\n * @param template - The template string with {{ placeholder }} syntax\n * @param values - Map of placeholder names to their replacement values\n * @returns Object with `isSimple` flag and `parts` array\n *\n * @example\n * ```ts\n * const result = splitInsertionTemplate('Hello {{ name }}!', { name: 'World' });\n * // { isSimple: true, parts: 'Hello World!' }\n *\n * const result = splitInsertionTemplate('Hello {{ name }}!', { name: <Component /> });\n * // { isSimple: false, parts: ['Hello ', <Component />, '!'] }\n * ```\n */\nexport const splitInsertionTemplate = <T = any>(\n template: string,\n values: Record<string, T> = {}\n): { isSimple: boolean; parts: string | T[] } => {\n const safeValues = values ?? {};\n\n // Check if any value is a complex object (React/Vue node, etc.)\n const hasComplexValue = Object.values(safeValues).some(isComplexValue);\n\n if (!hasComplexValue) {\n // Simple string replacement\n const result = template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (safeValues[trimmedKey] ?? '').toString();\n });\n return { isSimple: true, parts: result };\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: any[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = safeValues[key];\n if (value !== undefined && value !== null) {\n parts.push(value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n return { isSimple: false, parts };\n};\n"],"mappings":";;;;;;;AAIA,MAAM,kBAAkB,UAAwB;AAC9C,QACE,UAAU,QACV,UAAU,UACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;;;;;;;;;;;;;;;;;;;AAqBrB,MAAa,0BACX,UACA,SAA4B,EAAE,KACiB;CAC/C,MAAM,aAAa,UAAU,EAAE;AAK/B,KAAI,CAFoB,OAAO,OAAO,WAAW,CAAC,KAAK,eAAe,CAQpE,QAAO;EAAE,UAAU;EAAM,OAJV,SAAS,QAAQ,yBAAyB,GAAG,QAAQ;AAElE,WAAQ,WADW,IAAI,MAAM,KACK,IAAI,UAAU;IAChD;EACsC;CAI1C,MAAM,QAAe,EAAE;CACvB,IAAI,YAAY;CAChB,MAAM,QAAQ;CACd,IAAI,QAAgC,MAAM,KAAK,SAAS;AAExD,QAAO,UAAU,MAAM;AAErB,MAAI,MAAM,QAAQ,UAChB,OAAM,KAAK,SAAS,UAAU,WAAW,MAAM,MAAM,CAAC;EAKxD,MAAM,QAAQ,WADF,MAAM,GAAG,MAAM;AAE3B,MAAI,UAAU,UAAa,UAAU,KACnC,OAAM,KAAK,MAAM;AAGnB,cAAY,MAAM,QAAQ,MAAM,GAAG;AACnC,UAAQ,MAAM,KAAK,SAAS;;AAI9B,KAAI,YAAY,SAAS,OACvB,OAAM,KAAK,SAAS,UAAU,UAAU,CAAC;AAG3C,QAAO;EAAE,UAAU;EAAO;EAAO"}
1
+ {"version":3,"file":"splitAndJoinInsertion.cjs","names":[],"sources":["../../../src/interpreter/splitAndJoinInsertion.ts"],"sourcesContent":["/**\n * Check if a value is a complex object (not a primitive)\n * Used to determine if values need to be wrapped in fragments\n */\nconst isComplexValue = (value: any): boolean =>\n value != null &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean';\n\n// Hoisted: replace/split do not suffer from the stateful lastIndex mutation of .exec()\nconst insertionRegex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n\nexport const splitInsertionTemplate = <T = any>(\n template: string,\n values: Record<string, T> = {}\n): { isSimple: boolean; parts: string | T[] } => {\n if (!Object.values(values).some(isComplexValue)) {\n return {\n isSimple: true,\n parts: template.replace(insertionRegex, (_, key) =>\n (values[key.trim()] ?? '').toString()\n ),\n };\n }\n\n const chunks = template.split(insertionRegex);\n const parts: any[] = [];\n\n for (let i = 0; i < chunks.length; i++) {\n if (i % 2 === 0) {\n if (chunks[i]) parts.push(chunks[i]);\n } else {\n const val = values[chunks[i].trim()];\n if (val != null) parts.push(val);\n }\n }\n\n return { isSimple: false, parts };\n};\n"],"mappings":";;;;;;;AAIA,MAAM,kBAAkB,UACtB,SAAS,QACT,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;AAGnB,MAAM,iBAAiB;AAEvB,MAAa,0BACX,UACA,SAA4B,EAAE,KACiB;AAC/C,KAAI,CAAC,OAAO,OAAO,OAAO,CAAC,KAAK,eAAe,CAC7C,QAAO;EACL,UAAU;EACV,OAAO,SAAS,QAAQ,iBAAiB,GAAG,SACzC,OAAO,IAAI,MAAM,KAAK,IAAI,UAAU,CACtC;EACF;CAGH,MAAM,SAAS,SAAS,MAAM,eAAe;CAC7C,MAAM,QAAe,EAAE;AAEvB,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IACjC,KAAI,IAAI,MAAM,GACZ;MAAI,OAAO,GAAI,OAAM,KAAK,OAAO,GAAG;QAC/B;EACL,MAAM,MAAM,OAAO,OAAO,GAAG,MAAM;AACnC,MAAI,OAAO,KAAM,OAAM,KAAK,IAAI;;AAIpC,QAAO;EAAE,UAAU;EAAO;EAAO"}
@@ -0,0 +1,111 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_localization_getPrefix = require('./getPrefix.cjs');
3
+ const require_localization_getMultilingualUrls = require('./getMultilingualUrls.cjs');
4
+
5
+ //#region src/localization/generateSitemap.ts
6
+ /**
7
+ * Returns whether xhtml:link alternate tags should be generated for the given routing mode.
8
+ *
9
+ * Alternates are meaningful only when locale URLs are distinct:
10
+ * - 'no-prefix' produces identical URLs for all locales → no alternates
11
+ * - all other modes produce distinct URLs → alternates are generated
12
+ */
13
+ const shouldIncludeAlternates = (mode, xhtmlLinks) => xhtmlLinks && mode !== "no-prefix";
14
+ /**
15
+ * Generates a single `<url>` sitemap entry for the given path.
16
+ *
17
+ * Example:
18
+ *
19
+ * ```ts
20
+ * generateSitemapUrl('/dashboard', {
21
+ * siteUrl: 'https://example.com',
22
+ * changefreq: 'weekly',
23
+ * priority: 0.8,
24
+ * xhtmlLinks: true,
25
+ * locales: ['en', 'fr'],
26
+ * defaultLocale: 'en',
27
+ * mode: 'prefix-no-default',
28
+ * });
29
+ * // Returns:
30
+ * // <url>
31
+ * // <loc>https://example.com/dashboard</loc>
32
+ * // <changefreq>weekly</changefreq>
33
+ * // <priority>0.8</priority>
34
+ * // <xhtml:link rel="alternate" hrefLang="en" href="https://example.com/dashboard"/>
35
+ * // <xhtml:link rel="alternate" hrefLang="fr" href="https://example.com/fr/dashboard"/>
36
+ * // <xhtml:link rel="alternate" hrefLang="x-default" href="https://example.com/dashboard"/>
37
+ * // </url>
38
+ * ```
39
+ *
40
+ * @param path - The canonical path to generate the entry for.
41
+ * @param options - Configuration options.
42
+ * @returns A `<url>` XML string.
43
+ */
44
+ const generateSitemapUrl = (path, options) => {
45
+ const { siteUrl, changefreq, priority, lastmod, xhtmlLinks = true, ...routingOptions } = options;
46
+ const resolved = require_localization_getPrefix.resolveRoutingConfig(routingOptions);
47
+ const fullUrl = `${siteUrl}${path}`;
48
+ const lines = [
49
+ " <url>",
50
+ ` <loc>${fullUrl}</loc>`,
51
+ lastmod ? ` <lastmod>${lastmod}</lastmod>` : null,
52
+ changefreq ? ` <changefreq>${changefreq}</changefreq>` : null,
53
+ priority !== void 0 ? ` <priority>${priority}</priority>` : null
54
+ ];
55
+ if (shouldIncludeAlternates(resolved.mode, xhtmlLinks)) {
56
+ const alternates = require_localization_getMultilingualUrls.getMultilingualUrls(path, routingOptions);
57
+ for (const [lang, localePath] of Object.entries(alternates)) lines.push(` <xhtml:link rel="alternate" hrefLang="${lang}" href="${siteUrl}${localePath}"/>`);
58
+ lines.push(` <xhtml:link rel="alternate" hrefLang="x-default" href="${fullUrl}"/>`);
59
+ }
60
+ lines.push(" </url>");
61
+ return lines.filter(Boolean).join("\n");
62
+ };
63
+ /**
64
+ * Generates a full XML sitemap string from an array of URL entries.
65
+ *
66
+ * Automatically adds `xmlns:xhtml` to the `<urlset>` declaration when
67
+ * xhtml:link alternate tags are included.
68
+ *
69
+ * Example:
70
+ *
71
+ * ```ts
72
+ * generateSitemap(
73
+ * [
74
+ * { path: '/', changefreq: 'daily', priority: 1.0 },
75
+ * { path: '/about', changefreq: 'monthly', priority: 0.5 },
76
+ * ],
77
+ * {
78
+ * siteUrl: 'https://example.com',
79
+ * xhtmlLinks: true,
80
+ * locales: ['en', 'fr'],
81
+ * defaultLocale: 'en',
82
+ * mode: 'prefix-no-default',
83
+ * }
84
+ * );
85
+ * ```
86
+ *
87
+ * @param entries - Array of URL entries to include in the sitemap.
88
+ * @param options - Sitemap generation options.
89
+ * @returns A full XML sitemap string.
90
+ */
91
+ const generateSitemap = (entries, options) => {
92
+ const { siteUrl, xhtmlLinks = true, ...routingOptions } = options;
93
+ const includeAlternates = shouldIncludeAlternates(require_localization_getPrefix.resolveRoutingConfig(routingOptions).mode, xhtmlLinks);
94
+ const xmlEntries = entries.map((entry) => generateSitemapUrl(entry.path, {
95
+ ...entry,
96
+ siteUrl,
97
+ xhtmlLinks,
98
+ ...routingOptions
99
+ }));
100
+ return `<?xml version="1.0" encoding="UTF-8"?>
101
+ <urlset
102
+ xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${includeAlternates ? "\n xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"" : ""}
103
+ >
104
+ ${xmlEntries.join("\n")}
105
+ </urlset>`;
106
+ };
107
+
108
+ //#endregion
109
+ exports.generateSitemap = generateSitemap;
110
+ exports.generateSitemapUrl = generateSitemapUrl;
111
+ //# sourceMappingURL=generateSitemap.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateSitemap.cjs","names":["resolveRoutingConfig","getMultilingualUrls"],"sources":["../../../src/localization/generateSitemap.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getMultilingualUrls } from './getMultilingualUrls';\nimport { type RoutingOptions, resolveRoutingConfig } from './getPrefix';\n\nexport type SitemapUrlEntry = {\n /** The canonical path, e.g. '/dashboard' */\n path: string;\n changefreq?: string;\n priority?: number;\n /** ISO date string, e.g. '2024-01-15' */\n lastmod?: string;\n};\n\nexport type GenerateSitemapOptions = {\n /** Base site URL without trailing slash, e.g. 'https://example.com' */\n siteUrl: string;\n /**\n * Whether to include xhtml:link alternate tags for multilingual support.\n *\n * When enabled, alternate links are only generated for modes where URLs\n * differ per locale:\n * - 'prefix-no-default': included\n * - 'prefix-all': included\n * - 'search-params': included\n * - 'no-prefix': excluded (all locales share the same URL)\n *\n * @default true\n */\n xhtmlLinks?: boolean;\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: RoutingConfig['mode'];\n rewrite?: RoutingConfig['rewrite'];\n};\n\n/**\n * Returns whether xhtml:link alternate tags should be generated for the given routing mode.\n *\n * Alternates are meaningful only when locale URLs are distinct:\n * - 'no-prefix' produces identical URLs for all locales → no alternates\n * - all other modes produce distinct URLs → alternates are generated\n */\nconst shouldIncludeAlternates = (\n mode: RoutingConfig['mode'],\n xhtmlLinks: boolean\n): boolean => xhtmlLinks && mode !== 'no-prefix';\n\n/**\n * Generates a single `<url>` sitemap entry for the given path.\n *\n * Example:\n *\n * ```ts\n * generateSitemapUrl('/dashboard', {\n * siteUrl: 'https://example.com',\n * changefreq: 'weekly',\n * priority: 0.8,\n * xhtmlLinks: true,\n * locales: ['en', 'fr'],\n * defaultLocale: 'en',\n * mode: 'prefix-no-default',\n * });\n * // Returns:\n * // <url>\n * // <loc>https://example.com/dashboard</loc>\n * // <changefreq>weekly</changefreq>\n * // <priority>0.8</priority>\n * // <xhtml:link rel=\"alternate\" hrefLang=\"en\" href=\"https://example.com/dashboard\"/>\n * // <xhtml:link rel=\"alternate\" hrefLang=\"fr\" href=\"https://example.com/fr/dashboard\"/>\n * // <xhtml:link rel=\"alternate\" hrefLang=\"x-default\" href=\"https://example.com/dashboard\"/>\n * // </url>\n * ```\n *\n * @param path - The canonical path to generate the entry for.\n * @param options - Configuration options.\n * @returns A `<url>` XML string.\n */\nexport const generateSitemapUrl = (\n path: string,\n options: SitemapUrlEntry & GenerateSitemapOptions\n): string => {\n const {\n siteUrl,\n changefreq,\n priority,\n lastmod,\n xhtmlLinks = true,\n ...routingOptions\n } = options;\n\n const resolved = resolveRoutingConfig(routingOptions as RoutingOptions);\n const fullUrl = `${siteUrl}${path}`;\n\n const lines: (string | null)[] = [\n ' <url>',\n ` <loc>${fullUrl}</loc>`,\n lastmod ? ` <lastmod>${lastmod}</lastmod>` : null,\n changefreq ? ` <changefreq>${changefreq}</changefreq>` : null,\n priority !== undefined ? ` <priority>${priority}</priority>` : null,\n ];\n\n if (shouldIncludeAlternates(resolved.mode, xhtmlLinks)) {\n const alternates = getMultilingualUrls(\n path,\n routingOptions as RoutingOptions\n );\n\n for (const [lang, localePath] of Object.entries(alternates)) {\n lines.push(\n ` <xhtml:link rel=\"alternate\" hrefLang=\"${lang}\" href=\"${siteUrl}${localePath}\"/>`\n );\n }\n\n lines.push(\n ` <xhtml:link rel=\"alternate\" hrefLang=\"x-default\" href=\"${fullUrl}\"/>`\n );\n }\n\n lines.push(' </url>');\n\n return lines.filter(Boolean).join('\\n');\n};\n\n/**\n * Generates a full XML sitemap string from an array of URL entries.\n *\n * Automatically adds `xmlns:xhtml` to the `<urlset>` declaration when\n * xhtml:link alternate tags are included.\n *\n * Example:\n *\n * ```ts\n * generateSitemap(\n * [\n * { path: '/', changefreq: 'daily', priority: 1.0 },\n * { path: '/about', changefreq: 'monthly', priority: 0.5 },\n * ],\n * {\n * siteUrl: 'https://example.com',\n * xhtmlLinks: true,\n * locales: ['en', 'fr'],\n * defaultLocale: 'en',\n * mode: 'prefix-no-default',\n * }\n * );\n * ```\n *\n * @param entries - Array of URL entries to include in the sitemap.\n * @param options - Sitemap generation options.\n * @returns A full XML sitemap string.\n */\nexport const generateSitemap = (\n entries: SitemapUrlEntry[],\n options: GenerateSitemapOptions\n): string => {\n const { siteUrl, xhtmlLinks = true, ...routingOptions } = options;\n\n const resolved = resolveRoutingConfig(routingOptions as RoutingOptions);\n const includeAlternates = shouldIncludeAlternates(resolved.mode, xhtmlLinks);\n\n const xmlEntries = entries.map((entry) =>\n generateSitemapUrl(entry.path, {\n ...entry,\n siteUrl,\n xhtmlLinks,\n ...routingOptions,\n })\n );\n\n const xmlns = includeAlternates\n ? '\\n xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"'\n : '';\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset\n xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"${xmlns}\n>\n${xmlEntries.join('\\n')}\n</urlset>`;\n};\n"],"mappings":";;;;;;;;;;;;AA2CA,MAAM,2BACJ,MACA,eACY,cAAc,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCrC,MAAa,sBACX,MACA,YACW;CACX,MAAM,EACJ,SACA,YACA,UACA,SACA,aAAa,MACb,GAAG,mBACD;CAEJ,MAAM,WAAWA,oDAAqB,eAAiC;CACvE,MAAM,UAAU,GAAG,UAAU;CAE7B,MAAM,QAA2B;EAC/B;EACA,YAAY,QAAQ;EACpB,UAAU,gBAAgB,QAAQ,cAAc;EAChD,aAAa,mBAAmB,WAAW,iBAAiB;EAC5D,aAAa,SAAY,iBAAiB,SAAS,eAAe;EACnE;AAED,KAAI,wBAAwB,SAAS,MAAM,WAAW,EAAE;EACtD,MAAM,aAAaC,6DACjB,MACA,eACD;AAED,OAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,WAAW,CACzD,OAAM,KACJ,6CAA6C,KAAK,UAAU,UAAU,WAAW,KAClF;AAGH,QAAM,KACJ,8DAA8D,QAAQ,KACvE;;AAGH,OAAM,KAAK,WAAW;AAEtB,QAAO,MAAM,OAAO,QAAQ,CAAC,KAAK,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BzC,MAAa,mBACX,SACA,YACW;CACX,MAAM,EAAE,SAAS,aAAa,MAAM,GAAG,mBAAmB;CAG1D,MAAM,oBAAoB,wBADTD,oDAAqB,eAAiC,CACZ,MAAM,WAAW;CAE5E,MAAM,aAAa,QAAQ,KAAK,UAC9B,mBAAmB,MAAM,MAAM;EAC7B,GAAG;EACH;EACA;EACA,GAAG;EACJ,CAAC,CACH;AAMD,QAAO;;uDAJO,oBACV,qDACA,GAIuD;;EAE3D,WAAW,KAAK,KAAK,CAAC"}
@@ -55,7 +55,7 @@ const detectLanguage = (order, options) => {
55
55
  };
56
56
  const storageDetector = () => {
57
57
  if (typeof window === "undefined") return;
58
- const locale = require_utils_localeStorage.getLocaleFromStorage({
58
+ const locale = require_utils_localeStorage.getLocaleFromStorageClient({
59
59
  getCookie: (name) => {
60
60
  try {
61
61
  const cookies = document.cookie.split(";");
@@ -1 +1 @@
1
- {"version":3,"file":"getBrowserLocale.cjs","names":["getLocaleFromStorage","configuration","localeDetector","ENGLISH"],"sources":["../../../src/localization/getBrowserLocale.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { ENGLISH } from '@intlayer/types/locales';\nimport {\n getLocaleFromStorage,\n type LocaleStorageOptions,\n} from '../utils/localeStorage';\nimport { localeDetector } from './localeDetector';\n\nexport enum LanguageDetector {\n Querystring = 'querystring',\n Storage = 'storage',\n Navigator = 'navigator',\n HtmlTag = 'htmlTag',\n}\n\nexport const localeStorageOptions: LocaleStorageOptions = {\n getCookie: (name: string) =>\n document.cookie\n .split(';')\n .find((c) => c.trim().startsWith(`${name}=`))\n ?.split('=')[1],\n getLocaleStorage: (name: string) => localStorage.getItem(name),\n getSessionStorage: (name: string) => sessionStorage.getItem(name),\n isCookieEnabled: true,\n setCookieStore: (name, value, attributes) =>\n cookieStore.set({\n name,\n value,\n path: attributes.path,\n domain: attributes.domain,\n expires: attributes.expires,\n sameSite: attributes.sameSite,\n }),\n setCookieString: (_name, cookie) => {\n // biome-ignore lint/suspicious/noDocumentCookie: set cookie fallback\n document.cookie = cookie;\n },\n setSessionStorage: (name, value) => sessionStorage.setItem(name, value),\n setLocaleStorage: (name, value) => localStorage.setItem(name, value),\n};\n\n// Default settings for the language detector\ntype LanguageDetectorOptions = {\n order?: LanguageDetector[];\n lookupQuerystring?: string;\n htmlTag?: HTMLElement | null;\n};\n\nconst getDefaultsOptions = (): LanguageDetectorOptions => {\n return {\n order: [\n LanguageDetector.Querystring,\n LanguageDetector.Storage,\n LanguageDetector.Navigator,\n LanguageDetector.HtmlTag,\n ],\n lookupQuerystring: 'locale',\n htmlTag: typeof document !== 'undefined' ? document.documentElement : null,\n };\n};\n\nconst detectLanguage = (\n order: string[],\n options: LanguageDetectorOptions\n): Record<LanguageDetector, Locale | undefined> => {\n const detected: Record<LanguageDetector, Locale | undefined> = {} as Record<\n LanguageDetector,\n Locale | undefined\n >;\n\n const queryStringDetector = () => {\n if (typeof window === 'undefined') return;\n const search = window.location.search || '';\n const params = new URLSearchParams(search);\n const value = params.get(options.lookupQuerystring ?? '');\n if (value) {\n detected[LanguageDetector.Querystring] = value as Locale;\n }\n };\n\n const storageDetector = () => {\n if (typeof window === 'undefined') return;\n\n const locale = getLocaleFromStorage({\n getCookie: (name: string) => {\n try {\n const cookies = document.cookie.split(';');\n const cookieName = `${name}=`;\n\n const cookie = cookies.find((cookie) =>\n cookie.trim().startsWith(cookieName)\n );\n\n if (cookie) {\n return cookie.split('=')[1].trim();\n }\n } catch {}\n return undefined;\n },\n getSessionStorage: (name: string) => {\n try {\n return window.sessionStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n getLocaleStorage: (name: string) => {\n try {\n return window.localStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n });\n\n if (locale) {\n detected[LanguageDetector.Storage] = locale;\n }\n };\n\n const navigatorDetector = () => {\n if (typeof navigator === 'undefined') return;\n\n const { internationalization } = configuration;\n const languages = navigator.languages ?? [navigator.language];\n\n // Use localeDetector to find the best matching locale\n const locale = localeDetector(\n { 'accept-language': languages.join(',') },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n if (locale) {\n detected[LanguageDetector.Navigator] = locale;\n }\n };\n\n const htmlTagDetector = () => {\n const htmlTag = options.htmlTag;\n if (htmlTag && typeof htmlTag.getAttribute === 'function') {\n const lang = htmlTag.getAttribute('lang');\n if (lang) {\n const { internationalization } = configuration;\n\n // Validate and resolve the locale\n const locale = localeDetector(\n { 'accept-language': lang },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n detected[LanguageDetector.HtmlTag] = locale;\n }\n }\n };\n\n // Map detector names to their corresponding functions\n const detectors: Record<string, () => void> = {\n [LanguageDetector.Querystring]: queryStringDetector,\n [LanguageDetector.Storage]: storageDetector,\n [LanguageDetector.Navigator]: navigatorDetector,\n [LanguageDetector.HtmlTag]: htmlTagDetector,\n };\n\n // Use the provided order to run each detector\n order.forEach((detectorName) => {\n detectors[detectorName]?.();\n });\n\n return detected;\n};\n\nconst getFirstAvailableLocale = (\n locales: Record<LanguageDetector, Locale | undefined>,\n order: LanguageDetector[]\n): Locale => {\n const { internationalization } = configuration;\n\n for (const detector of order) {\n const locale = locales[detector];\n\n if (locale && internationalization.locales.includes(locale)) {\n return locale;\n }\n }\n\n return internationalization?.defaultLocale ?? ENGLISH;\n};\n\n/**\n * Core language detector function for browser environments.\n *\n * Detects the user's preferred locale by checking multiple sources in order:\n * 1. Query string parameter\n * 2. Storage (cookies, localStorage, sessionStorage) - uses getLocaleFromStorage\n * 3. Navigator languages - uses localeDetector\n * 4. HTML lang attribute - uses localeDetector\n *\n * @param userOptions - Optional configuration for detection order and lookup keys\n * @returns The detected locale or the default locale\n *\n * @example\n * const locale = getBrowserLocale({ order: [LanguageDetector.Storage, LanguageDetector.Navigator] });\n */\nexport const getBrowserLocale = (\n userOptions: LanguageDetectorOptions | undefined = {}\n): Locale => {\n const options = { ...getDefaultsOptions(), ...userOptions };\n\n const locales = detectLanguage(options.order ?? [], options);\n\n return getFirstAvailableLocale(locales, options.order ?? []);\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"getBrowserLocale.cjs","names":["getLocaleFromStorageClient","configuration","localeDetector","ENGLISH"],"sources":["../../../src/localization/getBrowserLocale.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { ENGLISH } from '@intlayer/types/locales';\nimport {\n getLocaleFromStorageClient,\n type LocaleStorageClientOptions,\n} from '../utils/localeStorage';\nimport { localeDetector } from './localeDetector';\n\nexport enum LanguageDetector {\n Querystring = 'querystring',\n Storage = 'storage',\n Navigator = 'navigator',\n HtmlTag = 'htmlTag',\n}\n\nexport const localeStorageOptions: LocaleStorageClientOptions = {\n getCookie: (name: string) =>\n document.cookie\n .split(';')\n .find((c) => c.trim().startsWith(`${name}=`))\n ?.split('=')[1],\n getLocaleStorage: (name: string) => localStorage.getItem(name),\n getSessionStorage: (name: string) => sessionStorage.getItem(name),\n isCookieEnabled: true,\n setCookieStore: (name, value, attributes) =>\n cookieStore.set({\n name,\n value,\n path: attributes.path,\n domain: attributes.domain,\n expires: attributes.expires,\n sameSite: attributes.sameSite,\n }),\n setCookieString: (_name, cookie) => {\n // biome-ignore lint/suspicious/noDocumentCookie: set cookie fallback\n document.cookie = cookie;\n },\n setSessionStorage: (name, value) => sessionStorage.setItem(name, value),\n setLocaleStorage: (name, value) => localStorage.setItem(name, value),\n};\n\n// Default settings for the language detector\ntype LanguageDetectorOptions = {\n order?: LanguageDetector[];\n lookupQuerystring?: string;\n htmlTag?: HTMLElement | null;\n};\n\nconst getDefaultsOptions = (): LanguageDetectorOptions => {\n return {\n order: [\n LanguageDetector.Querystring,\n LanguageDetector.Storage,\n LanguageDetector.Navigator,\n LanguageDetector.HtmlTag,\n ],\n lookupQuerystring: 'locale',\n htmlTag: typeof document !== 'undefined' ? document.documentElement : null,\n };\n};\n\nconst detectLanguage = (\n order: string[],\n options: LanguageDetectorOptions\n): Record<LanguageDetector, Locale | undefined> => {\n const detected: Record<LanguageDetector, Locale | undefined> = {} as Record<\n LanguageDetector,\n Locale | undefined\n >;\n\n const queryStringDetector = () => {\n if (typeof window === 'undefined') return;\n const search = window.location.search || '';\n const params = new URLSearchParams(search);\n const value = params.get(options.lookupQuerystring ?? '');\n if (value) {\n detected[LanguageDetector.Querystring] = value as Locale;\n }\n };\n\n const storageDetector = () => {\n if (typeof window === 'undefined') return;\n\n const locale = getLocaleFromStorageClient({\n getCookie: (name: string) => {\n try {\n const cookies = document.cookie.split(';');\n const cookieName = `${name}=`;\n\n const cookie = cookies.find((cookie) =>\n cookie.trim().startsWith(cookieName)\n );\n\n if (cookie) {\n return cookie.split('=')[1].trim();\n }\n } catch {}\n return undefined;\n },\n getSessionStorage: (name: string) => {\n try {\n return window.sessionStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n getLocaleStorage: (name: string) => {\n try {\n return window.localStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n });\n\n if (locale) {\n detected[LanguageDetector.Storage] = locale;\n }\n };\n\n const navigatorDetector = () => {\n if (typeof navigator === 'undefined') return;\n\n const { internationalization } = configuration;\n const languages = navigator.languages ?? [navigator.language];\n\n // Use localeDetector to find the best matching locale\n const locale = localeDetector(\n { 'accept-language': languages.join(',') },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n if (locale) {\n detected[LanguageDetector.Navigator] = locale;\n }\n };\n\n const htmlTagDetector = () => {\n const htmlTag = options.htmlTag;\n if (htmlTag && typeof htmlTag.getAttribute === 'function') {\n const lang = htmlTag.getAttribute('lang');\n if (lang) {\n const { internationalization } = configuration;\n\n // Validate and resolve the locale\n const locale = localeDetector(\n { 'accept-language': lang },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n detected[LanguageDetector.HtmlTag] = locale;\n }\n }\n };\n\n // Map detector names to their corresponding functions\n const detectors: Record<string, () => void> = {\n [LanguageDetector.Querystring]: queryStringDetector,\n [LanguageDetector.Storage]: storageDetector,\n [LanguageDetector.Navigator]: navigatorDetector,\n [LanguageDetector.HtmlTag]: htmlTagDetector,\n };\n\n // Use the provided order to run each detector\n order.forEach((detectorName) => {\n detectors[detectorName]?.();\n });\n\n return detected;\n};\n\nconst getFirstAvailableLocale = (\n locales: Record<LanguageDetector, Locale | undefined>,\n order: LanguageDetector[]\n): Locale => {\n const { internationalization } = configuration;\n\n for (const detector of order) {\n const locale = locales[detector];\n\n if (locale && internationalization.locales.includes(locale)) {\n return locale;\n }\n }\n\n return internationalization?.defaultLocale ?? ENGLISH;\n};\n\n/**\n * Core language detector function for browser environments.\n *\n * Detects the user's preferred locale by checking multiple sources in order:\n * 1. Query string parameter\n * 2. Storage (cookies, localStorage, sessionStorage) - uses getLocaleFromStorage\n * 3. Navigator languages - uses localeDetector\n * 4. HTML lang attribute - uses localeDetector\n *\n * @param userOptions - Optional configuration for detection order and lookup keys\n * @returns The detected locale or the default locale\n *\n * @example\n * const locale = getBrowserLocale({ order: [LanguageDetector.Storage, LanguageDetector.Navigator] });\n */\nexport const getBrowserLocale = (\n userOptions: LanguageDetectorOptions | undefined = {}\n): Locale => {\n const options = { ...getDefaultsOptions(), ...userOptions };\n\n const locales = detectLanguage(options.order ?? [], options);\n\n return getFirstAvailableLocale(locales, options.order ?? []);\n};\n"],"mappings":";;;;;;;;;AASA,IAAY,mBAAL;AACL;AACA;AACA;AACA;;KACD;AAED,MAAa,uBAAmD;CAC9D,YAAY,SACV,SAAS,OACN,MAAM,IAAI,CACV,MAAM,MAAM,EAAE,MAAM,CAAC,WAAW,GAAG,KAAK,GAAG,CAAC,EAC3C,MAAM,IAAI,CAAC;CACjB,mBAAmB,SAAiB,aAAa,QAAQ,KAAK;CAC9D,oBAAoB,SAAiB,eAAe,QAAQ,KAAK;CACjE,iBAAiB;CACjB,iBAAiB,MAAM,OAAO,eAC5B,YAAY,IAAI;EACd;EACA;EACA,MAAM,WAAW;EACjB,QAAQ,WAAW;EACnB,SAAS,WAAW;EACpB,UAAU,WAAW;EACtB,CAAC;CACJ,kBAAkB,OAAO,WAAW;AAElC,WAAS,SAAS;;CAEpB,oBAAoB,MAAM,UAAU,eAAe,QAAQ,MAAM,MAAM;CACvE,mBAAmB,MAAM,UAAU,aAAa,QAAQ,MAAM,MAAM;CACrE;AASD,MAAM,2BAAoD;AACxD,QAAO;EACL,OAAO;GACL,iBAAiB;GACjB,iBAAiB;GACjB,iBAAiB;GACjB,iBAAiB;GAClB;EACD,mBAAmB;EACnB,SAAS,OAAO,aAAa,cAAc,SAAS,kBAAkB;EACvE;;AAGH,MAAM,kBACJ,OACA,YACiD;CACjD,MAAM,WAAyD,EAAE;CAKjE,MAAM,4BAA4B;AAChC,MAAI,OAAO,WAAW,YAAa;EACnC,MAAM,SAAS,OAAO,SAAS,UAAU;EAEzC,MAAM,QADS,IAAI,gBAAgB,OAAO,CACrB,IAAI,QAAQ,qBAAqB,GAAG;AACzD,MAAI,MACF,UAAS,iBAAiB,eAAe;;CAI7C,MAAM,wBAAwB;AAC5B,MAAI,OAAO,WAAW,YAAa;EAEnC,MAAM,SAASA,uDAA2B;GACxC,YAAY,SAAiB;AAC3B,QAAI;KACF,MAAM,UAAU,SAAS,OAAO,MAAM,IAAI;KAC1C,MAAM,aAAa,GAAG,KAAK;KAE3B,MAAM,SAAS,QAAQ,MAAM,WAC3B,OAAO,MAAM,CAAC,WAAW,WAAW,CACrC;AAED,SAAI,OACF,QAAO,OAAO,MAAM,IAAI,CAAC,GAAG,MAAM;YAE9B;;GAGV,oBAAoB,SAAiB;AACnC,QAAI;AACF,YAAO,OAAO,eAAe,QAAQ,KAAK,IAAI;YACxC;;GAGV,mBAAmB,SAAiB;AAClC,QAAI;AACF,YAAO,OAAO,aAAa,QAAQ,KAAK,IAAI;YACtC;;GAGX,CAAC;AAEF,MAAI,OACF,UAAS,iBAAiB,WAAW;;CAIzC,MAAM,0BAA0B;AAC9B,MAAI,OAAO,cAAc,YAAa;EAEtC,MAAM,EAAE,yBAAyBC;EACjC,MAAM,YAAY,UAAU,aAAa,CAAC,UAAU,SAAS;EAG7D,MAAM,SAASC,mDACb,EAAE,mBAAmB,UAAU,KAAK,IAAI,EAAE,EAC1C,qBAAqB,SACrB,qBAAqB,cACtB;AAED,MAAI,OACF,UAAS,iBAAiB,aAAa;;CAI3C,MAAM,wBAAwB;EAC5B,MAAM,UAAU,QAAQ;AACxB,MAAI,WAAW,OAAO,QAAQ,iBAAiB,YAAY;GACzD,MAAM,OAAO,QAAQ,aAAa,OAAO;AACzC,OAAI,MAAM;IACR,MAAM,EAAE,yBAAyBD;IAGjC,MAAM,SAASC,mDACb,EAAE,mBAAmB,MAAM,EAC3B,qBAAqB,SACrB,qBAAqB,cACtB;AAED,aAAS,iBAAiB,WAAW;;;;CAM3C,MAAM,YAAwC;GAC3C,iBAAiB,cAAc;GAC/B,iBAAiB,UAAU;GAC3B,iBAAiB,YAAY;GAC7B,iBAAiB,UAAU;EAC7B;AAGD,OAAM,SAAS,iBAAiB;AAC9B,YAAU,iBAAiB;GAC3B;AAEF,QAAO;;AAGT,MAAM,2BACJ,SACA,UACW;CACX,MAAM,EAAE,yBAAyBD;AAEjC,MAAK,MAAM,YAAY,OAAO;EAC5B,MAAM,SAAS,QAAQ;AAEvB,MAAI,UAAU,qBAAqB,QAAQ,SAAS,OAAO,CACzD,QAAO;;AAIX,QAAO,sBAAsB,iBAAiBE;;;;;;;;;;;;;;;;;AAkBhD,MAAa,oBACX,cAAmD,EAAE,KAC1C;CACX,MAAM,UAAU;EAAE,GAAG,oBAAoB;EAAE,GAAG;EAAa;AAI3D,QAAO,wBAFS,eAAe,QAAQ,SAAS,EAAE,EAAE,QAAQ,EAEpB,QAAQ,SAAS,EAAE,CAAC"}
@@ -3,15 +3,15 @@ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_utils_localeStorage = require('../utils/localeStorage.cjs');
4
4
  const require_localization_localeResolver = require('./localeResolver.cjs');
5
5
  const require_localization_localeDetector = require('./localeDetector.cjs');
6
- let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
7
6
  let _intlayer_config_built = require("@intlayer/config/built");
8
7
  _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
8
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
9
9
 
10
10
  //#region src/localization/getLocale.ts
11
11
  const getLocale = async (ctx = {}) => {
12
12
  const defaultLocale = _intlayer_config_built.default?.internationalization?.defaultLocale ?? _intlayer_config_defaultValues.DEFAULT_LOCALE;
13
13
  const availableLocales = _intlayer_config_built.default?.internationalization?.locales ?? _intlayer_config_defaultValues.LOCALES;
14
- const storedLocale = require_utils_localeStorage.getLocaleFromStorage({
14
+ const storedLocale = require_utils_localeStorage.getLocaleFromStorageServer({
15
15
  getCookie: ctx.getCookie,
16
16
  getHeader: ctx.getHeader
17
17
  });
@@ -1 +1 @@
1
- {"version":3,"file":"getLocale.cjs","names":["configuration","DEFAULT_LOCALE","LOCALES","getLocaleFromStorage","localeResolver","getPreferredLanguages"],"sources":["../../../src/localization/getLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DEFAULT_LOCALE, LOCALES } from '@intlayer/config/defaultValues';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getLocaleFromStorage } from '../utils/localeStorage';\nimport { getPreferredLanguages } from './localeDetector';\nimport { localeResolver } from './localeResolver';\n\nexport type RequestContext = {\n getHeader?: (name: string) => string | null | undefined;\n getCookie?: (name: string) => string | null | undefined;\n};\n\nexport const getLocale = async (ctx: RequestContext = {}): Promise<Locale> => {\n const defaultLocale =\n configuration?.internationalization?.defaultLocale ?? DEFAULT_LOCALE;\n const availableLocales =\n configuration?.internationalization?.locales ?? LOCALES;\n\n // Try locale from storage (cookie or header)\n const storedLocale = getLocaleFromStorage({\n getCookie: ctx.getCookie,\n getHeader: ctx.getHeader,\n });\n\n if (storedLocale) {\n return storedLocale;\n }\n\n // Fallback to Accept-Language negotiation\n const acceptLanguageHeader = ctx.getHeader?.('accept-language');\n\n if (!acceptLanguageHeader) {\n return defaultLocale;\n }\n\n const preferredLocaleStrings = getPreferredLanguages(\n acceptLanguageHeader,\n availableLocales\n );\n\n const userFallbackLocale = localeResolver(\n preferredLocaleStrings,\n availableLocales,\n defaultLocale\n );\n\n if (userFallbackLocale) {\n return userFallbackLocale;\n }\n\n // Default locale\n return defaultLocale;\n};\n"],"mappings":";;;;;;;;;;AAYA,MAAa,YAAY,OAAO,MAAsB,EAAE,KAAsB;CAC5E,MAAM,gBACJA,gCAAe,sBAAsB,iBAAiBC;CACxD,MAAM,mBACJD,gCAAe,sBAAsB,WAAWE;CAGlD,MAAM,eAAeC,iDAAqB;EACxC,WAAW,IAAI;EACf,WAAW,IAAI;EAChB,CAAC;AAEF,KAAI,aACF,QAAO;CAIT,MAAM,uBAAuB,IAAI,YAAY,kBAAkB;AAE/D,KAAI,CAAC,qBACH,QAAO;CAQT,MAAM,qBAAqBC,mDALIC,0DAC7B,sBACA,iBACD,EAIC,kBACA,cACD;AAED,KAAI,mBACF,QAAO;AAIT,QAAO"}
1
+ {"version":3,"file":"getLocale.cjs","names":["configuration","DEFAULT_LOCALE","LOCALES","getLocaleFromStorageServer","localeResolver","getPreferredLanguages"],"sources":["../../../src/localization/getLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DEFAULT_LOCALE, LOCALES } from '@intlayer/config/defaultValues';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getLocaleFromStorageServer } from '../utils/localeStorage';\nimport { getPreferredLanguages } from './localeDetector';\nimport { localeResolver } from './localeResolver';\n\nexport type RequestContext = {\n getHeader?: (name: string) => string | null | undefined;\n getCookie?: (name: string) => string | null | undefined;\n};\n\nexport const getLocale = async (ctx: RequestContext = {}): Promise<Locale> => {\n const defaultLocale =\n configuration?.internationalization?.defaultLocale ?? DEFAULT_LOCALE;\n const availableLocales =\n configuration?.internationalization?.locales ?? LOCALES;\n\n // Try locale from storage (cookie or header)\n const storedLocale = getLocaleFromStorageServer({\n getCookie: ctx.getCookie,\n getHeader: ctx.getHeader,\n });\n\n if (storedLocale) {\n return storedLocale;\n }\n\n // Fallback to Accept-Language negotiation\n const acceptLanguageHeader = ctx.getHeader?.('accept-language');\n\n if (!acceptLanguageHeader) {\n return defaultLocale;\n }\n\n const preferredLocaleStrings = getPreferredLanguages(\n acceptLanguageHeader,\n availableLocales\n );\n\n const userFallbackLocale = localeResolver(\n preferredLocaleStrings,\n availableLocales,\n defaultLocale\n );\n\n if (userFallbackLocale) {\n return userFallbackLocale;\n }\n\n // Default locale\n return defaultLocale;\n};\n"],"mappings":";;;;;;;;;;AAYA,MAAa,YAAY,OAAO,MAAsB,EAAE,KAAsB;CAC5E,MAAM,gBACJA,gCAAe,sBAAsB,iBAAiBC;CACxD,MAAM,mBACJD,gCAAe,sBAAsB,WAAWE;CAGlD,MAAM,eAAeC,uDAA2B;EAC9C,WAAW,IAAI;EACf,WAAW,IAAI;EAChB,CAAC;AAEF,KAAI,aACF,QAAO;CAIT,MAAM,uBAAuB,IAAI,YAAY,kBAAkB;AAE/D,KAAI,CAAC,qBACH,QAAO;CAQT,MAAM,qBAAqBC,mDALIC,0DAC7B,sBACA,iBACD,EAIC,kBACA,cACD;AAED,KAAI,mBACF,QAAO;AAIT,QAAO"}
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_utils_checkIsURLAbsolute = require('../utils/checkIsURLAbsolute.cjs');
4
- const require_localization_getPrefix = require('./getPrefix.cjs');
5
4
  const require_localization_getPathWithoutLocale = require('./getPathWithoutLocale.cjs');
5
+ const require_localization_getPrefix = require('./getPrefix.cjs');
6
6
  const require_localization_rewriteUtils = require('./rewriteUtils.cjs');
7
7
  let _intlayer_config_built = require("@intlayer/config/built");
8
8
  _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
4
3
  let _intlayer_config_built = require("@intlayer/config/built");
5
4
  _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
5
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
6
6
 
7
7
  //#region src/localization/getPrefix.ts
8
8
  /**
@@ -1,21 +1,23 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_getStorageAttributes = require('../getStorageAttributes.cjs');
2
+ const require_localization_getPathWithoutLocale = require('./getPathWithoutLocale.cjs');
3
+ const require_localization_getPrefix = require('./getPrefix.cjs');
4
+ const require_localization_rewriteUtils = require('./rewriteUtils.cjs');
5
+ const require_localization_getLocalizedUrl = require('./getLocalizedUrl.cjs');
6
+ const require_localization_getMultilingualUrls = require('./getMultilingualUrls.cjs');
7
+ const require_localization_generateSitemap = require('./generateSitemap.cjs');
3
8
  const require_localization_localeResolver = require('./localeResolver.cjs');
4
9
  const require_localization_localeDetector = require('./localeDetector.cjs');
5
10
  const require_localization_getBrowserLocale = require('./getBrowserLocale.cjs');
6
11
  const require_localization_getHTMLTextDir = require('./getHTMLTextDir.cjs');
7
12
  const require_localization_getLocale = require('./getLocale.cjs');
8
- const require_localization_getPrefix = require('./getPrefix.cjs');
9
13
  const require_localization_getLocaleFromPath = require('./getLocaleFromPath.cjs');
10
14
  const require_localization_getLocaleLang = require('./getLocaleLang.cjs');
11
15
  const require_localization_getLocaleName = require('./getLocaleName.cjs');
12
- const require_localization_getPathWithoutLocale = require('./getPathWithoutLocale.cjs');
13
- const require_localization_rewriteUtils = require('./rewriteUtils.cjs');
14
- const require_localization_getLocalizedUrl = require('./getLocalizedUrl.cjs');
15
- const require_localization_getMultilingualUrls = require('./getMultilingualUrls.cjs');
16
16
  const require_localization_localeMapper = require('./localeMapper.cjs');
17
17
  const require_localization_validatePrefix = require('./validatePrefix.cjs');
18
18
 
19
+ exports.generateSitemap = require_localization_generateSitemap.generateSitemap;
20
+ exports.generateSitemapUrl = require_localization_generateSitemap.generateSitemapUrl;
19
21
  exports.getBrowserLocale = require_localization_getBrowserLocale.getBrowserLocale;
20
22
  exports.getCanonicalPath = require_localization_rewriteUtils.getCanonicalPath;
21
23
  exports.getHTMLTextDir = require_localization_getHTMLTextDir.getHTMLTextDir;
@@ -31,7 +33,6 @@ exports.getPathWithoutLocale = require_localization_getPathWithoutLocale.getPath
31
33
  exports.getPrefix = require_localization_getPrefix.getPrefix;
32
34
  exports.getRewritePath = require_localization_rewriteUtils.getRewritePath;
33
35
  exports.getRewriteRules = require_localization_rewriteUtils.getRewriteRules;
34
- exports.getStorageAttributes = require_getStorageAttributes.getStorageAttributes;
35
36
  exports.localeDetector = require_localization_localeDetector.localeDetector;
36
37
  exports.localeFlatMap = require_localization_localeMapper.localeFlatMap;
37
38
  exports.localeMap = require_localization_localeMapper.localeMap;
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
3
  const require_localization_getPrefix = require('./getPrefix.cjs');
4
- let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
5
4
  let _intlayer_config_built = require("@intlayer/config/built");
6
5
  _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
6
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
7
7
 
8
8
  //#region src/localization/localeMapper.ts
9
9
  /**
@@ -1,10 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_transpiler_html_htmlTags = require('./htmlTags.cjs');
3
2
 
4
3
  //#region src/transpiler/html/getHTMLCustomComponents.ts
5
4
  const parseAttributes = (attributesString) => {
6
5
  const attributes = {};
7
- if (!attributesString || !attributesString.trim()) return attributes;
6
+ if (!attributesString?.trim()) return attributes;
8
7
  [...attributesString.matchAll(/([a-zA-Z0-9-:_@]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))?/g)].forEach((match) => {
9
8
  const attrName = match[1];
10
9
  attributes[attrName] = "string";
@@ -25,7 +24,7 @@ const getHTMLCustomComponents = (content) => {
25
24
  const tagName = match[2];
26
25
  const attributesString = match[3];
27
26
  const isSelfClosing = !!match[4];
28
- if (require_transpiler_html_htmlTags.HTML_TAGS.includes(tagName.toLowerCase())) {
27
+ if (/^[a-z][a-z0-9]*$/.test(tagName)) {
29
28
  components[tagName] = true;
30
29
  return;
31
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getHTMLCustomComponents.cjs","names":["HTML_TAGS"],"sources":["../../../../src/transpiler/html/getHTMLCustomComponents.ts"],"sourcesContent":["import { HTML_TAGS } from './index';\n\nconst parseAttributes = (attributesString: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n\n if (!attributesString || !attributesString.trim()) {\n return attributes;\n }\n\n // Regex to match attribute names\n // Matches: name=\"value\", name='value', name=value, or just name\n const attrRegex =\n /([a-zA-Z0-9-:_@]+)(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^>\\s]+))?/g;\n\n const matches = [...attributesString.matchAll(attrRegex)];\n\n matches.forEach((match) => {\n const attrName = match[1];\n attributes[attrName] = 'string';\n });\n\n return attributes;\n};\n\n/**\n * Extracts component names from an HTML string.\n * - Standard HTML tags are set to `true`.\n * - Custom components are parsed to extract their attributes/props.\n */\nexport const getHTMLCustomComponents = (\n content: string\n): Record<string, Record<string, string> | true> => {\n if (typeof content !== 'string') {\n throw new Error('content must be a string');\n }\n\n // Regex to match tags: <Tag ...>, </Tag>, or <Tag ... />\n // Captures: 1: Closing slash (if any), 2: Tag Name, 3: Attributes, 4: Self-closing slash (if any)\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)\\s*([\\s\\S]*?)(\\/?)>/g;\n const matches = [...content.matchAll(tagRegex)];\n\n const components: Record<string, Record<string, string> | true> = {};\n\n matches.forEach((match) => {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attributesString = match[3];\n const isSelfClosing = !!match[4];\n\n // Component extraction logic\n if ((HTML_TAGS as readonly string[]).includes(tagName.toLowerCase())) {\n components[tagName] = true;\n return;\n }\n\n if (!components[tagName]) {\n components[tagName] = {};\n }\n\n // Safety check if we somehow have a collision or logic issue, though loop order handles it\n if (components[tagName] === true) {\n return;\n }\n\n if (isClosing) {\n return;\n }\n\n // Parse attributes for custom components\n const attributes = parseAttributes(attributesString);\n const componentDef = components[tagName] as Record<string, string>;\n Object.assign(componentDef, attributes);\n\n // If not self-closing, assume it has children\n if (!isSelfClosing) {\n componentDef.children = 'string';\n }\n });\n\n return components;\n};\n"],"mappings":";;;;AAEA,MAAM,mBAAmB,qBAAqD;CAC5E,MAAM,aAAqC,EAAE;AAE7C,KAAI,CAAC,oBAAoB,CAAC,iBAAiB,MAAM,CAC/C,QAAO;AAUT,CAFgB,CAAC,GAAG,iBAAiB,SAFnC,6DAEsD,CAAC,CAEjD,SAAS,UAAU;EACzB,MAAM,WAAW,MAAM;AACvB,aAAW,YAAY;GACvB;AAEF,QAAO;;;;;;;AAQT,MAAa,2BACX,YACkD;AAClD,KAAI,OAAO,YAAY,SACrB,OAAM,IAAI,MAAM,2BAA2B;CAM7C,MAAM,UAAU,CAAC,GAAG,QAAQ,SADX,6CAC6B,CAAC;CAE/C,MAAM,aAA4D,EAAE;AAEpE,SAAQ,SAAS,UAAU;EACzB,MAAM,YAAY,CAAC,CAAC,MAAM;EAC1B,MAAM,UAAU,MAAM;EACtB,MAAM,mBAAmB,MAAM;EAC/B,MAAM,gBAAgB,CAAC,CAAC,MAAM;AAG9B,MAAKA,2CAAgC,SAAS,QAAQ,aAAa,CAAC,EAAE;AACpE,cAAW,WAAW;AACtB;;AAGF,MAAI,CAAC,WAAW,SACd,YAAW,WAAW,EAAE;AAI1B,MAAI,WAAW,aAAa,KAC1B;AAGF,MAAI,UACF;EAIF,MAAM,aAAa,gBAAgB,iBAAiB;EACpD,MAAM,eAAe,WAAW;AAChC,SAAO,OAAO,cAAc,WAAW;AAGvC,MAAI,CAAC,cACH,cAAa,WAAW;GAE1B;AAEF,QAAO"}
1
+ {"version":3,"file":"getHTMLCustomComponents.cjs","names":[],"sources":["../../../../src/transpiler/html/getHTMLCustomComponents.ts"],"sourcesContent":["const parseAttributes = (attributesString: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n\n if (!attributesString?.trim()) {\n return attributes;\n }\n\n // Regex to match attribute names\n // Matches: name=\"value\", name='value', name=value, or just name\n const attrRegex =\n /([a-zA-Z0-9-:_@]+)(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^>\\s]+))?/g;\n\n const matches = [...attributesString.matchAll(attrRegex)];\n\n matches.forEach((match) => {\n const attrName = match[1];\n attributes[attrName] = 'string';\n });\n\n return attributes;\n};\n\n/**\n * Extracts component names from an HTML string.\n * - Standard HTML tags are set to `true`.\n * - Custom components are parsed to extract their attributes/props.\n */\nexport const getHTMLCustomComponents = (\n content: string\n): Record<string, Record<string, string> | true> => {\n if (typeof content !== 'string') {\n throw new Error('content must be a string');\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)\\s*([\\s\\S]*?)(\\/?)>/g;\n const matches = [...content.matchAll(tagRegex)];\n\n const components: Record<string, Record<string, string> | true> = {};\n\n matches.forEach((match) => {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attributesString = match[3];\n const isSelfClosing = !!match[4];\n\n // Matches any tag that is entirely lowercase letters and numbers (e.g., div, h1)\n const isStandardHTMLTag = /^[a-z][a-z0-9]*$/.test(tagName);\n\n if (isStandardHTMLTag) {\n components[tagName] = true;\n return;\n }\n\n if (!components[tagName]) {\n components[tagName] = {};\n }\n\n if (components[tagName] === true) {\n return;\n }\n\n if (isClosing) {\n return;\n }\n\n const attributes = parseAttributes(attributesString);\n const componentDef = components[tagName] as Record<string, string>;\n Object.assign(componentDef, attributes);\n\n if (!isSelfClosing) {\n componentDef.children = 'string';\n }\n });\n\n return components;\n};\n"],"mappings":";;;AAAA,MAAM,mBAAmB,qBAAqD;CAC5E,MAAM,aAAqC,EAAE;AAE7C,KAAI,CAAC,kBAAkB,MAAM,CAC3B,QAAO;AAUT,CAFgB,CAAC,GAAG,iBAAiB,SAFnC,6DAEsD,CAAC,CAEjD,SAAS,UAAU;EACzB,MAAM,WAAW,MAAM;AACvB,aAAW,YAAY;GACvB;AAEF,QAAO;;;;;;;AAQT,MAAa,2BACX,YACkD;AAClD,KAAI,OAAO,YAAY,SACrB,OAAM,IAAI,MAAM,2BAA2B;CAI7C,MAAM,UAAU,CAAC,GAAG,QAAQ,SADX,6CAC6B,CAAC;CAE/C,MAAM,aAA4D,EAAE;AAEpE,SAAQ,SAAS,UAAU;EACzB,MAAM,YAAY,CAAC,CAAC,MAAM;EAC1B,MAAM,UAAU,MAAM;EACtB,MAAM,mBAAmB,MAAM;EAC/B,MAAM,gBAAgB,CAAC,CAAC,MAAM;AAK9B,MAF0B,mBAAmB,KAAK,QAAQ,EAEnC;AACrB,cAAW,WAAW;AACtB;;AAGF,MAAI,CAAC,WAAW,SACd,YAAW,WAAW,EAAE;AAG1B,MAAI,WAAW,aAAa,KAC1B;AAGF,MAAI,UACF;EAGF,MAAM,aAAa,gBAAgB,iBAAiB;EACpD,MAAM,eAAe,WAAW;AAChC,SAAO,OAAO,cAAc,WAAW;AAEvC,MAAI,CAAC,cACH,cAAa,WAAW;GAE1B;AAEF,QAAO"}
@@ -2,20 +2,26 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils_parseYaml = require('./parseYaml.cjs');
3
3
  const require_utils_isValidReactElement = require('./isValidReactElement.cjs');
4
4
  const require_utils_intl = require('./intl.cjs');
5
+ const require_utils_checkIsURLAbsolute = require('./checkIsURLAbsolute.cjs');
5
6
  const require_utils_getCookie = require('./getCookie.cjs');
6
7
  const require_utils_localeStorage = require('./localeStorage.cjs');
7
- const require_utils_checkIsURLAbsolute = require('./checkIsURLAbsolute.cjs');
8
8
  const require_utils_isSameKeyPath = require('./isSameKeyPath.cjs');
9
9
 
10
10
  exports.CachedIntl = require_utils_intl.CachedIntl;
11
11
  exports.Intl = require_utils_intl.CachedIntl;
12
12
  exports.LocaleStorage = require_utils_localeStorage.LocaleStorage;
13
+ exports.LocaleStorageClient = require_utils_localeStorage.LocaleStorageClient;
14
+ exports.LocaleStorageServer = require_utils_localeStorage.LocaleStorageServer;
13
15
  exports.bindIntl = require_utils_intl.bindIntl;
14
16
  exports.checkIsURLAbsolute = require_utils_checkIsURLAbsolute.checkIsURLAbsolute;
15
- exports.createCachedIntl = require_utils_intl.createCachedIntl;
17
+ exports.getCachedIntl = require_utils_intl.getCachedIntl;
16
18
  exports.getCookie = require_utils_getCookie.getCookie;
17
19
  exports.getLocaleFromStorage = require_utils_localeStorage.getLocaleFromStorage;
20
+ exports.getLocaleFromStorageClient = require_utils_localeStorage.getLocaleFromStorageClient;
21
+ exports.getLocaleFromStorageServer = require_utils_localeStorage.getLocaleFromStorageServer;
18
22
  exports.isSameKeyPath = require_utils_isSameKeyPath.isSameKeyPath;
19
23
  exports.isValidElement = require_utils_isValidReactElement.isValidElement;
20
24
  exports.parseYaml = require_utils_parseYaml.parseYaml;
21
- exports.setLocaleInStorage = require_utils_localeStorage.setLocaleInStorage;
25
+ exports.setLocaleInStorage = require_utils_localeStorage.setLocaleInStorage;
26
+ exports.setLocaleInStorageClient = require_utils_localeStorage.setLocaleInStorageClient;
27
+ exports.setLocaleInStorageServer = require_utils_localeStorage.setLocaleInStorageServer;
@@ -1,92 +1,108 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types_locales = require("@intlayer/types/locales");
3
+ let _intlayer_config_built = require("@intlayer/config/built");
4
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
4
5
 
5
6
  //#region src/utils/intl.ts
6
7
  /**
7
- * Optimized Cache Key Generator
8
- * 1. Fast path: If no options, just use the locale string.
9
- * 2. Normal path: JSON.stringify for deterministic object comparison.
8
+ * Cached Intl helper – drop‑in replacement for the global `Intl` object.
9
+ * ‑‑‑
10
+ * Uses a `Proxy` to lazily wrap every *constructor* hanging off `Intl` (NumberFormat, DateTimeFormat, …).
11
+ * • Each wrapped constructor keeps an in‑memory cache keyed by `[locales, options]` so that identical requests
12
+ * reuse the same heavy instance instead of reparsing CLDR data every time.
13
+ * • A polyfill warning for `Intl.DisplayNames` is emitted only once and only in dev.
14
+ * • The public API is fully type‑safe and mirrors the native `Intl` surface exactly –
15
+ * you can treat `CachedIntl` just like the built‑in `Intl`.
16
+ *
17
+ * Usage @example:
18
+ * ---------------
19
+ * ```ts
20
+ * import { CachedIntl } from "./cached-intl";
21
+ *
22
+ * const nf = CachedIntl.NumberFormat("en-US", { style: "currency", currency: "USD" });
23
+ * console.log(nf.format(1234));
24
+ *
25
+ * const dn = CachedIntl.DisplayNames(["fr"], { type: "language" });
26
+ * console.log(dn.of("en")); * → "anglais"
27
+ *
28
+ * You can also spin up an isolated instance with its own caches (handy in test suites):
29
+ * const TestIntl = createCachedIntl();
30
+ * ```
10
31
  */
11
- const getCacheKey = (locales, options) => {
12
- const localeKey = locales ? String(locales) : _intlayer_types_locales.ENGLISH;
13
- if (!options) return localeKey;
14
- return `${localeKey}|${JSON.stringify(options)}`;
15
- };
32
+ const MAX_CACHE_SIZE = 50;
33
+ const cache = /* @__PURE__ */ new Map();
16
34
  /**
17
- * Generic wrapper for any `new Intl.*()` constructor.
35
+ * Generic caching instantiator for Intl constructors.
18
36
  */
19
- const createCachedConstructor = (Ctor) => {
20
- const cache = /* @__PURE__ */ new Map();
21
- const MAX_CACHE_SIZE = 50;
22
- function Wrapped(locales, options) {
23
- let resolvedLocales = locales;
24
- let resolvedOptions = options;
25
- if (typeof locales === "object" && !Array.isArray(locales) && locales !== null) {
26
- resolvedOptions = locales;
27
- resolvedLocales = locales.locale;
28
- }
29
- if (Ctor.name === "DisplayNames" && typeof Intl?.DisplayNames !== "function") {}
30
- const key = getCacheKey(resolvedLocales, resolvedOptions);
31
- let instance = cache.get(key);
32
- if (instance) return instance;
33
- instance = new Ctor(resolvedLocales, resolvedOptions);
34
- if (cache.size >= MAX_CACHE_SIZE) {
35
- const oldestKey = cache.keys().next().value;
36
- if (oldestKey) cache.delete(oldestKey);
37
- }
38
- cache.set(key, instance);
39
- return instance;
37
+ const getCachedIntl = (Ctor, locale, options) => {
38
+ const resLoc = locale ?? _intlayer_config_built.default?.internationalization?.defaultLocale;
39
+ const key = `${resLoc}|${options ? JSON.stringify(options) : ""}`;
40
+ let ctorCache = cache.get(Ctor);
41
+ if (!ctorCache) {
42
+ ctorCache = /* @__PURE__ */ new Map();
43
+ cache.set(Ctor, ctorCache);
40
44
  }
41
- Wrapped.prototype = Ctor.prototype;
42
- return Wrapped;
45
+ let instance = ctorCache.get(key);
46
+ if (!instance) {
47
+ if (ctorCache.size > MAX_CACHE_SIZE) ctorCache.clear();
48
+ instance = new Ctor(resLoc, options);
49
+ ctorCache.set(key, instance);
50
+ }
51
+ return instance;
43
52
  };
44
53
  /**
45
- * Factory that turns the global `Intl` into a cached clone.
54
+ * Optional: Keep bindIntl if your library exports it publicly.
55
+ * It now uses the much smaller getCachedIntl under the hood.
46
56
  */
47
- const createCachedIntl = () => {
48
- const constructorCache = /* @__PURE__ */ new Map();
49
- return new Proxy(Intl, { get: (target, prop, receiver) => {
50
- if (constructorCache.has(prop)) return constructorCache.get(prop);
51
- const value = Reflect.get(target, prop, receiver);
52
- if (typeof value === "function" && typeof prop === "string" && /^[A-Z]/.test(prop)) {
53
- const wrapped = createCachedConstructor(value);
54
- constructorCache.set(prop, wrapped);
55
- return wrapped;
56
- }
57
- return value;
58
- } });
57
+ const bindIntl = (boundLocale) => {
58
+ const bindWrap = (Ctor) => function intlConstructor(locales, options) {
59
+ const isOptsFirst = locales !== null && typeof locales === "object" && !Array.isArray(locales);
60
+ const resOpts = isOptsFirst ? locales : options;
61
+ return getCachedIntl(Ctor, isOptsFirst ? resOpts.locale || boundLocale : locales || boundLocale, resOpts);
62
+ };
63
+ return {
64
+ ...Intl,
65
+ Collator: bindWrap(Intl.Collator),
66
+ DateTimeFormat: bindWrap(Intl.DateTimeFormat),
67
+ DisplayNames: bindWrap(Intl.DisplayNames),
68
+ ListFormat: bindWrap(Intl.ListFormat),
69
+ NumberFormat: bindWrap(Intl.NumberFormat),
70
+ PluralRules: bindWrap(Intl.PluralRules),
71
+ RelativeTimeFormat: bindWrap(Intl.RelativeTimeFormat),
72
+ Locale: bindWrap(Intl.Locale),
73
+ Segmenter: bindWrap(Intl.Segmenter)
74
+ };
59
75
  };
60
- const CachedIntl = createCachedIntl();
61
- /**
62
- * Creates a proxied Intl object with a preset locale.
63
- *
64
- * @example
65
- * const intl = bindIntl(Locales.FRENCH);
66
- * new intl.NumberFormat(undefined, { style: 'currency', currency: 'EUR' }).format(10);
67
- * // Uses 'fr' automatically
68
- */
69
- const bindIntl = (locale) => {
70
- return new Proxy(CachedIntl, { get: (target, prop) => {
71
- const value = Reflect.get(target, prop);
72
- if (typeof value === "function" && typeof prop === "string" && /^[A-Z]/.test(prop)) return new Proxy(value, {
73
- construct: (Ctor, args) => {
74
- let [locales, options] = args;
75
- if (typeof locales === "object" && !Array.isArray(locales) && locales !== null) {
76
- options = locales;
77
- locales = options.locale ?? locale;
78
- } else if (locales === void 0) locales = locale;
79
- return new Ctor(locales, options);
80
- },
81
- get: (Ctor, key) => Reflect.get(Ctor, key)
82
- });
83
- return value;
84
- } });
76
+ const CachedIntl = {
77
+ Collator: function Collator(locales, options) {
78
+ return getCachedIntl(Intl.Collator, locales, options);
79
+ },
80
+ DateTimeFormat: function DateTimeFormat(locales, options) {
81
+ return getCachedIntl(Intl.DateTimeFormat, locales, options);
82
+ },
83
+ DisplayNames: function DisplayNames(locales, options) {
84
+ return getCachedIntl(Intl.DisplayNames, locales, options);
85
+ },
86
+ ListFormat: function ListFormat(locales, options) {
87
+ return getCachedIntl(Intl.ListFormat, locales, options);
88
+ },
89
+ NumberFormat: function NumberFormat(locales, options) {
90
+ return getCachedIntl(Intl.NumberFormat, locales, options);
91
+ },
92
+ PluralRules: function PluralRules(locales, options) {
93
+ return getCachedIntl(Intl.PluralRules, locales, options);
94
+ },
95
+ RelativeTimeFormat: function RelativeTimeFormat(locales, options) {
96
+ return getCachedIntl(Intl.RelativeTimeFormat, locales, options);
97
+ },
98
+ Segmenter: function Segmenter(locales, options) {
99
+ return getCachedIntl(Intl.Segmenter, locales, options);
100
+ }
85
101
  };
86
102
 
87
103
  //#endregion
88
104
  exports.CachedIntl = CachedIntl;
89
105
  exports.Intl = CachedIntl;
90
106
  exports.bindIntl = bindIntl;
91
- exports.createCachedIntl = createCachedIntl;
107
+ exports.getCachedIntl = getCachedIntl;
92
108
  //# sourceMappingURL=intl.cjs.map