@intlayer/core 9.8.5 → 9.9.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 (76) hide show
  1. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +3 -1
  2. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  3. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs +2 -1
  4. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
  5. package/dist/cjs/dictionaryManipulator/dynamicDictionary.cjs +262 -0
  6. package/dist/cjs/dictionaryManipulator/dynamicDictionary.cjs.map +1 -0
  7. package/dist/cjs/dictionaryManipulator/getLocalizedMetadata.cjs +25 -0
  8. package/dist/cjs/dictionaryManipulator/getLocalizedMetadata.cjs.map +1 -0
  9. package/dist/cjs/dictionaryManipulator/index.cjs +27 -3
  10. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +3 -0
  11. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  12. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs +6 -2
  13. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs.map +1 -1
  14. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs +2 -1
  15. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  16. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs +80 -12
  17. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs.map +1 -1
  18. package/dist/cjs/dictionaryManipulator/qualifiedDictionaryDeclaration.cjs +9 -3
  19. package/dist/cjs/dictionaryManipulator/qualifiedDictionaryDeclaration.cjs.map +1 -1
  20. package/dist/cjs/dictionaryManipulator/qualifiedDynamicLoader.cjs +38 -68
  21. package/dist/cjs/dictionaryManipulator/qualifiedDynamicLoader.cjs.map +1 -1
  22. package/dist/cjs/index.cjs +27 -3
  23. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  24. package/dist/cjs/interpreter/getDictionary.cjs +3 -0
  25. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  26. package/dist/cjs/interpreter/getDictionaryAsync.cjs +5 -19
  27. package/dist/cjs/interpreter/getDictionaryAsync.cjs.map +1 -1
  28. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +3 -1
  29. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  30. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs +2 -1
  31. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  32. package/dist/esm/dictionaryManipulator/dynamicDictionary.mjs +252 -0
  33. package/dist/esm/dictionaryManipulator/dynamicDictionary.mjs.map +1 -0
  34. package/dist/esm/dictionaryManipulator/getLocalizedMetadata.mjs +22 -0
  35. package/dist/esm/dictionaryManipulator/getLocalizedMetadata.mjs.map +1 -0
  36. package/dist/esm/dictionaryManipulator/index.mjs +6 -4
  37. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +3 -0
  38. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  39. package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs +6 -2
  40. package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs.map +1 -1
  41. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs +2 -1
  42. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  43. package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs +75 -13
  44. package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs.map +1 -1
  45. package/dist/esm/dictionaryManipulator/qualifiedDictionaryDeclaration.mjs +10 -5
  46. package/dist/esm/dictionaryManipulator/qualifiedDictionaryDeclaration.mjs.map +1 -1
  47. package/dist/esm/dictionaryManipulator/qualifiedDynamicLoader.mjs +33 -68
  48. package/dist/esm/dictionaryManipulator/qualifiedDynamicLoader.mjs.map +1 -1
  49. package/dist/esm/index.mjs +6 -4
  50. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  51. package/dist/esm/interpreter/getDictionary.mjs +3 -0
  52. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  53. package/dist/esm/interpreter/getDictionaryAsync.mjs +5 -19
  54. package/dist/esm/interpreter/getDictionaryAsync.mjs.map +1 -1
  55. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +2 -1
  56. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +2 -1
  57. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +2 -1
  58. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +1 -1
  59. package/dist/types/dictionaryManipulator/dynamicDictionary.d.ts +159 -0
  60. package/dist/types/dictionaryManipulator/dynamicDictionary.d.ts.map +1 -0
  61. package/dist/types/dictionaryManipulator/getLocalizedMetadata.d.ts +14 -0
  62. package/dist/types/dictionaryManipulator/getLocalizedMetadata.d.ts.map +1 -0
  63. package/dist/types/dictionaryManipulator/index.d.ts +6 -4
  64. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts.map +1 -1
  65. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts +51 -5
  66. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts.map +1 -1
  67. package/dist/types/dictionaryManipulator/qualifiedDictionaryDeclaration.d.ts +7 -2
  68. package/dist/types/dictionaryManipulator/qualifiedDictionaryDeclaration.d.ts.map +1 -1
  69. package/dist/types/dictionaryManipulator/qualifiedDynamicLoader.d.ts +34 -54
  70. package/dist/types/dictionaryManipulator/qualifiedDynamicLoader.d.ts.map +1 -1
  71. package/dist/types/index.d.ts +6 -4
  72. package/dist/types/interpreter/getContent/plugins.d.ts +2 -1
  73. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  74. package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
  75. package/dist/types/interpreter/getDictionaryAsync.d.ts.map +1 -1
  76. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":["getNestingOptimized"],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n Gender,\n GenderContent,\n InsertionContent,\n NestedContent,\n PluralContent,\n PluralContentState,\n SelectContent,\n TranslationContent,\n} from '../../transpiler';\nimport { DEFAULT_PLURAL_VARIABLE } from '../../transpiler/plural/plural';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { getGender } from '../getGender';\nimport { getInsertion } from '../getInsertion';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getNesting as getNestingOptimized } from '../getNesting.optimized';\nimport { getPlural } from '../getPlural';\nimport { getSelect } from '../getSelect';\nimport { getTranslation } from '../getTranslation';\nimport {\n isInterpolableWrapperNode,\n transformInterpolableNode,\n} from '../interpolableNode';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n id: string;\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * FALLBACK PLUGIN\n *\n * Used to fallback a tree-shaken plugin\n * --------------------------------------------- */\n\nexport const fallbackPlugin: Plugins = {\n id: 'fallback-plugin',\n canHandle: () => false,\n transform: (node) => node,\n};\n\n/**\n * Whether a resolved branch still expects insertion values.\n *\n * Some renderers return callable nodes (Svelte components, Angular proxies)\n * exposing their content on `.value`: those are final and must not be called\n * with the values. A pending insertion either has no `.value` or a function\n * one.\n */\nconst isAwaitingValues = (\n branch: unknown\n): branch is (values: Record<string, unknown>) => unknown => {\n if (typeof branch !== 'function') return false;\n\n const { value } = branch as { value?: unknown };\n\n return value === undefined || typeof value === 'function';\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type UnionKeys<T> = T extends unknown ? keyof T : never;\nexport type ValueAtKey<T, K> = T extends unknown\n ? K extends keyof T\n ? T[K]\n : never\n : never;\n\nexport type TranslationCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.TRANSLATION]: infer U;\n}\n ? U extends Record<PropertyKey, unknown>\n ? U[keyof U] extends Record<PropertyKey, unknown>\n ? {\n [K in UnionKeys<U[keyof U]>]: L extends keyof U\n ? K extends keyof U[L]\n ? U[L][K]\n : ValueAtKey<U[keyof U], K>\n : ValueAtKey<U[keyof U], K>;\n } extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : (L extends keyof U ? U[L] : U[keyof U]) extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : never\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins =>\n process.env.INTLAYER_NODE_TYPE_TRANSLATION === 'false'\n ? fallbackPlugin\n : {\n id: 'translation-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n // Resolve on the raw content first: only the displayed locale (and\n // the fallback keys it lacks) is ever transformed\n const content = getTranslation(\n node[NodeTypes.TRANSLATION] ?? {},\n locale,\n fallback\n );\n\n return deepTransformNode(content, {\n ...props,\n children: content,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.TRANSLATION, key: locale } as KeyPath,\n ],\n });\n },\n };\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.ENUMERATION]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[typeof NodeTypes.ENUMERATION][keyof T[typeof NodeTypes.ENUMERATION]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_ENUMERATION === 'false'\n ? fallbackPlugin\n : {\n id: 'enumeration-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.ENUMERATION,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const original = node[NodeTypes.ENUMERATION];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as unknown as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.ENUMERATION, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: number | { count: number }) => {\n const quantity = typeof arg === 'number' ? arg : arg.count;\n const subResult = getEnumeration(result, quantity);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * PLURAL PLUGIN\n * --------------------------------------------- */\n\n/**\n * A plural branch wrapped in an `insertion` node (auto-transformed\n * `{{count}}`) resolves to its inner content: the plural applies the values.\n */\ntype PluralBranch<Branch> = Branch extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer InsertionContent;\n fields: readonly string[];\n}\n ? InsertionContent\n : Branch;\n\n/** Value name a plural node selects on (`variable`, defaulting to `count`). */\ntype PluralVariable<T> = T extends { variable: infer Variable extends string }\n ? Variable\n : typeof DEFAULT_PLURAL_VARIABLE;\n\nexport type PluralCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.PLURAL]: object;\n}\n ? (\n arg:\n | number\n | ({ [Key in PluralVariable<T>]: number } & { [key: string]: unknown })\n ) => DeepTransformContent<\n PluralBranch<\n T[typeof NodeTypes.PLURAL][keyof T[typeof NodeTypes.PLURAL]]\n >,\n S\n >\n : never;\n\ntype SubResultFunction = (values: Record<string, string | number>) => string;\n\n/**\n * Plural plugin. Replaces node with a function that takes a count (or\n * `{ count, ...values }`) => string, picking the matching CLDR plural form\n * for the active locale and interpolating `{{count}}` (and other values).\n */\nexport const pluralPlugin = (locale?: LocalesValues): Plugins =>\n process.env.INTLAYER_NODE_TYPE_PLURAL === 'false'\n ? fallbackPlugin\n : {\n id: 'plural-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.PLURAL,\n transform: (node: PluralContent, props, deepTransformNode) => {\n const original = node[NodeTypes.PLURAL];\n const result: Record<string, any> = {};\n const variable = node.variable ?? DEFAULT_PLURAL_VARIABLE;\n // The plural interpolates its own branches. A string plugin from an\n // enclosing `insert()` or `plural()` would turn them into functions.\n const branchPlugins = (props.plugins ?? []).filter(\n (plugin) =>\n plugin.id !== 'insertion-string-plugin' &&\n plugin.id !== 'plural-string-plugin'\n );\n\n /** String plugin for plural. Replaces string node with a component that renders the insertion. */\n const pluralStringPlugin: Plugins = {\n id: 'plural-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // An `insertion` node below the plural (e.g. auto-transformed\n // `{{count}}` branches) already returns `(values) => …`. Leave its\n // strings untouched, or its template would become a function.\n const isInsideInsertion = subProps.keyPath\n .slice(props.keyPath.length)\n .some((keyPath) => keyPath.type === NodeTypes.INSERTION);\n\n if (isInsideInsertion) {\n return deepTransformNode(node, {\n ...subProps,\n plugins: subProps.plugins?.filter(\n (plugin) => plugin.id !== 'plural-string-plugin'\n ),\n });\n }\n\n // `html()`/`markdown()` nodes carry their `{{count}}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (values: { [k: string]: string | number }) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n branchPlugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: branchPlugins.filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (values: { [k: string]: string | number }) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: branchPlugins,\n children,\n });\n };\n },\n };\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.PLURAL, key } as KeyPath,\n ],\n plugins: [pluralStringPlugin, ...branchPlugins],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n const effectiveLocale = String(locale ?? props.locale ?? 'en');\n\n return (arg: number | { [key: string]: unknown }) => {\n const values: Record<string, unknown> =\n typeof arg === 'number' ? { [variable]: arg } : arg;\n const count = Number(values[variable]);\n\n const subResult: string | SubResultFunction = getPlural(\n result as PluralContent['plural'] as PluralContentState<string>,\n count,\n effectiveLocale\n );\n\n if (isAwaitingValues(subResult)) {\n return (subResult as SubResultFunction)(\n values as Record<string, string | number>\n );\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.CONDITION]: object;\n}\n ? (\n value: boolean | { value: boolean }\n ) => DeepTransformContent<\n T[typeof NodeTypes.CONDITION][keyof T[typeof NodeTypes.CONDITION]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_CONDITION === 'false'\n ? fallbackPlugin\n : {\n id: 'condition-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.CONDITION,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const original = node[NodeTypes.CONDITION];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.CONDITION, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: boolean | { value: boolean }) => {\n const value = typeof arg === 'boolean' ? arg : arg.value;\n const subResult = getCondition(result as any, value);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I;\n fields: readonly string[];\n}\n ? (values: {\n [K in T['fields'][number]]: string | number;\n }) => I extends string\n ? DeepTransformContent<string, S>\n : DeepTransformContent<I, S>\n : never;\n\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: (props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: props.plugins,\n children,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, result);\n },\n };\n\n/** Container nodes resolved by a selector call: `enu(3)`, `cond(true)`, … */\nconst selectorNodeTypes: string[] = [\n NodeTypes.ENUMERATION,\n NodeTypes.CONDITION,\n NodeTypes.PLURAL,\n NodeTypes.GENDER,\n NodeTypes.SELECT,\n];\n\n/**\n * Binds the values of an `insert()` to the selector node it wraps, returning\n * `(selector) => content`. Any other child result is returned unchanged.\n *\n * `areBranchesInterpolated` is set by frameworks that interpolate the branch\n * strings as soon as the values are known: the selected branch is then final\n * content and is never called with the values.\n */\nexport const bindInsertedValues = (\n children: unknown,\n result: unknown,\n values: Record<string, unknown>,\n areBranchesInterpolated = false\n): unknown => {\n const nodeType = (children as { nodeType?: string })?.nodeType;\n if (\n typeof result !== 'function' ||\n !nodeType ||\n !selectorNodeTypes.includes(nodeType)\n ) {\n return result;\n }\n\n const isCountSelector =\n nodeType === NodeTypes.PLURAL || nodeType === NodeTypes.ENUMERATION;\n\n return (selector: unknown) => {\n // Object selectors (`{ count }`, `{ value }`) carry the values along.\n if (typeof selector === 'object' && selector !== null) {\n return result({ ...values, ...selector });\n }\n\n // The count both selects the branch and fills `{{count}}`: the selector\n // wins over a `count` passed with the values.\n if (isCountSelector) {\n return result({ ...values, count: selector });\n }\n\n const selected = result(selector);\n\n return !areBranchesInterpolated && isAwaitingValues(selected)\n ? selected(values)\n : selected;\n };\n};\n\n/**\n * Shapes the result of `insert()` wrapping a selector node as\n * `(values) => (selector) => content`, so the values reach the selected\n * branch. Any other child result is returned unchanged.\n */\nexport const resolveInsertedSelector = (\n children: unknown,\n result: unknown\n): unknown =>\n typeof result === 'function' &&\n selectorNodeTypes.includes(\n (children as { nodeType?: string })?.nodeType ?? ''\n )\n ? (values: Record<string, unknown>) =>\n bindInsertedValues(children, result, values)\n : result;\n\n/** ---------------------------------------------\n * GENDER PLUGIN\n * --------------------------------------------- */\n\nexport type GenderCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.GENDER]: object;\n}\n ? (\n value: Gender\n ) => DeepTransformContent<\n T[typeof NodeTypes.GENDER][keyof T[typeof NodeTypes.GENDER]],\n S\n >\n : never;\n\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nexport const genderPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_GENDER === 'false'\n ? fallbackPlugin\n : {\n id: 'gender-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.GENDER,\n transform: (node: GenderContent, props, deepTransformNode) => {\n const original = node[NodeTypes.GENDER];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.GENDER, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (value: Gender) => getGender(result as any, value);\n },\n };\n\n/** ---------------------------------------------\n * SELECT PLUGIN\n * --------------------------------------------- */\n\n/**\n * Accepted selector for a select node.\n *\n * When the node declares a `fallback` case, any string is accepted (the\n * fallback covers the unmatched values) while the declared cases still\n * autocomplete. Without a `fallback`, only the declared cases are accepted.\n */\nexport type SelectSelector<States> = 'fallback' extends keyof States\n ? Exclude<keyof States & string, 'fallback'> | (string & {})\n : keyof States & string;\n\nexport type SelectCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.SELECT]: object;\n}\n ? (\n value:\n | SelectSelector<T[typeof NodeTypes.SELECT]>\n | { value: SelectSelector<T[typeof NodeTypes.SELECT]> }\n ) => DeepTransformContent<\n T[typeof NodeTypes.SELECT][keyof T[typeof NodeTypes.SELECT]],\n S\n >\n : never;\n\n/** Select plugin. Replaces node with a function that takes a string => content. */\nexport const selectPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_SELECT === 'false'\n ? fallbackPlugin\n : {\n id: 'select-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.SELECT,\n transform: (node: SelectContent, props, deepTransformNode) => {\n const original = node[NodeTypes.SELECT];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.SELECT, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: string | { value: string }) => {\n const value = typeof arg === 'string' ? arg : arg?.value;\n const subResult = getSelect(result, value);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.NESTED]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/**\n * Resolver used to turn a nested node into content.\n *\n * Optimized builds set `INTLAYER_OPTIMIZED_NESTING` so bundlers fold this to\n * the local resolver and dead-code-eliminate the registry-based one — together\n * with its `getIntlayer` import, and therefore the whole\n * `@intlayer/dictionaries-entry` module. That is what allows the dictionaries\n * entry to be emptied while `nest()` keeps working.\n */\nconst resolveNesting =\n process.env.INTLAYER_OPTIMIZED_NESTING === 'true'\n ? getNestingOptimized\n : getNesting;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin = (locale?: LocalesValues): Plugins =>\n process.env.INTLAYER_NODE_TYPE_NESTED === 'false'\n ? fallbackPlugin\n : {\n id: 'nested-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n (node?.nodeType === NodeTypes.NESTED || node?.nodeType === 'n'),\n transform: (node: NestedContent, props) =>\n resolveNesting(\n node[NodeTypes.NESTED].dictionaryKey,\n node[NodeTypes.NESTED].path,\n {\n ...props,\n locale: (locale ?? props.locale) as Locale,\n }\n ),\n };\n\n/** ---------------------------------------------\n * FILE PLUGIN\n * --------------------------------------------- */\n\nexport type FileCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.FILE]: string;\n content?: string;\n}\n ? DeepTransformContent<string, S>\n : never;\n\n/** File plugin. Replaces node with the result of `getNesting`. */\nexport const filePlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_FILE === 'false'\n ? fallbackPlugin\n : {\n id: 'file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.FILE,\n transform: (node: FileContent, props, deepTransform) =>\n deepTransform(node.content, {\n ...props,\n children: node.content,\n }),\n };\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locale;\n dictionaryPath?: string;\n children?: any;\n /**\n * Dictionaries referenced through `nest()`, attached to the consuming\n * dictionary by the build optimization and threaded down by\n * `deepTransformNode`.\n *\n * Present only in optimized builds, where the global dictionary registry is\n * stripped and `getNesting` resolves from this map instead. See\n * `getNesting.optimized.ts`.\n */\n nestedDictionaries?: Record<string, unknown>;\n /**\n * Forces eager traversal of plain objects in `deepTransformNode`. By default\n * traversal is lazy (property getters), so callers that discard the returned\n * value never trigger plugins on nested nodes. Set this when running plugins\n * for their side effects only (e.g. missing-locale detection), or when most\n * of the content is read anyway: defining a getter per key, then redefining\n * it on first read, costs more than transforming the key outright.\n */\n eager?: boolean;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S, L extends LocalesValues> {\n translation: TranslationCond<T, S, L>;\n enumeration: EnumerationCond<T, S, L>;\n plural: PluralCond<T, S, L>;\n condition: ConditionCond<T, S, L>;\n insertion: InsertionCond<T, S, L>;\n gender: GenderCond<T, S, L>;\n select: SelectCond<T, S, L>;\n nested: NestedCond<T, S, L>;\n file: FileCond<T, S, L>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n plural: true;\n condition: true;\n insertion: true;\n gender: true;\n select: true;\n nested: true;\n file: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<\n T,\n K extends keyof IInterpreterPlugin<T, S, L>,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = K extends keyof S // Test if the key is a key of S.\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S, L>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S, L>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S, L extends LocalesValues = DeclaredLocales> =\n T extends ReadonlyArray<infer U> // Turn any read-only array into a plain mutable array\n ? Array<DeepTransformContent<U, S, L>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S, L> }\n : T;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<\n T,\n S = IInterpreterPluginState,\n L extends LocalesValues = DeclaredLocales,\n> =\n IsAny<T> extends true\n ? T\n : CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L> extends never // Check if there is a plugin for T:\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S, L>\n : // A plugin was found – use the plugin's transformation.\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoEA,MAAa,iBAA0B;CACrC,IAAI;CACJ,iBAAiB;CACjB,YAAY,SAAS;AACvB;;;;;;;;;AAUA,MAAM,oBACJ,WAC2D;CAC3D,IAAI,OAAO,WAAW,YAAY,OAAO;CAEzC,MAAM,EAAE,UAAU;CAElB,OAAO,UAAU,UAAa,OAAO,UAAU;AACjD;;AAmCA,MAAa,qBACX,QACA,aAEA,QAAQ,IAAI,mCAAmC,UAC3C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA0B,OAAO,sBAAsB;EAGjE,MAAM,UAAU,eACd,KAAK,UAAU,gBAAgB,CAAC,GAChC,QACA,QACF;EAEA,OAAO,kBAAkB,SAAS;GAChC,GAAG;GACH,UAAU;GACV,SAAS,CACP,GAAG,MAAM,SACT;IAAE,MAAM,UAAU;IAAa,KAAK;GAAO,CAC7C;EACF,CAAC;CACH;AACF;;AAmBN,MAAa,oBACX,QAAQ,IAAI,mCAAmC,UAC3C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA0B,OAAO,sBAAsB;EACjE,MAAM,WAAW,KAAK,UA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,MAAM,QAAQ,SAAS;GASvB,OAAO,OAAO,kBAAkB,OAAO;IAPrC,GAAG;IACH,UAAU;IACV,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM,UAAU;KAAQ;IAAI,CAChC;GAE8C,CAAC;EACnD;EAEA,QAAQ,QAAoC;GAC1C,MAAM,QAAQ,OAAO,QAAQ,WAAW,MAAM,KAAK;GACnD,MAAM,YAAY,UAAU,QAAQ,KAAK;GAEzC,IAAI,iBAAiB,SAAS,KAAK,OAAO,QAAQ,UAChD,OAAO,UAAU,GAAG;GAGtB,OAAO;EACT;CACF;AACF;;;;;;;;;;AA2BN,MAAM,iBACJ,QAAQ,IAAI,+BAA+B,SACvCA,eACA;;AAGN,MAAa,gBAAgB,WAC3B,QAAQ,IAAI,8BAA8B,UACtC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,aACf,MAAM,aAAa,UAAU,UAAU,MAAM,aAAa;CAC7D,YAAY,MAAqB,UAC/B,eACE,KAAK,UAAU,OAAO,CAAC,eACvB,KAAK,UAAU,OAAO,CAAC,MACvB;EACE,GAAG;EACH,QAAS,UAAU,MAAM;CAC3B,CACF;AACJ;;AAeN,MAAa,aACX,QAAQ,IAAI,4BAA4B,UACpC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAmB,OAAO,kBACpC,cAAc,KAAK,SAAS;EAC1B,GAAG;EACH,UAAU,KAAK;CACjB,CAAC;AACL"}
