@intlayer/core 9.1.2 → 9.2.0

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 (30) hide show
  1. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.test-d.cjs +7 -2
  2. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.test-d.cjs.map +1 -1
  3. package/dist/cjs/index.cjs +4 -0
  4. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  5. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  6. package/dist/cjs/interpreter/getIntlayer.test-d.cjs +28 -0
  7. package/dist/cjs/interpreter/getIntlayer.test-d.cjs.map +1 -0
  8. package/dist/cjs/localization/index.cjs +4 -0
  9. package/dist/cjs/localization/proxyMode.cjs +92 -0
  10. package/dist/cjs/localization/proxyMode.cjs.map +1 -0
  11. package/dist/esm/dictionaryManipulator/qualifiedDictionary.test-d.mjs +7 -2
  12. package/dist/esm/dictionaryManipulator/qualifiedDictionary.test-d.mjs.map +1 -1
  13. package/dist/esm/index.mjs +2 -1
  14. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  15. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  16. package/dist/esm/interpreter/getIntlayer.test-d.mjs +28 -0
  17. package/dist/esm/interpreter/getIntlayer.test-d.mjs.map +1 -0
  18. package/dist/esm/localization/index.mjs +2 -1
  19. package/dist/esm/localization/proxyMode.mjs +87 -0
  20. package/dist/esm/localization/proxyMode.mjs.map +1 -0
  21. package/dist/types/index.d.ts +2 -1
  22. package/dist/types/interpreter/getDictionary.d.ts +2 -2
  23. package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
  24. package/dist/types/interpreter/getIntlayer.d.ts +2 -2
  25. package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
  26. package/dist/types/interpreter/getIntlayer.test-d.d.ts +1 -0
  27. package/dist/types/localization/index.d.ts +2 -1
  28. package/dist/types/localization/proxyMode.d.ts +92 -0
  29. package/dist/types/localization/proxyMode.d.ts.map +1 -0
  30. package/package.json +6 -6
@@ -73,8 +73,13 @@ let vitest = require("vitest");
73
73
  (0, vitest.expectTypeOf)().not.toExtend();
74
74
  });
75
75
  });
76
- (0, vitest.it)("should reject an undeclared locale", () => {
77
- (0, vitest.expectTypeOf)().not.toExtend();
76
+ (0, vitest.describe)("locale", () => {
77
+ (0, vitest.it)("should accept a declared locale", () => {
78
+ (0, vitest.expectTypeOf)().toExtend();
79
+ });
80
+ (0, vitest.it)("should accept a widened `string` locale", () => {
81
+ (0, vitest.expectTypeOf)().toExtend();
82
+ });
78
83
  });
79
84
  });
