@intlayer/core 9.5.10 → 9.5.12

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 (57) hide show
  1. package/dist/cjs/index.cjs +7 -2
  2. package/dist/cjs/interpreter/getDictionary.cjs +4 -3
  3. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  4. package/dist/cjs/interpreter/getDictionaryAsync.cjs +2 -2
  5. package/dist/cjs/interpreter/getDictionaryAsync.cjs.map +1 -1
  6. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  7. package/dist/cjs/interpreter/getIntlayerAsync.cjs +10 -1
  8. package/dist/cjs/interpreter/getIntlayerAsync.cjs.map +1 -1
  9. package/dist/cjs/interpreter/index.cjs +5 -0
  10. package/dist/cjs/interpreter/resolveInterpreterLocale.cjs +101 -0
  11. package/dist/cjs/interpreter/resolveInterpreterLocale.cjs.map +1 -0
  12. package/dist/cjs/localization/getLocaleFromRequest.cjs +1 -1
  13. package/dist/cjs/localization/resolveBrowserLocale.cjs +1 -1
  14. package/dist/cjs/localization/rewriteMatch.cjs +11 -1
  15. package/dist/cjs/localization/rewriteMatch.cjs.map +1 -1
  16. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  17. package/dist/cjs/markdown/constants.cjs.map +1 -1
  18. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +29 -9
  19. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
  20. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  21. package/dist/cjs/utils/index.cjs +2 -2
  22. package/dist/cjs/utils/intl.cjs.map +1 -1
  23. package/dist/esm/index.mjs +4 -3
  24. package/dist/esm/interpreter/getDictionary.mjs +4 -3
  25. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  26. package/dist/esm/interpreter/getDictionaryAsync.mjs +2 -2
  27. package/dist/esm/interpreter/getDictionaryAsync.mjs.map +1 -1
  28. package/dist/esm/interpreter/getIntlayer.mjs +1 -1
  29. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  30. package/dist/esm/interpreter/getIntlayerAsync.mjs +10 -1
  31. package/dist/esm/interpreter/getIntlayerAsync.mjs.map +1 -1
  32. package/dist/esm/interpreter/index.mjs +2 -1
  33. package/dist/esm/interpreter/resolveInterpreterLocale.mjs +97 -0
  34. package/dist/esm/interpreter/resolveInterpreterLocale.mjs.map +1 -0
  35. package/dist/esm/localization/getLocaleFromRequest.mjs +1 -1
  36. package/dist/esm/localization/resolveBrowserLocale.mjs +1 -1
  37. package/dist/esm/localization/rewriteMatch.mjs +11 -1
  38. package/dist/esm/localization/rewriteMatch.mjs.map +1 -1
  39. package/dist/esm/markdown/compiler.mjs +1 -1
  40. package/dist/esm/markdown/compiler.mjs.map +1 -1
  41. package/dist/esm/markdown/constants.mjs +3 -0
  42. package/dist/esm/markdown/constants.mjs.map +1 -1
  43. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +29 -9
  44. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  45. package/dist/esm/transpiler/markdown/markdown.mjs +1 -1
  46. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  47. package/dist/esm/utils/index.mjs +2 -2
  48. package/dist/esm/utils/intl.mjs +1 -0
  49. package/dist/esm/utils/intl.mjs.map +1 -1
  50. package/dist/types/index.d.ts +2 -1
  51. package/dist/types/interpreter/getIntlayerAsync.d.ts.map +1 -1
  52. package/dist/types/interpreter/index.d.ts +2 -1
  53. package/dist/types/interpreter/resolveInterpreterLocale.d.ts +63 -0
  54. package/dist/types/interpreter/resolveInterpreterLocale.d.ts.map +1 -0
  55. package/dist/types/localization/rewriteMatch.d.ts.map +1 -1
  56. package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts.map +1 -1
  57. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.mjs","names":[],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, MARKDOWN } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<typeof MARKDOWN, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(MARKDOWN, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":";;;;;;;AA8BA,MAAM,eAAe,OAAO,YAAiB;CAC3C,IAAI,OAAO,YAAY,YAAY,OAAO,YAAY,UACpD,OAAO;CAGT,IAAI,OAAO,YAAY,YACrB,OAAO,QAAQ;CAEjB,IAAI,OAAO,QAAQ,SAAS,YAC1B,OAAO,MAAM;AAEjB;;;;;;;;;;;;;AAcA,MAAM,YAIJ,SACA,eACyC;CACzC,MAAM,WAAW,YAAY;EAC3B,MAAM,iBAAiB,MAAM,aAAa,OAAO;EAEjD,MAAM,cAAc,WAAW,gBAAgB;GAC7C,eAAe;GACf,SAAS,CAAC;EACZ,CAAC;EAED,IAAI,OAAO,gBAAgB,UAAU;GACQ;IACzC,MAAM,EAAE,WAAW,iBAAiB,WAAW;IAC/C,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,SAAS,SACjB,QAAQ,MAAM,uBAAuB,MAAM,SAAS;SAEpD,QAAQ,KAAK,uBAAuB,MAAM,SAAS;GAGzD;GAEA,OAAO,oBAAoB,WAAW;EACxC;CACF;CAEA,MAAM,sBAAsB;EAC1B,IAAI,YACF,OAAO;EAGT,IAAI,OAAO,YAAY,UACrB,OAAO,wBAAwB,OAAO;EAGxC,IAAI;EAEJ,IAAI,OAAO,YAAY,YACrB,gBAAgB,QAAQ;OACnB,IAAI,OAAQ,QAA4B,SAAS,YACtD,gBAAgB,YACd,wBAAyB,MAAO,OAAsC;EAG1E,IAAI,OAAO,kBAAkB,UAC3B,OAAO,wBAAwB,aAAa;EAG9C,IAAI;GACF,OAAO,wBAAwB,KAAK,UAAU,OAAO,CAAC;EACxD,SAAS,IAAI;GACX,OAAO,CAAC;EACV;CACF;CAEA,OAAO,eAAe,UAAU,SAAS;EACvC;EACA,MAAM,cAAc;CACtB,CAAC;AACH"}
