@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
@@ -53,6 +53,43 @@ const serializeVariant = (variant) => {
53
53
  if (typeof variant === "string") return encodeSegmentText(variant, SEGMENT_UNSAFE_CHARS);
54
54
  return Object.keys(variant).sort().map((field) => `${encodeSegmentText(field, COMPONENT_UNSAFE_CHARS)}=${encodeSegmentText(String(variant[field]), COMPONENT_UNSAFE_CHARS)}`).join("&");
55
55
  };
56
+ /** Reverses `encodeSegmentText`: decodes the `%XXXX` runs and the `%` stand-in. */
57
+ const decodeSegmentText = (segment) => segment === "%" ? "" : segment.replace(/%([0-9A-F]{4})/g, (_match, charCode) => String.fromCharCode(Number.parseInt(charCode, 16)));
58
+ /**
59
+ * Normalizes a raw item id: a string holding a number's exact canonical form
60
+ * becomes that number (`'2'` → `2`), anything else stays a string id
61
+ * (`'007'`, `'65f1c0a2'`, `'Infinity'`).
62
+ *
63
+ * @param rawItem - The item id as text (a composite id segment, a form input…).
64
+ */
65
+ const parseItemId = (rawItem) => {
66
+ const numericItem = Number(rawItem);
67
+ return rawItem !== "" && Number.isFinite(numericItem) && String(numericItem) === rawItem ? numericItem : rawItem;
68
+ };
69
+ /**
70
+ * Canonical serialization of an item id — the item segment of a composite id,
71
+ * the chunk directory name in dynamic mode, and the runtime matching key.
72
+ *
73
+ * A number and its digits serialize identically (`2` and `'2'` → `'2'`).
74
+ * Characters unsafe in file paths or generated code are percent-encoded like
75
+ * variant names, so database ids (hex, UUID, nanoid…) are kept verbatim.
76
+ */
77
+ const serializeItem = (item) => encodeSegmentText(String(item), SEGMENT_UNSAFE_CHARS);
78
+ /** Decodes the item segment of a composite id back into its item id. */
79
+ const parseItemSegment = (segment) => parseItemId(decodeSegmentText(segment));
80
+ /**
81
+ * Collection order of two item ids: numeric ids by value first, then string
82
+ * ids by UTF-16 code unit (locale-independent, so every build agrees).
83
+ */
84
+ const compareItemIds = (leftItem, rightItem) => {
85
+ if (typeof leftItem === "number" && typeof rightItem === "number") return leftItem - rightItem;
86
+ if (typeof leftItem === "number") return -1;
87
+ if (typeof rightItem === "number") return 1;
88
+ if (leftItem === rightItem) return 0;
89
+ return leftItem < rightItem ? -1 : 1;
90
+ };
91
+ /** Collection order of two serialized item segments (see {@link compareItemIds}). */
92
+ const compareItemSegments = (leftSegment, rightSegment) => compareItemIds(parseItemSegment(leftSegment), parseItemSegment(rightSegment));
56
93
  /**
57
94
  * Serializes the variant coordinate of a selector into the ordered list of
58
95
  * candidate ids to try, so a single value and a preference chain share one code
@@ -101,7 +138,7 @@ const compositeIdMatchesSelector = (compositeId, qualifierTypes, selector, effec
101
138
  const segments = compositeId.split("/");
102
139
  return qualifierTypes.every((qualifierType, index) => {
103
140
  if (qualifierType === "variant") return segments[index] === effectiveVariantId;
104
- return selector?.item === void 0 || segments[index] === String(selector.item);
141
+ return selector?.item === void 0 || segments[index] === serializeItem(selector.item);
105
142
  });
106
143
  };
107
144
  /**
@@ -119,7 +156,8 @@ const isQualifiedDictionaryGroup = (value) => typeof value === "object" && value
119
156
  * `{ key, content, variant?, item? }` shape, even though the stored format no
120
157
  * longer duplicates those fields per entry. The `variant` coordinate stays in
121
158
  * its serialized (encoded) form, e.g. `'id=abc&userId=123'` — matching happens
122
- * on the composite id segments, never on this reconstructed field.
159
+ * on the composite id segments, never on this reconstructed field. The `item`
160
+ * coordinate is decoded back to its id (`2`, `'65f1c0a2'`).
123
161
  */
124
162
  const reconstructQualifiedEntry = (group, compositeId) => {
125
163
  const segments = compositeId.split("/");
@@ -127,9 +165,11 @@ const reconstructQualifiedEntry = (group, compositeId) => {
127
165
  key: group.key,
128
166
  content: group.content[compositeId]
129
167
  };
168
+ const entryMetadata = group.metadata?.[compositeId];
169
+ if (entryMetadata !== void 0) entry.metadata = entryMetadata;
130
170
  group.qualifierTypes.forEach((qualifierType, index) => {
131
171
  if (qualifierType === "variant") entry.variant = segments[index];
132
- else if (qualifierType === "item") entry.item = Number(segments[index]);
172
+ else if (qualifierType === "item") entry.item = parseItemSegment(segments[index] ?? "");
133
173
  });
134
174
  return entry;
135
175
  };