80
85
  (0, vitest.describe)("DictionarySelectorForGroup — keys without a default entry", () => {
@@ -1 +1 @@
1
- {"version":3,"file":"qualifiedDictionary.test-d.cjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDictionary.test-d.ts"],"sourcesContent":["import type {\n DictionarySelectorForGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport { describe, expectTypeOf, it } from 'vitest';\n\n/**\n * Compile-time counterpart of `qualifiedDictionary.test.ts`. The runtime\n * resolver and `ResolveQualifiedDictionaryContent` implement the same rules\n * twice — once in value space, once in type space — so a divergence between\n * them is invisible to the runtime suite. These assertions pin the type side.\n *\n * Groups are written the way `createTypes` emits them (`as const`, hence\n * readonly tuples of qualifier dimensions and literal composite-id keys).\n */\n\ntype LessonGroup = {\n key: 'lesson';\n qualifierTypes: readonly ['variant'];\n content: {\n default: { title: 'Lesson'; teacher: 'Teacher' };\n preschool: { title: 'Lesson'; teacher: 'Pedagogue' };\n };\n};\n\ntype NoDefaultGroup = {\n key: 'promoOnly';\n qualifierTypes: readonly ['variant'];\n content: { promo: { title: 'Promo' } };\n};\n\ntype BannerGroup = {\n key: 'banner';\n qualifierTypes: readonly ['variant', 'item'];\n content: {\n 'default/1': { title: 'D1' };\n 'promo/1': { title: 'P1' };\n 'promo/2': { title: 'P2' };\n };\n};\n\ntype FaqGroup = {\n key: 'faq';\n qualifierTypes: readonly ['item'];\n content: { '1': { question: 'Q1' }; '2': { question: 'Q2' } };\n};\n\ntype ProductGroup = {\n key: 'product';\n qualifierTypes: readonly ['variant'];\n content: { 'id=abc&userId=123': { name: 'ABC' } };\n};\n\ndescribe('ResolveQualifiedDictionaryContent', () => {\n it('should resolve a plain dictionary to its content, ignoring the selector', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<{ key: 'home'; content: { a: 'b' } }>\n >().toEqualTypeOf<{ a: 'b' }>();\n });\n\n describe('variant', () => {\n it('should resolve to the default entry when no variant is selected', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve a locale-only selector like no selector', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup, { locale: 'sv' }>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve a declared variant to its own entry', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup, { variant: 'preschool' }>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Pedagogue' }>();\n });\n\n it('should fall back to the default entry for an undeclared variant', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n LessonGroup,\n { variant: 'upperSecondary' }\n >\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve to null when no default entry is declared', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n NoDefaultGroup,\n { variant: 'unknown' }\n >\n >().toEqualTypeOf<null>();\n });\n\n it('should resolve an object variant to its entry', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n ProductGroup,\n { variant: { id: 'abc'; userId: '123' } }\n >\n >().toEqualTypeOf<{ name: 'ABC' }>();\n });\n\n it('should resolve to null when an object-variant key has no default', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<ProductGroup>\n >().toEqualTypeOf<null>();\n });\n });\n\n describe('item', () => {\n it('should resolve to an array of every item when the axis is left open', () => {\n expectTypeOf<ResolveQualifiedDictionaryContent<FaqGroup>>().toEqualTypeOf<\n ({ question: 'Q1' } | { question: 'Q2' })[]\n >();\n });\n\n it('should narrow to the selected item', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<FaqGroup, { item: 2 }>\n >().toEqualTypeOf<{ question: 'Q2' }>();\n });\n });\n\n describe('composite (variant × item)', () => {\n it('should narrow to a single entry when both dimensions are pinned', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n BannerGroup,\n { variant: 'promo'; item: 2 }\n >\n >().toEqualTypeOf<{ title: 'P2' }>();\n });\n\n it('should fan the item axis out for the selected variant', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<BannerGroup, { variant: 'promo' }>\n >().toEqualTypeOf<({ title: 'P1' } | { title: 'P2' })[]>();\n });\n\n it('should fall back to the default variant then fan out its items', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<BannerGroup, { variant: 'unknown' }>\n >().toEqualTypeOf<{ title: 'D1' }[]>();\n });\n });\n});\n\ndescribe('DictionarySelectorForGroup', () => {\n /** Stands in for the project-wide variant vocabulary (`DeclaredVariants`). */\n type ProjectVariants = 'default' | 'preschool' | 'promo';\n\n type LessonSelector = DictionarySelectorForGroup<\n LessonGroup,\n ProjectVariants\n >;\n\n it('should accept a variant this key declares', () => {\n expectTypeOf<{ variant: 'preschool' }>().toExtend<LessonSelector>();\n });\n\n it('should accept a variant declared elsewhere in the project', () => {\n // `LessonGroup` has no `promo` entry — it resolves to `default` at runtime,\n // which is what makes one session-wide variant usable across every key.\n expectTypeOf<{ variant: 'promo' }>().toExtend<LessonSelector>();\n });\n\n it('should reject a variant no dictionary declares', () => {\n expectTypeOf<{ variant: 'promoo' }>().not.toExtend<LessonSelector>();\n });\n\n it('should reject an object variant on a key that declares none', () => {\n expectTypeOf<{ variant: { id: 'abc' } }>().not.toExtend<LessonSelector>();\n });\n\n describe('object variants', () => {\n // `ProductGroup` stores `'id=abc&userId=123'` — the serialized form of\n // `{ id: 'abc', userId: '123' }`.\n type ProductSelector = DictionarySelectorForGroup<\n ProductGroup,\n ProjectVariants\n >;\n\n it('should accept the object the key declares', () => {\n expectTypeOf<{\n variant: { id: 'abc'; userId: '123' };\n }>().toExtend<ProductSelector>();\n });\n\n it('should reject the serialized form as a string', () => {\n // `'id=abc&userId=123'` is a storage encoding, not part of the API.\n expectTypeOf<{\n variant: 'id=abc&userId=123';\n }>().not.toExtend<ProductSelector>();\n });\n\n it('should reject a partial or mismatched object', () => {\n expectTypeOf<{\n variant: { id: 'abc' };\n }>().not.toExtend<ProductSelector>();\n expectTypeOf<{\n variant: { id: 'abc'; userId: 'other' };\n }>().not.toExtend<ProductSelector>();\n });\n });\n\n it('should reject an undeclared locale', () => {\n expectTypeOf<{ locale: 'not-a-locale' }>().not.toExtend<LessonSelector>();\n });\n});\n\ndescribe('DictionarySelectorForGroup — keys without a default entry', () => {\n type ProjectVariants = 'default' | 'preschool' | 'promo';\n\n // Declares only object variants: an undeclared name resolves to `null`, so\n // the project vocabulary must not be accepted here.\n type ProductSelector = DictionarySelectorForGroup<\n ProductGroup,\n ProjectVariants\n >;\n\n // Declares `promo` but no `default` — same reasoning.\n type NoDefaultSelector = DictionarySelectorForGroup<\n NoDefaultGroup,\n ProjectVariants\n >;\n\n it('should reject a project variant on a key with no default entry', () => {\n expectTypeOf<{ variant: 'promo' }>().not.toExtend<ProductSelector>();\n expectTypeOf<{ variant: 'default' }>().not.toExtend<ProductSelector>();\n expectTypeOf<{ variant: 'preschool' }>().not.toExtend<NoDefaultSelector>();\n });\n\n it('should still accept the names such a key declares itself', () => {\n expectTypeOf<{ variant: 'promo' }>().toExtend<NoDefaultSelector>();\n });\n});\n"],"mappings":";;;qBAqDS,2CAA2C;CAClD,eAAG,iFAAiF;EAClF,yBAEE,CAAC,CAAC,cAA0B;CAChC,CAAC;CAED,qBAAS,iBAAiB;EACxB,eAAG,yEAAyE;GAC1E,yBAEE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,eAAG,gEAAgE;GACjE,yBAEE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,eAAG,4DAA4D;GAC7D,yBAEE,CAAC,CAAC,cAAyD;EAC/D,CAAC;EAED,eAAG,yEAAyE;GAC1E,yBAKE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,eAAG,kEAAkE;GACnE,yBAKE,CAAC,CAAC,cAAoB;EAC1B,CAAC;EAED,eAAG,uDAAuD;GACxD,yBAKE,CAAC,CAAC,cAA+B;EACrC,CAAC;EAED,eAAG,0EAA0E;GAC3E,yBAEE,CAAC,CAAC,cAAoB;EAC1B,CAAC;CACH,CAAC;CAED,qBAAS,cAAc;EACrB,eAAG,6EAA6E;GAC9E,yBAA0D,CAAC,CAAC,cAE1D;EACJ,CAAC;EAED,eAAG,4CAA4C;GAC7C,yBAEE,CAAC,CAAC,cAAkC;EACxC,CAAC;CACH,CAAC;CAED,qBAAS,oCAAoC;EAC3C,eAAG,yEAAyE;GAC1E,yBAKE,CAAC,CAAC,cAA+B;EACrC,CAAC;EAED,eAAG,+DAA+D;GAChE,yBAEE,CAAC,CAAC,cAAqD;EAC3D,CAAC;EAED,eAAG,wEAAwE;GACzE,yBAEE,CAAC,CAAC,cAAiC;EACvC,CAAC;CACH,CAAC;AACH,CAAC;qBAEQ,oCAAoC;CAS3C,eAAG,mDAAmD;EACpD,yBAAuC,CAAC,CAAC,SAAyB;CACpE,CAAC;CAED,eAAG,mEAAmE;EAGpE,yBAAmC,CAAC,CAAC,SAAyB;CAChE,CAAC;CAED,eAAG,wDAAwD;EACzD,yBAAoC,CAAC,CAAC,IAAI,SAAyB;CACrE,CAAC;CAED,eAAG,qEAAqE;EACtE,yBAAyC,CAAC,CAAC,IAAI,SAAyB;CAC1E,CAAC;CAED,qBAAS,yBAAyB;EAQhC,eAAG,mDAAmD;GACpD,yBAEG,CAAC,CAAC,SAA0B;EACjC,CAAC;EAED,eAAG,uDAAuD;GAExD,yBAEG,CAAC,CAAC,IAAI,SAA0B;EACrC,CAAC;EAED,eAAG,sDAAsD;GACvD,yBAEG,CAAC,CAAC,IAAI,SAA0B;GACnC,yBAEG,CAAC,CAAC,IAAI,SAA0B;EACrC,CAAC;CACH,CAAC;CAED,eAAG,4CAA4C;EAC7C,yBAAyC,CAAC,CAAC,IAAI,SAAyB;CAC1E,CAAC;AACH,CAAC;qBAEQ,mEAAmE;CAgB1E,eAAG,wEAAwE;EACzE,yBAAmC,CAAC,CAAC,IAAI,SAA0B;EACnE,yBAAqC,CAAC,CAAC,IAAI,SAA0B;EACrE,yBAAuC,CAAC,CAAC,IAAI,SAA4B;CAC3E,CAAC;CAED,eAAG,kEAAkE;EACnE,yBAAmC,CAAC,CAAC,SAA4B;CACnE,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"qualifiedDictionary.test-d.cjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDictionary.test-d.ts"],"sourcesContent":["import type {\n DictionarySelectorForGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport { describe, expectTypeOf, it } from 'vitest';\n\n/**\n * Compile-time counterpart of `qualifiedDictionary.test.ts`. The runtime\n * resolver and `ResolveQualifiedDictionaryContent` implement the same rules\n * twice — once in value space, once in type space — so a divergence between\n * them is invisible to the runtime suite. These assertions pin the type side.\n *\n * Groups are written the way `createTypes` emits them (`as const`, hence\n * readonly tuples of qualifier dimensions and literal composite-id keys).\n */\n\ntype LessonGroup = {\n key: 'lesson';\n qualifierTypes: readonly ['variant'];\n content: {\n default: { title: 'Lesson'; teacher: 'Teacher' };\n preschool: { title: 'Lesson'; teacher: 'Pedagogue' };\n };\n};\n\ntype NoDefaultGroup = {\n key: 'promoOnly';\n qualifierTypes: readonly ['variant'];\n content: { promo: { title: 'Promo' } };\n};\n\ntype BannerGroup = {\n key: 'banner';\n qualifierTypes: readonly ['variant', 'item'];\n content: {\n 'default/1': { title: 'D1' };\n 'promo/1': { title: 'P1' };\n 'promo/2': { title: 'P2' };\n };\n};\n\ntype FaqGroup = {\n key: 'faq';\n qualifierTypes: readonly ['item'];\n content: { '1': { question: 'Q1' }; '2': { question: 'Q2' } };\n};\n\ntype ProductGroup = {\n key: 'product';\n qualifierTypes: readonly ['variant'];\n content: { 'id=abc&userId=123': { name: 'ABC' } };\n};\n\ndescribe('ResolveQualifiedDictionaryContent', () => {\n it('should resolve a plain dictionary to its content, ignoring the selector', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<{ key: 'home'; content: { a: 'b' } }>\n >().toEqualTypeOf<{ a: 'b' }>();\n });\n\n describe('variant', () => {\n it('should resolve to the default entry when no variant is selected', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve a locale-only selector like no selector', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup, { locale: 'sv' }>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve a declared variant to its own entry', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup, { variant: 'preschool' }>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Pedagogue' }>();\n });\n\n it('should fall back to the default entry for an undeclared variant', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n LessonGroup,\n { variant: 'upperSecondary' }\n >\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve to null when no default entry is declared', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n NoDefaultGroup,\n { variant: 'unknown' }\n >\n >().toEqualTypeOf<null>();\n });\n\n it('should resolve an object variant to its entry', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n ProductGroup,\n { variant: { id: 'abc'; userId: '123' } }\n >\n >().toEqualTypeOf<{ name: 'ABC' }>();\n });\n\n it('should resolve to null when an object-variant key has no default', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<ProductGroup>\n >().toEqualTypeOf<null>();\n });\n });\n\n describe('item', () => {\n it('should resolve to an array of every item when the axis is left open', () => {\n expectTypeOf<ResolveQualifiedDictionaryContent<FaqGroup>>().toEqualTypeOf<\n ({ question: 'Q1' } | { question: 'Q2' })[]\n >();\n });\n\n it('should narrow to the selected item', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<FaqGroup, { item: 2 }>\n >().toEqualTypeOf<{ question: 'Q2' }>();\n });\n });\n\n describe('composite (variant × item)', () => {\n it('should narrow to a single entry when both dimensions are pinned', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n BannerGroup,\n { variant: 'promo'; item: 2 }\n >\n >().toEqualTypeOf<{ title: 'P2' }>();\n });\n\n it('should fan the item axis out for the selected variant', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<BannerGroup, { variant: 'promo' }>\n >().toEqualTypeOf<({ title: 'P1' } | { title: 'P2' })[]>();\n });\n\n it('should fall back to the default variant then fan out its items', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<BannerGroup, { variant: 'unknown' }>\n >().toEqualTypeOf<{ title: 'D1' }[]>();\n });\n });\n});\n\ndescribe('DictionarySelectorForGroup', () => {\n /** Stands in for the project-wide variant vocabulary (`DeclaredVariants`). */\n type ProjectVariants = 'default' | 'preschool' | 'promo';\n\n type LessonSelector = DictionarySelectorForGroup<\n LessonGroup,\n ProjectVariants\n >;\n\n it('should accept a variant this key declares', () => {\n expectTypeOf<{ variant: 'preschool' }>().toExtend<LessonSelector>();\n });\n\n it('should accept a variant declared elsewhere in the project', () => {\n // `LessonGroup` has no `promo` entry — it resolves to `default` at runtime,\n // which is what makes one session-wide variant usable across every key.\n expectTypeOf<{ variant: 'promo' }>().toExtend<LessonSelector>();\n });\n\n it('should reject a variant no dictionary declares', () => {\n expectTypeOf<{ variant: 'promoo' }>().not.toExtend<LessonSelector>();\n });\n\n it('should reject an object variant on a key that declares none', () => {\n expectTypeOf<{ variant: { id: 'abc' } }>().not.toExtend<LessonSelector>();\n });\n\n describe('object variants', () => {\n // `ProductGroup` stores `'id=abc&userId=123'` — the serialized form of\n // `{ id: 'abc', userId: '123' }`.\n type ProductSelector = DictionarySelectorForGroup<\n ProductGroup,\n ProjectVariants\n >;\n\n it('should accept the object the key declares', () => {\n expectTypeOf<{\n variant: { id: 'abc'; userId: '123' };\n }>().toExtend<ProductSelector>();\n });\n\n it('should reject the serialized form as a string', () => {\n // `'id=abc&userId=123'` is a storage encoding, not part of the API.\n expectTypeOf<{\n variant: 'id=abc&userId=123';\n }>().not.toExtend<ProductSelector>();\n });\n\n it('should reject a partial or mismatched object', () => {\n expectTypeOf<{\n variant: { id: 'abc' };\n }>().not.toExtend<ProductSelector>();\n expectTypeOf<{\n variant: { id: 'abc'; userId: 'other' };\n }>().not.toExtend<ProductSelector>();\n });\n });\n\n describe('locale', () => {\n it('should accept a declared locale', () => {\n expectTypeOf<{ locale: 'fr' }>().toExtend<LessonSelector>();\n });\n\n it('should accept a widened `string` locale', () => {\n // A locale usually reaches this API as a router param (`params.locale`)\n // or a stored value, both typed `string`. Rejecting those would force a\n // cast at every call site, so the declared locales are suggestions only.\n expectTypeOf<{ locale: string }>().toExtend<LessonSelector>();\n });\n });\n});\n\ndescribe('DictionarySelectorForGroup — keys without a default entry', () => {\n type ProjectVariants = 'default' | 'preschool' | 'promo';\n\n // Declares only object variants: an undeclared name resolves to `null`, so\n // the project vocabulary must not be accepted here.\n type ProductSelector = DictionarySelectorForGroup<\n ProductGroup,\n ProjectVariants\n >;\n\n // Declares `promo` but no `default` — same reasoning.\n type NoDefaultSelector = DictionarySelectorForGroup<\n NoDefaultGroup,\n ProjectVariants\n >;\n\n it('should reject a project variant on a key with no default entry', () => {\n expectTypeOf<{ variant: 'promo' }>().not.toExtend<ProductSelector>();\n expectTypeOf<{ variant: 'default' }>().not.toExtend<ProductSelector>();\n expectTypeOf<{ variant: 'preschool' }>().not.toExtend<NoDefaultSelector>();\n });\n\n it('should still accept the names such a key declares itself', () => {\n expectTypeOf<{ variant: 'promo' }>().toExtend<NoDefaultSelector>();\n });\n});\n"],"mappings":";;;qBAqDS,2CAA2C;CAClD,eAAG,iFAAiF;EAClF,yBAEE,CAAC,CAAC,cAA0B;CAChC,CAAC;CAED,qBAAS,iBAAiB;EACxB,eAAG,yEAAyE;GAC1E,yBAEE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,eAAG,gEAAgE;GACjE,yBAEE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,eAAG,4DAA4D;GAC7D,yBAEE,CAAC,CAAC,cAAyD;EAC/D,CAAC;EAED,eAAG,yEAAyE;GAC1E,yBAKE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,eAAG,kEAAkE;GACnE,yBAKE,CAAC,CAAC,cAAoB;EAC1B,CAAC;EAED,eAAG,uDAAuD;GACxD,yBAKE,CAAC,CAAC,cAA+B;EACrC,CAAC;EAED,eAAG,0EAA0E;GAC3E,yBAEE,CAAC,CAAC,cAAoB;EAC1B,CAAC;CACH,CAAC;CAED,qBAAS,cAAc;EACrB,eAAG,6EAA6E;GAC9E,yBAA0D,CAAC,CAAC,cAE1D;EACJ,CAAC;EAED,eAAG,4CAA4C;GAC7C,yBAEE,CAAC,CAAC,cAAkC;EACxC,CAAC;CACH,CAAC;CAED,qBAAS,oCAAoC;EAC3C,eAAG,yEAAyE;GAC1E,yBAKE,CAAC,CAAC,cAA+B;EACrC,CAAC;EAED,eAAG,+DAA+D;GAChE,yBAEE,CAAC,CAAC,cAAqD;EAC3D,CAAC;EAED,eAAG,wEAAwE;GACzE,yBAEE,CAAC,CAAC,cAAiC;EACvC,CAAC;CACH,CAAC;AACH,CAAC;qBAEQ,oCAAoC;CAS3C,eAAG,mDAAmD;EACpD,yBAAuC,CAAC,CAAC,SAAyB;CACpE,CAAC;CAED,eAAG,mEAAmE;EAGpE,yBAAmC,CAAC,CAAC,SAAyB;CAChE,CAAC;CAED,eAAG,wDAAwD;EACzD,yBAAoC,CAAC,CAAC,IAAI,SAAyB;CACrE,CAAC;CAED,eAAG,qEAAqE;EACtE,yBAAyC,CAAC,CAAC,IAAI,SAAyB;CAC1E,CAAC;CAED,qBAAS,yBAAyB;EAQhC,eAAG,mDAAmD;GACpD,yBAEG,CAAC,CAAC,SAA0B;EACjC,CAAC;EAED,eAAG,uDAAuD;GAExD,yBAEG,CAAC,CAAC,IAAI,SAA0B;EACrC,CAAC;EAED,eAAG,sDAAsD;GACvD,yBAEG,CAAC,CAAC,IAAI,SAA0B;GACnC,yBAEG,CAAC,CAAC,IAAI,SAA0B;EACrC,CAAC;CACH,CAAC;CAED,qBAAS,gBAAgB;EACvB,eAAG,yCAAyC;GAC1C,yBAA+B,CAAC,CAAC,SAAyB;EAC5D,CAAC;EAED,eAAG,iDAAiD;GAIlD,yBAAiC,CAAC,CAAC,SAAyB;EAC9D,CAAC;CACH,CAAC;AACH,CAAC;qBAEQ,mEAAmE;CAgB1E,eAAG,wEAAwE;EACzE,yBAAmC,CAAC,CAAC,IAAI,SAA0B;EACnE,yBAAqC,CAAC,CAAC,IAAI,SAA0B;EACrE,yBAAuC,CAAC,CAAC,IAAI,SAA4B;CAC3E,CAAC;CAED,eAAG,kEAAkE;EACnE,yBAAmC,CAAC,CAAC,SAA4B;CACnE,CAAC;AACH,CAAC"}
@@ -86,6 +86,7 @@ const require_localization_getLocaleFromPath = require('./localization/getLocale
86
86
  const require_localization_getLocaleLang = require('./localization/getLocaleLang.cjs');
87
87
  const require_localization_getLocaleName = require('./localization/getLocaleName.cjs');
88
88
  const require_localization_localeMapper = require('./localization/localeMapper.cjs');
89
+ const require_localization_proxyMode = require('./localization/proxyMode.cjs');
89
90
  const require_localization_validatePrefix = require('./localization/validatePrefix.cjs');
90
91
  const require_markdown_constants = require('./markdown/constants.cjs');
91
92
  const require_markdown_utils = require('./markdown/utils.cjs');
@@ -214,6 +215,7 @@ exports.filePlugin = require_interpreter_getContent_plugins.filePlugin;
214
215
  exports.filterMissingTranslationsOnlyPlugin = require_deepTransformPlugins_getFilterMissingTranslationsContent.filterMissingTranslationsOnlyPlugin;
215
216
  exports.filterTranslationsOnlyPlugin = require_deepTransformPlugins_getFilterTranslationsOnlyContent.filterTranslationsOnlyPlugin;
216
217
  exports.findMatchingCondition = require_interpreter_getEnumeration.findMatchingCondition;
218
+ exports.formatProxyEnabledMessage = require_localization_proxyMode.formatProxyEnabledMessage;
217
219
  exports.gender = require_transpiler_gender_gender.gender;
218
220
  exports.genderPlugin = require_interpreter_getContent_plugins.genderPlugin;
219
221
  exports.generateListItemPrefix = require_markdown_constants.generateListItemPrefix;
@@ -303,6 +305,7 @@ exports.intlayerToPortableObjectFormatter = require_messageFormat_po.intlayerToP
303
305
  exports.intlayerToVueI18nFormatter = require_messageFormat_vue_i18n.intlayerToVueI18nFormatter;
304
306
  exports.isInterpolableWrapperNode = require_interpreter_interpolableNode.isInterpolableWrapperNode;
305
307
  exports.isLocaleExclusiveOnDomain = require_localization_domainUtils.isLocaleExclusiveOnDomain;
308
+ exports.isProxyStorageLocaleEnabled = require_localization_proxyMode.isProxyStorageLocaleEnabled;
306
309
  exports.isQualifiedDictionaryGroup = require_dictionaryManipulator_qualifiedDictionary.isQualifiedDictionaryGroup;
307
310
  exports.isQualifiedDynamicLoaderMap = require_dictionaryManipulator_qualifiedDictionary.isQualifiedDynamicLoaderMap;
308
311
  exports.isSameKeyPath = require_utils_isSameKeyPath.isSameKeyPath;
@@ -359,6 +362,7 @@ exports.resolveDictionaryArgument = require_dictionaryManipulator_qualifiedDicti
359
362
  exports.resolveMessage = require_messageFormat_resolveMessage.resolveMessage;
360
363
  exports.resolveMessageNode = require_messageFormat_resolveMessage.resolveMessageNode;
361
364
  exports.resolveProviderVariant = require_dictionaryManipulator_qualifiedDictionary.resolveProviderVariant;
365
+ exports.resolveProxyMode = require_localization_proxyMode.resolveProxyMode;
362
366
  exports.resolveQualifiedDictionary = require_dictionaryManipulator_qualifiedDictionary.resolveQualifiedDictionary;
363
367
  exports.resolveQualifiedDynamicContent = require_dictionaryManipulator_qualifiedDictionary.resolveQualifiedDynamicContent;
364
368
  exports.resolveQualifiedDynamicContentAsync = require_dictionaryManipulator_qualifiedDictionary.resolveQualifiedDynamicContentAsync;
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.cjs","names":["parseDictionarySelector","getBasePlugins","resolveQualifiedDictionary","getContent"],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelector,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n} from '@intlayer/types/module_augmentation';\nimport {\n parseDictionarySelector,\n resolveQualifiedDictionary,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getBasePlugins, getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * Also accepts a `QualifiedDictionaryGroup` (collections, variants) together\n * with a selector as second argument — the group is resolved to a single entry\n * (or an ordered array of entries for collections without an `item` selector)\n * before transformation.\n *\n * @param dictionary The dictionary (or qualified dictionary group) to transform.\n * @param localeOrSelector The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends DeclaredLocales | DictionarySelector = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const { locale, selector } = parseDictionarySelector(localeOrSelector);\n const appliedPlugins = plugins ?? getBasePlugins(locale);\n\n const resolved = resolveQualifiedDictionary(dictionary, selector);\n\n const transformDictionary = (resolvedDictionary: Dictionary) => {\n const props: NodeProps = {\n dictionaryKey: resolvedDictionary.key,\n dictionaryPath: resolvedDictionary.filePath,\n keyPath: [],\n plugins: appliedPlugins,\n };\n\n return getContent(resolvedDictionary.content, props, appliedPlugins);\n };\n\n if (resolved === null) return null as any;\n\n if (Array.isArray(resolved)) {\n return resolved.map(transformDictionary) as any;\n }\n\n return transformDictionary(resolved) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,MAAa,iBAIX,YACA,kBACA,YAKG;CACH,MAAM,EAAE,QAAQ,aAAaA,0EAAwB,gBAAgB;CACrE,MAAM,iBAAiB,WAAWC,yDAAe,MAAM;CAEvD,MAAM,WAAWC,6EAA2B,YAAY,QAAQ;CAEhE,MAAM,uBAAuB,uBAAmC;EAC9D,MAAM,QAAmB;GACvB,eAAe,mBAAmB;GAClC,gBAAgB,mBAAmB;GACnC,SAAS,CAAC;GACV,SAAS;EACX;EAEA,OAAOC,qDAAW,mBAAmB,SAAS,OAAO,cAAc;CACrE;CAEA,IAAI,aAAa,MAAM,OAAO;CAE9B,IAAI,MAAM,QAAQ,QAAQ,GACxB,OAAO,SAAS,IAAI,mBAAmB;CAGzC,OAAO,oBAAoB,QAAQ;AACrC"}
1
+ {"version":3,"file":"getDictionary.cjs","names":["parseDictionarySelector","getBasePlugins","resolveQualifiedDictionary","getContent"],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelector,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n parseDictionarySelector,\n resolveQualifiedDictionary,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getBasePlugins, getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * Also accepts a `QualifiedDictionaryGroup` (collections, variants) together\n * with a selector as second argument — the group is resolved to a single entry\n * (or an ordered array of entries for collections without an `item` selector)\n * before transformation.\n *\n * @param dictionary The dictionary (or qualified dictionary group) to transform.\n * @param localeOrSelector The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const { locale, selector } = parseDictionarySelector(localeOrSelector);\n const appliedPlugins = plugins ?? getBasePlugins(locale);\n\n const resolved = resolveQualifiedDictionary(dictionary, selector);\n\n const transformDictionary = (resolvedDictionary: Dictionary) => {\n const props: NodeProps = {\n dictionaryKey: resolvedDictionary.key,\n dictionaryPath: resolvedDictionary.filePath,\n keyPath: [],\n plugins: appliedPlugins,\n };\n\n return getContent(resolvedDictionary.content, props, appliedPlugins);\n };\n\n if (resolved === null) return null as any;\n\n if (Array.isArray(resolved)) {\n return resolved.map(transformDictionary) as any;\n }\n\n return transformDictionary(resolved) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAa,iBAIX,YACA,kBACA,YAKG;CACH,MAAM,EAAE,QAAQ,aAAaA,0EAAwB,gBAAgB;CACrE,MAAM,iBAAiB,WAAWC,yDAAe,MAAM;CAEvD,MAAM,WAAWC,6EAA2B,YAAY,QAAQ;CAEhE,MAAM,uBAAuB,uBAAmC;EAC9D,MAAM,QAAmB;GACvB,eAAe,mBAAmB;GAClC,gBAAgB,mBAAmB;GACnC,SAAS,CAAC;GACV,SAAS;EACX;EAEA,OAAOC,qDAAW,mBAAmB,SAAS,OAAO,cAAc;CACrE;CAEA,IAAI,aAAa,MAAM,OAAO;CAE9B,IAAI,MAAM,QAAQ,QAAQ,GACxB,OAAO,SAAS,IAAI,mBAAmB;CAGzC,OAAO,oBAAoB,QAAQ;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.cjs","names":["parseDictionarySelector","getDictionarySelectorCacheKey","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy({} as Record<string | symbol, unknown>, {\n get: (_target, prop) => {\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString' ||\n prop === 'valueOf'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n if (prop === Symbol.iterator) {\n return function* () {\n yield path;\n };\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n });\n};\n\nconst dictionaryCache = new Map<string, any>();\nconst warnedMissingDictionaries = new Set<string>();\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector.\n *\n * The second argument is either a locale (`'fr'`) or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: { id: 'prod_abc', userId: '123' } }` — structured variant\n * - `locale` can be combined with any selector: `{ item: 2, locale: 'fr' }`\n */\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const A extends DeclaredLocales | DictionarySelector = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T];\n\n if (!dictionary && process.env.NODE_ENV === 'development') {\n if (!warnedMissingDictionaries.has(key as string)) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger({ log });\n logger(\n typeof window === 'undefined'\n ? `Dictionary ${colorizeKey(key)} was not found. Using fallback proxy.`\n : `Dictionary ${key} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n }\n );\n warnedMissingDictionaries.add(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n let locale: LocalesValues | undefined;\n let selectorCacheKey = '';\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const parsed = parseDictionarySelector(localeOrSelector);\n locale = parsed.locale;\n selectorCacheKey = getDictionarySelectorCacheKey(parsed.selector);\n } else {\n // Selectors are unused in this project (build-time flag): the second\n // argument can only be a locale, so the selector parsing is dead code.\n locale = localeOrSelector as LocalesValues | undefined;\n }\n\n const cacheKey = `${key}_${locale ?? 'default'}_${selectorCacheKey}_${plugins ? 'custom_plugins' : 'default_plugins'}`;\n\n if (dictionaryCache.has(cacheKey)) {\n return dictionaryCache.get(cacheKey);\n }\n\n const result = getDictionary(dictionary, localeOrSelector, plugins);\n\n dictionaryCache.set(cacheKey, result);\n\n return result as any;\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,sBAAsB,OAAO,OAAY;CAC7C,OAAO,IAAI,MAAM,CAAC,GAAuC,EACvD,MAAM,SAAS,SAAS;EACtB,IACE,SAAS,YACT,SAAS,OAAO,eAChB,SAAS,cACT,SAAS,WAET,aAAa;EAEf,IAAI,SAAS,QACX;EAEF,IAAI,SAAS,OAAO,UAClB,OAAO,aAAa;GAClB,MAAM;EACR;EAIF,MAAM,WAAW,OAAO,GAAG,KAAK,GAAG,OAAO,IAAI,MAAM,OAAO,IAAI;EAC/D,OAAO,mBAAmB,QAAQ;CACpC,EACF,CAAC;AACH;AAEA,MAAM,kCAAkB,IAAI,IAAiB;AAC7C,MAAM,4CAA4B,IAAI,IAAY;;;;;;;;;;;AAYlD,MAAa,eAIX,KACA,kBACA,YAKG;CAEH,MAAM,+DAAwB,CAAC,CAAC;CAEhC,IAAI,CAAC,cAAc,QAAQ,IAAI,aAAa,eAAe;EACzD,IAAI,CAAC,0BAA0B,IAAI,GAAa,GAAG;GAGjD,0CAD4B,EAAE,gCAAI,CAC7B,CAAC,CACJ,OAAO,WAAW,cACd,uDAA0B,GAAG,EAAE,yCAC/B,cAAc,IAAI,wCACtB,EACE,OAAO,OACT,CACF;GACA,0BAA0B,IAAI,GAAa;EAC7C;EAEA,OAAO,mBAAmB,GAAa;CACzC;CAEA,IAAI;CACJ,IAAI,mBAAmB;CAEvB,IAAI,QAAQ,IAAI,iCAAiC,SAAS;EACxD,MAAM,SAASA,0EAAwB,gBAAgB;EACvD,SAAS,OAAO;EAChB,mBAAmBC,gFAA8B,OAAO,QAAQ;CAClE,OAGE,SAAS;CAGX,MAAM,WAAW,GAAG,IAAI,GAAG,UAAU,UAAU,GAAG,iBAAiB,GAAG,UAAU,mBAAmB;CAEnG,IAAI,gBAAgB,IAAI,QAAQ,GAC9B,OAAO,gBAAgB,IAAI,QAAQ;CAGrC,MAAM,SAASC,gDAAc,YAAY,kBAAkB,OAAO;CAElE,gBAAgB,IAAI,UAAU,MAAM;CAEpC,OAAO;AACT"}
1
+ {"version":3,"file":"getIntlayer.cjs","names":["parseDictionarySelector","getDictionarySelectorCacheKey","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy({} as Record<string | symbol, unknown>, {\n get: (_target, prop) => {\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString' ||\n prop === 'valueOf'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n if (prop === Symbol.iterator) {\n return function* () {\n yield path;\n };\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n });\n};\n\nconst dictionaryCache = new Map<string, any>();\nconst warnedMissingDictionaries = new Set<string>();\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector.\n *\n * The second argument is either a locale (`'fr'`) or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: { id: 'prod_abc', userId: '123' } }` — structured variant\n * - `locale` can be combined with any selector: `{ item: 2, locale: 'fr' }`\n */\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T];\n\n if (!dictionary && process.env.NODE_ENV === 'development') {\n if (!warnedMissingDictionaries.has(key as string)) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger({ log });\n logger(\n typeof window === 'undefined'\n ? `Dictionary ${colorizeKey(key)} was not found. Using fallback proxy.`\n : `Dictionary ${key} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n }\n );\n warnedMissingDictionaries.add(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n let locale: LocalesValues | undefined;\n let selectorCacheKey = '';\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const parsed = parseDictionarySelector(localeOrSelector);\n locale = parsed.locale;\n selectorCacheKey = getDictionarySelectorCacheKey(parsed.selector);\n } else {\n // Selectors are unused in this project (build-time flag): the second\n // argument can only be a locale, so the selector parsing is dead code.\n locale = localeOrSelector as LocalesValues | undefined;\n }\n\n const cacheKey = `${key}_${locale ?? 'default'}_${selectorCacheKey}_${plugins ? 'custom_plugins' : 'default_plugins'}`;\n\n if (dictionaryCache.has(cacheKey)) {\n return dictionaryCache.get(cacheKey);\n }\n\n const result = getDictionary(dictionary, localeOrSelector, plugins);\n\n dictionaryCache.set(cacheKey, result);\n\n return result as any;\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,sBAAsB,OAAO,OAAY;CAC7C,OAAO,IAAI,MAAM,CAAC,GAAuC,EACvD,MAAM,SAAS,SAAS;EACtB,IACE,SAAS,YACT,SAAS,OAAO,eAChB,SAAS,cACT,SAAS,WAET,aAAa;EAEf,IAAI,SAAS,QACX;EAEF,IAAI,SAAS,OAAO,UAClB,OAAO,aAAa;GAClB,MAAM;EACR;EAIF,MAAM,WAAW,OAAO,GAAG,KAAK,GAAG,OAAO,IAAI,MAAM,OAAO,IAAI;EAC/D,OAAO,mBAAmB,QAAQ;CACpC,EACF,CAAC;AACH;AAEA,MAAM,kCAAkB,IAAI,IAAiB;AAC7C,MAAM,4CAA4B,IAAI,IAAY;;;;;;;;;;;AAYlD,MAAa,eAIX,KACA,kBACA,YAKG;CAEH,MAAM,+DAAwB,CAAC,CAAC;CAEhC,IAAI,CAAC,cAAc,QAAQ,IAAI,aAAa,eAAe;EACzD,IAAI,CAAC,0BAA0B,IAAI,GAAa,GAAG;GAGjD,0CAD4B,EAAE,gCAAI,CAC7B,CAAC,CACJ,OAAO,WAAW,cACd,uDAA0B,GAAG,EAAE,yCAC/B,cAAc,IAAI,wCACtB,EACE,OAAO,OACT,CACF;GACA,0BAA0B,IAAI,GAAa;EAC7C;EAEA,OAAO,mBAAmB,GAAa;CACzC;CAEA,IAAI;CACJ,IAAI,mBAAmB;CAEvB,IAAI,QAAQ,IAAI,iCAAiC,SAAS;EACxD,MAAM,SAASA,0EAAwB,gBAAgB;EACvD,SAAS,OAAO;EAChB,mBAAmBC,gFAA8B,OAAO,QAAQ;CAClE,OAGE,SAAS;CAGX,MAAM,WAAW,GAAG,IAAI,GAAG,UAAU,UAAU,GAAG,iBAAiB,GAAG,UAAU,mBAAmB;CAEnG,IAAI,gBAAgB,IAAI,QAAQ,GAC9B,OAAO,gBAAgB,IAAI,QAAQ;CAGrC,MAAM,SAASC,gDAAc,YAAY,kBAAkB,OAAO;CAElE,gBAAgB,IAAI,UAAU,MAAM;CAEpC,OAAO;AACT"}
@@ -0,0 +1,28 @@
1
+ const require_interpreter_getIntlayer = require('./getIntlayer.cjs');
2
+ let vitest = require("vitest");
3
+
4
+ //#region src/interpreter/getIntlayer.test-d.ts
5
+ /**
6
+ * The second argument of `getIntlayer` is almost always a value the framework
7
+ * hands over as a plain `string`: a router param (`params.locale`), a cookie, a
8
+ * header. Constraining it to the declared locales made every such call site a
9
+ * compile error, so the declared locales are offered as suggestions while any
10
+ * string is still accepted.
11
+ */
12
+ (0, vitest.describe)("getIntlayer — locale argument", () => {
13
+ (0, vitest.it)("should accept a locale literal", () => {
14
+ (0, vitest.expectTypeOf)(require_interpreter_getIntlayer.getIntlayer("lesson", "fr")).not.toBeNever();
15
+ });
16
+ (0, vitest.it)("should accept a `string | undefined` router param", () => {
17
+ (0, vitest.expectTypeOf)(require_interpreter_getIntlayer.getIntlayer("lesson", "fr")).not.toBeNever();
18
+ });
19
+ (0, vitest.it)("should accept a selector carrying a widened locale", () => {
20
+ (0, vitest.expectTypeOf)(require_interpreter_getIntlayer.getIntlayer("lesson", {
21
+ locale: "fr",
22
+ item: 1
23
+ })).not.toBeNever();
24
+ });
25
+ });
26
+
27
+ //#endregion
28
+ //# sourceMappingURL=getIntlayer.test-d.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIntlayer.test-d.cjs","names":["getIntlayer"],"sources":["../../../src/interpreter/getIntlayer.test-d.ts"],"sourcesContent":["import { describe, expectTypeOf, it } from 'vitest';\nimport { getIntlayer } from './getIntlayer';\n\n/**\n * The second argument of `getIntlayer` is almost always a value the framework\n * hands over as a plain `string`: a router param (`params.locale`), a cookie, a\n * header. Constraining it to the declared locales made every such call site a\n * compile error, so the declared locales are offered as suggestions while any\n * string is still accepted.\n */\ndescribe('getIntlayer — locale argument', () => {\n it('should accept a locale literal', () => {\n expectTypeOf(getIntlayer('lesson', 'fr')).not.toBeNever();\n });\n\n it('should accept a `string | undefined` router param', () => {\n const routerLocale = 'fr' as string | undefined;\n\n expectTypeOf(getIntlayer('lesson', routerLocale)).not.toBeNever();\n });\n\n it('should accept a selector carrying a widened locale', () => {\n const routerLocale = 'fr' as string;\n\n expectTypeOf(\n getIntlayer('lesson', { locale: routerLocale, item: 1 })\n ).not.toBeNever();\n });\n});\n"],"mappings":";;;;;;;;;;;qBAUS,uCAAuC;CAC9C,eAAG,wCAAwC;EACzC,yBAAaA,4CAAY,UAAU,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU;CAC1D,CAAC;CAED,eAAG,2DAA2D;EAG5D,yBAAaA,4CAAY,UAAU,IAAY,CAAC,CAAC,CAAC,IAAI,UAAU;CAClE,CAAC;CAED,eAAG,4DAA4D;EAG7D,yBACEA,4CAAY,UAAU;GAAE,QAAQ;GAAc,MAAM;EAAE,CAAC,CACzD,CAAC,CAAC,IAAI,UAAU;CAClB,CAAC;AACH,CAAC"}
@@ -16,9 +16,11 @@ const require_localization_getLocaleFromPath = require('./getLocaleFromPath.cjs'
16
16
  const require_localization_getLocaleLang = require('./getLocaleLang.cjs');
17
17
  const require_localization_getLocaleName = require('./getLocaleName.cjs');
18
18
  const require_localization_localeMapper = require('./localeMapper.cjs');
19
+ const require_localization_proxyMode = require('./proxyMode.cjs');
19
20
  const require_localization_validatePrefix = require('./validatePrefix.cjs');
20
21
 
21
22
  exports.comparePaths = require_localization_comparePaths.comparePaths;
23
+ exports.formatProxyEnabledMessage = require_localization_proxyMode.formatProxyEnabledMessage;
22
24
  exports.generateSitemap = require_localization_generateSitemap.generateSitemap;
23
25
  exports.generateSitemapUrl = require_localization_generateSitemap.generateSitemapUrl;
24
26
  exports.getBrowserLocale = require_localization_getBrowserLocale.getBrowserLocale;
@@ -40,10 +42,12 @@ exports.getPrefix = require_localization_getPrefix.getPrefix;
40
42
  exports.getRewritePath = require_localization_rewriteUtils.getRewritePath;
41
43
  exports.getRewriteRules = require_localization_rewriteUtils.getRewriteRules;
42
44
  exports.isLocaleExclusiveOnDomain = require_localization_domainUtils.isLocaleExclusiveOnDomain;
45
+ exports.isProxyStorageLocaleEnabled = require_localization_proxyMode.isProxyStorageLocaleEnabled;
43
46
  exports.localeDetector = require_localization_localeDetector.localeDetector;
44
47
  exports.localeFlatMap = require_localization_localeMapper.localeFlatMap;
45
48
  exports.localeMap = require_localization_localeMapper.localeMap;
46
49
  exports.localeRecord = require_localization_localeMapper.localeRecord;
47
50
  exports.localeResolver = require_localization_localeResolver.localeResolver;
48
51
  exports.normalizePath = require_localization_comparePaths.normalizePath;
52
+ exports.resolveProxyMode = require_localization_proxyMode.resolveProxyMode;
49
53
  exports.validatePrefix = require_localization_validatePrefix.validatePrefix;
@@ -0,0 +1,92 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _intlayer_config_logger = require("@intlayer/config/logger");
4
+ let _intlayer_config_colors = require("@intlayer/config/colors");
5
+ _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
6
+
7
+ //#region src/localization/proxyMode.ts
8
+ /**
9
+ * Resolves the effective {@link ProxyMode} from the `routing.enableProxy`
10
+ * configuration value.
11
+ *
12
+ * `process.env.INTLAYER_ROUTING_ENABLE_PROXY` is injected at build time by
13
+ * `getConfigEnvVars` and takes precedence, so bundlers can dead-code-eliminate
14
+ * the branches guarded by the resolved mode. The variable is only emitted for
15
+ * the two explicit states; its absence means `'auto'` and defers to the
16
+ * configuration value read at runtime.
17
+ *
18
+ * @param enableProxy - The `routing.enableProxy` value; `undefined` means auto.
19
+ * @returns The resolved proxy mode.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * resolveProxyMode(undefined); // 'auto'
24
+ * resolveProxyMode(true); // 'forced'
25
+ * resolveProxyMode(false); // 'disabled'
26
+ * ```
27
+ */
28
+ const resolveProxyMode = (enableProxy) => {
29
+ if (process.env.INTLAYER_ROUTING_ENABLE_PROXY === "false") return "disabled";
30
+ if (process.env.INTLAYER_ROUTING_ENABLE_PROXY === "true") return "forced";
31
+ if (enableProxy === false) return "disabled";
32
+ if (enableProxy === true) return "forced";
33
+ return "auto";
34
+ };
35
+ /**
36
+ * Indicates whether the proxy may use the locale held in storage (cookie or
37
+ * header) as a source when deciding which locale a request resolves to.
38
+ *
39
+ * Auto mode suppresses it on development and preview servers only. Every other
40
+ * combination keeps the stored locale active, which notably preserves the
41
+ * behaviour of `createIntlayerProxyHandler` when it is mounted manually in a
42
+ * production Nitro server.
43
+ *
44
+ * Suppressing the read affects redirect *sources* only — the locale is still
45
+ * persisted onto responses, the URL locale prefix still wins over everything,
46
+ * and `Accept-Language` detection still applies as the fallback.
47
+ *
48
+ * @param proxyMode - The resolved proxy mode.
49
+ * @param isDevServer - Whether a development or preview server is serving the app.
50
+ * @returns `true` when the stored locale may drive locale resolution.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * isProxyStorageLocaleEnabled('auto', true); // false — dev server, URL-driven only
55
+ * isProxyStorageLocaleEnabled('auto', false); // true — production
56
+ * isProxyStorageLocaleEnabled('forced', true); // true — explicitly opted in
57
+ * ```
58
+ */
59
+ const isProxyStorageLocaleEnabled = (proxyMode, isDevServer) => !(proxyMode === "auto" && isDevServer);
60
+ /**
61
+ * Builds the line announcing that a server has mounted the locale-routing
62
+ * proxy.
63
+ *
64
+ * Shared by every integration (Vite plugin, Next.js middleware) so the reported
65
+ * state cannot drift between them: when the stored locale is suppressed the
66
+ * message says so, which would otherwise look like a broken proxy to anyone
67
+ * testing locale switching with a cookie already set.
68
+ *
69
+ * Takes the suppression flag rather than the {@link ProxyMode} on purpose. Auto
70
+ * mode only suppresses storage on a dev server, so a mode-based signature would
71
+ * let a production caller — such as the Nitro production handler — announce a
72
+ * suppression that is not actually in effect.
73
+ *
74
+ * @param isStorageLocaleSuppressed - Whether the stored locale is barred from
75
+ * driving redirects, i.e. the negation of {@link isProxyStorageLocaleEnabled}.
76
+ * @returns An ANSI-coloured, ready-to-log message.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * formatProxyEnabledMessage(true);
81
+ * // Intlayer proxy enabled - storage redirection disabled for dev purpose
82
+ * formatProxyEnabledMessage(false);
83
+ * // Intlayer proxy enabled
84
+ * ```
85
+ */
86
+ const formatProxyEnabledMessage = (isStorageLocaleSuppressed) => [`Intlayer proxy ${(0, _intlayer_config_logger.colorize)("enabled", _intlayer_config_colors.GREEN)}`, isStorageLocaleSuppressed && (0, _intlayer_config_logger.colorize)("- storage redirection disabled for dev purpose", _intlayer_config_colors.GREY)].filter(Boolean).join(" ");
87
+
88
+ //#endregion
89
+ exports.formatProxyEnabledMessage = formatProxyEnabledMessage;
90
+ exports.isProxyStorageLocaleEnabled = isProxyStorageLocaleEnabled;
91
+ exports.resolveProxyMode = resolveProxyMode;
92
+ //# sourceMappingURL=proxyMode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxyMode.cjs","names":["ANSIColors"],"sources":["../../../src/localization/proxyMode.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport { colorize } from '@intlayer/config/logger';\n\n/**\n * Effective mode of the Intlayer locale-routing proxy, resolved from the\n * `routing.enableProxy` configuration option.\n *\n * - `'auto'` — the option was left unset. The proxy is registered, but it stays\n * URL-driven while a development or preview server is serving the app: the\n * stored locale (cookie / header) is not used as a redirect source, so a\n * stale cookie cannot silently pull every navigation to another locale. In\n * production the mode behaves exactly like `'forced'`.\n * - `'forced'` — the option was explicitly set to `true`. Full proxy behaviour\n * in every environment, storage-driven redirects included.\n * - `'disabled'` — the option was explicitly set to `false`. The proxy is not\n * registered at all (Vite) or becomes a pass-through (Next.js).\n */\nexport type ProxyMode = 'auto' | 'forced' | 'disabled';\n\n/**\n * Resolves the effective {@link ProxyMode} from the `routing.enableProxy`\n * configuration value.\n *\n * `process.env.INTLAYER_ROUTING_ENABLE_PROXY` is injected at build time by\n * `getConfigEnvVars` and takes precedence, so bundlers can dead-code-eliminate\n * the branches guarded by the resolved mode. The variable is only emitted for\n * the two explicit states; its absence means `'auto'` and defers to the\n * configuration value read at runtime.\n *\n * @param enableProxy - The `routing.enableProxy` value; `undefined` means auto.\n * @returns The resolved proxy mode.\n *\n * @example\n * ```ts\n * resolveProxyMode(undefined); // 'auto'\n * resolveProxyMode(true); // 'forced'\n * resolveProxyMode(false); // 'disabled'\n * ```\n */\nexport const resolveProxyMode = (enableProxy?: boolean): ProxyMode => {\n if (process.env.INTLAYER_ROUTING_ENABLE_PROXY === 'false') return 'disabled';\n if (process.env.INTLAYER_ROUTING_ENABLE_PROXY === 'true') return 'forced';\n\n if (enableProxy === false) return 'disabled';\n if (enableProxy === true) return 'forced';\n\n return 'auto';\n};\n\n/**\n * Indicates whether the proxy may use the locale held in storage (cookie or\n * header) as a source when deciding which locale a request resolves to.\n *\n * Auto mode suppresses it on development and preview servers only. Every other\n * combination keeps the stored locale active, which notably preserves the\n * behaviour of `createIntlayerProxyHandler` when it is mounted manually in a\n * production Nitro server.\n *\n * Suppressing the read affects redirect *sources* only — the locale is still\n * persisted onto responses, the URL locale prefix still wins over everything,\n * and `Accept-Language` detection still applies as the fallback.\n *\n * @param proxyMode - The resolved proxy mode.\n * @param isDevServer - Whether a development or preview server is serving the app.\n * @returns `true` when the stored locale may drive locale resolution.\n *\n * @example\n * ```ts\n * isProxyStorageLocaleEnabled('auto', true); // false — dev server, URL-driven only\n * isProxyStorageLocaleEnabled('auto', false); // true — production\n * isProxyStorageLocaleEnabled('forced', true); // true — explicitly opted in\n * ```\n */\nexport const isProxyStorageLocaleEnabled = (\n proxyMode: ProxyMode,\n isDevServer: boolean\n): boolean => !(proxyMode === 'auto' && isDevServer);\n\n/**\n * Builds the line announcing that a server has mounted the locale-routing\n * proxy.\n *\n * Shared by every integration (Vite plugin, Next.js middleware) so the reported\n * state cannot drift between them: when the stored locale is suppressed the\n * message says so, which would otherwise look like a broken proxy to anyone\n * testing locale switching with a cookie already set.\n *\n * Takes the suppression flag rather than the {@link ProxyMode} on purpose. Auto\n * mode only suppresses storage on a dev server, so a mode-based signature would\n * let a production caller — such as the Nitro production handler — announce a\n * suppression that is not actually in effect.\n *\n * @param isStorageLocaleSuppressed - Whether the stored locale is barred from\n * driving redirects, i.e. the negation of {@link isProxyStorageLocaleEnabled}.\n * @returns An ANSI-coloured, ready-to-log message.\n *\n * @example\n * ```ts\n * formatProxyEnabledMessage(true);\n * // Intlayer proxy enabled - storage redirection disabled for dev purpose\n * formatProxyEnabledMessage(false);\n * // Intlayer proxy enabled\n * ```\n */\nexport const formatProxyEnabledMessage = (\n isStorageLocaleSuppressed: boolean\n): string =>\n [\n `Intlayer proxy ${colorize('enabled', ANSIColors.GREEN)}`,\n isStorageLocaleSuppressed &&\n colorize(\n '- storage redirection disabled for dev purpose',\n ANSIColors.GREY\n ),\n ]\n .filter(Boolean)\n .join(' ');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAa,oBAAoB,gBAAqC;CACpE,IAAI,QAAQ,IAAI,kCAAkC,SAAS,OAAO;CAClE,IAAI,QAAQ,IAAI,kCAAkC,QAAQ,OAAO;CAEjE,IAAI,gBAAgB,OAAO,OAAO;CAClC,IAAI,gBAAgB,MAAM,OAAO;CAEjC,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,+BACX,WACA,gBACY,EAAE,cAAc,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BxC,MAAa,6BACX,8BAEA,CACE,wDAA2B,WAAWA,wBAAW,KAAK,KACtD,mEAEI,kDACAA,wBAAW,IACb,CACJ,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG"}
@@ -73,8 +73,13 @@ describe("DictionarySelectorForGroup", () => {
73
73
  expectTypeOf().not.toExtend();
74
74
  });
75
75
  });
76
- it("should reject an undeclared locale", () => {
77
- expectTypeOf().not.toExtend();
76
+ describe("locale", () => {
77
+ it("should accept a declared locale", () => {
78
+ expectTypeOf().toExtend();
79
+ });
80
+ it("should accept a widened `string` locale", () => {
81
+ expectTypeOf().toExtend();
82
+ });
78
83
  });
79
84
  });
80
85
  describe("DictionarySelectorForGroup — keys without a default entry", () => {
@@ -1 +1 @@
1
- {"version":3,"file":"qualifiedDictionary.test-d.mjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDictionary.test-d.ts"],"sourcesContent":["import type {\n DictionarySelectorForGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport { describe, expectTypeOf, it } from 'vitest';\n\n/**\n * Compile-time counterpart of `qualifiedDictionary.test.ts`. The runtime\n * resolver and `ResolveQualifiedDictionaryContent` implement the same rules\n * twice — once in value space, once in type space — so a divergence between\n * them is invisible to the runtime suite. These assertions pin the type side.\n *\n * Groups are written the way `createTypes` emits them (`as const`, hence\n * readonly tuples of qualifier dimensions and literal composite-id keys).\n */\n\ntype LessonGroup = {\n key: 'lesson';\n qualifierTypes: readonly ['variant'];\n content: {\n default: { title: 'Lesson'; teacher: 'Teacher' };\n preschool: { title: 'Lesson'; teacher: 'Pedagogue' };\n };\n};\n\ntype NoDefaultGroup = {\n key: 'promoOnly';\n qualifierTypes: readonly ['variant'];\n content: { promo: { title: 'Promo' } };\n};\n\ntype BannerGroup = {\n key: 'banner';\n qualifierTypes: readonly ['variant', 'item'];\n content: {\n 'default/1': { title: 'D1' };\n 'promo/1': { title: 'P1' };\n 'promo/2': { title: 'P2' };\n };\n};\n\ntype FaqGroup = {\n key: 'faq';\n qualifierTypes: readonly ['item'];\n content: { '1': { question: 'Q1' }; '2': { question: 'Q2' } };\n};\n\ntype ProductGroup = {\n key: 'product';\n qualifierTypes: readonly ['variant'];\n content: { 'id=abc&userId=123': { name: 'ABC' } };\n};\n\ndescribe('ResolveQualifiedDictionaryContent', () => {\n it('should resolve a plain dictionary to its content, ignoring the selector', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<{ key: 'home'; content: { a: 'b' } }>\n >().toEqualTypeOf<{ a: 'b' }>();\n });\n\n describe('variant', () => {\n it('should resolve to the default entry when no variant is selected', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve a locale-only selector like no selector', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup, { locale: 'sv' }>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve a declared variant to its own entry', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup, { variant: 'preschool' }>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Pedagogue' }>();\n });\n\n it('should fall back to the default entry for an undeclared variant', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n LessonGroup,\n { variant: 'upperSecondary' }\n >\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve to null when no default entry is declared', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n NoDefaultGroup,\n { variant: 'unknown' }\n >\n >().toEqualTypeOf<null>();\n });\n\n it('should resolve an object variant to its entry', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n ProductGroup,\n { variant: { id: 'abc'; userId: '123' } }\n >\n >().toEqualTypeOf<{ name: 'ABC' }>();\n });\n\n it('should resolve to null when an object-variant key has no default', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<ProductGroup>\n >().toEqualTypeOf<null>();\n });\n });\n\n describe('item', () => {\n it('should resolve to an array of every item when the axis is left open', () => {\n expectTypeOf<ResolveQualifiedDictionaryContent<FaqGroup>>().toEqualTypeOf<\n ({ question: 'Q1' } | { question: 'Q2' })[]\n >();\n });\n\n it('should narrow to the selected item', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<FaqGroup, { item: 2 }>\n >().toEqualTypeOf<{ question: 'Q2' }>();\n });\n });\n\n describe('composite (variant × item)', () => {\n it('should narrow to a single entry when both dimensions are pinned', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n BannerGroup,\n { variant: 'promo'; item: 2 }\n >\n >().toEqualTypeOf<{ title: 'P2' }>();\n });\n\n it('should fan the item axis out for the selected variant', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<BannerGroup, { variant: 'promo' }>\n >().toEqualTypeOf<({ title: 'P1' } | { title: 'P2' })[]>();\n });\n\n it('should fall back to the default variant then fan out its items', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<BannerGroup, { variant: 'unknown' }>\n >().toEqualTypeOf<{ title: 'D1' }[]>();\n });\n });\n});\n\ndescribe('DictionarySelectorForGroup', () => {\n /** Stands in for the project-wide variant vocabulary (`DeclaredVariants`). */\n type ProjectVariants = 'default' | 'preschool' | 'promo';\n\n type LessonSelector = DictionarySelectorForGroup<\n LessonGroup,\n ProjectVariants\n >;\n\n it('should accept a variant this key declares', () => {\n expectTypeOf<{ variant: 'preschool' }>().toExtend<LessonSelector>();\n });\n\n it('should accept a variant declared elsewhere in the project', () => {\n // `LessonGroup` has no `promo` entry — it resolves to `default` at runtime,\n // which is what makes one session-wide variant usable across every key.\n expectTypeOf<{ variant: 'promo' }>().toExtend<LessonSelector>();\n });\n\n it('should reject a variant no dictionary declares', () => {\n expectTypeOf<{ variant: 'promoo' }>().not.toExtend<LessonSelector>();\n });\n\n it('should reject an object variant on a key that declares none', () => {\n expectTypeOf<{ variant: { id: 'abc' } }>().not.toExtend<LessonSelector>();\n });\n\n describe('object variants', () => {\n // `ProductGroup` stores `'id=abc&userId=123'` — the serialized form of\n // `{ id: 'abc', userId: '123' }`.\n type ProductSelector = DictionarySelectorForGroup<\n ProductGroup,\n ProjectVariants\n >;\n\n it('should accept the object the key declares', () => {\n expectTypeOf<{\n variant: { id: 'abc'; userId: '123' };\n }>().toExtend<ProductSelector>();\n });\n\n it('should reject the serialized form as a string', () => {\n // `'id=abc&userId=123'` is a storage encoding, not part of the API.\n expectTypeOf<{\n variant: 'id=abc&userId=123';\n }>().not.toExtend<ProductSelector>();\n });\n\n it('should reject a partial or mismatched object', () => {\n expectTypeOf<{\n variant: { id: 'abc' };\n }>().not.toExtend<ProductSelector>();\n expectTypeOf<{\n variant: { id: 'abc'; userId: 'other' };\n }>().not.toExtend<ProductSelector>();\n });\n });\n\n it('should reject an undeclared locale', () => {\n expectTypeOf<{ locale: 'not-a-locale' }>().not.toExtend<LessonSelector>();\n });\n});\n\ndescribe('DictionarySelectorForGroup — keys without a default entry', () => {\n type ProjectVariants = 'default' | 'preschool' | 'promo';\n\n // Declares only object variants: an undeclared name resolves to `null`, so\n // the project vocabulary must not be accepted here.\n type ProductSelector = DictionarySelectorForGroup<\n ProductGroup,\n ProjectVariants\n >;\n\n // Declares `promo` but no `default` — same reasoning.\n type NoDefaultSelector = DictionarySelectorForGroup<\n NoDefaultGroup,\n ProjectVariants\n >;\n\n it('should reject a project variant on a key with no default entry', () => {\n expectTypeOf<{ variant: 'promo' }>().not.toExtend<ProductSelector>();\n expectTypeOf<{ variant: 'default' }>().not.toExtend<ProductSelector>();\n expectTypeOf<{ variant: 'preschool' }>().not.toExtend<NoDefaultSelector>();\n });\n\n it('should still accept the names such a key declares itself', () => {\n expectTypeOf<{ variant: 'promo' }>().toExtend<NoDefaultSelector>();\n });\n});\n"],"mappings":";;;AAqDA,SAAS,2CAA2C;CAClD,GAAG,iFAAiF;EAClF,aAEE,CAAC,CAAC,cAA0B;CAChC,CAAC;CAED,SAAS,iBAAiB;EACxB,GAAG,yEAAyE;GAC1E,aAEE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,GAAG,gEAAgE;GACjE,aAEE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,GAAG,4DAA4D;GAC7D,aAEE,CAAC,CAAC,cAAyD;EAC/D,CAAC;EAED,GAAG,yEAAyE;GAC1E,aAKE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,GAAG,kEAAkE;GACnE,aAKE,CAAC,CAAC,cAAoB;EAC1B,CAAC;EAED,GAAG,uDAAuD;GACxD,aAKE,CAAC,CAAC,cAA+B;EACrC,CAAC;EAED,GAAG,0EAA0E;GAC3E,aAEE,CAAC,CAAC,cAAoB;EAC1B,CAAC;CACH,CAAC;CAED,SAAS,cAAc;EACrB,GAAG,6EAA6E;GAC9E,aAA0D,CAAC,CAAC,cAE1D;EACJ,CAAC;EAED,GAAG,4CAA4C;GAC7C,aAEE,CAAC,CAAC,cAAkC;EACxC,CAAC;CACH,CAAC;CAED,SAAS,oCAAoC;EAC3C,GAAG,yEAAyE;GAC1E,aAKE,CAAC,CAAC,cAA+B;EACrC,CAAC;EAED,GAAG,+DAA+D;GAChE,aAEE,CAAC,CAAC,cAAqD;EAC3D,CAAC;EAED,GAAG,wEAAwE;GACzE,aAEE,CAAC,CAAC,cAAiC;EACvC,CAAC;CACH,CAAC;AACH,CAAC;AAED,SAAS,oCAAoC;CAS3C,GAAG,mDAAmD;EACpD,aAAuC,CAAC,CAAC,SAAyB;CACpE,CAAC;CAED,GAAG,mEAAmE;EAGpE,aAAmC,CAAC,CAAC,SAAyB;CAChE,CAAC;CAED,GAAG,wDAAwD;EACzD,aAAoC,CAAC,CAAC,IAAI,SAAyB;CACrE,CAAC;CAED,GAAG,qEAAqE;EACtE,aAAyC,CAAC,CAAC,IAAI,SAAyB;CAC1E,CAAC;CAED,SAAS,yBAAyB;EAQhC,GAAG,mDAAmD;GACpD,aAEG,CAAC,CAAC,SAA0B;EACjC,CAAC;EAED,GAAG,uDAAuD;GAExD,aAEG,CAAC,CAAC,IAAI,SAA0B;EACrC,CAAC;EAED,GAAG,sDAAsD;GACvD,aAEG,CAAC,CAAC,IAAI,SAA0B;GACnC,aAEG,CAAC,CAAC,IAAI,SAA0B;EACrC,CAAC;CACH,CAAC;CAED,GAAG,4CAA4C;EAC7C,aAAyC,CAAC,CAAC,IAAI,SAAyB;CAC1E,CAAC;AACH,CAAC;AAED,SAAS,mEAAmE;CAgB1E,GAAG,wEAAwE;EACzE,aAAmC,CAAC,CAAC,IAAI,SAA0B;EACnE,aAAqC,CAAC,CAAC,IAAI,SAA0B;EACrE,aAAuC,CAAC,CAAC,IAAI,SAA4B;CAC3E,CAAC;CAED,GAAG,kEAAkE;EACnE,aAAmC,CAAC,CAAC,SAA4B;CACnE,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"qualifiedDictionary.test-d.mjs","names":[],"sources":["../../../src/dictionaryManipulator/qualifiedDictionary.test-d.ts"],"sourcesContent":["import type {\n DictionarySelectorForGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport { describe, expectTypeOf, it } from 'vitest';\n\n/**\n * Compile-time counterpart of `qualifiedDictionary.test.ts`. The runtime\n * resolver and `ResolveQualifiedDictionaryContent` implement the same rules\n * twice — once in value space, once in type space — so a divergence between\n * them is invisible to the runtime suite. These assertions pin the type side.\n *\n * Groups are written the way `createTypes` emits them (`as const`, hence\n * readonly tuples of qualifier dimensions and literal composite-id keys).\n */\n\ntype LessonGroup = {\n key: 'lesson';\n qualifierTypes: readonly ['variant'];\n content: {\n default: { title: 'Lesson'; teacher: 'Teacher' };\n preschool: { title: 'Lesson'; teacher: 'Pedagogue' };\n };\n};\n\ntype NoDefaultGroup = {\n key: 'promoOnly';\n qualifierTypes: readonly ['variant'];\n content: { promo: { title: 'Promo' } };\n};\n\ntype BannerGroup = {\n key: 'banner';\n qualifierTypes: readonly ['variant', 'item'];\n content: {\n 'default/1': { title: 'D1' };\n 'promo/1': { title: 'P1' };\n 'promo/2': { title: 'P2' };\n };\n};\n\ntype FaqGroup = {\n key: 'faq';\n qualifierTypes: readonly ['item'];\n content: { '1': { question: 'Q1' }; '2': { question: 'Q2' } };\n};\n\ntype ProductGroup = {\n key: 'product';\n qualifierTypes: readonly ['variant'];\n content: { 'id=abc&userId=123': { name: 'ABC' } };\n};\n\ndescribe('ResolveQualifiedDictionaryContent', () => {\n it('should resolve a plain dictionary to its content, ignoring the selector', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<{ key: 'home'; content: { a: 'b' } }>\n >().toEqualTypeOf<{ a: 'b' }>();\n });\n\n describe('variant', () => {\n it('should resolve to the default entry when no variant is selected', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve a locale-only selector like no selector', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup, { locale: 'sv' }>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve a declared variant to its own entry', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<LessonGroup, { variant: 'preschool' }>\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Pedagogue' }>();\n });\n\n it('should fall back to the default entry for an undeclared variant', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n LessonGroup,\n { variant: 'upperSecondary' }\n >\n >().toEqualTypeOf<{ title: 'Lesson'; teacher: 'Teacher' }>();\n });\n\n it('should resolve to null when no default entry is declared', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n NoDefaultGroup,\n { variant: 'unknown' }\n >\n >().toEqualTypeOf<null>();\n });\n\n it('should resolve an object variant to its entry', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n ProductGroup,\n { variant: { id: 'abc'; userId: '123' } }\n >\n >().toEqualTypeOf<{ name: 'ABC' }>();\n });\n\n it('should resolve to null when an object-variant key has no default', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<ProductGroup>\n >().toEqualTypeOf<null>();\n });\n });\n\n describe('item', () => {\n it('should resolve to an array of every item when the axis is left open', () => {\n expectTypeOf<ResolveQualifiedDictionaryContent<FaqGroup>>().toEqualTypeOf<\n ({ question: 'Q1' } | { question: 'Q2' })[]\n >();\n });\n\n it('should narrow to the selected item', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<FaqGroup, { item: 2 }>\n >().toEqualTypeOf<{ question: 'Q2' }>();\n });\n });\n\n describe('composite (variant × item)', () => {\n it('should narrow to a single entry when both dimensions are pinned', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<\n BannerGroup,\n { variant: 'promo'; item: 2 }\n >\n >().toEqualTypeOf<{ title: 'P2' }>();\n });\n\n it('should fan the item axis out for the selected variant', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<BannerGroup, { variant: 'promo' }>\n >().toEqualTypeOf<({ title: 'P1' } | { title: 'P2' })[]>();\n });\n\n it('should fall back to the default variant then fan out its items', () => {\n expectTypeOf<\n ResolveQualifiedDictionaryContent<BannerGroup, { variant: 'unknown' }>\n >().toEqualTypeOf<{ title: 'D1' }[]>();\n });\n });\n});\n\ndescribe('DictionarySelectorForGroup', () => {\n /** Stands in for the project-wide variant vocabulary (`DeclaredVariants`). */\n type ProjectVariants = 'default' | 'preschool' | 'promo';\n\n type LessonSelector = DictionarySelectorForGroup<\n LessonGroup,\n ProjectVariants\n >;\n\n it('should accept a variant this key declares', () => {\n expectTypeOf<{ variant: 'preschool' }>().toExtend<LessonSelector>();\n });\n\n it('should accept a variant declared elsewhere in the project', () => {\n // `LessonGroup` has no `promo` entry — it resolves to `default` at runtime,\n // which is what makes one session-wide variant usable across every key.\n expectTypeOf<{ variant: 'promo' }>().toExtend<LessonSelector>();\n });\n\n it('should reject a variant no dictionary declares', () => {\n expectTypeOf<{ variant: 'promoo' }>().not.toExtend<LessonSelector>();\n });\n\n it('should reject an object variant on a key that declares none', () => {\n expectTypeOf<{ variant: { id: 'abc' } }>().not.toExtend<LessonSelector>();\n });\n\n describe('object variants', () => {\n // `ProductGroup` stores `'id=abc&userId=123'` — the serialized form of\n // `{ id: 'abc', userId: '123' }`.\n type ProductSelector = DictionarySelectorForGroup<\n ProductGroup,\n ProjectVariants\n >;\n\n it('should accept the object the key declares', () => {\n expectTypeOf<{\n variant: { id: 'abc'; userId: '123' };\n }>().toExtend<ProductSelector>();\n });\n\n it('should reject the serialized form as a string', () => {\n // `'id=abc&userId=123'` is a storage encoding, not part of the API.\n expectTypeOf<{\n variant: 'id=abc&userId=123';\n }>().not.toExtend<ProductSelector>();\n });\n\n it('should reject a partial or mismatched object', () => {\n expectTypeOf<{\n variant: { id: 'abc' };\n }>().not.toExtend<ProductSelector>();\n expectTypeOf<{\n variant: { id: 'abc'; userId: 'other' };\n }>().not.toExtend<ProductSelector>();\n });\n });\n\n describe('locale', () => {\n it('should accept a declared locale', () => {\n expectTypeOf<{ locale: 'fr' }>().toExtend<LessonSelector>();\n });\n\n it('should accept a widened `string` locale', () => {\n // A locale usually reaches this API as a router param (`params.locale`)\n // or a stored value, both typed `string`. Rejecting those would force a\n // cast at every call site, so the declared locales are suggestions only.\n expectTypeOf<{ locale: string }>().toExtend<LessonSelector>();\n });\n });\n});\n\ndescribe('DictionarySelectorForGroup — keys without a default entry', () => {\n type ProjectVariants = 'default' | 'preschool' | 'promo';\n\n // Declares only object variants: an undeclared name resolves to `null`, so\n // the project vocabulary must not be accepted here.\n type ProductSelector = DictionarySelectorForGroup<\n ProductGroup,\n ProjectVariants\n >;\n\n // Declares `promo` but no `default` — same reasoning.\n type NoDefaultSelector = DictionarySelectorForGroup<\n NoDefaultGroup,\n ProjectVariants\n >;\n\n it('should reject a project variant on a key with no default entry', () => {\n expectTypeOf<{ variant: 'promo' }>().not.toExtend<ProductSelector>();\n expectTypeOf<{ variant: 'default' }>().not.toExtend<ProductSelector>();\n expectTypeOf<{ variant: 'preschool' }>().not.toExtend<NoDefaultSelector>();\n });\n\n it('should still accept the names such a key declares itself', () => {\n expectTypeOf<{ variant: 'promo' }>().toExtend<NoDefaultSelector>();\n });\n});\n"],"mappings":";;;AAqDA,SAAS,2CAA2C;CAClD,GAAG,iFAAiF;EAClF,aAEE,CAAC,CAAC,cAA0B;CAChC,CAAC;CAED,SAAS,iBAAiB;EACxB,GAAG,yEAAyE;GAC1E,aAEE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,GAAG,gEAAgE;GACjE,aAEE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,GAAG,4DAA4D;GAC7D,aAEE,CAAC,CAAC,cAAyD;EAC/D,CAAC;EAED,GAAG,yEAAyE;GAC1E,aAKE,CAAC,CAAC,cAAuD;EAC7D,CAAC;EAED,GAAG,kEAAkE;GACnE,aAKE,CAAC,CAAC,cAAoB;EAC1B,CAAC;EAED,GAAG,uDAAuD;GACxD,aAKE,CAAC,CAAC,cAA+B;EACrC,CAAC;EAED,GAAG,0EAA0E;GAC3E,aAEE,CAAC,CAAC,cAAoB;EAC1B,CAAC;CACH,CAAC;CAED,SAAS,cAAc;EACrB,GAAG,6EAA6E;GAC9E,aAA0D,CAAC,CAAC,cAE1D;EACJ,CAAC;EAED,GAAG,4CAA4C;GAC7C,aAEE,CAAC,CAAC,cAAkC;EACxC,CAAC;CACH,CAAC;CAED,SAAS,oCAAoC;EAC3C,GAAG,yEAAyE;GAC1E,aAKE,CAAC,CAAC,cAA+B;EACrC,CAAC;EAED,GAAG,+DAA+D;GAChE,aAEE,CAAC,CAAC,cAAqD;EAC3D,CAAC;EAED,GAAG,wEAAwE;GACzE,aAEE,CAAC,CAAC,cAAiC;EACvC,CAAC;CACH,CAAC;AACH,CAAC;AAED,SAAS,oCAAoC;CAS3C,GAAG,mDAAmD;EACpD,aAAuC,CAAC,CAAC,SAAyB;CACpE,CAAC;CAED,GAAG,mEAAmE;EAGpE,aAAmC,CAAC,CAAC,SAAyB;CAChE,CAAC;CAED,GAAG,wDAAwD;EACzD,aAAoC,CAAC,CAAC,IAAI,SAAyB;CACrE,CAAC;CAED,GAAG,qEAAqE;EACtE,aAAyC,CAAC,CAAC,IAAI,SAAyB;CAC1E,CAAC;CAED,SAAS,yBAAyB;EAQhC,GAAG,mDAAmD;GACpD,aAEG,CAAC,CAAC,SAA0B;EACjC,CAAC;EAED,GAAG,uDAAuD;GAExD,aAEG,CAAC,CAAC,IAAI,SAA0B;EACrC,CAAC;EAED,GAAG,sDAAsD;GACvD,aAEG,CAAC,CAAC,IAAI,SAA0B;GACnC,aAEG,CAAC,CAAC,IAAI,SAA0B;EACrC,CAAC;CACH,CAAC;CAED,SAAS,gBAAgB;EACvB,GAAG,yCAAyC;GAC1C,aAA+B,CAAC,CAAC,SAAyB;EAC5D,CAAC;EAED,GAAG,iDAAiD;GAIlD,aAAiC,CAAC,CAAC,SAAyB;EAC9D,CAAC;CACH,CAAC;AACH,CAAC;AAED,SAAS,mEAAmE;CAgB1E,GAAG,wEAAwE;EACzE,aAAmC,CAAC,CAAC,IAAI,SAA0B;EACnE,aAAqC,CAAC,CAAC,IAAI,SAA0B;EACrE,aAAuC,CAAC,CAAC,IAAI,SAA4B;CAC3E,CAAC;CAED,GAAG,kEAAkE;EACnE,aAAmC,CAAC,CAAC,SAA4B;CACnE,CAAC;AACH,CAAC"}
@@ -85,6 +85,7 @@ import { getLocaleFromPath } from "./localization/getLocaleFromPath.mjs";
85
85
  import { getLocaleLang } from "./localization/getLocaleLang.mjs";
86
86
  import { getLocaleName } from "./localization/getLocaleName.mjs";
87
87
  import { localeFlatMap, localeMap, localeRecord } from "./localization/localeMapper.mjs";
88
+ import { formatProxyEnabledMessage, isProxyStorageLocaleEnabled, resolveProxyMode } from "./localization/proxyMode.mjs";
88
89
  import { validatePrefix } from "./localization/validatePrefix.mjs";
89
90
  import { ATTRIBUTES_TO_SANITIZE, 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, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, 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, Priority, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, 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_PLAIN_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, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex } from "./markdown/constants.mjs";
90
91
  import { allowInline, anyScopeRegex, attributeValueToNodePropValue, blockRegex, captureNothing, cx, get, inlineRegex, normalizeAttributeKey, normalizeWhitespace, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, qualifies, renderNothing, sanitizer, simpleInlineRegex, slugify, some, startsWith, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, unquote } from "./markdown/utils.mjs";
@@ -100,4 +101,4 @@ import { interpolateMessage, parseTaggedMessage, resolveMessage, resolveMessageN
100
101
  import { isSameKeyPath } from "./utils/isSameKeyPath.mjs";
101
102
  import { stringifyYaml } from "./utils/stringifyYaml.mjs";
102
103
 
103
- export { ATTRIBUTES_TO_SANITIZE, 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, CUSTOM_COMPONENT_R, CachedIntl, CachedIntl as Intl, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HTML_TAGS, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_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, Priority, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, 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_PLAIN_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, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createCompiler, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDomainHostname, getDomainOrigin, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPlural, getPrefix, getReplacedValuesContent, getRewritePath, getRewriteRules, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, isInterpolableWrapperNode, isLocaleExclusiveOnDomain, 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, rebuildInterpolableContent, reconstructQualifiedEntry, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveDictionaryArgument, resolveMessage, resolveMessageNode, resolveProviderVariant, 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 };
104
+ export { ATTRIBUTES_TO_SANITIZE, 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, CUSTOM_COMPONENT_R, CachedIntl, CachedIntl as Intl, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HTML_TAGS, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_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, Priority, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, 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_PLAIN_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, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createCompiler, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, formatProxyEnabledMessage, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDomainHostname, getDomainOrigin, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPlural, getPrefix, getReplacedValuesContent, getRewritePath, getRewriteRules, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, 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, rebuildInterpolableContent, reconstructQualifiedEntry, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveDictionaryArgument, resolveMessage, resolveMessageNode, 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 };
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.mjs","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelector,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n} from '@intlayer/types/module_augmentation';\nimport {\n parseDictionarySelector,\n resolveQualifiedDictionary,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getBasePlugins, getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * Also accepts a `QualifiedDictionaryGroup` (collections, variants) together\n * with a selector as second argument — the group is resolved to a single entry\n * (or an ordered array of entries for collections without an `item` selector)\n * before transformation.\n *\n * @param dictionary The dictionary (or qualified dictionary group) to transform.\n * @param localeOrSelector The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends DeclaredLocales | DictionarySelector = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const { locale, selector } = parseDictionarySelector(localeOrSelector);\n const appliedPlugins = plugins ?? getBasePlugins(locale);\n\n const resolved = resolveQualifiedDictionary(dictionary, selector);\n\n const transformDictionary = (resolvedDictionary: Dictionary) => {\n const props: NodeProps = {\n dictionaryKey: resolvedDictionary.key,\n dictionaryPath: resolvedDictionary.filePath,\n keyPath: [],\n plugins: appliedPlugins,\n };\n\n return getContent(resolvedDictionary.content, props, appliedPlugins);\n };\n\n if (resolved === null) return null as any;\n\n if (Array.isArray(resolved)) {\n return resolved.map(transformDictionary) as any;\n }\n\n return transformDictionary(resolved) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,MAAa,iBAIX,YACA,kBACA,YAKG;CACH,MAAM,EAAE,QAAQ,aAAa,wBAAwB,gBAAgB;CACrE,MAAM,iBAAiB,WAAW,eAAe,MAAM;CAEvD,MAAM,WAAW,2BAA2B,YAAY,QAAQ;CAEhE,MAAM,uBAAuB,uBAAmC;EAC9D,MAAM,QAAmB;GACvB,eAAe,mBAAmB;GAClC,gBAAgB,mBAAmB;GACnC,SAAS,CAAC;GACV,SAAS;EACX;EAEA,OAAO,WAAW,mBAAmB,SAAS,OAAO,cAAc;CACrE;CAEA,IAAI,aAAa,MAAM,OAAO;CAE9B,IAAI,MAAM,QAAQ,QAAQ,GACxB,OAAO,SAAS,IAAI,mBAAmB;CAGzC,OAAO,oBAAoB,QAAQ;AACrC"}
1
+ {"version":3,"file":"getDictionary.mjs","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelector,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n parseDictionarySelector,\n resolveQualifiedDictionary,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getBasePlugins, getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * Also accepts a `QualifiedDictionaryGroup` (collections, variants) together\n * with a selector as second argument — the group is resolved to a single entry\n * (or an ordered array of entries for collections without an `item` selector)\n * before transformation.\n *\n * @param dictionary The dictionary (or qualified dictionary group) to transform.\n * @param localeOrSelector The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const { locale, selector } = parseDictionarySelector(localeOrSelector);\n const appliedPlugins = plugins ?? getBasePlugins(locale);\n\n const resolved = resolveQualifiedDictionary(dictionary, selector);\n\n const transformDictionary = (resolvedDictionary: Dictionary) => {\n const props: NodeProps = {\n dictionaryKey: resolvedDictionary.key,\n dictionaryPath: resolvedDictionary.filePath,\n keyPath: [],\n plugins: appliedPlugins,\n };\n\n return getContent(resolvedDictionary.content, props, appliedPlugins);\n };\n\n if (resolved === null) return null as any;\n\n if (Array.isArray(resolved)) {\n return resolved.map(transformDictionary) as any;\n }\n\n return transformDictionary(resolved) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqCA,MAAa,iBAIX,YACA,kBACA,YAKG;CACH,MAAM,EAAE,QAAQ,aAAa,wBAAwB,gBAAgB;CACrE,MAAM,iBAAiB,WAAW,eAAe,MAAM;CAEvD,MAAM,WAAW,2BAA2B,YAAY,QAAQ;CAEhE,MAAM,uBAAuB,uBAAmC;EAC9D,MAAM,QAAmB;GACvB,eAAe,mBAAmB;GAClC,gBAAgB,mBAAmB;GACnC,SAAS,CAAC;GACV,SAAS;EACX;EAEA,OAAO,WAAW,mBAAmB,SAAS,OAAO,cAAc;CACrE;CAEA,IAAI,aAAa,MAAM,OAAO;CAE9B,IAAI,MAAM,QAAQ,QAAQ,GACxB,OAAO,SAAS,IAAI,mBAAmB;CAGzC,OAAO,oBAAoB,QAAQ;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.mjs","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy({} as Record<string | symbol, unknown>, {\n get: (_target, prop) => {\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString' ||\n prop === 'valueOf'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n if (prop === Symbol.iterator) {\n return function* () {\n yield path;\n };\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n });\n};\n\nconst dictionaryCache = new Map<string, any>();\nconst warnedMissingDictionaries = new Set<string>();\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector.\n *\n * The second argument is either a locale (`'fr'`) or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: { id: 'prod_abc', userId: '123' } }` — structured variant\n * - `locale` can be combined with any selector: `{ item: 2, locale: 'fr' }`\n */\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const A extends DeclaredLocales | DictionarySelector = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T];\n\n if (!dictionary && process.env.NODE_ENV === 'development') {\n if (!warnedMissingDictionaries.has(key as string)) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger({ log });\n logger(\n typeof window === 'undefined'\n ? `Dictionary ${colorizeKey(key)} was not found. Using fallback proxy.`\n : `Dictionary ${key} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n }\n );\n warnedMissingDictionaries.add(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n let locale: LocalesValues | undefined;\n let selectorCacheKey = '';\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const parsed = parseDictionarySelector(localeOrSelector);\n locale = parsed.locale;\n selectorCacheKey = getDictionarySelectorCacheKey(parsed.selector);\n } else {\n // Selectors are unused in this project (build-time flag): the second\n // argument can only be a locale, so the selector parsing is dead code.\n locale = localeOrSelector as LocalesValues | undefined;\n }\n\n const cacheKey = `${key}_${locale ?? 'default'}_${selectorCacheKey}_${plugins ? 'custom_plugins' : 'default_plugins'}`;\n\n if (dictionaryCache.has(cacheKey)) {\n return dictionaryCache.get(cacheKey);\n }\n\n const result = getDictionary(dictionary, localeOrSelector, plugins);\n\n dictionaryCache.set(cacheKey, result);\n\n return result as any;\n};\n"],"mappings":";;;;;;;;;;;AA0BA,MAAM,sBAAsB,OAAO,OAAY;CAC7C,OAAO,IAAI,MAAM,CAAC,GAAuC,EACvD,MAAM,SAAS,SAAS;EACtB,IACE,SAAS,YACT,SAAS,OAAO,eAChB,SAAS,cACT,SAAS,WAET,aAAa;EAEf,IAAI,SAAS,QACX;EAEF,IAAI,SAAS,OAAO,UAClB,OAAO,aAAa;GAClB,MAAM;EACR;EAIF,MAAM,WAAW,OAAO,GAAG,KAAK,GAAG,OAAO,IAAI,MAAM,OAAO,IAAI;EAC/D,OAAO,mBAAmB,QAAQ;CACpC,EACF,CAAC;AACH;AAEA,MAAM,kCAAkB,IAAI,IAAiB;AAC7C,MAAM,4CAA4B,IAAI,IAAY;;;;;;;;;;;AAYlD,MAAa,eAIX,KACA,kBACA,YAKG;CAEH,MAAM,aADe,gBACS,CAAC,CAAC;CAEhC,IAAI,CAAC,cAAc,MAAwC;EACzD,IAAI,CAAC,0BAA0B,IAAI,GAAa,GAAG;GAGjD,AADe,aAAa,EAAE,IAAI,CAC7B,CAAC,CACJ,OAAO,WAAW,cACd,cAAc,YAAY,GAAG,EAAE,yCAC/B,cAAc,IAAI,wCACtB,EACE,OAAO,OACT,CACF;GACA,0BAA0B,IAAI,GAAa;EAC7C;EAEA,OAAO,mBAAmB,GAAa;CACzC;CAEA,IAAI;CACJ,IAAI,mBAAmB;CAEvB,IAAI,QAAQ,IAAI,iCAAiC,SAAS;EACxD,MAAM,SAAS,wBAAwB,gBAAgB;EACvD,SAAS,OAAO;EAChB,mBAAmB,8BAA8B,OAAO,QAAQ;CAClE,OAGE,SAAS;CAGX,MAAM,WAAW,GAAG,IAAI,GAAG,UAAU,UAAU,GAAG,iBAAiB,GAAG,UAAU,mBAAmB;CAEnG,IAAI,gBAAgB,IAAI,QAAQ,GAC9B,OAAO,gBAAgB,IAAI,QAAQ;CAGrC,MAAM,SAAS,cAAc,YAAY,kBAAkB,OAAO;CAElE,gBAAgB,IAAI,UAAU,MAAM;CAEpC,OAAO;AACT"}
1
+ {"version":3,"file":"getIntlayer.mjs","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy({} as Record<string | symbol, unknown>, {\n get: (_target, prop) => {\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString' ||\n prop === 'valueOf'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n if (prop === Symbol.iterator) {\n return function* () {\n yield path;\n };\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n });\n};\n\nconst dictionaryCache = new Map<string, any>();\nconst warnedMissingDictionaries = new Set<string>();\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector.\n *\n * The second argument is either a locale (`'fr'`) or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: { id: 'prod_abc', userId: '123' } }` — structured variant\n * - `locale` can be combined with any selector: `{ item: 2, locale: 'fr' }`\n */\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T];\n\n if (!dictionary && process.env.NODE_ENV === 'development') {\n if (!warnedMissingDictionaries.has(key as string)) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger({ log });\n logger(\n typeof window === 'undefined'\n ? `Dictionary ${colorizeKey(key)} was not found. Using fallback proxy.`\n : `Dictionary ${key} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n }\n );\n warnedMissingDictionaries.add(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n let locale: LocalesValues | undefined;\n let selectorCacheKey = '';\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const parsed = parseDictionarySelector(localeOrSelector);\n locale = parsed.locale;\n selectorCacheKey = getDictionarySelectorCacheKey(parsed.selector);\n } else {\n // Selectors are unused in this project (build-time flag): the second\n // argument can only be a locale, so the selector parsing is dead code.\n locale = localeOrSelector as LocalesValues | undefined;\n }\n\n const cacheKey = `${key}_${locale ?? 'default'}_${selectorCacheKey}_${plugins ? 'custom_plugins' : 'default_plugins'}`;\n\n if (dictionaryCache.has(cacheKey)) {\n return dictionaryCache.get(cacheKey);\n }\n\n const result = getDictionary(dictionary, localeOrSelector, plugins);\n\n dictionaryCache.set(cacheKey, result);\n\n return result as any;\n};\n"],"mappings":";;;;;;;;;;;AA0BA,MAAM,sBAAsB,OAAO,OAAY;CAC7C,OAAO,IAAI,MAAM,CAAC,GAAuC,EACvD,MAAM,SAAS,SAAS;EACtB,IACE,SAAS,YACT,SAAS,OAAO,eAChB,SAAS,cACT,SAAS,WAET,aAAa;EAEf,IAAI,SAAS,QACX;EAEF,IAAI,SAAS,OAAO,UAClB,OAAO,aAAa;GAClB,MAAM;EACR;EAIF,MAAM,WAAW,OAAO,GAAG,KAAK,GAAG,OAAO,IAAI,MAAM,OAAO,IAAI;EAC/D,OAAO,mBAAmB,QAAQ;CACpC,EACF,CAAC;AACH;AAEA,MAAM,kCAAkB,IAAI,IAAiB;AAC7C,MAAM,4CAA4B,IAAI,IAAY;;;;;;;;;;;AAYlD,MAAa,eAIX,KACA,kBACA,YAKG;CAEH,MAAM,aADe,gBACS,CAAC,CAAC;CAEhC,IAAI,CAAC,cAAc,MAAwC;EACzD,IAAI,CAAC,0BAA0B,IAAI,GAAa,GAAG;GAGjD,AADe,aAAa,EAAE,IAAI,CAC7B,CAAC,CACJ,OAAO,WAAW,cACd,cAAc,YAAY,GAAG,EAAE,yCAC/B,cAAc,IAAI,wCACtB,EACE,OAAO,OACT,CACF;GACA,0BAA0B,IAAI,GAAa;EAC7C;EAEA,OAAO,mBAAmB,GAAa;CACzC;CAEA,IAAI;CACJ,IAAI,mBAAmB;CAEvB,IAAI,QAAQ,IAAI,iCAAiC,SAAS;EACxD,MAAM,SAAS,wBAAwB,gBAAgB;EACvD,SAAS,OAAO;EAChB,mBAAmB,8BAA8B,OAAO,QAAQ;CAClE,OAGE,SAAS;CAGX,MAAM,WAAW,GAAG,IAAI,GAAG,UAAU,UAAU,GAAG,iBAAiB,GAAG,UAAU,mBAAmB;CAEnG,IAAI,gBAAgB,IAAI,QAAQ,GAC9B,OAAO,gBAAgB,IAAI,QAAQ;CAGrC,MAAM,SAAS,cAAc,YAAY,kBAAkB,OAAO;CAElE,gBAAgB,IAAI,UAAU,MAAM;CAEpC,OAAO;AACT"}
@@ -0,0 +1,28 @@
1
+ import { getIntlayer } from "./getIntlayer.mjs";
2
+ import { describe, expectTypeOf, it } from "vitest";
3
+
4
+ //#region src/interpreter/getIntlayer.test-d.ts
5
+ /**
6
+ * The second argument of `getIntlayer` is almost always a value the framework
7
+ * hands over as a plain `string`: a router param (`params.locale`), a cookie, a
8
+ * header. Constraining it to the declared locales made every such call site a
9
+ * compile error, so the declared locales are offered as suggestions while any
10
+ * string is still accepted.
11
+ */
12
+ describe("getIntlayer — locale argument", () => {
13
+ it("should accept a locale literal", () => {
14
+ expectTypeOf(getIntlayer("lesson", "fr")).not.toBeNever();
15
+ });
16
+ it("should accept a `string | undefined` router param", () => {
17
+ expectTypeOf(getIntlayer("lesson", "fr")).not.toBeNever();
18
+ });
19
+ it("should accept a selector carrying a widened locale", () => {
20
+ expectTypeOf(getIntlayer("lesson", {
21
+ locale: "fr",
22
+ item: 1
23
+ })).not.toBeNever();
24
+ });
25
+ });
26
+
27
+ //#endregion
28
+ //# sourceMappingURL=getIntlayer.test-d.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIntlayer.test-d.mjs","names":[],"sources":["../../../src/interpreter/getIntlayer.test-d.ts"],"sourcesContent":["import { describe, expectTypeOf, it } from 'vitest';\nimport { getIntlayer } from './getIntlayer';\n\n/**\n * The second argument of `getIntlayer` is almost always a value the framework\n * hands over as a plain `string`: a router param (`params.locale`), a cookie, a\n * header. Constraining it to the declared locales made every such call site a\n * compile error, so the declared locales are offered as suggestions while any\n * string is still accepted.\n */\ndescribe('getIntlayer — locale argument', () => {\n it('should accept a locale literal', () => {\n expectTypeOf(getIntlayer('lesson', 'fr')).not.toBeNever();\n });\n\n it('should accept a `string | undefined` router param', () => {\n const routerLocale = 'fr' as string | undefined;\n\n expectTypeOf(getIntlayer('lesson', routerLocale)).not.toBeNever();\n });\n\n it('should accept a selector carrying a widened locale', () => {\n const routerLocale = 'fr' as string;\n\n expectTypeOf(\n getIntlayer('lesson', { locale: routerLocale, item: 1 })\n ).not.toBeNever();\n });\n});\n"],"mappings":";;;;;;;;;;;AAUA,SAAS,uCAAuC;CAC9C,GAAG,wCAAwC;EACzC,aAAa,YAAY,UAAU,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU;CAC1D,CAAC;CAED,GAAG,2DAA2D;EAG5D,aAAa,YAAY,UAAU,IAAY,CAAC,CAAC,CAAC,IAAI,UAAU;CAClE,CAAC;CAED,GAAG,4DAA4D;EAG7D,aACE,YAAY,UAAU;GAAE,QAAQ;GAAc,MAAM;EAAE,CAAC,CACzD,CAAC,CAAC,IAAI,UAAU;CAClB,CAAC;AACH,CAAC"}
@@ -15,6 +15,7 @@ import { getLocaleFromPath } from "./getLocaleFromPath.mjs";
15
15
  import { getLocaleLang } from "./getLocaleLang.mjs";
16
16
  import { getLocaleName } from "./getLocaleName.mjs";
17
17
  import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.mjs";
18
+ import { formatProxyEnabledMessage, isProxyStorageLocaleEnabled, resolveProxyMode } from "./proxyMode.mjs";
18
19
  import { validatePrefix } from "./validatePrefix.mjs";
19
20
 
20
- export { comparePaths, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getDomainHostname, getDomainOrigin, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, isLocaleExclusiveOnDomain, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, normalizePath, validatePrefix };
21
+ export { comparePaths, formatProxyEnabledMessage, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getDomainHostname, getDomainOrigin, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, normalizePath, resolveProxyMode, validatePrefix };
@@ -0,0 +1,87 @@
1
+ import { colorize } from "@intlayer/config/logger";
2
+ import * as ANSIColors from "@intlayer/config/colors";
3
+
4
+ //#region src/localization/proxyMode.ts
5
+ /**
6
+ * Resolves the effective {@link ProxyMode} from the `routing.enableProxy`
7
+ * configuration value.
8
+ *
9
+ * `process.env.INTLAYER_ROUTING_ENABLE_PROXY` is injected at build time by
10
+ * `getConfigEnvVars` and takes precedence, so bundlers can dead-code-eliminate
11
+ * the branches guarded by the resolved mode. The variable is only emitted for
12
+ * the two explicit states; its absence means `'auto'` and defers to the
13
+ * configuration value read at runtime.
14
+ *
15
+ * @param enableProxy - The `routing.enableProxy` value; `undefined` means auto.
16
+ * @returns The resolved proxy mode.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * resolveProxyMode(undefined); // 'auto'
21
+ * resolveProxyMode(true); // 'forced'
22
+ * resolveProxyMode(false); // 'disabled'
23
+ * ```
24
+ */
25
+ const resolveProxyMode = (enableProxy) => {
26
+ if (process.env.INTLAYER_ROUTING_ENABLE_PROXY === "false") return "disabled";
27
+ if (process.env.INTLAYER_ROUTING_ENABLE_PROXY === "true") return "forced";
28
+ if (enableProxy === false) return "disabled";
29
+ if (enableProxy === true) return "forced";
30
+ return "auto";
31
+ };
32
+ /**
33
+ * Indicates whether the proxy may use the locale held in storage (cookie or
34
+ * header) as a source when deciding which locale a request resolves to.
35
+ *
36
+ * Auto mode suppresses it on development and preview servers only. Every other
37
+ * combination keeps the stored locale active, which notably preserves the
38
+ * behaviour of `createIntlayerProxyHandler` when it is mounted manually in a
39
+ * production Nitro server.
40
+ *
41
+ * Suppressing the read affects redirect *sources* only — the locale is still
42
+ * persisted onto responses, the URL locale prefix still wins over everything,
43
+ * and `Accept-Language` detection still applies as the fallback.
44
+ *
45
+ * @param proxyMode - The resolved proxy mode.
46
+ * @param isDevServer - Whether a development or preview server is serving the app.
47
+ * @returns `true` when the stored locale may drive locale resolution.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * isProxyStorageLocaleEnabled('auto', true); // false — dev server, URL-driven only
52
+ * isProxyStorageLocaleEnabled('auto', false); // true — production
53
+ * isProxyStorageLocaleEnabled('forced', true); // true — explicitly opted in
54
+ * ```
55
+ */
56
+ const isProxyStorageLocaleEnabled = (proxyMode, isDevServer) => !(proxyMode === "auto" && isDevServer);
57
+ /**
58
+ * Builds the line announcing that a server has mounted the locale-routing
59
+ * proxy.
60
+ *
61
+ * Shared by every integration (Vite plugin, Next.js middleware) so the reported
62
+ * state cannot drift between them: when the stored locale is suppressed the
63
+ * message says so, which would otherwise look like a broken proxy to anyone
64
+ * testing locale switching with a cookie already set.
65
+ *
66
+ * Takes the suppression flag rather than the {@link ProxyMode} on purpose. Auto
67
+ * mode only suppresses storage on a dev server, so a mode-based signature would
68
+ * let a production caller — such as the Nitro production handler — announce a
69
+ * suppression that is not actually in effect.
70
+ *
71
+ * @param isStorageLocaleSuppressed - Whether the stored locale is barred from
72
+ * driving redirects, i.e. the negation of {@link isProxyStorageLocaleEnabled}.
73
+ * @returns An ANSI-coloured, ready-to-log message.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * formatProxyEnabledMessage(true);
78
+ * // Intlayer proxy enabled - storage redirection disabled for dev purpose
79
+ * formatProxyEnabledMessage(false);
80
+ * // Intlayer proxy enabled
81
+ * ```
82
+ */
83
+ const formatProxyEnabledMessage = (isStorageLocaleSuppressed) => [`Intlayer proxy ${colorize("enabled", ANSIColors.GREEN)}`, isStorageLocaleSuppressed && colorize("- storage redirection disabled for dev purpose", ANSIColors.GREY)].filter(Boolean).join(" ");
84
+
85
+ //#endregion
86
+ export { formatProxyEnabledMessage, isProxyStorageLocaleEnabled, resolveProxyMode };
87
+ //# sourceMappingURL=proxyMode.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxyMode.mjs","names":[],"sources":["../../../src/localization/proxyMode.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport { colorize } from '@intlayer/config/logger';\n\n/**\n * Effective mode of the Intlayer locale-routing proxy, resolved from the\n * `routing.enableProxy` configuration option.\n *\n * - `'auto'` — the option was left unset. The proxy is registered, but it stays\n * URL-driven while a development or preview server is serving the app: the\n * stored locale (cookie / header) is not used as a redirect source, so a\n * stale cookie cannot silently pull every navigation to another locale. In\n * production the mode behaves exactly like `'forced'`.\n * - `'forced'` — the option was explicitly set to `true`. Full proxy behaviour\n * in every environment, storage-driven redirects included.\n * - `'disabled'` — the option was explicitly set to `false`. The proxy is not\n * registered at all (Vite) or becomes a pass-through (Next.js).\n */\nexport type ProxyMode = 'auto' | 'forced' | 'disabled';\n\n/**\n * Resolves the effective {@link ProxyMode} from the `routing.enableProxy`\n * configuration value.\n *\n * `process.env.INTLAYER_ROUTING_ENABLE_PROXY` is injected at build time by\n * `getConfigEnvVars` and takes precedence, so bundlers can dead-code-eliminate\n * the branches guarded by the resolved mode. The variable is only emitted for\n * the two explicit states; its absence means `'auto'` and defers to the\n * configuration value read at runtime.\n *\n * @param enableProxy - The `routing.enableProxy` value; `undefined` means auto.\n * @returns The resolved proxy mode.\n *\n * @example\n * ```ts\n * resolveProxyMode(undefined); // 'auto'\n * resolveProxyMode(true); // 'forced'\n * resolveProxyMode(false); // 'disabled'\n * ```\n */\nexport const resolveProxyMode = (enableProxy?: boolean): ProxyMode => {\n if (process.env.INTLAYER_ROUTING_ENABLE_PROXY === 'false') return 'disabled';\n if (process.env.INTLAYER_ROUTING_ENABLE_PROXY === 'true') return 'forced';\n\n if (enableProxy === false) return 'disabled';\n if (enableProxy === true) return 'forced';\n\n return 'auto';\n};\n\n/**\n * Indicates whether the proxy may use the locale held in storage (cookie or\n * header) as a source when deciding which locale a request resolves to.\n *\n * Auto mode suppresses it on development and preview servers only. Every other\n * combination keeps the stored locale active, which notably preserves the\n * behaviour of `createIntlayerProxyHandler` when it is mounted manually in a\n * production Nitro server.\n *\n * Suppressing the read affects redirect *sources* only — the locale is still\n * persisted onto responses, the URL locale prefix still wins over everything,\n * and `Accept-Language` detection still applies as the fallback.\n *\n * @param proxyMode - The resolved proxy mode.\n * @param isDevServer - Whether a development or preview server is serving the app.\n * @returns `true` when the stored locale may drive locale resolution.\n *\n * @example\n * ```ts\n * isProxyStorageLocaleEnabled('auto', true); // false — dev server, URL-driven only\n * isProxyStorageLocaleEnabled('auto', false); // true — production\n * isProxyStorageLocaleEnabled('forced', true); // true — explicitly opted in\n * ```\n */\nexport const isProxyStorageLocaleEnabled = (\n proxyMode: ProxyMode,\n isDevServer: boolean\n): boolean => !(proxyMode === 'auto' && isDevServer);\n\n/**\n * Builds the line announcing that a server has mounted the locale-routing\n * proxy.\n *\n * Shared by every integration (Vite plugin, Next.js middleware) so the reported\n * state cannot drift between them: when the stored locale is suppressed the\n * message says so, which would otherwise look like a broken proxy to anyone\n * testing locale switching with a cookie already set.\n *\n * Takes the suppression flag rather than the {@link ProxyMode} on purpose. Auto\n * mode only suppresses storage on a dev server, so a mode-based signature would\n * let a production caller — such as the Nitro production handler — announce a\n * suppression that is not actually in effect.\n *\n * @param isStorageLocaleSuppressed - Whether the stored locale is barred from\n * driving redirects, i.e. the negation of {@link isProxyStorageLocaleEnabled}.\n * @returns An ANSI-coloured, ready-to-log message.\n *\n * @example\n * ```ts\n * formatProxyEnabledMessage(true);\n * // Intlayer proxy enabled - storage redirection disabled for dev purpose\n * formatProxyEnabledMessage(false);\n * // Intlayer proxy enabled\n * ```\n */\nexport const formatProxyEnabledMessage = (\n isStorageLocaleSuppressed: boolean\n): string =>\n [\n `Intlayer proxy ${colorize('enabled', ANSIColors.GREEN)}`,\n isStorageLocaleSuppressed &&\n colorize(\n '- storage redirection disabled for dev purpose',\n ANSIColors.GREY\n ),\n ]\n .filter(Boolean)\n .join(' ');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAa,oBAAoB,gBAAqC;CACpE,IAAI,QAAQ,IAAI,kCAAkC,SAAS,OAAO;CAClE,IAAI,QAAQ,IAAI,kCAAkC,QAAQ,OAAO;CAEjE,IAAI,gBAAgB,OAAO,OAAO;CAClC,IAAI,gBAAgB,MAAM,OAAO;CAEjC,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,+BACX,WACA,gBACY,EAAE,cAAc,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BxC,MAAa,6BACX,8BAEA,CACE,kBAAkB,SAAS,WAAW,WAAW,KAAK,KACtD,6BACE,SACE,kDACA,WAAW,IACb,CACJ,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG"}
@@ -85,6 +85,7 @@ import { getPathWithoutLocale } from "./localization/getPathWithoutLocale.js";
85
85
  import { localeDetector } from "./localization/localeDetector.js";
86
86
  import { localeFlatMap, localeMap, localeRecord } from "./localization/localeMapper.js";
87
87
  import { localeResolver } from "./localization/localeResolver.js";
88
+ import { ProxyMode, formatProxyEnabledMessage, isProxyStorageLocaleEnabled, resolveProxyMode } from "./localization/proxyMode.js";
88
89
  import { LocalizedPathResult, getCanonicalPath, getInternalPath, getLocalizedPath, getRewritePath, getRewriteRules } from "./localization/rewriteUtils.js";
89
90
  import { validatePrefix } from "./localization/validatePrefix.js";
90
91
  import "./localization/index.js";
@@ -110,4 +111,4 @@ import { CookieBuildAttributes, LocaleStorage, LocaleStorageClient, LocaleStorag
110
111
  import { YamlRecord, YamlValue, parseYaml } from "./utils/parseYaml.js";
111
112
  import { stringifyYaml } from "./utils/stringifyYaml.js";
112
113
  import "./utils/index.js";
113
- export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, type BlockQuoteNode, type BoldTextNode, type BreakLineNode, type BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, COMPOSITE_ID_SEPARATOR, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, CachedIntl, CachedIntl as Intl, type CodeBlockNode, type CodeFencedNode, type CodeInlineNode, type CompileOptions, type ComponentOverrides, ConditionCond, ConditionContent, ConditionContentStates, CookieBuildAttributes, type CustomComponentNode, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, DateTimePreset, DeepTransformContent, DotPath, DynamicDictionaryLoader, type ElementType, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, type EscapedTextNode, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FileCond, type FileContent, type FileContentConstructor, type FootnoteNode, type FootnoteReferenceNode, type GFMTaskNode, GFM_TASK_R, Gender, GenderCond, GenderContent, GenderContentStates, type GenerateSitemapOptions, GetNestingResult, type GetPrefixOptions, type GetPrefixResult, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, type HTMLCommentNode, HTMLContent, HTMLContentConstructor, type HTMLNode, type HTMLSelfClosingNode, type HTMLTag, HTMLTagsType, HTMLValidationIssue, HTMLValidationResult, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HTML_TAGS, type HeadingNode, type HeadingSetextNode, IInterpreterPlugin, IInterpreterPluginState, INLINE_SKIP_R, INTERPOLATION_R, type ImageNode, InsertionCond, InsertionContent, InsertionContentConstructor, InterpolableNode, IntlConstructorName, IsAny, type ItalicTextNode, JsonValue, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, type LinkAngleBraceNode, type LinkBareURLNode, type LinkNode, ListType, type LocaleDomainMap, LocaleStorage, LocaleStorageClient, LocaleStorageClientOptions, LocaleStorageOptions, LocaleStorageServer, LocaleStorageServerOptions, type LocalizedPathResult, MarkdownContent, MarkdownContentConstructor, type MarkdownContext, type MarkdownOptions, type MarkdownRuntime, type HTMLValidationIssue as MarkdownValidationIssue, MarkdownValidationResult, type MarkedTextNode, MessageFormatDialect, MessageValues, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedCond, NestedContent, NestedContentState, type NestedParser, type NewlineNode, NodeProps, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, type OrderedListNode, PARAGRAPH_R, type ParagraphNode, type ParseState, ParsedMarkdown, type Parser, type ParserResult, Plugins, PluralCategory, PluralCond, PluralContent, PluralContentState, PortableObject, Priority, PriorityValue, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, type ReferenceImageNode, type ReferenceLinkNode, type ReferenceNode, type RenderRuleHook, type Rule, type RuleOutput, RuleType, RuleTypeValue, type Rules, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, SelectCond, SelectContent, SelectContentStates, SelectSelector, type SitemapUrlEntry, type StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, type TableNode, type TableSeparatorNode, TaggedMessageToken, type TextNode, TranslationCond, TranslationContent, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnionKeys, type UnorderedListNode, VOID_HTML_ELEMENTS, ValidDotPathsFor, ValueAtKey, WrappedIntl, YamlRecord, YamlValue, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createCompiler, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, type file, type fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDomainHostname, getDomainOrigin, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPlural, getPrefix, getReplacedValuesContent, getRewritePath, getRewriteRules, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, isInterpolableWrapperNode, isLocaleExclusiveOnDomain, 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, rebuildInterpolableContent, reconstructQualifiedEntry, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveDictionaryArgument, resolveMessage, resolveMessageNode, resolveProviderVariant, 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 };
114
+ export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, type BlockQuoteNode, type BoldTextNode, type BreakLineNode, type BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, COMPOSITE_ID_SEPARATOR, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, CachedIntl, CachedIntl as Intl, type CodeBlockNode, type CodeFencedNode, type CodeInlineNode, type CompileOptions, type ComponentOverrides, ConditionCond, ConditionContent, ConditionContentStates, CookieBuildAttributes, type CustomComponentNode, DEFAULT_VARIANT_ID, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, DateTimePreset, DeepTransformContent, DotPath, DynamicDictionaryLoader, type ElementType, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, type EscapedTextNode, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FileCond, type FileContent, type FileContentConstructor, type FootnoteNode, type FootnoteReferenceNode, type GFMTaskNode, GFM_TASK_R, Gender, GenderCond, GenderContent, GenderContentStates, type GenerateSitemapOptions, GetNestingResult, type GetPrefixOptions, type GetPrefixResult, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, type HTMLCommentNode, HTMLContent, HTMLContentConstructor, type HTMLNode, type HTMLSelfClosingNode, type HTMLTag, HTMLTagsType, HTMLValidationIssue, HTMLValidationResult, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HTML_TAGS, type HeadingNode, type HeadingSetextNode, IInterpreterPlugin, IInterpreterPluginState, INLINE_SKIP_R, INTERPOLATION_R, type ImageNode, InsertionCond, InsertionContent, InsertionContentConstructor, InterpolableNode, IntlConstructorName, IsAny, type ItalicTextNode, JsonValue, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, type LinkAngleBraceNode, type LinkBareURLNode, type LinkNode, ListType, type LocaleDomainMap, LocaleStorage, LocaleStorageClient, LocaleStorageClientOptions, LocaleStorageOptions, LocaleStorageServer, LocaleStorageServerOptions, type LocalizedPathResult, MarkdownContent, MarkdownContentConstructor, type MarkdownContext, type MarkdownOptions, type MarkdownRuntime, type HTMLValidationIssue as MarkdownValidationIssue, MarkdownValidationResult, type MarkedTextNode, MessageFormatDialect, MessageValues, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedCond, NestedContent, NestedContentState, type NestedParser, type NewlineNode, NodeProps, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, type OrderedListNode, PARAGRAPH_R, type ParagraphNode, type ParseState, ParsedMarkdown, type Parser, type ParserResult, Plugins, PluralCategory, PluralCond, PluralContent, PluralContentState, PortableObject, Priority, PriorityValue, type ProxyMode, QUALIFIER_DYNAMIC_TYPES_KEY, QUALIFIER_ORDER, QualifiedDynamicLoaderMap, QualifiedDynamicLoaderTree, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, type ReferenceImageNode, type ReferenceLinkNode, type ReferenceNode, type RenderRuleHook, type Rule, type RuleOutput, RuleType, RuleTypeValue, type Rules, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, SelectCond, SelectContent, SelectContentStates, SelectSelector, type SitemapUrlEntry, type StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, type TableNode, type TableSeparatorNode, TaggedMessageToken, type TextNode, TranslationCond, TranslationContent, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnionKeys, type UnorderedListNode, VOID_HTML_ELEMENTS, ValidDotPathsFor, ValueAtKey, WrappedIntl, YamlRecord, YamlValue, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, comparePaths, compile, compileWithOptions, condition as cond, conditionPlugin, createCompiler, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, fallbackPlugin, type file, type fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, formatProxyEnabledMessage, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, generateSitemap, generateSitemapUrl, get, getBasePlugins, getBrowserLocale, getCachedIntl, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getDictionaryCompositeIds, getDictionaryQualifierIds, getDictionaryQualifierTypes, getDictionarySelectorCacheKey, getDomainHostname, getDomainOrigin, getEditedContent, getEditedDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getGender, getHTML, getHTMLTextDir, getInsertion, getInsertionValues, getInternalPath, getInterpolableContent, getIntlayer, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleFromStorage, getLocaleFromStorageClient, getLocaleFromStorageServer, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPlural, getPrefix, getReplacedValuesContent, getRewritePath, getRewriteRules, getSelect, getSplittedContent, getSplittedDictionaryContent, getTranslation, getVariantIds, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, interpolateMessage, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToPortableObjectFormatter, intlayerToVueI18nFormatter, 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, rebuildInterpolableContent, reconstructQualifiedEntry, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderMarkdownAst, renderNothing, resolveDictionaryArgument, resolveMessage, resolveMessageNode, 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 };
@@ -1,7 +1,7 @@
1
1
  import { DeepTransformContent, IInterpreterPluginState, Plugins } from "./getContent/plugins.js";
2
2
  import "./getContent/index.js";
3
3
  import { Dictionary, DictionarySelector, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent } from "@intlayer/types/dictionary";
4
- import { DeclaredLocales, ExtractSelectorLocale } from "@intlayer/types/module_augmentation";
4
+ import { DeclaredLocales, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
5
5
  //#region src/interpreter/getDictionary.d.ts
6
6
  /**
7
7
  * Transforms a dictionary in a single pass, applying each plugin as needed.
@@ -17,7 +17,7 @@ import { DeclaredLocales, ExtractSelectorLocale } from "@intlayer/types/module_a
17
17
  * @param plugins An array of NodeTransformer that define how to transform recognized nodes.
18
18
  * If omitted, we’ll use a default set of plugins.
19
19
  */
20
- declare const getDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends DeclaredLocales | DictionarySelector = DeclaredLocales>(dictionary: T, localeOrSelector?: A, plugins?: Plugins[]) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, IInterpreterPluginState, ExtractSelectorLocale<A>>;
20
+ declare const getDictionary: <const T extends Dictionary | QualifiedDictionaryGroup, const A extends LocalesValues | DictionarySelector = DeclaredLocales>(dictionary: T, localeOrSelector?: A, plugins?: Plugins[]) => DeepTransformContent<ResolveQualifiedDictionaryContent<T, A>, IInterpreterPluginState, ExtractSelectorLocale<A>>;
21
21
  //#endregion
22
22
  export { getDictionary };
23
23
  //# sourceMappingURL=getDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAoCa,sBACL,UAAU,aAAa,gCACvB,UAAU,kBAAkB,qBAAqB,iBAAe,YAE1D,GAAC,mBACM,GAAC,UACV,cACT,qBACD,kCAAkC,GAAG,IACrC,yBACA,sBAAsB"}
1
+ {"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAqCa,sBACL,UAAU,aAAa,gCACvB,UAAU,gBAAgB,qBAAqB,iBAAe,YAExD,GAAC,mBACM,GAAC,UACV,cACT,qBACD,kCAAkC,GAAG,IACrC,yBACA,sBAAsB"}
@@ -1,7 +1,7 @@
1
1
  import { DeepTransformContent, IInterpreterPluginState, Plugins } from "./getContent/plugins.js";
2
2
  import "./getContent/index.js";
3
3
  import { DictionarySelector } from "@intlayer/types/dictionary";
4
- import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, ExtractSelectorLocale } from "@intlayer/types/module_augmentation";
4
+ import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, ExtractSelectorLocale, LocalesValues } from "@intlayer/types/module_augmentation";
5
5
  //#region src/interpreter/getIntlayer.d.ts
6
6
  /**
7
7
  * Picks one dictionary by its key and returns its content for the given
@@ -13,7 +13,7 @@ import { DeclaredLocales, DictionaryKeys, DictionaryRegistryResult, ExtractSelec
13
13
  * - `{ variant: { id: 'prod_abc', userId: '123' } }` — structured variant
14
14
  * - `locale` can be combined with any selector: `{ item: 2, locale: 'fr' }`
15
15
  */
16
- declare const getIntlayer: <const T extends DictionaryKeys, const A extends DeclaredLocales | DictionarySelector = DeclaredLocales>(key: T, localeOrSelector?: A, plugins?: Plugins[]) => DeepTransformContent<DictionaryRegistryResult<T, A>, IInterpreterPluginState, ExtractSelectorLocale<A>>;
16
+ declare const getIntlayer: <const T extends DictionaryKeys, const A extends LocalesValues | DictionarySelector = DeclaredLocales>(key: T, localeOrSelector?: A, plugins?: Plugins[]) => DeepTransformContent<DictionaryRegistryResult<T, A>, IInterpreterPluginState, ExtractSelectorLocale<A>>;
17
17
  //#endregion
18
18
  export { getIntlayer };
19
19
  //# sourceMappingURL=getIntlayer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"mappings":";;;;;;;;;;;;;;;cAkEa,oBACL,UAAU,sBACV,UAAU,kBAAkB,qBAAqB,iBAAe,KAEjE,GAAC,mBACa,GAAC,UACV,cACT,qBACD,yBAAyB,GAAG,IAC5B,yBACA,sBAAsB"}
1
+ {"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"mappings":";;;;;;;;;;;;;;;cAkEa,oBACL,UAAU,sBACV,UAAU,gBAAgB,qBAAqB,iBAAe,KAE/D,GAAC,mBACa,GAAC,UACV,cACT,qBACD,yBAAyB,GAAG,IAC5B,yBACA,sBAAsB"}
@@ -0,0 +1 @@
1
+ export {}
@@ -14,6 +14,7 @@ import { getPathWithoutLocale } from "./getPathWithoutLocale.js";
14
14
  import { localeDetector } from "./localeDetector.js";
15
15
  import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.js";
16
16
  import { localeResolver } from "./localeResolver.js";
17
+ import { ProxyMode, formatProxyEnabledMessage, isProxyStorageLocaleEnabled, resolveProxyMode } from "./proxyMode.js";
17
18
  import { LocalizedPathResult, getCanonicalPath, getInternalPath, getLocalizedPath, getRewritePath, getRewriteRules } from "./rewriteUtils.js";
18
19
  import { validatePrefix } from "./validatePrefix.js";
19
- export { type GenerateSitemapOptions, type GetPrefixOptions, type GetPrefixResult, type LocaleDomainMap, type LocalizedPathResult, type SitemapUrlEntry, comparePaths, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getDomainHostname, getDomainOrigin, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, isLocaleExclusiveOnDomain, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, normalizePath, validatePrefix };
20
+ export { type GenerateSitemapOptions, type GetPrefixOptions, type GetPrefixResult, type LocaleDomainMap, type LocalizedPathResult, type ProxyMode, type SitemapUrlEntry, comparePaths, formatProxyEnabledMessage, generateSitemap, generateSitemapUrl, getBrowserLocale, getCanonicalPath, getDomainHostname, getDomainOrigin, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromDomain, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, isLocaleExclusiveOnDomain, isProxyStorageLocaleEnabled, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, normalizePath, resolveProxyMode, validatePrefix };
@@ -0,0 +1,92 @@
1
+ //#region src/localization/proxyMode.d.ts
2
+ /**
3
+ * Effective mode of the Intlayer locale-routing proxy, resolved from the
4
+ * `routing.enableProxy` configuration option.
5
+ *
6
+ * - `'auto'` — the option was left unset. The proxy is registered, but it stays
7
+ * URL-driven while a development or preview server is serving the app: the
8
+ * stored locale (cookie / header) is not used as a redirect source, so a
9
+ * stale cookie cannot silently pull every navigation to another locale. In
10
+ * production the mode behaves exactly like `'forced'`.
11
+ * - `'forced'` — the option was explicitly set to `true`. Full proxy behaviour
12
+ * in every environment, storage-driven redirects included.
13
+ * - `'disabled'` — the option was explicitly set to `false`. The proxy is not
14
+ * registered at all (Vite) or becomes a pass-through (Next.js).
15
+ */
16
+ type ProxyMode = 'auto' | 'forced' | 'disabled';
17
+ /**
18
+ * Resolves the effective {@link ProxyMode} from the `routing.enableProxy`
19
+ * configuration value.
20
+ *
21
+ * `process.env.INTLAYER_ROUTING_ENABLE_PROXY` is injected at build time by
22
+ * `getConfigEnvVars` and takes precedence, so bundlers can dead-code-eliminate
23
+ * the branches guarded by the resolved mode. The variable is only emitted for
24
+ * the two explicit states; its absence means `'auto'` and defers to the
25
+ * configuration value read at runtime.
26
+ *
27
+ * @param enableProxy - The `routing.enableProxy` value; `undefined` means auto.
28
+ * @returns The resolved proxy mode.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * resolveProxyMode(undefined); // 'auto'
33
+ * resolveProxyMode(true); // 'forced'
34
+ * resolveProxyMode(false); // 'disabled'
35
+ * ```
36
+ */
37
+ declare const resolveProxyMode: (enableProxy?: boolean) => ProxyMode;
38
+ /**
39
+ * Indicates whether the proxy may use the locale held in storage (cookie or
40
+ * header) as a source when deciding which locale a request resolves to.
41
+ *
42
+ * Auto mode suppresses it on development and preview servers only. Every other
43
+ * combination keeps the stored locale active, which notably preserves the
44
+ * behaviour of `createIntlayerProxyHandler` when it is mounted manually in a
45
+ * production Nitro server.
46
+ *
47
+ * Suppressing the read affects redirect *sources* only — the locale is still
48
+ * persisted onto responses, the URL locale prefix still wins over everything,
49
+ * and `Accept-Language` detection still applies as the fallback.
50
+ *
51
+ * @param proxyMode - The resolved proxy mode.
52
+ * @param isDevServer - Whether a development or preview server is serving the app.
53
+ * @returns `true` when the stored locale may drive locale resolution.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * isProxyStorageLocaleEnabled('auto', true); // false — dev server, URL-driven only
58
+ * isProxyStorageLocaleEnabled('auto', false); // true — production
59
+ * isProxyStorageLocaleEnabled('forced', true); // true — explicitly opted in
60
+ * ```
61
+ */
62
+ declare const isProxyStorageLocaleEnabled: (proxyMode: ProxyMode, isDevServer: boolean) => boolean;
63
+ /**
64
+ * Builds the line announcing that a server has mounted the locale-routing
65
+ * proxy.
66
+ *
67
+ * Shared by every integration (Vite plugin, Next.js middleware) so the reported
68
+ * state cannot drift between them: when the stored locale is suppressed the
69
+ * message says so, which would otherwise look like a broken proxy to anyone
70
+ * testing locale switching with a cookie already set.
71
+ *
72
+ * Takes the suppression flag rather than the {@link ProxyMode} on purpose. Auto
73
+ * mode only suppresses storage on a dev server, so a mode-based signature would
74
+ * let a production caller — such as the Nitro production handler — announce a
75
+ * suppression that is not actually in effect.
76
+ *
77
+ * @param isStorageLocaleSuppressed - Whether the stored locale is barred from
78
+ * driving redirects, i.e. the negation of {@link isProxyStorageLocaleEnabled}.
79
+ * @returns An ANSI-coloured, ready-to-log message.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * formatProxyEnabledMessage(true);
84
+ * // Intlayer proxy enabled - storage redirection disabled for dev purpose
85
+ * formatProxyEnabledMessage(false);
86
+ * // Intlayer proxy enabled
87
+ * ```
88
+ */
89
+ declare const formatProxyEnabledMessage: (isStorageLocaleSuppressed: boolean) => string;
90
+ //#endregion
91
+ export { ProxyMode, formatProxyEnabledMessage, isProxyStorageLocaleEnabled, resolveProxyMode };
92
+ //# sourceMappingURL=proxyMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxyMode.d.ts","names":[],"sources":["../../../src/localization/proxyMode.ts"],"mappings":";;;;;;;;;;;;;;;KAiBY;;;;;;;;;;;;;;;;;;;;;cAsBC,mBAAgB,0BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;cAkC5C,8BAA2B,WAC3B,WAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BT,4BAAyB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/core",
3
- "version": "9.1.2",
3
+ "version": "9.2.0",
4
4
  "private": false,
5
5
  "description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
6
6
  "keywords": [
@@ -172,11 +172,11 @@
172
172
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
173
173
  },
174
174
  "dependencies": {
175
- "@intlayer/api": "9.1.2",
176
- "@intlayer/config": "9.1.2",
177
- "@intlayer/dictionaries-entry": "9.1.2",
178
- "@intlayer/types": "9.1.2",
179
- "@intlayer/unmerged-dictionaries-entry": "9.1.2",
175
+ "@intlayer/api": "9.2.0",
176
+ "@intlayer/config": "9.2.0",
177
+ "@intlayer/dictionaries-entry": "9.2.0",
178
+ "@intlayer/types": "9.2.0",
179
+ "@intlayer/unmerged-dictionaries-entry": "9.2.0",
180
180
  "defu": "6.1.7"
181
181
  },
182
182
  "devDependencies": {