1
+ {"version":3,"file":"markdown.mjs","names":[],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, MARKDOWN } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<typeof MARKDOWN, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(MARKDOWN, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":";;;;;;;AA8BA,MAAM,eAAe,OAAO,YAAiB;CAC3C,IAAI,OAAO,YAAY,YAAY,OAAO,YAAY,UACpD,OAAO;CAGT,IAAI,OAAO,YAAY,YACrB,OAAO,QAAQ;CAEjB,IAAI,OAAO,QAAQ,SAAS,YAC1B,OAAO,MAAM;AAEjB;;;;;;;;;;;;;AAcA,MAAM,YAIJ,SACA,eACyC;CACzC,MAAM,WAAW,YAAY;EAC3B,MAAM,iBAAiB,MAAM,aAAa,OAAO;EAEjD,MAAM,cAAc,WAAW,gBAAgB;GAC7C,eAAe;GACf,SAAS,CAAC;EACZ,CAAC;EAED,IAAI,OAAO,gBAAgB,UAAU;GACnC,6BAA6B,cAAc;IACzC,MAAM,EAAE,WAAW,iBAAiB,WAAW;IAC/C,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,SAAS,SACjB,QAAQ,MAAM,uBAAuB,MAAM,SAAS;SAEpD,QAAQ,KAAK,uBAAuB,MAAM,SAAS;GAGzD;GAEA,OAAO,oBAAoB,WAAW;EACxC;CACF;CAEA,MAAM,sBAAsB;EAC1B,IAAI,YACF,OAAO;EAGT,IAAI,OAAO,YAAY,UACrB,OAAO,wBAAwB,OAAO;EAGxC,IAAI;EAEJ,IAAI,OAAO,YAAY,YACrB,gBAAgB,QAAQ;OACnB,IAAI,OAAQ,QAA4B,SAAS,YACtD,gBAAgB,YACd,wBAAyB,MAAO,OAAsC;EAG1E,IAAI,OAAO,kBAAkB,UAC3B,OAAO,wBAAwB,aAAa;EAG9C,IAAI;GACF,OAAO,wBAAwB,KAAK,UAAU,OAAO,CAAC;EACxD,SAAS,IAAI;GACX,OAAO,CAAC;EACV;CACF;CAEA,OAAO,eAAe,UAAU,SAAS;EACvC;EACA,MAAM,cAAc;CACtB,CAAC;AACH"}
@@ -1,9 +1,9 @@
1
+ import { getCookie } from "./getCookie.mjs";
2
+ import { LocaleStorage, LocaleStorageClient, LocaleStorageServer, getCachedLocaleFromStorageClient, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, localeStorageOptions, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer } from "./localeStorage.mjs";
1
3
  import { CachedIntl, bindIntl, getCachedIntl } from "./intl.mjs";
2
4
  import { parseYaml } from "./parseYaml.mjs";
3
5
  import { isValidElement } from "./isValidReactElement.mjs";
4
6
  import { checkIsURLAbsolute } from "./checkIsURLAbsolute.mjs";
5
- import { getCookie } from "./getCookie.mjs";
6
- import { LocaleStorage, LocaleStorageClient, LocaleStorageServer, getCachedLocaleFromStorageClient, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, localeStorageOptions, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer } from "./localeStorage.mjs";
7
7
  import { getIntlayerNodePrototype } from "./intlayerNodePrototype.mjs";
8
8
  import { isSameKeyPath } from "./isSameKeyPath.mjs";
9
9
  import { stringifyYaml } from "./stringifyYaml.mjs";
@@ -33,6 +33,7 @@ const alreadyWarnedConstructors = /* @__PURE__ */ new Set();
33
33
  * Warns once per missing `Intl` constructor, in development only.
34
34
  */
35
35
  const warnMissingIntlConstructor = (constructorName) => {
36
+ if (process.env.NODE_ENV === "production") return;
36
37
  if (alreadyWarnedConstructors.has(constructorName)) return;
37
38
  alreadyWarnedConstructors.add(constructorName);
38
39
  console.warn(`[intlayer] \`Intl.${constructorName}\` is not available in this JavaScript engine. A degraded fallback is used instead. On React Native, load a polyfill (e.g. \`@formatjs/intl-${constructorName.toLowerCase()}/polyfill\`) before rendering your app.`);
@@ -1 +1 @@
1
- {"version":3,"file":"intl.mjs","names":[],"sources":["../../../src/utils/intl.ts"],"sourcesContent":["/**\n * Cached Intl helper – drop‑in replacement for the global `Intl` object.\n * ‑‑‑\n * • Uses a `Proxy` to lazily wrap every *constructor* hanging off `Intl` (NumberFormat, DateTimeFormat, …).\n * • Each wrapped constructor keeps an in‑memory cache keyed by `[locales, options]` so that identical requests\n * reuse the same heavy instance instead of reparsing CLDR data every time.\n * • A polyfill warning for `Intl.DisplayNames` is emitted only once and only in dev.\n * • The public API is fully type‑safe and mirrors the native `Intl` surface exactly –\n * you can treat `CachedIntl` just like the built‑in `Intl`.\n *\n * Usage @example:\n * ---------------\n * ```ts\n * import { CachedIntl } from \"./cached-intl\";\n *\n * const nf = CachedIntl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\" });\n * console.log(nf.format(1234));\n *\n * const dn = CachedIntl.DisplayNames([\"fr\"], { type: \"language\" });\n * console.log(dn.of(\"en\")); * → \"anglais\"\n *\n * You can also spin up an isolated instance with its own caches (handy in test suites):\n * const TestIntl = createCachedIntl();\n * ```\n */\n\nimport { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nconst MAX_CACHE_SIZE = 50;\nconst cache = new Map<any, Map<string, any>>();\n\n/**\n * Minimal `Intl.ListFormat` surface, declared locally so consumers do not need\n * the `ES2021.Intl` lib in their tsconfig.\n */\ntype ListFormatInstance = {\n format(list: Iterable<string>): string;\n formatToParts(\n list: Iterable<string>\n ): { type: 'element' | 'literal'; value: string }[];\n};\n\n/**\n * Minimal `Intl.Segmenter` surface, declared locally so consumers do not need\n * the `ES2022.Intl` lib in their tsconfig.\n */\ntype SegmenterInstance = {\n segment(input: string): Iterable<{ segment: string; index: number }>;\n};\n\n/**\n * Instance type produced by each `Intl` constructor this module can build.\n */\ntype IntlInstanceByName = {\n Collator: Intl.Collator;\n DateTimeFormat: Intl.DateTimeFormat;\n DisplayNames: Intl.DisplayNames;\n ListFormat: ListFormatInstance;\n Locale: Intl.Locale;\n NumberFormat: Intl.NumberFormat;\n PluralRules: Intl.PluralRules;\n RelativeTimeFormat: Intl.RelativeTimeFormat;\n Segmenter: SegmenterInstance;\n};\n\n/**\n * Names of the `Intl` constructors this module knows how to instantiate.\n */\nexport type IntlConstructorName = keyof IntlInstanceByName;\n\nconst alreadyWarnedConstructors = new Set<string>();\n\n/**\n * Warns once per missing `Intl` constructor, in development only.\n */\nconst warnMissingIntlConstructor = (constructorName: string): void => {\n if (process.env.NODE_ENV === 'production') return;\n if (alreadyWarnedConstructors.has(constructorName)) return;\n\n alreadyWarnedConstructors.add(constructorName);\n\n console.warn(\n `[intlayer] \\`Intl.${constructorName}\\` is not available in this JavaScript engine. ` +\n `A degraded fallback is used instead. ` +\n `On React Native, load a polyfill (e.g. \\`@formatjs/intl-${constructorName.toLowerCase()}/polyfill\\`) before rendering your app.`\n );\n};\n\n/**\n * Minimal stand-ins used when the engine ships without the matching `Intl`\n * constructor. Hermes — the default React Native engine — omits\n * `DisplayNames`, `ListFormat` and `Segmenter` in release builds unless the\n * app opts into the full ICU build or loads a polyfill. Without these shims,\n * `new Intl.DisplayNames(...)` throws\n * `TypeError: undefined cannot be used as a constructor` and takes the whole\n * app down at render time.\n *\n * Each shim mirrors only the surface Intlayer relies on, and returns the\n * un-localized input so rendering degrades rather than crashing.\n */\nconst intlConstructorFallbacks: Partial<\n Record<IntlConstructorName, new (locale?: any, options?: any) => any>\n> = {\n DisplayNames: class DisplayNamesFallback {\n /** Returns the requested code unchanged, since no CLDR data is available. */\n public of(code: string): string {\n return code;\n }\n },\n ListFormat: class ListFormatFallback {\n /** Joins the list with a comma, the most neutral separator available. */\n public format(list: Iterable<string>): string {\n return Array.from(list).join(', ');\n }\n\n /** Mirrors `Intl.ListFormat.prototype.formatToParts` shape. */\n public formatToParts(\n list: Iterable<string>\n ): { type: 'element' | 'literal'; value: string }[] {\n return Array.from(list).flatMap((value, index) =>\n index === 0\n ? [{ type: 'element' as const, value }]\n : [\n { type: 'literal' as const, value: ', ' },\n { type: 'element' as const, value },\n ]\n );\n }\n },\n Segmenter: class SegmenterFallback {\n /** Segments by code point, the closest approximation without ICU data. */\n public segment(input: string): { segment: string; index: number }[] {\n let index = 0;\n\n return Array.from(input).map((segment) => {\n const segmentStart = index;\n index += segment.length;\n\n return { segment, index: segmentStart };\n });\n }\n },\n};\n\n/**\n * Resolves an `Intl` constructor by name at call time, falling back to a\n * degraded shim when the engine does not provide it.\n *\n * Resolution is deliberately lazy: React Native apps install their polyfills\n * at startup, which may run after this module is first imported.\n */\nconst resolveIntlConstructor = (\n constructorName: IntlConstructorName\n): (new (locale?: any, options?: any) => any) | undefined => {\n const nativeConstructor = (\n Intl as unknown as Record<string, new (...args: any[]) => any>\n )[constructorName];\n\n if (typeof nativeConstructor === 'function') return nativeConstructor;\n\n warnMissingIntlConstructor(constructorName);\n\n return intlConstructorFallbacks[constructorName];\n};\n\ntype IntlConstructors = {\n [K in keyof typeof Intl as (typeof Intl)[K] extends new (\n ...args: any\n ) => any\n ? K\n : never]: (typeof Intl)[K];\n};\n\ntype ReplaceLocaleWithLocalesValues<T> = T extends new (\n locales: any,\n options?: infer Options\n) => infer Instance\n ? {\n new (locales?: LocalesValues, options?: Options): Instance;\n new (options?: Options & { locale?: LocalesValues }): Instance;\n (locales?: LocalesValues, options?: Options): Instance;\n (options?: Options & { locale?: LocalesValues }): Instance;\n }\n : T extends new (\n locales: any\n ) => infer Instance\n ? {\n new (locales?: LocalesValues): Instance;\n new (options?: { locale?: LocalesValues }): Instance;\n (locales?: LocalesValues): Instance;\n (options?: { locale?: LocalesValues }): Instance;\n }\n : T;\n\nexport type WrappedIntl = {\n [K in keyof typeof Intl]: K extends keyof IntlConstructors\n ? ReplaceLocaleWithLocalesValues<(typeof Intl)[K]>\n : (typeof Intl)[K];\n};\n\n/**\n * Generic caching instantiator for Intl constructors.\n *\n * Prefer passing the constructor *name* (e.g. `'DisplayNames'`) rather than the\n * constructor itself: the name is resolved lazily against the global `Intl`, so\n * late-installed polyfills are picked up and missing constructors degrade to a\n * fallback instead of throwing.\n */\nexport function getCachedIntl<Name extends IntlConstructorName>(\n constructorName: Name,\n locale?: LocalesValues | string,\n options?: any\n): IntlInstanceByName[Name];\nexport function getCachedIntl<T extends new (...args: any[]) => any>(\n Ctor: T,\n locale?: LocalesValues | string,\n options?: any\n): InstanceType<T>;\nexport function getCachedIntl(\n intlConstructor: IntlConstructorName | (new (...args: any[]) => any),\n locale?: LocalesValues | string,\n options?: any\n): any {\n const resLoc = locale ?? internationalization?.defaultLocale;\n\n const optKey = options ? JSON.stringify(options) : '';\n const key = `${resLoc}|${optKey}`;\n\n // Cache per name when available, so two constructors that are both missing\n // from the engine do not collide on a single `undefined` cache bucket.\n const cacheKey = intlConstructor;\n\n let ctorCache = cache.get(cacheKey);\n\n if (!ctorCache) {\n ctorCache = new Map();\n cache.set(cacheKey, ctorCache);\n }\n\n let instance = ctorCache.get(key);\n\n if (!instance) {\n const ResolvedConstructor =\n typeof intlConstructor === 'string'\n ? resolveIntlConstructor(intlConstructor)\n : intlConstructor;\n\n if (typeof ResolvedConstructor !== 'function') {\n throw new Error(\n `[intlayer] \\`Intl.${String(intlConstructor)}\\` is not available in this JavaScript engine and has no fallback. ` +\n `Load the matching polyfill before formatting.`\n );\n }\n\n if (ctorCache.size > MAX_CACHE_SIZE) ctorCache.clear();\n instance = new ResolvedConstructor(resLoc, options);\n ctorCache.set(key, instance);\n }\n return instance;\n}\n\n/**\n * Optional: Keep bindIntl if your library exports it publicly.\n * It now uses the much smaller getCachedIntl under the hood.\n */\nexport const bindIntl = (boundLocale: LocalesValues): WrappedIntl => {\n const bindWrap = (constructorName: IntlConstructorName) =>\n // function is used as a constructor, do not change in arrow function\n function intlConstructor(locales?: any, options?: any) {\n const isOptsFirst =\n locales !== null &&\n typeof locales === 'object' &&\n !Array.isArray(locales);\n const resOpts = isOptsFirst ? locales : options;\n const resLoc = isOptsFirst\n ? (resOpts as any).locale || boundLocale\n : locales || boundLocale;\n\n return getCachedIntl(constructorName, resLoc, resOpts);\n };\n\n return {\n ...Intl,\n Collator: bindWrap('Collator'),\n DateTimeFormat: bindWrap('DateTimeFormat'),\n DisplayNames: bindWrap('DisplayNames'),\n ListFormat: bindWrap('ListFormat'),\n NumberFormat: bindWrap('NumberFormat'),\n PluralRules: bindWrap('PluralRules'),\n RelativeTimeFormat: bindWrap('RelativeTimeFormat'),\n Locale: bindWrap('Locale'),\n Segmenter: bindWrap('Segmenter'),\n } as unknown as WrappedIntl;\n};\n\n// Add this to the bottom of utils/intl.ts ONLY if required for public API compatibility.\nexport const CachedIntl = {\n // function is used as a constructor, do not change in arrow function\n Collator: function Collator(locales?: any, options?: any) {\n return getCachedIntl('Collator', locales, options);\n },\n DateTimeFormat: function DateTimeFormat(locales?: any, options?: any) {\n return getCachedIntl('DateTimeFormat', locales, options);\n },\n DisplayNames: function DisplayNames(locales?: any, options?: any) {\n return getCachedIntl('DisplayNames', locales, options);\n },\n ListFormat: function ListFormat(locales?: any, options?: any) {\n return getCachedIntl('ListFormat', locales, options);\n },\n NumberFormat: function NumberFormat(locales?: any, options?: any) {\n return getCachedIntl('NumberFormat', locales, options);\n },\n PluralRules: function PluralRules(locales?: any, options?: any) {\n return getCachedIntl('PluralRules', locales, options);\n },\n RelativeTimeFormat: function RelativeTimeFormat(\n locales?: any,\n options?: any\n ) {\n return getCachedIntl('RelativeTimeFormat', locales, options);\n },\n Segmenter: function Segmenter(locales?: any, options?: any) {\n return getCachedIntl('Segmenter', locales, options);\n },\n} as any; // Cast to 'any' internally to avoid TS readonly errors\n\nexport { CachedIntl as Intl };\n"],"mappings":"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"}
1
+ {"version":3,"file":"intl.mjs","names":[],"sources":["../../../src/utils/intl.ts"],"sourcesContent":["/**\n * Cached Intl helper – drop‑in replacement for the global `Intl` object.\n * ‑‑‑\n * • Uses a `Proxy` to lazily wrap every *constructor* hanging off `Intl` (NumberFormat, DateTimeFormat, …).\n * • Each wrapped constructor keeps an in‑memory cache keyed by `[locales, options]` so that identical requests\n * reuse the same heavy instance instead of reparsing CLDR data every time.\n * • A polyfill warning for `Intl.DisplayNames` is emitted only once and only in dev.\n * • The public API is fully type‑safe and mirrors the native `Intl` surface exactly –\n * you can treat `CachedIntl` just like the built‑in `Intl`.\n *\n * Usage @example:\n * ---------------\n * ```ts\n * import { CachedIntl } from \"./cached-intl\";\n *\n * const nf = CachedIntl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\" });\n * console.log(nf.format(1234));\n *\n * const dn = CachedIntl.DisplayNames([\"fr\"], { type: \"language\" });\n * console.log(dn.of(\"en\")); * → \"anglais\"\n *\n * You can also spin up an isolated instance with its own caches (handy in test suites):\n * const TestIntl = createCachedIntl();\n * ```\n */\n\nimport { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nconst MAX_CACHE_SIZE = 50;\nconst cache = new Map<any, Map<string, any>>();\n\n/**\n * Minimal `Intl.ListFormat` surface, declared locally so consumers do not need\n * the `ES2021.Intl` lib in their tsconfig.\n */\ntype ListFormatInstance = {\n format(list: Iterable<string>): string;\n formatToParts(\n list: Iterable<string>\n ): { type: 'element' | 'literal'; value: string }[];\n};\n\n/**\n * Minimal `Intl.Segmenter` surface, declared locally so consumers do not need\n * the `ES2022.Intl` lib in their tsconfig.\n */\ntype SegmenterInstance = {\n segment(input: string): Iterable<{ segment: string; index: number }>;\n};\n\n/**\n * Instance type produced by each `Intl` constructor this module can build.\n */\ntype IntlInstanceByName = {\n Collator: Intl.Collator;\n DateTimeFormat: Intl.DateTimeFormat;\n DisplayNames: Intl.DisplayNames;\n ListFormat: ListFormatInstance;\n Locale: Intl.Locale;\n NumberFormat: Intl.NumberFormat;\n PluralRules: Intl.PluralRules;\n RelativeTimeFormat: Intl.RelativeTimeFormat;\n Segmenter: SegmenterInstance;\n};\n\n/**\n * Names of the `Intl` constructors this module knows how to instantiate.\n */\nexport type IntlConstructorName = keyof IntlInstanceByName;\n\nconst alreadyWarnedConstructors = new Set<string>();\n\n/**\n * Warns once per missing `Intl` constructor, in development only.\n */\nconst warnMissingIntlConstructor = (constructorName: string): void => {\n if (process.env.NODE_ENV === 'production') return;\n if (alreadyWarnedConstructors.has(constructorName)) return;\n\n alreadyWarnedConstructors.add(constructorName);\n\n console.warn(\n `[intlayer] \\`Intl.${constructorName}\\` is not available in this JavaScript engine. ` +\n `A degraded fallback is used instead. ` +\n `On React Native, load a polyfill (e.g. \\`@formatjs/intl-${constructorName.toLowerCase()}/polyfill\\`) before rendering your app.`\n );\n};\n\n/**\n * Minimal stand-ins used when the engine ships without the matching `Intl`\n * constructor. Hermes — the default React Native engine — omits\n * `DisplayNames`, `ListFormat` and `Segmenter` in release builds unless the\n * app opts into the full ICU build or loads a polyfill. Without these shims,\n * `new Intl.DisplayNames(...)` throws\n * `TypeError: undefined cannot be used as a constructor` and takes the whole\n * app down at render time.\n *\n * Each shim mirrors only the surface Intlayer relies on, and returns the\n * un-localized input so rendering degrades rather than crashing.\n */\nconst intlConstructorFallbacks: Partial<\n Record<IntlConstructorName, new (locale?: any, options?: any) => any>\n> = {\n DisplayNames: class DisplayNamesFallback {\n /** Returns the requested code unchanged, since no CLDR data is available. */\n public of(code: string): string {\n return code;\n }\n },\n ListFormat: class ListFormatFallback {\n /** Joins the list with a comma, the most neutral separator available. */\n public format(list: Iterable<string>): string {\n return Array.from(list).join(', ');\n }\n\n /** Mirrors `Intl.ListFormat.prototype.formatToParts` shape. */\n public formatToParts(\n list: Iterable<string>\n ): { type: 'element' | 'literal'; value: string }[] {\n return Array.from(list).flatMap((value, index) =>\n index === 0\n ? [{ type: 'element' as const, value }]\n : [\n { type: 'literal' as const, value: ', ' },\n { type: 'element' as const, value },\n ]\n );\n }\n },\n Segmenter: class SegmenterFallback {\n /** Segments by code point, the closest approximation without ICU data. */\n public segment(input: string): { segment: string; index: number }[] {\n let index = 0;\n\n return Array.from(input).map((segment) => {\n const segmentStart = index;\n index += segment.length;\n\n return { segment, index: segmentStart };\n });\n }\n },\n};\n\n/**\n * Resolves an `Intl` constructor by name at call time, falling back to a\n * degraded shim when the engine does not provide it.\n *\n * Resolution is deliberately lazy: React Native apps install their polyfills\n * at startup, which may run after this module is first imported.\n */\nconst resolveIntlConstructor = (\n constructorName: IntlConstructorName\n): (new (locale?: any, options?: any) => any) | undefined => {\n const nativeConstructor = (\n Intl as unknown as Record<string, new (...args: any[]) => any>\n )[constructorName];\n\n if (typeof nativeConstructor === 'function') return nativeConstructor;\n\n warnMissingIntlConstructor(constructorName);\n\n return intlConstructorFallbacks[constructorName];\n};\n\ntype IntlConstructors = {\n [K in keyof typeof Intl as (typeof Intl)[K] extends new (\n ...args: any\n ) => any\n ? K\n : never]: (typeof Intl)[K];\n};\n\ntype ReplaceLocaleWithLocalesValues<T> = T extends new (\n locales: any,\n options?: infer Options\n) => infer Instance\n ? {\n new (locales?: LocalesValues, options?: Options): Instance;\n new (options?: Options & { locale?: LocalesValues }): Instance;\n (locales?: LocalesValues, options?: Options): Instance;\n (options?: Options & { locale?: LocalesValues }): Instance;\n }\n : T extends new (\n locales: any\n ) => infer Instance\n ? {\n new (locales?: LocalesValues): Instance;\n new (options?: { locale?: LocalesValues }): Instance;\n (locales?: LocalesValues): Instance;\n (options?: { locale?: LocalesValues }): Instance;\n }\n : T;\n\nexport type WrappedIntl = {\n [K in keyof typeof Intl]: K extends keyof IntlConstructors\n ? ReplaceLocaleWithLocalesValues<(typeof Intl)[K]>\n : (typeof Intl)[K];\n};\n\n/**\n * Generic caching instantiator for Intl constructors.\n *\n * Prefer passing the constructor *name* (e.g. `'DisplayNames'`) rather than the\n * constructor itself: the name is resolved lazily against the global `Intl`, so\n * late-installed polyfills are picked up and missing constructors degrade to a\n * fallback instead of throwing.\n */\nexport function getCachedIntl<Name extends IntlConstructorName>(\n constructorName: Name,\n locale?: LocalesValues | string,\n options?: any\n): IntlInstanceByName[Name];\nexport function getCachedIntl<T extends new (...args: any[]) => any>(\n Ctor: T,\n locale?: LocalesValues | string,\n options?: any\n): InstanceType<T>;\nexport function getCachedIntl(\n intlConstructor: IntlConstructorName | (new (...args: any[]) => any),\n locale?: LocalesValues | string,\n options?: any\n): any {\n const resLoc = locale ?? internationalization?.defaultLocale;\n\n const optKey = options ? JSON.stringify(options) : '';\n const key = `${resLoc}|${optKey}`;\n\n // Cache per name when available, so two constructors that are both missing\n // from the engine do not collide on a single `undefined` cache bucket.\n const cacheKey = intlConstructor;\n\n let ctorCache = cache.get(cacheKey);\n\n if (!ctorCache) {\n ctorCache = new Map();\n cache.set(cacheKey, ctorCache);\n }\n\n let instance = ctorCache.get(key);\n\n if (!instance) {\n const ResolvedConstructor =\n typeof intlConstructor === 'string'\n ? resolveIntlConstructor(intlConstructor)\n : intlConstructor;\n\n if (typeof ResolvedConstructor !== 'function') {\n throw new Error(\n `[intlayer] \\`Intl.${String(intlConstructor)}\\` is not available in this JavaScript engine and has no fallback. ` +\n `Load the matching polyfill before formatting.`\n );\n }\n\n if (ctorCache.size > MAX_CACHE_SIZE) ctorCache.clear();\n instance = new ResolvedConstructor(resLoc, options);\n ctorCache.set(key, instance);\n }\n return instance;\n}\n\n/**\n * Optional: Keep bindIntl if your library exports it publicly.\n * It now uses the much smaller getCachedIntl under the hood.\n */\nexport const bindIntl = (boundLocale: LocalesValues): WrappedIntl => {\n const bindWrap = (constructorName: IntlConstructorName) =>\n // function is used as a constructor, do not change in arrow function\n function intlConstructor(locales?: any, options?: any) {\n const isOptsFirst =\n locales !== null &&\n typeof locales === 'object' &&\n !Array.isArray(locales);\n const resOpts = isOptsFirst ? locales : options;\n const resLoc = isOptsFirst\n ? (resOpts as any).locale || boundLocale\n : locales || boundLocale;\n\n return getCachedIntl(constructorName, resLoc, resOpts);\n };\n\n return {\n ...Intl,\n Collator: bindWrap('Collator'),\n DateTimeFormat: bindWrap('DateTimeFormat'),\n DisplayNames: bindWrap('DisplayNames'),\n ListFormat: bindWrap('ListFormat'),\n NumberFormat: bindWrap('NumberFormat'),\n PluralRules: bindWrap('PluralRules'),\n RelativeTimeFormat: bindWrap('RelativeTimeFormat'),\n Locale: bindWrap('Locale'),\n Segmenter: bindWrap('Segmenter'),\n } as unknown as WrappedIntl;\n};\n\n// Add this to the bottom of utils/intl.ts ONLY if required for public API compatibility.\nexport const CachedIntl = {\n // function is used as a constructor, do not change in arrow function\n Collator: function Collator(locales?: any, options?: any) {\n return getCachedIntl('Collator', locales, options);\n },\n DateTimeFormat: function DateTimeFormat(locales?: any, options?: any) {\n return getCachedIntl('DateTimeFormat', locales, options);\n },\n DisplayNames: function DisplayNames(locales?: any, options?: any) {\n return getCachedIntl('DisplayNames', locales, options);\n },\n ListFormat: function ListFormat(locales?: any, options?: any) {\n return getCachedIntl('ListFormat', locales, options);\n },\n NumberFormat: function NumberFormat(locales?: any, options?: any) {\n return getCachedIntl('NumberFormat', locales, options);\n },\n PluralRules: function PluralRules(locales?: any, options?: any) {\n return getCachedIntl('PluralRules', locales, options);\n },\n RelativeTimeFormat: function RelativeTimeFormat(\n locales?: any,\n options?: any\n ) {\n return getCachedIntl('RelativeTimeFormat', locales, options);\n },\n Segmenter: function Segmenter(locales?: any, options?: any) {\n return getCachedIntl('Segmenter', locales, options);\n },\n} as any; // Cast to 'any' internally to avoid TS readonly errors\n\nexport { CachedIntl as Intl };\n"],"mappings":"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"}
@@ -36,6 +36,7 @@ import { getPlural } from "./interpreter/getPlural.js";
36
36
  import { getSelect } from "./interpreter/getSelect.js";
37
37
  import { getTranslation } from "./interpreter/getTranslation.js";
38
38
  import { InterpolableNode, getInterpolableContent, isInterpolableWrapperNode, rebuildInterpolableContent, transformInterpolableNode } from "./interpreter/interpolableNode.js";
39
+ import { AmbientLocaleResolver, AsyncAmbientLocaleResolver, registerAmbientLocaleResolver, registerAsyncAmbientLocaleResolver, resolveInterpreterLocale, resolveInterpreterLocaleAsync } from "./interpreter/resolveInterpreterLocale.js";
39
40
  import { splitInsertionTemplate } from "./interpreter/splitAndJoinInsertion.js";
40
41
  import "./interpreter/index.js";
41
42
  import { filterMissingTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary } from "./deepTransformPlugins/getFilterMissingTranslationsContent.js";
@@ -125,4 +126,4 @@ import { CookieBuildAttributes, LocaleStorage, LocaleStorageClient, LocaleStorag
125
126
  import { YamlRecord, YamlValue, parseYaml } from "./utils/parseYaml.js";
126
127
  import { stringifyYaml } from "./utils/stringifyYaml.js";
127
128
  import "./utils/index.js";
128
- export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_NAME_START_R, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, type BlockQuoteNode, BlockSyntaxProbe, type BoldTextNode, type BreakLineNode, type BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, COMPOSITE_ID_SEPARATOR, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CachedIntl, CachedIntl as Intl, type CodeBlockNode, type CodeFencedNode, type CodeInlineNode, type CompileOptions, type ComponentOverrides, ConditionCond, ConditionContent, ConditionContentStates, CookieBuildAttributes, type CustomComponentNode, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, DateTimePreset, DeepTransformContent, DotPath, DynamicDictionaryLoader, type ElementType, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, type EscapedTextNode, FENCE_DELIMITER_R, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FileCond, type FileContent, type FileContentConstructor, type FootnoteNode, type FootnoteReferenceNode, type GFMTaskNode, GFM_TASK_R, Gender, GenderCond, GenderContent, GenderContentStates, type GenerateSitemapOptions, GetNestingResult, type GetPrefixOptions, type GetPrefixResult, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, type HTMLCommentNode, HTMLContent, HTMLContentConstructor, type HTMLNode, type HTMLSelfClosingNode, type HTMLTag, HTMLTagsType, HTMLValidationIssue, HTMLValidationResult, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_TAGS, type HeadingNode, type HeadingSetextNode, IInterpreterPlugin, IInterpreterPluginState, INLINE_SKIP_R, INTERPOLATION_R, type ImageNode, InsertionCond, InsertionContent, InsertionContentConstructor, InterpolableNode, IntlConstructorName, IsAny, type ItalicTextNode, JsonValue, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LOOKAHEAD, type LinkAngleBraceNode, type LinkBareURLNode, type LinkNode, ListFormatOptions, ListType, type LocaleDomainMap, type LocaleRequest, LocaleStorage, LocaleStorageClient, LocaleStorageClientOptions, LocaleStorageOptions, LocaleStorageServer, LocaleStorageServerOptions, type LocalizedPathResult, MarkdownContent, MarkdownContentConstructor, type MarkdownContext, type MarkdownOptions, MarkdownReferences, type MarkdownRuntime, type HTMLValidationIssue as MarkdownValidationIssue, MarkdownValidationResult, type MarkedTextNode, MessageFormatDialect, MessageFormatter, MessageResolver, MessageValues, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedCond, NestedContent, NestedContentState, NestedFieldReferences, type NestedParser, type NewlineNode, NodeProps, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, type OrderedListNode, PARAGRAPH_R, PRELOADED_DYNAMIC_KEY, type ParagraphNode, type ParseState, ParsedMarkdown, type Parser, type ParserResult, PlainDynamicLoaderMap, Plugins, PluralCategory, PluralCond, PluralContent, PluralContentState, PortableObject, PreloadableDynamicLoaderMap, PreloadedDynamicEntry, Priority, PriorityValue, type ProxyMode, type ProxyStorageSuppressionPurpose, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, type ReferenceImageNode, type ReferenceLinkNode, type ReferenceNode, type RenderRuleHook, ResolvedDynamicLoader, type Rule, type RuleOutput, RuleScope, RuleScopeValue, RuleType, RuleTypeValue, type Rules, SCOPE_BLOCK, SCOPE_BOTH, SCOPE_INLINE, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, SelectCond, SelectContent, SelectContentStates, SelectSelector, type SitemapUrlEntry, type StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, type TableNode, type TableSeparatorNode, TaggedMessageToken, type TextNode, TranslationCond, TranslationContent, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnionKeys, type UnorderedListNode, VOID_HTML_ELEMENTS, ValidDotPathsFor, ValueAtKey, WrappedIntl, YamlRecord, YamlValue, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindInsertedValues, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createCompiler, createMessageResolver, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, type file, type fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, findPlainDynamicLoader, formatProxyEnabledMessage, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCachedLocaleFromStorageClient, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryAsync, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDictionaryTransformCacheKey, getDomainHostname, getDomainOrigin, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getIntlayerAsync, getIntlayerNodePrototype, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromRequest, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNestedDictionaryGraph, getNestedDictionaryKeys, getNestedDictionaryReferences, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPluginsCacheKey, getPlural, getPrefix, getPreloadLocale, getPreloadedDictionary, getReplacedValuesContent, getRewritePath, getRewriteRules, getRuleSet, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, isDeclaredLocale, isInterpolableWrapperNode, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, isQualifiedDictionaryGroup, isQualifiedDynamicLoaderMap, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, mergeQualifiedDictionaries, navigatePath, nesting as nest, nestedPlugin, normalizeAttributeKey, normalizeDictionaries, normalizeDictionary, normalizePath, normalizeWhitespace, number, orderDictionaries, parseBlock, parseCaptureInline, parseDictionarySelector, parseInline, parseMarkdown, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parseTaggedMessage, parseYaml, parserFor, percentage, plural, pluralPlugin, portableObjectToIntlayerFormatter, presets, qualifies, readTransformCache, rebuildInterpolableContent, reconstructQualifiedEntry, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveBrowserLocale, resolveDictionaryArgument, resolveEffectiveVariantId, resolveInsertedSelector, resolveLocalizedPath, resolveMessage, resolveMessageNode, resolveMessageNodeToString, resolvePlainDynamicLoader, resolveProviderVariant, resolveProxyMode, resolveQualifiedDictionary, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync, sanitizer, select, selectPlugin, serializeVariant, serializeVariantChain, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer, simpleInlineRegex, slugify, some, splitInsertionTemplate, startsWith, stringifyYaml, translation as t, transformInterpolableNode, translationPlugin, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, units, unquote, updateNodeChildren, validateHTML, validateMarkdown, validatePrefix, vueI18nToIntlayerFormatter, writeTransformCache };
129
+ export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_NAME_START_R, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, AmbientLocaleResolver, AsyncAmbientLocaleResolver, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, type BlockQuoteNode, BlockSyntaxProbe, type BoldTextNode, type BreakLineNode, type BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, COMPOSITE_ID_SEPARATOR, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CachedIntl, CachedIntl as Intl, type CodeBlockNode, type CodeFencedNode, type CodeInlineNode, type CompileOptions, type ComponentOverrides, ConditionCond, ConditionContent, ConditionContentStates, CookieBuildAttributes, type CustomComponentNode, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, DateTimePreset, DeepTransformContent, DotPath, DynamicDictionaryLoader, type ElementType, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, type EscapedTextNode, FENCE_DELIMITER_R, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FileCond, type FileContent, type FileContentConstructor, type FootnoteNode, type FootnoteReferenceNode, type GFMTaskNode, GFM_TASK_R, Gender, GenderCond, GenderContent, GenderContentStates, type GenerateSitemapOptions, GetNestingResult, type GetPrefixOptions, type GetPrefixResult, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, type HTMLCommentNode, HTMLContent, HTMLContentConstructor, type HTMLNode, type HTMLSelfClosingNode, type HTMLTag, HTMLTagsType, HTMLValidationIssue, HTMLValidationResult, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_TAGS, type HeadingNode, type HeadingSetextNode, IInterpreterPlugin, IInterpreterPluginState, INLINE_SKIP_R, INTERPOLATION_R, type ImageNode, InsertionCond, InsertionContent, InsertionContentConstructor, InterpolableNode, IntlConstructorName, IsAny, type ItalicTextNode, JsonValue, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LOOKAHEAD, type LinkAngleBraceNode, type LinkBareURLNode, type LinkNode, ListFormatOptions, ListType, type LocaleDomainMap, type LocaleRequest, LocaleStorage, LocaleStorageClient, LocaleStorageClientOptions, LocaleStorageOptions, LocaleStorageServer, LocaleStorageServerOptions, type LocalizedPathResult, MarkdownContent, MarkdownContentConstructor, type MarkdownContext, type MarkdownOptions, MarkdownReferences, type MarkdownRuntime, type HTMLValidationIssue as MarkdownValidationIssue, MarkdownValidationResult, type MarkedTextNode, MessageFormatDialect, MessageFormatter, MessageResolver, MessageValues, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedCond, NestedContent, NestedContentState, NestedFieldReferences, type NestedParser, type NewlineNode, NodeProps, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, type OrderedListNode, PARAGRAPH_R, PRELOADED_DYNAMIC_KEY, type ParagraphNode, type ParseState, ParsedMarkdown, type Parser, type ParserResult, PlainDynamicLoaderMap, Plugins, PluralCategory, PluralCond, PluralContent, PluralContentState, PortableObject, PreloadableDynamicLoaderMap, PreloadedDynamicEntry, Priority, PriorityValue, type ProxyMode, type ProxyStorageSuppressionPurpose, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, type ReferenceImageNode, type ReferenceLinkNode, type ReferenceNode, type RenderRuleHook, ResolvedDynamicLoader, type Rule, type RuleOutput, RuleScope, RuleScopeValue, RuleType, RuleTypeValue, type Rules, SCOPE_BLOCK, SCOPE_BOTH, SCOPE_INLINE, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, SelectCond, SelectContent, SelectContentStates, SelectSelector, type SitemapUrlEntry, type StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, type TableNode, type TableSeparatorNode, TaggedMessageToken, type TextNode, TranslationCond, TranslationContent, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnionKeys, type UnorderedListNode, VOID_HTML_ELEMENTS, ValidDotPathsFor, ValueAtKey, WrappedIntl, YamlRecord, YamlValue, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindInsertedValues, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createCompiler, createMessageResolver, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, type file, type fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, findPlainDynamicLoader, formatProxyEnabledMessage, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCachedLocaleFromStorageClient, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryAsync, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDictionaryTransformCacheKey, getDomainHostname, getDomainOrigin, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getIntlayerAsync, getIntlayerNodePrototype, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromRequest, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNestedDictionaryGraph, getNestedDictionaryKeys, getNestedDictionaryReferences, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPluginsCacheKey, getPlural, getPrefix, getPreloadLocale, getPreloadedDictionary, getReplacedValuesContent, getRewritePath, getRewriteRules, getRuleSet, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, isDeclaredLocale, isInterpolableWrapperNode, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, isQualifiedDictionaryGroup, isQualifiedDynamicLoaderMap, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, mergeQualifiedDictionaries, navigatePath, nesting as nest, nestedPlugin, normalizeAttributeKey, normalizeDictionaries, normalizeDictionary, normalizePath, normalizeWhitespace, number, orderDictionaries, parseBlock, parseCaptureInline, parseDictionarySelector, parseInline, parseMarkdown, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parseTaggedMessage, parseYaml, parserFor, percentage, plural, pluralPlugin, portableObjectToIntlayerFormatter, presets, qualifies, readTransformCache, rebuildInterpolableContent, reconstructQualifiedEntry, registerAmbientLocaleResolver, registerAsyncAmbientLocaleResolver, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveBrowserLocale, resolveDictionaryArgument, resolveEffectiveVariantId, resolveInsertedSelector, resolveInterpreterLocale, resolveInterpreterLocaleAsync, resolveLocalizedPath, resolveMessage, resolveMessageNode, resolveMessageNodeToString, resolvePlainDynamicLoader, resolveProviderVariant, resolveProxyMode, resolveQualifiedDictionary, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync, sanitizer, select, selectPlugin, serializeVariant, serializeVariantChain, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer, simpleInlineRegex, slugify, some, splitInsertionTemplate, startsWith, stringifyYaml, translation as t, transformInterpolableNode, translationPlugin, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, units, unquote, updateNodeChildren, validateHTML, validateMarkdown, validatePrefix, vueI18nToIntlayerFormatter, writeTransformCache };
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayerAsync.d.ts","names":[],"sources":["../../../src/interpreter/getIntlayerAsync.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA0Ca,yBACL,UAAU,sBACV,UAAU,gBAAgB,qBAAqB,iBAAe,KAE/D,GAAC,mBACa,GAAC,UACV,cACT,QACD,qBACE,yBAAyB,GAAG,IAC5B,yBACA,sBAAsB"}
1
+ {"version":3,"file":"getIntlayerAsync.d.ts","names":[],"sources":["../../../src/interpreter/getIntlayerAsync.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA2Ca,yBACL,UAAU,sBACV,UAAU,gBAAgB,qBAAqB,iBAAe,KAE/D,GAAC,mBACa,GAAC,UACV,cACT,QACD,qBACE,yBAAyB,GAAG,IAC5B,yBACA,sBAAsB"}
@@ -17,5 +17,6 @@ import { getPlural } from "./getPlural.js";
17
17
  import { getSelect } from "./getSelect.js";
18
18
  import { getTranslation } from "./getTranslation.js";
19
19
  import { InterpolableNode, getInterpolableContent, isInterpolableWrapperNode, rebuildInterpolableContent, transformInterpolableNode } from "./interpolableNode.js";
20
+ import { AmbientLocaleResolver, AsyncAmbientLocaleResolver, registerAmbientLocaleResolver, registerAsyncAmbientLocaleResolver, resolveInterpreterLocale, resolveInterpreterLocaleAsync } from "./resolveInterpreterLocale.js";
20
21
  import { splitInsertionTemplate } from "./splitAndJoinInsertion.js";
21
- export { ConditionCond, DeepTransformContent, EnumerationCond, FileCond, GenderCond, GetNestingResult, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, InterpolableNode, IsAny, NestedCond, NodeProps, Plugins, PluralCond, SelectCond, SelectSelector, TranslationCond, UnionKeys, ValueAtKey, bindInsertedValues, conditionPlugin, deepTransformNode, enumerationPlugin, fallbackPlugin, filePlugin, findMatchingCondition, genderPlugin, getBasePlugins, getCondition, getContent, getDictionary, getDictionaryAsync, getDictionaryTransformCacheKey, getEnumeration, getGender, getHTML, getInsertion, getInterpolableContent, getIntlayer, getIntlayerAsync, getNesting, getPluginsCacheKey, getPlural, getSelect, getTranslation, insertionPlugin, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, readTransformCache, rebuildInterpolableContent, resolveInsertedSelector, selectPlugin, splitInsertionTemplate, transformInterpolableNode, translationPlugin, writeTransformCache };
22
+ export { AmbientLocaleResolver, AsyncAmbientLocaleResolver, ConditionCond, DeepTransformContent, EnumerationCond, FileCond, GenderCond, GetNestingResult, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, InterpolableNode, IsAny, NestedCond, NodeProps, Plugins, PluralCond, SelectCond, SelectSelector, TranslationCond, UnionKeys, ValueAtKey, bindInsertedValues, conditionPlugin, deepTransformNode, enumerationPlugin, fallbackPlugin, filePlugin, findMatchingCondition, genderPlugin, getBasePlugins, getCondition, getContent, getDictionary, getDictionaryAsync, getDictionaryTransformCacheKey, getEnumeration, getGender, getHTML, getInsertion, getInterpolableContent, getIntlayer, getIntlayerAsync, getNesting, getPluginsCacheKey, getPlural, getSelect, getTranslation, insertionPlugin, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, readTransformCache, rebuildInterpolableContent, registerAmbientLocaleResolver, registerAsyncAmbientLocaleResolver, resolveInsertedSelector, resolveInterpreterLocale, resolveInterpreterLocaleAsync, selectPlugin, splitInsertionTemplate, transformInterpolableNode, translationPlugin, writeTransformCache };
@@ -0,0 +1,63 @@
1
+ import { LocalesValues } from "@intlayer/types/module_augmentation";
2
+ //#region src/interpreter/resolveInterpreterLocale.d.ts
3
+ /**
4
+ * Returns the locale of the context the code runs in (typically the request
5
+ * being handled on the server), or `undefined` outside of such a context.
6
+ */
7
+ export type AmbientLocaleResolver = () => LocalesValues | undefined;
8
+ /**
9
+ * Asynchronous {@link AmbientLocaleResolver}, for sources that can only be read
10
+ * by awaiting them (e.g. Next.js `headers()` / `cookies()`).
11
+ */
12
+ export type AsyncAmbientLocaleResolver = () => Promise<LocalesValues | undefined>;
13
+ /**
14
+ * Registers a resolver giving the locale of the current context, consulted by
15
+ * `getIntlayer` / `getDictionary` when the call site passes no locale.
16
+ *
17
+ * Integrations owning a request scope (server middlewares keeping the request
18
+ * in `AsyncLocalStorage`) register one so that a bare `getIntlayer('key')`
19
+ * answers in the request locale.
20
+ *
21
+ * @param resolver - Returns the current locale, or `undefined` when unknown.
22
+ * @returns A function unregistering the resolver.
23
+ */
24
+ export declare const registerAmbientLocaleResolver: (resolver: AmbientLocaleResolver) => (() => void);
25
+ /**
26
+ * Registers an {@link AsyncAmbientLocaleResolver}, consulted only by the
27
+ * asynchronous reads (`getIntlayerAsync` / `getDictionaryAsync`), after the
28
+ * synchronous resolvers.
29
+ *
30
+ * Unlike synchronous resolvers, its errors propagate: frameworks rely on them
31
+ * for control flow (Next.js marks a route dynamic by throwing from
32
+ * `headers()`). A resolver returns `undefined` for errors meaning "unknown".
33
+ *
34
+ * @param resolver - Resolves the current locale, or `undefined` when unknown.
35
+ * @returns A function unregistering the resolver.
36
+ */
37
+ export declare const registerAsyncAmbientLocaleResolver: (resolver: AsyncAmbientLocaleResolver) => (() => void);
38
+ /**
39
+ * Resolves the locale a dictionary is read in when the call site gives none:
40
+ *
41
+ * 1. the locale of the current context, from the registered resolvers
42
+ * (e.g. the request being handled by a server middleware);
43
+ * 2. in the browser, the locale persisted in storage (cookie, localStorage,
44
+ * sessionStorage), cached until the next `setLocaleInStorageClient`;
45
+ * 3. the default locale.
46
+ *
47
+ * Browser storage is never read off-browser: the server shares module state
48
+ * across requests, and the request cookie is only known to its integration.
49
+ *
50
+ * @param locale - Locale passed by the call site, if any.
51
+ * @returns The resolved locale.
52
+ */
53
+ export declare const resolveInterpreterLocale: (locale?: LocalesValues) => LocalesValues;
54
+ /**
55
+ * Asynchronous twin of {@link resolveInterpreterLocale}: the asynchronous
56
+ * resolvers are awaited after the synchronous ones, before browser storage.
57
+ *
58
+ * @param locale - Locale passed by the call site, if any.
59
+ * @returns The resolved locale.
60
+ */
61
+ export declare const resolveInterpreterLocaleAsync: (locale?: LocalesValues) => Promise<LocalesValues>;
62
+ //#endregion
63
+ //# sourceMappingURL=resolveInterpreterLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveInterpreterLocale.d.ts","names":[],"sources":["../../../src/interpreter/resolveInterpreterLocale.ts"],"mappings":";;;;;;YAQY,8BAA8B;;;;;YAM9B,mCAAmC,QAC7C;;;;;;;;;;;;qBAkCW,gCAA6B,UAC9B;;;;;;;;;;;;;qBAuBC,qCAAkC,UACnC;;;;;;;;;;;;;;;;qBAsCC,2BAAwB,SAC1B,kBACR;;;;;;;;qBAeU,gCAA6B,SAC/B,kBACR,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"rewriteMatch.d.ts","names":[],"sources":["../../../src/localization/rewriteMatch.ts"],"mappings":";;;;;;;;qBAYa,wBACL,sBAAsB,uBAAqB,SAExC,2BAA2B,cAAY,UACvC,YACR;;;;qBA+DU,WAAQ,iBAAmB;;;;qBAa3B,gBAAa,aACb"}
1
+ {"version":3,"file":"rewriteMatch.d.ts","names":[],"sources":["../../../src/localization/rewriteMatch.ts"],"mappings":";;;;;;;;qBAYa,wBACL,sBAAsB,uBAAqB,SAExC,2BAA2B,cAAY,UACvC,YACR;;;;qBA6EU,WAAQ,iBAAmB;;;;qBAa3B,gBAAa,aACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"getMarkdownMetadata.d.ts","names":[],"sources":["../../../../src/transpiler/markdown/getMarkdownMetadata.ts"],"mappings":";qBAEa,sBAAuB,UAAU,qBAAmB,qBAE9D"}
1
+ {"version":3,"file":"getMarkdownMetadata.d.ts","names":[],"sources":["../../../../src/transpiler/markdown/getMarkdownMetadata.ts"],"mappings":";qBA2Ca,sBAAuB,UAAU,qBAAmB,qBAE9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/core",
3
- "version": "9.5.10",
3
+ "version": "9.5.12",
4
4
  "private": false,
5
5
  "description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
6
6
  "keywords": [
@@ -173,10 +173,10 @@
173
173
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
174
174
  },
175
175
  "dependencies": {
176
- "@intlayer/api": "9.5.10",
177
- "@intlayer/config": "9.5.10",
178
- "@intlayer/dictionaries-entry": "9.5.10",
179
- "@intlayer/types": "9.5.10",
176
+ "@intlayer/api": "9.5.12",
177
+ "@intlayer/config": "9.5.12",
178
+ "@intlayer/dictionaries-entry": "9.5.12",
179
+ "@intlayer/types": "9.5.12",
180
180
  "defu": "6.1.7"
181
181
  },
182
182
  "devDependencies": {