@@ -138,7 +178,8 @@ const reconstructQualifiedEntry = (group, compositeId) => {
138
178
  * across every declared dimension.
139
179
  *
140
180
  * - Plain dictionary → returned as-is (selector ignored)
141
- * - `item` declared but not selected → every matching entry ordered by index
181
+ * - `item` declared but not selected → every matching entry, in collection
182
+ * order (see `compareItemIds`)
142
183
  * - `item` selected → the matching entry or null
143
184
  * - `variant` defaults to the `default` entry when not selected, and falls back
144
185
  * to it when the selected variant declares no entry of its own; an object
@@ -150,14 +191,34 @@ const reconstructQualifiedEntry = (group, compositeId) => {
150
191
  */
151
192
  const resolveQualifiedDictionary = (dictionaryOrGroup, selector) => {
152
193
  if (!isQualifiedDictionaryGroup(dictionaryOrGroup)) return dictionaryOrGroup;
153
- const { qualifierTypes, content } = dictionaryOrGroup;
194
+ const { itemAxisOpen, matchedIds } = matchQualifiedEntryIds(Object.keys(dictionaryOrGroup.content), dictionaryOrGroup.qualifierTypes, selector);
195
+ const matchedEntries = matchedIds.map((compositeId) => reconstructQualifiedEntry(dictionaryOrGroup, compositeId));
196
+ if (itemAxisOpen) return matchedEntries;
197
+ return matchedEntries[0] ?? null;
198
+ };
199
+ /**
200
+ * Selects the composite ids a selector targets across every declared
201
+ * dimension — the matching shared by the static resolver and the dynamic
202
+ * metadata index, so both modes resolve the same entries.
203
+ *
204
+ * @param compositeIds - Every composite id the key declares.
205
+ * @param qualifierTypes - The key's dimensions, in canonical order.
206
+ * @param selector - The selector splitting the dimensions.
207
+ */
208
+ const matchQualifiedEntryIds = (compositeIds, qualifierTypes, selector) => {
154
209
  const itemAxisOpen = qualifierTypes.includes("item") && selector?.item === void 0;
155
- const compositeIds = Object.keys(content);
156
210
  const variantIndex = qualifierTypes.indexOf("variant");
211
+ const itemIndex = qualifierTypes.indexOf("item");
157
212
  const effectiveVariantId = variantIndex === -1 ? DEFAULT_VARIANT_ID : resolveEffectiveVariantId(serializeVariantChain(selector?.variant), (variantId) => compositeIds.some((compositeId) => compositeId.split("/")[variantIndex] === variantId));
158
- const matchedEntries = compositeIds.filter((compositeId) => compositeIdMatchesSelector(compositeId, qualifierTypes, selector, effectiveVariantId)).map((compositeId) => reconstructQualifiedEntry(dictionaryOrGroup, compositeId));
159
- if (itemAxisOpen) return matchedEntries.sort((left, right) => (left.item ?? 0) - (right.item ?? 0));
160
- return matchedEntries[0] ?? null;
213
+ const matchedIds = compositeIds.filter((compositeId) => compositeIdMatchesSelector(compositeId, qualifierTypes, selector, effectiveVariantId));
214
+ if (itemAxisOpen) {
215
+ const getItemSegment = (compositeId) => compositeId.split("/")[itemIndex] ?? "";
216
+ matchedIds.sort((left, right) => compareItemSegments(getItemSegment(left), getItemSegment(right)));
217
+ }
218
+ return {
219
+ itemAxisOpen,
220
+ matchedIds
221
+ };
161
222
  };
162
223
  /**
163
224
  * Splits the second argument of `getIntlayer` / `getDictionary` into the
@@ -221,16 +282,17 @@ const resolveDictionaryArgument = (params) => {
221
282
  };
222
283
  };
223
284
  /**
224
- * Builds a stable string identity of a selector (excluding `locale`), suitable
225
- * for cache keys and memoization dependencies.
285
+ * Builds a stable string identity of a selector (excluding `locale`, and the
286
+ * dimensions left `undefined`), suitable for cache keys and memoization
287
+ * dependencies.
226
288
  */
227
289
  const getDictionarySelectorCacheKey = (selector) => {
228
290
  if (!selector) return "";
229
- return Object.keys(selector).filter((selectorKey) => selectorKey !== "locale").sort().map((selectorKey) => {
291
+ return Object.keys(selector).filter((selectorKey) => selectorKey !== "locale" && selector[selectorKey] !== void 0).sort().map((selectorKey) => {
230
292
  const value = selector[selectorKey];
231
293
  return `${selectorKey}:${selectorKey === "variant" ? serializeVariantChain(value).join(",") : String(value)}`;
232
294
  }).join("|");
233
295
  };
234
296
 
235
- export { COMPOSITE_ID_SEPARATOR, DEFAULT_VARIANT_ID, getDictionarySelectorCacheKey, isQualifiedDictionaryGroup, parseDictionarySelector, reconstructQualifiedEntry, resolveDictionaryArgument, resolveEffectiveVariantId, resolveProviderVariant, resolveQualifiedDictionary, serializeVariant, serializeVariantChain };
297
+ export { COMPOSITE_ID_SEPARATOR, DEFAULT_VARIANT_ID, compareItemIds, compareItemSegments, getDictionarySelectorCacheKey, isQualifiedDictionaryGroup, matchQualifiedEntryIds, parseDictionarySelector, parseItemId, parseItemSegment, reconstructQualifiedEntry, resolveDictionaryArgument, resolveEffectiveVariantId, resolveProviderVariant, resolveQualifiedDictionary, serializeItem, serializeVariant, serializeVariantChain };
236
298
  //# sourceMappingURL=qualifiedDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"qualifiedDictionary.mjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionaryQualifierType,\n DictionarySelector,\n DictionaryVariantChain,\n DictionaryVariantValue,\n ProviderVariantBase,\n ProviderVariantMap,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Separator joining per-dimension ids into a composite entry id. Also used as\n * the chunk path separator in dynamic mode.\n */\nexport const COMPOSITE_ID_SEPARATOR = '/';\n\n/**\n * Identity of the implicit fallback variant. A selector that pins no variant\n * resolves to it, and a variant that declares no entry of its own falls back to\n * it — so a key only has to ship the entries that actually differ.\n */\nexport const DEFAULT_VARIANT_ID = 'default';\n\n/**\n * Characters kept verbatim in an encoded qualifier segment. Everything else is\n * percent-encoded so a segment can never contain the composite-id separator\n * (`/`), path-hostile characters (`\\` `:` `*` `?` `\"` `<` `>` `|`, control\n * chars), or characters that would break the generated loader modules (`'`).\n */\nconst SEGMENT_UNSAFE_CHARS = /[^A-Za-z0-9._&=-]/g;\n\n/**\n * Stricter set for the components of an object variant: also encodes `&` and\n * `=` so the `field=value&field=value` serialization stays unambiguous.\n */\nconst COMPONENT_UNSAFE_CHARS = /[^A-Za-z0-9._-]/g;\n\n/** Percent-encodes one UTF-16 code unit as a fixed-width `%XXXX` run. */\nconst percentEncodeChar = (char: string): string =>\n `%${char.charCodeAt(0).toString(16).toUpperCase().padStart(4, '0')}`;\n\nconst encodeSegmentText = (raw: string, unsafeChars: RegExp): string => {\n // Bare '%' cannot be produced by encoding (every encoded run is %XXXX),\n // so it is a safe stand-in for the empty string.\n if (raw === '') return '%';\n\n const encoded = raw.replace(unsafeChars, percentEncodeChar);\n\n // '.' and '..' are path navigation on every filesystem — encode the dots.\n if (encoded === '.' || encoded === '..') {\n return encoded.replace(/\\./g, '%002E');\n }\n\n return encoded;\n};\n\n/**\n * Canonical serialization of a single variant value into its identity string —\n * the variant segment of a composite id, the chunk directory name in dynamic\n * mode, and the runtime matching key.\n *\n * - `undefined` → `'default'` (the implicit fallback variant)\n * - a string → the string itself (a named variant)\n * - an object → its sorted `key=value` pairs joined by `&`\n * (e.g. `{ userId: '123', id: 'abc' }` → `'id=abc&userId=123'`)\n *\n * Characters that are unsafe in file paths or generated code are\n * percent-encoded (fixed-width `%XXXX` runs, injective). Common names —\n * letters, digits, `-` `_` `.` — are left untouched. Both the declaration and\n * the selector go through this function, so encoding never affects matching.\n *\n * Two variants resolve to the same entry iff their serializations are equal, so\n * an object variant in a selector must equal the one declared on the dictionary.\n */\nexport const serializeVariant = (\n variant: DictionaryVariantValue | undefined\n): string => {\n if (variant === undefined) return DEFAULT_VARIANT_ID;\n if (typeof variant === 'string') {\n return encodeSegmentText(variant, SEGMENT_UNSAFE_CHARS);\n }\n\n return Object.keys(variant)\n .sort()\n .map(\n (field) =>\n `${encodeSegmentText(field, COMPONENT_UNSAFE_CHARS)}=${encodeSegmentText(String(variant[field]), COMPONENT_UNSAFE_CHARS)}`\n )\n .join('&');\n};\n\n/**\n * Serializes the variant coordinate of a selector into the ordered list of\n * candidate ids to try, so a single value and a preference chain share one code\n * path downstream.\n *\n * - `undefined` → `['default']`\n * - a single value → its one serialization\n * - a chain → one serialization per entry, order preserved\n *\n * An empty chain is treated as \"no variant pinned\" (`['default']`) rather than\n * as an unsatisfiable request.\n */\nexport const serializeVariantChain = (\n variant: DictionaryVariantChain | undefined\n): string[] => {\n if (!Array.isArray(variant)) {\n return [serializeVariant(variant as DictionaryVariantValue | undefined)];\n }\n\n if (variant.length === 0) return [DEFAULT_VARIANT_ID];\n\n return variant.map(serializeVariant);\n};\n\n/**\n * Resolves the variant id a selector actually targets among the ids a key\n * declares — the sparse-override fallback.\n *\n * Candidates are tried in order and the first one the key declares wins.\n * Otherwise the key falls back to its `default` entry, so a variant only has to\n * be declared where its wording differs. When the key declares no `default`\n * either, the first candidate is returned unchanged and the caller resolves to\n * `null` / `[]`.\n *\n * @param requestedVariantIds - The serialized ids the selector asks for, in\n * preference order (a single value is a 1-element\n * list).\n * @param isVariantIdDeclared - Whether the key declares an entry for an id.\n */\nexport const resolveEffectiveVariantId = (\n requestedVariantIds: string[],\n isVariantIdDeclared: (variantId: string) => boolean\n): string => {\n for (const requestedVariantId of requestedVariantIds) {\n if (isVariantIdDeclared(requestedVariantId)) return requestedVariantId;\n }\n\n return isVariantIdDeclared(DEFAULT_VARIANT_ID)\n ? DEFAULT_VARIANT_ID\n : (requestedVariantIds[0] ?? DEFAULT_VARIANT_ID);\n};\n\n/**\n * Tests whether a composite entry id matches a selector across every declared\n * dimension. Segments are compared in their encoded form (both the stored id\n * and the selector go through {@link serializeVariant}). The `item` dimension\n * matches any value when the selector does not provide one (open collection\n * axis); the `variant` dimension is compared against the already-resolved\n * effective id, so the fallback is applied consistently across dimensions.\n */\nconst compositeIdMatchesSelector = (\n compositeId: string,\n qualifierTypes: DictionaryQualifierType[],\n selector: DictionarySelector | undefined,\n effectiveVariantId: string\n): boolean => {\n const segments = compositeId.split(COMPOSITE_ID_SEPARATOR);\n\n return qualifierTypes.every((qualifierType, index) => {\n if (qualifierType === 'variant') {\n return segments[index] === effectiveVariantId;\n }\n\n // qualifierType === 'item'\n return (\n selector?.item === undefined || segments[index] === String(selector.item)\n );\n });\n};\n\n/**\n * Type guard discriminating a `QualifiedDictionaryGroup` (merge output of a\n * qualified key) from a plain `Dictionary`. Both carry a `content` field; only\n * the group declares `qualifierTypes`, which is therefore the discriminator.\n */\nexport const isQualifiedDictionaryGroup = (\n value: unknown\n): value is QualifiedDictionaryGroup =>\n typeof value === 'object' &&\n value !== null &&\n 'qualifierTypes' in value &&\n Array.isArray((value as { qualifierTypes: unknown }).qualifierTypes) &&\n 'content' in value;\n\n/**\n * Reconstructs a resolvable {@link Dictionary} from a single entry of a\n * qualified group: the content node stored under its composite id, plus the\n * qualifier coordinates decoded from that id (`variant`, `item`).\n *\n * This keeps the resolver's transform code unchanged: it still sees a\n * `{ key, content, variant?, item? }` shape, even though the stored format no\n * longer duplicates those fields per entry. The `variant` coordinate stays in\n * its serialized (encoded) form, e.g. `'id=abc&userId=123'` — matching happens\n * on the composite id segments, never on this reconstructed field.\n */\nexport const reconstructQualifiedEntry = (\n group: QualifiedDictionaryGroup,\n compositeId: string\n): Dictionary => {\n const segments = compositeId.split(COMPOSITE_ID_SEPARATOR);\n\n const entry = {\n key: group.key,\n content: group.content[compositeId],\n } as Dictionary;\n\n group.qualifierTypes.forEach((qualifierType, index) => {\n if (qualifierType === 'variant') {\n entry.variant = segments[index];\n } else if (qualifierType === 'item') {\n entry.item = Number(segments[index]);\n }\n });\n\n return entry;\n};\n\n/**\n * Resolves a dictionary (or qualified dictionary group) against a selector,\n * across every declared dimension.\n *\n * - Plain dictionary → returned as-is (selector ignored)\n * - `item` declared but not selected → every matching entry ordered by index\n * - `item` selected → the matching entry or null\n * - `variant` defaults to the `default` entry when not selected, and falls back\n * to it when the selected variant declares no entry of its own; an object\n * variant resolves only when the selector provides an equal object (or, again,\n * through the `default` fallback)\n *\n * Dimensions compose: e.g. a variant × item key with `{ variant: 'promo' }`\n * returns every promo item as an array; adding `{ item: 2 }` narrows to one.\n */\nexport const resolveQualifiedDictionary = (\n dictionaryOrGroup: Dictionary | QualifiedDictionaryGroup,\n selector?: DictionarySelector\n): Dictionary | Dictionary[] | null => {\n if (!isQualifiedDictionaryGroup(dictionaryOrGroup)) {\n return dictionaryOrGroup;\n }\n\n const { qualifierTypes, content } = dictionaryOrGroup;\n\n const itemAxisOpen =\n qualifierTypes.includes('item') && selector?.item === undefined;\n\n const compositeIds = Object.keys(content);\n const variantIndex = qualifierTypes.indexOf('variant');\n\n const effectiveVariantId =\n variantIndex === -1\n ? DEFAULT_VARIANT_ID\n : resolveEffectiveVariantId(\n serializeVariantChain(selector?.variant),\n (variantId) =>\n compositeIds.some(\n (compositeId) =>\n compositeId.split(COMPOSITE_ID_SEPARATOR)[variantIndex] ===\n variantId\n )\n );\n\n const matchedEntries = compositeIds\n .filter((compositeId) =>\n compositeIdMatchesSelector(\n compositeId,\n qualifierTypes,\n selector,\n effectiveVariantId\n )\n )\n .map((compositeId) =>\n reconstructQualifiedEntry(dictionaryOrGroup, compositeId)\n );\n\n if (itemAxisOpen) {\n return matchedEntries.sort(\n (left, right) => (left.item ?? 0) - (right.item ?? 0)\n );\n }\n\n return matchedEntries[0] ?? null;\n};\n\n/**\n * Splits the second argument of `getIntlayer` / `getDictionary` into the\n * effective locale and the selector object (if any).\n */\nexport const parseDictionarySelector = <L extends LocalesValues>(\n localeOrSelector?: L | DictionarySelector\n): { locale?: L; selector?: DictionarySelector } => {\n if (typeof localeOrSelector === 'object' && localeOrSelector !== null) {\n return {\n locale: localeOrSelector.locale as L | undefined,\n selector: localeOrSelector,\n };\n }\n\n return { locale: localeOrSelector as L | undefined };\n};\n\n/**\n * Resolves the variant a provider pins for one dictionary key.\n *\n * A string or a chain applies to every key as-is. A plain object is the per-key\n * map: the entry for `dictionaryKey` wins, falling back to the reserved\n * `default` entry, and `undefined` when neither is present (the key then\n * resolves to its own `default` variant, i.e. the behaviour without a provider\n * variant at all).\n *\n * A plain object is **always** the map here — never a structured variant value,\n * which is why a structured variant has to be nested (`{ default: { id } }`).\n *\n * @param providerVariant - The `variant` prop of the surrounding provider.\n * @param dictionaryKey - The key being read.\n */\nexport const resolveProviderVariant = (\n providerVariant: ProviderVariantBase | undefined,\n dictionaryKey: string\n): DictionaryVariantChain | undefined => {\n if (providerVariant === undefined) return undefined;\n\n if (typeof providerVariant === 'string' || Array.isArray(providerVariant)) {\n return providerVariant as DictionaryVariantChain;\n }\n\n const variantMap = providerVariant as ProviderVariantMap;\n\n return variantMap[dictionaryKey] ?? variantMap[DEFAULT_VARIANT_ID];\n};\n\n/**\n * Builds the effective second argument of a dictionary read by layering the\n * provider defaults under the call-site one — the single place the `locale` and\n * `variant` context defaults are applied, shared by every framework binding.\n *\n * Precedence, per dimension independently:\n * - a call-site selector always wins; `{ variant: 'x' }` **replaces** the\n * provider chain rather than extending it\n * - otherwise the provider value applies\n *\n * Returns a bare locale (not a selector object) whenever no variant is in play,\n * so the existing fast path — and the cache keys built from it — are unchanged\n * for projects that never use variants.\n */\nexport const resolveDictionaryArgument = (params: {\n localeOrSelector?: LocalesValues | DictionarySelector;\n contextLocale?: LocalesValues;\n contextVariant?: ProviderVariantBase;\n dictionaryKey: string;\n}): LocalesValues | DictionarySelector | undefined => {\n const { localeOrSelector, contextLocale, contextVariant, dictionaryKey } =\n params;\n\n const callSelector =\n typeof localeOrSelector === 'object' && localeOrSelector !== null\n ? localeOrSelector\n : undefined;\n\n const callLocale = callSelector\n ? callSelector.locale\n : (localeOrSelector as LocalesValues | undefined);\n\n // The context locale is typed as widely as the runtime allows, while a\n // selector narrows `locale` to the declared ones — the value is the same.\n const locale = (callLocale ?? contextLocale) as DictionarySelector['locale'];\n\n // A call-site variant is authoritative; the provider only fills the gap.\n const variant =\n callSelector?.variant ??\n resolveProviderVariant(contextVariant, dictionaryKey);\n\n if (variant === undefined) {\n // Nothing to add: keep the argument in its original shape so the identity\n // built from it stays byte-identical to the pre-variant behaviour.\n return callSelector\n ? { ...callSelector, locale }\n : (locale as LocalesValues | undefined);\n }\n\n return { ...callSelector, locale, variant };\n};\n\n/**\n * Builds a stable string identity of a selector (excluding `locale`), suitable\n * for cache keys and memoization dependencies.\n */\nexport const getDictionarySelectorCacheKey = (\n selector?: DictionarySelector\n): string => {\n if (!selector) return '';\n\n return Object.keys(selector)\n .filter((selectorKey) => selectorKey !== 'locale')\n .sort()\n .map((selectorKey) => {\n const value = selector[selectorKey as keyof DictionarySelector];\n const serialized =\n selectorKey === 'variant'\n ? serializeVariantChain(\n value as DictionaryVariantChain | undefined\n ).join(',')\n : String(value);\n return `${selectorKey}:${serialized}`;\n })\n .join('|');\n};\n"],"mappings":";;;;;AAgBA,MAAa,yBAAyB;;;;;;AAOtC,MAAa,qBAAqB;;;;;;;AAQlC,MAAM,uBAAuB;;;;;AAM7B,MAAM,yBAAyB;;AAG/B,MAAM,qBAAqB,SACzB,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,GAAG,GAAG;AAEnE,MAAM,qBAAqB,KAAa,gBAAgC;CAGtE,IAAI,QAAQ,IAAI,OAAO;CAEvB,MAAM,UAAU,IAAI,QAAQ,aAAa,iBAAiB;CAG1D,IAAI,YAAY,OAAO,YAAY,MACjC,OAAO,QAAQ,QAAQ,OAAO,OAAO;CAGvC,OAAO;AACT;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,oBACX,YACW;CACX,IAAI,YAAY,QAAW,OAAO;CAClC,IAAI,OAAO,YAAY,UACrB,OAAO,kBAAkB,SAAS,oBAAoB;CAGxD,OAAO,OAAO,KAAK,OAAO,CAAC,CACxB,KAAK,CAAC,CACN,KACE,UACC,GAAG,kBAAkB,OAAO,sBAAsB,EAAE,GAAG,kBAAkB,OAAO,QAAQ,MAAM,GAAG,sBAAsB,GAC3H,CAAC,CACA,KAAK,GAAG;AACb;;;;;;;;;;;;;AAcA,MAAa,yBACX,YACa;CACb,IAAI,CAAC,MAAM,QAAQ,OAAO,GACxB,OAAO,CAAC,iBAAiB,OAA6C,CAAC;CAGzE,IAAI,QAAQ,WAAW,GAAG,OAAO,CAAC,kBAAkB;CAEpD,OAAO,QAAQ,IAAI,gBAAgB;AACrC;;;;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K,GAAG,IACV,OAAO,KAAK;CAEpB,CAAC,CAAC,CACD,KAAK,GAAG;AACb"}
1
+ {"version":3,"file":"qualifiedDictionary.mjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionaryItemId,\n DictionaryQualifierType,\n DictionarySelector,\n DictionaryVariantChain,\n DictionaryVariantValue,\n ProviderVariantBase,\n ProviderVariantMap,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Separator joining per-dimension ids into a composite entry id. Also used as\n * the chunk path separator in dynamic mode.\n */\nexport const COMPOSITE_ID_SEPARATOR = '/';\n\n/**\n * Identity of the implicit fallback variant. A selector that pins no variant\n * resolves to it, and a variant that declares no entry of its own falls back to\n * it — so a key only has to ship the entries that actually differ.\n */\nexport const DEFAULT_VARIANT_ID = 'default';\n\n/**\n * Characters kept verbatim in an encoded qualifier segment. Everything else is\n * percent-encoded so a segment can never contain the composite-id separator\n * (`/`), path-hostile characters (`\\` `:` `*` `?` `\"` `<` `>` `|`, control\n * chars), or characters that would break the generated loader modules (`'`).\n */\nconst SEGMENT_UNSAFE_CHARS = /[^A-Za-z0-9._&=-]/g;\n\n/**\n * Stricter set for the components of an object variant: also encodes `&` and\n * `=` so the `field=value&field=value` serialization stays unambiguous.\n */\nconst COMPONENT_UNSAFE_CHARS = /[^A-Za-z0-9._-]/g;\n\n/** Percent-encodes one UTF-16 code unit as a fixed-width `%XXXX` run. */\nconst percentEncodeChar = (char: string): string =>\n `%${char.charCodeAt(0).toString(16).toUpperCase().padStart(4, '0')}`;\n\nconst encodeSegmentText = (raw: string, unsafeChars: RegExp): string => {\n // Bare '%' cannot be produced by encoding (every encoded run is %XXXX),\n // so it is a safe stand-in for the empty string.\n if (raw === '') return '%';\n\n const encoded = raw.replace(unsafeChars, percentEncodeChar);\n\n // '.' and '..' are path navigation on every filesystem — encode the dots.\n if (encoded === '.' || encoded === '..') {\n return encoded.replace(/\\./g, '%002E');\n }\n\n return encoded;\n};\n\n/**\n * Canonical serialization of a single variant value into its identity string —\n * the variant segment of a composite id, the chunk directory name in dynamic\n * mode, and the runtime matching key.\n *\n * - `undefined` → `'default'` (the implicit fallback variant)\n * - a string → the string itself (a named variant)\n * - an object → its sorted `key=value` pairs joined by `&`\n * (e.g. `{ userId: '123', id: 'abc' }` → `'id=abc&userId=123'`)\n *\n * Characters that are unsafe in file paths or generated code are\n * percent-encoded (fixed-width `%XXXX` runs, injective). Common names —\n * letters, digits, `-` `_` `.` — are left untouched. Both the declaration and\n * the selector go through this function, so encoding never affects matching.\n *\n * Two variants resolve to the same entry iff their serializations are equal, so\n * an object variant in a selector must equal the one declared on the dictionary.\n */\nexport const serializeVariant = (\n variant: DictionaryVariantValue | undefined\n): string => {\n if (variant === undefined) return DEFAULT_VARIANT_ID;\n if (typeof variant === 'string') {\n return encodeSegmentText(variant, SEGMENT_UNSAFE_CHARS);\n }\n\n return Object.keys(variant)\n .sort()\n .map(\n (field) =>\n `${encodeSegmentText(field, COMPONENT_UNSAFE_CHARS)}=${encodeSegmentText(String(variant[field]), COMPONENT_UNSAFE_CHARS)}`\n )\n .join('&');\n};\n\n/** Reverses `encodeSegmentText`: decodes the `%XXXX` runs and the `%` stand-in. */\nconst decodeSegmentText = (segment: string): string =>\n segment === '%'\n ? ''\n : segment.replace(/%([0-9A-F]{4})/g, (_match, charCode: string) =>\n String.fromCharCode(Number.parseInt(charCode, 16))\n );\n\n/**\n * Normalizes a raw item id: a string holding a number's exact canonical form\n * becomes that number (`'2'` → `2`), anything else stays a string id\n * (`'007'`, `'65f1c0a2'`, `'Infinity'`).\n *\n * @param rawItem - The item id as text (a composite id segment, a form input…).\n */\nexport const parseItemId = (rawItem: string): DictionaryItemId => {\n const numericItem = Number(rawItem);\n\n return rawItem !== '' &&\n Number.isFinite(numericItem) &&\n String(numericItem) === rawItem\n ? numericItem\n : rawItem;\n};\n\n/**\n * Canonical serialization of an item id — the item segment of a composite id,\n * the chunk directory name in dynamic mode, and the runtime matching key.\n *\n * A number and its digits serialize identically (`2` and `'2'` → `'2'`).\n * Characters unsafe in file paths or generated code are percent-encoded like\n * variant names, so database ids (hex, UUID, nanoid…) are kept verbatim.\n */\nexport const serializeItem = (item: DictionaryItemId): string =>\n encodeSegmentText(String(item), SEGMENT_UNSAFE_CHARS);\n\n/** Decodes the item segment of a composite id back into its item id. */\nexport const parseItemSegment = (segment: string): DictionaryItemId =>\n parseItemId(decodeSegmentText(segment));\n\n/**\n * Collection order of two item ids: numeric ids by value first, then string\n * ids by UTF-16 code unit (locale-independent, so every build agrees).\n */\nexport const compareItemIds = (\n leftItem: DictionaryItemId,\n rightItem: DictionaryItemId\n): number => {\n if (typeof leftItem === 'number' && typeof rightItem === 'number') {\n return leftItem - rightItem;\n }\n\n if (typeof leftItem === 'number') return -1;\n if (typeof rightItem === 'number') return 1;\n if (leftItem === rightItem) return 0;\n\n return leftItem < rightItem ? -1 : 1;\n};\n\n/** Collection order of two serialized item segments (see {@link compareItemIds}). */\nexport const compareItemSegments = (\n leftSegment: string,\n rightSegment: string\n): number =>\n compareItemIds(parseItemSegment(leftSegment), parseItemSegment(rightSegment));\n\n/**\n * Serializes the variant coordinate of a selector into the ordered list of\n * candidate ids to try, so a single value and a preference chain share one code\n * path downstream.\n *\n * - `undefined` → `['default']`\n * - a single value → its one serialization\n * - a chain → one serialization per entry, order preserved\n *\n * An empty chain is treated as \"no variant pinned\" (`['default']`) rather than\n * as an unsatisfiable request.\n */\nexport const serializeVariantChain = (\n variant: DictionaryVariantChain | undefined\n): string[] => {\n if (!Array.isArray(variant)) {\n return [serializeVariant(variant as DictionaryVariantValue | undefined)];\n }\n\n if (variant.length === 0) return [DEFAULT_VARIANT_ID];\n\n return variant.map(serializeVariant);\n};\n\n/**\n * Resolves the variant id a selector actually targets among the ids a key\n * declares — the sparse-override fallback.\n *\n * Candidates are tried in order and the first one the key declares wins.\n * Otherwise the key falls back to its `default` entry, so a variant only has to\n * be declared where its wording differs. When the key declares no `default`\n * either, the first candidate is returned unchanged and the caller resolves to\n * `null` / `[]`.\n *\n * @param requestedVariantIds - The serialized ids the selector asks for, in\n * preference order (a single value is a 1-element\n * list).\n * @param isVariantIdDeclared - Whether the key declares an entry for an id.\n */\nexport const resolveEffectiveVariantId = (\n requestedVariantIds: string[],\n isVariantIdDeclared: (variantId: string) => boolean\n): string => {\n for (const requestedVariantId of requestedVariantIds) {\n if (isVariantIdDeclared(requestedVariantId)) return requestedVariantId;\n }\n\n return isVariantIdDeclared(DEFAULT_VARIANT_ID)\n ? DEFAULT_VARIANT_ID\n : (requestedVariantIds[0] ?? DEFAULT_VARIANT_ID);\n};\n\n/**\n * Tests whether a composite entry id matches a selector across every declared\n * dimension. Segments are compared in their encoded form (both the stored id\n * and the selector go through {@link serializeVariant}). The `item` dimension\n * matches any value when the selector does not provide one (open collection\n * axis); the `variant` dimension is compared against the already-resolved\n * effective id, so the fallback is applied consistently across dimensions.\n */\nconst compositeIdMatchesSelector = (\n compositeId: string,\n qualifierTypes: DictionaryQualifierType[],\n selector: DictionarySelector | undefined,\n effectiveVariantId: string\n): boolean => {\n const segments = compositeId.split(COMPOSITE_ID_SEPARATOR);\n\n return qualifierTypes.every((qualifierType, index) => {\n if (qualifierType === 'variant') {\n return segments[index] === effectiveVariantId;\n }\n\n // qualifierType === 'item'\n return (\n selector?.item === undefined ||\n segments[index] === serializeItem(selector.item)\n );\n });\n};\n\n/**\n * Type guard discriminating a `QualifiedDictionaryGroup` (merge output of a\n * qualified key) from a plain `Dictionary`. Both carry a `content` field; only\n * the group declares `qualifierTypes`, which is therefore the discriminator.\n */\nexport const isQualifiedDictionaryGroup = (\n value: unknown\n): value is QualifiedDictionaryGroup =>\n typeof value === 'object' &&\n value !== null &&\n 'qualifierTypes' in value &&\n Array.isArray((value as { qualifierTypes: unknown }).qualifierTypes) &&\n 'content' in value;\n\n/**\n * Reconstructs a resolvable {@link Dictionary} from a single entry of a\n * qualified group: the content node stored under its composite id, plus the\n * qualifier coordinates decoded from that id (`variant`, `item`).\n *\n * This keeps the resolver's transform code unchanged: it still sees a\n * `{ key, content, variant?, item? }` shape, even though the stored format no\n * longer duplicates those fields per entry. The `variant` coordinate stays in\n * its serialized (encoded) form, e.g. `'id=abc&userId=123'` — matching happens\n * on the composite id segments, never on this reconstructed field. The `item`\n * coordinate is decoded back to its id (`2`, `'65f1c0a2'`).\n */\nexport const reconstructQualifiedEntry = (\n group: QualifiedDictionaryGroup,\n compositeId: string\n): Dictionary => {\n const segments = compositeId.split(COMPOSITE_ID_SEPARATOR);\n\n const entry = {\n key: group.key,\n content: group.content[compositeId],\n } as Dictionary;\n\n const entryMetadata = group.metadata?.[compositeId];\n\n if (entryMetadata !== undefined) {\n entry.metadata = entryMetadata as Dictionary['metadata'];\n }\n\n group.qualifierTypes.forEach((qualifierType, index) => {\n if (qualifierType === 'variant') {\n entry.variant = segments[index];\n } else if (qualifierType === 'item') {\n entry.item = parseItemSegment(segments[index] ?? '');\n }\n });\n\n return entry;\n};\n\n/**\n * Resolves a dictionary (or qualified dictionary group) against a selector,\n * across every declared dimension.\n *\n * - Plain dictionary → returned as-is (selector ignored)\n * - `item` declared but not selected → every matching entry, in collection\n * order (see `compareItemIds`)\n * - `item` selected → the matching entry or null\n * - `variant` defaults to the `default` entry when not selected, and falls back\n * to it when the selected variant declares no entry of its own; an object\n * variant resolves only when the selector provides an equal object (or, again,\n * through the `default` fallback)\n *\n * Dimensions compose: e.g. a variant × item key with `{ variant: 'promo' }`\n * returns every promo item as an array; adding `{ item: 2 }` narrows to one.\n */\nexport const resolveQualifiedDictionary = (\n dictionaryOrGroup: Dictionary | QualifiedDictionaryGroup,\n selector?: DictionarySelector\n): Dictionary | Dictionary[] | null => {\n if (!isQualifiedDictionaryGroup(dictionaryOrGroup)) {\n return dictionaryOrGroup;\n }\n\n const { itemAxisOpen, matchedIds } = matchQualifiedEntryIds(\n Object.keys(dictionaryOrGroup.content),\n dictionaryOrGroup.qualifierTypes,\n selector\n );\n\n const matchedEntries = matchedIds.map((compositeId) =>\n reconstructQualifiedEntry(dictionaryOrGroup, compositeId)\n );\n\n if (itemAxisOpen) return matchedEntries;\n\n return matchedEntries[0] ?? null;\n};\n\n/** Ids a selector targets among a qualified key's entries. */\nexport type MatchedQualifiedEntryIds = {\n /** True when the `item` axis is open (collection result → array). */\n itemAxisOpen: boolean;\n /** Matching composite ids, in collection order when the axis is open. */\n matchedIds: string[];\n};\n\n/**\n * Selects the composite ids a selector targets across every declared\n * dimension — the matching shared by the static resolver and the dynamic\n * metadata index, so both modes resolve the same entries.\n *\n * @param compositeIds - Every composite id the key declares.\n * @param qualifierTypes - The key's dimensions, in canonical order.\n * @param selector - The selector splitting the dimensions.\n */\nexport const matchQualifiedEntryIds = (\n compositeIds: string[],\n qualifierTypes: DictionaryQualifierType[],\n selector?: DictionarySelector\n): MatchedQualifiedEntryIds => {\n const itemAxisOpen =\n qualifierTypes.includes('item') && selector?.item === undefined;\n\n const variantIndex = qualifierTypes.indexOf('variant');\n const itemIndex = qualifierTypes.indexOf('item');\n\n const effectiveVariantId =\n variantIndex === -1\n ? DEFAULT_VARIANT_ID\n : resolveEffectiveVariantId(\n serializeVariantChain(selector?.variant),\n (variantId) =>\n compositeIds.some(\n (compositeId) =>\n compositeId.split(COMPOSITE_ID_SEPARATOR)[variantIndex] ===\n variantId\n )\n );\n\n const matchedIds = compositeIds.filter((compositeId) =>\n compositeIdMatchesSelector(\n compositeId,\n qualifierTypes,\n selector,\n effectiveVariantId\n )\n );\n\n if (itemAxisOpen) {\n const getItemSegment = (compositeId: string): string =>\n compositeId.split(COMPOSITE_ID_SEPARATOR)[itemIndex] ?? '';\n\n matchedIds.sort((left, right) =>\n compareItemSegments(getItemSegment(left), getItemSegment(right))\n );\n }\n\n return { itemAxisOpen, matchedIds };\n};\n\n/**\n * Splits the second argument of `getIntlayer` / `getDictionary` into the\n * effective locale and the selector object (if any).\n */\nexport const parseDictionarySelector = <L extends LocalesValues>(\n localeOrSelector?: L | DictionarySelector\n): { locale?: L; selector?: DictionarySelector } => {\n if (typeof localeOrSelector === 'object' && localeOrSelector !== null) {\n return {\n locale: localeOrSelector.locale as L | undefined,\n selector: localeOrSelector,\n };\n }\n\n return { locale: localeOrSelector as L | undefined };\n};\n\n/**\n * Resolves the variant a provider pins for one dictionary key.\n *\n * A string or a chain applies to every key as-is. A plain object is the per-key\n * map: the entry for `dictionaryKey` wins, falling back to the reserved\n * `default` entry, and `undefined` when neither is present (the key then\n * resolves to its own `default` variant, i.e. the behaviour without a provider\n * variant at all).\n *\n * A plain object is **always** the map here — never a structured variant value,\n * which is why a structured variant has to be nested (`{ default: { id } }`).\n *\n * @param providerVariant - The `variant` prop of the surrounding provider.\n * @param dictionaryKey - The key being read.\n */\nexport const resolveProviderVariant = (\n providerVariant: ProviderVariantBase | undefined,\n dictionaryKey: string\n): DictionaryVariantChain | undefined => {\n if (providerVariant === undefined) return undefined;\n\n if (typeof providerVariant === 'string' || Array.isArray(providerVariant)) {\n return providerVariant as DictionaryVariantChain;\n }\n\n const variantMap = providerVariant as ProviderVariantMap;\n\n return variantMap[dictionaryKey] ?? variantMap[DEFAULT_VARIANT_ID];\n};\n\n/**\n * Builds the effective second argument of a dictionary read by layering the\n * provider defaults under the call-site one — the single place the `locale` and\n * `variant` context defaults are applied, shared by every framework binding.\n *\n * Precedence, per dimension independently:\n * - a call-site selector always wins; `{ variant: 'x' }` **replaces** the\n * provider chain rather than extending it\n * - otherwise the provider value applies\n *\n * Returns a bare locale (not a selector object) whenever no variant is in play,\n * so the existing fast path — and the cache keys built from it — are unchanged\n * for projects that never use variants.\n */\nexport const resolveDictionaryArgument = (params: {\n localeOrSelector?: LocalesValues | DictionarySelector;\n contextLocale?: LocalesValues;\n contextVariant?: ProviderVariantBase;\n dictionaryKey: string;\n}): LocalesValues | DictionarySelector | undefined => {\n const { localeOrSelector, contextLocale, contextVariant, dictionaryKey } =\n params;\n\n const callSelector =\n typeof localeOrSelector === 'object' && localeOrSelector !== null\n ? localeOrSelector\n : undefined;\n\n const callLocale = callSelector\n ? callSelector.locale\n : (localeOrSelector as LocalesValues | undefined);\n\n // The context locale is typed as widely as the runtime allows, while a\n // selector narrows `locale` to the declared ones — the value is the same.\n const locale = (callLocale ?? contextLocale) as DictionarySelector['locale'];\n\n // A call-site variant is authoritative; the provider only fills the gap.\n const variant =\n callSelector?.variant ??\n resolveProviderVariant(contextVariant, dictionaryKey);\n\n if (variant === undefined) {\n // Nothing to add: keep the argument in its original shape so the identity\n // built from it stays byte-identical to the pre-variant behaviour.\n return callSelector\n ? { ...callSelector, locale }\n : (locale as LocalesValues | undefined);\n }\n\n return { ...callSelector, locale, variant };\n};\n\n/**\n * Builds a stable string identity of a selector (excluding `locale`, and the\n * dimensions left `undefined`), suitable for cache keys and memoization\n * dependencies.\n */\nexport const getDictionarySelectorCacheKey = (\n selector?: DictionarySelector\n): string => {\n if (!selector) return '';\n\n return Object.keys(selector)\n .filter(\n (selectorKey) =>\n selectorKey !== 'locale' &&\n selector[selectorKey as keyof DictionarySelector] !== undefined\n )\n .sort()\n .map((selectorKey) => {\n const value = selector[selectorKey as keyof DictionarySelector];\n const serialized =\n selectorKey === 'variant'\n ? serializeVariantChain(\n value as DictionaryVariantChain | undefined\n ).join(',')\n : String(value);\n return `${selectorKey}:${serialized}`;\n })\n .join('|');\n};\n"],"mappings":";;;;;AAiBA,MAAa,yBAAyB;;;;;;AAOtC,MAAa,qBAAqB;;;;;;;AAQlC,MAAM,uBAAuB;;;;;AAM7B,MAAM,yBAAyB;;AAG/B,MAAM,qBAAqB,SACzB,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,GAAG,GAAG;AAEnE,MAAM,qBAAqB,KAAa,gBAAgC;CAGtE,IAAI,QAAQ,IAAI,OAAO;CAEvB,MAAM,UAAU,IAAI,QAAQ,aAAa,iBAAiB;CA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IyB;CAG9B,MAAM,UACJ,cAAc,WACd,uBAAuB,gBAAgB,aAAa;CAEtD,IAAI,YAAY,QAGd,OAAO,eACH;EAAE,GAAG;EAAc;CAAO,IACzB;CAGP,OAAO;EAAE,GAAG;EAAc;EAAQ;CAAQ;AAC5C;;;;;;AAOA,MAAa,iCACX,aACW;CACX,IAAI,CAAC,UAAU,OAAO;CAEtB,OAAO,OAAO,KAAK,QAAQ,CAAC,CACzB,QACE,gBACC,gBAAgB,YAChB,SAAS,iBAA6C,MAC1D,CAAC,CACA,KAAK,CAAC,CACN,KAAK,gBAAgB;EACpB,MAAM,QAAQ,SAAS;EAOvB,OAAO,GAAG,YAAY,GALpB,gBAAgB,YACZ,sBACE,KACF,CAAC,CAAC,KAAK,GAAG,IACV,OAAO,KAAK;CAEpB,CAAC,CAAC,CACD,KAAK,GAAG;AACb"}
@@ -1,4 +1,4 @@
1
- import { COMPOSITE_ID_SEPARATOR, serializeVariant } from "./qualifiedDictionary.mjs";
1
+ import { COMPOSITE_ID_SEPARATOR, serializeItem, serializeVariant } from "./qualifiedDictionary.mjs";
2
2
 
3
3
  // src/dictionaryManipulator/qualifiedDictionaryDeclaration.ts
4
4
  /**
@@ -21,6 +21,11 @@ const getVariantIds = (variant) => {
21
21
  return [...new Set(values.map(serializeVariant))];
22
22
  };
23
23
  /**
24
+ * Whether an `item` field declares the collection dimension: a number, or a
25
+ * non-empty string id. An empty string (a blank form field) declares nothing.
26
+ */
27
+ const isDeclaredItem = (item) => typeof item === "number" || typeof item === "string" && item !== "";
28
+ /**
24
29
  * Returns the qualifier dimensions declared on a dictionary, in canonical
25
30
  * order (`variant → item`). Empty when the dictionary is unqualified
26
31
  * (plain dictionary or shared base content of a qualified group).
@@ -28,7 +33,7 @@ const getVariantIds = (variant) => {
28
33
  const getDictionaryQualifierTypes = (dictionary) => {
29
34
  const declaredQualifiers = [];
30
35
  if (getVariantIds(dictionary.variant) !== void 0) declaredQualifiers.push("variant");
31
- if (typeof dictionary.item === "number") declaredQualifiers.push("item");
36
+ if (isDeclaredItem(dictionary.item)) declaredQualifiers.push("item");
32
37
  return declaredQualifiers;
33
38
  };
34
39
  /**
@@ -37,11 +42,11 @@ const getDictionaryQualifierTypes = (dictionary) => {
37
42
  *
38
43
  * - 'variant' → the serialized variant id(s); an array variant yields one id
39
44
  * per element (declaration-side fan-out)
40
- * - 'item' → the item index as a single-element list
45
+ * - 'item' → the serialized item id as a single-element list
41
46
  */
42
47
  const getDictionaryQualifierIds = (dictionary, qualifierType) => {
43
48
  if (qualifierType === "variant") return getVariantIds(dictionary.variant);
44
- return dictionary.item === void 0 ? void 0 : [String(dictionary.item)];
49
+ return isDeclaredItem(dictionary.item) ? [serializeItem(dictionary.item)] : void 0;
45
50
  };
46
51
  /**
47
52
  * Builds every composite entry id of a dictionary — the cartesian product of
@@ -59,5 +64,5 @@ const getDictionaryCompositeIds = (dictionary, qualifierTypes) => {
59
64
  return compositeIds;
60
65
  };
61
66
 
62
- export { QUALIFIER_ORDER, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getVariantIds };
67
+ export { QUALIFIER_ORDER, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getVariantIds, isDeclaredItem };
63
68
  //# sourceMappingURL=qualifiedDictionaryDeclaration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"qualifiedDictionaryDeclaration.mjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDictionaryDeclaration.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionaryQualifierType,\n} from '@intlayer/types/dictionary';\nimport {\n COMPOSITE_ID_SEPARATOR,\n serializeVariant,\n} from './qualifiedDictionary';\n\n/**\n * Canonical order of qualifier dimensions. A key that declares both dimensions\n * always nests them in this order, with `item` innermost so it can act as the\n * collection (array) axis.\n */\nexport const QUALIFIER_ORDER = [\n 'variant',\n 'item',\n] as const satisfies readonly DictionaryQualifierType[];\n\n/**\n * Normalizes the `variant` field of a dictionary into the list of variant ids\n * the declaration registers under. A single value yields one id; an **array**\n * fans out into one id per element (duplicates collapsed). Returns `undefined`\n * when the dictionary does not declare the variant dimension (no `variant`\n * field, or an empty array).\n */\nexport const getVariantIds = (\n variant: Dictionary['variant']\n): string[] | undefined => {\n if (variant === undefined) return undefined;\n\n const values = Array.isArray(variant) ? variant : [variant];\n if (values.length === 0) return undefined;\n\n return [...new Set(values.map(serializeVariant))];\n};\n\n/**\n * Returns the qualifier dimensions declared on a dictionary, in canonical\n * order (`variant → item`). Empty when the dictionary is unqualified\n * (plain dictionary or shared base content of a qualified group).\n */\nexport const getDictionaryQualifierTypes = (\n dictionary: Dictionary\n): DictionaryQualifierType[] => {\n const declaredQualifiers: DictionaryQualifierType[] = [];\n\n if (getVariantIds(dictionary.variant) !== undefined) {\n declaredQualifiers.push('variant');\n }\n if (typeof dictionary.item === 'number') declaredQualifiers.push('item');\n\n return declaredQualifiers;\n};\n\n/**\n * Returns the qualifier identifiers of a dictionary for the given qualifier\n * dimension — the candidate segments of the composite entry ids.\n *\n * - 'variant' → the serialized variant id(s); an array variant yields one id\n * per element (declaration-side fan-out)\n * - 'item' → the item index as a single-element list\n */\nexport const getDictionaryQualifierIds = (\n dictionary: Dictionary,\n qualifierType: DictionaryQualifierType\n): string[] | undefined => {\n if (qualifierType === 'variant') {\n return getVariantIds(dictionary.variant);\n }\n return dictionary.item === undefined ? undefined : [String(dictionary.item)];\n};\n\n/**\n * Builds every composite entry id of a dictionary — the cartesian product of\n * its per-dimension id lists, joined in canonical order. A dictionary with a\n * plain (non-array) variant yields exactly one id; an array variant fans out\n * into one id per element. `undefined` when a dimension of the set is missing.\n */\nexport const getDictionaryCompositeIds = (\n dictionary: Dictionary,\n qualifierTypes: DictionaryQualifierType[]\n): string[] | undefined => {\n let compositeIds: string[] = [''];\n\n for (const qualifierType of qualifierTypes) {\n const ids = getDictionaryQualifierIds(dictionary, qualifierType);\n if (ids === undefined) return undefined;\n\n compositeIds = compositeIds.flatMap((prefix) =>\n ids.map((id) =>\n prefix === '' ? id : `${prefix}${COMPOSITE_ID_SEPARATOR}${id}`\n )\n );\n }\n\n return compositeIds;\n};\n"],"mappings":";;;;;;;;AAcA,MAAa,kBAAkB,CAC7B,WACA,MACF;;;;;;;;AASA,MAAa,iBACX,YACyB;CACzB,IAAI,YAAY,QAAW,OAAO;CAElC,MAAM,SAAS,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;CAC1D,IAAI,OAAO,WAAW,GAAG,OAAO;CAEhC,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,gBAAgB,CAAC,CAAC;AAClD;;;;;;AAOA,MAAa,+BACX,eAC8B;CAC9B,MAAM,qBAAgD,CAAC;CAEvD,IAAI,cAAc,WAAW,OAAO,MAAM,QACxC,mBAAmB,KAAK,SAAS;CAEnC,IAAI,OAAO,WAAW,SAAS,UAAU,mBAAmB,KAAK,MAAM;CAEvE,OAAO;AACT;;;;;;;;;AAUA,MAAa,6BACX,YACA,kBACyB;CACzB,IAAI,kBAAkB,WACpB,OAAO,cAAc,WAAW,OAAO;CAEzC,OAAO,WAAW,SAAS,SAAY,SAAY,CAAC,OAAO,WAAW,IAAI,CAAC;AAC7E;;;;;;;AAQA,MAAa,6BACX,YACA,mBACyB;CACzB,IAAI,eAAyB,CAAC,EAAE;CAEhC,KAAK,MAAM,iBAAiB,gBAAgB;EAC1C,MAAM,MAAM,0BAA0B,YAAY,aAAa;EAC/D,IAAI,QAAQ,QAAW,OAAO;EAE9B,eAAe,aAAa,SAAS,WACnC,IAAI,KAAK,OACP,WAAW,KAAK,KAAK,GAAG,eAAkC,IAC5D,CACF;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"qualifiedDictionaryDeclaration.mjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDictionaryDeclaration.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionaryItemId,\n DictionaryQualifierType,\n} from '@intlayer/types/dictionary';\nimport {\n COMPOSITE_ID_SEPARATOR,\n serializeItem,\n serializeVariant,\n} from './qualifiedDictionary';\n\n/**\n * Canonical order of qualifier dimensions. A key that declares both dimensions\n * always nests them in this order, with `item` innermost so it can act as the\n * collection (array) axis.\n */\nexport const QUALIFIER_ORDER = [\n 'variant',\n 'item',\n] as const satisfies readonly DictionaryQualifierType[];\n\n/**\n * Normalizes the `variant` field of a dictionary into the list of variant ids\n * the declaration registers under. A single value yields one id; an **array**\n * fans out into one id per element (duplicates collapsed). Returns `undefined`\n * when the dictionary does not declare the variant dimension (no `variant`\n * field, or an empty array).\n */\nexport const getVariantIds = (\n variant: Dictionary['variant']\n): string[] | undefined => {\n if (variant === undefined) return undefined;\n\n const values = Array.isArray(variant) ? variant : [variant];\n if (values.length === 0) return undefined;\n\n return [...new Set(values.map(serializeVariant))];\n};\n\n/**\n * Whether an `item` field declares the collection dimension: a number, or a\n * non-empty string id. An empty string (a blank form field) declares nothing.\n */\nexport const isDeclaredItem = (\n item: Dictionary['item']\n): item is DictionaryItemId =>\n typeof item === 'number' || (typeof item === 'string' && item !== '');\n\n/**\n * Returns the qualifier dimensions declared on a dictionary, in canonical\n * order (`variant → item`). Empty when the dictionary is unqualified\n * (plain dictionary or shared base content of a qualified group).\n */\nexport const getDictionaryQualifierTypes = (\n dictionary: Dictionary\n): DictionaryQualifierType[] => {\n const declaredQualifiers: DictionaryQualifierType[] = [];\n\n if (getVariantIds(dictionary.variant) !== undefined) {\n declaredQualifiers.push('variant');\n }\n if (isDeclaredItem(dictionary.item)) declaredQualifiers.push('item');\n\n return declaredQualifiers;\n};\n\n/**\n * Returns the qualifier identifiers of a dictionary for the given qualifier\n * dimension — the candidate segments of the composite entry ids.\n *\n * - 'variant' → the serialized variant id(s); an array variant yields one id\n * per element (declaration-side fan-out)\n * - 'item' → the serialized item id as a single-element list\n */\nexport const getDictionaryQualifierIds = (\n dictionary: Dictionary,\n qualifierType: DictionaryQualifierType\n): string[] | undefined => {\n if (qualifierType === 'variant') {\n return getVariantIds(dictionary.variant);\n }\n return isDeclaredItem(dictionary.item)\n ? [serializeItem(dictionary.item)]\n : undefined;\n};\n\n/**\n * Builds every composite entry id of a dictionary — the cartesian product of\n * its per-dimension id lists, joined in canonical order. A dictionary with a\n * plain (non-array) variant yields exactly one id; an array variant fans out\n * into one id per element. `undefined` when a dimension of the set is missing.\n */\nexport const getDictionaryCompositeIds = (\n dictionary: Dictionary,\n qualifierTypes: DictionaryQualifierType[]\n): string[] | undefined => {\n let compositeIds: string[] = [''];\n\n for (const qualifierType of qualifierTypes) {\n const ids = getDictionaryQualifierIds(dictionary, qualifierType);\n if (ids === undefined) return undefined;\n\n compositeIds = compositeIds.flatMap((prefix) =>\n ids.map((id) =>\n prefix === '' ? id : `${prefix}${COMPOSITE_ID_SEPARATOR}${id}`\n )\n );\n }\n\n return compositeIds;\n};\n"],"mappings":";;;;;;;;AAgBA,MAAa,kBAAkB,CAC7B,WACA,MACF;;;;;;;;AASA,MAAa,iBACX,YACyB;CACzB,IAAI,YAAY,QAAW,OAAO;CAElC,MAAM,SAAS,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;CAC1D,IAAI,OAAO,WAAW,GAAG,OAAO;CAEhC,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,gBAAgB,CAAC,CAAC;AAClD;;;;;AAMA,MAAa,kBACX,SAEA,OAAO,SAAS,YAAa,OAAO,SAAS,YAAY,SAAS;;;;;;AAOpE,MAAa,+BACX,eAC8B;CAC9B,MAAM,qBAAgD,CAAC;CAEvD,IAAI,cAAc,WAAW,OAAO,MAAM,QACxC,mBAAmB,KAAK,SAAS;CAEnC,IAAI,eAAe,WAAW,IAAI,GAAG,mBAAmB,KAAK,MAAM;CAEnE,OAAO;AACT;;;;;;;;;AAUA,MAAa,6BACX,YACA,kBACyB;CACzB,IAAI,kBAAkB,WACpB,OAAO,cAAc,WAAW,OAAO;CAEzC,OAAO,eAAe,WAAW,IAAI,IACjC,CAAC,cAAc,WAAW,IAAI,CAAC,IAC/B;AACN;;;;;;;AAQA,MAAa,6BACX,YACA,mBACyB;CACzB,IAAI,eAAyB,CAAC,EAAE;CAEhC,KAAK,MAAM,iBAAiB,gBAAgB;EAC1C,MAAM,MAAM,0BAA0B,YAAY,aAAa;EAC/D,IAAI,QAAQ,QAAW,OAAO;EAE9B,eAAe,aAAa,SAAS,WACnC,IAAI,KAAK,OACP,WAAW,KAAK,KAAK,GAAG,eAAkC,IAC5D,CACF;CACF;CAEA,OAAO;AACT"}
@@ -1,7 +1,9 @@
1
- import { COMPOSITE_ID_SEPARATOR, resolveEffectiveVariantId, serializeVariantChain } from "./qualifiedDictionary.mjs";
2
- import { QUALIFIER_DYNAMIC_TYPES_KEY } from "@intlayer/config/defaultValues";
1
+ import { COMPOSITE_ID_SEPARATOR, compareItemSegments, matchQualifiedEntryIds, resolveEffectiveVariantId, serializeItem, serializeVariantChain } from "./qualifiedDictionary.mjs";
2
+ import { QUALIFIER_DYNAMIC_METADATA_KEY, QUALIFIER_DYNAMIC_TYPES_KEY } from "@intlayer/config/defaultValues";
3
3
 
4
4
  // src/dictionaryManipulator/qualifiedDynamicLoader.ts
5
+ /** Cache-key suffix of a metadata index chunk (never a valid composite id). */
6
+ const METADATA_INDEX_CACHE_SEGMENT = "#metadata";
5
7
  /**
6
8
  * Type guard discriminating a qualified dynamic loader map (collections /
7
9
  * variants, possibly combined) from a plain dynamic loader map.
@@ -9,13 +11,29 @@ import { QUALIFIER_DYNAMIC_TYPES_KEY } from "@intlayer/config/defaultValues";
9
11
  const isQualifiedDynamicLoaderMap = (value) => typeof value === "object" && value !== null && QUALIFIER_DYNAMIC_TYPES_KEY in value;
10
12
  /**
11
13
  * Walks the loader tree following the selector and collects the chunk loaders
12
- * it targets — shared by the sync ({@link resolveQualifiedDynamicContent}) and
13
- * async ({@link resolveQualifiedDynamicContentAsync}) resolvers.
14
+ * it targets.
15
+ *
16
+ * Walks one dimension at a time (canonical order `variant → item`): `variant`
17
+ * descends by the serialized id, falling back to `default` when the selected
18
+ * variant has no chunk of its own, and `item` either narrows to the selected
19
+ * index or — when no item is given — expands into every sibling chunk (the
20
+ * collection axis). Semantics mirror `resolveQualifiedDictionary` so dynamic
21
+ * and static modes behave alike.
14
22
  */
15
23
  const collectQualifiedChunks = (loaderMap, key, locale, selector) => {
16
24
  const qualifierTypes = loaderMap[QUALIFIER_DYNAMIC_TYPES_KEY];
17
25
  const localeTree = loaderMap[locale];
18
26
  const itemAxisOpen = qualifierTypes.includes("item") && selector?.item === void 0;
27
+ const metadataIndexLoader = selector?.metadataOnly && itemAxisOpen ? loaderMap[QUALIFIER_DYNAMIC_METADATA_KEY]?.[locale] : void 0;
28
+ if (metadataIndexLoader) return {
29
+ itemAxisOpen,
30
+ missed: false,
31
+ readsMetadataIndex: true,
32
+ chunks: [{
33
+ cacheKey: `${key}.${locale}.${METADATA_INDEX_CACHE_SEGMENT}`,
34
+ loader: metadataIndexLoader
35
+ }]
36
+ };
19
37
  if (!localeTree) return {
20
38
  itemAxisOpen,
21
39
  missed: true,
@@ -33,10 +51,10 @@ const collectQualifiedChunks = (loaderMap, key, locale, selector) => {
33
51
  const [dimension, ...rest] = dimensions;
34
52
  const tree = node;
35
53
  if (dimension === "item" && selector?.item === void 0) {
36
- for (const segment of Object.keys(tree).sort((left, right) => Number(left) - Number(right))) walk(tree[segment], rest, [...segments, segment]);
54
+ for (const segment of Object.keys(tree).sort(compareItemSegments)) walk(tree[segment], rest, [...segments, segment]);
37
55
  return true;
38
56
  }
39
- const segment = dimension === "variant" ? resolveEffectiveVariantId(serializeVariantChain(selector?.variant), (variantId) => tree[variantId] !== void 0) : String(selector?.item);
57
+ const segment = dimension === "item" && selector?.item !== void 0 ? serializeItem(selector.item) : resolveEffectiveVariantId(serializeVariantChain(selector?.variant), (variantId) => tree[variantId] !== void 0);
40
58
  const child = tree[segment];
41
59
  if (!child) return false;
42
60
  return walk(child, rest, [...segments, segment]);
@@ -48,70 +66,17 @@ const collectQualifiedChunks = (loaderMap, key, locale, selector) => {
48
66
  };
49
67
  };
50
68
  /**
51
- * Lists the chunks a selector targets in a qualified dynamic loader map,
52
- * without loading them — lets a caller warm a suspender cache ahead of render.
53
- *
54
- * @returns The targeted chunks, empty when a required coordinate is absent.
55
- */
56
- const getQualifiedDynamicChunks = (loaderMap, key, locale, selector) => {
57
- const { missed, chunks } = collectQualifiedChunks(loaderMap, key, locale, selector);
58
- return missed ? [] : chunks;
59
- };
60
- /**
61
- * Resolves the content of a qualified dynamic loader map against a selector,
62
- * loading only the chunk(s) the selector actually targets.
63
- *
64
- * Walks the nested loader tree one dimension at a time (canonical order
65
- * `variant → item`): `variant` descends by the serialized id, falling back to
66
- * `default` when the selected variant has no chunk of its own, and `item`
67
- * either narrows to the selected index or — when no item is given — expands
68
- * into every sibling chunk (the collection axis). Semantics mirror
69
- * `resolveQualifiedDictionary` so dynamic and static modes behave alike.
70
- *
71
- * The Suspense mechanism is injected through `loadChunk` so the same logic
72
- * serves both the client (suspender cache) and the server (`react.use`). Every
73
- * targeted loader is started before the first chunk is read, so sibling chunks
74
- * load in parallel rather than waterfalling.
75
- *
76
- * @param loaderMap - The qualified dynamic loader map (entry point default export).
77
- * @param key - The dictionary key (used to build stable chunk cache keys).
78
- * @param locale - The resolved locale to load chunks for.
79
- * @param selector - The selector splitting the qualifier dimensions.
80
- * @param loadChunk - Reads a started chunk promise, suspending until it resolves.
81
- * @param transform - Turns a resolved chunk dictionary into final content.
82
- */
83
- const resolveQualifiedDynamicContent = (params) => {
84
- const { loaderMap, key, locale, selector, loadChunk, transform } = params;
85
- const { itemAxisOpen, missed, chunks } = collectQualifiedChunks(loaderMap, key, locale, selector);
86
- if (missed) return itemAxisOpen ? [] : null;
87
- const dictionaries = chunks.map(({ cacheKey, loader }) => ({
88
- cacheKey,
89
- promise: loader()
90
- })).map(({ cacheKey, promise }) => loadChunk(cacheKey, promise));
91
- if (itemAxisOpen) return dictionaries.map(transform);
92
- const [dictionary] = dictionaries;
93
- return dictionary ? transform(dictionary) : null;
94
- };
95
- /**
96
- * Async counterpart of {@link resolveQualifiedDynamicContent} for frameworks
97
- * that load dictionaries with `await` instead of Suspense (Vue, Svelte, Lit,
98
- * vanilla). Awaits every targeted chunk in parallel, then resolves identically.
69
+ * Reads the metadata a selector targets out of a loaded metadata index, with
70
+ * the same entry matching as static mode.
99
71
  *
100
- * @param loaderMap - The qualified dynamic loader map.
101
- * @param key - The dictionary key (used to build stable chunk cache keys).
102
- * @param locale - The resolved locale to load chunks for.
103
- * @param selector - The selector splitting the qualifier dimensions.
104
- * @param transform - Turns a resolved chunk dictionary into final content.
72
+ * @param metadataIndex - The loaded index chunk (`metadata` maps composite ids).
73
+ * @param qualifierTypes - The key's dimensions, in canonical order.
74
+ * @param selector - The selector splitting the dimensions.
105
75
  */
106
- const resolveQualifiedDynamicContentAsync = async (params) => {
107
- const { loaderMap, key, locale, selector, transform } = params;
108
- const { itemAxisOpen, missed, chunks } = collectQualifiedChunks(loaderMap, key, locale, selector);
109
- if (missed) return itemAxisOpen ? [] : null;
110
- const dictionaries = await Promise.all(chunks.map(({ loader }) => loader()));
111
- if (itemAxisOpen) return dictionaries.map(transform);
112
- const [dictionary] = dictionaries;
113
- return dictionary ? transform(dictionary) : null;
76
+ const readMetadataIndex = (metadataIndex, qualifierTypes, selector) => {
77
+ const indexMetadata = metadataIndex?.metadata ?? {};
78
+ return matchQualifiedEntryIds(Object.keys(indexMetadata), qualifierTypes, selector).matchedIds.map((compositeId) => indexMetadata[compositeId]);
114
79
  };
115
80
 
116
- export { QUALIFIER_DYNAMIC_TYPES_KEY, getQualifiedDynamicChunks, isQualifiedDynamicLoaderMap, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync };
81
+ export { QUALIFIER_DYNAMIC_METADATA_KEY, QUALIFIER_DYNAMIC_TYPES_KEY, collectQualifiedChunks, isQualifiedDynamicLoaderMap, readMetadataIndex };
117
82
  //# sourceMappingURL=qualifiedDynamicLoader.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"qualifiedDynamicLoader.mjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDynamicLoader.ts"],"sourcesContent":["import { QUALIFIER_DYNAMIC_TYPES_KEY } from '@intlayer/config/defaultValues';\nimport type {\n Dictionary,\n DictionaryQualifierType,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport {\n COMPOSITE_ID_SEPARATOR,\n resolveEffectiveVariantId,\n serializeVariantChain,\n} from './qualifiedDictionary';\n\n/**\n * Marker property carrying the ordered qualifier dimensions on a dynamic loader\n * map. Defined in `@intlayer/config` so the code generator and the build\n * plugins can read it without pulling the runtime in, and re-exported here\n * where its consumers live.\n */\nexport { QUALIFIER_DYNAMIC_TYPES_KEY };\n\n/**\n * A lazily-imported per-locale dictionary chunk loader.\n */\nexport type DynamicDictionaryLoader = () => Promise<Dictionary>;\n\n/**\n * Nested tree of chunk loaders: one nesting level per declared dimension (in\n * canonical order), leaves are loaders.\n */\nexport type QualifiedDynamicLoaderTree = {\n [segment: string]: QualifiedDynamicLoaderTree | DynamicDictionaryLoader;\n};\n\n/**\n * Default export shape of a generated dynamic entry point for a qualified key.\n * One nesting level per dimension under each locale, plus the dimension marker.\n *\n * ```ts\n * {\n * __intlayerQualifierTypes: ['variant', 'item'],\n * en: { promo: { '1': () => import('./json/x/promo/1/en.json'), … }, … },\n * fr: { … },\n * }\n * ```\n */\nexport type QualifiedDynamicLoaderMap = {\n [QUALIFIER_DYNAMIC_TYPES_KEY]: DictionaryQualifierType[];\n [locale: string]: QualifiedDynamicLoaderTree | DictionaryQualifierType[];\n};\n\n/**\n * Type guard discriminating a qualified dynamic loader map (collections /\n * variants, possibly combined) from a plain dynamic loader map.\n */\nexport const isQualifiedDynamicLoaderMap = (\n value: unknown\n): value is QualifiedDynamicLoaderMap =>\n typeof value === 'object' &&\n value !== null &&\n QUALIFIER_DYNAMIC_TYPES_KEY in value;\n\n/** One targeted chunk: its stable cache key and lazy loader. */\nexport type CollectedChunk = {\n cacheKey: string;\n loader: DynamicDictionaryLoader;\n};\n\ntype CollectedChunks = {\n /** True when the `item` axis is open (collection result → array). */\n itemAxisOpen: boolean;\n /** True when a required coordinate is absent (result → [] or null). */\n missed: boolean;\n /** The chunks the selector targets (in collection order for the item axis). */\n chunks: CollectedChunk[];\n};\n\n/**\n * Walks the loader tree following the selector and collects the chunk loaders\n * it targets — shared by the sync ({@link resolveQualifiedDynamicContent}) and\n * async ({@link resolveQualifiedDynamicContentAsync}) resolvers.\n */\nconst collectQualifiedChunks = (\n loaderMap: QualifiedDynamicLoaderMap,\n key: string,\n locale: string,\n selector: DictionarySelector | undefined\n): CollectedChunks => {\n const qualifierTypes = loaderMap[QUALIFIER_DYNAMIC_TYPES_KEY];\n const localeTree = loaderMap[locale] as\n | QualifiedDynamicLoaderTree\n | undefined;\n\n const itemAxisOpen =\n qualifierTypes.includes('item') && selector?.item === undefined;\n\n if (!localeTree) return { itemAxisOpen, missed: true, chunks: [] };\n\n const chunks: CollectedChunk[] = [];\n\n const walk = (\n node: QualifiedDynamicLoaderTree | DynamicDictionaryLoader,\n dimensions: DictionaryQualifierType[],\n segments: string[]\n ): boolean => {\n if (dimensions.length === 0) {\n chunks.push({\n cacheKey: `${key}.${locale}.${segments.join(COMPOSITE_ID_SEPARATOR)}`,\n loader: node as DynamicDictionaryLoader,\n });\n return true;\n }\n\n const [dimension, ...rest] = dimensions;\n const tree = node as QualifiedDynamicLoaderTree;\n\n if (dimension === 'item' && selector?.item === undefined) {\n // Open collection axis: fan out into every sibling chunk, ordered.\n for (const segment of Object.keys(tree).sort(\n (left, right) => Number(left) - Number(right)\n )) {\n walk(tree[segment]!, rest, [...segments, segment]);\n }\n return true;\n }\n\n // A variant with no chunk of its own falls back to the `default` chunk, so\n // only the entries that actually differ need to be emitted.\n const segment =\n dimension === 'variant'\n ? resolveEffectiveVariantId(\n serializeVariantChain(selector?.variant),\n (variantId) => tree[variantId] !== undefined\n )\n : String(selector?.item);\n\n const child = tree[segment];\n if (!child) return false;\n\n return walk(child, rest, [...segments, segment]);\n };\n\n const found = walk(localeTree, qualifierTypes, []);\n\n return { itemAxisOpen, missed: !found, chunks };\n};\n\n/**\n * Lists the chunks a selector targets in a qualified dynamic loader map,\n * without loading them — lets a caller warm a suspender cache ahead of render.\n *\n * @returns The targeted chunks, empty when a required coordinate is absent.\n */\nexport const getQualifiedDynamicChunks = (\n loaderMap: QualifiedDynamicLoaderMap,\n key: string,\n locale: string,\n selector: DictionarySelector | undefined\n): CollectedChunk[] => {\n const { missed, chunks } = collectQualifiedChunks(\n loaderMap,\n key,\n locale,\n selector\n );\n\n return missed ? [] : chunks;\n};\n\n/**\n * Resolves the content of a qualified dynamic loader map against a selector,\n * loading only the chunk(s) the selector actually targets.\n *\n * Walks the nested loader tree one dimension at a time (canonical order\n * `variant → item`): `variant` descends by the serialized id, falling back to\n * `default` when the selected variant has no chunk of its own, and `item`\n * either narrows to the selected index or — when no item is given — expands\n * into every sibling chunk (the collection axis). Semantics mirror\n * `resolveQualifiedDictionary` so dynamic and static modes behave alike.\n *\n * The Suspense mechanism is injected through `loadChunk` so the same logic\n * serves both the client (suspender cache) and the server (`react.use`). Every\n * targeted loader is started before the first chunk is read, so sibling chunks\n * load in parallel rather than waterfalling.\n *\n * @param loaderMap - The qualified dynamic loader map (entry point default export).\n * @param key - The dictionary key (used to build stable chunk cache keys).\n * @param locale - The resolved locale to load chunks for.\n * @param selector - The selector splitting the qualifier dimensions.\n * @param loadChunk - Reads a started chunk promise, suspending until it resolves.\n * @param transform - Turns a resolved chunk dictionary into final content.\n */\nexport const resolveQualifiedDynamicContent = <Content>(params: {\n loaderMap: QualifiedDynamicLoaderMap;\n key: string;\n locale: string;\n selector: DictionarySelector | undefined;\n loadChunk: (cacheKey: string, promise: Promise<Dictionary>) => Dictionary;\n transform: (dictionary: Dictionary) => Content;\n}): Content | Content[] | null => {\n const { loaderMap, key, locale, selector, loadChunk, transform } = params;\n\n const { itemAxisOpen, missed, chunks } = collectQualifiedChunks(\n loaderMap,\n key,\n locale,\n selector\n );\n\n if (missed) return itemAxisOpen ? [] : null;\n\n // Start every loader before reading, so siblings load in parallel: the first\n // `loadChunk` that suspends throws, and would leave later loaders unstarted.\n const startedChunks = chunks.map(({ cacheKey, loader }) => ({\n cacheKey,\n promise: loader(),\n }));\n const dictionaries = startedChunks.map(({ cacheKey, promise }) =>\n loadChunk(cacheKey, promise)\n );\n\n if (itemAxisOpen) return dictionaries.map(transform);\n\n const [dictionary] = dictionaries;\n return dictionary ? transform(dictionary) : null;\n};\n\n/**\n * Async counterpart of {@link resolveQualifiedDynamicContent} for frameworks\n * that load dictionaries with `await` instead of Suspense (Vue, Svelte, Lit,\n * vanilla). Awaits every targeted chunk in parallel, then resolves identically.\n *\n * @param loaderMap - The qualified dynamic loader map.\n * @param key - The dictionary key (used to build stable chunk cache keys).\n * @param locale - The resolved locale to load chunks for.\n * @param selector - The selector splitting the qualifier dimensions.\n * @param transform - Turns a resolved chunk dictionary into final content.\n */\nexport const resolveQualifiedDynamicContentAsync = async <Content>(params: {\n loaderMap: QualifiedDynamicLoaderMap;\n key: string;\n locale: string;\n selector: DictionarySelector | undefined;\n transform: (dictionary: Dictionary) => Content;\n}): Promise<Content | Content[] | null> => {\n const { loaderMap, key, locale, selector, transform } = params;\n\n const { itemAxisOpen, missed, chunks } = collectQualifiedChunks(\n loaderMap,\n key,\n locale,\n selector\n );\n\n if (missed) return itemAxisOpen ? [] : null;\n\n const dictionaries = await Promise.all(chunks.map(({ loader }) => loader()));\n\n if (itemAxisOpen) return dictionaries.map(transform);\n\n const [dictionary] = dictionaries;\n return dictionary ? transform(dictionary) : null;\n};\n"],"mappings":";;;;;;;;AAsDA,MAAa,+BACX,UAEA,OAAO,UAAU,YACjB,UAAU,QACV,+BAA+B;;;;;;AAsBjC,MAAM,0BACJ,WACA,KACA,QACA,aACoB;CACpB,MAAM,iBAAiB,UAAU;CACjC,MAAM,aAAa,UAAU;CAI7B,MAAM,eACJ,eAAe,SAAS,MAAM,KAAK,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OAAO,eAAe,CAAC,IAAI;CAQvC,MAAM,eAJgB,OAAO,KAAK,EAAE,UAAU,cAAc;EAC1D;EACA,SAAS,OAAO;CAClB,EACiC,CAAC,CAAC,KAAK,EAAE,UAAU,cAClD,UAAU,UAAU,OAAO,CAC7B;CAEA,IAAI,cAAc,OAAO,aAAa,IAAI,SAAS;CAEnD,MAAM,CAAC,cAAc;CACrB,OAAO,aAAa,UAAU,UAAU,IAAI;AAC9C;;;;;;;;;;;;AAaA,MAAa,sCAAsC,OAAgB,WAMxB;CACzC,MAAM,EAAE,WAAW,KAAK,QAAQ,UAAU,cAAc;CAExD,MAAM,EAAE,cAAc,QAAQ,WAAW,uBACvC,WACA,KACA,QACA,QACF;CAEA,IAAI,QAAQ,OAAO,eAAe,CAAC,IAAI;CAEvC,MAAM,eAAe,MAAM,QAAQ,IAAI,OAAO,KAAK,EAAE,aAAa,OAAO,CAAC,CAAC;CAE3E,IAAI,cAAc,OAAO,aAAa,IAAI,SAAS;CAEnD,MAAM,CAAC,cAAc;CACrB,OAAO,aAAa,UAAU,UAAU,IAAI;AAC9C"}
1
+ {"version":3,"file":"qualifiedDynamicLoader.mjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDynamicLoader.ts"],"sourcesContent":["import {\n QUALIFIER_DYNAMIC_METADATA_KEY,\n QUALIFIER_DYNAMIC_TYPES_KEY,\n} from '@intlayer/config/defaultValues';\nimport type {\n Dictionary,\n DictionaryMetadata,\n DictionaryQualifierType,\n DictionarySelector,\n} from '@intlayer/types/dictionary';\nimport {\n COMPOSITE_ID_SEPARATOR,\n compareItemSegments,\n matchQualifiedEntryIds,\n resolveEffectiveVariantId,\n serializeItem,\n serializeVariantChain,\n} from './qualifiedDictionary';\n\n/**\n * Marker properties of a qualified dynamic loader map: the ordered qualifier\n * dimensions, and the per-locale metadata index loaders. Defined in\n * `@intlayer/config` so the code generator and the build plugins can read them\n * without pulling the runtime in, and re-exported here where their consumers\n * live.\n */\nexport { QUALIFIER_DYNAMIC_METADATA_KEY, QUALIFIER_DYNAMIC_TYPES_KEY };\n\n/** Cache-key suffix of a metadata index chunk (never a valid composite id). */\nconst METADATA_INDEX_CACHE_SEGMENT = '#metadata';\n\n/**\n * A lazily-imported per-locale dictionary chunk loader.\n */\nexport type DynamicDictionaryLoader = () => Promise<Dictionary>;\n\n/**\n * Nested tree of chunk loaders: one nesting level per declared dimension (in\n * canonical order), leaves are loaders.\n */\nexport type QualifiedDynamicLoaderTree = {\n [segment: string]: QualifiedDynamicLoaderTree | DynamicDictionaryLoader;\n};\n\n/**\n * Default export shape of a generated dynamic entry point for a qualified key.\n * One nesting level per dimension under each locale, plus the dimension marker.\n *\n * ```ts\n * {\n * __intlayerQualifierTypes: ['variant', 'item'],\n * en: { promo: { '1': () => import('./json/x/promo/1/en.json'), … }, … },\n * fr: { … },\n * }\n * ```\n */\nexport type QualifiedDynamicLoaderMap = {\n [QUALIFIER_DYNAMIC_TYPES_KEY]: DictionaryQualifierType[];\n /** Per-locale loaders of the metadata index (absent in older builds). */\n [QUALIFIER_DYNAMIC_METADATA_KEY]?: Record<string, DynamicDictionaryLoader>;\n [locale: string]:\n | QualifiedDynamicLoaderTree\n | DictionaryQualifierType[]\n | Record<string, DynamicDictionaryLoader>\n | undefined;\n};\n\n/**\n * Type guard discriminating a qualified dynamic loader map (collections /\n * variants, possibly combined) from a plain dynamic loader map.\n */\nexport const isQualifiedDynamicLoaderMap = (\n value: unknown\n): value is QualifiedDynamicLoaderMap =>\n typeof value === 'object' &&\n value !== null &&\n QUALIFIER_DYNAMIC_TYPES_KEY in value;\n\n/** One targeted chunk: its stable cache key and lazy loader. */\nexport type CollectedChunk = {\n cacheKey: string;\n loader: DynamicDictionaryLoader;\n /** The chunk, already loaded by the entry point's preload. */\n preloaded?: Dictionary;\n};\n\n/** The chunks a dynamic read targets. */\nexport type CollectedChunks = {\n /** True when the `item` axis is open (collection result → array). */\n itemAxisOpen: boolean;\n /** True when a required coordinate is absent (result → [] or null). */\n missed: boolean;\n /** The chunks the selector targets (in collection order for the item axis). */\n chunks: CollectedChunk[];\n /** True when the single chunk is the metadata index, not entry chunks. */\n readsMetadataIndex?: boolean;\n};\n\n/**\n * Walks the loader tree following the selector and collects the chunk loaders\n * it targets.\n *\n * Walks one dimension at a time (canonical order `variant → item`): `variant`\n * descends by the serialized id, falling back to `default` when the selected\n * variant has no chunk of its own, and `item` either narrows to the selected\n * index or — when no item is given — expands into every sibling chunk (the\n * collection axis). Semantics mirror `resolveQualifiedDictionary` so dynamic\n * and static modes behave alike.\n */\nexport const collectQualifiedChunks = (\n loaderMap: QualifiedDynamicLoaderMap,\n key: string,\n locale: string,\n selector: DictionarySelector | undefined\n): CollectedChunks => {\n const qualifierTypes = loaderMap[QUALIFIER_DYNAMIC_TYPES_KEY];\n const localeTree = loaderMap[locale] as\n | QualifiedDynamicLoaderTree\n | undefined;\n\n const itemAxisOpen =\n qualifierTypes.includes('item') && selector?.item === undefined;\n\n // Listing a collection's metadata reads the per-locale index instead of\n // every entry chunk. A pinned entry keeps loading its own chunk, which\n // carries its metadata and is usually loaded for its content anyway.\n const metadataIndexLoader =\n selector?.metadataOnly && itemAxisOpen\n ? loaderMap[QUALIFIER_DYNAMIC_METADATA_KEY]?.[locale]\n : undefined;\n\n if (metadataIndexLoader) {\n return {\n itemAxisOpen,\n missed: false,\n readsMetadataIndex: true,\n chunks: [\n {\n cacheKey: `${key}.${locale}.${METADATA_INDEX_CACHE_SEGMENT}`,\n loader: metadataIndexLoader,\n },\n ],\n };\n }\n\n if (!localeTree) return { itemAxisOpen, missed: true, chunks: [] };\n\n const chunks: CollectedChunk[] = [];\n\n const walk = (\n node: QualifiedDynamicLoaderTree | DynamicDictionaryLoader,\n dimensions: DictionaryQualifierType[],\n segments: string[]\n ): boolean => {\n if (dimensions.length === 0) {\n chunks.push({\n cacheKey: `${key}.${locale}.${segments.join(COMPOSITE_ID_SEPARATOR)}`,\n loader: node as DynamicDictionaryLoader,\n });\n return true;\n }\n\n const [dimension, ...rest] = dimensions;\n const tree = node as QualifiedDynamicLoaderTree;\n\n if (dimension === 'item' && selector?.item === undefined) {\n // Open collection axis: fan out into every sibling chunk, ordered.\n for (const segment of Object.keys(tree).sort(compareItemSegments)) {\n walk(tree[segment]!, rest, [...segments, segment]);\n }\n return true;\n }\n\n // A pinned item descends by its serialized id. A variant with no chunk of\n // its own falls back to the `default` chunk, so only the entries that\n // actually differ need to be emitted.\n const segment =\n dimension === 'item' && selector?.item !== undefined\n ? serializeItem(selector.item)\n : resolveEffectiveVariantId(\n serializeVariantChain(selector?.variant),\n (variantId) => tree[variantId] !== undefined\n );\n\n const child = tree[segment];\n if (!child) return false;\n\n return walk(child, rest, [...segments, segment]);\n };\n\n const found = walk(localeTree, qualifierTypes, []);\n\n return { itemAxisOpen, missed: !found, chunks };\n};\n\n/**\n * Reads the metadata a selector targets out of a loaded metadata index, with\n * the same entry matching as static mode.\n *\n * @param metadataIndex - The loaded index chunk (`metadata` maps composite ids).\n * @param qualifierTypes - The key's dimensions, in canonical order.\n * @param selector - The selector splitting the dimensions.\n */\nexport const readMetadataIndex = (\n metadataIndex: Dictionary | undefined,\n qualifierTypes: DictionaryQualifierType[],\n selector: DictionarySelector | undefined\n): DictionaryMetadata[] => {\n const indexMetadata = (metadataIndex?.metadata ?? {}) as Record<\n string,\n DictionaryMetadata\n >;\n\n return matchQualifiedEntryIds(\n Object.keys(indexMetadata),\n qualifierTypes,\n selector\n ).matchedIds.map((compositeId) => indexMetadata[compositeId]!);\n};\n"],"mappings":";;;;;AA6BA,MAAM,+BAA+B;;;;;AA0CrC,MAAa,+BACX,UAEA,OAAO,UAAU,YACjB,UAAU,QACV,+BAA+B;;;;;;;;;;;;AAiCjC,MAAa,0BACX,WACA,KACA,QACA,aACoB;CACpB,MAAM,iBAAiB,UAAU;CACjC,MAAM,aAAa,UAAU;CAI7B,MAAM,eACJ,eAAe,SAAS,MAAM,KAAK,UAAU,SAAS;CAKxD,MAAM,sBACJ,UAAU,gBAAg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"}
@@ -6,7 +6,8 @@ import { DEFAULT_PLURAL_VARIABLE, plural } from "./transpiler/plural/plural.mjs"
6
6
  import { findMatchingCondition, getEnumeration } from "./interpreter/getEnumeration.mjs";
7
7
  import { getGender } from "./interpreter/getGender.mjs";
8
8
  import { getInsertion } from "./interpreter/getInsertion.mjs";
9
- import { COMPOSITE_ID_SEPARATOR, DEFAULT_VARIANT_ID, getDictionarySelectorCacheKey, isQualifiedDictionaryGroup, parseDictionarySelector, reconstructQualifiedEntry, resolveDictionaryArgument, resolveEffectiveVariantId, resolveProviderVariant, resolveQualifiedDictionary, serializeVariant, serializeVariantChain } from "./dictionaryManipulator/qualifiedDictionary.mjs";
9
+ import { getLocalizedMetadata } from "./dictionaryManipulator/getLocalizedMetadata.mjs";
10
+ import { COMPOSITE_ID_SEPARATOR, DEFAULT_VARIANT_ID, compareItemIds, compareItemSegments, getDictionarySelectorCacheKey, isQualifiedDictionaryGroup, matchQualifiedEntryIds, parseDictionarySelector, parseItemId, parseItemSegment, reconstructQualifiedEntry, resolveDictionaryArgument, resolveEffectiveVariantId, resolveProviderVariant, resolveQualifiedDictionary, serializeItem, serializeVariant, serializeVariantChain } from "./dictionaryManipulator/qualifiedDictionary.mjs";
10
11
  import { getCookie } from "./utils/getCookie.mjs";
11
12
  import { LocaleStorage, LocaleStorageClient, LocaleStorageServer, getCachedLocaleFromStorageClient, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, localeStorageOptions, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer } from "./utils/localeStorage.mjs";
12
13
  import { registerAmbientLocaleResolver, registerAsyncAmbientLocaleResolver, resolveInterpreterLocale, resolveInterpreterLocaleAsync } from "./interpreter/resolveInterpreterLocale.mjs";
@@ -29,8 +30,9 @@ import { getInterpolableContent, isInterpolableWrapperNode, rebuildInterpolableC
29
30
  import { bindInsertedValues, conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, pluralPlugin, resolveInsertedSelector, selectPlugin, translationPlugin } from "./interpreter/getContent/plugins.mjs";
30
31
  import { getBasePlugins, getContent } from "./interpreter/getContent/getContent.mjs";
31
32
  import { PRELOADED_DYNAMIC_KEY, getPreloadedDictionary } from "./dictionaryManipulator/preloadedDynamicLoader.mjs";
32
- import { QUALIFIER_DYNAMIC_TYPES_KEY, getQualifiedDynamicChunks, isQualifiedDynamicLoaderMap, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync } from "./dictionaryManipulator/qualifiedDynamicLoader.mjs";
33
+ import { QUALIFIER_DYNAMIC_METADATA_KEY, QUALIFIER_DYNAMIC_TYPES_KEY, collectQualifiedChunks, isQualifiedDynamicLoaderMap, readMetadataIndex } from "./dictionaryManipulator/qualifiedDynamicLoader.mjs";
33
34
  import { findPlainDynamicLoader, resolvePlainDynamicLoader } from "./dictionaryManipulator/plainDynamicLoader.mjs";
35
+ import { createChunkSuspenseCache, createDynamicContentStore, getDynamicChunkArgument, getDynamicChunks, loadDynamicDictionary, loadingContentPlaceholder, resolveDictionaryRead, resolveDynamicContent, resolveDynamicContentAsync } from "./dictionaryManipulator/dynamicDictionary.mjs";
34
36
  import { getDictionaryAsync } from "./interpreter/getDictionaryAsync.mjs";
35
37
  import { getHTML } from "./interpreter/getHTML.mjs";
36
38
  import { getIntlayerAsync } from "./interpreter/getIntlayerAsync.mjs";
@@ -69,7 +71,7 @@ import { getNodeChildren } from "./dictionaryManipulator/getNodeChildren.mjs";
69
71
  import { isValidElement } from "./utils/isValidReactElement.mjs";
70
72
  import { getNodeType } from "./dictionaryManipulator/getNodeType.mjs";
71
73
  import { mergeDictionaries } from "./dictionaryManipulator/mergeDictionaries.mjs";
72
- import { QUALIFIER_ORDER, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getVariantIds } from "./dictionaryManipulator/qualifiedDictionaryDeclaration.mjs";
74
+ import { QUALIFIER_ORDER, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getVariantIds, isDeclaredItem } from "./dictionaryManipulator/qualifiedDictionaryDeclaration.mjs";
73
75
  import { mergeQualifiedDictionaries } from "./dictionaryManipulator/mergeQualifiedDictionaries.mjs";
74
76
  import { orderDictionaries } from "./dictionaryManipulator/orderDictionaries.mjs";
75
77
  import { normalizeDictionaries, normalizeDictionary } from "./dictionaryManipulator/normalizeDictionary.mjs";
@@ -116,4 +118,4 @@ import { getIntlayerNodePrototype } from "./utils/intlayerNodePrototype.mjs";
116
118
  import { isSameKeyPath } from "./utils/isSameKeyPath.mjs";
117
119
  import { stringifyYaml } from "./utils/stringifyYaml.mjs";
118
120
 
119
- export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_NAME_START_R, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, COMPOSITE_ID_SEPARATOR, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CachedIntl, CachedIntl as Intl, DEFAULT_PLURAL_VARIABLE, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, FENCE_DELIMITER_R, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_TAGS, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LOOKAHEAD, LocaleStorage, LocaleStorageClient, LocaleStorageServer, NAMED_CODES_TO_UNICODE, NP_TABLE_R, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, PARAGRAPH_R, PRELOADED_DYNAMIC_KEY, Priority, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleScope, RuleType, SCOPE_BLOCK, SCOPE_BOTH, SCOPE_INLINE, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, VOID_HTML_ELEMENTS, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindInsertedValues, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, collectTransformCacheWrites, compact, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createCompiler, createMessageResolver, createRenderer, currency, cx, date, deepTransformNode, deleteTransformCacheWrites, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, findPlainDynamicLoader, formatProxyEnabledMessage, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCachedLocaleFromStorageClient, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryAsync, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDictionaryTransformCacheKey, getDomainHostname, getDomainOrigin, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getIntlayerAsync, getIntlayerNodePrototype, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromRequest, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNestedDictionaryGraph, getNestedDictionaryKeys, getNestedDictionaryReferences, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPluginsCacheKey, getPlural, getPrefix, getPreloadLocale, getPreloadedDictionary, getQualifiedDynamicChunks, getReplacedValuesContent, getRewritePath, getRewriteRules, getRuleSet, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, isDeclaredLocale, isInterpolableWrapperNode, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, isQualifiedDictionaryGroup, isQualifiedDynamicLoaderMap, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, mergeQualifiedDictionaries, navigatePath, nesting as nest, nestedPlugin, normalizeAttributeKey, normalizeDictionaries, normalizeDictionary, normalizePath, normalizeWhitespace, number, orderDictionaries, parseBlock, parseCaptureInline, parseDictionarySelector, parseInline, parseMarkdown, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parseTaggedMessage, parseYaml, parserFor, percentage, plural, pluralPlugin, portableObjectToIntlayerFormatter, presets, qualifies, readTransformCache, rebuildInterpolableContent, reconstructQualifiedEntry, registerAmbientLocaleResolver, registerAsyncAmbientLocaleResolver, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveBrowserLocale, resolveDictionaryArgument, resolveEffectiveVariantId, resolveInsertedSelector, resolveInterpreterLocale, resolveInterpreterLocaleAsync, resolveLocalizedPath, resolveMessage, resolveMessageNode, resolveMessageNodeToString, resolvePlainDynamicLoader, resolveProviderVariant, resolveProxyMode, resolveQualifiedDictionary, resolveQualifiedDynamicContent, resolveQualifiedDynamicContentAsync, sanitizer, select, selectPlugin, serializeVariant, serializeVariantChain, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer, simpleInlineRegex, slugify, some, splitInsertionTemplate, startsWith, stringifyYaml, translation as t, transformInterpolableNode, translationPlugin, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, units, unquote, updateNodeChildren, validateHTML, validateMarkdown, validatePrefix, vueI18nToIntlayerFormatter, writeTransformCache };
121
+ export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_NAME_START_R, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, COMPOSITE_ID_SEPARATOR, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CachedIntl, CachedIntl as Intl, DEFAULT_PLURAL_VARIABLE, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, FENCE_DELIMITER_R, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_TAGS, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LOOKAHEAD, LocaleStorage, LocaleStorageClient, LocaleStorageServer, NAMED_CODES_TO_UNICODE, NP_TABLE_R, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, PARAGRAPH_R, PRELOADED_DYNAMIC_KEY, Priority, QUALIFIER_DYNAMIC_METADATA_KEY, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleScope, RuleType, SCOPE_BLOCK, SCOPE_BOTH, SCOPE_INLINE, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, VOID_HTML_ELEMENTS, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindInsertedValues, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, collectQualifiedChunks, collectTransformCacheWrites, compact, compareItemIds, compareItemSegments, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createChunkSuspenseCache, createCompiler, createDynamicContentStore, createMessageResolver, createRenderer, currency, cx, date, deepTransformNode, deleteTransformCacheWrites, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, findPlainDynamicLoader, formatProxyEnabledMessage, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCachedLocaleFromStorageClient, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryAsync, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDictionaryTransformCacheKey, getDomainHostname, getDomainOrigin, getDynamicChunkArgument, getDynamicChunks, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getIntlayerAsync, getIntlayerNodePrototype, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromRequest, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedMetadata, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNestedDictionaryGraph, getNestedDictionaryKeys, getNestedDictionaryReferences, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPluginsCacheKey, getPlural, getPrefix, getPreloadLocale, getPreloadedDictionary, getReplacedValuesContent, getRewritePath, getRewriteRules, getRuleSet, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, isDeclaredItem, isDeclaredLocale, isInterpolableWrapperNode, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, isQualifiedDictionaryGroup, isQualifiedDynamicLoaderMap, isSameKeyPath, isValidElement, list, loadDynamicDictionary, loadingContentPlaceholder, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, matchQualifiedEntryIds, markdown as md, mergeDictionaries, mergeQualifiedDictionaries, navigatePath, nesting as nest, nestedPlugin, normalizeAttributeKey, normalizeDictionaries, normalizeDictionary, normalizePath, normalizeWhitespace, number, orderDictionaries, parseBlock, parseCaptureInline, parseDictionarySelector, parseInline, parseItemId, parseItemSegment, parseMarkdown, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parseTaggedMessage, parseYaml, parserFor, percentage, plural, pluralPlugin, portableObjectToIntlayerFormatter, presets, qualifies, readMetadataIndex, readTransformCache, rebuildInterpolableContent, reconstructQualifiedEntry, registerAmbientLocaleResolver, registerAsyncAmbientLocaleResolver, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveBrowserLocale, resolveDictionaryArgument, resolveDictionaryRead, resolveDynamicContent, resolveDynamicContentAsync, resolveEffectiveVariantId, resolveInsertedSelector, resolveInterpreterLocale, resolveInterpreterLocaleAsync, resolveLocalizedPath, resolveMessage, resolveMessageNode, resolveMessageNodeToString, resolvePlainDynamicLoader, resolveProviderVariant, resolveProxyMode, resolveQualifiedDictionary, sanitizer, select, selectPlugin, serializeItem, serializeVariant, serializeVariantChain, setLocaleInStorage, setLocaleInStorageClient, setLocaleInStorageServer, simpleInlineRegex, slugify, some, splitInsertionTemplate, startsWith, stringifyYaml, translation as t, transformInterpolableNode, translationPlugin, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, units, unquote, updateNodeChildren, validateHTML, validateMarkdown, validatePrefix, vueI18nToIntlayerFormatter, writeTransformCache };