1
+ {"version":3,"file":"plugins.mjs","names":["getNestingOptimized"],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { UninterpretedContent } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n Gender,\n GenderContent,\n InsertionContent,\n NestedContent,\n PluralContent,\n PluralContentState,\n SelectContent,\n TranslationContent,\n} from '../../transpiler';\nimport { DEFAULT_PLURAL_VARIABLE } from '../../transpiler/plural/plural';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { getGender } from '../getGender';\nimport { getInsertion } from '../getInsertion';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getNesting as getNestingOptimized } from '../getNesting.optimized';\nimport { getPlural } from '../getPlural';\nimport { getSelect } from '../getSelect';\nimport { getTranslation } from '../getTranslation';\nimport {\n isInterpolableWrapperNode,\n transformInterpolableNode,\n} from '../interpolableNode';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n id: string;\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * FALLBACK PLUGIN\n *\n * Used to fallback a tree-shaken plugin\n * --------------------------------------------- */\n\nexport const fallbackPlugin: Plugins = {\n id: 'fallback-plugin',\n canHandle: () => false,\n transform: (node) => node,\n};\n\n/**\n * Whether a resolved branch still expects insertion values.\n *\n * Some renderers return callable nodes (Svelte components, Angular proxies)\n * exposing their content on `.value`: those are final and must not be called\n * with the values. A pending insertion either has no `.value` or a function\n * one.\n */\nconst isAwaitingValues = (\n branch: unknown\n): branch is (values: Record<string, unknown>) => unknown => {\n if (typeof branch !== 'function') return false;\n\n const { value } = branch as { value?: unknown };\n\n return value === undefined || typeof value === 'function';\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type UnionKeys<T> = T extends unknown ? keyof T : never;\nexport type ValueAtKey<T, K> = T extends unknown\n ? K extends keyof T\n ? T[K]\n : never\n : never;\n\nexport type TranslationCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.TRANSLATION]: infer U;\n}\n ? U extends Record<PropertyKey, unknown>\n ? U[keyof U] extends Record<PropertyKey, unknown>\n ? {\n [K in UnionKeys<U[keyof U]>]: L extends keyof U\n ? K extends keyof U[L]\n ? U[L][K]\n : ValueAtKey<U[keyof U], K>\n : ValueAtKey<U[keyof U], K>;\n } extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : (L extends keyof U ? U[L] : U[keyof U]) extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : never\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins =>\n process.env.INTLAYER_NODE_TYPE_TRANSLATION === 'false'\n ? fallbackPlugin\n : {\n id: 'translation-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n // Resolve on the raw content first: only the displayed locale (and\n // the fallback keys it lacks) is ever transformed\n const content = getTranslation(\n node[NodeTypes.TRANSLATION] ?? {},\n locale,\n fallback\n );\n\n return deepTransformNode(content, {\n ...props,\n children: content,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.TRANSLATION, key: locale } as KeyPath,\n ],\n });\n },\n };\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.ENUMERATION]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[typeof NodeTypes.ENUMERATION][keyof T[typeof NodeTypes.ENUMERATION]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_ENUMERATION === 'false'\n ? fallbackPlugin\n : {\n id: 'enumeration-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.ENUMERATION,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const original = node[NodeTypes.ENUMERATION];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as unknown as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.ENUMERATION, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: number | { count: number }) => {\n const quantity = typeof arg === 'number' ? arg : arg.count;\n const subResult = getEnumeration(result, quantity);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * PLURAL PLUGIN\n * --------------------------------------------- */\n\n/**\n * A plural branch wrapped in an `insertion` node (auto-transformed\n * `{{count}}`) resolves to its inner content: the plural applies the values.\n */\ntype PluralBranch<Branch> = Branch extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer InsertionContent;\n fields: readonly string[];\n}\n ? InsertionContent\n : Branch;\n\n/** Value name a plural node selects on (`variable`, defaulting to `count`). */\ntype PluralVariable<T> = T extends { variable: infer Variable extends string }\n ? Variable\n : typeof DEFAULT_PLURAL_VARIABLE;\n\nexport type PluralCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.PLURAL]: object;\n}\n ? (\n arg:\n | number\n | ({ [Key in PluralVariable<T>]: number } & { [key: string]: unknown })\n ) => DeepTransformContent<\n PluralBranch<\n T[typeof NodeTypes.PLURAL][keyof T[typeof NodeTypes.PLURAL]]\n >,\n S\n >\n : never;\n\ntype SubResultFunction = (values: Record<string, string | number>) => string;\n\n/**\n * Plural plugin. Replaces node with a function that takes a count (or\n * `{ count, ...values }`) => string, picking the matching CLDR plural form\n * for the active locale and interpolating `{{count}}` (and other values).\n */\nexport const pluralPlugin = (locale?: LocalesValues): Plugins =>\n process.env.INTLAYER_NODE_TYPE_PLURAL === 'false'\n ? fallbackPlugin\n : {\n id: 'plural-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.PLURAL,\n transform: (node: PluralContent, props, deepTransformNode) => {\n const original = node[NodeTypes.PLURAL];\n const result: Record<string, any> = {};\n const variable = node.variable ?? DEFAULT_PLURAL_VARIABLE;\n // The plural interpolates its own branches. A string plugin from an\n // enclosing `insert()` or `plural()` would turn them into functions.\n const branchPlugins = (props.plugins ?? []).filter(\n (plugin) =>\n plugin.id !== 'insertion-string-plugin' &&\n plugin.id !== 'plural-string-plugin'\n );\n\n /** String plugin for plural. Replaces string node with a component that renders the insertion. */\n const pluralStringPlugin: Plugins = {\n id: 'plural-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // An `insertion` node below the plural (e.g. auto-transformed\n // `{{count}}` branches) already returns `(values) => …`. Leave its\n // strings untouched, or its template would become a function.\n const isInsideInsertion = subProps.keyPath\n .slice(props.keyPath.length)\n .some((keyPath) => keyPath.type === NodeTypes.INSERTION);\n\n if (isInsideInsertion) {\n return deepTransformNode(node, {\n ...subProps,\n plugins: subProps.plugins?.filter(\n (plugin) => plugin.id !== 'plural-string-plugin'\n ),\n });\n }\n\n // `html()`/`markdown()` nodes carry their `{{count}}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (values: { [k: string]: string | number }) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n branchPlugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: branchPlugins.filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (values: { [k: string]: string | number }) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: branchPlugins,\n children,\n });\n };\n },\n };\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.PLURAL, key } as KeyPath,\n ],\n plugins: [pluralStringPlugin, ...branchPlugins],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n const effectiveLocale = String(locale ?? props.locale ?? 'en');\n\n return (arg: number | { [key: string]: unknown }) => {\n const values: Record<string, unknown> =\n typeof arg === 'number' ? { [variable]: arg } : arg;\n const count = Number(values[variable]);\n\n const subResult: string | SubResultFunction = getPlural(\n result as PluralContent['plural'] as PluralContentState<string>,\n count,\n effectiveLocale\n );\n\n if (isAwaitingValues(subResult)) {\n return (subResult as SubResultFunction)(\n values as Record<string, string | number>\n );\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.CONDITION]: object;\n}\n ? (\n value: boolean | { value: boolean }\n ) => DeepTransformContent<\n T[typeof NodeTypes.CONDITION][keyof T[typeof NodeTypes.CONDITION]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_CONDITION === 'false'\n ? fallbackPlugin\n : {\n id: 'condition-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.CONDITION,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const original = node[NodeTypes.CONDITION];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.CONDITION, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: boolean | { value: boolean }) => {\n const value = typeof arg === 'boolean' ? arg : arg.value;\n const subResult = getCondition(result as any, value);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I;\n fields: readonly string[];\n}\n ? (values: {\n [K in T['fields'][number]]: string | number;\n }) => I extends string\n ? DeepTransformContent<string, S>\n : DeepTransformContent<I, S>\n : never;\n\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nexport const insertionPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_INSERTION === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: (props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: props.plugins,\n children,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, result);\n },\n };\n\n/** Container nodes resolved by a selector call: `enu(3)`, `cond(true)`, … */\nconst selectorNodeTypes: string[] = [\n NodeTypes.ENUMERATION,\n NodeTypes.CONDITION,\n NodeTypes.PLURAL,\n NodeTypes.GENDER,\n NodeTypes.SELECT,\n];\n\n/**\n * Binds the values of an `insert()` to the selector node it wraps, returning\n * `(selector) => content`. Any other child result is returned unchanged.\n *\n * `areBranchesInterpolated` is set by frameworks that interpolate the branch\n * strings as soon as the values are known: the selected branch is then final\n * content and is never called with the values.\n */\nexport const bindInsertedValues = (\n children: unknown,\n result: unknown,\n values: Record<string, unknown>,\n areBranchesInterpolated = false\n): unknown => {\n const nodeType = (children as { nodeType?: string })?.nodeType;\n if (\n typeof result !== 'function' ||\n !nodeType ||\n !selectorNodeTypes.includes(nodeType)\n ) {\n return result;\n }\n\n const isCountSelector =\n nodeType === NodeTypes.PLURAL || nodeType === NodeTypes.ENUMERATION;\n\n return (selector: unknown) => {\n // Object selectors (`{ count }`, `{ value }`) carry the values along.\n if (typeof selector === 'object' && selector !== null) {\n return result({ ...values, ...selector });\n }\n\n // The count both selects the branch and fills `{{count}}`: the selector\n // wins over a `count` passed with the values.\n if (isCountSelector) {\n return result({ ...values, count: selector });\n }\n\n const selected = result(selector);\n\n return !areBranchesInterpolated && isAwaitingValues(selected)\n ? selected(values)\n : selected;\n };\n};\n\n/**\n * Shapes the result of `insert()` wrapping a selector node as\n * `(values) => (selector) => content`, so the values reach the selected\n * branch. Any other child result is returned unchanged.\n */\nexport const resolveInsertedSelector = (\n children: unknown,\n result: unknown\n): unknown =>\n typeof result === 'function' &&\n selectorNodeTypes.includes(\n (children as { nodeType?: string })?.nodeType ?? ''\n )\n ? (values: Record<string, unknown>) =>\n bindInsertedValues(children, result, values)\n : result;\n\n/** ---------------------------------------------\n * GENDER PLUGIN\n * --------------------------------------------- */\n\nexport type GenderCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.GENDER]: object;\n}\n ? (\n value: Gender\n ) => DeepTransformContent<\n T[typeof NodeTypes.GENDER][keyof T[typeof NodeTypes.GENDER]],\n S\n >\n : never;\n\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nexport const genderPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_GENDER === 'false'\n ? fallbackPlugin\n : {\n id: 'gender-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.GENDER,\n transform: (node: GenderContent, props, deepTransformNode) => {\n const original = node[NodeTypes.GENDER];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.GENDER, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (value: Gender) => getGender(result as any, value);\n },\n };\n\n/** ---------------------------------------------\n * SELECT PLUGIN\n * --------------------------------------------- */\n\n/**\n * Accepted selector for a select node.\n *\n * When the node declares a `fallback` case, any string is accepted (the\n * fallback covers the unmatched values) while the declared cases still\n * autocomplete. Without a `fallback`, only the declared cases are accepted.\n */\nexport type SelectSelector<States> = 'fallback' extends keyof States\n ? Exclude<keyof States & string, 'fallback'> | (string & {})\n : keyof States & string;\n\nexport type SelectCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.SELECT]: object;\n}\n ? (\n value:\n | SelectSelector<T[typeof NodeTypes.SELECT]>\n | { value: SelectSelector<T[typeof NodeTypes.SELECT]> }\n ) => DeepTransformContent<\n T[typeof NodeTypes.SELECT][keyof T[typeof NodeTypes.SELECT]],\n S\n >\n : never;\n\n/** Select plugin. Replaces node with a function that takes a string => content. */\nexport const selectPlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_SELECT === 'false'\n ? fallbackPlugin\n : {\n id: 'select-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.SELECT,\n transform: (node: SelectContent, props, deepTransformNode) => {\n const original = node[NodeTypes.SELECT];\n const result: Record<string, any> = {};\n\n for (const key in original) {\n const child = original[key as keyof typeof original];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.SELECT, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(child, childProps);\n }\n\n return (arg: string | { value: string }) => {\n const value = typeof arg === 'string' ? arg : arg?.value;\n const subResult = getSelect(result, value);\n\n if (isAwaitingValues(subResult) && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n };\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.NESTED]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/**\n * Resolver used to turn a nested node into content.\n *\n * Optimized builds set `INTLAYER_OPTIMIZED_NESTING` so bundlers fold this to\n * the local resolver and dead-code-eliminate the registry-based one — together\n * with its `getIntlayer` import, and therefore the whole\n * `@intlayer/dictionaries-entry` module. That is what allows the dictionaries\n * entry to be emptied while `nest()` keeps working.\n */\nconst resolveNesting =\n process.env.INTLAYER_OPTIMIZED_NESTING === 'true'\n ? getNestingOptimized\n : getNesting;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin = (locale?: LocalesValues): Plugins =>\n process.env.INTLAYER_NODE_TYPE_NESTED === 'false'\n ? fallbackPlugin\n : {\n id: 'nested-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n (node?.nodeType === NodeTypes.NESTED || node?.nodeType === 'n'),\n transform: (node: NestedContent, props) =>\n resolveNesting(\n node[NodeTypes.NESTED].dictionaryKey,\n node[NodeTypes.NESTED].path,\n {\n ...props,\n locale: (locale ?? props.locale) as Locale,\n }\n ),\n };\n\n/** ---------------------------------------------\n * FILE PLUGIN\n * --------------------------------------------- */\n\nexport type FileCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.FILE]: string;\n content?: string;\n}\n ? DeepTransformContent<string, S>\n : never;\n\n/** File plugin. Replaces node with the result of `getNesting`. */\nexport const filePlugin: Plugins =\n process.env.INTLAYER_NODE_TYPE_FILE === 'false'\n ? fallbackPlugin\n : {\n id: 'file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.FILE,\n transform: (node: FileContent, props, deepTransform) =>\n deepTransform(node.content, {\n ...props,\n children: node.content,\n }),\n };\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locale;\n dictionaryPath?: string;\n children?: any;\n /**\n * Dictionaries referenced through `nest()`, attached to the consuming\n * dictionary by the build optimization and threaded down by\n * `deepTransformNode`.\n *\n * Present only in optimized builds, where the global dictionary registry is\n * stripped and `getNesting` resolves from this map instead. See\n * `getNesting.optimized.ts`.\n */\n nestedDictionaries?: Record<string, unknown>;\n /**\n * Forces eager traversal of plain objects in `deepTransformNode`. By default\n * traversal is lazy (property getters), so callers that discard the returned\n * value never trigger plugins on nested nodes. Set this when running plugins\n * for their side effects only (e.g. missing-locale detection), or when most\n * of the content is read anyway: defining a getter per key, then redefining\n * it on first read, costs more than transforming the key outright.\n */\n eager?: boolean;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S, L extends LocalesValues> {\n translation: TranslationCond<T, S, L>;\n enumeration: EnumerationCond<T, S, L>;\n plural: PluralCond<T, S, L>;\n condition: ConditionCond<T, S, L>;\n insertion: InsertionCond<T, S, L>;\n gender: GenderCond<T, S, L>;\n select: SelectCond<T, S, L>;\n nested: NestedCond<T, S, L>;\n file: FileCond<T, S, L>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n plural: true;\n condition: true;\n insertion: true;\n gender: true;\n select: true;\n nested: true;\n file: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<\n T,\n K extends keyof IInterpreterPlugin<T, S, L>,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = K extends keyof S // Test if the key is a key of S.\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S, L>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S, L>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S, L extends LocalesValues = DeclaredLocales> =\n T extends ReadonlyArray<infer U> // Turn any read-only array into a plain mutable array\n ? Array<DeepTransformContent<U, S, L>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S, L> }\n : T;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<\n T,\n S = IInterpreterPluginState,\n L extends LocalesValues = DeclaredLocales,\n> =\n IsAny<T> extends true\n ? T\n : [T] extends [UninterpretedContent<infer Declared>] // Metadata: returned as declared\n ? Declared\n : CheckApplyPlugin<\n T,\n keyof IInterpreterPlugin<T, S, L>,\n S,\n L\n > extends never // Check if there is a plugin for T:\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S, L>\n : // A plugin was found – use the plugin's transformation.\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqEA,MAAa,iBAA0B;CACrC,IAAI;CACJ,iBAAiB;CACjB,YAAY,SAAS;AACvB;;;;;;;;;AAUA,MAAM,oBACJ,WAC2D;CAC3D,IAAI,OAAO,WAAW,YAAY,OAAO;CAEzC,MAAM,EAAE,UAAU;CAElB,OAAO,UAAU,UAAa,OAAO,UAAU;AACjD;;AAmCA,MAAa,qBACX,QACA,aAEA,QAAQ,IAAI,mCAAmC,UAC3C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA0B,OAAO,sBAAsB;EAGjE,MAAM,UAAU,eACd,KAAK,UAAU,gBAAgB,CAAC,GAChC,QACA,QACF;EAEA,OAAO,kBAAkB,SAAS;GAChC,GAAG;GACH,UAAU;GACV,SAAS,CACP,GAAG,MAAM,SACT;IAAE,MAAM,UAAU;IAAa,KAAK;GAAO,CAC7C;EACF,CAAC;CACH;AACF;;AAmBN,MAAa,oBACX,QAAQ,IAAI,mCAAmC,UAC3C,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAA0B,OAAO,sBAAsB;EACjE,MAAM,WAAW,KAAK,UAAU;EAChC,MAAM,SAA8B,CAAC;EAErC,KAAK,MAAM,OAAO,UAAU;GAC1B,MAAM,QAAQ,SAAS;GASvB,OAAO,OAAO,kBAAkB,OAAO;IAPrC,GAAG;IACH,UAAU;IACV,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM,UAAU;KAAa;IAAI,CACrC;GAE8C,CAAC;EACnD;EAEA,QAAQ,QAAoC;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AAY,UAAU,QAAQ,KAAK;GAEzC,IAAI,iBAAiB,SAAS,KAAK,OAAO,QAAQ,UAChD,OAAO,UAAU,GAAG;GAGtB,OAAO;EACT;CACF;AACF;;;;;;;;;;AA2BN,MAAM,iBACJ,QAAQ,IAAI,+BAA+B,SACvCA,eACA;;AAGN,MAAa,gBAAgB,WAC3B,QAAQ,IAAI,8BAA8B,UACtC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,aACf,MAAM,aAAa,UAAU,UAAU,MAAM,aAAa;CAC7D,YAAY,MAAqB,UAC/B,eACE,KAAK,UAAU,OAAO,CAAC,eACvB,KAAK,UAAU,OAAO,CAAC,MACvB;EACE,GAAG;EACH,QAAS,UAAU,MAAM;CAC3B,CACF;AACJ;;AAeN,MAAa,aACX,QAAQ,IAAI,4BAA4B,UACpC,iBACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAmB,OAAO,kBACpC,cAAc,KAAK,SAAS;EAC1B,GAAG;EACH,UAAU,KAAK;CACjB,CAAC;AACL"}
@@ -1,7 +1,9 @@
1
+ import { getLocalizedMetadata } from "../dictionaryManipulator/getLocalizedMetadata.mjs";
1
2
  import { getDictionarySelectorCacheKey, parseDictionarySelector, resolveQualifiedDictionary } from "../dictionaryManipulator/qualifiedDictionary.mjs";
2
3
  import { getDictionaryTransformCacheKey, readTransformCache, writeTransformCache } from "./dictionaryTransformCache.mjs";
3
4
  import { getBasePlugins, getContent } from "./getContent/getContent.mjs";
4
5
  import { resolveInterpreterLocale } from "./resolveInterpreterLocale.mjs";
6
+ import { internationalization } from "@intlayer/config/built";
5
7
 
6
8
  // src/interpreter/getDictionary.ts
7
9
  /**
@@ -31,6 +33,7 @@ const getDictionary = (dictionary, localeOrSelector, plugins) => {
31
33
  const appliedPlugins = plugins ?? getBasePlugins(locale);
32
34
  const resolved = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? resolveQualifiedDictionary(dictionary, selector) : dictionary;
33
35
  const transformDictionary = (resolvedDictionary) => {
36
+ if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && selector?.metadataOnly) return getLocalizedMetadata(resolvedDictionary.metadata, locale, internationalization.defaultLocale);
34
37
  const props = {
35
38
  dictionaryKey: resolvedDictionary.key,
36
39
  dictionaryPath: resolvedDictionary.filePath,
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.mjs","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelector,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n resolveQualifiedDictionary,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport {\n getDictionaryTransformCacheKey,\n readTransformCache,\n writeTransformCache,\n} from './dictionaryTransformCache';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getBasePlugins, getContent } from './getContent/getContent';\nimport { resolveInterpreterLocale } from './resolveInterpreterLocale';\n\n/**\n * Dictionaries whose transform is running. Content is transformed eagerly, so a\n * dictionary reached again through a `nest()` cycle is transformed lazily\n * instead: its nodes then resolve on read, and the cycle unwinds.\n */\nconst transformsInProgress = new WeakSet<object>();\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary (or qualified dictionary group) to transform.\n * @param localeOrSelector The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n // The selector checks stay inline so bundlers can drop the whole\n // qualified-dictionary module when no dictionary declares a qualifier.\n const { locale: requestedLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector(localeOrSelector)\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n const locale = resolveInterpreterLocale(requestedLocale);\n\n // The base plugins are rebuilt on every call, so they cannot identify\n // themselves — but they are fully determined by the locale, which the key\n // already carries. Only an explicitly passed array needs its own identity.\n const cacheKey = getDictionaryTransformCacheKey(\n locale,\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? getDictionarySelectorCacheKey(selector)\n : '',\n plugins\n );\n\n const cached = readTransformCache<any>(dictionary, cacheKey);\n if (cached.hit) return cached.content;\n\n const appliedPlugins = plugins ?? getBasePlugins(locale);\n\n const resolved =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveQualifiedDictionary(dictionary, selector)\n : (dictionary as Dictionary);\n\n const transformDictionary = (resolvedDictionary: Dictionary) => {\n const props: NodeProps = {\n dictionaryKey: resolvedDictionary.key,\n dictionaryPath: resolvedDictionary.filePath,\n keyPath: [],\n plugins: appliedPlugins,\n // Attached by the build optimization so `nest()` resolves without the\n // global registry. Undefined in unoptimized builds, where the\n // registry-based resolver is used instead.\n nestedDictionaries: resolvedDictionary.nestedDictionaries,\n eager: !transformsInProgress.has(resolvedDictionary),\n };\n\n transformsInProgress.add(resolvedDictionary);\n\n try {\n return getContent(resolvedDictionary.content, props, appliedPlugins);\n } finally {\n if (props.eager) transformsInProgress.delete(resolvedDictionary);\n }\n };\n\n if (resolved === null)\n return writeTransformCache(dictionary, cacheKey, null)!;\n\n if (Array.isArray(resolved)) {\n return writeTransformCache(\n dictionary,\n cacheKey,\n resolved.map(transformDictionary)\n ) as any;\n }\n\n return writeTransformCache(\n dictionary,\n cacheKey,\n transformDictionary(resolved)\n ) as any;\n};\n"],"mappings":";;;;;;;;;;;AAmCA,MAAM,uCAAuB,IAAI,QAAgB;;;;;;;;;;AAWjD,MAAa,iBAIX,YACA,kBACA,YAKG;CAGH,MAAM,EAAE,QAAQ,iBAAiB,aAC/B,QAAQ,IAAI,iCAAiC,UACzC,wBAAwB,gBAAgB,IACxC;EACE,QAAQ;EACR,UAAU;CACZ;CACN,MAAM,SAAS,yBAAyB,eAAe;CAKvD,MAAM,WAAW,+BACf,QACA,QAAQ,IAAI,iCAAiC,UACzC,8BAA8B,QAAQ,IACtC,IACJ,OACF;CAEA,MAAM,SAAS,mBAAwB,YAAY,QAAQ;CAC3D,IAAI,OAAO,KAAK,OAAO,OAAO;CAE9B,MAAM,iBAAiB,WAAW,eAAe,MAAM;CAEvD,MAAM,WACJ,QAAQ,IAAI,iCAAiC,UACzC,2BAA2B,YAAY,QAAQ,IAC9C;CAEP,MAAM,uBAAuB,uBAAmC;EAC9D,MAAM,QAAmB;GACvB,eAAe,mBAAmB;GAClC,gBAAgB,mBAAmB;GACnC,SAAS,CAAC;GACV,SAAS;GAIT,oBAAoB,mBAAmB;GACvC,OAAO,CAAC,qBAAqB,IAAI,kBAAkB;EACrD;EAEA,qBAAqB,IAAI,kBAAkB;EAE3C,IAAI;GACF,OAAO,WAAW,mBAAmB,SAAS,OAAO,cAAc;EACrE,UAAU;GACR,IAAI,MAAM,OAAO,qBAAqB,OAAO,kBAAkB;EACjE;CACF;CAEA,IAAI,aAAa,MACf,OAAO,oBAAoB,YAAY,UAAU,IAAI;CAEvD,IAAI,MAAM,QAAQ,QAAQ,GACxB,OAAO,oBACL,YACA,UACA,SAAS,IAAI,mBAAmB,CAClC;CAGF,OAAO,oBACL,YACA,UACA,oBAAoB,QAAQ,CAC9B;AACF"}
1
+ {"version":3,"file":"getDictionary.mjs","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n Dictionary,\n DictionarySelector,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getLocalizedMetadata } from '../dictionaryManipulator/getLocalizedMetadata';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n resolveQualifiedDictionary,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport {\n getDictionaryTransformCacheKey,\n readTransformCache,\n writeTransformCache,\n} from './dictionaryTransformCache';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getBasePlugins, getContent } from './getContent/getContent';\nimport { resolveInterpreterLocale } from './resolveInterpreterLocale';\n\n/**\n * Dictionaries whose transform is running. Content is transformed eagerly, so a\n * dictionary reached again through a `nest()` cycle is transformed lazily\n * instead: its nodes then resolve on read, and the cycle unwinds.\n */\nconst transformsInProgress = new WeakSet<object>();\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary (or qualified dictionary group) to transform.\n * @param localeOrSelector The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n // The selector checks stay inline so bundlers can drop the whole\n // qualified-dictionary module when no dictionary declares a qualifier.\n const { locale: requestedLocale, selector } =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? parseDictionarySelector(localeOrSelector)\n : {\n locale: localeOrSelector as LocalesValues | undefined,\n selector: undefined,\n };\n const locale = resolveInterpreterLocale(requestedLocale);\n\n // The base plugins are rebuilt on every call, so they cannot identify\n // themselves — but they are fully determined by the locale, which the key\n // already carries. Only an explicitly passed array needs its own identity.\n const cacheKey = getDictionaryTransformCacheKey(\n locale,\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? getDictionarySelectorCacheKey(selector)\n : '',\n plugins\n );\n\n const cached = readTransformCache<any>(dictionary, cacheKey);\n if (cached.hit) return cached.content;\n\n const appliedPlugins = plugins ?? getBasePlugins(locale);\n\n const resolved =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveQualifiedDictionary(dictionary, selector)\n : (dictionary as Dictionary);\n\n const transformDictionary = (resolvedDictionary: Dictionary) => {\n // Metadata is plain data: read for the locale, never interpreted. Inline\n // flag check, so bundlers drop it when no dictionary declares metadata.\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n selector?.metadataOnly\n ) {\n return getLocalizedMetadata(\n resolvedDictionary.metadata,\n locale,\n internationalization.defaultLocale\n );\n }\n\n const props: NodeProps = {\n dictionaryKey: resolvedDictionary.key,\n dictionaryPath: resolvedDictionary.filePath,\n keyPath: [],\n plugins: appliedPlugins,\n // Attached by the build optimization so `nest()` resolves without the\n // global registry. Undefined in unoptimized builds, where the\n // registry-based resolver is used instead.\n nestedDictionaries: resolvedDictionary.nestedDictionaries,\n eager: !transformsInProgress.has(resolvedDictionary),\n };\n\n transformsInProgress.add(resolvedDictionary);\n\n try {\n return getContent(resolvedDictionary.content, props, appliedPlugins);\n } finally {\n if (props.eager) transformsInProgress.delete(resolvedDictionary);\n }\n };\n\n if (resolved === null)\n return writeTransformCache(dictionary, cacheKey, null)!;\n\n if (Array.isArray(resolved)) {\n return writeTransformCache(\n dictionary,\n cacheKey,\n resolved.map(transformDictionary)\n ) as any;\n }\n\n return writeTransformCache(\n dictionary,\n cacheKey,\n transformDict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{ findPlainDynamicLoader } from "../dictionaryManipulator/plainDynamicLoader.mjs";
1
+ import { resolveDynamicContentAsync } from "../dictionaryManipulator/dynamicDictionary.mjs";
2
2
  import { getDictionarySelectorCacheKey, parseDictionarySelector } from "../dictionaryManipulator/qualifiedDictionary.mjs";
3
- import { isQualifiedDynamicLoaderMap, resolveQualifiedDynamicContentAsync } from "../dictionaryManipulator/qualifiedDynamicLoader.mjs";
4
3
  import { getPluginsCacheKey } from "./dictionaryTransformCache.mjs";
5
4
  import { getDictionary } from "./getDictionary.mjs";
6
5
  import { resolveInterpreterLocaleAsync } from "./resolveInterpreterLocale.mjs";
@@ -14,18 +13,6 @@ import { resolveInterpreterLocaleAsync } from "./resolveInterpreterLocale.mjs";
14
13
  */
15
14
  const contentPromiseCache = /* @__PURE__ */ new Map();
16
15
  /**
17
- * Awaits the chunk a plain loader map holds for `locale` — walking the same
18
- * fallback chain as static mode — and transforms it.
19
- *
20
- * Returns `null` when the map emitted no chunk for the locale nor for any of
21
- * its fallbacks, mirroring how a missing qualified coordinate resolves.
22
- */
23
- const loadPlainChunk = async (dictionaryLoaders, locale, transform) => {
24
- const resolved = findPlainDynamicLoader(dictionaryLoaders, locale);
25
- if (!resolved) return null;
26
- return transform(await resolved.loader());
27
- };
28
- /**
29
16
  * Loads a single locale chunk of a dictionary and returns its transformed
30
17
  * content.
31
18
  *
@@ -57,17 +44,16 @@ const getDictionaryAsync = async (dictionaryLoaders, key, localeOrSelector, plug
57
44
  selector = parsed.selector;
58
45
  } else locale = localeOrSelector;
59
46
  const localeTarget = locale ?? await resolveInterpreterLocaleAsync();
60
- const cacheKey = `${key}_${localeTarget}_${getDictionarySelectorCacheKey(selector)}_${getPluginsCacheKey(plugins)}`;
47
+ const cacheKey = `${key}_${localeTarget}_${process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" ? getDictionarySelectorCacheKey(selector) : ""}_${getPluginsCacheKey(plugins)}`;
61
48
  const cachedContent = contentPromiseCache.get(cacheKey);
62
49
  if (cachedContent) return cachedContent;
63
- const transform = (dictionary) => getDictionary(dictionary, localeTarget, plugins);
64
- const contentPromise = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && isQualifiedDynamicLoaderMap(dictionaryLoaders) ? resolveQualifiedDynamicContentAsync({
50
+ const contentPromise = resolveDynamicContentAsync({
65
51
  loaderMap: dictionaryLoaders,
66
52
  key,
67
53
  locale: localeTarget,
68
54
  selector,
69
- transform
70
- }) : loadPlainChunk(dictionaryLoaders, localeTarget, transform);
55
+ transform: (dictionary, argument) => getDictionary(dictionary, argument, plugins)
56
+ });
71
57
  contentPromiseCache.set(cacheKey, contentPromise);
72
58
  contentPromise.catch(() => contentPromiseCache.delete(cacheKey));
73
59
  return contentPromise;
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionaryAsync.mjs","names":[],"sources":["../../../src/interpreter/getDictionaryAsync.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n findPlainDynamicLoader,\n type PlainDynamicLoaderMap,\n} from '../dictionaryManipulator/plainDynamicLoader';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport {\n isQualifiedDynamicLoaderMap,\n type QualifiedDynamicLoaderMap,\n resolveQualifiedDynamicContentAsync,\n} from '../dictionaryManipulator/qualifiedDynamicLoader';\nimport { getPluginsCacheKey } from './dictionaryTransformCache';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\nimport { resolveInterpreterLocaleAsync } from './resolveInterpreterLocale';\n\n/**\n * Content already resolved for a `key + locale + selector` triple, or the\n * in-flight promise resolving it. Storing the promise itself makes the cache\n * double as an in-flight deduplication table: concurrent calls for the same\n * chunk await one single load.\n */\nconst contentPromiseCache = new Map<string, Promise<unknown>>();\n\n/**\n * Awaits the chunk a plain loader map holds for `locale` — walking the same\n * fallback chain as static mode — and transforms it.\n *\n * Returns `null` when the map emitted no chunk for the locale nor for any of\n * its fallbacks, mirroring how a missing qualified coordinate resolves.\n */\nconst loadPlainChunk = async <T extends Dictionary, Content>(\n dictionaryLoaders: PlainDynamicLoaderMap<T>,\n locale: LocalesValues,\n transform: (dictionary: Dictionary) => Content\n): Promise<Content | null> => {\n const resolved = findPlainDynamicLoader<T>(dictionaryLoaders, locale);\n\n if (!resolved) return null;\n\n return transform(await resolved.loader());\n};\n\n/**\n * Loads a single locale chunk of a dictionary and returns its transformed\n * content.\n *\n * Counterpart of {@link getDictionary} for the per-locale loader maps emitted\n * in `.intlayer/dynamic_dictionaries/`: instead of receiving a dictionary\n * holding every locale, it receives the loader map and awaits only the chunk\n * the requested locale needs.\n *\n * The loader map is either plain (`locale → loader`) or qualified\n * (`locale → qualifierId → loader`, for collections and variants). For a\n * qualified map, only the chunk(s) the selector targets are loaded.\n *\n * Build plugins rewrite every `getIntlayerAsync('key', locale)` call into a\n * `getDictionaryAsync(loaderMap, 'key', locale)` one, so applications call\n * {@link getIntlayerAsync} and never this function directly.\n *\n * @param dictionaryLoaders - Plain or qualified per-locale loader map.\n * @param key - Dictionary key, used to namespace the chunk cache.\n * @param localeOrSelector - The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins - Node transformers. Defaults to the base interpreter set.\n */\nexport const getDictionaryAsync = async <\n const T extends Dictionary,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n dictionaryLoaders: PlainDynamicLoaderMap<T> | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): Promise<\n DeepTransformContent<\n T['content'],\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n >\n> => {\n let locale: LocalesValues | undefined;\n let selector: DictionarySelector | undefined;\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const parsed = parseDictionarySelector<LocalesValues>(localeOrSelector);\n locale = parsed.locale;\n selector = parsed.selector;\n } else {\n // Selectors are unused in this project (build-time flag): the argument can\n // only be a locale, so the selector parsing is dead code.\n locale = localeOrSelector as LocalesValues | undefined;\n }\n\n const localeTarget = locale ?? (await resolveInterpreterLocaleAsync());\n\n const cacheKey = `${key}_${localeTarget}_${getDictionarySelectorCacheKey(\n selector\n )}_${getPluginsCacheKey(plugins)}`;\n\n const cachedContent = contentPromiseCache.get(cacheKey);\n if (cachedContent) return cachedContent as Promise<any>;\n\n const transform = (dictionary: Dictionary) =>\n getDictionary(dictionary, localeTarget, plugins);\n\n const contentPromise =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryLoaders)\n ? resolveQualifiedDynamicContentAsync({\n loaderMap: dictionaryLoaders,\n key,\n locale: localeTarget,\n selector,\n transform,\n })\n : loadPlainChunk(\n dictionaryLoaders as PlainDynamicLoaderMap<T>,\n localeTarget,\n transform\n );\n\n contentPromiseCache.set(cacheKey, contentPromise);\n\n // A rejected load must not stay cached, or every later call replays the\n // same failure without ever retrying the chunk.\n contentPromise.catch(() => contentPromiseCache.delete(cacheKey));\n\n return contentPromise as Promise<any>;\n};\n"],"mappings":";;;;;;;;;;;;;;AAqCA,MAAM,sCAAsB,IAAI,IAA8B;;;;;;;;AAS9D,MAAM,iBAAiB,OACrB,mBACA,QACA,cAC4B;CAC5B,MAAM,WAAW,uBAA0B,mBAAmB,MAAM;CAEpE,IAAI,CAAC,UAAU,OAAO;CAEtB,OAAO,UAAU,MAAM,SAAS,OAAO,CAAC;AAC1C;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,qBAAqB,OAIhC,mBACA,KACA,kBACA,YAOG;CACH,IAAI;CACJ,IAAI;CAEJ,IAAI,QAAQ,IAAI,iCAAiC,SAAS;EACxD,MAAM,SAAS,wBAAuC,gBAAgB;EACtE,SAAS,OAAO;EAChB,WAAW,OAAO;CACpB,OAGE,SAAS;CAGX,MAAM,eAAe,UAAW,MAAM,8BAA8B;CAEpE,MAAM,WAAW,GAAG,IAAI,GAAG,aAAa,GAAG,8BACzC,QACF,EAAE,GAAG,mBAAmB,OAAO;CAE/B,MAAM,gBAAgB,oBAAoB,IAAI,QAAQ;CACtD,IAAI,eAAe,OAAO;CAE1B,MAAM,aAAa,eACjB,cAAc,YAAY,cAAc,OAAO;CAEjD,MAAM,iBACJ,QAAQ,IAAI,iCAAiC,WAC7C,4BAA4B,iBAAiB,IACzC,oCAAoC;EAClC,WAAW;EACX;EACA,QAAQ;EACR;EACA;CACF,CAAC,IACD,eACE,mBACA,cACA,SACF;CAEN,oBAAoB,IAAI,UAAU,cAAc;CAIhD,eAAe,YAAY,oBAAoB,OAAO,QAAQ,CAAC;CAE/D,OAAO;AACT"}
1
+ {"version":3,"file":"getDictionaryAsync.mjs","names":[],"sources":["../../../src/interpreter/getDictionaryAsync.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n type DynamicLoaderMap,\n resolveDynamicContentAsync,\n} from '../dictionaryManipulator/dynamicDictionary';\nimport type { PlainDynamicLoaderMap } from '../dictionaryManipulator/plainDynamicLoader';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type { QualifiedDynamicLoaderMap } from '../dictionaryManipulator/qualifiedDynamicLoader';\nimport { getPluginsCacheKey } from './dictionaryTransformCache';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\nimport { resolveInterpreterLocaleAsync } from './resolveInterpreterLocale';\n\n/**\n * Content already resolved for a `key + locale + selector` triple, or the\n * in-flight promise resolving it. Storing the promise itself makes the cache\n * double as an in-flight deduplication table: concurrent calls for the same\n * chunk await one single load.\n */\nconst contentPromiseCache = new Map<string, Promise<unknown>>();\n\n/**\n * Loads a single locale chunk of a dictionary and returns its transformed\n * content.\n *\n * Counterpart of {@link getDictionary} for the per-locale loader maps emitted\n * in `.intlayer/dynamic_dictionaries/`: instead of receiving a dictionary\n * holding every locale, it receives the loader map and awaits only the chunk\n * the requested locale needs.\n *\n * The loader map is either plain (`locale → loader`) or qualified\n * (`locale → qualifierId → loader`, for collections and variants). For a\n * qualified map, only the chunk(s) the selector targets are loaded.\n *\n * Build plugins rewrite every `getIntlayerAsync('key', locale)` call into a\n * `getDictionaryAsync(loaderMap, 'key', locale)` one, so applications call\n * {@link getIntlayerAsync} and never this function directly.\n *\n * @param dictionaryLoaders - Plain or qualified per-locale loader map.\n * @param key - Dictionary key, used to namespace the chunk cache.\n * @param localeOrSelector - The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins - Node transformers. Defaults to the base interpreter set.\n */\nexport const getDictionaryAsync = async <\n const T extends Dictionary,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n dictionaryLoaders: PlainDynamicLoaderMap<T> | QualifiedDynamicLoaderMap,\n key: string,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): Promise<\n DeepTransformContent<\n T['content'],\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n >\n> => {\n let locale: LocalesValues | undefined;\n let selector: DictionarySelector | undefined;\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const parsed = parseDictionarySelector<LocalesValues>(localeOrSelector);\n locale = parsed.locale;\n selector = parsed.selector;\n } else {\n // Selectors are unused in this project (build-time flag): the argument can\n // only be a locale, so the selector parsing is dead code.\n locale = localeOrSelector as LocalesValues | undefined;\n }\n\n const localeTarget = locale ?? (await resolveInterpreterLocaleAsync());\n\n const selectorCacheKey =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? getDictionarySelectorCacheKey(selector)\n : '';\n const cacheKey = `${key}_${localeTarget}_${selectorCacheKey}_${getPluginsCacheKey(plugins)}`;\n\n const cachedContent = contentPromiseCache.get(cacheKey);\n if (cachedContent) return cachedContent as Promise<any>;\n\n const contentPromise = resolveDynamicContentAsync({\n loaderMap: dictionaryLoaders as DynamicLoaderMap,\n key,\n locale: localeTarget,\n selector,\n transform: (dictionary, argument) =>\n getDictionary(dictionary, argument, plugins),\n });\n\n contentPromiseCache.set(cacheKey, contentPromise);\n\n // A rejected load must not stay cached, or every later call replays the\n // same failure without ever retrying the chunk.\n contentPromise.catch(() => contentPromiseCache.delete(cacheKey));\n\n return contentPromise as Promise<any>;\n};\n"],"mappings":";;;;;;;;;;;;;AAkCA,MAAM,sCAAsB,IAAI,IAA8B;;;;;;;;;;;;;;;;;;;;;;;;AAyB9D,MAAa,qBAAqB,OAIhC,mBACA,KACA,kBACA,YAOG;CACH,IAAI;CACJ,IAAI;CAEJ,IAAI,QAAQ,IAAI,iCAAiC,SAAS;EACxD,MAAM,SAAS,wBAAuC,gBAAgB;EACtE,SAAS,OAAO;EAChB,WAAW,OAAO;CACpB,OAGE,SAAS;CAGX,MAAM,eAAe,UAAW,MAAM,8BAA8B;CAMpE,MAAM,WAAW,GAAG,IAAI,GAAG,aAAa,GAHtC,QAAQ,IAAI,iCAAiC,UACzC,8BAA8B,QAAQ,IACtC,GACsD,GAAG,mBAAmB,OAAO;CAEzF,MAAM,gBAAgB,oBAAoB,IAAI,QAAQ;CACtD,IAAI,eAAe,OAAO;CAE1B,MAAM,iBAAiB,2BAA2B;EAChD,WAAW;EACX;EACA,QAAQ;EACR;EACA,YAAY,YAAY,aACtB,cAAc,YAAY,UAAU,OAAO;CAC/C,CAAC;CAED,oBAAoB,IAAI,UAAU,cAAc;CAIhD,eAAe,YAAY,oBAAoB,OAAO,QAAQ,CAAC;CAE/D,OAAO;AACT"}
@@ -35,8 +35,9 @@ export declare const getFilterMissingTranslationsDictionary: (dictionary: Dictio
35
35
  filePath?: string;
36
36
  componentFilePath?: string;
37
37
  tags?: string[];
38
- item?: number;
38
+ item?: import("@intlayer/types").DictionaryItemId;
39
39
  variant?: import("@intlayer/types").DictionaryVariantValue | import("@intlayer/types").DictionaryVariantValue[];
40
+ metadata?: import("@intlayer/types").DictionaryMetadata;
40
41
  locale?: LocalesValues;
41
42
  contentAutoTransformation?: import("@intlayer/types").ContentAutoTransformation;
42
43
  fill?: import("@intlayer/types").Fill;
@@ -27,8 +27,9 @@ export declare const getFilterTranslationsOnlyDictionary: (dictionary: Dictionar
27
27
  filePath?: string;
28
28
  componentFilePath?: string;
29
29
  tags?: string[];
30
- item?: number;
30
+ item?: import("@intlayer/types").DictionaryItemId;
31
31
  variant?: import("@intlayer/types").DictionaryVariantValue | import("@intlayer/types").DictionaryVariantValue[];
32
+ metadata?: import("@intlayer/types").DictionaryMetadata;
32
33
  locale?: LocalesValues;
33
34
  contentAutoTransformation?: import("@intlayer/types").ContentAutoTransformation;
34
35
  fill?: import("@intlayer/types").Fill;
@@ -19,8 +19,9 @@ export declare const getFilteredLocalesDictionary: (dictionary: Dictionary, loca
19
19
  filePath?: string;
20
20
  componentFilePath?: string;
21
21
  tags?: string[];
22
- item?: number;
22
+ item?: import("@intlayer/types").DictionaryItemId;
23
23
  variant?: import("@intlayer/types").DictionaryVariantValue | import("@intlayer/types").DictionaryVariantValue[];
24
+ metadata?: import("@intlayer/types").DictionaryMetadata;
24
25
  locale?: LocalesValues;
25
26
  contentAutoTransformation?: import("@intlayer/types").ContentAutoTransformation;
26
27
  fill?: import("@intlayer/types").Fill;
@@ -1 +1 @@
1
- {"version":3,"file":"getLocalizedContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getLocalizedContent.ts"],"mappings":";;;;;;;;;;;;qBAqBa,sBACX,UAAU,aACV,UAAU,gBAAgB,iBAAe,MAEnC,GAAC,QACC,GAAC,WACE,WAAS,WACT,kBAUL,qBAAqB;qBAGhB,yBACX,UAAU,YACV,UAAU,eAAa,YAEX,GAAC,QACL,GAAC,WACE,kBACV"}
1
+ {"version":3,"file":"getLocalizedContent.d.ts","names":[],"sources":["../../../src/deepTransformPlugins/getLocalizedContent.ts"],"mappings":";;;;;;;;;;;;qBAsBa,sBACX,UAAU,aACV,UAAU,gBAAgB,iBAAe,MAEnC,GAAC,QACC,GAAC,WACE,WAAS,WACT,kBAUL,qBAAqB;qBAGhB,yBACX,UAAU,YACV,UAAU,eAAa,YAEX,GAAC,QACL,GAAC,WACE,kBACV"}
@@ -0,0 +1,159 @@
1
+ import { PlainDynamicLoaderMap } from "./plainDynamicLoader.js";
2
+ import { CollectedChunk, QualifiedDynamicLoaderMap } from "./qualifiedDynamicLoader.js";
3
+ import { Dictionary, DictionarySelector, ProviderVariantBase } from "@intlayer/types/dictionary";
4
+ import { LocalesValues } from "@intlayer/types/module_augmentation";
5
+ /**
6
+ * Default export of a generated dynamic entry point: a plain `locale → loader`
7
+ * map, or a qualified one (collections / variants).
8
+ */
9
+ export type DynamicLoaderMap<T extends Dictionary = Dictionary> = PlainDynamicLoaderMap<T> | QualifiedDynamicLoaderMap;
10
+ /** The effective locale and selector of a dictionary read. */
11
+ export type DictionaryRead = {
12
+ locale: LocalesValues;
13
+ selector?: DictionarySelector;
14
+ };
15
+ /**
16
+ * Turns a loaded chunk into content — a binding's `getDictionary`, so its
17
+ * plugins apply. Receives the bare locale, or `{ locale, metadataOnly }`.
18
+ */
19
+ export type DynamicChunkTransform<Content> = (dictionary: Dictionary, argument: LocalesValues | DictionarySelector) => Content;
20
+ /** Result of a dynamic read: an entry, a collection, or a missed coordinate. */
21
+ export type DynamicContent<Content> = Content | Content[] | null;
22
+ /** Everything a dynamic read needs, besides how chunks are loaded. */
23
+ export type DynamicReadParams<Content> = DictionaryRead & {
24
+ loaderMap: DynamicLoaderMap;
25
+ /** Dictionary key, namespacing the chunk cache keys. */
26
+ key: string;
27
+ transform: DynamicChunkTransform<Content>;
28
+ };
29
+ /**
30
+ * Resolves the locale and selector of a dynamic dictionary read: the call-site
31
+ * argument wins, then the provider context (locale and ambient variant), then
32
+ * the interpreter locale. Every binding's dynamic hook goes through it, so
33
+ * static and dynamic reads resolve identically.
34
+ *
35
+ * Subscription-based bindings call it again on each locale change with the new
36
+ * `contextLocale`, so a locale pinned at the call site stays pinned and an
37
+ * unpinned one follows the switch.
38
+ */
39
+ export declare const resolveDictionaryRead: (params: {
40
+ localeOrSelector?: LocalesValues | DictionarySelector | null;
41
+ contextLocale?: LocalesValues;
42
+ contextVariant?: ProviderVariantBase;
43
+ dictionaryKey: string;
44
+ }) => DictionaryRead;
45
+ /**
46
+ * The argument a loaded chunk is transformed with: its locale, plus
47
+ * `metadataOnly` when the read requests metadata. The other selector dimensions
48
+ * were already applied by picking the chunk.
49
+ *
50
+ * @param locale - The read's locale; `undefined` lets the binding's
51
+ * `useDictionary` follow its context locale.
52
+ * @param selector - The read's selector, if any.
53
+ */
54
+ export declare const getDynamicChunkArgument: <L extends LocalesValues | undefined = LocalesValues>(locale: L, selector: DictionarySelector | undefined) => L | DictionarySelector;
55
+ /**
56
+ * Lists the chunks a read targets without loading them — lets a binding warm
57
+ * its chunk cache ahead of render.
58
+ *
59
+ * @returns The targeted chunks, empty when a required coordinate is absent.
60
+ */
61
+ export declare const getDynamicChunks: (loaderMap: DynamicLoaderMap, key: string, locale: LocalesValues, selector: DictionarySelector | undefined) => CollectedChunk[];
62
+ /**
63
+ * Loads the raw chunk a plain loader map serves for a locale — same fallback
64
+ * chain and preload as every other dynamic read — for the `useDictionaryAsync`
65
+ * bindings, which interpret it with their own `useDictionary`.
66
+ *
67
+ * @returns The chunk, or `undefined` when the map holds none for the locale
68
+ * nor for any of its fallbacks.
69
+ */
70
+ export declare const loadDynamicDictionary: <T extends Dictionary>(loaderMap: PlainDynamicLoaderMap<T>, locale: LocalesValues) => Promise<T | undefined>;
71
+ /**
72
+ * Resolves a dynamic read synchronously, loading only the chunk(s) it targets
73
+ * through `loadChunk` — a suspender cache that throws while a chunk is pending.
74
+ *
75
+ * Every pending loader is started before the first chunk is read, so sibling
76
+ * chunks load in parallel rather than waterfalling. Preloaded chunks are read
77
+ * directly, never through `loadChunk`, which would suspend for one microtask.
78
+ *
79
+ * @param params.loadChunk - Reads a started chunk, suspending until it resolves.
80
+ */
81
+ export declare const resolveDynamicContent: <Content>(params: DynamicReadParams<Content> & {
82
+ loadChunk: (cacheKey: string, promise: Promise<Dictionary>) => Dictionary;
83
+ }) => DynamicContent<Content>;
84
+ /**
85
+ * Resolves a dynamic read, awaiting only the chunk(s) it targets.
86
+ */
87
+ export declare const resolveDynamicContentAsync: <Content>(params: DynamicReadParams<Content>) => Promise<DynamicContent<Content>>;
88
+ /** A dynamic read handed to a {@link DynamicContentStore}. */
89
+ export type DynamicStoreRead = DictionaryRead & {
90
+ loaderMap: DynamicLoaderMap;
91
+ key: string;
92
+ };
93
+ /** Settled content of a read; wrapped, since `null` is a valid content. */
94
+ export type SettledDynamicContent<Content> = {
95
+ content: DynamicContent<Content>;
96
+ };
97
+ /** What a {@link DynamicReader} resolves a read from, besides the map. */
98
+ export type DynamicReadContext = {
99
+ localeOrSelector?: LocalesValues | DictionarySelector | null;
100
+ contextLocale?: LocalesValues;
101
+ contextVariant?: ProviderVariantBase;
102
+ };
103
+ /**
104
+ * Reads one dictionary across context changes: returns the content when it is
105
+ * available synchronously, else loads it and calls `onLoad` (or `onError`) —
106
+ * unless a newer read of the same reader superseded it meanwhile. Without
107
+ * `onError`, a failed load surfaces as an unhandled rejection.
108
+ */
109
+ export type DynamicReader<Content> = (context: DynamicReadContext, onLoad: (content: DynamicContent<Content>) => void, onError?: (error: unknown) => void) => SettledDynamicContent<Content> | undefined;
110
+ /**
111
+ * Content cache of the bindings that re-render on a notification instead of
112
+ * suspending (vanilla, Lit, Svelte, Vue, Angular).
113
+ */
114
+ export type DynamicContentStore<Content> = {
115
+ /**
116
+ * The content of a read when it is available without loading — loaded
117
+ * before, or preloaded by the entry point — else `undefined`.
118
+ */
119
+ peek: (read: DynamicStoreRead) => SettledDynamicContent<Content> | undefined;
120
+ /** Loads the content of a read, sharing one load between concurrent reads. */
121
+ load: (read: DynamicStoreRead) => Promise<DynamicContent<Content>>;
122
+ /** Creates the reader of one hook call (see {@link DynamicReader}). */
123
+ createReader: (loaderMap: DynamicLoaderMap, dictionaryKey: string) => DynamicReader<Content>;
124
+ };
125
+ /**
126
+ * Creates the content cache of a binding. Entries are kept per loader map, so
127
+ * a hot-reloaded entry point (a new map object) never serves stale content.
128
+ *
129
+ * @param transform - The binding's `getDictionary`, applied to every chunk.
130
+ */
131
+ export declare const createDynamicContentStore: <Content>(transform: DynamicChunkTransform<Content>) => DynamicContentStore<Content>;
132
+ /**
133
+ * Inert stand-in for content still loading: any property access, call or
134
+ * construction returns it again, and string coercion yields `''`. It never
135
+ * passes for a thenable, an iterable, a DOM node or a Lit template part, so
136
+ * renderers print nothing instead of crashing.
137
+ */
138
+ export declare const loadingContentPlaceholder: any;
139
+ /** Chunk cache read the Suspense way (see {@link createChunkSuspenseCache}). */
140
+ export type ChunkSuspenseCache = {
141
+ /** Whether `cacheKey` holds an entry, pending or settled. */
142
+ has: (cacheKey: string) => boolean;
143
+ /**
144
+ * Reads `cacheKey`, started from `promise` on the first read: throws the
145
+ * pending promise (Suspense) or the rejection until it resolves.
146
+ */
147
+ read: <T>(cacheKey: string, promise: Promise<T>) => T;
148
+ /**
149
+ * Starts `cacheKey` ahead of render. The returned promise settles — never
150
+ * rejects — once a `read` no longer suspends.
151
+ */
152
+ preload: (cacheKey: string, loader: () => Promise<unknown>) => Promise<void>;
153
+ };
154
+ /**
155
+ * Creates the chunk cache of a Suspense binding (React, Preact): the
156
+ * `loadChunk` of {@link resolveDynamicContent}.
157
+ */
158
+ export declare const createChunkSuspenseCache: () => ChunkSuspenseCache;
159
+ //# sourceMappingURL=dynamicDictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamicDictionary.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/dynamicDictionary.ts"],"mappings":";;;;;;;;YA+BY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;;;;;;qBAOpD,gCAA+B"}
@@ -0,0 +1,14 @@
1
+ import { DictionaryMetadata } from "@intlayer/types/dictionary";
2
+ import { LocalesValues } from "@intlayer/types/module_augmentation";
3
+ /**
4
+ * Returns the metadata of a dictionary for a locale. The build merges
5
+ * per-locale declarations under a translation node (`t({ en: {…}, fr: {…} })`),
6
+ * read for `locale`, else `fallbackLocale`; any other metadata applies to
7
+ * every locale.
8
+ *
9
+ * @param metadata - The `metadata` of a dictionary or of a collection entry.
10
+ * @param locale - The locale to read.
11
+ * @param fallbackLocale - The locale read when `locale` declares none.
12
+ */
13
+ export declare const getLocalizedMetadata: (metadata: unknown, locale: LocalesValues, fallbackLocale?: LocalesValues) => DictionaryMetadata;
14
+ //# sourceMappingURL=getLocalizedMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLocalizedMetadata.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/getLocalizedMetadata.ts"],"mappings":";;;;;;;;;;;;qBAmBa,uBAAoB,mBACd,QACT,eAAa,iBACJ,kBAChB"}
@@ -1,7 +1,9 @@
1
+ import { ChunkSuspenseCache, DictionaryRead, DynamicChunkTransform, DynamicContent, DynamicContentStore, DynamicLoaderMap, DynamicReadContext, DynamicReadParams, DynamicReader, DynamicStoreRead, SettledDynamicContent, createChunkSuspenseCache, createDynamicContentStore, getDynamicChunkArgument, getDynamicChunks, loadDynamicDictionary, loadingContentPlaceholder, resolveDictionaryRead, resolveDynamicContent, resolveDynamicContentAsync } from "./dynamicDictionary.js";
1
2
  import { editDictionaryByKeyPath } from "./editDictionaryByKeyPath.js";
2
3
  import { getContentNodeByKeyPath } from "./getContentNodeByKeyPath.js";
3
4
  import { getDefaultNode } from "./getDefaultNode.js";
4
5
  import { getEmptyNode } from "./getEmptyNode.js";
6
+ import { getLocalizedMetadata } from "./getLocalizedMetadata.js";
5
7
  import { NestedFieldReferences, getNestedDictionaryGraph, getNestedDictionaryKeys, getNestedDictionaryReferences } from "./getNestedDictionaryReferences.js";
6
8
  import { getNodeChildren } from "./getNodeChildren.js";
7
9
  import { getNodeType } from "./getNodeType.js";
@@ -11,10 +13,10 @@ import { normalizeDictionaries, normalizeDictionary } from "./normalizeDictionar
11
13
  import { orderDictionaries } from "./orderDictionaries.js";
12
14
  import { PlainDynamicLoaderMap, ResolvedDynamicLoader, findPlainDynamicLoader, resolvePlainDynamicLoader } from "./plainDynamicLoader.js";
13
15
  import { PRELOADED_DYNAMIC_KEY, PreloadableDynamicLoaderMap, PreloadedDynamicEntry, getPreloadedDictionary } from "./preloadedDynamicLoader.js";
14
- import { COMPOSITE_ID_SEPARATOR, DEFAULT_VARIANT_ID, getDictionarySelectorCacheKey, isQualifiedDictionaryGroup, parseDictionarySelector, reconstructQualifiedEntry, resolveDictionaryArgument, resolveEffectiveVariantId, resolveProviderVariant, resolveQualifiedDictionary, serializeVariant, serializeVariantChain } from "./qualifiedDictionary.js";
15
- import { QUALIFIER_ORDER, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getVariantIds } from "./qualifiedDictionaryDeclaration.js";
16
- import { CollectedChunk, DynamicDictionaryLoader, QUALIFIER_DYNAMIC_TYPES_KEY, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, getQualifiedDynamicChunks, isQualifiedDynamicLoaderMap, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync } from "./qualifiedDynamicLoader.js";
16
+ import { COMPOSITE_ID_SEPARATOR, DEFAULT_VARIANT_ID, MatchedQualifiedEntryIds, compareItemIds, compareItemSegments, getDictionarySelectorCacheKey, isQualifiedDictionaryGroup, matchQualifiedEntryIds, parseDictionarySelector, parseItemId, parseItemSegment, reconstructQualifiedEntry, resolveDictionaryArgument, resolveEffectiveVariantId, resolveProviderVariant, resolveQualifiedDictionary, serializeItem, serializeVariant, serializeVariantChain } from "./qualifiedDictionary.js";
17
+ import { QUALIFIER_ORDER, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getVariantIds, isDeclaredItem } from "./qualifiedDictionaryDeclaration.js";
18
+ import { CollectedChunk, CollectedChunks, DynamicDictionaryLoader, QUALIFIER_DYNAMIC_METADATA_KEY, QUALIFIER_DYNAMIC_TYPES_KEY, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, collectQualifiedChunks, isQualifiedDynamicLoaderMap, readMetadataIndex } from "./qualifiedDynamicLoader.js";
17
19
  import { removeContentNodeByKeyPath } from "./removeContentNodeByKeyPath.js";
18
20
  import { renameContentNodeByKeyPath } from "./renameContentNodeByKeyPath.js";
19
21
  import { updateNodeChildren } from "./updateNodeChildren.js";
20
- export { COMPOSITE_ID_SEPARATOR, CollectedChunk, DEFAULT_VARIANT_ID, DynamicDictionaryLoader, NestedFieldReferences, PRELOADED_DYNAMIC_KEY, PlainDynamicLoaderMap, PreloadableDynamicLoaderMap, PreloadedDynamicEntry, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, ResolvedDynamicLoader, editDictionaryByKeyPath, findPlainDynamicLoader, getContentNodeByKeyPath, getDefaultNode, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getEmptyNode, getNestedDictionaryGraph, getNestedDictionaryKeys, getNestedDictionaryReferences, getNodeChildren, getNodeType, getPreloadedDictionary, getQualifiedDynamicChunks, getVariantIds, isQualifiedDictionaryGroup, isQualifiedDynamicLoaderMap, mergeDictionaries, mergeQualifiedDictionaries, normalizeDictionaries, normalizeDictionary, orderDictionaries, parseDictionarySelector, reconstructQualifiedEntry, removeContentNodeByKeyPath, renameContentNodeByKeyPath, resolveDictionaryArgument, resolveEffectiveVariantId, resolvePlainDynamicLoader, resolveProviderVariant, resolveQualifiedDictionary, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync, serializeVariant, serializeVariantChain, updateNodeChildren };
22
+ export { COMPOSITE_ID_SEPARATOR, ChunkSuspenseCache, CollectedChunk, CollectedChunks, DEFAULT_VARIANT_ID, DictionaryRead, DynamicChunkTransform, DynamicContent, DynamicContentStore, DynamicDictionaryLoader, DynamicLoaderMap, DynamicReadContext, DynamicReadParams, DynamicReader, DynamicStoreRead, MatchedQualifiedEntryIds, NestedFieldReferences, PRELOADED_DYNAMIC_KEY, PlainDynamicLoaderMap, PreloadableDynamicLoaderMap, PreloadedDynamicEntry, QUALIFIER_DYNAMIC_METADATA_KEY, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, ResolvedDynamicLoader, SettledDynamicContent, collectQualifiedChunks, compareItemIds, compareItemSegments, createChunkSuspenseCache, createDynamicContentStore, editDictionaryByKeyPath, findPlainDynamicLoader, getContentNodeByKeyPath, getDefaultNode, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDynamicChunkArgument, getDynamicChunks, getEmptyNode, getLocalizedMetadata, getNestedDictionaryGraph, getNestedDictionaryKeys, getNestedDictionaryReferences, getNodeChildren, getNodeType, getPreloadedDictionary, getVariantIds, isDeclaredItem, isQualifiedDictionaryGroup, isQualifiedDynamicLoaderMap, loadDynamicDictionary, loadingContentPlaceholder, matchQualifiedEntryIds, mergeDictionaries, mergeQualifiedDictionaries, normalizeDictionaries, normalizeDictionary, orderDictionaries, parseDictionarySelector, parseItemId, parseItemSegment, readMetadataIndex, reconstructQualifiedEntry, removeContentNodeByKeyPath, renameContentNodeByKeyPath, resolveDictionaryArgument, resolveDictionaryRead, resolveDynamicContent, resolveDynamicContentAsync, resolveEffectiveVariantId, resolvePlainDynamicLoader, resolveProviderVariant, resolveQualifiedDictionary, serializeItem, serializeVariant, serializeVariantChain, updateNodeChildren };
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeDictionary.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/normalizeDictionary.ts"],"mappings":";;qBAOa,sBAAmB,YAClB,YAAU,eACP,mBACd;qBAmCU,wBAAqB,cAClB,cAAY,eACX,mBACd"}
1
+ {"version":3,"file":"normalizeDictionary.d.ts","names":[],"sources":["../../../src/dictionaryManipulator/normalizeDictionary.ts"],"mappings":";;qBAOa,sBAAmB,YAClB,YAAU,eACP,mBACd;qBAuCU,wBAAqB,cAClB,cAAY,eACX,mBACd"}