@intlayer/core 8.4.0-canary.0 → 8.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{_virtual/_rolldown/runtime.cjs → chunk-Bmb41Sf3.cjs} +1 -1
- package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -1
- package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -1
- package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -1
- package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +1 -1
- package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -1
- package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -1
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -1
- package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -1
- package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
- package/dist/cjs/formatters/compact.cjs +1 -1
- package/dist/cjs/formatters/compact.cjs.map +1 -1
- package/dist/cjs/formatters/currency.cjs +1 -1
- package/dist/cjs/formatters/currency.cjs.map +1 -1
- package/dist/cjs/formatters/date.cjs +1 -1
- package/dist/cjs/formatters/date.cjs.map +1 -1
- package/dist/cjs/formatters/list.cjs +1 -1
- package/dist/cjs/formatters/list.cjs.map +1 -1
- package/dist/cjs/formatters/number.cjs +1 -1
- package/dist/cjs/formatters/number.cjs.map +1 -1
- package/dist/cjs/formatters/percentage.cjs +1 -1
- package/dist/cjs/formatters/percentage.cjs.map +1 -1
- package/dist/cjs/formatters/relativeTime.cjs +1 -1
- package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
- package/dist/cjs/formatters/units.cjs +1 -1
- package/dist/cjs/formatters/units.cjs.map +1 -1
- package/dist/cjs/getContent-DrqM8pqO.cjs +2 -0
- package/dist/cjs/getContent-DrqM8pqO.cjs.map +1 -0
- package/dist/cjs/getStorageAttributes.cjs +1 -1
- package/dist/cjs/getStorageAttributes.cjs.map +1 -1
- package/dist/cjs/html-CZ1N-VL0.cjs +2 -0
- package/dist/cjs/html-CZ1N-VL0.cjs.map +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -1
- package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/getContent.cjs +1 -2
- package/dist/cjs/interpreter/getContent/index.cjs +1 -1
- package/dist/cjs/interpreter/getContent/plugins.cjs +1 -2
- package/dist/cjs/interpreter/getDictionary.cjs +1 -2
- package/dist/cjs/interpreter/getIntlayer.cjs +1 -2
- package/dist/cjs/interpreter/getNesting.cjs +1 -2
- package/dist/cjs/interpreter/index.cjs +1 -1
- package/dist/cjs/localization/getBrowserLocale.cjs +1 -1
- package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
- package/dist/cjs/localization/getHTMLTextDir.cjs +1 -1
- package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
- package/dist/cjs/localization/getLocale.cjs +1 -1
- package/dist/cjs/localization/getLocale.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleFromPath.cjs +1 -1
- package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
- package/dist/cjs/localization/getLocalizedUrl.cjs +1 -1
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
- package/dist/cjs/localization/getMultilingualUrls.cjs +1 -1
- package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
- package/dist/cjs/localization/getPathWithoutLocale.cjs +1 -1
- package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
- package/dist/cjs/localization/getPrefix.cjs +1 -1
- package/dist/cjs/localization/getPrefix.cjs.map +1 -1
- package/dist/cjs/localization/localeMapper.cjs +1 -1
- package/dist/cjs/localization/localeMapper.cjs.map +1 -1
- package/dist/cjs/localization/localeResolver.cjs +1 -1
- package/dist/cjs/localization/localeResolver.cjs.map +1 -1
- package/dist/cjs/localization/validatePrefix.cjs +1 -1
- package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
- package/dist/cjs/messageFormat/ICU.cjs +1 -1
- package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
- package/dist/cjs/messageFormat/i18next.cjs +1 -1
- package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
- package/dist/cjs/messageFormat/vue-i18n.cjs +1 -1
- package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
- package/dist/cjs/transpiler/condition/condition.cjs +1 -1
- package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
- package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -1
- package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
- package/dist/cjs/transpiler/file/file.cjs +1 -1
- package/dist/cjs/transpiler/file/file.cjs.map +1 -1
- package/dist/cjs/transpiler/gender/gender.cjs +1 -1
- package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +1 -2
- package/dist/cjs/transpiler/html/html.cjs +1 -2
- package/dist/cjs/transpiler/html/index.cjs +1 -1
- package/dist/cjs/transpiler/index.cjs +1 -1
- package/dist/cjs/transpiler/insertion/insertion.cjs +1 -1
- package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/markdown.cjs +1 -1
- package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
- package/dist/cjs/transpiler/nesting/nesting.cjs +1 -1
- package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
- package/dist/cjs/transpiler/translation/translation.cjs +1 -1
- package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
- package/dist/cjs/utils/intl.cjs +1 -1
- package/dist/cjs/utils/intl.cjs.map +1 -1
- package/dist/cjs/utils/localeStorage.cjs +1 -1
- package/dist/cjs/utils/localeStorage.cjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +1 -1
- package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
- package/dist/esm/formatters/list.mjs.map +1 -1
- package/dist/esm/getContent-DKqtIZGL.mjs +2 -0
- package/dist/esm/getContent-DKqtIZGL.mjs.map +1 -0
- package/dist/esm/html-3bo80xzx.mjs +2 -0
- package/dist/esm/html-3bo80xzx.mjs.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/interpreter/getContent/getContent.mjs +1 -2
- package/dist/esm/interpreter/getContent/index.mjs +1 -1
- package/dist/esm/interpreter/getContent/plugins.mjs +1 -2
- package/dist/esm/interpreter/getDictionary.mjs +1 -2
- package/dist/esm/interpreter/getIntlayer.mjs +1 -2
- package/dist/esm/interpreter/getNesting.mjs +1 -2
- package/dist/esm/interpreter/index.mjs +1 -1
- package/dist/esm/localization/getBrowserLocale.mjs +1 -1
- package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
- package/dist/esm/localization/getHTMLTextDir.mjs +1 -1
- package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
- package/dist/esm/localization/localeMapper.mjs.map +1 -1
- package/dist/esm/messageFormat/ICU.mjs +1 -1
- package/dist/esm/messageFormat/ICU.mjs.map +1 -1
- package/dist/esm/messageFormat/i18next.mjs +1 -1
- package/dist/esm/messageFormat/i18next.mjs.map +1 -1
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -2
- package/dist/esm/transpiler/html/html.mjs +1 -2
- package/dist/esm/transpiler/html/index.mjs +1 -1
- package/dist/esm/transpiler/index.mjs +1 -1
- package/dist/esm/transpiler/markdown/markdown.mjs +1 -1
- package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
- package/dist/esm/utils/intl.mjs +1 -1
- package/dist/esm/utils/intl.mjs.map +1 -1
- package/dist/types/ICU-tA3ZHN5U.d.ts +11 -0
- package/dist/types/ICU-tA3ZHN5U.d.ts.map +1 -0
- package/dist/types/checkIsURLAbsolute-CTf3JFU6.d.ts +5 -0
- package/dist/types/checkIsURLAbsolute-CTf3JFU6.d.ts.map +1 -0
- package/dist/types/compact-IHXcM4pT.d.ts +20 -0
- package/dist/types/compact-IHXcM4pT.d.ts.map +1 -0
- package/dist/types/compiler-DFiAsUdH.d.ts +9 -0
- package/dist/types/compiler-DFiAsUdH.d.ts.map +1 -0
- package/dist/types/condition-BDUtoh_1.d.ts +28 -0
- package/dist/types/condition-BDUtoh_1.d.ts.map +1 -0
- package/dist/types/constants-CI_D82B1.d.ts +177 -0
- package/dist/types/constants-CI_D82B1.d.ts.map +1 -0
- package/dist/types/currency-PbMCnHep.d.ts +20 -0
- package/dist/types/currency-PbMCnHep.d.ts.map +1 -0
- package/dist/types/date-C-PI8KqU.d.ts +20 -0
- package/dist/types/date-C-PI8KqU.d.ts.map +1 -0
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +2 -50
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +2 -42
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +2 -34
- package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts +2 -18
- package/dist/types/deepTransformPlugins/getMaskContent.d.ts +2 -10
- package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts +2 -19
- package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts +2 -32
- package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts +2 -8
- package/dist/types/deepTransformPlugins/getSplittedContent.d.ts +2 -43
- package/dist/types/deepTransformPlugins/index.d.ts +10 -10
- package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts +2 -25
- package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts +2 -8
- package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +2 -9
- package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +2 -9
- package/dist/types/dictionaryManipulator/getEmptyNode.d.ts +2 -7
- package/dist/types/dictionaryManipulator/getNodeChildren.d.ts +2 -7
- package/dist/types/dictionaryManipulator/getNodeType.d.ts +2 -8
- package/dist/types/dictionaryManipulator/index.d.ts +12 -12
- package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts +2 -7
- package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts +2 -9
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +2 -15
- package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts +2 -8
- package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts +2 -8
- package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts +2 -7
- package/dist/types/editDictionaryByKeyPath-BYIHcsyf.d.ts +8 -0
- package/dist/types/editDictionaryByKeyPath-BYIHcsyf.d.ts.map +1 -0
- package/dist/types/enumeration-CtuvB5Zz.d.ts +40 -0
- package/dist/types/enumeration-CtuvB5Zz.d.ts.map +1 -0
- package/dist/types/file-C3q8xvQb.d.ts +28 -0
- package/dist/types/file-C3q8xvQb.d.ts.map +1 -0
- package/dist/types/formatters/compact.d.ts +2 -20
- package/dist/types/formatters/currency.d.ts +2 -20
- package/dist/types/formatters/date.d.ts +2 -20
- package/dist/types/formatters/index.d.ts +10 -10
- package/dist/types/formatters/list.d.ts +2 -24
- package/dist/types/formatters/number.d.ts +2 -16
- package/dist/types/formatters/percentage.d.ts +2 -16
- package/dist/types/formatters/relativeTime.d.ts +2 -11
- package/dist/types/formatters/units.d.ts +2 -16
- package/dist/types/gender-Dd39Ijmf.d.ts +29 -0
- package/dist/types/gender-Dd39Ijmf.d.ts.map +1 -0
- package/dist/types/getBrowserLocale-RD_Mwv1t.d.ts +35 -0
- package/dist/types/getBrowserLocale-RD_Mwv1t.d.ts.map +1 -0
- package/dist/types/getContentNodeByKeyPath-B0Tdi5mj.d.ts +9 -0
- package/dist/types/getContentNodeByKeyPath-B0Tdi5mj.d.ts.map +1 -0
- package/dist/types/getCookie-DPOvVv_h.d.ts +11 -0
- package/dist/types/getCookie-DPOvVv_h.d.ts.map +1 -0
- package/dist/types/getDefaultNode-DQNsje2D.d.ts +9 -0
- package/dist/types/getDefaultNode-DQNsje2D.d.ts.map +1 -0
- package/dist/types/getEmptyNode-DW27TTBj.d.ts +7 -0
- package/dist/types/getEmptyNode-DW27TTBj.d.ts.map +1 -0
- package/dist/types/getFilterMissingTranslationsContent-CDNQqoy1.d.ts +50 -0
- package/dist/types/getFilterMissingTranslationsContent-CDNQqoy1.d.ts.map +1 -0
- package/dist/types/getFilterTranslationsOnlyContent-D2YgBkHn.d.ts +42 -0
- package/dist/types/getFilterTranslationsOnlyContent-D2YgBkHn.d.ts.map +1 -0
- package/dist/types/getFilteredLocalesContent-D0GP-uEg.d.ts +34 -0
- package/dist/types/getFilteredLocalesContent-D0GP-uEg.d.ts.map +1 -0
- package/dist/types/getHTML-CP6OXtdo.d.ts +32 -0
- package/dist/types/getHTML-CP6OXtdo.d.ts.map +1 -0
- package/dist/types/getHTMLTextDir-4Zh8J3x7.d.ts +21 -0
- package/dist/types/getHTMLTextDir-4Zh8J3x7.d.ts.map +1 -0
- package/dist/types/getInsertionValues-Cu9IdbuE.d.ts +5 -0
- package/dist/types/getInsertionValues-Cu9IdbuE.d.ts.map +1 -0
- package/dist/types/getLocale-B9dECUM_.d.ts +11 -0
- package/dist/types/getLocale-B9dECUM_.d.ts.map +1 -0
- package/dist/types/getLocaleFromPath-621W32QA.d.ts +26 -0
- package/dist/types/getLocaleFromPath-621W32QA.d.ts.map +1 -0
- package/dist/types/getLocaleLang-Bcan1gS4.d.ts +20 -0
- package/dist/types/getLocaleLang-Bcan1gS4.d.ts.map +1 -0
- package/dist/types/getLocaleName-CfRAD9Hc.d.ts +7 -0
- package/dist/types/getLocaleName-CfRAD9Hc.d.ts.map +1 -0
- package/dist/types/getLocalizedContent-DOncZd-0.d.ts +18 -0
- package/dist/types/getLocalizedContent-DOncZd-0.d.ts.map +1 -0
- package/dist/types/getLocalizedUrl-BbqeA3-W.d.ts +49 -0
- package/dist/types/getLocalizedUrl-BbqeA3-W.d.ts.map +1 -0
- package/dist/types/getMarkdownMetadata-Bf1S1NQ0.d.ts +5 -0
- package/dist/types/getMarkdownMetadata-Bf1S1NQ0.d.ts.map +1 -0
- package/dist/types/getMaskContent-BwLFqp7v.d.ts +10 -0
- package/dist/types/getMaskContent-BwLFqp7v.d.ts.map +1 -0
- package/dist/types/getMissingLocalesContent-BYffYcdx.d.ts +19 -0
- package/dist/types/getMissingLocalesContent-BYffYcdx.d.ts.map +1 -0
- package/dist/types/getMultilingualDictionary-DO3i1MFs.d.ts +32 -0
- package/dist/types/getMultilingualDictionary-DO3i1MFs.d.ts.map +1 -0
- package/dist/types/getMultilingualUrls-CUxYYfA4.d.ts +47 -0
- package/dist/types/getMultilingualUrls-CUxYYfA4.d.ts.map +1 -0
- package/dist/types/getNodeChildren-OT7Liqke.d.ts +7 -0
- package/dist/types/getNodeChildren-OT7Liqke.d.ts.map +1 -0
- package/dist/types/getNodeType-Cp765I26.d.ts +8 -0
- package/dist/types/getNodeType-Cp765I26.d.ts.map +1 -0
- package/dist/types/getPathWithoutLocale-B_aIR7O0.d.ts +31 -0
- package/dist/types/getPathWithoutLocale-B_aIR7O0.d.ts.map +1 -0
- package/dist/types/getPrefix-X9XKkrZD.d.ts +68 -0
- package/dist/types/getPrefix-X9XKkrZD.d.ts.map +1 -0
- package/dist/types/getReplacedValuesContent-BvL25pdt.d.ts +8 -0
- package/dist/types/getReplacedValuesContent-BvL25pdt.d.ts.map +1 -0
- package/dist/types/getSplittedContent-YD4JDMfB.d.ts +43 -0
- package/dist/types/getSplittedContent-YD4JDMfB.d.ts.map +1 -0
- package/dist/types/getStorageAttributes-CIO2xWqQ.d.ts +29 -0
- package/dist/types/getStorageAttributes-CIO2xWqQ.d.ts.map +1 -0
- package/dist/types/getStorageAttributes.d.ts +2 -29
- package/dist/types/getTranslation-BG2Wg-af.d.ts +30 -0
- package/dist/types/getTranslation-BG2Wg-af.d.ts.map +1 -0
- package/dist/types/html-Dn6KrpJ3.d.ts +25 -0
- package/dist/types/html-Dn6KrpJ3.d.ts.map +1 -0
- package/dist/types/htmlTags-YxTtVUx6.d.ts +115 -0
- package/dist/types/htmlTags-YxTtVUx6.d.ts.map +1 -0
- package/dist/types/i18next-qY0AixrB.d.ts +9 -0
- package/dist/types/i18next-qY0AixrB.d.ts.map +1 -0
- package/dist/types/index-1CTsSKEn.d.ts +1 -0
- package/dist/types/index-B8xF2zGo.d.ts +1 -0
- package/dist/types/index-BcsOTSQF.d.ts +1 -0
- package/dist/types/index-BnEeKNKW.d.ts +322 -0
- package/dist/types/index-BnEeKNKW.d.ts.map +1 -0
- package/dist/types/index-Cf8zm5QQ.d.ts +1 -0
- package/dist/types/index-CfvILin8.d.ts +1 -0
- package/dist/types/index-DK_kKFOF.d.ts +1 -0
- package/dist/types/index-DeJa0xZp.d.ts +1 -0
- package/dist/types/index-Vlqtiwjx.d.ts +1 -0
- package/dist/types/index.d.ts +80 -88
- package/dist/types/insertContentInDictionary-DZ3UzG4K.d.ts +25 -0
- package/dist/types/insertContentInDictionary-DZ3UzG4K.d.ts.map +1 -0
- package/dist/types/insertion-M5fwK-29.d.ts +23 -0
- package/dist/types/insertion-M5fwK-29.d.ts.map +1 -0
- package/dist/types/interpreter/getCondition.d.ts +2 -22
- package/dist/types/interpreter/getContent/deepTransform.d.ts +2 -12
- package/dist/types/interpreter/getContent/getContent.d.ts +2 -16
- package/dist/types/interpreter/getContent/index.d.ts +1 -3
- package/dist/types/interpreter/getContent/plugins.d.ts +2 -151
- package/dist/types/interpreter/getDictionary.d.ts +2 -17
- package/dist/types/interpreter/getEnumeration.d.ts +2 -58
- package/dist/types/interpreter/getGender.d.ts +1 -1
- package/dist/types/interpreter/getGender.d.ts.map +1 -1
- package/dist/types/interpreter/getHTML.d.ts +2 -32
- package/dist/types/interpreter/getInsertion.d.ts +1 -1
- package/dist/types/interpreter/getInsertion.d.ts.map +1 -1
- package/dist/types/interpreter/getIntlayer.d.ts +2 -8
- package/dist/types/interpreter/getNesting.d.ts +2 -27
- package/dist/types/interpreter/getTranslation.d.ts +2 -30
- package/dist/types/interpreter/index.d.ts +4 -11
- package/dist/types/interpreter/splitAndJoinInsertion.d.ts +2 -25
- package/dist/types/intl-B2Ap8I5x.d.ts +33 -0
- package/dist/types/intl-B2Ap8I5x.d.ts.map +1 -0
- package/dist/types/isSameKeyPath-CkH8NdJh.d.ts +7 -0
- package/dist/types/isSameKeyPath-CkH8NdJh.d.ts.map +1 -0
- package/dist/types/isValidReactElement-BsoJ01oP.d.ts +12 -0
- package/dist/types/isValidReactElement-BsoJ01oP.d.ts.map +1 -0
- package/dist/types/list-BdjJM2Gx.d.ts +30 -0
- package/dist/types/list-BdjJM2Gx.d.ts.map +1 -0
- package/dist/types/localeDetector-BWNCQRiZ.d.ts +18 -0
- package/dist/types/localeDetector-BWNCQRiZ.d.ts.map +1 -0
- package/dist/types/localeMapper-DoAnasqf.d.ts +92 -0
- package/dist/types/localeMapper-DoAnasqf.d.ts.map +1 -0
- package/dist/types/localeResolver-bb7AWQNX.d.ts +12 -0
- package/dist/types/localeResolver-bb7AWQNX.d.ts.map +1 -0
- package/dist/types/localeStorage-CZHwY0u3.d.ts +108 -0
- package/dist/types/localeStorage-CZHwY0u3.d.ts.map +1 -0
- package/dist/types/localization/getBrowserLocale.d.ts +2 -35
- package/dist/types/localization/getHTMLTextDir.d.ts +2 -21
- package/dist/types/localization/getLocale.d.ts +2 -11
- package/dist/types/localization/getLocaleFromPath.d.ts +2 -26
- package/dist/types/localization/getLocaleLang.d.ts +2 -20
- package/dist/types/localization/getLocaleName.d.ts +2 -7
- package/dist/types/localization/getLocalizedUrl.d.ts +2 -49
- package/dist/types/localization/getMultilingualUrls.d.ts +2 -47
- package/dist/types/localization/getPathWithoutLocale.d.ts +2 -31
- package/dist/types/localization/getPrefix.d.ts +2 -68
- package/dist/types/localization/index.d.ts +16 -16
- package/dist/types/localization/localeDetector.d.ts +2 -18
- package/dist/types/localization/localeMapper.d.ts +2 -92
- package/dist/types/localization/localeResolver.d.ts +2 -12
- package/dist/types/localization/rewriteUtils.d.ts +2 -34
- package/dist/types/localization/validatePrefix.d.ts +2 -38
- package/dist/types/markdown/compiler.d.ts +2 -9
- package/dist/types/markdown/constants.d.ts +2 -177
- package/dist/types/markdown/index.d.ts +10 -10
- package/dist/types/markdown/parser.d.ts +2 -16
- package/dist/types/markdown/renderer.d.ts +2 -22
- package/dist/types/markdown/types.d.ts +2 -333
- package/dist/types/markdown/utils.d.ts +2 -140
- package/dist/types/markdown-MzfikrI1.d.ts +26 -0
- package/dist/types/markdown-MzfikrI1.d.ts.map +1 -0
- package/dist/types/mergeDictionaries-D6WUMQN5.d.ts +7 -0
- package/dist/types/mergeDictionaries-D6WUMQN5.d.ts.map +1 -0
- package/dist/types/messageFormat/ICU.d.ts +2 -11
- package/dist/types/messageFormat/i18next.d.ts +2 -9
- package/dist/types/messageFormat/index.d.ts +3 -3
- package/dist/types/messageFormat/vue-i18n.d.ts +2 -9
- package/dist/types/normalizeDictionary-coviIGTW.d.ts +9 -0
- package/dist/types/normalizeDictionary-coviIGTW.d.ts.map +1 -0
- package/dist/types/number-C8izkCmU.d.ts +16 -0
- package/dist/types/number-C8izkCmU.d.ts.map +1 -0
- package/dist/types/orderDictionaries-SSCMY6qG.d.ts +15 -0
- package/dist/types/orderDictionaries-SSCMY6qG.d.ts.map +1 -0
- package/dist/types/parseYaml-D5gxutvA.d.ts +5 -0
- package/dist/types/parseYaml-D5gxutvA.d.ts.map +1 -0
- package/dist/types/parser-BVwR6Tjw.d.ts +16 -0
- package/dist/types/parser-BVwR6Tjw.d.ts.map +1 -0
- package/dist/types/percentage-BqsvW0Zw.d.ts +16 -0
- package/dist/types/percentage-BqsvW0Zw.d.ts.map +1 -0
- package/dist/types/relativeTime-mJaYEq7H.d.ts +11 -0
- package/dist/types/relativeTime-mJaYEq7H.d.ts.map +1 -0
- package/dist/types/removeContentNodeByKeyPath-CotCOOsD.d.ts +8 -0
- package/dist/types/removeContentNodeByKeyPath-CotCOOsD.d.ts.map +1 -0
- package/dist/types/renameContentNodeByKeyPath-BuyH5gOr.d.ts +8 -0
- package/dist/types/renameContentNodeByKeyPath-BuyH5gOr.d.ts.map +1 -0
- package/dist/types/renderer-C06x2Orf.d.ts +22 -0
- package/dist/types/renderer-C06x2Orf.d.ts.map +1 -0
- package/dist/types/rewriteUtils-Bd82NiGR.d.ts +34 -0
- package/dist/types/rewriteUtils-Bd82NiGR.d.ts.map +1 -0
- package/dist/types/splitAndJoinInsertion-bkuLa7o2.d.ts +25 -0
- package/dist/types/splitAndJoinInsertion-bkuLa7o2.d.ts.map +1 -0
- package/dist/types/translation-CiC-Avxc.d.ts +33 -0
- package/dist/types/translation-CiC-Avxc.d.ts.map +1 -0
- package/dist/types/transpiler/condition/condition.d.ts +2 -28
- package/dist/types/transpiler/condition/index.d.ts +1 -1
- package/dist/types/transpiler/enumeration/enumeration.d.ts +2 -40
- package/dist/types/transpiler/enumeration/index.d.ts +1 -1
- package/dist/types/transpiler/file/file.d.ts +2 -28
- package/dist/types/transpiler/file/fileBrowser.d.ts +1 -1
- package/dist/types/transpiler/file/index.d.ts +1 -1
- package/dist/types/transpiler/gender/gender.d.ts +2 -29
- package/dist/types/transpiler/gender/index.d.ts +1 -1
- package/dist/types/transpiler/html/html.d.ts +2 -25
- package/dist/types/transpiler/html/htmlTags.d.ts +2 -115
- package/dist/types/transpiler/html/index.d.ts +3 -3
- package/dist/types/transpiler/html/validateHTML.d.ts +2 -21
- package/dist/types/transpiler/index.d.ts +15 -15
- package/dist/types/transpiler/insertion/getInsertionValues.d.ts +2 -5
- package/dist/types/transpiler/insertion/index.d.ts +2 -2
- package/dist/types/transpiler/insertion/insertion.d.ts +2 -23
- package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts +2 -5
- package/dist/types/transpiler/markdown/index.d.ts +4 -4
- package/dist/types/transpiler/markdown/markdown.d.ts +2 -26
- package/dist/types/transpiler/markdown/validateMarkdown.d.ts +3 -18
- package/dist/types/transpiler/nesting/index.d.ts +1 -1
- package/dist/types/transpiler/nesting/nesting.d.ts +2 -49
- package/dist/types/transpiler/translation/index.d.ts +1 -1
- package/dist/types/transpiler/translation/translation.d.ts +2 -33
- package/dist/types/types-C2Om0aEM.d.ts +333 -0
- package/dist/types/types-C2Om0aEM.d.ts.map +1 -0
- package/dist/types/units-CouGqa8j.d.ts +16 -0
- package/dist/types/units-CouGqa8j.d.ts.map +1 -0
- package/dist/types/updateNodeChildren-B5Tu1UBZ.d.ts +7 -0
- package/dist/types/updateNodeChildren-B5Tu1UBZ.d.ts.map +1 -0
- package/dist/types/utils/checkIsURLAbsolute.d.ts +2 -5
- package/dist/types/utils/getCookie.d.ts +2 -11
- package/dist/types/utils/index.d.ts +8 -8
- package/dist/types/utils/intl.d.ts +2 -33
- package/dist/types/utils/isSameKeyPath.d.ts +2 -7
- package/dist/types/utils/isValidReactElement.d.ts +2 -12
- package/dist/types/utils/localeStorage.d.ts +2 -108
- package/dist/types/utils/parseYaml.d.ts +2 -5
- package/dist/types/utils-Dcmgh_80.d.ts +140 -0
- package/dist/types/utils-Dcmgh_80.d.ts.map +1 -0
- package/dist/types/validateHTML-U7UKTtFd.d.ts +21 -0
- package/dist/types/validateHTML-U7UKTtFd.d.ts.map +1 -0
- package/dist/types/validateMarkdown-BUaTDDIu.d.ts +18 -0
- package/dist/types/validateMarkdown-BUaTDDIu.d.ts.map +1 -0
- package/dist/types/validatePrefix-Dtmg7QLq.d.ts +38 -0
- package/dist/types/validatePrefix-Dtmg7QLq.d.ts.map +1 -0
- package/dist/types/vue-i18n-JtUB7N_m.d.ts +9 -0
- package/dist/types/vue-i18n-JtUB7N_m.d.ts.map +1 -0
- package/package.json +6 -6
- package/dist/cjs/interpreter/getContent/getContent.cjs.map +0 -1
- package/dist/cjs/interpreter/getContent/plugins.cjs.map +0 -1
- package/dist/cjs/interpreter/getDictionary.cjs.map +0 -1
- package/dist/cjs/interpreter/getIntlayer.cjs.map +0 -1
- package/dist/cjs/interpreter/getNesting.cjs.map +0 -1
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +0 -1
- package/dist/cjs/transpiler/html/html.cjs.map +0 -1
- package/dist/esm/interpreter/getContent/getContent.mjs.map +0 -1
- package/dist/esm/interpreter/getContent/plugins.mjs.map +0 -1
- package/dist/esm/interpreter/getDictionary.mjs.map +0 -1
- package/dist/esm/interpreter/getIntlayer.mjs.map +0 -1
- package/dist/esm/interpreter/getNesting.mjs.map +0 -1
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +0 -1
- package/dist/esm/transpiler/html/html.mjs.map +0 -1
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +0 -1
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +0 -1
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +0 -1
- package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +0 -1
- package/dist/types/deepTransformPlugins/getMaskContent.d.ts.map +0 -1
- package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts.map +0 -1
- package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts.map +0 -1
- package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts.map +0 -1
- package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +0 -1
- package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +0 -1
- package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +0 -1
- package/dist/types/formatters/compact.d.ts.map +0 -1
- package/dist/types/formatters/currency.d.ts.map +0 -1
- package/dist/types/formatters/date.d.ts.map +0 -1
- package/dist/types/formatters/list.d.ts.map +0 -1
- package/dist/types/formatters/number.d.ts.map +0 -1
- package/dist/types/formatters/percentage.d.ts.map +0 -1
- package/dist/types/formatters/relativeTime.d.ts.map +0 -1
- package/dist/types/formatters/units.d.ts.map +0 -1
- package/dist/types/getStorageAttributes.d.ts.map +0 -1
- package/dist/types/interpreter/getCondition.d.ts.map +0 -1
- package/dist/types/interpreter/getContent/deepTransform.d.ts.map +0 -1
- package/dist/types/interpreter/getContent/getContent.d.ts.map +0 -1
- package/dist/types/interpreter/getContent/plugins.d.ts.map +0 -1
- package/dist/types/interpreter/getDictionary.d.ts.map +0 -1
- package/dist/types/interpreter/getEnumeration.d.ts.map +0 -1
- package/dist/types/interpreter/getHTML.d.ts.map +0 -1
- package/dist/types/interpreter/getIntlayer.d.ts.map +0 -1
- package/dist/types/interpreter/getNesting.d.ts.map +0 -1
- package/dist/types/interpreter/getTranslation.d.ts.map +0 -1
- package/dist/types/interpreter/splitAndJoinInsertion.d.ts.map +0 -1
- package/dist/types/localization/getBrowserLocale.d.ts.map +0 -1
- package/dist/types/localization/getHTMLTextDir.d.ts.map +0 -1
- package/dist/types/localization/getLocale.d.ts.map +0 -1
- package/dist/types/localization/getLocaleFromPath.d.ts.map +0 -1
- package/dist/types/localization/getLocaleLang.d.ts.map +0 -1
- package/dist/types/localization/getLocaleName.d.ts.map +0 -1
- package/dist/types/localization/getLocalizedUrl.d.ts.map +0 -1
- package/dist/types/localization/getMultilingualUrls.d.ts.map +0 -1
- package/dist/types/localization/getPathWithoutLocale.d.ts.map +0 -1
- package/dist/types/localization/getPrefix.d.ts.map +0 -1
- package/dist/types/localization/localeDetector.d.ts.map +0 -1
- package/dist/types/localization/localeMapper.d.ts.map +0 -1
- package/dist/types/localization/localeResolver.d.ts.map +0 -1
- package/dist/types/localization/rewriteUtils.d.ts.map +0 -1
- package/dist/types/localization/validatePrefix.d.ts.map +0 -1
- package/dist/types/markdown/compiler.d.ts.map +0 -1
- package/dist/types/markdown/constants.d.ts.map +0 -1
- package/dist/types/markdown/parser.d.ts.map +0 -1
- package/dist/types/markdown/renderer.d.ts.map +0 -1
- package/dist/types/markdown/types.d.ts.map +0 -1
- package/dist/types/markdown/utils.d.ts.map +0 -1
- package/dist/types/messageFormat/ICU.d.ts.map +0 -1
- package/dist/types/messageFormat/i18next.d.ts.map +0 -1
- package/dist/types/messageFormat/vue-i18n.d.ts.map +0 -1
- package/dist/types/transpiler/condition/condition.d.ts.map +0 -1
- package/dist/types/transpiler/enumeration/enumeration.d.ts.map +0 -1
- package/dist/types/transpiler/file/file.d.ts.map +0 -1
- package/dist/types/transpiler/gender/gender.d.ts.map +0 -1
- package/dist/types/transpiler/html/html.d.ts.map +0 -1
- package/dist/types/transpiler/html/htmlTags.d.ts.map +0 -1
- package/dist/types/transpiler/html/validateHTML.d.ts.map +0 -1
- package/dist/types/transpiler/insertion/getInsertionValues.d.ts.map +0 -1
- package/dist/types/transpiler/insertion/insertion.d.ts.map +0 -1
- package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts.map +0 -1
- package/dist/types/transpiler/markdown/markdown.d.ts.map +0 -1
- package/dist/types/transpiler/markdown/validateMarkdown.d.ts.map +0 -1
- package/dist/types/transpiler/nesting/nesting.d.ts.map +0 -1
- package/dist/types/transpiler/translation/translation.d.ts.map +0 -1
- package/dist/types/utils/checkIsURLAbsolute.d.ts.map +0 -1
- package/dist/types/utils/getCookie.d.ts.map +0 -1
- package/dist/types/utils/intl.d.ts.map +0 -1
- package/dist/types/utils/isSameKeyPath.d.ts.map +0 -1
- package/dist/types/utils/isValidReactElement.d.ts.map +0 -1
- package/dist/types/utils/localeStorage.d.ts.map +0 -1
- package/dist/types/utils/parseYaml.d.ts.map +0 -1
package/dist/cjs/utils/intl.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`})
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/types/locales`);const t=(t,n)=>{let r=t?String(t):e.ENGLISH;return n?`${r}|${JSON.stringify(n)}`:r},n=e=>{let n=new Map;function r(r,i){let a=r,o=i;typeof r==`object`&&!Array.isArray(r)&&r!==null&&(o=r,a=r.locale),e.name===`DisplayNames`&&Intl?.DisplayNames;let s=t(a,o),c=n.get(s);if(c)return c;if(c=new e(a,o),n.size>=50){let e=n.keys().next().value;e&&n.delete(e)}return n.set(s,c),c}return r.prototype=e.prototype,r},r=()=>{let e=new Map;return new Proxy(Intl,{get:(t,r,i)=>{if(e.has(r))return e.get(r);let a=Reflect.get(t,r,i);if(typeof a==`function`&&typeof r==`string`&&/^[A-Z]/.test(r)){let t=n(a);return e.set(r,t),t}return a}})},i=r(),a=e=>new Proxy(i,{get:(t,n)=>{let r=Reflect.get(t,n);return typeof r==`function`&&typeof n==`string`&&/^[A-Z]/.test(n)?new Proxy(r,{construct:(t,n)=>{let[r,i]=n;return typeof r==`object`&&!Array.isArray(r)&&r!==null?(i=r,r=i.locale??e):r===void 0&&(r=e),new t(r,i)},get:(e,t)=>Reflect.get(e,t)}):r}});exports.CachedIntl=i,exports.Intl=i,exports.bindIntl=a,exports.createCachedIntl=r;
|
|
2
2
|
//# sourceMappingURL=intl.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intl.cjs","names":["Locales"],"sources":["../../../src/utils/intl.ts"],"sourcesContent":["// Cached Intl helper – drop‑in replacement for the global `Intl` object.\n// ‑‑‑\n// • Uses a `Proxy` to lazily wrap every *constructor* hanging off `Intl` (NumberFormat, DateTimeFormat, …).\n// • Each wrapped constructor keeps an in‑memory cache keyed by `[locales, options]` so that identical requests\n// reuse the same heavy instance instead of reparsing CLDR data every time.\n// • A polyfill warning for `Intl.DisplayNames` is emitted only once and only in dev.\n// • The public API is fully type‑safe and mirrors the native `Intl` surface exactly –\n// you can treat `CachedIntl` just like the built‑in `Intl`.\n//\n// Usage examples:\n// ---------------\n// import { CachedIntl } from \"./cached-intl\";\n//\n// const nf = CachedIntl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\" });\n// console.log(nf.format(1234));\n//\n// const dn = CachedIntl.DisplayNames([\"fr\"], { type: \"language\" });\n// console.log(dn.of(\"en\")); // → \"anglais\"\n//\n// You can also spin up an isolated instance with its own caches (handy in test suites):\n// const TestIntl = createCachedIntl();\n//\n// ---------------------------------------------------------------------\n\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as Locales from '@intlayer/types/locales';\n\n// Helper type that picks just the constructor members off `typeof Intl`.\n// The \"capital‑letter\" heuristic is 100 % accurate today and keeps the\n// mapping short‑lived, so we don't have to manually list every constructor.\ntype IntlConstructors = {\n [K in keyof typeof Intl as (typeof Intl)[K] extends new (\n ...args: any\n ) => any\n ? K\n : never]: (typeof Intl)[K];\n};\n\n// Type wrapper to replace locale arguments with LocalesValues\ntype ReplaceLocaleWithLocalesValues<T> = T extends new (\n locales: any,\n options?: infer Options\n) => infer Instance\n ? {\n new (locales?: LocalesValues, options?: Options): Instance;\n new (options?: Options & { locale?: LocalesValues }): Instance;\n }\n : T extends new (\n locales: any\n ) => infer Instance\n ? {\n new (locales?: LocalesValues): Instance;\n new (options?: { locale?: LocalesValues }): Instance;\n }\n : T;\n\n// Wrapped Intl type with LocalesValues\ntype WrappedIntl = {\n [K in keyof typeof Intl]: K extends keyof IntlConstructors\n ? ReplaceLocaleWithLocalesValues<(typeof Intl)[K]>\n : (typeof Intl)[K];\n};\n\n// ... (Keep your Type Helper definitions here: IntlConstructors, ReplaceLocaleWithLocalesValues, WrappedIntl) ...\n\n/**\n * Optimized Cache Key Generator\n * 1. Fast path: If no options, just use the locale string.\n * 2. Normal path: JSON.stringify for deterministic object comparison.\n */\nconst getCacheKey = (\n locales: LocalesValues | undefined,\n options: unknown\n): string => {\n const localeKey = locales ? String(locales) : Locales.ENGLISH;\n\n if (!options) return localeKey;\n\n // JSON.stringify is the most robust way to handle nested options objects\n // without a heavy custom hashing function.\n return `${localeKey}|${JSON.stringify(options)}`;\n};\n\n/**\n * Generic wrapper for any `new Intl.*()` constructor.\n */\nconst createCachedConstructor = <T extends new (...args: any[]) => any>(\n Ctor: T\n) => {\n // The cache lives here, inside the closure of the wrapped constructor.\n const cache = new Map<string, InstanceType<T>>();\n const MAX_CACHE_SIZE = 50;\n\n function Wrapped(locales?: LocalesValues | any, options?: any) {\n let resolvedLocales = locales;\n let resolvedOptions = options;\n\n // Handle case where first argument is an options object instead of locales\n if (\n typeof locales === 'object' &&\n !Array.isArray(locales) &&\n locales !== null\n ) {\n resolvedOptions = locales;\n resolvedLocales = locales.locale;\n }\n\n // Handle DisplayNames Polyfill warning\n if (\n Ctor.name === 'DisplayNames' &&\n typeof (Intl as any)?.DisplayNames !== 'function'\n ) {\n // ... (Existing polyfill logic would go here if needed, but let's keep it simple for now as it was empty in the read output)\n // Actually the read output had \"// ... (Your existing polyfill warning logic) ...\"\n // I should check what was there before or just preserve it.\n }\n\n // Generate Key\n const key = getCacheKey(resolvedLocales, resolvedOptions);\n\n // Check Cache\n let instance = cache.get(key);\n if (instance) return instance;\n\n // Create New Instance\n instance = new Ctor(resolvedLocales as never, resolvedOptions as never);\n\n // Smart Eviction (LRU-ish)\n // Map iterates in insertion order. Deleting the first key removes the \"oldest\".\n if (cache.size >= MAX_CACHE_SIZE) {\n const oldestKey = cache.keys().next().value;\n if (oldestKey) cache.delete(oldestKey);\n }\n\n cache.set(key, instance as InstanceType<T>);\n return instance as InstanceType<T>;\n }\n\n // Preserve prototype for `instanceof` checks\n (Wrapped as any).prototype = (Ctor as any).prototype;\n\n return Wrapped as unknown as ReplaceLocaleWithLocalesValues<T>;\n};\n\n/**\n * Factory that turns the global `Intl` into a cached clone.\n */\nexport const createCachedIntl = (): WrappedIntl => {\n // We must cache the *wrapped constructors* themselves.\n // Otherwise, the Proxy creates a new `Wrapped` function (and a new empty Map)\n // on every single property access.\n const constructorCache = new Map<string | symbol, any>();\n\n return new Proxy(Intl as IntlConstructors, {\n get: (target, prop, receiver) => {\n // Fast return if we already wrapped this constructor\n if (constructorCache.has(prop)) {\n return constructorCache.get(prop);\n }\n\n const value = Reflect.get(target, prop, receiver);\n\n // Wrap only Constructors (Heuristic: Function + starts with Uppercase)\n // This prevents wrapping static methods like `Intl.getCanonicalLocales`\n if (\n typeof value === 'function' &&\n typeof prop === 'string' &&\n /^[A-Z]/.test(prop)\n ) {\n const wrapped = createCachedConstructor(value);\n constructorCache.set(prop, wrapped);\n return wrapped;\n }\n\n // Pass through everything else (static methods, constants)\n return value;\n },\n }) as unknown as WrappedIntl;\n};\n\nexport const CachedIntl = createCachedIntl();\n\n/**\n * Creates a proxied Intl object with a preset locale.\n *\n * @example\n * const intl = bindIntl(Locales.FRENCH);\n * new intl.NumberFormat(undefined, { style: 'currency', currency: 'EUR' }).format(10);\n * // Uses 'fr' automatically\n */\nexport const bindIntl = (locale: LocalesValues): WrappedIntl => {\n return new Proxy(CachedIntl, {\n get: (target, prop) => {\n const value = Reflect.get(target, prop);\n\n // We only want to intercept Constructors (e.g., NumberFormat, DateTimeFormat)\n // to inject the locale into their arguments.\n if (\n typeof value === 'function' &&\n typeof prop === 'string' &&\n /^[A-Z]/.test(prop)\n ) {\n return new Proxy(value, {\n construct: (Ctor, args) => {\n let [locales, options] = args;\n\n // If the user provided a locale (args[0]), respect it.\n // If args[0] is undefined, inject the bound locale.\n // If args[0] is an object (not array), it's the options object.\n if (\n typeof locales === 'object' &&\n !Array.isArray(locales) &&\n locales !== null\n ) {\n options = locales;\n locales = options.locale ?? locale;\n } else if (locales === undefined) {\n locales = locale;\n }\n\n // We pass it to `CachedIntl` which handles caching logic.\n return new Ctor(locales, options);\n },\n // Ensure static methods (like supportedLocalesOf) still work\n get: (Ctor, key) => Reflect.get(Ctor, key),\n });\n }\n\n // Return constants or static methods as-is\n return value;\n },\n }) as unknown as WrappedIntl;\n};\n\n// new CachedIntl.DisplayNames(Locales.FRENCH, { type: 'language' });\n// new CachedIntl.DisplayNames('fr', { type: 'language' });\n// new CachedIntl.DateTimeFormat('fr', {\n// year: 'numeric',\n// month: 'long',\n// day: 'numeric',\n// });\n// new CachedIntl.NumberFormat('fr', {\n// style: 'currency',\n// currency: 'EUR',\n// });\n// new CachedIntl.Collator('fr', { sensitivity: 'base' });\n// new CachedIntl.PluralRules('fr');\n// new CachedIntl.RelativeTimeFormat('fr', { numeric: 'auto' });\n// new CachedIntl.ListFormat('fr', { type: 'conjunction' });\nexport { CachedIntl as Intl };\n"],"mappings":"gLAsEA,MAAM,GACJ,EACA,IACW,CACX,IAAM,EAAY,EAAU,OAAO,EAAQ,CAAGA,EAAQ,QAMtD,OAJK,EAIE,GAAG,EAAU,GAAG,KAAK,UAAU,EAAQ,GAJzB,GAUjB,EACJ,GACG,CAEH,IAAM,EAAQ,IAAI,IAGlB,SAAS,EAAQ,EAA+B,EAAe,CAC7D,IAAI,EAAkB,EAClB,EAAkB,EAIpB,OAAO,GAAY,UACnB,CAAC,MAAM,QAAQ,EAAQ,EACvB,IAAY,OAEZ,EAAkB,EAClB,EAAkB,EAAQ,QAK1B,EAAK,OAAS,gBACN,MAAc,aAQxB,IAAM,EAAM,EAAY,EAAiB,EAAgB,CAGrD,EAAW,EAAM,IAAI,EAAI,CAC7B,GAAI,EAAU,OAAO,EAOrB,GAJA,EAAW,IAAI,EAAK,EAA0B,EAAyB,CAInE,EAAM,MAAQ,GAAgB,CAChC,IAAM,EAAY,EAAM,MAAM,CAAC,MAAM,CAAC,MAClC,GAAW,EAAM,OAAO,EAAU,CAIxC,OADA,EAAM,IAAI,EAAK,EAA4B,CACpC,EAMT,MAFC,GAAgB,UAAa,EAAa,UAEpC,GAMI,MAAsC,CAIjD,IAAM,EAAmB,IAAI,IAE7B,OAAO,IAAI,MAAM,KAA0B,CACzC,KAAM,EAAQ,EAAM,IAAa,CAE/B,GAAI,EAAiB,IAAI,EAAK,CAC5B,OAAO,EAAiB,IAAI,EAAK,CAGnC,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAM,EAAS,CAIjD,GACE,OAAO,GAAU,YACjB,OAAO,GAAS,UAChB,SAAS,KAAK,EAAK,CACnB,CACA,IAAM,EAAU,EAAwB,EAAM,CAE9C,OADA,EAAiB,IAAI,EAAM,EAAQ,CAC5B,EAIT,OAAO,GAEV,CAAC,EAGS,EAAa,GAAkB,CAU/B,EAAY,GAChB,IAAI,MAAM,EAAY,CAC3B,KAAM,EAAQ,IAAS,CACrB,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAK,CAoCvC,OA/BE,OAAO,GAAU,YACjB,OAAO,GAAS,UAChB,SAAS,KAAK,EAAK,CAEZ,IAAI,MAAM,EAAO,CACtB,WAAY,EAAM,IAAS,CACzB,GAAI,CAAC,EAAS,GAAW,EAiBzB,OAXE,OAAO,GAAY,UACnB,CAAC,MAAM,QAAQ,EAAQ,EACvB,IAAY,MAEZ,EAAU,EACV,EAAU,EAAQ,QAAU,GACnB,IAAY,IAAA,KACrB,EAAU,GAIL,IAAI,EAAK,EAAS,EAAQ,EAGnC,KAAM,EAAM,IAAQ,QAAQ,IAAI,EAAM,EAAI,CAC3C,CAAC,CAIG,GAEV,CAAC"}
|
|
1
|
+
{"version":3,"file":"intl.cjs","names":["ENGLISH"],"sources":["../../../src/utils/intl.ts"],"sourcesContent":["// Cached Intl helper – drop‑in replacement for the global `Intl` object.\n// ‑‑‑\n// • Uses a `Proxy` to lazily wrap every *constructor* hanging off `Intl` (NumberFormat, DateTimeFormat, …).\n// • Each wrapped constructor keeps an in‑memory cache keyed by `[locales, options]` so that identical requests\n// reuse the same heavy instance instead of reparsing CLDR data every time.\n// • A polyfill warning for `Intl.DisplayNames` is emitted only once and only in dev.\n// • The public API is fully type‑safe and mirrors the native `Intl` surface exactly –\n// you can treat `CachedIntl` just like the built‑in `Intl`.\n//\n// Usage examples:\n// ---------------\n// import { CachedIntl } from \"./cached-intl\";\n//\n// const nf = CachedIntl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\" });\n// console.log(nf.format(1234));\n//\n// const dn = CachedIntl.DisplayNames([\"fr\"], { type: \"language\" });\n// console.log(dn.of(\"en\")); // → \"anglais\"\n//\n// You can also spin up an isolated instance with its own caches (handy in test suites):\n// const TestIntl = createCachedIntl();\n//\n// ---------------------------------------------------------------------\n\nimport { ENGLISH } from '@intlayer/types/locales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n// Helper type that picks just the constructor members off `typeof Intl`.\n// The \"capital‑letter\" heuristic is 100 % accurate today and keeps the\n// mapping short‑lived, so we don't have to manually list every constructor.\ntype IntlConstructors = {\n [K in keyof typeof Intl as (typeof Intl)[K] extends new (\n ...args: any\n ) => any\n ? K\n : never]: (typeof Intl)[K];\n};\n\n// Type wrapper to replace locale arguments with LocalesValues\ntype ReplaceLocaleWithLocalesValues<T> = T extends new (\n locales: any,\n options?: infer Options\n) => infer Instance\n ? {\n new (locales?: LocalesValues, options?: Options): Instance;\n new (options?: Options & { locale?: LocalesValues }): Instance;\n }\n : T extends new (\n locales: any\n ) => infer Instance\n ? {\n new (locales?: LocalesValues): Instance;\n new (options?: { locale?: LocalesValues }): Instance;\n }\n : T;\n\n// Wrapped Intl type with LocalesValues\nexport type WrappedIntl = {\n [K in keyof typeof Intl]: K extends keyof IntlConstructors\n ? ReplaceLocaleWithLocalesValues<(typeof Intl)[K]>\n : (typeof Intl)[K];\n};\n\n// ... (Keep your Type Helper definitions here: IntlConstructors, ReplaceLocaleWithLocalesValues, WrappedIntl) ...\n\n/**\n * Optimized Cache Key Generator\n * 1. Fast path: If no options, just use the locale string.\n * 2. Normal path: JSON.stringify for deterministic object comparison.\n */\nconst getCacheKey = (\n locales: LocalesValues | undefined,\n options: unknown\n): string => {\n const localeKey = locales ? String(locales) : ENGLISH;\n\n if (!options) return localeKey;\n\n // JSON.stringify is the most robust way to handle nested options objects\n // without a heavy custom hashing function.\n return `${localeKey}|${JSON.stringify(options)}`;\n};\n\n/**\n * Generic wrapper for any `new Intl.*()` constructor.\n */\nconst createCachedConstructor = <T extends new (...args: any[]) => any>(\n Ctor: T\n) => {\n // The cache lives here, inside the closure of the wrapped constructor.\n const cache = new Map<string, InstanceType<T>>();\n const MAX_CACHE_SIZE = 50;\n\n function Wrapped(locales?: LocalesValues | any, options?: any) {\n let resolvedLocales = locales;\n let resolvedOptions = options;\n\n // Handle case where first argument is an options object instead of locales\n if (\n typeof locales === 'object' &&\n !Array.isArray(locales) &&\n locales !== null\n ) {\n resolvedOptions = locales;\n resolvedLocales = locales.locale;\n }\n\n // Handle DisplayNames Polyfill warning\n if (\n Ctor.name === 'DisplayNames' &&\n typeof (Intl as any)?.DisplayNames !== 'function'\n ) {\n // ... (Existing polyfill logic would go here if needed, but let's keep it simple for now as it was empty in the read output)\n // Actually the read output had \"// ... (Your existing polyfill warning logic) ...\"\n // I should check what was there before or just preserve it.\n }\n\n // Generate Key\n const key = getCacheKey(resolvedLocales, resolvedOptions);\n\n // Check Cache\n let instance = cache.get(key);\n if (instance) return instance;\n\n // Create New Instance\n instance = new Ctor(resolvedLocales as never, resolvedOptions as never);\n\n // Smart Eviction (LRU-ish)\n // Map iterates in insertion order. Deleting the first key removes the \"oldest\".\n if (cache.size >= MAX_CACHE_SIZE) {\n const oldestKey = cache.keys().next().value;\n if (oldestKey) cache.delete(oldestKey);\n }\n\n cache.set(key, instance as InstanceType<T>);\n return instance as InstanceType<T>;\n }\n\n // Preserve prototype for `instanceof` checks\n (Wrapped as any).prototype = (Ctor as any).prototype;\n\n return Wrapped as unknown as ReplaceLocaleWithLocalesValues<T>;\n};\n\n/**\n * Factory that turns the global `Intl` into a cached clone.\n */\nexport const createCachedIntl = (): WrappedIntl => {\n // We must cache the *wrapped constructors* themselves.\n // Otherwise, the Proxy creates a new `Wrapped` function (and a new empty Map)\n // on every single property access.\n const constructorCache = new Map<string | symbol, any>();\n\n return new Proxy(Intl as IntlConstructors, {\n get: (target, prop, receiver) => {\n // Fast return if we already wrapped this constructor\n if (constructorCache.has(prop)) {\n return constructorCache.get(prop);\n }\n\n const value = Reflect.get(target, prop, receiver);\n\n // Wrap only Constructors (Heuristic: Function + starts with Uppercase)\n // This prevents wrapping static methods like `Intl.getCanonicalLocales`\n if (\n typeof value === 'function' &&\n typeof prop === 'string' &&\n /^[A-Z]/.test(prop)\n ) {\n const wrapped = createCachedConstructor(value);\n constructorCache.set(prop, wrapped);\n return wrapped;\n }\n\n // Pass through everything else (static methods, constants)\n return value;\n },\n }) as unknown as WrappedIntl;\n};\n\nexport const CachedIntl = createCachedIntl();\n\n/**\n * Creates a proxied Intl object with a preset locale.\n *\n * @example\n * const intl = bindIntl(Locales.FRENCH);\n * new intl.NumberFormat(undefined, { style: 'currency', currency: 'EUR' }).format(10);\n * // Uses 'fr' automatically\n */\nexport const bindIntl = (locale: LocalesValues): WrappedIntl => {\n return new Proxy(CachedIntl, {\n get: (target, prop) => {\n const value = Reflect.get(target, prop);\n\n // We only want to intercept Constructors (e.g., NumberFormat, DateTimeFormat)\n // to inject the locale into their arguments.\n if (\n typeof value === 'function' &&\n typeof prop === 'string' &&\n /^[A-Z]/.test(prop)\n ) {\n return new Proxy(value, {\n construct: (Ctor, args) => {\n let [locales, options] = args;\n\n // If the user provided a locale (args[0]), respect it.\n // If args[0] is undefined, inject the bound locale.\n // If args[0] is an object (not array), it's the options object.\n if (\n typeof locales === 'object' &&\n !Array.isArray(locales) &&\n locales !== null\n ) {\n options = locales;\n locales = options.locale ?? locale;\n } else if (locales === undefined) {\n locales = locale;\n }\n\n // We pass it to `CachedIntl` which handles caching logic.\n return new Ctor(locales, options);\n },\n // Ensure static methods (like supportedLocalesOf) still work\n get: (Ctor, key) => Reflect.get(Ctor, key),\n });\n }\n\n // Return constants or static methods as-is\n return value;\n },\n }) as unknown as WrappedIntl;\n};\n\n// new CachedIntl.DisplayNames(Locales.FRENCH, { type: 'language' });\n// new CachedIntl.DisplayNames('fr', { type: 'language' });\n// new CachedIntl.DateTimeFormat('fr', {\n// year: 'numeric',\n// month: 'long',\n// day: 'numeric',\n// });\n// new CachedIntl.NumberFormat('fr', {\n// style: 'currency',\n// currency: 'EUR',\n// });\n// new CachedIntl.Collator('fr', { sensitivity: 'base' });\n// new CachedIntl.PluralRules('fr');\n// new CachedIntl.RelativeTimeFormat('fr', { numeric: 'auto' });\n// new CachedIntl.ListFormat('fr', { type: 'conjunction' });\nexport { CachedIntl as Intl };\n"],"mappings":"6IAsEA,MAAM,GACJ,EACA,IACW,CACX,IAAM,EAAY,EAAU,OAAO,EAAQ,CAAGA,EAAAA,QAM9C,OAJK,EAIE,GAAG,EAAU,GAAG,KAAK,UAAU,EAAQ,GAJzB,GAUjB,EACJ,GACG,CAEH,IAAM,EAAQ,IAAI,IAGlB,SAAS,EAAQ,EAA+B,EAAe,CAC7D,IAAI,EAAkB,EAClB,EAAkB,EAIpB,OAAO,GAAY,UACnB,CAAC,MAAM,QAAQ,EAAQ,EACvB,IAAY,OAEZ,EAAkB,EAClB,EAAkB,EAAQ,QAK1B,EAAK,OAAS,gBACN,MAAc,aAQxB,IAAM,EAAM,EAAY,EAAiB,EAAgB,CAGrD,EAAW,EAAM,IAAI,EAAI,CAC7B,GAAI,EAAU,OAAO,EAOrB,GAJA,EAAW,IAAI,EAAK,EAA0B,EAAyB,CAInE,EAAM,MAAQ,GAAgB,CAChC,IAAM,EAAY,EAAM,MAAM,CAAC,MAAM,CAAC,MAClC,GAAW,EAAM,OAAO,EAAU,CAIxC,OADA,EAAM,IAAI,EAAK,EAA4B,CACpC,EAMT,MAFC,GAAgB,UAAa,EAAa,UAEpC,GAMI,MAAsC,CAIjD,IAAM,EAAmB,IAAI,IAE7B,OAAO,IAAI,MAAM,KAA0B,CACzC,KAAM,EAAQ,EAAM,IAAa,CAE/B,GAAI,EAAiB,IAAI,EAAK,CAC5B,OAAO,EAAiB,IAAI,EAAK,CAGnC,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAM,EAAS,CAIjD,GACE,OAAO,GAAU,YACjB,OAAO,GAAS,UAChB,SAAS,KAAK,EAAK,CACnB,CACA,IAAM,EAAU,EAAwB,EAAM,CAE9C,OADA,EAAiB,IAAI,EAAM,EAAQ,CAC5B,EAIT,OAAO,GAEV,CAAC,EAGS,EAAa,GAAkB,CAU/B,EAAY,GAChB,IAAI,MAAM,EAAY,CAC3B,KAAM,EAAQ,IAAS,CACrB,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAK,CAoCvC,OA/BE,OAAO,GAAU,YACjB,OAAO,GAAS,UAChB,SAAS,KAAK,EAAK,CAEZ,IAAI,MAAM,EAAO,CACtB,WAAY,EAAM,IAAS,CACzB,GAAI,CAAC,EAAS,GAAW,EAiBzB,OAXE,OAAO,GAAY,UACnB,CAAC,MAAM,QAAQ,EAAQ,EACvB,IAAY,MAEZ,EAAU,EACV,EAAU,EAAQ,QAAU,GACnB,IAAY,IAAA,KACrB,EAAU,GAIL,IAAI,EAAK,EAAS,EAAQ,EAGnC,KAAM,EAAM,IAAQ,QAAQ,IAAI,EAAM,EAAI,CAC3C,CAAC,CAIG,GAEV,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`../getStorageAttributes.cjs`),n=require(`./getCookie.cjs`);let r=require(`@intlayer/config/built`);r=e.t(r);const i=(e,t,n)=>{let r=[`${e}=${encodeURIComponent(t)}`];return n.path&&r.push(`Path=${n.path}`),n.domain&&r.push(`Domain=${n.domain}`),n.expires instanceof Date&&r.push(`Expires=${n.expires.toUTCString()}`),n.secure&&r.push(`Secure`),n.sameSite&&r.push(`SameSite=${n.sameSite}`),r.join(`; `)},a=e=>{let{routing:i,internationalization:a}=r.default,{locales:o}=a,{storage:s}=i;if(s===!1||e?.isCookieEnabled===!1)return;let c=t.getStorageAttributes(s),l=e=>e?o.includes(e):!1,u=t=>{try{let n=e?.getCookie?.(t);if(n!=null)return n}catch{}return n.getCookie(t)};for(let e=0;e<c.cookies.length;e++){let{name:t}=c.cookies[e],n=u(t);if(l(n))return n}for(let t=0;t<c.localStorage.length;t++){let{name:n}=c.localStorage[t];try{let t=e?.getLocaleStorage?.(n);if(l(t))return t}catch{}}for(let t=0;t<c.sessionStorage.length;t++){let{name:n}=c.sessionStorage[t];try{let t=e?.getSessionStorage?.(n);if(l(t))return t}catch{}}for(let t=0;t<c.headers.length;t++){let{name:n}=c.headers[t];try{let t=e?.getHeader?.(n);if(l(t))return t}catch{}}},o=(e,n)=>{if(r.default.routing.storage===!1||n?.isCookieEnabled===!1)return;let a=t.getStorageAttributes(r.default.routing.storage);for(let t=0;t<a.cookies.length;t++){let{name:r,attributes:o}=a.cookies[t];try{n?.setCookieStore&&n?.setCookieStore?.(r,e,{...o,expires:o.expires instanceof Date?o.expires.getTime():o.expires})}catch{try{if(n?.setCookieString){let t=i(r,e,o);n?.setCookieString?.(r,t)}}catch{}}}if(n?.setLocaleStorage)for(let t=0;t<a.localStorage.length;t++){let{name:r}=a.localStorage[t];try{if(!(n?.overwrite??!0)&&n?.getLocaleStorage&&n?.getLocaleStorage?.(r))continue;n?.setLocaleStorage?.(r,e)}catch{}}if(n?.setSessionStorage)for(let t=0;t<a.sessionStorage.length;t++){let{name:r}=a.sessionStorage[t];try{if(!(n?.overwrite??!0)&&n?.getSessionStorage&&n?.getSessionStorage?.(r))continue;n?.setSessionStorage?.(r,e)}catch{}}if(n?.setHeader)for(let t=0;t<a.headers.length;t++){let{name:r}=a.headers[t];try{n?.setHeader?.(r,e)}catch{}}},s=e=>({getLocale:()=>a(e),setLocale:t=>o(t,e)});exports.LocaleStorage=s,exports.getLocaleFromStorage=a,exports.setLocaleInStorage=o;
|
|
2
2
|
//# sourceMappingURL=localeStorage.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeStorage.cjs","names":["configuration","getStorageAttributes","getCookie"],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { CookiesAttributes } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getStorageAttributes } from '../getStorageAttributes';\nimport { getCookie } from './getCookie';\n\ntype CookieBuildAttributes = {\n /**\n * Cookie domain to store the locale information\n *\n * Default: undefined\n *\n * Define the domain where the cookie is available. Defaults to\n * the domain of the page where the cookie was created.\n */\n domain?: string;\n /**\n * Cookie path to store the locale information\n *\n * Default: undefined\n *\n * Define the path where the cookie is available. Defaults to '/'\n */\n path?: string;\n /**\n * Cookie secure to store the locale information\n *\n * Default: undefined\n *\n * A Boolean indicating if the cookie transmission requires a\n * secure protocol (https). Defaults to false.\n */\n secure?: boolean;\n /**\n * Cookie httpOnly to store the locale information\n *\n * Default: undefined\n *\n * The cookie httpOnly where the locale information is stored.\n */\n httpOnly?: boolean;\n /**\n * Cookie sameSite to store the locale information\n *\n * Default: undefined\n *\n * Asserts that a cookie must not be sent with cross-origin requests,\n * providing some protection against cross-site request forgery\n * attacks (CSRF)\n */\n sameSite?: 'strict' | 'lax' | 'none';\n\n /**\n * Cookie expires to store the locale information\n *\n * Default: undefined\n *\n * Define when the cookie will be removed. Value can be a Number\n * which will be interpreted as days from time of creation or a\n * Date instance. If omitted, the cookie becomes a session cookie.\n */\n expires?: number | undefined;\n};\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\n};\n\nexport type LocaleStorageOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const { storage } = routing;\n\n // If storage is disabled, return undefined\n if (storage === false || options?.isCookieEnabled === false) return undefined;\n\n const storageAttributes = getStorageAttributes(storage);\n\n const isValidLocale = (value: string | null | undefined): value is Locale => {\n if (!value) return false;\n\n return locales.includes(value as Locale);\n };\n\n const readCookie = (name: string): string | undefined => {\n // Prefer provided getter (server or custom environment)\n try {\n const fromOption = options?.getCookie?.(name);\n\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n\n // Fallback to browser cookie parsing\n return getCookie(name);\n };\n\n // Check cookies first\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name } = storageAttributes.cookies[i];\n\n const value = readCookie(name);\n\n if (isValidLocale(value)) return value;\n }\n\n // Then check localStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const value = options?.getLocaleStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Check sessionStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const value = options?.getSessionStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Finally check header candidates (server only)\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n const value = options?.getHeader?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @param locale - The locale to store\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n // If storage is disabled, do nothing\n if (\n configuration.routing.storage === false ||\n options?.isCookieEnabled === false\n )\n return;\n\n const storageAttributes = getStorageAttributes(configuration.routing.storage);\n\n // Write to cookies (server via setCookie, client via cookieStore/document)\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n\n try {\n if (options?.setCookieStore) {\n options?.setCookieStore?.(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n const cookieString = buildCookieString(name, locale, attributes);\n\n options?.setCookieString?.(name, cookieString);\n }\n } catch {}\n }\n }\n\n // Write to localStorage (browser only)\n if (options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getLocaleStorage) {\n const existing = options?.getLocaleStorage?.(name);\n\n if (existing) continue;\n }\n options?.setLocaleStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to sessionStorage (browser only)\n if (options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getSessionStorage) {\n const existing = options?.getSessionStorage?.(name);\n if (existing) continue;\n }\n\n options?.setSessionStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to headers (server only)\n if (options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n options?.setHeader?.(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in the storage by considering the configuration\n *\n * @property getLocale - Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @property setLocale - Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"localeStorage.cjs","names":["configuration","getStorageAttributes","getCookie"],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { CookiesAttributes } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getStorageAttributes } from '../getStorageAttributes';\nimport { getCookie } from './getCookie';\n\ntype CookieBuildAttributes = {\n /**\n * Cookie domain to store the locale information\n *\n * Default: undefined\n *\n * Define the domain where the cookie is available. Defaults to\n * the domain of the page where the cookie was created.\n */\n domain?: string;\n /**\n * Cookie path to store the locale information\n *\n * Default: undefined\n *\n * Define the path where the cookie is available. Defaults to '/'\n */\n path?: string;\n /**\n * Cookie secure to store the locale information\n *\n * Default: undefined\n *\n * A Boolean indicating if the cookie transmission requires a\n * secure protocol (https). Defaults to false.\n */\n secure?: boolean;\n /**\n * Cookie httpOnly to store the locale information\n *\n * Default: undefined\n *\n * The cookie httpOnly where the locale information is stored.\n */\n httpOnly?: boolean;\n /**\n * Cookie sameSite to store the locale information\n *\n * Default: undefined\n *\n * Asserts that a cookie must not be sent with cross-origin requests,\n * providing some protection against cross-site request forgery\n * attacks (CSRF)\n */\n sameSite?: 'strict' | 'lax' | 'none';\n\n /**\n * Cookie expires to store the locale information\n *\n * Default: undefined\n *\n * Define when the cookie will be removed. Value can be a Number\n * which will be interpreted as days from time of creation or a\n * Date instance. If omitted, the cookie becomes a session cookie.\n */\n expires?: number | undefined;\n};\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\n};\n\nexport type LocaleStorageOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const { storage } = routing;\n\n // If storage is disabled, return undefined\n if (storage === false || options?.isCookieEnabled === false) return undefined;\n\n const storageAttributes = getStorageAttributes(storage);\n\n const isValidLocale = (value: string | null | undefined): value is Locale => {\n if (!value) return false;\n\n return locales.includes(value as Locale);\n };\n\n const readCookie = (name: string): string | undefined => {\n // Prefer provided getter (server or custom environment)\n try {\n const fromOption = options?.getCookie?.(name);\n\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n\n // Fallback to browser cookie parsing\n return getCookie(name);\n };\n\n // Check cookies first\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name } = storageAttributes.cookies[i];\n\n const value = readCookie(name);\n\n if (isValidLocale(value)) return value;\n }\n\n // Then check localStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const value = options?.getLocaleStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Check sessionStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const value = options?.getSessionStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Finally check header candidates (server only)\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n const value = options?.getHeader?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @param locale - The locale to store\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n // If storage is disabled, do nothing\n if (\n configuration.routing.storage === false ||\n options?.isCookieEnabled === false\n )\n return;\n\n const storageAttributes = getStorageAttributes(configuration.routing.storage);\n\n // Write to cookies (server via setCookie, client via cookieStore/document)\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n\n try {\n if (options?.setCookieStore) {\n options?.setCookieStore?.(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n const cookieString = buildCookieString(name, locale, attributes);\n\n options?.setCookieString?.(name, cookieString);\n }\n } catch {}\n }\n }\n\n // Write to localStorage (browser only)\n if (options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getLocaleStorage) {\n const existing = options?.getLocaleStorage?.(name);\n\n if (existing) continue;\n }\n options?.setLocaleStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to sessionStorage (browser only)\n if (options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getSessionStorage) {\n const existing = options?.getSessionStorage?.(name);\n if (existing) continue;\n }\n\n options?.setSessionStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to headers (server only)\n if (options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n options?.setHeader?.(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in the storage by considering the configuration\n *\n * @property getLocale - Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @property setLocale - Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{deepTransformNode as e}from"../interpreter/getContent/deepTransform.mjs";import{
|
|
1
|
+
import{deepTransformNode as e}from"../interpreter/getContent/deepTransform.mjs";import{l as t}from"../getContent-DKqtIZGL.mjs";const n=(n,r,i,a)=>{let o=[t(r,a),...i.plugins??[]];return e(n,{...i,plugins:o})},r=(e,t,r)=>({...e,locale:t,content:n(e.content,t,{dictionaryKey:e.key,keyPath:[],plugins:[]},r)});export{n as getLocalizedContent,r as getPerLocaleDictionary};
|
|
2
2
|
//# sourceMappingURL=getLocalizedContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocalizedContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getLocalizedContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type DeepTransformContent,\n type NodeProps,\n type Plugins,\n translationPlugin,\n} from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n * In comparison to `getContent`, this function will only apply the translation plugin.\n * It will not transform enumerations, insertions, or other content types.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getLocalizedContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n locale: L,\n nodeProps: NodeProps,\n fallback?: LocalesValues // fallback mean that if field is not translated, it will use the default locale\n) => {\n const plugins: Plugins[] = [\n translationPlugin(locale, fallback),\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n};\n\nexport const getPerLocaleDictionary = <\n T extends Dictionary,\n L extends LocalesValues,\n>(\n dictionary: T,\n locale: L,\n fallback?: LocalesValues\n): Dictionary => ({\n ...dictionary,\n locale,\n content: getLocalizedContent(\n dictionary.content,\n locale,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [],\n },\n fallback\n ),\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getLocalizedContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getLocalizedContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type DeepTransformContent,\n type NodeProps,\n type Plugins,\n translationPlugin,\n} from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n * In comparison to `getContent`, this function will only apply the translation plugin.\n * It will not transform enumerations, insertions, or other content types.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getLocalizedContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n locale: L,\n nodeProps: NodeProps,\n fallback?: LocalesValues // fallback mean that if field is not translated, it will use the default locale\n) => {\n const plugins: Plugins[] = [\n translationPlugin(locale, fallback),\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n};\n\nexport const getPerLocaleDictionary = <\n T extends Dictionary,\n L extends LocalesValues,\n>(\n dictionary: T,\n locale: L,\n fallback?: LocalesValues\n): Dictionary => ({\n ...dictionary,\n locale,\n content: getLocalizedContent(\n dictionary.content,\n locale,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [],\n },\n fallback\n ),\n});\n"],"mappings":"+HAkBA,MAAa,GAIX,EACA,EACA,EACA,IACG,CACH,IAAM,EAAqB,CACzB,EAAkB,EAAQ,EAAS,CACnC,GAAI,EAAU,SAAW,EAAE,CAC5B,CAED,OAAO,EAAkB,EAAM,CAC7B,GAAG,EACH,UACD,CAAC,EAGS,GAIX,EACA,EACA,KACgB,CAChB,GAAG,EACH,SACA,QAAS,EACP,EAAW,QACX,EACA,CACE,cAAe,EAAW,IAC1B,QAAS,EAAE,CACX,QAAS,EAAE,CACZ,CACD,EACD,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.mjs","names":[],"sources":["../../../src/formatters/list.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats an array of values into a localized list string using the Intl API.\n *\n * @example\n * list(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * @example\n * list(['red', 'green', 'blue'], { locale: Locales.FRENCH, type: 'disjunction' });\n * // \"rouge, vert ou bleu\"\n *\n * @example\n * list([1, 2, 3], { type: 'unit' });\n * // \"1, 2, 3\"\n */\nexport const list = (\n values: (string | number)[],\n
|
|
1
|
+
{"version":3,"file":"list.mjs","names":[],"sources":["../../../src/formatters/list.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/** Locally defined subset of Intl.ListFormatOptions so consumers don't need ES2021.Intl in their lib. */\ntype ListFormatOptions = {\n localeMatcher?: 'lookup' | 'best fit';\n type?: 'conjunction' | 'disjunction' | 'unit';\n style?: 'long' | 'short' | 'narrow';\n};\n\n/**\n * Formats an array of values into a localized list string using the Intl API.\n *\n * @example\n * list(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * @example\n * list(['red', 'green', 'blue'], { locale: Locales.FRENCH, type: 'disjunction' });\n * // \"rouge, vert ou bleu\"\n *\n * @example\n * list([1, 2, 3], { type: 'unit' });\n * // \"1, 2, 3\"\n */\nexport const list = (\n values: (string | number)[],\n options?: ListFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.ListFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n type: options?.type ?? 'conjunction',\n style: options?.style ?? 'long',\n ...options,\n }\n ).format(values.map(String));\n"],"mappings":"qFA0BA,MAAa,GACX,EACA,IAEA,IAAI,EAAW,WACb,GAAS,QAAU,GAAe,sBAAsB,cACxD,CACE,KAAM,GAAS,MAAQ,cACvB,MAAO,GAAS,OAAS,OACzB,GAAG,EACJ,CACF,CAAC,OAAO,EAAO,IAAI,OAAO,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getCondition as e}from"./interpreter/getCondition.mjs";import{deepTransformNode as t}from"./interpreter/getContent/deepTransform.mjs";import{getEnumeration as n}from"./interpreter/getEnumeration.mjs";import{getGender as r}from"./interpreter/getGender.mjs";import{getInsertion as i}from"./interpreter/getInsertion.mjs";import{getTranslation as a}from"./interpreter/getTranslation.mjs";import{NodeType as o}from"@intlayer/types/nodeType";import s from"@intlayer/config/built";import{colorizeKey as c,getAppLogger as l}from"@intlayer/config/logger";import{getDictionaries as u}from"@intlayer/dictionaries-entry";const d=(e,t,n=S(t))=>{let r={dictionaryKey:e.key,dictionaryPath:e.filePath,keyPath:[],plugins:n};return C(e.content,r,n)},f=(e=``)=>new Proxy(()=>e,{get:(t,n)=>{if(n===`toJSON`||n===Symbol.toPrimitive||n===`toString`)return()=>e;if(n!==`then`)return f(e?`${e}.${String(n)}`:String(n))},apply:()=>e}),p=(e,t,n)=>{let r=u()[e];return r?d(r,t,n):(l(s)(`Dictionary ${c(e)} was not found. Using fallback proxy.`,{level:`warn`,isVerbose:!0}),f(e))},m=(e,t,n)=>{let r=p(e,n?.locale,n?.plugins);if(typeof t==`string`){let e=t.split(`.`),n=r;for(let t of e)if(n=n?.[t],n===void 0)return r;return n}return r},h=(e,t)=>({id:`translation-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Translation,transform:(n,r,i)=>{let s={...n[o.Translation]??{}};for(let e in s){let t={...r,children:s[e],keyPath:[...r.keyPath,{type:o.Translation,key:e}]};s[e]=i(s[e],t)}return a(s,e,t)}}),g={id:`enumeration-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Enumeration,transform:(e,t,r)=>{let i={...e[o.Enumeration]};for(let e in i){let n=i[e];i[e]=r(n,{...t,children:n,keyPath:[...t.keyPath,{type:o.Enumeration,key:e}]})}return e=>{let t=n(i,typeof e==`number`?e:e.count);return typeof t==`function`&&typeof e==`object`?t(e):t}}},_={id:`condition-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Condition,transform:(t,n,r)=>{let i={...t[o.Condition]};for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.Condition,key:e}]})}return t=>{let n=e(i,typeof t==`boolean`?t:t.value);return typeof n==`function`&&typeof t==`object`?n(t):n}}},v={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Insertion,transform:(e,t,n)=>{let r=[...t.keyPath,{type:o.Insertion}],a=e[o.Insertion],s={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let a=r(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let o=i(a,e);return r(o,{...n,plugins:t.plugins,children:o})}}};return n(a,{...t,children:a,keyPath:r,plugins:[s,...t.plugins??[]]})}},y={id:`gender-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Gender,transform:(e,t,n)=>{let i={...e[o.Gender]};for(let e in i){let r=i[e];i[e]=n(r,{...t,children:r,keyPath:[...t.keyPath,{type:o.Gender,key:e}]})}return e=>r(i,e)}},b=e=>({id:`nested-plugin`,canHandle:e=>typeof e==`object`&&(e?.nodeType===o.Nested||e?.nodeType===`nested`),transform:(t,n)=>m(t.nested.dictionaryKey,t.nested.path,{...n,locale:e??n.locale})}),x={id:`file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.File,transform:(e,t,n)=>n(e.content,{...t,children:e.content})},S=(e,t=!0)=>[h(e??s.internationalization.defaultLocale,t?s.internationalization.defaultLocale:void 0),g,_,v,b(e??s.internationalization.defaultLocale),x,y],C=(e,n,r=[])=>t(e,{...n,plugins:r});export{x as a,b as c,p as d,d as f,g as i,h as l,C as n,y as o,_ as r,v as s,S as t,m as u};
|
|
2
|
+
//# sourceMappingURL=getContent-DKqtIZGL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getContent-DKqtIZGL.mjs","names":[],"sources":["../../src/interpreter/getDictionary.ts","../../src/interpreter/getIntlayer.ts","../../src/interpreter/getNesting.ts","../../src/interpreter/getContent/plugins.ts","../../src/interpreter/getContent/getContent.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\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 * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins 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 T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n plugins: Plugins[] = getBasePlugins(locale)\n): DeepTransformContent<T['content'], IInterpreterPluginState, L> => {\n const props: NodeProps = {\n dictionaryKey: dictionary.key,\n dictionaryPath: dictionary.filePath,\n keyPath: [],\n plugins,\n };\n\n return getContent(dictionary.content, props, plugins);\n};\n","import configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\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(\n // Target is a function so it can be called if the dictionary expects a function\n () => path,\n {\n get: (_target, prop) => {\n // Handle common object methods to prevent infinite recursion or weird behavior\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\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 // If the code tries to execute the missing key as a function: t.title()\n apply: () => {\n return path;\n },\n }\n );\n};\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger(configuration);\n logger(\n `Dictionary ${colorizeKey(key as string)} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n\n if (process.env.NODE_ENV === 'development') {\n // Return the Safe Proxy\n // We initialize it with the dictionary key name so the UI shows \"my-dictionary.someKey\"\n return createSafeFallback(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n","import type { DictionaryKeys, DictionaryRegistryContent } from '@intlayer/types/module_augmentation';\nimport type { GetSubPath } from '@intlayer/types/dictionary';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<DeepTransformContent<DictionaryRegistryContent<K>, S>, P>;\n\n/**\n * Extracts content from another dictionary by its key and an optional path.\n *\n * This allows for reusing content across different dictionaries.\n *\n * @param dictionaryKey - The key of the dictionary to nest.\n * @param path - Optional dot-separated path to a specific field within the nested dictionary.\n * @param props - Optional properties like locale and plugins.\n * @returns The nested content.\n *\n * @example\n * ```ts\n * const content = getNesting(\"common\", \"buttons.save\");\n * // 'Save'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n","import type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n Gender,\n GenderContent,\n InsertionContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { getGender } from '../getGender';\nimport { getInsertion } from '../getInsertion';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n id: string;\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type UnionKeys<T> = T extends unknown ? keyof T : never;\nexport type ValueAtKey<T, K> = T extends unknown\n ? K extends keyof T\n ? T[K]\n : never\n : never;\n\nexport type TranslationCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: infer U;\n}\n ? U extends Record<PropertyKey, unknown>\n ? U[keyof U] extends Record<PropertyKey, unknown>\n ? {\n [K in UnionKeys<U[keyof U]>]: L extends keyof U\n ? K extends keyof U[L]\n ? U[L][K]\n : ValueAtKey<U[keyof U], K>\n : ValueAtKey<U[keyof U], K>;\n } extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : (L extends keyof U ? U[L] : U[keyof U]) extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : never\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins => ({\n id: 'translation-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = {\n ...(node[NodeType.Translation] ?? {}),\n };\n\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Translation, key } as KeyPath,\n ],\n };\n result[key as keyof typeof result] = deepTransformNode(\n result[key as keyof typeof result],\n childProps\n );\n }\n\n return getTranslation(result, locale, fallback);\n },\n});\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Enumeration]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[NodeType.Enumeration][keyof T[NodeType.Enumeration]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins = {\n id: 'enumeration-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Enumeration,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const result = { ...node[NodeType.Enumeration] };\n\n for (const key in result) {\n const child = result[key as unknown as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Enumeration, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: number | { count: number }) => {\n const quantity = typeof arg === 'number' ? arg : arg.count;\n const subResult = getEnumeration(result, quantity);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Condition]: object;\n}\n ? (\n value: boolean | { value: boolean }\n ) => DeepTransformContent<\n T[NodeType.Condition][keyof T[NodeType.Condition]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins = {\n id: 'condition-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Condition,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const result = { ...node[NodeType.Condition] };\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Condition, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: boolean | { value: boolean }) => {\n const value = typeof arg === 'boolean' ? arg : arg.value;\n const subResult = getCondition(result, value);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? (\n values: {\n [K in T['fields'][number]]: string | number;\n }\n ) => DeepTransformContent<string, S>\n : never;\n\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: props.plugins,\n children,\n });\n };\n },\n };\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * GENDER PLUGIN\n * --------------------------------------------- */\n\nexport type GenderCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Gender]: object;\n}\n ? (\n value: Gender\n ) => DeepTransformContent<T[NodeType.Gender][keyof T[NodeType.Gender]], S>\n : never;\n\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nexport const genderPlugin: Plugins = {\n id: 'gender-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Gender,\n transform: (node: GenderContent, props, deepTransformNode) => {\n const result = { ...node[NodeType.Gender] };\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [...props.keyPath, { type: NodeType.Gender, key } as KeyPath],\n };\n result[key as keyof typeof result] = deepTransformNode(child, childProps);\n }\n\n return (value: Gender) => getGender(result, value);\n },\n};\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Nested]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin = (locale?: LocalesValues): Plugins => ({\n id: 'nested-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n (node?.nodeType === NodeType.Nested || node?.nodeType === 'nested'),\n transform: (node: NestedContent, props) =>\n getNesting(node.nested.dictionaryKey, node.nested.path, {\n ...props,\n locale: (locale ?? props.locale) as Locale,\n }),\n});\n\n/** ---------------------------------------------\n * FILE PLUGIN\n * --------------------------------------------- */\n\nexport type FileCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.File]: string;\n content?: string;\n}\n ? string\n : never;\n\n/** File plugin. Replaces node with the result of `getNesting`. */\nexport const filePlugin: Plugins = {\n id: 'file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent, props, deepTransform) =>\n deepTransform(node.content, {\n ...props,\n children: node.content,\n }),\n};\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locale;\n dictionaryPath?: string;\n children?: any;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S, L extends LocalesValues> {\n translation: TranslationCond<T, S, L>;\n enumeration: EnumerationCond<T, S, L>;\n condition: ConditionCond<T, S, L>;\n insertion: InsertionCond<T, S, L>;\n gender: GenderCond<T, S, L>;\n nested: NestedCond<T, S, L>;\n file: FileCond<T>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n condition: true;\n insertion: true;\n gender: true;\n nested: true;\n file: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<\n T,\n K extends keyof IInterpreterPlugin<T, S, L>,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = K extends keyof S // Test if the key is a key of S.\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S, L>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S, L>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S, L extends LocalesValues = DeclaredLocales> =\n T extends ReadonlyArray<infer U> // Turn any read-only array into a plain mutable array\n ? Array<DeepTransformContent<U, S, L>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S, L> }\n : T;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<\n T,\n S = IInterpreterPluginState,\n L extends LocalesValues = DeclaredLocales,\n> =\n IsAny<T> extends true\n ? T\n : CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L> extends never // Check if there is a plugin for T:\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S, L>\n : // A plugin was found – use the plugin’s transformation.\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L>;\n","import configuration from '@intlayer/config/built';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { deepTransformNode } from './deepTransform';\nimport {\n conditionPlugin,\n type DeepTransformContent,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState,\n insertionPlugin,\n type NodeProps,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from './plugins';\n\nexport const getBasePlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n insertionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n];\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n nodeProps: NodeProps,\n plugins: Plugins[] = []\n) =>\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T, IInterpreterPluginState, L>;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{validateHTML as e}from"./transpiler/html/validateHTML.mjs";import{HTML_TAGS as t}from"./transpiler/html/htmlTags.mjs";import{NodeType as n,formatNodeType as r}from"@intlayer/types/nodeType";const i=e=>{let t={};return!e||!e.trim()||[...e.matchAll(/([a-zA-Z0-9-:_@]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))?/g)].forEach(e=>{let n=e[1];t[n]=`string`}),t},a=e=>{if(typeof e!=`string`)throw Error(`content must be a string`);let n=[...e.matchAll(/<(\/)?([a-zA-Z0-9.-]+)\s*([\s\S]*?)(\/?)>/g)],r={};return n.forEach(e=>{let n=!!e[1],a=e[2],o=e[3],s=!!e[4];if(t.includes(a.toLowerCase())){r[a]=!0;return}if(r[a]||(r[a]={}),r[a]===!0||n)return;let c=i(o),l=r[a];Object.assign(l,c),s||(l.children=`string`)}),r},o=(t,i)=>r(n.HTML,t,{tags:(()=>{if(i)return i;if(typeof t==`string`){let{issues:n}=e(t);for(let e of n)e.type===`error`?console.error(`[intlayer/html] ${e.message}`):console.warn(`[intlayer/html] ${e.message}`);return a(t)}let n;if(typeof t==`function`?n=t():typeof t.then==`function`&&(n=async()=>a(await t)),typeof n==`string`)return a(n);try{return a(JSON.stringify(t))}catch{return[]}})()});export{a as n,o as t};
|
|
2
|
+
//# sourceMappingURL=html-3bo80xzx.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-3bo80xzx.mjs","names":[],"sources":["../../src/transpiler/html/getHTMLCustomComponents.ts","../../src/transpiler/html/html.ts"],"sourcesContent":["import { HTML_TAGS } from './index';\n\nconst parseAttributes = (attributesString: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n\n if (!attributesString || !attributesString.trim()) {\n return attributes;\n }\n\n // Regex to match attribute names\n // Matches: name=\"value\", name='value', name=value, or just name\n const attrRegex =\n /([a-zA-Z0-9-:_@]+)(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^>\\s]+))?/g;\n\n const matches = [...attributesString.matchAll(attrRegex)];\n\n matches.forEach((match) => {\n const attrName = match[1];\n attributes[attrName] = 'string';\n });\n\n return attributes;\n};\n\n/**\n * Extracts component names from an HTML string.\n * - Standard HTML tags are set to `true`.\n * - Custom components are parsed to extract their attributes/props.\n */\nexport const getHTMLCustomComponents = (\n content: string\n): Record<string, Record<string, string> | true> => {\n if (typeof content !== 'string') {\n throw new Error('content must be a string');\n }\n\n // Regex to match tags: <Tag ...>, </Tag>, or <Tag ... />\n // Captures: 1: Closing slash (if any), 2: Tag Name, 3: Attributes, 4: Self-closing slash (if any)\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)\\s*([\\s\\S]*?)(\\/?)>/g;\n const matches = [...content.matchAll(tagRegex)];\n\n const components: Record<string, Record<string, string> | true> = {};\n\n matches.forEach((match) => {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attributesString = match[3];\n const isSelfClosing = !!match[4];\n\n // Component extraction logic\n if ((HTML_TAGS as readonly string[]).includes(tagName.toLowerCase())) {\n components[tagName] = true;\n return;\n }\n\n if (!components[tagName]) {\n components[tagName] = {};\n }\n\n // Safety check if we somehow have a collision or logic issue, though loop order handles it\n if (components[tagName] === true) {\n return;\n }\n\n if (isClosing) {\n return;\n }\n\n // Parse attributes for custom components\n const attributes = parseAttributes(attributesString);\n const componentDef = components[tagName] as Record<string, string>;\n Object.assign(componentDef, attributes);\n\n // If not self-closing, assume it has children\n if (!isSelfClosing) {\n componentDef.children = 'string';\n }\n });\n\n return components;\n};\n","import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getHTMLCustomComponents } from './getHTMLCustomComponents';\nimport { validateHTML } from './validateHTML';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type HTMLContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<NodeType.HTML, Content, T>;\n\nexport type HTMLContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = HTMLContentConstructor<\n Content,\n {\n tags: string[] | Components;\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to parse HTML/JSX-like strings and replace tags with components during interpretation.\n *\n * Usage:\n *\n * ```ts\n * html('Hello <b>World</b>')\n * ```\n *\n */\nexport const html = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): HTMLContent<Content, Components> => {\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n const { issues } = validateHTML(content);\n\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/html] ${issue.message}`);\n } else {\n console.warn(`[intlayer/html] ${issue.message}`);\n }\n }\n\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.HTML, content, {\n tags: getComponents(),\n });\n};\n"],"mappings":"qMAEA,MAAM,EAAmB,GAAqD,CAC5E,IAAM,EAAqC,EAAE,CAkB7C,MAhBI,CAAC,GAAoB,CAAC,EAAiB,MAAM,EASjC,CAAC,GAAG,EAAiB,SAFnC,6DAEsD,CAAC,CAEjD,QAAS,GAAU,CACzB,IAAM,EAAW,EAAM,GACvB,EAAW,GAAY,UACvB,CAbO,GAuBE,EACX,GACkD,CAClD,GAAI,OAAO,GAAY,SACrB,MAAU,MAAM,2BAA2B,CAM7C,IAAM,EAAU,CAAC,GAAG,EAAQ,SADX,6CAC6B,CAAC,CAEzC,EAA4D,EAAE,CAsCpE,OApCA,EAAQ,QAAS,GAAU,CACzB,IAAM,EAAY,CAAC,CAAC,EAAM,GACpB,EAAU,EAAM,GAChB,EAAmB,EAAM,GACzB,EAAgB,CAAC,CAAC,EAAM,GAG9B,GAAK,EAAgC,SAAS,EAAQ,aAAa,CAAC,CAAE,CACpE,EAAW,GAAW,GACtB,OAYF,GATK,EAAW,KACd,EAAW,GAAW,EAAE,EAItB,EAAW,KAAa,IAIxB,EACF,OAIF,IAAM,EAAa,EAAgB,EAAiB,CAC9C,EAAe,EAAW,GAChC,OAAO,OAAO,EAAc,EAAW,CAGlC,IACH,EAAa,SAAW,WAE1B,CAEK,GCxCI,GAIX,EACA,IAyCO,EAAe,EAAS,KAAM,EAAS,CAC5C,UAxC0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SAAU,CAC/B,GAAM,CAAE,UAAW,EAAa,EAAQ,CAExC,IAAK,IAAM,KAAS,EACd,EAAM,OAAS,QACjB,QAAQ,MAAM,mBAAmB,EAAM,UAAU,CAEjD,QAAQ,KAAK,mBAAmB,EAAM,UAAU,CAIpD,OAAO,EAAwB,EAAQ,CAGzC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACd,EAAyB,MAAO,EAAuC,EAGvE,OAAO,GAAkB,SAC3B,OAAO,EAAwB,EAAc,CAG/C,GAAI,CACF,OAAO,EAAwB,KAAK,UAAU,EAAQ,CAAC,MAC5C,CACX,MAAO,EAAE,KAKU,CACtB,CAAC"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getStorageAttributes as ee}from"./getStorageAttributes.mjs";import{getCondition as te}from"./interpreter/getCondition.mjs";import{deepTransformNode as ne}from"./interpreter/getContent/deepTransform.mjs";import{findMatchingCondition as e,getEnumeration as t}from"./interpreter/getEnumeration.mjs";import{getDictionary as n}from"./interpreter/getDictionary.mjs";import{getIntlayer as r}from"./interpreter/getIntlayer.mjs";import{getNesting as i}from"./interpreter/getNesting.mjs";import{getTranslation as a}from"./interpreter/getTranslation.mjs";import{conditionPlugin as o,enumerationPlugin as s,filePlugin as c,genderPlugin as l,insertionPlugin as u,nestedPlugin as d,translationPlugin as f}from"./interpreter/getContent/plugins.mjs";import{getBasePlugins as p,getContent as m}from"./interpreter/getContent/getContent.mjs";import{getHTML as h}from"./interpreter/getHTML.mjs";import{splitInsertionTemplate as g}from"./interpreter/splitAndJoinInsertion.mjs";import{getFilteredLocalesContent as _,getFilteredLocalesDictionary as v}from"./deepTransformPlugins/getFilteredLocalesContent.mjs";import{cond as y}from"./transpiler/condition/condition.mjs";import{enu as b}from"./transpiler/enumeration/enumeration.mjs";import{gender as x}from"./transpiler/gender/gender.mjs";import{VOID_ELEMENTS as S,validateHTML as C}from"./transpiler/html/validateHTML.mjs";import{html as w}from"./transpiler/html/html.mjs";import{HTML_TAGS as T}from"./transpiler/html/htmlTags.mjs";import{getInsertionValues as E}from"./transpiler/insertion/getInsertionValues.mjs";import{insert as D}from"./transpiler/insertion/insertion.mjs";import{parseYaml as O}from"./utils/parseYaml.mjs";import{getMarkdownMetadata as k}from"./transpiler/markdown/getMarkdownMetadata.mjs";import{validateMarkdown as A}from"./transpiler/markdown/validateMarkdown.mjs";import{md as j}from"./transpiler/markdown/markdown.mjs";import{nest as M}from"./transpiler/nesting/nesting.mjs";import{t as N}from"./transpiler/translation/translation.mjs";import{filterMissingTranslationsOnlyPlugin as P,getFilterMissingTranslationsContent as F,getFilterMissingTranslationsDictionary as I}from"./deepTransformPlugins/getFilterMissingTranslationsContent.mjs";import{filterTranslationsOnlyPlugin as L,getFilterTranslationsOnlyContent as R,getFilterTranslationsOnlyDictionary as z}from"./deepTransformPlugins/getFilterTranslationsOnlyContent.mjs";import{getLocalizedContent as B,getPerLocaleDictionary as V}from"./deepTransformPlugins/getLocalizedContent.mjs";import{buildMaskPlugin as H,getMaskContent as U}from"./deepTransformPlugins/getMaskContent.mjs";import{checkMissingLocalesPlugin as W,getMissingLocalesContent as G,getMissingLocalesContentFromDictionary as K}from"./deepTransformPlugins/getMissingLocalesContent.mjs";import{getMultilingualDictionary as q}from"./deepTransformPlugins/getMultilingualDictionary.mjs";import{getReplacedValuesContent as J}from"./deepTransformPlugins/getReplacedValuesContent.mjs";import{getSplittedContent as Y,getSplittedDictionaryContent as X}from"./deepTransformPlugins/getSplittedContent.mjs";import{insertContentInDictionary as Z}from"./deepTransformPlugins/insertContentInDictionary.mjs";import{editDictionaryByKeyPath as re}from"./dictionaryManipulator/editDictionaryByKeyPath.mjs";import{getContentNodeByKeyPath as ie}from"./dictionaryManipulator/getContentNodeByKeyPath.mjs";import{getDefaultNode as ae}from"./dictionaryManipulator/getDefaultNode.mjs";import{getEmptyNode as oe}from"./dictionaryManipulator/getEmptyNode.mjs";import{getNodeChildren as se}from"./dictionaryManipulator/getNodeChildren.mjs";import{isValidElement as ce}from"./utils/isValidReactElement.mjs";import{getNodeType as le}from"./dictionaryManipulator/getNodeType.mjs";import{mergeDictionaries as ue}from"./dictionaryManipulator/mergeDictionaries.mjs";import{orderDictionaries as de}from"./dictionaryManipulator/orderDictionaries.mjs";import{normalizeDictionaries as fe,normalizeDictionary as pe}from"./dictionaryManipulator/normalizeDictionary.mjs";import{removeContentNodeByKeyPath as me}from"./dictionaryManipulator/removeContentNodeByKeyPath.mjs";import{renameContentNodeByKeyPath as he}from"./dictionaryManipulator/renameContentNodeByKeyPath.mjs";import{updateNodeChildren as ge}from"./dictionaryManipulator/updateNodeChildren.mjs";import{CachedIntl as Q,bindIntl as _e,createCachedIntl as ve}from"./utils/intl.mjs";import{compact as ye}from"./formatters/compact.mjs";import{currency as be}from"./formatters/currency.mjs";import{date as xe}from"./formatters/date.mjs";import{list as Se}from"./formatters/list.mjs";import{number as Ce}from"./formatters/number.mjs";import{percentage as we}from"./formatters/percentage.mjs";import{relativeTime as Te}from"./formatters/relativeTime.mjs";import{units as Ee}from"./formatters/units.mjs";import{getCookie as De}from"./utils/getCookie.mjs";import{LocaleStorage as Oe,getLocaleFromStorage as ke,setLocaleInStorage as Ae}from"./utils/localeStorage.mjs";import{localeResolver as je}from"./localization/localeResolver.mjs";import{localeDetector as Me}from"./localization/localeDetector.mjs";import{getBrowserLocale as Ne,localeStorageOptions as Pe}from"./localization/getBrowserLocale.mjs";import{getHTMLTextDir as Fe}from"./localization/getHTMLTextDir.mjs";import{getLocale as Ie}from"./localization/getLocale.mjs";import{checkIsURLAbsolute as Le}from"./utils/checkIsURLAbsolute.mjs";import{getLocaleFromPath as Re}from"./localization/getLocaleFromPath.mjs";import{getLocaleLang as ze}from"./localization/getLocaleLang.mjs";import{getLocaleName as Be}from"./localization/getLocaleName.mjs";import{getPathWithoutLocale as Ve}from"./localization/getPathWithoutLocale.mjs";import{getPrefix as He}from"./localization/getPrefix.mjs";import{getCanonicalPath as Ue,getInternalPath as We,getLocalizedPath as Ge,getRewritePath as Ke,getRewriteRules as qe}from"./localization/rewriteUtils.mjs";import{getLocalizedUrl as Je}from"./localization/getLocalizedUrl.mjs";import{getMultilingualUrls as Ye}from"./localization/getMultilingualUrls.mjs";import{localeFlatMap as Xe,localeMap as Ze,localeRecord as Qe}from"./localization/localeMapper.mjs";import{validatePrefix as $e}from"./localization/validatePrefix.mjs";import{ATTRIBUTES_TO_SANITIZE as et,ATTRIBUTE_TO_NODE_PROP_MAP as tt,ATTR_EXTRACTOR_R as nt,BLOCKQUOTE_ALERT_R as rt,BLOCKQUOTE_R as it,BLOCKQUOTE_TRIM_LEFT_MULTILINE_R as at,BLOCK_END_R as ot,BREAK_LINE_R as st,BREAK_THEMATIC_R as ct,CAPTURE_LETTER_AFTER_HYPHEN as lt,CODE_BLOCK_FENCED_R as ut,CODE_BLOCK_R as dt,CODE_INLINE_R as ft,CONSECUTIVE_NEWLINE_R as pt,CR_NEWLINE_R as mt,CUSTOM_COMPONENT_R as ht,DO_NOT_PROCESS_HTML_ELEMENTS as gt,DURATION_DELAY_TRIGGER as $,FOOTNOTE_R as _t,FOOTNOTE_REFERENCE_R as vt,FORMFEED_R as yt,FRONT_MATTER_R as bt,GFM_TASK_R as xt,HEADING_ATX_COMPLIANT_R as St,HEADING_R as Ct,HEADING_SETEXT_R as wt,HTML_BLOCK_ELEMENT_R as Tt,HTML_CHAR_CODE_R as Et,HTML_COMMENT_R as Dt,HTML_CUSTOM_ATTR_R as Ot,HTML_LEFT_TRIM_AMOUNT_R as kt,HTML_SELF_CLOSING_ELEMENT_R as At,INLINE_SKIP_R as jt,INTERPOLATION_R as Mt,LINK_AUTOLINK_BARE_URL_R as Nt,LINK_AUTOLINK_R as Pt,LIST_LOOKBEHIND_R as Ft,LOOKAHEAD as It,NAMED_CODES_TO_UNICODE as Lt,NP_TABLE_R as Rt,ORDERED as zt,ORDERED_LIST_BULLET as Bt,ORDERED_LIST_ITEM_PREFIX as Vt,ORDERED_LIST_ITEM_PREFIX_R as Ht,ORDERED_LIST_ITEM_R as Ut,ORDERED_LIST_R as Wt,PARAGRAPH_R as Gt,Priority as Kt,REFERENCE_IMAGE_OR_LINK as qt,REFERENCE_IMAGE_R as Jt,REFERENCE_LINK_R as Yt,RuleType as Xt,SHORTCODE_R as Zt,SHOULD_RENDER_AS_BLOCK_R as Qt,TABLE_CENTER_ALIGN as $t,TABLE_LEFT_ALIGN as en,TABLE_RIGHT_ALIGN as tn,TABLE_TRIM_PIPES as nn,TAB_R as rn,TEXT_BOLD_R as an,TEXT_EMPHASIZED_R as on,TEXT_ESCAPED_R as sn,TEXT_MARKED_R as cn,TEXT_PLAIN_R as ln,TEXT_STRIKETHROUGHED_R as un,TRIM_STARTING_NEWLINES as dn,UNESCAPE_R as fn,UNORDERED as pn,UNORDERED_LIST_BULLET as mn,UNORDERED_LIST_ITEM_PREFIX as hn,UNORDERED_LIST_ITEM_PREFIX_R as gn,UNORDERED_LIST_ITEM_R as _n,UNORDERED_LIST_R as vn,generateListItemPrefix as yn,generateListItemPrefixRegex as bn,generateListItemRegex as xn,generateListRegex as Sn}from"./markdown/constants.mjs";import{allowInline as Cn,anyScopeRegex as wn,attributeValueToNodePropValue as Tn,blockRegex as En,captureNothing as Dn,cx as On,get as kn,inlineRegex as An,normalizeAttributeKey as jn,normalizeWhitespace as Mn,parseBlock as Nn,parseCaptureInline as Pn,parseInline as Fn,parseSimpleInline as In,parseStyleAttribute as Ln,parseTableAlign as Rn,parseTableAlignCapture as zn,parseTableCells as Bn,parseTableRow as Vn,qualifies as Hn,renderNothing as Un,sanitizer as Wn,simpleInlineRegex as Gn,slugify as Kn,some as qn,startsWith as Jn,trimEnd as Yn,trimLeadingWhitespaceOutsideFences as Xn,unescapeString as Zn,unquote as Qn}from"./markdown/utils.mjs";import{parserFor as $n}from"./markdown/parser.mjs";import{createRenderer as er,renderFor as tr}from"./markdown/renderer.mjs";import{compile as nr,compileWithOptions as rr,createCompiler as ir}from"./markdown/compiler.mjs";import{icuToIntlayerFormatter as ar,intlayerToICUFormatter as or}from"./messageFormat/ICU.mjs";import{i18nextToIntlayerFormatter as sr,intlayerToI18nextFormatter as cr}from"./messageFormat/i18next.mjs";import{intlayerToVueI18nFormatter as lr,vueI18nToIntlayerFormatter as ur}from"./messageFormat/vue-i18n.mjs";import{isSameKeyPath as dr}from"./utils/isSameKeyPath.mjs";export{et as ATTRIBUTES_TO_SANITIZE,tt as ATTRIBUTE_TO_NODE_PROP_MAP,nt as ATTR_EXTRACTOR_R,rt as BLOCKQUOTE_ALERT_R,it as BLOCKQUOTE_R,at as BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,ot as BLOCK_END_R,st as BREAK_LINE_R,ct as BREAK_THEMATIC_R,lt as CAPTURE_LETTER_AFTER_HYPHEN,ut as CODE_BLOCK_FENCED_R,dt as CODE_BLOCK_R,ft as CODE_INLINE_R,pt as CONSECUTIVE_NEWLINE_R,mt as CR_NEWLINE_R,ht as CUSTOM_COMPONENT_R,Q as CachedIntl,Q as Intl,gt as DO_NOT_PROCESS_HTML_ELEMENTS,$ as DURATION_DELAY_TRIGGER,_t as FOOTNOTE_R,vt as FOOTNOTE_REFERENCE_R,yt as FORMFEED_R,bt as FRONT_MATTER_R,xt as GFM_TASK_R,St as HEADING_ATX_COMPLIANT_R,Ct as HEADING_R,wt as HEADING_SETEXT_R,Tt as HTML_BLOCK_ELEMENT_R,Et as HTML_CHAR_CODE_R,Dt as HTML_COMMENT_R,Ot as HTML_CUSTOM_ATTR_R,kt as HTML_LEFT_TRIM_AMOUNT_R,At as HTML_SELF_CLOSING_ELEMENT_R,T as HTML_TAGS,jt as INLINE_SKIP_R,Mt as INTERPOLATION_R,Nt as LINK_AUTOLINK_BARE_URL_R,Pt as LINK_AUTOLINK_R,Ft as LIST_LOOKBEHIND_R,It as LOOKAHEAD,Oe as LocaleStorage,Lt as NAMED_CODES_TO_UNICODE,Rt as NP_TABLE_R,zt as ORDERED,Bt as ORDERED_LIST_BULLET,Vt as ORDERED_LIST_ITEM_PREFIX,Ht as ORDERED_LIST_ITEM_PREFIX_R,Ut as ORDERED_LIST_ITEM_R,Wt as ORDERED_LIST_R,Gt as PARAGRAPH_R,Kt as Priority,qt as REFERENCE_IMAGE_OR_LINK,Jt as REFERENCE_IMAGE_R,Yt as REFERENCE_LINK_R,Xt as RuleType,Zt as SHORTCODE_R,Qt as SHOULD_RENDER_AS_BLOCK_R,$t as TABLE_CENTER_ALIGN,en as TABLE_LEFT_ALIGN,tn as TABLE_RIGHT_ALIGN,nn as TABLE_TRIM_PIPES,rn as TAB_R,an as TEXT_BOLD_R,on as TEXT_EMPHASIZED_R,sn as TEXT_ESCAPED_R,cn as TEXT_MARKED_R,ln as TEXT_PLAIN_R,un as TEXT_STRIKETHROUGHED_R,dn as TRIM_STARTING_NEWLINES,fn as UNESCAPE_R,pn as UNORDERED,mn as UNORDERED_LIST_BULLET,hn as UNORDERED_LIST_ITEM_PREFIX,gn as UNORDERED_LIST_ITEM_PREFIX_R,_n as UNORDERED_LIST_ITEM_R,vn as UNORDERED_LIST_R,S as VOID_ELEMENTS,Cn as allowInline,wn as anyScopeRegex,Tn as attributeValueToNodePropValue,_e as bindIntl,En as blockRegex,H as buildMaskPlugin,Dn as captureNothing,Le as checkIsURLAbsolute,W as checkMissingLocalesPlugin,ye as compact,nr as compile,rr as compileWithOptions,y as cond,o as conditionPlugin,ve as createCachedIntl,ir as createCompiler,er as createRenderer,be as currency,On as cx,xe as date,ne as deepTransformNode,re as editDictionaryByKeyPath,b as enu,s as enumerationPlugin,c as filePlugin,P as filterMissingTranslationsOnlyPlugin,L as filterTranslationsOnlyPlugin,e as findMatchingCondition,x as gender,l as genderPlugin,yn as generateListItemPrefix,bn as generateListItemPrefixRegex,xn as generateListItemRegex,Sn as generateListRegex,kn as get,p as getBasePlugins,Ne as getBrowserLocale,Ue as getCanonicalPath,te as getCondition,m as getContent,ie as getContentNodeByKeyPath,De as getCookie,ae as getDefaultNode,n as getDictionary,oe as getEmptyNode,t as getEnumeration,F as getFilterMissingTranslationsContent,I as getFilterMissingTranslationsDictionary,R as getFilterTranslationsOnlyContent,z as getFilterTranslationsOnlyDictionary,_ as getFilteredLocalesContent,v as getFilteredLocalesDictionary,h as getHTML,Fe as getHTMLTextDir,E as getInsertionValues,We as getInternalPath,r as getIntlayer,Ie as getLocale,Re as getLocaleFromPath,ke as getLocaleFromStorage,ze as getLocaleLang,Be as getLocaleName,B as getLocalizedContent,Ge as getLocalizedPath,Je as getLocalizedUrl,k as getMarkdownMetadata,U as getMaskContent,G as getMissingLocalesContent,K as getMissingLocalesContentFromDictionary,q as getMultilingualDictionary,Ye as getMultilingualUrls,i as getNesting,se as getNodeChildren,le as getNodeType,Ve as getPathWithoutLocale,V as getPerLocaleDictionary,He as getPrefix,J as getReplacedValuesContent,Ke as getRewritePath,qe as getRewriteRules,Y as getSplittedContent,X as getSplittedDictionaryContent,ee as getStorageAttributes,a as getTranslation,w as html,sr as i18nextToIntlayerFormatter,ar as icuToIntlayerFormatter,An as inlineRegex,D as insert,Z as insertContentInDictionary,u as insertionPlugin,cr as intlayerToI18nextFormatter,or as intlayerToICUFormatter,lr as intlayerToVueI18nFormatter,dr as isSameKeyPath,ce as isValidElement,Se as list,Me as localeDetector,Xe as localeFlatMap,Ze as localeMap,Qe as localeRecord,je as localeResolver,Pe as localeStorageOptions,j as md,ue as mergeDictionaries,M as nest,d as nestedPlugin,jn as normalizeAttributeKey,fe as normalizeDictionaries,pe as normalizeDictionary,Mn as normalizeWhitespace,Ce as number,de as orderDictionaries,Nn as parseBlock,Pn as parseCaptureInline,Fn as parseInline,In as parseSimpleInline,Ln as parseStyleAttribute,Rn as parseTableAlign,zn as parseTableAlignCapture,Bn as parseTableCells,Vn as parseTableRow,O as parseYaml,$n as parserFor,we as percentage,Hn as qualifies,Te as relativeTime,me as removeContentNodeByKeyPath,he as renameContentNodeByKeyPath,tr as renderFor,Un as renderNothing,Wn as sanitizer,Ae as setLocaleInStorage,Gn as simpleInlineRegex,Kn as slugify,qn as some,g as splitInsertionTemplate,Jn as startsWith,N as t,f as translationPlugin,Yn as trimEnd,Xn as trimLeadingWhitespaceOutsideFences,Zn as unescapeString,Ee as units,Qn as unquote,ge as updateNodeChildren,C as validateHTML,A as validateMarkdown,$e as validatePrefix,ur as vueI18nToIntlayerFormatter};
|
|
1
|
+
import{getStorageAttributes as ee}from"./getStorageAttributes.mjs";import{getCondition as te}from"./interpreter/getCondition.mjs";import{deepTransformNode as ne}from"./interpreter/getContent/deepTransform.mjs";import{findMatchingCondition as e,getEnumeration as t}from"./interpreter/getEnumeration.mjs";import{a as n,c as r,d as i,f as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f,u as p}from"./getContent-DKqtIZGL.mjs";import{getTranslation as m}from"./interpreter/getTranslation.mjs";import{getHTML as h}from"./interpreter/getHTML.mjs";import{splitInsertionTemplate as g}from"./interpreter/splitAndJoinInsertion.mjs";import{getFilteredLocalesContent as _,getFilteredLocalesDictionary as v}from"./deepTransformPlugins/getFilteredLocalesContent.mjs";import{cond as y}from"./transpiler/condition/condition.mjs";import{enu as b}from"./transpiler/enumeration/enumeration.mjs";import{gender as x}from"./transpiler/gender/gender.mjs";import{t as S}from"./html-3bo80xzx.mjs";import{VOID_ELEMENTS as C,validateHTML as w}from"./transpiler/html/validateHTML.mjs";import{HTML_TAGS as T}from"./transpiler/html/htmlTags.mjs";import{getInsertionValues as E}from"./transpiler/insertion/getInsertionValues.mjs";import{insert as D}from"./transpiler/insertion/insertion.mjs";import{parseYaml as O}from"./utils/parseYaml.mjs";import{getMarkdownMetadata as k}from"./transpiler/markdown/getMarkdownMetadata.mjs";import{validateMarkdown as A}from"./transpiler/markdown/validateMarkdown.mjs";import{md as j}from"./transpiler/markdown/markdown.mjs";import{nest as M}from"./transpiler/nesting/nesting.mjs";import{t as N}from"./transpiler/translation/translation.mjs";import{filterMissingTranslationsOnlyPlugin as P,getFilterMissingTranslationsContent as F,getFilterMissingTranslationsDictionary as I}from"./deepTransformPlugins/getFilterMissingTranslationsContent.mjs";import{filterTranslationsOnlyPlugin as L,getFilterTranslationsOnlyContent as R,getFilterTranslationsOnlyDictionary as z}from"./deepTransformPlugins/getFilterTranslationsOnlyContent.mjs";import{getLocalizedContent as B,getPerLocaleDictionary as V}from"./deepTransformPlugins/getLocalizedContent.mjs";import{buildMaskPlugin as H,getMaskContent as U}from"./deepTransformPlugins/getMaskContent.mjs";import{checkMissingLocalesPlugin as W,getMissingLocalesContent as G,getMissingLocalesContentFromDictionary as K}from"./deepTransformPlugins/getMissingLocalesContent.mjs";import{getMultilingualDictionary as q}from"./deepTransformPlugins/getMultilingualDictionary.mjs";import{getReplacedValuesContent as J}from"./deepTransformPlugins/getReplacedValuesContent.mjs";import{getSplittedContent as Y,getSplittedDictionaryContent as X}from"./deepTransformPlugins/getSplittedContent.mjs";import{insertContentInDictionary as Z}from"./deepTransformPlugins/insertContentInDictionary.mjs";import{editDictionaryByKeyPath as re}from"./dictionaryManipulator/editDictionaryByKeyPath.mjs";import{getContentNodeByKeyPath as ie}from"./dictionaryManipulator/getContentNodeByKeyPath.mjs";import{getDefaultNode as ae}from"./dictionaryManipulator/getDefaultNode.mjs";import{getEmptyNode as oe}from"./dictionaryManipulator/getEmptyNode.mjs";import{getNodeChildren as se}from"./dictionaryManipulator/getNodeChildren.mjs";import{isValidElement as ce}from"./utils/isValidReactElement.mjs";import{getNodeType as le}from"./dictionaryManipulator/getNodeType.mjs";import{mergeDictionaries as ue}from"./dictionaryManipulator/mergeDictionaries.mjs";import{orderDictionaries as de}from"./dictionaryManipulator/orderDictionaries.mjs";import{normalizeDictionaries as fe,normalizeDictionary as pe}from"./dictionaryManipulator/normalizeDictionary.mjs";import{removeContentNodeByKeyPath as me}from"./dictionaryManipulator/removeContentNodeByKeyPath.mjs";import{renameContentNodeByKeyPath as he}from"./dictionaryManipulator/renameContentNodeByKeyPath.mjs";import{updateNodeChildren as ge}from"./dictionaryManipulator/updateNodeChildren.mjs";import"./dictionaryManipulator/index.mjs";import{CachedIntl as Q,bindIntl as _e,createCachedIntl as ve}from"./utils/intl.mjs";import{compact as ye}from"./formatters/compact.mjs";import{currency as be}from"./formatters/currency.mjs";import{date as xe}from"./formatters/date.mjs";import{list as Se}from"./formatters/list.mjs";import{number as Ce}from"./formatters/number.mjs";import{percentage as we}from"./formatters/percentage.mjs";import{relativeTime as Te}from"./formatters/relativeTime.mjs";import{units as Ee}from"./formatters/units.mjs";import"./formatters/index.mjs";import{getCookie as De}from"./utils/getCookie.mjs";import{LocaleStorage as Oe,getLocaleFromStorage as ke,setLocaleInStorage as Ae}from"./utils/localeStorage.mjs";import{localeResolver as je}from"./localization/localeResolver.mjs";import{localeDetector as Me}from"./localization/localeDetector.mjs";import{getBrowserLocale as Ne,localeStorageOptions as Pe}from"./localization/getBrowserLocale.mjs";import{getHTMLTextDir as Fe}from"./localization/getHTMLTextDir.mjs";import{getLocale as Ie}from"./localization/getLocale.mjs";import{checkIsURLAbsolute as Le}from"./utils/checkIsURLAbsolute.mjs";import{getLocaleFromPath as Re}from"./localization/getLocaleFromPath.mjs";import{getLocaleLang as ze}from"./localization/getLocaleLang.mjs";import{getLocaleName as Be}from"./localization/getLocaleName.mjs";import{getPathWithoutLocale as Ve}from"./localization/getPathWithoutLocale.mjs";import{getPrefix as He}from"./localization/getPrefix.mjs";import{getCanonicalPath as Ue,getInternalPath as We,getLocalizedPath as Ge,getRewritePath as Ke,getRewriteRules as qe}from"./localization/rewriteUtils.mjs";import{getLocalizedUrl as Je}from"./localization/getLocalizedUrl.mjs";import{getMultilingualUrls as Ye}from"./localization/getMultilingualUrls.mjs";import{localeFlatMap as Xe,localeMap as Ze,localeRecord as Qe}from"./localization/localeMapper.mjs";import{validatePrefix as $e}from"./localization/validatePrefix.mjs";import"./localization/index.mjs";import{ATTRIBUTES_TO_SANITIZE as et,ATTRIBUTE_TO_NODE_PROP_MAP as tt,ATTR_EXTRACTOR_R as nt,BLOCKQUOTE_ALERT_R as rt,BLOCKQUOTE_R as it,BLOCKQUOTE_TRIM_LEFT_MULTILINE_R as at,BLOCK_END_R as ot,BREAK_LINE_R as st,BREAK_THEMATIC_R as ct,CAPTURE_LETTER_AFTER_HYPHEN as lt,CODE_BLOCK_FENCED_R as ut,CODE_BLOCK_R as dt,CODE_INLINE_R as ft,CONSECUTIVE_NEWLINE_R as pt,CR_NEWLINE_R as mt,CUSTOM_COMPONENT_R as ht,DO_NOT_PROCESS_HTML_ELEMENTS as gt,DURATION_DELAY_TRIGGER as $,FOOTNOTE_R as _t,FOOTNOTE_REFERENCE_R as vt,FORMFEED_R as yt,FRONT_MATTER_R as bt,GFM_TASK_R as xt,HEADING_ATX_COMPLIANT_R as St,HEADING_R as Ct,HEADING_SETEXT_R as wt,HTML_BLOCK_ELEMENT_R as Tt,HTML_CHAR_CODE_R as Et,HTML_COMMENT_R as Dt,HTML_CUSTOM_ATTR_R as Ot,HTML_LEFT_TRIM_AMOUNT_R as kt,HTML_SELF_CLOSING_ELEMENT_R as At,INLINE_SKIP_R as jt,INTERPOLATION_R as Mt,LINK_AUTOLINK_BARE_URL_R as Nt,LINK_AUTOLINK_R as Pt,LIST_LOOKBEHIND_R as Ft,LOOKAHEAD as It,NAMED_CODES_TO_UNICODE as Lt,NP_TABLE_R as Rt,ORDERED as zt,ORDERED_LIST_BULLET as Bt,ORDERED_LIST_ITEM_PREFIX as Vt,ORDERED_LIST_ITEM_PREFIX_R as Ht,ORDERED_LIST_ITEM_R as Ut,ORDERED_LIST_R as Wt,PARAGRAPH_R as Gt,Priority as Kt,REFERENCE_IMAGE_OR_LINK as qt,REFERENCE_IMAGE_R as Jt,REFERENCE_LINK_R as Yt,RuleType as Xt,SHORTCODE_R as Zt,SHOULD_RENDER_AS_BLOCK_R as Qt,TABLE_CENTER_ALIGN as $t,TABLE_LEFT_ALIGN as en,TABLE_RIGHT_ALIGN as tn,TABLE_TRIM_PIPES as nn,TAB_R as rn,TEXT_BOLD_R as an,TEXT_EMPHASIZED_R as on,TEXT_ESCAPED_R as sn,TEXT_MARKED_R as cn,TEXT_PLAIN_R as ln,TEXT_STRIKETHROUGHED_R as un,TRIM_STARTING_NEWLINES as dn,UNESCAPE_R as fn,UNORDERED as pn,UNORDERED_LIST_BULLET as mn,UNORDERED_LIST_ITEM_PREFIX as hn,UNORDERED_LIST_ITEM_PREFIX_R as gn,UNORDERED_LIST_ITEM_R as _n,UNORDERED_LIST_R as vn,generateListItemPrefix as yn,generateListItemPrefixRegex as bn,generateListItemRegex as xn,generateListRegex as Sn}from"./markdown/constants.mjs";import{allowInline as Cn,anyScopeRegex as wn,attributeValueToNodePropValue as Tn,blockRegex as En,captureNothing as Dn,cx as On,get as kn,inlineRegex as An,normalizeAttributeKey as jn,normalizeWhitespace as Mn,parseBlock as Nn,parseCaptureInline as Pn,parseInline as Fn,parseSimpleInline as In,parseStyleAttribute as Ln,parseTableAlign as Rn,parseTableAlignCapture as zn,parseTableCells as Bn,parseTableRow as Vn,qualifies as Hn,renderNothing as Un,sanitizer as Wn,simpleInlineRegex as Gn,slugify as Kn,some as qn,startsWith as Jn,trimEnd as Yn,trimLeadingWhitespaceOutsideFences as Xn,unescapeString as Zn,unquote as Qn}from"./markdown/utils.mjs";import{parserFor as $n}from"./markdown/parser.mjs";import{createRenderer as er,renderFor as tr}from"./markdown/renderer.mjs";import{compile as nr,compileWithOptions as rr,createCompiler as ir}from"./markdown/compiler.mjs";import"./markdown/index.mjs";import{icuToIntlayerFormatter as ar,intlayerToICUFormatter as or}from"./messageFormat/ICU.mjs";import{i18nextToIntlayerFormatter as sr,intlayerToI18nextFormatter as cr}from"./messageFormat/i18next.mjs";import{intlayerToVueI18nFormatter as lr,vueI18nToIntlayerFormatter as ur}from"./messageFormat/vue-i18n.mjs";import"./messageFormat/index.mjs";import{isSameKeyPath as dr}from"./utils/isSameKeyPath.mjs";import"./utils/index.mjs";export{et as ATTRIBUTES_TO_SANITIZE,tt as ATTRIBUTE_TO_NODE_PROP_MAP,nt as ATTR_EXTRACTOR_R,rt as BLOCKQUOTE_ALERT_R,it as BLOCKQUOTE_R,at as BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,ot as BLOCK_END_R,st as BREAK_LINE_R,ct as BREAK_THEMATIC_R,lt as CAPTURE_LETTER_AFTER_HYPHEN,ut as CODE_BLOCK_FENCED_R,dt as CODE_BLOCK_R,ft as CODE_INLINE_R,pt as CONSECUTIVE_NEWLINE_R,mt as CR_NEWLINE_R,ht as CUSTOM_COMPONENT_R,Q as CachedIntl,Q as Intl,gt as DO_NOT_PROCESS_HTML_ELEMENTS,$ as DURATION_DELAY_TRIGGER,_t as FOOTNOTE_R,vt as FOOTNOTE_REFERENCE_R,yt as FORMFEED_R,bt as FRONT_MATTER_R,xt as GFM_TASK_R,St as HEADING_ATX_COMPLIANT_R,Ct as HEADING_R,wt as HEADING_SETEXT_R,Tt as HTML_BLOCK_ELEMENT_R,Et as HTML_CHAR_CODE_R,Dt as HTML_COMMENT_R,Ot as HTML_CUSTOM_ATTR_R,kt as HTML_LEFT_TRIM_AMOUNT_R,At as HTML_SELF_CLOSING_ELEMENT_R,T as HTML_TAGS,jt as INLINE_SKIP_R,Mt as INTERPOLATION_R,Nt as LINK_AUTOLINK_BARE_URL_R,Pt as LINK_AUTOLINK_R,Ft as LIST_LOOKBEHIND_R,It as LOOKAHEAD,Oe as LocaleStorage,Lt as NAMED_CODES_TO_UNICODE,Rt as NP_TABLE_R,zt as ORDERED,Bt as ORDERED_LIST_BULLET,Vt as ORDERED_LIST_ITEM_PREFIX,Ht as ORDERED_LIST_ITEM_PREFIX_R,Ut as ORDERED_LIST_ITEM_R,Wt as ORDERED_LIST_R,Gt as PARAGRAPH_R,Kt as Priority,qt as REFERENCE_IMAGE_OR_LINK,Jt as REFERENCE_IMAGE_R,Yt as REFERENCE_LINK_R,Xt as RuleType,Zt as SHORTCODE_R,Qt as SHOULD_RENDER_AS_BLOCK_R,$t as TABLE_CENTER_ALIGN,en as TABLE_LEFT_ALIGN,tn as TABLE_RIGHT_ALIGN,nn as TABLE_TRIM_PIPES,rn as TAB_R,an as TEXT_BOLD_R,on as TEXT_EMPHASIZED_R,sn as TEXT_ESCAPED_R,cn as TEXT_MARKED_R,ln as TEXT_PLAIN_R,un as TEXT_STRIKETHROUGHED_R,dn as TRIM_STARTING_NEWLINES,fn as UNESCAPE_R,pn as UNORDERED,mn as UNORDERED_LIST_BULLET,hn as UNORDERED_LIST_ITEM_PREFIX,gn as UNORDERED_LIST_ITEM_PREFIX_R,_n as UNORDERED_LIST_ITEM_R,vn as UNORDERED_LIST_R,C as VOID_ELEMENTS,Cn as allowInline,wn as anyScopeRegex,Tn as attributeValueToNodePropValue,_e as bindIntl,En as blockRegex,H as buildMaskPlugin,Dn as captureNothing,Le as checkIsURLAbsolute,W as checkMissingLocalesPlugin,ye as compact,nr as compile,rr as compileWithOptions,y as cond,u as conditionPlugin,ve as createCachedIntl,ir as createCompiler,er as createRenderer,be as currency,On as cx,xe as date,ne as deepTransformNode,re as editDictionaryByKeyPath,b as enu,o as enumerationPlugin,n as filePlugin,P as filterMissingTranslationsOnlyPlugin,L as filterTranslationsOnlyPlugin,e as findMatchingCondition,x as gender,l as genderPlugin,yn as generateListItemPrefix,bn as generateListItemPrefixRegex,xn as generateListItemRegex,Sn as generateListRegex,kn as get,f as getBasePlugins,Ne as getBrowserLocale,Ue as getCanonicalPath,te as getCondition,c as getContent,ie as getContentNodeByKeyPath,De as getCookie,ae as getDefaultNode,a as getDictionary,oe as getEmptyNode,t as getEnumeration,F as getFilterMissingTranslationsContent,I as getFilterMissingTranslationsDictionary,R as getFilterTranslationsOnlyContent,z as getFilterTranslationsOnlyDictionary,_ as getFilteredLocalesContent,v as getFilteredLocalesDictionary,h as getHTML,Fe as getHTMLTextDir,E as getInsertionValues,We as getInternalPath,i as getIntlayer,Ie as getLocale,Re as getLocaleFromPath,ke as getLocaleFromStorage,ze as getLocaleLang,Be as getLocaleName,B as getLocalizedContent,Ge as getLocalizedPath,Je as getLocalizedUrl,k as getMarkdownMetadata,U as getMaskContent,G as getMissingLocalesContent,K as getMissingLocalesContentFromDictionary,q as getMultilingualDictionary,Ye as getMultilingualUrls,p as getNesting,se as getNodeChildren,le as getNodeType,Ve as getPathWithoutLocale,V as getPerLocaleDictionary,He as getPrefix,J as getReplacedValuesContent,Ke as getRewritePath,qe as getRewriteRules,Y as getSplittedContent,X as getSplittedDictionaryContent,ee as getStorageAttributes,m as getTranslation,S as html,sr as i18nextToIntlayerFormatter,ar as icuToIntlayerFormatter,An as inlineRegex,D as insert,Z as insertContentInDictionary,d as insertionPlugin,cr as intlayerToI18nextFormatter,or as intlayerToICUFormatter,lr as intlayerToVueI18nFormatter,dr as isSameKeyPath,ce as isValidElement,Se as list,Me as localeDetector,Xe as localeFlatMap,Ze as localeMap,Qe as localeRecord,je as localeResolver,Pe as localeStorageOptions,j as md,ue as mergeDictionaries,M as nest,r as nestedPlugin,jn as normalizeAttributeKey,fe as normalizeDictionaries,pe as normalizeDictionary,Mn as normalizeWhitespace,Ce as number,de as orderDictionaries,Nn as parseBlock,Pn as parseCaptureInline,Fn as parseInline,In as parseSimpleInline,Ln as parseStyleAttribute,Rn as parseTableAlign,zn as parseTableAlignCapture,Bn as parseTableCells,Vn as parseTableRow,O as parseYaml,$n as parserFor,we as percentage,Hn as qualifies,Te as relativeTime,me as removeContentNodeByKeyPath,he as renameContentNodeByKeyPath,tr as renderFor,Un as renderNothing,Wn as sanitizer,Ae as setLocaleInStorage,Gn as simpleInlineRegex,Kn as slugify,qn as some,g as splitInsertionTemplate,Jn as startsWith,N as t,s as translationPlugin,Yn as trimEnd,Xn as trimLeadingWhitespaceOutsideFences,Zn as unescapeString,Ee as units,Qn as unquote,ge as updateNodeChildren,w as validateHTML,A as validateMarkdown,$e as validatePrefix,ur as vueI18nToIntlayerFormatter};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=getContent.mjs.map
|
|
1
|
+
import{n as e,t}from"../../getContent-DKqtIZGL.mjs";export{t as getBasePlugins,e as getContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{deepTransformNode as e}from"./deepTransform.mjs";import{
|
|
1
|
+
import{deepTransformNode as e}from"./deepTransform.mjs";import{a as t,c as n,i as r,l as i,n as a,o,r as s,s as c,t as l}from"../../getContent-DKqtIZGL.mjs";export{s as conditionPlugin,e as deepTransformNode,r as enumerationPlugin,t as filePlugin,o as genderPlugin,l as getBasePlugins,a as getContent,c as insertionPlugin,n as nestedPlugin,i as translationPlugin};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=plugins.mjs.map
|
|
1
|
+
import{a as e,c as t,i as n,l as r,o as i,r as a,s as o}from"../../getContent-DKqtIZGL.mjs";export{a as conditionPlugin,n as enumerationPlugin,e as filePlugin,i as genderPlugin,o as insertionPlugin,t as nestedPlugin,r as translationPlugin};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=getDictionary.mjs.map
|
|
1
|
+
import{f as e}from"../getContent-DKqtIZGL.mjs";export{e as getDictionary};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=getIntlayer.mjs.map
|
|
1
|
+
import{d as e}from"../getContent-DKqtIZGL.mjs";export{e as getIntlayer};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=getNesting.mjs.map
|
|
1
|
+
import{u as e}from"../getContent-DKqtIZGL.mjs";export{e as getNesting};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCondition as e}from"./getCondition.mjs";import{deepTransformNode as t}from"./getContent/deepTransform.mjs";import{findMatchingCondition as n,getEnumeration as r}from"./getEnumeration.mjs";import{
|
|
1
|
+
import{getCondition as e}from"./getCondition.mjs";import{deepTransformNode as t}from"./getContent/deepTransform.mjs";import{findMatchingCondition as n,getEnumeration as r}from"./getEnumeration.mjs";import{a as i,c as a,d as o,f as s,i as c,l,n as u,o as d,r as f,s as p,t as m,u as h}from"../getContent-DKqtIZGL.mjs";import{getTranslation as g}from"./getTranslation.mjs";import{getHTML as _}from"./getHTML.mjs";import{splitInsertionTemplate as v}from"./splitAndJoinInsertion.mjs";export{f as conditionPlugin,t as deepTransformNode,c as enumerationPlugin,i as filePlugin,n as findMatchingCondition,d as genderPlugin,m as getBasePlugins,e as getCondition,u as getContent,s as getDictionary,r as getEnumeration,_ as getHTML,o as getIntlayer,h as getNesting,g as getTranslation,p as insertionPlugin,a as nestedPlugin,v as splitInsertionTemplate,l as translationPlugin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getLocaleFromStorage as e}from"../utils/localeStorage.mjs";import{localeDetector as t}from"./localeDetector.mjs";import n from"@intlayer/config/built";import
|
|
1
|
+
import{getLocaleFromStorage as e}from"../utils/localeStorage.mjs";import{localeDetector as t}from"./localeDetector.mjs";import n from"@intlayer/config/built";import{ENGLISH as r}from"@intlayer/types/locales";let i=function(e){return e.Querystring=`querystring`,e.Storage=`storage`,e.Navigator=`navigator`,e.HtmlTag=`htmlTag`,e}({});const a={getCookie:e=>document.cookie.split(`;`).find(t=>t.trim().startsWith(`${e}=`))?.split(`=`)[1],getLocaleStorage:e=>localStorage.getItem(e),getSessionStorage:e=>sessionStorage.getItem(e),isCookieEnabled:!0,setCookieStore:(e,t,n)=>cookieStore.set({name:e,value:t,path:n.path,domain:n.domain,expires:n.expires,sameSite:n.sameSite}),setCookieString:(e,t)=>{document.cookie=t},setSessionStorage:(e,t)=>sessionStorage.setItem(e,t),setLocaleStorage:(e,t)=>localStorage.setItem(e,t)},o=()=>({order:[i.Querystring,i.Storage,i.Navigator,i.HtmlTag],lookupQuerystring:`locale`,htmlTag:typeof document<`u`?document.documentElement:null}),s=(r,a)=>{let o={},s=()=>{if(typeof window>`u`)return;let e=window.location.search||``,t=new URLSearchParams(e).get(a.lookupQuerystring??``);t&&(o[i.Querystring]=t)},c=()=>{if(typeof window>`u`)return;let t=e({getCookie:e=>{try{let t=document.cookie.split(`;`),n=`${e}=`,r=t.find(e=>e.trim().startsWith(n));if(r)return r.split(`=`)[1].trim()}catch{}},getSessionStorage:e=>{try{return window.sessionStorage.getItem(e)??void 0}catch{}},getLocaleStorage:e=>{try{return window.localStorage.getItem(e)??void 0}catch{}}});t&&(o[i.Storage]=t)},l=()=>{if(typeof navigator>`u`)return;let{internationalization:e}=n,r=navigator.languages??[navigator.language],a=t({"accept-language":r.join(`,`)},e.locales,e.defaultLocale);a&&(o[i.Navigator]=a)},u=()=>{let e=a.htmlTag;if(e&&typeof e.getAttribute==`function`){let r=e.getAttribute(`lang`);if(r){let{internationalization:e}=n,a=t({"accept-language":r},e.locales,e.defaultLocale);o[i.HtmlTag]=a}}},d={[i.Querystring]:s,[i.Storage]:c,[i.Navigator]:l,[i.HtmlTag]:u};return r.forEach(e=>{d[e]?.()}),o},c=(e,t)=>{let{internationalization:i}=n;for(let n of t){let t=e[n];if(t&&i.locales.includes(t))return t}return i?.defaultLocale??r},l=(e={})=>{let t={...o(),...e};return c(s(t.order??[],t),t.order??[])};export{i as LanguageDetector,l as getBrowserLocale,a as localeStorageOptions};
|
|
2
2
|
//# sourceMappingURL=getBrowserLocale.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBrowserLocale.mjs","names":[],"sources":["../../../src/localization/getBrowserLocale.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport
|
|
1
|
+
{"version":3,"file":"getBrowserLocale.mjs","names":[],"sources":["../../../src/localization/getBrowserLocale.tsx"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { ENGLISH } from '@intlayer/types/locales';\nimport {\n getLocaleFromStorage,\n type LocaleStorageOptions,\n} from '../utils/localeStorage';\nimport { localeDetector } from './localeDetector';\n\nexport enum LanguageDetector {\n Querystring = 'querystring',\n Storage = 'storage',\n Navigator = 'navigator',\n HtmlTag = 'htmlTag',\n}\n\nexport const localeStorageOptions: LocaleStorageOptions = {\n getCookie: (name: string) =>\n document.cookie\n .split(';')\n .find((c) => c.trim().startsWith(`${name}=`))\n ?.split('=')[1],\n getLocaleStorage: (name: string) => localStorage.getItem(name),\n getSessionStorage: (name: string) => sessionStorage.getItem(name),\n isCookieEnabled: true,\n setCookieStore: (name, value, attributes) =>\n cookieStore.set({\n name,\n value,\n path: attributes.path,\n domain: attributes.domain,\n expires: attributes.expires,\n sameSite: attributes.sameSite,\n }),\n setCookieString: (_name, cookie) => {\n // biome-ignore lint/suspicious/noDocumentCookie: set cookie fallback\n document.cookie = cookie;\n },\n setSessionStorage: (name, value) => sessionStorage.setItem(name, value),\n setLocaleStorage: (name, value) => localStorage.setItem(name, value),\n};\n\n// Default settings for the language detector\ntype LanguageDetectorOptions = {\n order?: LanguageDetector[];\n lookupQuerystring?: string;\n htmlTag?: HTMLElement | null;\n};\n\nconst getDefaultsOptions = (): LanguageDetectorOptions => {\n return {\n order: [\n LanguageDetector.Querystring,\n LanguageDetector.Storage,\n LanguageDetector.Navigator,\n LanguageDetector.HtmlTag,\n ],\n lookupQuerystring: 'locale',\n htmlTag: typeof document !== 'undefined' ? document.documentElement : null,\n };\n};\n\nconst detectLanguage = (\n order: string[],\n options: LanguageDetectorOptions\n): Record<LanguageDetector, Locale | undefined> => {\n const detected: Record<LanguageDetector, Locale | undefined> = {} as Record<\n LanguageDetector,\n Locale | undefined\n >;\n\n const queryStringDetector = () => {\n if (typeof window === 'undefined') return;\n const search = window.location.search || '';\n const params = new URLSearchParams(search);\n const value = params.get(options.lookupQuerystring ?? '');\n if (value) {\n detected[LanguageDetector.Querystring] = value as Locale;\n }\n };\n\n const storageDetector = () => {\n if (typeof window === 'undefined') return;\n\n const locale = getLocaleFromStorage({\n getCookie: (name: string) => {\n try {\n const cookies = document.cookie.split(';');\n const cookieName = `${name}=`;\n\n const cookie = cookies.find((cookie) =>\n cookie.trim().startsWith(cookieName)\n );\n\n if (cookie) {\n return cookie.split('=')[1].trim();\n }\n } catch {}\n return undefined;\n },\n getSessionStorage: (name: string) => {\n try {\n return window.sessionStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n getLocaleStorage: (name: string) => {\n try {\n return window.localStorage.getItem(name) ?? undefined;\n } catch {}\n return undefined;\n },\n });\n\n if (locale) {\n detected[LanguageDetector.Storage] = locale;\n }\n };\n\n const navigatorDetector = () => {\n if (typeof navigator === 'undefined') return;\n\n const { internationalization } = configuration;\n const languages = navigator.languages ?? [navigator.language];\n\n // Use localeDetector to find the best matching locale\n const locale = localeDetector(\n { 'accept-language': languages.join(',') },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n if (locale) {\n detected[LanguageDetector.Navigator] = locale;\n }\n };\n\n const htmlTagDetector = () => {\n const htmlTag = options.htmlTag;\n if (htmlTag && typeof htmlTag.getAttribute === 'function') {\n const lang = htmlTag.getAttribute('lang');\n if (lang) {\n const { internationalization } = configuration;\n\n // Validate and resolve the locale\n const locale = localeDetector(\n { 'accept-language': lang },\n internationalization.locales,\n internationalization.defaultLocale\n );\n\n detected[LanguageDetector.HtmlTag] = locale;\n }\n }\n };\n\n // Map detector names to their corresponding functions\n const detectors: Record<string, () => void> = {\n [LanguageDetector.Querystring]: queryStringDetector,\n [LanguageDetector.Storage]: storageDetector,\n [LanguageDetector.Navigator]: navigatorDetector,\n [LanguageDetector.HtmlTag]: htmlTagDetector,\n };\n\n // Use the provided order to run each detector\n order.forEach((detectorName) => {\n detectors[detectorName]?.();\n });\n\n return detected;\n};\n\nconst getFirstAvailableLocale = (\n locales: Record<LanguageDetector, Locale | undefined>,\n order: LanguageDetector[]\n): Locale => {\n const { internationalization } = configuration;\n\n for (const detector of order) {\n const locale = locales[detector];\n\n if (locale && internationalization.locales.includes(locale)) {\n return locale;\n }\n }\n\n return internationalization?.defaultLocale ?? ENGLISH;\n};\n\n/**\n * Core language detector function for browser environments.\n *\n * Detects the user's preferred locale by checking multiple sources in order:\n * 1. Query string parameter\n * 2. Storage (cookies, localStorage, sessionStorage) - uses getLocaleFromStorage\n * 3. Navigator languages - uses localeDetector\n * 4. HTML lang attribute - uses localeDetector\n *\n * @param userOptions - Optional configuration for detection order and lookup keys\n * @returns The detected locale or the default locale\n *\n * @example\n * const locale = getBrowserLocale({ order: [LanguageDetector.Storage, LanguageDetector.Navigator] });\n */\nexport const getBrowserLocale = (\n userOptions: LanguageDetectorOptions | undefined = {}\n): Locale => {\n const options = { ...getDefaultsOptions(), ...userOptions };\n\n const locales = detectLanguage(options.order ?? [], options);\n\n return getFirstAvailableLocale(locales, options.order ?? []);\n};\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{ARABIC as e,ARABIC_ALGERIA as t,ARABIC_BAHRAIN as n,ARABIC_CHAD as r,ARABIC_COMOROS as i,ARABIC_DJIBOUTI as a,ARABIC_EGYPT as o,ARABIC_IRAQ as s,ARABIC_JORDAN as c,ARABIC_KUWAIT as l,ARABIC_LEBANON as u,ARABIC_LIBYA as d,ARABIC_MAURITANIA as f,ARABIC_MOROCCO as p,ARABIC_OMAN as m,ARABIC_PALESTINE as h,ARABIC_QATAR as g,ARABIC_SAUDI_ARABIA as _,ARABIC_SOMALIA as v,ARABIC_SUDAN as y,ARABIC_SYRIA as b,ARABIC_TUNISIA as x,ARABIC_UNITED_ARAB_EMIRATES as S,ARABIC_YEMEN as C,DIVEHI as w,DIVEHI_MALDIVES as T,FARSI as E,FARSI_IRAN as D,HEBREW as O,HEBREW_ISRAEL as k,PASHTO as A,PASHTO_AFGHANISTAN as j,SYRIAC as M,SYRIAC_SYRIA as N,URDU as P,URDU_ISLAMIC_REPUBLIC_OF_PAKISTAN as F,YIDDISH as I,YIDDISH_WORLD as L}from"@intlayer/types/locales";const R=R=>{switch(R){case e:case S:case n:case t:case o:case s:case c:case l:case u:case d:case p:case m:case g:case _:case b:case x:case C:case f:case h:case y:case a:case v:case r:case i:case O:case k:case E:case D:case P:case F:case A:case j:case M:case N:case w:case T:case I:case L:return`rtl`;default:return`ltr`}};export{R as getHTMLTextDir};
|
|
2
2
|
//# sourceMappingURL=getHTMLTextDir.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHTMLTextDir.mjs","names":[],"sources":["../../../src/localization/getHTMLTextDir.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"getHTMLTextDir.mjs","names":[],"sources":["../../../src/localization/getHTMLTextDir.ts"],"sourcesContent":["import {\n ARABIC,\n ARABIC_ALGERIA,\n ARABIC_BAHRAIN,\n ARABIC_CHAD,\n ARABIC_COMOROS,\n ARABIC_DJIBOUTI,\n ARABIC_EGYPT,\n ARABIC_IRAQ,\n ARABIC_JORDAN,\n ARABIC_KUWAIT,\n ARABIC_LEBANON,\n ARABIC_LIBYA,\n ARABIC_MAURITANIA,\n ARABIC_MOROCCO,\n ARABIC_OMAN,\n ARABIC_PALESTINE,\n ARABIC_QATAR,\n ARABIC_SAUDI_ARABIA,\n ARABIC_SOMALIA,\n ARABIC_SUDAN,\n ARABIC_SYRIA,\n ARABIC_TUNISIA,\n ARABIC_UNITED_ARAB_EMIRATES,\n ARABIC_YEMEN,\n DIVEHI,\n DIVEHI_MALDIVES,\n FARSI,\n FARSI_IRAN,\n HEBREW,\n HEBREW_ISRAEL,\n PASHTO,\n PASHTO_AFGHANISTAN,\n SYRIAC,\n SYRIAC_SYRIA,\n URDU,\n URDU_ISLAMIC_REPUBLIC_OF_PAKISTAN,\n YIDDISH,\n YIDDISH_WORLD,\n} from '@intlayer/types/locales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\ntype Dir = 'ltr' | 'rtl' | 'auto';\n\n/**\n * Returns the text direction of the given locale.\n *\n * Example:\n *\n * getHTMLTextDir('en-US') // 'ltr'\n * getHTMLTextDir('en') // 'ltr'\n * getHTMLTextDir('fr-CA') // 'ltr'\n * getHTMLTextDir('fr') // 'ltr'\n *\n * @param locale The locale to get the text direction for.\n * @returns The text direction of the given locale.\n */\nexport const getHTMLTextDir = (locale?: LocalesValues): Dir => {\n switch (locale) {\n // Arabic (uses Arabic script)\n case ARABIC:\n case ARABIC_UNITED_ARAB_EMIRATES:\n case ARABIC_BAHRAIN:\n case ARABIC_ALGERIA:\n case ARABIC_EGYPT:\n case ARABIC_IRAQ:\n case ARABIC_JORDAN:\n case ARABIC_KUWAIT:\n case ARABIC_LEBANON:\n case ARABIC_LIBYA:\n case ARABIC_MOROCCO:\n case ARABIC_OMAN:\n case ARABIC_QATAR:\n case ARABIC_SAUDI_ARABIA:\n case ARABIC_SYRIA:\n case ARABIC_TUNISIA:\n case ARABIC_YEMEN:\n case ARABIC_MAURITANIA:\n case ARABIC_PALESTINE:\n case ARABIC_SUDAN:\n case ARABIC_DJIBOUTI:\n case ARABIC_SOMALIA:\n case ARABIC_CHAD:\n case ARABIC_COMOROS:\n // Hebrew (uses Hebrew script)\n case HEBREW:\n case HEBREW_ISRAEL:\n // Farsi/Persian (uses Arabic script)\n case FARSI:\n case FARSI_IRAN:\n // Urdu (uses Arabic script)\n case URDU:\n case URDU_ISLAMIC_REPUBLIC_OF_PAKISTAN:\n // Pashto (uses Arabic script)\n case PASHTO:\n case PASHTO_AFGHANISTAN:\n // Syriac (uses Syriac script)\n case SYRIAC:\n case SYRIAC_SYRIA:\n // Divehi (uses Thaana script)\n case DIVEHI:\n case DIVEHI_MALDIVES:\n // Yiddish (uses Hebrew script)\n case YIDDISH:\n case YIDDISH_WORLD:\n return 'rtl';\n\n default:\n return 'ltr';\n }\n};\n"],"mappings":"4uBAyDA,MAAa,EAAkB,GAAgC,CAC7D,OAAQ,EAAR,CAEE,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EAEL,KAAK,EACL,KAAK,EAEL,KAAK,EACL,KAAK,EAEL,KAAK,EACL,KAAK,EAEL,KAAK,EACL,KAAK,EAEL,KAAK,EACL,KAAK,EAEL,KAAK,EACL,KAAK,EAEL,KAAK,EACL,KAAK,EACH,MAAO,MAET,QACE,MAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeMapper.mjs","names":[],"sources":["../../../src/localization/localeMapper.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type {
|
|
1
|
+
{"version":3,"file":"localeMapper.mjs","names":[],"sources":["../../../src/localization/localeMapper.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport type LocaleData = {\n locale: Locale;\n defaultLocale: Locale;\n isDefault: boolean;\n locales: Locale[];\n urlPrefix: string;\n};\n\n/**\n * Determine if the locale should be prefixed in the URL based on routing mode\n */\nconst shouldPrefixLocale = (\n locale: LocalesValues,\n defaultLocale: LocalesValues,\n mode: 'prefix-no-default' | 'prefix-all' | 'no-prefix' | 'search-params'\n): boolean => {\n if (mode === 'no-prefix' || mode === 'search-params') {\n return false;\n }\n if (mode === 'prefix-all') {\n return true;\n }\n // 'prefix-no-default'\n return locale !== defaultLocale;\n};\n\n/**\n * Map the locale data to an array of objects\n *\n * @example\n * ```ts\n * const routes = localeMap((localizedData) =>\n * ({\n * path: localizedData.urlPrefix,\n * name: localizedData.locale,\n * isDefault: localizedData.isDefault,\n * locales: localizedData.locales,\n * defaultLocale: localizedData.defaultLocale,\n * }),\n * );\n *\n * // Result\n * [\n * { path: '/', name: 'en', isDefault: true, locales: ['en'], defaultLocale: 'en', urlPrefix: '' },\n * { path: '/fr', name: 'fr', isDefault: false, locales: ['fr'], defaultLocale: 'en', urlPrefix: '/fr' },\n * { path: '/es', name: 'es', isDefault: false, locales: ['es'], defaultLocale: 'en', urlPrefix: '/es' },\n * ]\n * ```\n *\n * @param mapper - The mapper function that returns an object\n * @returns An array of objects\n */\nexport const localeMap = <T>(\n mapper: (locale: LocaleData) => T,\n locales: LocalesValues[] = configuration?.internationalization.locales ?? [],\n defaultLocale: LocalesValues = configuration?.internationalization\n .defaultLocale ?? DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode:\n | 'prefix-no-default'\n | 'prefix-all'\n | 'no-prefix'\n | 'search-params' = configuration?.routing?.mode ?? 'prefix-no-default'\n): T[] =>\n (locales ?? []).map((locale) =>\n mapper({\n locale,\n defaultLocale,\n locales,\n isDefault: locale === defaultLocale,\n urlPrefix: shouldPrefixLocale(locale, defaultLocale, mode)\n ? `/${locale}`\n : '',\n } as LocaleData)\n );\n\n/**\n * Flatten the locale map into a single array of objects\n *\n * @example\n * ```ts\n * const routes = localeMap((localizedData) =>\n * [{\n * path: localizedData.urlPrefix,\n * name: localizedData.locale,\n * isDefault: localizedData.isDefault,\n * locales: localizedData.locales,\n * defaultLocale: localizedData.defaultLocale,\n * }],\n * );\n *\n * // Result\n * [\n * path: '/', name: 'en', isDefault: true, locales: ['en'], defaultLocale: 'en', urlPrefix: '' ,\n * path: '/fr', name: 'fr', isDefault: false, locales: ['fr'], defaultLocale: 'en', urlPrefix: '/fr' ,\n * path: '/es', name: 'es', isDefault: false, locales: ['es'], defaultLocale: 'en', urlPrefix: '/es' ,\n * ]\n * ```\n *\n * @param mapper - The mapper function that returns an array of objects\n * @returns An array of objects\n */\nexport const localeFlatMap = <T>(\n mapper: (locale: LocaleData) => T[],\n locales: LocalesValues[] = configuration?.internationalization.locales ?? [],\n defaultLocale: LocalesValues = configuration?.internationalization\n .defaultLocale ?? DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode:\n | 'prefix-no-default'\n | 'prefix-all'\n | 'no-prefix'\n | 'search-params' = configuration?.routing?.mode ?? 'prefix-no-default'\n): T[] =>\n locales.flatMap((locale) =>\n mapper({\n locale,\n defaultLocale,\n locales,\n isDefault: locale === defaultLocale,\n urlPrefix: shouldPrefixLocale(locale, defaultLocale, mode)\n ? `/${locale}`\n : '',\n } as LocaleData)\n );\n\n/**\n * Creates a record object mapping locales to values transformed by the mapper function\n *\n * @example\n * ```ts\n * const translations = localeRecord(({ locale }) =>\n * require(`./translations/${locale}.json`)\n * );\n *\n * // Result\n *\n * en: ... , // Content of translations/en.json\n * fr: ... , // Content of translations/fr.json\n * es: ...\n *\n * ```\n *\n * @param mapper - Function that takes locale data and returns a value for that locale\n * @param locales - Array of locale codes to map over (defaults to configured locales)\n * @param defaultLocale - The default locale (defaults to configured default)\n * @param mode - URL routing mode for locale handling (defaults to configured value)\n * @returns Record mapping locale codes to mapped values\n */\nexport const localeRecord = <T>(\n mapper: (locale: LocaleData) => T,\n locales: LocalesValues[] = configuration?.internationalization.locales ?? [],\n defaultLocale: LocalesValues = configuration?.internationalization\n .defaultLocale ?? DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode:\n | 'prefix-no-default'\n | 'prefix-all'\n | 'no-prefix'\n | 'search-params' = configuration?.routing?.mode ?? 'prefix-no-default'\n): Record<LocalesValues, T> =>\n (locales ?? []).reduce(\n (acc, locale) => {\n acc[locale] = mapper({\n locale,\n defaultLocale,\n locales,\n isDefault: locale === defaultLocale,\n urlPrefix: shouldPrefixLocale(locale, defaultLocale, mode)\n ? `/${locale}`\n : '',\n } as LocaleData);\n return acc;\n },\n {} as Record<LocalesValues, T>\n );\n"],"mappings":"8FAgBA,MAAM,GACJ,EACA,EACA,IAEI,IAAS,aAAe,IAAS,gBAC5B,GAEL,IAAS,aACJ,GAGF,IAAW,EA6BP,GACX,EACA,EAA2B,GAAe,qBAAqB,SAAW,EAAE,CAC5E,EAA+B,GAAe,qBAC3C,eAAiB,EAAc,qBAAqB,eACvD,EAIsB,GAAe,SAAS,MAAQ,uBAErD,GAAW,EAAE,EAAE,IAAK,GACnB,EAAO,CACL,SACA,gBACA,UACA,UAAW,IAAW,EACtB,UAAW,EAAmB,EAAQ,EAAe,EAAK,CACtD,IAAI,IACJ,GACL,CAAe,CACjB,CA4BU,GACX,EACA,EAA2B,GAAe,qBAAqB,SAAW,EAAE,CAC5E,EAA+B,GAAe,qBAC3C,eAAiB,EAAc,qBAAqB,eACvD,EAIsB,GAAe,SAAS,MAAQ,sBAEtD,EAAQ,QAAS,GACf,EAAO,CACL,SACA,gBACA,UACA,UAAW,IAAW,EACtB,UAAW,EAAmB,EAAQ,EAAe,EAAK,CACtD,IAAI,IACJ,GACL,CAAe,CACjB,CAyBU,GACX,EACA,EAA2B,GAAe,qBAAqB,SAAW,EAAE,CAC5E,EAA+B,GAAe,qBAC3C,eAAiB,EAAc,qBAAqB,eACvD,EAIsB,GAAe,SAAS,MAAQ,uBAErD,GAAW,EAAE,EAAE,QACb,EAAK,KACJ,EAAI,GAAU,EAAO,CACnB,SACA,gBACA,UACA,UAAW,IAAW,EACtB,UAAW,EAAmB,EAAQ,EAAe,EAAK,CACtD,IAAI,IACJ,GACL,CAAe,CACT,GAET,EAAE,CACH"}
|