@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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{deepTransformNode as e}from"../interpreter/getContent/deepTransform.mjs";import{enu as t}from"../transpiler/enumeration/enumeration.mjs";import{gender as n}from"../transpiler/gender/gender.mjs";import{
|
|
1
|
+
import{deepTransformNode as e}from"../interpreter/getContent/deepTransform.mjs";import{enu as t}from"../transpiler/enumeration/enumeration.mjs";import{gender as n}from"../transpiler/gender/gender.mjs";import{t as r}from"../html-3bo80xzx.mjs";import{insert as i}from"../transpiler/insertion/insertion.mjs";import{NodeType as a}from"@intlayer/types/nodeType";const o=e=>{let t=0,n=()=>{let n=[],i=``;for(;t<e.length;){let a=e[t];if(a===`{`)i&&=(n.push(i),``),t++,n.push(r());else if(a===`}`)break;else if(a===`'`)if(t+1<e.length&&e[t+1]===`'`)i+=`'`,t+=2;else{let n=e.indexOf(`'`,t+1);n===-1?(i+=`'`,t++):(i+=e.substring(t+1,n),t=n+1)}else i+=a,t++}return i&&n.push(i),n},r=()=>{let r=``;for(;t<e.length&&/[^,}]/.test(e[t]);)r+=e[t],t++;if(r=r.trim(),t>=e.length)throw Error(`Unclosed argument`);if(e[t]===`}`)return t++,{type:`argument`,name:r};if(e[t]===`,`){t++;let i=``;for(;t<e.length&&/[^,}]/.test(e[t]);)i+=e[t],t++;if(i=i.trim(),t>=e.length)throw Error(`Unclosed argument`);if(e[t]===`}`)return t++,{type:`argument`,name:r,format:{type:i}};if(e[t]===`,`)if(t++,i===`plural`||i===`select`){let a={};for(;t<e.length&&e[t]!==`}`;){for(;t<e.length&&/\s/.test(e[t]);)t++;let r=``;for(;t<e.length&&/[^{\s]/.test(e[t]);)r+=e[t],t++;for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]!==`{`)throw Error(`Expected { after option key`);t++;let i=n();if(e[t]!==`}`)throw Error(`Expected } after option value`);for(t++,a[r]=i;t<e.length&&/\s/.test(e[t]);)t++}if(t++,i===`plural`)return{type:`plural`,name:r,options:a};if(i===`select`)return{type:`select`,name:r,options:a}}else{let n=``;for(;t<e.length&&e[t]!==`}`;)n+=e[t],t++;if(t>=e.length)throw Error(`Unclosed argument`);return n=n.trim(),t++,{type:`argument`,name:r,format:{type:i,style:n}}}}throw Error(`Malformed argument`)};return n()},s=e=>{if(e.length===0)return``;if(e.length===1&&typeof e[0]==`string`){let t=e[0];return/<[a-zA-Z0-9-]+[^>]*>/.test(t)?r(t):t}if(e.every(e=>typeof e==`string`||e.type===`argument`)){let t=``;for(let n of e)typeof n==`string`?t+=n:typeof n!=`string`&&n.type===`argument`&&(n.format?t+=`{${n.name}, ${n.format.type}${n.format.style?`, ${n.format.style}`:``}}`:t+=`{{${n.name}}}`);return/<[a-zA-Z0-9-]+[^>]*>/.test(t)?r(t):i(t)}if(e.length===1){let a=e[0];if(typeof a==`string`)return/<[a-zA-Z0-9-]+[^>]*>/.test(a)?r(a):a;if(a.type===`argument`)return a.format?i(`{${a.name}, ${a.format.type}${a.format.style?`, ${a.format.style}`:``}}`):i(`{{${a.name}}}`);if(a.type===`plural`){let e={};for(let[t,n]of Object.entries(a.options)){let r=t;t.startsWith(`=`)?r=t.substring(1):t===`one`?r=`1`:t===`two`?r=`2`:t===`few`?r=`<=3`:t===`many`?r=`>=4`:t===`other`&&(r=`fallback`),e[r]=s(n.map(e=>typeof e==`string`?e.replace(/#/g,`{{${a.name}}}`):e))}return e.__intlayer_icu_var=a.name,t(e)}if(a.type===`select`){let e={};for(let[t,n]of Object.entries(a.options))e[t]=s(n);let r=Object.keys(e);return(e.male||e.female)&&r.every(e=>[`male`,`female`,`other`,`fallback`].includes(e))?n({fallback:e.other,male:e.male,female:e.female}):(e.__intlayer_icu_var=a.name,t(e))}}return e.map(e=>s([e]))},c={canHandle:e=>typeof e==`string`&&(e.includes(`{`)||e.includes(`}`)||/<[a-zA-Z0-9-]+[^>]*>/.test(e)),transform:e=>{try{return s(o(e))}catch{return e}}},l={canHandle:e=>{if(typeof e==`string`&&(e.includes(`{`)||e.includes(`}`))||e&&typeof e==`object`&&(e.nodeType===a.Insertion||e.nodeType===a.HTML||e.nodeType===a.Enumeration||e.nodeType===a.Gender||e.nodeType===`composite`))return!0;if(Array.isArray(e)){if(e.length===0)return!1;let t=!1,n=!1;for(let r of e)typeof r==`string`||(r&&typeof r==`object`&&(r.nodeType===a.Insertion||r.nodeType===a.HTML||r.nodeType===a.Enumeration||r.nodeType===a.Gender||r.nodeType===`composite`)?t=!0:n=!0);return!(n||!t)}return!1},transform:(e,t,n)=>{if(typeof e==`string`)return e.replace(/\{\{([^}]+)\}\}/g,`{$1}`);if(e.nodeType===a.Insertion)return e.insertion.replace(/\{\{([^}]+)\}\}/g,`{$1}`);if(e.nodeType===a.HTML)return e.html;if(e.nodeType===a.Enumeration){let r=e.enumeration,i={};for(let[e,a]of Object.entries(r)){if(e===`__intlayer_icu_var`)continue;let r=n(a,t);i[e]=typeof r==`string`?r:JSON.stringify(r)}let a=r.__intlayer_icu_var||`n`;if(!r.__intlayer_icu_var){let e=(i.fallback||i.other||Object.values(i)[0]).match(/\{([a-zA-Z0-9_]+)\}(?!,)/);e&&(a=e[1])}let o=Object.keys(i),s=[`1`,`2`,`<=3`,`>=4`,`fallback`,`other`,`zero`,`one`,`two`,`few`,`many`],c=o.every(e=>s.includes(e)||/^[<>=]?\d+(\.\d+)?$/.test(e)),l=[];if(c){for(let[e,t]of Object.entries(i)){let n=e;n=e===`fallback`?`other`:e===`<=3`?`few`:e===`>=4`?`many`:/^\d+$/.test(e)?`=${e}`:[`zero`,`few`,`many`].includes(e)?e:`other`;let r=t;r=r.replace(RegExp(`\\{${a}\\}`,`g`),`#`),l.push(`${n} {${r}}`)}return`{${a}, plural, ${l.join(` `)}}`}else{let e=Object.entries(i).sort(([e],[t])=>e===`fallback`||e===`other`?1:t===`fallback`||t===`other`?-1:0);for(let[t,n]of e){let e=t;t===`fallback`&&(e=`other`),l.push(`${e} {${n}}`)}return`{${a}, select, ${l.join(` `)}}`}}if(e.nodeType===a.Gender){let r=e.gender,i=[],a=Object.entries(r).sort(([e],[t])=>e===`fallback`?1:t===`fallback`?-1:0);for(let[e,r]of a){let a=e;e===`fallback`&&(a=`other`);let o=n(r,t),s=typeof o==`string`?o:JSON.stringify(o);i.push(`${a} {${s}}`)}return`{gender, select, ${i.join(` `)}}`}return Array.isArray(e)||e.nodeType===`composite`&&Array.isArray(e.composite)?(Array.isArray(e)?e:e.composite).map(e=>n(e,t)).join(``):n(e,t)}},u=t=>e(t,{dictionaryKey:`icu`,keyPath:[],plugins:[{id:`icu`,...l}]}),d=t=>e(t,{dictionaryKey:`icu`,keyPath:[],plugins:[{id:`icu`,...c}]});export{d as icuToIntlayerFormatter,u as intlayerToICUFormatter};
|
|
2
2
|
//# sourceMappingURL=ICU.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICU.mjs","names":["insert","enu"],"sources":["../../../src/messageFormat/ICU.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, gender, html, insert } from '../transpiler';\n\n/**\n * ICU MessageFormat Converter\n *\n * This module converts between ICU MessageFormat and Intlayer's internal format.\n *\n * IMPORTANT: Two different formats are used:\n *\n * 1. ICU MessageFormat (external format):\n * - Simple variables: {name}\n * - Formatted variables: {amount, number, currency}\n * - Plural: {count, plural, =0 {none} other {# items}}\n * - Select: {gender, select, male {He} female {She} other {They}}\n *\n * 2. Intlayer Internal Format:\n * - Simple variables: {{name}} (double braces for clarity and to distinguish from literal text)\n * - Formatted variables: {amount, number, currency} (keeps ICU format)\n * - Plural: enu({ 0: 'none', fallback: '{{count}} items' })\n * - Select/Gender: gender({ male: 'He', female: 'She', fallback: 'They' })\n *\n * Conversion flow:\n * - ICU → Intlayer: {name} → {{name}}\n * - Intlayer → ICU: {{name}} → {name}\n *\n * The double braces in Intlayer format serve to:\n * - Distinguish variables from literal text containing braces\n * - Work with getInsertion() runtime function which expects {{var}} patterns\n * - Provide clear visual distinction in content dictionaries\n */\n\n// Types for our AST\ntype ICUNode =\n | string\n | {\n type: 'argument';\n name: string;\n format?: { type: string; style?: string };\n }\n | { type: 'plural'; name: string; options: Record<string, ICUNode[]> }\n | { type: 'select'; name: string; options: Record<string, ICUNode[]> };\n\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\nconst parseICU = (text: string): ICUNode[] => {\n let index = 0;\n\n const parseNodes = (): ICUNode[] => {\n const nodes: ICUNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n nodes.push(parseArgument());\n } else if (char === '}') {\n // End of current block\n break;\n } else if (char === \"'\") {\n // Escaping\n if (index + 1 < text.length && text[index + 1] === \"'\") {\n currentText += \"'\";\n index += 2;\n } else {\n // Find next quote\n const nextQuote = text.indexOf(\"'\", index + 1);\n if (nextQuote !== -1) {\n // Determine if this is escaping syntax characters\n // For simplicity, we'll treat content between single quotes as literal\n // provided it contains syntax chars.\n // Standard ICU: ' quoted string '\n // If it is just an apostrophe, it should be doubled.\n // But simplified: take content between quotes literally.\n currentText += text.substring(index + 1, nextQuote);\n index = nextQuote + 1;\n } else {\n currentText += \"'\";\n index++;\n }\n }\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n return nodes;\n };\n\n const parseArgument = (): ICUNode => {\n // We are past '{'\n // Parse name\n let name = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n name += text[index];\n index++;\n }\n name = name.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name };\n }\n\n // Must be comma\n if (text[index] === ',') {\n index++;\n // Parse type\n let type = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n type += text[index];\n index++;\n }\n type = type.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name, format: { type } };\n }\n\n if (text[index] === ',') {\n index++;\n\n // If plural or select, parse options\n if (type === 'plural' || type === 'select') {\n // Parse options\n const options: Record<string, ICUNode[]> = {};\n\n while (index < text.length && text[index] !== '}') {\n // skip whitespace\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n // parse key\n let key = '';\n while (index < text.length && /[^{\\s]/.test(text[index])) {\n key += text[index];\n index++;\n }\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n if (text[index] !== '{')\n throw new Error('Expected { after option key');\n index++; // skip {\n\n const value = parseNodes();\n\n if (text[index] !== '}')\n throw new Error('Expected } after option value');\n index++; // skip }\n\n options[key] = value;\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n }\n\n index++; // skip closing argument }\n\n if (type === 'plural') {\n return { type: 'plural', name, options };\n } else if (type === 'select') {\n return { type: 'select', name, options };\n }\n } else {\n // Parse style for number/date/time\n let style = '';\n while (index < text.length && text[index] !== '}') {\n style += text[index];\n index++;\n }\n if (index >= text.length) throw new Error('Unclosed argument');\n\n style = style.trim();\n index++; // skip }\n\n return { type: 'argument', name, format: { type, style } };\n }\n }\n }\n\n throw new Error('Malformed argument');\n };\n\n return parseNodes();\n};\n\nconst icuNodesToIntlayer = (nodes: ICUNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') {\n const node = nodes[0];\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n // Check if we can flatten to a single string (insert)\n const canFlatten = nodes.every(\n (node) => typeof node === 'string' || node.type === 'argument'\n );\n if (canFlatten) {\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else if (typeof node !== 'string' && node.type === 'argument') {\n if (node.format) {\n // Formatted variables keep ICU format: {var, type, style}\n str += `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`;\n } else {\n // Simple variables use Intlayer format: {{var}}\n str += `{{${node.name}}}`;\n }\n }\n }\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(str)) {\n return html(str);\n }\n return insert(str);\n }\n\n // Mix of string and complex types.\n // If we have just one complex type and it covers everything?\n if (nodes.length === 1) {\n const node = nodes[0];\n\n if (typeof node === 'string') {\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n if (node.type === 'argument') {\n if (node.format) {\n return insert(\n `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`\n );\n }\n return insert(`{{${node.name}}}`);\n }\n if (node.type === 'plural') {\n const options: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(node.options)) {\n // Map ICU keys to Intlayer keys\n let newKey = key;\n if (key.startsWith('=')) {\n newKey = key.substring(1); // =0 -> 0\n } else if (key === 'one') {\n newKey = '1';\n } else if (key === 'two') {\n newKey = '2';\n } else if (key === 'few') {\n newKey = '<=3';\n } else if (key === 'many') {\n newKey = '>=4';\n } else if (key === 'other') {\n newKey = 'fallback';\n }\n // Handle # in plural value\n // For plural, we need to pass the variable name down or replace #\n // Intlayer uses {{n}} (or whatever var name) for simple variables\n // We should replace # with {{n}} in the string parts of val\n const replacedVal = val.map((v) => {\n if (typeof v === 'string') {\n return v.replace(/#/g, `{{${node.name}}}`);\n }\n return v;\n });\n\n options[newKey] = icuNodesToIntlayer(replacedVal);\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n if (node.type === 'select') {\n const options: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(node.options)) {\n options[key] = icuNodesToIntlayer(val);\n }\n\n // Check if it looks like gender\n const optionKeys = Object.keys(options);\n // It is gender if it has 'male' OR 'female' AND only contains gender keys (male, female, other)\n const isGender =\n (options.male || options.female) &&\n optionKeys.every((k) =>\n ['male', 'female', 'other', 'fallback'].includes(k)\n );\n\n if (isGender) {\n return gender({\n fallback: options.other,\n male: options.male,\n female: options.female,\n });\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n }\n\n // If multiple nodes, return array\n return nodes.map((node) => icuNodesToIntlayer([node]));\n};\n\nconst icuToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' &&\n (node.includes('{') ||\n node.includes('}') ||\n /<[a-zA-Z0-9-]+[^>]*>/.test(node)),\n transform: (node: any) => {\n try {\n const ast = parseICU(node);\n return icuNodesToIntlayer(ast);\n } catch {\n // If parsing fails, return original string\n return node;\n }\n },\n};\n\nconst intlayerToIcuPlugin = {\n canHandle: (node: any) => {\n if (\n typeof node === 'string' &&\n (node.includes('{') || node.includes('}'))\n ) {\n return true;\n }\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.HTML ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.HTML ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n // Convert Intlayer's double-brace format {{var}} to ICU's single-brace format {var}\n if (typeof node === 'string') {\n return node.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.Insertion) {\n return node.insertion.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.HTML) {\n return node.html;\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_icu_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n let varName = options.__intlayer_icu_var || 'n';\n\n if (!options.__intlayer_icu_var) {\n const fallbackVal =\n transformedOptions.fallback ||\n transformedOptions.other ||\n Object.values(transformedOptions)[0];\n const match = fallbackVal.match(/\\{([a-zA-Z0-9_]+)\\}(?!,)/);\n if (match) {\n varName = match[1];\n }\n }\n\n const keys = Object.keys(transformedOptions);\n const pluralKeys = [\n '1',\n '2',\n '<=3',\n '>=4',\n 'fallback',\n 'other',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n ];\n\n const isPlural = keys.every(\n (k) => pluralKeys.includes(k) || /^[<>=]?\\d+(\\.\\d+)?$/.test(k)\n );\n\n const parts = [];\n\n if (isPlural) {\n for (const [key, val] of Object.entries(transformedOptions)) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n else if (key === '<=3') icuKey = 'few';\n else if (key === '>=4') icuKey = 'many';\n else if (/^\\d+$/.test(key)) icuKey = `=${key}`;\n else if (['zero', 'few', 'many'].includes(key)) icuKey = key;\n else icuKey = 'other';\n\n let strVal = val;\n strVal = strVal.replace(new RegExp(`\\\\{${varName}\\\\}`, 'g'), '#');\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, plural, ${parts.join(' ')}}`;\n } else {\n const entries = Object.entries(transformedOptions).sort(\n ([keyA], [keyB]) => {\n if (keyA === 'fallback' || keyA === 'other') return 1;\n if (keyB === 'fallback' || keyB === 'other') return -1;\n return 0;\n }\n );\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n parts.push(`${icuKey} {${val}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const varName = 'gender';\n const parts = [];\n\n const entries = Object.entries(options).sort(([keyA], [keyB]) => {\n if (keyA === 'fallback') return 1;\n if (keyB === 'fallback') return -1;\n return 0;\n });\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n const childVal = next(val, props);\n const strVal =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n // handle array/composite strings that passed canHandle\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToICUFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'icu',\n keyPath: [],\n plugins: [{ id: 'icu', ...intlayerToIcuPlugin }],\n });\n};\n\nexport const icuToIntlayerFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'icu',\n keyPath: [],\n plugins: [{ id: 'icu', ...icuToIntlayerPlugin }],\n });\n};\n"],"mappings":"+WAsDA,MAAM,EAAY,GAA4B,CAC5C,IAAI,EAAQ,EAEN,MAA8B,CAClC,IAAM,EAAmB,EAAE,CACvB,EAAc,GAElB,KAAO,EAAQ,EAAK,QAAQ,CAC1B,IAAM,EAAO,E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../../src/messageFormat/ICU.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\n\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, gender, html, insert } from '../transpiler';\n\n/**\n * ICU MessageFormat Converter\n *\n * This module converts between ICU MessageFormat and Intlayer's internal format.\n *\n * IMPORTANT: Two different formats are used:\n *\n * 1. ICU MessageFormat (external format):\n * - Simple variables: {name}\n * - Formatted variables: {amount, number, currency}\n * - Plural: {count, plural, =0 {none} other {# items}}\n * - Select: {gender, select, male {He} female {She} other {They}}\n *\n * 2. Intlayer Internal Format:\n * - Simple variables: {{name}} (double braces for clarity and to distinguish from literal text)\n * - Formatted variables: {amount, number, currency} (keeps ICU format)\n * - Plural: enu({ 0: 'none', fallback: '{{count}} items' })\n * - Select/Gender: gender({ male: 'He', female: 'She', fallback: 'They' })\n *\n * Conversion flow:\n * - ICU → Intlayer: {name} → {{name}}\n * - Intlayer → ICU: {{name}} → {name}\n *\n * The double braces in Intlayer format serve to:\n * - Distinguish variables from literal text containing braces\n * - Work with getInsertion() runtime function which expects {{var}} patterns\n * - Provide clear visual distinction in content dictionaries\n */\n\n// Types for our AST\ntype ICUNode =\n | string\n | {\n type: 'argument';\n name: string;\n format?: { type: string; style?: string };\n }\n | { type: 'plural'; name: string; options: Record<string, ICUNode[]> }\n | { type: 'select'; name: string; options: Record<string, ICUNode[]> };\n\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue };\n\nconst parseICU = (text: string): ICUNode[] => {\n let index = 0;\n\n const parseNodes = (): ICUNode[] => {\n const nodes: ICUNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n nodes.push(parseArgument());\n } else if (char === '}') {\n // End of current block\n break;\n } else if (char === \"'\") {\n // Escaping\n if (index + 1 < text.length && text[index + 1] === \"'\") {\n currentText += \"'\";\n index += 2;\n } else {\n // Find next quote\n const nextQuote = text.indexOf(\"'\", index + 1);\n if (nextQuote !== -1) {\n // Determine if this is escaping syntax characters\n // For simplicity, we'll treat content between single quotes as literal\n // provided it contains syntax chars.\n // Standard ICU: ' quoted string '\n // If it is just an apostrophe, it should be doubled.\n // But simplified: take content between quotes literally.\n currentText += text.substring(index + 1, nextQuote);\n index = nextQuote + 1;\n } else {\n currentText += \"'\";\n index++;\n }\n }\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n return nodes;\n };\n\n const parseArgument = (): ICUNode => {\n // We are past '{'\n // Parse name\n let name = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n name += text[index];\n index++;\n }\n name = name.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name };\n }\n\n // Must be comma\n if (text[index] === ',') {\n index++;\n // Parse type\n let type = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n type += text[index];\n index++;\n }\n type = type.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name, format: { type } };\n }\n\n if (text[index] === ',') {\n index++;\n\n // If plural or select, parse options\n if (type === 'plural' || type === 'select') {\n // Parse options\n const options: Record<string, ICUNode[]> = {};\n\n while (index < text.length && text[index] !== '}') {\n // skip whitespace\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n // parse key\n let key = '';\n while (index < text.length && /[^{\\s]/.test(text[index])) {\n key += text[index];\n index++;\n }\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n if (text[index] !== '{')\n throw new Error('Expected { after option key');\n index++; // skip {\n\n const value = parseNodes();\n\n if (text[index] !== '}')\n throw new Error('Expected } after option value');\n index++; // skip }\n\n options[key] = value;\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n }\n\n index++; // skip closing argument }\n\n if (type === 'plural') {\n return { type: 'plural', name, options };\n } else if (type === 'select') {\n return { type: 'select', name, options };\n }\n } else {\n // Parse style for number/date/time\n let style = '';\n while (index < text.length && text[index] !== '}') {\n style += text[index];\n index++;\n }\n if (index >= text.length) throw new Error('Unclosed argument');\n\n style = style.trim();\n index++; // skip }\n\n return { type: 'argument', name, format: { type, style } };\n }\n }\n }\n\n throw new Error('Malformed argument');\n };\n\n return parseNodes();\n};\n\nconst icuNodesToIntlayer = (nodes: ICUNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') {\n const node = nodes[0];\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n // Check if we can flatten to a single string (insert)\n const canFlatten = nodes.every(\n (node) => typeof node === 'string' || node.type === 'argument'\n );\n if (canFlatten) {\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else if (typeof node !== 'string' && node.type === 'argument') {\n if (node.format) {\n // Formatted variables keep ICU format: {var, type, style}\n str += `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`;\n } else {\n // Simple variables use Intlayer format: {{var}}\n str += `{{${node.name}}}`;\n }\n }\n }\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(str)) {\n return html(str);\n }\n return insert(str);\n }\n\n // Mix of string and complex types.\n // If we have just one complex type and it covers everything?\n if (nodes.length === 1) {\n const node = nodes[0];\n\n if (typeof node === 'string') {\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n if (node.type === 'argument') {\n if (node.format) {\n return insert(\n `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`\n );\n }\n return insert(`{{${node.name}}}`);\n }\n if (node.type === 'plural') {\n const options: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(node.options)) {\n // Map ICU keys to Intlayer keys\n let newKey = key;\n if (key.startsWith('=')) {\n newKey = key.substring(1); // =0 -> 0\n } else if (key === 'one') {\n newKey = '1';\n } else if (key === 'two') {\n newKey = '2';\n } else if (key === 'few') {\n newKey = '<=3';\n } else if (key === 'many') {\n newKey = '>=4';\n } else if (key === 'other') {\n newKey = 'fallback';\n }\n // Handle # in plural value\n // For plural, we need to pass the variable name down or replace #\n // Intlayer uses {{n}} (or whatever var name) for simple variables\n // We should replace # with {{n}} in the string parts of val\n const replacedVal = val.map((v) => {\n if (typeof v === 'string') {\n return v.replace(/#/g, `{{${node.name}}}`);\n }\n return v;\n });\n\n options[newKey] = icuNodesToIntlayer(replacedVal);\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n if (node.type === 'select') {\n const options: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(node.options)) {\n options[key] = icuNodesToIntlayer(val);\n }\n\n // Check if it looks like gender\n const optionKeys = Object.keys(options);\n // It is gender if it has 'male' OR 'female' AND only contains gender keys (male, female, other)\n const isGender =\n (options.male || options.female) &&\n optionKeys.every((k) =>\n ['male', 'female', 'other', 'fallback'].includes(k)\n );\n\n if (isGender) {\n return gender({\n fallback: options.other,\n male: options.male,\n female: options.female,\n });\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n }\n\n // If multiple nodes, return array\n return nodes.map((node) => icuNodesToIntlayer([node]));\n};\n\nconst icuToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' &&\n (node.includes('{') ||\n node.includes('}') ||\n /<[a-zA-Z0-9-]+[^>]*>/.test(node)),\n transform: (node: any) => {\n try {\n const ast = parseICU(node);\n return icuNodesToIntlayer(ast);\n } catch {\n // If parsing fails, return original string\n return node;\n }\n },\n};\n\nconst intlayerToIcuPlugin = {\n canHandle: (node: any) => {\n if (\n typeof node === 'string' &&\n (node.includes('{') || node.includes('}'))\n ) {\n return true;\n }\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.HTML ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.HTML ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n // Convert Intlayer's double-brace format {{var}} to ICU's single-brace format {var}\n if (typeof node === 'string') {\n return node.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.Insertion) {\n return node.insertion.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeType.HTML) {\n return node.html;\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_icu_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n let varName = options.__intlayer_icu_var || 'n';\n\n if (!options.__intlayer_icu_var) {\n const fallbackVal =\n transformedOptions.fallback ||\n transformedOptions.other ||\n Object.values(transformedOptions)[0];\n const match = fallbackVal.match(/\\{([a-zA-Z0-9_]+)\\}(?!,)/);\n if (match) {\n varName = match[1];\n }\n }\n\n const keys = Object.keys(transformedOptions);\n const pluralKeys = [\n '1',\n '2',\n '<=3',\n '>=4',\n 'fallback',\n 'other',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n ];\n\n const isPlural = keys.every(\n (k) => pluralKeys.includes(k) || /^[<>=]?\\d+(\\.\\d+)?$/.test(k)\n );\n\n const parts = [];\n\n if (isPlural) {\n for (const [key, val] of Object.entries(transformedOptions)) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n else if (key === '<=3') icuKey = 'few';\n else if (key === '>=4') icuKey = 'many';\n else if (/^\\d+$/.test(key)) icuKey = `=${key}`;\n else if (['zero', 'few', 'many'].includes(key)) icuKey = key;\n else icuKey = 'other';\n\n let strVal = val;\n strVal = strVal.replace(new RegExp(`\\\\{${varName}\\\\}`, 'g'), '#');\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, plural, ${parts.join(' ')}}`;\n } else {\n const entries = Object.entries(transformedOptions).sort(\n ([keyA], [keyB]) => {\n if (keyA === 'fallback' || keyA === 'other') return 1;\n if (keyB === 'fallback' || keyB === 'other') return -1;\n return 0;\n }\n );\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n parts.push(`${icuKey} {${val}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const varName = 'gender';\n const parts = [];\n\n const entries = Object.entries(options).sort(([keyA], [keyB]) => {\n if (keyA === 'fallback') return 1;\n if (keyB === 'fallback') return -1;\n return 0;\n });\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n const childVal = next(val, props);\n const strVal =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n // handle array/composite strings that passed canHandle\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToICUFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'icu',\n keyPath: [],\n plugins: [{ id: 'icu', ...intlayerToIcuPlugin }],\n });\n};\n\nexport const icuToIntlayerFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'icu',\n keyPath: [],\n plugins: [{ id: 'icu', ...icuToIntlayerPlugin }],\n });\n};\n"],"mappings":"qWAsDA,MAAM,EAAY,GAA4B,CAC5C,IAAI,EAAQ,EAEN,MAA8B,CAClC,IAAM,EAAmB,EAAE,CACvB,EAAc,GAElB,KAAO,EAAQ,EAAK,QAAQ,CAC1B,IAAM,EAAO,EAAK,GAElB,GAAI,IAAS,IACX,AAEE,KADA,EAAM,KAAK,EAAY,CACT,IAEhB,IACA,EAAM,KAAK,GAAe,CAAC,SAClB,IAAS,IAElB,cACS,IAAS,IAElB,GAAI,EAAQ,EAAI,EAAK,QAAU,EAAK,EAAQ,KAAO,IACjD,GAAe,IACf,GAAS,MACJ,CAEL,IAAM,EAAY,EAAK,QAAQ,IAAK,EAAQ,EAAE,CAC1C,IAAc,IAUhB,GAAe,IACf,MAJA,GAAe,EAAK,UAAU,EAAQ,EAAG,EAAU,CACnD,EAAQ,EAAY,QAOxB,GAAe,EACf,IAOJ,OAHI,GACF,EAAM,KAAK,EAAY,CAElB,GAGH,MAA+B,CAGnC,IAAI,EAAO,GACX,KAAO,EAAQ,EAAK,QAAU,QAAQ,KAAK,EAAK,GAAO,EACrD,GAAQ,EAAK,GACb,IAIF,GAFA,EAAO,EAAK,MAAM,CAEd,GAAS,EAAK,OAAQ,MAAU,MAAM,oBAAoB,CAE9D,GAAI,EAAK,KAAW,IAElB,MADA,KACO,CAAE,KAAM,WAAY,OAAM,CAInC,GAAI,EAAK,KAAW,IAAK,CACvB,IAEA,IAAI,EAAO,GACX,KAAO,EAAQ,EAAK,QAAU,QAAQ,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,MAAM,QAAQ,EAAK,UAAU,EAGnD,MAAM,QAAQ,EAAK,CAAG,EAAO,EAAK,WAC5B,IAAK,GAAc,EAAK,EAAM,EAAM,CAAC,CAC1C,KAAK,GAAG,CAGhB,EAAK,EAAM,EAAM,EAE3B,CAEY,EACX,GAEO,EAAkB,EAAS,CAChC,cAAe,MACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,MAAO,GAAG,EAAqB,CAAC,CACjD,CAAC,CAGS,EACX,GAEO,EAAkB,EAAS,CAChC,cAAe,MACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,MAAO,GAAG,EAAqB,CAAC,CACjD,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{deepTransformNode as e}from"../interpreter/getContent/deepTransform.mjs";import{enu as t}from"../transpiler/enumeration/enumeration.mjs";import{gender as n}from"../transpiler/gender/gender.mjs";import{
|
|
1
|
+
import{deepTransformNode as e}from"../interpreter/getContent/deepTransform.mjs";import{enu as t}from"../transpiler/enumeration/enumeration.mjs";import{gender as n}from"../transpiler/gender/gender.mjs";import{t as r}from"../html-3bo80xzx.mjs";import{insert as i}from"../transpiler/insertion/insertion.mjs";import{NodeType as a}from"@intlayer/types/nodeType";const o=e=>{let t=0,n=()=>{let n=[],a=``;for(;t<e.length;){let o=e[t];if(o===`{`&&e[t+1]===`{`)a&&=(n.push(a),``),t+=2,n.push(r());else if(o===`{`)a&&=(n.push(a),``),t++,n.push(i());else if(o===`}`)break;else a+=o,t++}return a&&n.push(a),n},r=()=>{let n=``;for(;t<e.length;){if(e[t]===`}`&&e[t+1]===`}`)return t+=2,{type:`argument`,name:n.trim()};n+=e[t],t++}throw Error(`Unclosed i18next variable`)},i=()=>{let r=``;for(;t<e.length&&/[^,}]/.test(e[t]);)r+=e[t],t++;if(r=r.trim(),t>=e.length)throw Error(`Unclosed argument`);if(e[t]===`}`)return t++,{type:`argument`,name:r};if(e[t]===`,`){t++;let i=``;for(;t<e.length&&/[^,}]/.test(e[t]);)i+=e[t],t++;if(i=i.trim(),t>=e.length)throw Error(`Unclosed argument`);if(e[t]===`}`)return t++,{type:`argument`,name:r,format:{type:i}};if(e[t]===`,`)if(t++,i===`plural`||i===`select`){let a={};for(;t<e.length&&e[t]!==`}`;){for(;t<e.length&&/\s/.test(e[t]);)t++;let r=``;for(;t<e.length&&/[^{\s]/.test(e[t]);)r+=e[t],t++;for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]!==`{`)throw Error(`Expected { after option key`);t++;let i=n();if(e[t]!==`}`)throw Error(`Expected } after option value`);for(t++,a[r]=i;t<e.length&&/\s/.test(e[t]);)t++}if(t++,i===`plural`)return{type:`plural`,name:r,options:a};if(i===`select`)return{type:`select`,name:r,options:a}}else{let n=``;for(;t<e.length&&e[t]!==`}`;)n+=e[t],t++;if(t>=e.length)throw Error(`Unclosed argument`);return n=n.trim(),t++,{type:`argument`,name:r,format:{type:i,style:n}}}}throw Error(`Malformed argument`)};return n()},s=e=>{if(e.length===0)return``;if(e.length===1&&typeof e[0]==`string`){let t=e[0];return/<[a-zA-Z0-9-]+[^>]*>/.test(t)?r(t):t}if(e.every(e=>typeof e==`string`||e.type===`argument`)){let t=``;for(let n of e)typeof n==`string`?t+=n:typeof n!=`string`&&n.type===`argument`&&(n.format?t+=`{${n.name}, ${n.format.type}${n.format.style?`, ${n.format.style}`:``}}`:t+=`{{${n.name}}}`);return/<[a-zA-Z0-9-]+[^>]*>/.test(t)?r(t):i(t)}if(e.length===1){let a=e[0];if(typeof a==`string`)return/<[a-zA-Z0-9-]+[^>]*>/.test(a)?r(a):a;if(a.type===`argument`)return a.format?i(`{${a.name}, ${a.format.type}${a.format.style?`, ${a.format.style}`:``}}`):i(`{{${a.name}}}`);if(a.type===`plural`){let e={};for(let[t,n]of Object.entries(a.options)){let r=t;t.startsWith(`=`)?r=t.substring(1):t===`one`?r=`1`:t===`two`?r=`2`:t===`few`?r=`<=3`:t===`many`?r=`>=4`:t===`other`&&(r=`fallback`),e[r]=s(n.map(e=>typeof e==`string`?e.replace(/#/g,`{{${a.name}}}`):e))}return e.__intlayer_icu_var=a.name,t(e)}if(a.type===`select`){let e={};for(let[t,n]of Object.entries(a.options))e[t]=s(n);let r=Object.keys(e);return(e.male||e.female)&&r.every(e=>[`male`,`female`,`other`,`fallback`].includes(e))?n({fallback:e.other,male:e.male,female:e.female}):(e.__intlayer_icu_var=a.name,t(e))}}return e.map(e=>s([e]))},c={canHandle:e=>typeof e==`string`&&(e.includes(`{`)||e.includes(`}`)||/<[a-zA-Z0-9-]+[^>]*>/.test(e)),transform:e=>{try{return s(o(e))}catch{return e}}},l={canHandle:e=>{if(typeof e==`string`||e&&typeof e==`object`&&(e.nodeType===a.Insertion||e.nodeType===a.HTML||e.nodeType===a.Enumeration||e.nodeType===a.Gender||e.nodeType===`composite`))return!0;if(Array.isArray(e)){if(e.length===0)return!1;let t=!1,n=!1;for(let r of e)typeof r==`string`||(r&&typeof r==`object`&&(r.nodeType===a.Insertion||r.nodeType===a.HTML||r.nodeType===a.Enumeration||r.nodeType===a.Gender||r.nodeType===`composite`)?t=!0:n=!0);return!(n||!t)}return!1},transform:(e,t,n)=>{if(typeof e==`string`)return e;if(e.nodeType===a.Insertion)return e.insertion.match(/\{[^}]*,[^}]*\}/),e.insertion;if(e.nodeType===a.HTML)return e.html;if(e.nodeType===a.Enumeration){let r=e.enumeration,i={};for(let[e,a]of Object.entries(r)){if(e===`__intlayer_icu_var`)continue;let r=n(a,t);i[e]=typeof r==`string`?r:JSON.stringify(r)}let a=r.__intlayer_icu_var||`count`;if(!r.__intlayer_icu_var){let e=i.fallback||i.other||Object.values(i)[0],t=e.match(/\{\{([a-zA-Z0-9_]+)\}\}/)||e.match(/\{([a-zA-Z0-9_]+)\}(?!,)/);t&&(a=t[1])}let o=Object.keys(i),s=[`1`,`2`,`<=3`,`>=4`,`fallback`,`other`,`zero`,`one`,`two`,`few`,`many`],c=o.every(e=>s.includes(e)||/^[<>=]?\d+(\.\d+)?$/.test(e)),l=[];if(c){for(let[e,t]of Object.entries(i)){let n=e;e===`fallback`?n=`other`:e===`<=3`?n=`few`:e===`>=4`?n=`many`:/^\d+$/.test(e)&&(n=`=${e}`);let r=t;r=r.replace(/\{\{([^}]+)\}\}/g,`{$1}`),r=r.replace(RegExp(`\\{${a}\\}`,`g`),`#`),l.push(`${n} {${r}}`)}return`{${a}, plural, ${l.join(` `)}}`}else{let e=Object.entries(i).sort(([e],[t])=>e===`fallback`||e===`other`?1:t===`fallback`||t===`other`?-1:0);for(let[t,n]of e){let e=t;t===`fallback`&&(e=`other`);let r=n;r=r.replace(/\{\{([^}]+)\}\}/g,`{$1}`),l.push(`${e} {${r}}`)}return`{${a}, select, ${l.join(` `)}}`}}if(e.nodeType===a.Gender){let r=e.gender,i=[],a=Object.entries(r).sort(([e],[t])=>e===`fallback`?1:t===`fallback`?-1:0);for(let[e,r]of a){let a=e;e===`fallback`&&(a=`other`);let o=n(r,t),s=typeof o==`string`?o:JSON.stringify(o);s=s.replace(/\{\{([^}]+)\}\}/g,`{$1}`),i.push(`${a} {${s}}`)}return`{gender, select, ${i.join(` `)}}`}return Array.isArray(e)||e.nodeType===`composite`&&Array.isArray(e.composite)?(Array.isArray(e)?e:e.composite).map(e=>n(e,t)).join(``):n(e,t)}},u=t=>e(t,{dictionaryKey:`i18next`,keyPath:[],plugins:[{id:`i18next`,...l}]}),d=t=>e(t,{dictionaryKey:`i18next`,keyPath:[],plugins:[{id:`i18next`,...c}]});export{d as i18nextToIntlayerFormatter,u as intlayerToI18nextFormatter};
|
|
2
2
|
//# sourceMappingURL=i18next.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18next.mjs","names":["insert","enu"],"sources":["../../../src/messageFormat/i18next.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, gender, html, insert } from '../transpiler';\nimport type { JsonValue } from './ICU';\n\n// Types for our AST\ntype I18NextNode =\n | string\n | {\n type: 'argument';\n name: string;\n format?: { type: string; style?: string };\n }\n | { type: 'plural'; name: string; options: Record<string, I18NextNode[]> }\n | { type: 'select'; name: string; options: Record<string, I18NextNode[]> };\n\nconst parseI18Next = (text: string): I18NextNode[] => {\n let index = 0;\n\n const parseNodes = (): I18NextNode[] => {\n const nodes: I18NextNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n // Standard i18next variable: {{var}}\n if (char === '{' && text[index + 1] === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index += 2; // skip {{\n nodes.push(parseStandardArgument());\n }\n // ICU syntax: {var} or {var, plural, ...}\n else if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n nodes.push(parseICUArgument());\n } else if (char === '}') {\n // End of current block (likely ICU block end)\n break;\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n return nodes;\n };\n\n const parseStandardArgument = (): I18NextNode => {\n // We are past '{{'\n let name = '';\n while (index < text.length) {\n // Check for closing }}\n if (text[index] === '}' && text[index + 1] === '}') {\n index += 2; // skip }}\n return { type: 'argument', name: name.trim() };\n }\n name += text[index];\n index++;\n }\n throw new Error('Unclosed i18next variable');\n };\n\n const parseICUArgument = (): I18NextNode => {\n // We are past '{'\n let name = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n name += text[index];\n index++;\n }\n name = name.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name };\n }\n\n // Must be comma\n if (text[index] === ',') {\n index++;\n // Parse type\n let type = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n type += text[index];\n index++;\n }\n type = type.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name, format: { type } };\n }\n\n if (text[index] === ',') {\n index++;\n\n // If plural or select, parse options\n if (type === 'plural' || type === 'select') {\n const options: Record<string, I18NextNode[]> = {};\n\n while (index < text.length && text[index] !== '}') {\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n let key = '';\n while (index < text.length && /[^{\\s]/.test(text[index])) {\n key += text[index];\n index++;\n }\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n if (text[index] !== '{')\n throw new Error('Expected { after option key');\n index++; // skip {\n\n const value = parseNodes();\n\n if (text[index] !== '}')\n throw new Error('Expected } after option value');\n index++; // skip }\n\n options[key] = value;\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n }\n\n index++; // skip closing argument }\n\n if (type === 'plural') {\n return { type: 'plural', name, options };\n } else if (type === 'select') {\n return { type: 'select', name, options };\n }\n } else {\n // Parse style for number/date/time\n let style = '';\n while (index < text.length && text[index] !== '}') {\n style += text[index];\n index++;\n }\n if (index >= text.length) throw new Error('Unclosed argument');\n\n style = style.trim();\n index++; // skip }\n\n return { type: 'argument', name, format: { type, style } };\n }\n }\n }\n\n throw new Error('Malformed argument');\n };\n\n return parseNodes();\n};\n\nconst i18nextNodesToIntlayer = (nodes: I18NextNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') {\n const node = nodes[0];\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n const canFlatten = nodes.every(\n (node) => typeof node === 'string' || node.type === 'argument'\n );\n\n if (canFlatten) {\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else if (typeof node !== 'string' && node.type === 'argument') {\n if (node.format) {\n // For formatted arguments, use ICU syntax: {name, type, style}\n str += `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`;\n } else {\n // For simple arguments, use standard i18next: {{name}}\n str += `{{${node.name}}}`;\n }\n }\n }\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(str)) {\n return html(str);\n }\n return insert(str);\n }\n\n if (nodes.length === 1) {\n const node = nodes[0];\n if (typeof node === 'string') {\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n if (node.type === 'argument') {\n if (node.format) {\n return insert(\n `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`\n );\n }\n return insert(`{{${node.name}}}`);\n }\n\n if (node.type === 'plural') {\n const options: Record<string, any> = {};\n for (const [key, val] of Object.entries(node.options)) {\n let newKey = key;\n if (key.startsWith('=')) {\n newKey = key.substring(1);\n } else if (key === 'one') {\n newKey = '1';\n } else if (key === 'two') {\n newKey = '2';\n } else if (key === 'few') {\n newKey = '<=3';\n } else if (key === 'many') {\n newKey = '>=4';\n } else if (key === 'other') {\n newKey = 'fallback';\n }\n // Handle # replacement\n const replacedVal = val.map((v) => {\n if (typeof v === 'string') {\n // In ICU plural, # is replaced by the number\n // In i18next, if using ICU plugin, it behaves same.\n // We map it to {{varName}} in Intlayer\n return v.replace(/#/g, `{{${node.name}}}`);\n }\n return v;\n });\n\n options[newKey] = i18nextNodesToIntlayer(replacedVal);\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n\n if (node.type === 'select') {\n const options: Record<string, any> = {};\n for (const [key, val] of Object.entries(node.options)) {\n options[key] = i18nextNodesToIntlayer(val);\n }\n\n // Check for gender\n const optionKeys = Object.keys(options);\n const isGender =\n (options.male || options.female) &&\n optionKeys.every((k) =>\n ['male', 'female', 'other', 'fallback'].includes(k)\n );\n\n if (isGender) {\n return gender({\n fallback: options.other,\n male: options.male,\n female: options.female,\n });\n }\n\n // Preserve variable name for generic select\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n }\n\n return nodes.map((node) => i18nextNodesToIntlayer([node]));\n};\n\nconst i18nextToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' &&\n (node.includes('{') ||\n node.includes('}') ||\n /<[a-zA-Z0-9-]+[^>]*>/.test(node)),\n transform: (node: any) => {\n try {\n const ast = parseI18Next(node);\n return i18nextNodesToIntlayer(ast);\n } catch {\n return node;\n }\n },\n};\n\nconst intlayerToI18nextPlugin = {\n canHandle: (node: any) => {\n if (typeof node === 'string') return true;\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.HTML ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.HTML ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n if (typeof node === 'string') {\n return node;\n }\n\n if (node.nodeType === NodeType.Insertion) {\n if (node.insertion.match(/\\{[^}]*,[^}]*\\}/)) {\n return node.insertion;\n }\n return node.insertion;\n }\n\n if (node.nodeType === NodeType.HTML) {\n return node.html;\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_icu_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n let varName = options.__intlayer_icu_var || 'count';\n\n if (!options.__intlayer_icu_var) {\n const fallbackVal =\n transformedOptions.fallback ||\n transformedOptions.other ||\n Object.values(transformedOptions)[0];\n\n const match =\n fallbackVal.match(/\\{\\{([a-zA-Z0-9_]+)\\}\\}/) ||\n fallbackVal.match(/\\{([a-zA-Z0-9_]+)\\}(?!,)/);\n if (match) {\n varName = match[1];\n }\n }\n\n const keys = Object.keys(transformedOptions);\n const pluralKeys = [\n '1',\n '2',\n '<=3',\n '>=4',\n 'fallback',\n 'other',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n ];\n const isPlural = keys.every(\n (k) => pluralKeys.includes(k) || /^[<>=]?\\d+(\\.\\d+)?$/.test(k)\n );\n\n const parts = [];\n\n if (isPlural) {\n for (const [key, val] of Object.entries(transformedOptions)) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n else if (key === '<=3') icuKey = 'few';\n else if (key === '>=4') icuKey = 'many';\n else if (/^\\d+$/.test(key)) icuKey = `=${key}`;\n\n let strVal = val;\n\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n strVal = strVal.replace(new RegExp(`\\\\{${varName}\\\\}`, 'g'), '#');\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, plural, ${parts.join(' ')}}`;\n } else {\n const entries = Object.entries(transformedOptions).sort(\n ([keyA], [keyB]) => {\n if (keyA === 'fallback' || keyA === 'other') return 1;\n if (keyB === 'fallback' || keyB === 'other') return -1;\n return 0;\n }\n );\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n let strVal = val;\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const varName = 'gender';\n const parts = [];\n\n const entries = Object.entries(options).sort(([keyA], [keyB]) => {\n if (keyA === 'fallback') return 1;\n if (keyB === 'fallback') return -1;\n return 0;\n });\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n const childVal = next(val, props);\n let strVal =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToI18nextFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'i18next',\n keyPath: [],\n plugins: [{ id: 'i18next', ...intlayerToI18nextPlugin }],\n });\n};\n\nexport const i18nextToIntlayerFormatter = (\n message: JsonValue\n): Dictionary['content'] => {\n return deepTransformNode(message, {\n dictionaryKey: 'i18next',\n keyPath: [],\n plugins: [{ id: 'i18next', ...i18nextToIntlayerPlugin }],\n });\n};\n"],"mappings":"+WAiBA,MAAM,EAAgB,GAAgC,CACpD,IAAI,EAAQ,EAEN,MAAkC,CACtC,IAAM,EAAuB,EAAE,CAC3B,EAAc,GAElB,KAAO,EAAQ,EAAK,QAAQ,CAC1B,IAAM,EAAO,EAAK,GAGlB,GAAI,IAAS,KAAO,EAAK,EAAQ,KAAO,IACtC,AAEE,KADA,EAAM,KAAK,EAAY,CACT,IAEhB,GAAS,EACT,EAAM,KAAK,GAAuB,CAAC,SAG5B,IAAS,IAChB,AAEE,KADA,EAAM,KAAK,EAAY,CACT,IAEhB,IACA,EAAM,KAAK,GAAkB,CAAC,SACrB,IAAS,IAElB,WAEA,GAAe,EACf,IAOJ,OAHI,GACF,EAAM,KAAK,EAAY,CAElB,GAGH,MAA2C,CAE/C,IAAI,EAAO,GACX,KAAO,EAAQ,EAAK,QAAQ,CAE1B,GAAI,EAAK,KAAW,KAAO,EAAK,EAAQ,K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OAAQ,CACrC,IAAM,EAAU,EAAK,OAEf,EAAQ,EAAE,CAEV,EAAU,OAAO,QAAQ,EAAQ,CAAC,MAAM,CAAC,GAAO,CAAC,KACjD,IAAS,WAAmB,EAC5B,IAAS,WAAmB,GACzB,EACP,CAEF,IAAK,GAAM,CAAC,EAAK,KAAQ,EAAS,CAChC,IAAI,EAAS,EACT,IAAQ,aAAY,EAAS,SAEjC,IAAM,EAAW,EAAK,EAAK,EAAM,CAC7B,EACF,OAAO,GAAa,SAAW,EAAW,KAAK,UAAU,EAAS,CAEpE,EAAS,EAAO,QAAQ,mBAAoB,OAAO,CACnD,EAAM,KAAK,GAAG,EAAO,IAAI,EAAO,GAAG,CAErC,MAAO,oBAAwB,EAAM,KAAK,IAAI,CAAC,GAYjD,OARE,MAAM,QAAQ,EAAK,EAClB,EAAK,WAAa,aAAe,MAAM,QAAQ,EAAK,UAAU,EAEnD,MAAM,QAAQ,EAAK,CAAG,EAAO,EAAK,WAC5B,IAAK,GAAc,EAAK,EAAM,EAAM,CAAC,CAC1C,KAAK,GAAG,CAGhB,EAAK,EAAM,EAAM,EAE3B,CAEY,EACX,GAEO,EAAkB,EAAS,CAChC,cAAe,UACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,UAAW,GAAG,EAAyB,CAAC,CACzD,CAAC,CAGS,EACX,GAEO,EAAkB,EAAS,CAChC,cAAe,UACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,UAAW,GAAG,EAAyB,CAAC,CACzD,CAAC"}
|
|
1
|
+
{"version":3,"file":"i18next.mjs","names":["insert","enu"],"sources":["../../../src/messageFormat/i18next.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, gender, html, insert } from '../transpiler';\nimport type { JsonValue } from './ICU';\n\n// Types for our AST\ntype I18NextNode =\n | string\n | {\n type: 'argument';\n name: string;\n format?: { type: string; style?: string };\n }\n | { type: 'plural'; name: string; options: Record<string, I18NextNode[]> }\n | { type: 'select'; name: string; options: Record<string, I18NextNode[]> };\n\nconst parseI18Next = (text: string): I18NextNode[] => {\n let index = 0;\n\n const parseNodes = (): I18NextNode[] => {\n const nodes: I18NextNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n // Standard i18next variable: {{var}}\n if (char === '{' && text[index + 1] === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index += 2; // skip {{\n nodes.push(parseStandardArgument());\n }\n // ICU syntax: {var} or {var, plural, ...}\n else if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n nodes.push(parseICUArgument());\n } else if (char === '}') {\n // End of current block (likely ICU block end)\n break;\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n return nodes;\n };\n\n const parseStandardArgument = (): I18NextNode => {\n // We are past '{{'\n let name = '';\n while (index < text.length) {\n // Check for closing }}\n if (text[index] === '}' && text[index + 1] === '}') {\n index += 2; // skip }}\n return { type: 'argument', name: name.trim() };\n }\n name += text[index];\n index++;\n }\n throw new Error('Unclosed i18next variable');\n };\n\n const parseICUArgument = (): I18NextNode => {\n // We are past '{'\n let name = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n name += text[index];\n index++;\n }\n name = name.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name };\n }\n\n // Must be comma\n if (text[index] === ',') {\n index++;\n // Parse type\n let type = '';\n while (index < text.length && /[^,}]/.test(text[index])) {\n type += text[index];\n index++;\n }\n type = type.trim();\n\n if (index >= text.length) throw new Error('Unclosed argument');\n\n if (text[index] === '}') {\n index++;\n return { type: 'argument', name, format: { type } };\n }\n\n if (text[index] === ',') {\n index++;\n\n // If plural or select, parse options\n if (type === 'plural' || type === 'select') {\n const options: Record<string, I18NextNode[]> = {};\n\n while (index < text.length && text[index] !== '}') {\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n let key = '';\n while (index < text.length && /[^{\\s]/.test(text[index])) {\n key += text[index];\n index++;\n }\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n\n if (text[index] !== '{')\n throw new Error('Expected { after option key');\n index++; // skip {\n\n const value = parseNodes();\n\n if (text[index] !== '}')\n throw new Error('Expected } after option value');\n index++; // skip }\n\n options[key] = value;\n\n while (index < text.length && /\\s/.test(text[index])) index++;\n }\n\n index++; // skip closing argument }\n\n if (type === 'plural') {\n return { type: 'plural', name, options };\n } else if (type === 'select') {\n return { type: 'select', name, options };\n }\n } else {\n // Parse style for number/date/time\n let style = '';\n while (index < text.length && text[index] !== '}') {\n style += text[index];\n index++;\n }\n if (index >= text.length) throw new Error('Unclosed argument');\n\n style = style.trim();\n index++; // skip }\n\n return { type: 'argument', name, format: { type, style } };\n }\n }\n }\n\n throw new Error('Malformed argument');\n };\n\n return parseNodes();\n};\n\nconst i18nextNodesToIntlayer = (nodes: I18NextNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') {\n const node = nodes[0];\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n const canFlatten = nodes.every(\n (node) => typeof node === 'string' || node.type === 'argument'\n );\n\n if (canFlatten) {\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else if (typeof node !== 'string' && node.type === 'argument') {\n if (node.format) {\n // For formatted arguments, use ICU syntax: {name, type, style}\n str += `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`;\n } else {\n // For simple arguments, use standard i18next: {{name}}\n str += `{{${node.name}}}`;\n }\n }\n }\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(str)) {\n return html(str);\n }\n return insert(str);\n }\n\n if (nodes.length === 1) {\n const node = nodes[0];\n if (typeof node === 'string') {\n if (/<[a-zA-Z0-9-]+[^>]*>/.test(node)) {\n return html(node);\n }\n return node;\n }\n\n if (node.type === 'argument') {\n if (node.format) {\n return insert(\n `{${node.name}, ${node.format.type}${\n node.format.style ? `, ${node.format.style}` : ''\n }}`\n );\n }\n return insert(`{{${node.name}}}`);\n }\n\n if (node.type === 'plural') {\n const options: Record<string, any> = {};\n for (const [key, val] of Object.entries(node.options)) {\n let newKey = key;\n if (key.startsWith('=')) {\n newKey = key.substring(1);\n } else if (key === 'one') {\n newKey = '1';\n } else if (key === 'two') {\n newKey = '2';\n } else if (key === 'few') {\n newKey = '<=3';\n } else if (key === 'many') {\n newKey = '>=4';\n } else if (key === 'other') {\n newKey = 'fallback';\n }\n // Handle # replacement\n const replacedVal = val.map((v) => {\n if (typeof v === 'string') {\n // In ICU plural, # is replaced by the number\n // In i18next, if using ICU plugin, it behaves same.\n // We map it to {{varName}} in Intlayer\n return v.replace(/#/g, `{{${node.name}}}`);\n }\n return v;\n });\n\n options[newKey] = i18nextNodesToIntlayer(replacedVal);\n }\n\n // Preserve variable name\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n\n if (node.type === 'select') {\n const options: Record<string, any> = {};\n for (const [key, val] of Object.entries(node.options)) {\n options[key] = i18nextNodesToIntlayer(val);\n }\n\n // Check for gender\n const optionKeys = Object.keys(options);\n const isGender =\n (options.male || options.female) &&\n optionKeys.every((k) =>\n ['male', 'female', 'other', 'fallback'].includes(k)\n );\n\n if (isGender) {\n return gender({\n fallback: options.other,\n male: options.male,\n female: options.female,\n });\n }\n\n // Preserve variable name for generic select\n options.__intlayer_icu_var = node.name;\n\n return enu(options);\n }\n }\n\n return nodes.map((node) => i18nextNodesToIntlayer([node]));\n};\n\nconst i18nextToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' &&\n (node.includes('{') ||\n node.includes('}') ||\n /<[a-zA-Z0-9-]+[^>]*>/.test(node)),\n transform: (node: any) => {\n try {\n const ast = parseI18Next(node);\n return i18nextNodesToIntlayer(ast);\n } catch {\n return node;\n }\n },\n};\n\nconst intlayerToI18nextPlugin = {\n canHandle: (node: any) => {\n if (typeof node === 'string') return true;\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeType.Insertion ||\n node.nodeType === NodeType.HTML ||\n node.nodeType === NodeType.Enumeration ||\n node.nodeType === NodeType.Gender ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeType.Insertion ||\n item.nodeType === NodeType.HTML ||\n item.nodeType === NodeType.Enumeration ||\n item.nodeType === NodeType.Gender ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n if (typeof node === 'string') {\n return node;\n }\n\n if (node.nodeType === NodeType.Insertion) {\n if (node.insertion.match(/\\{[^}]*,[^}]*\\}/)) {\n return node.insertion;\n }\n return node.insertion;\n }\n\n if (node.nodeType === NodeType.HTML) {\n return node.html;\n }\n\n if (node.nodeType === NodeType.Enumeration) {\n const options = node.enumeration;\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (key === '__intlayer_icu_var') continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n let varName = options.__intlayer_icu_var || 'count';\n\n if (!options.__intlayer_icu_var) {\n const fallbackVal =\n transformedOptions.fallback ||\n transformedOptions.other ||\n Object.values(transformedOptions)[0];\n\n const match =\n fallbackVal.match(/\\{\\{([a-zA-Z0-9_]+)\\}\\}/) ||\n fallbackVal.match(/\\{([a-zA-Z0-9_]+)\\}(?!,)/);\n if (match) {\n varName = match[1];\n }\n }\n\n const keys = Object.keys(transformedOptions);\n const pluralKeys = [\n '1',\n '2',\n '<=3',\n '>=4',\n 'fallback',\n 'other',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n ];\n const isPlural = keys.every(\n (k) => pluralKeys.includes(k) || /^[<>=]?\\d+(\\.\\d+)?$/.test(k)\n );\n\n const parts = [];\n\n if (isPlural) {\n for (const [key, val] of Object.entries(transformedOptions)) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n else if (key === '<=3') icuKey = 'few';\n else if (key === '>=4') icuKey = 'many';\n else if (/^\\d+$/.test(key)) icuKey = `=${key}`;\n\n let strVal = val;\n\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n strVal = strVal.replace(new RegExp(`\\\\{${varName}\\\\}`, 'g'), '#');\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, plural, ${parts.join(' ')}}`;\n } else {\n const entries = Object.entries(transformedOptions).sort(\n ([keyA], [keyB]) => {\n if (keyA === 'fallback' || keyA === 'other') return 1;\n if (keyB === 'fallback' || keyB === 'other') return -1;\n return 0;\n }\n );\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n let strVal = val;\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n }\n\n if (node.nodeType === NodeType.Gender) {\n const options = node.gender;\n const varName = 'gender';\n const parts = [];\n\n const entries = Object.entries(options).sort(([keyA], [keyB]) => {\n if (keyA === 'fallback') return 1;\n if (keyB === 'fallback') return -1;\n return 0;\n });\n\n for (const [key, val] of entries) {\n let icuKey = key;\n if (key === 'fallback') icuKey = 'other';\n\n const childVal = next(val, props);\n let strVal =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n\n strVal = strVal.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n parts.push(`${icuKey} {${strVal}}`);\n }\n return `{${varName}, select, ${parts.join(' ')}}`;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToI18nextFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'i18next',\n keyPath: [],\n plugins: [{ id: 'i18next', ...intlayerToI18nextPlugin }],\n });\n};\n\nexport const i18nextToIntlayerFormatter = (\n message: JsonValue\n): Dictionary['content'] => {\n return deepTransformNode(message, {\n dictionaryKey: 'i18next',\n keyPath: [],\n plugins: [{ id: 'i18next', ...i18nextToIntlayerPlugin }],\n });\n};\n"],"mappings":"qWAiBA,MAAM,EAAgB,GAAgC,CACpD,IAAI,EAAQ,EAEN,MAAkC,CACtC,IAAM,EAAuB,EAAE,CAC3B,EAAc,GAElB,KAAO,EAAQ,EAAK,QAAQ,CAC1B,IAAM,EAAO,EAAK,GAGlB,GAAI,IAAS,KAAO,EAAK,EAAQ,KAAO,IACtC,AAEE,KADA,EAAM,KAAK,EAAY,CACT,IAEhB,GAAS,EACT,EAAM,KAAK,GAAuB,CAAC,SAG5B,IAAS,IAChB,AAEE,KADA,EAAM,KAAK,EAAY,CACT,IAEhB,IACA,EAAM,KAAK,GAAkB,CAAC,SACrB,IAAS,IAElB,WAEA,GAAe,EACf,IAOJ,OAHI,GACF,EAAM,KAAK,EAAY,CAElB,GAGH,MAA2C,CAE/C,IAAI,EAAO,GACX,KAAO,EAAQ,EAAK,QAAQ,CAE1B,GAAI,EAAK,KAAW,KAAO,EAAK,EAAQ,KAAO,IAE7C,MADA,IAAS,EACF,CAAE,KAAM,WAAY,KAAM,EAAK,MAAM,CAAE,CAEhD,GAAQ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CAAC,MAAM,CAAC,GAAO,CAAC,KACjD,IAAS,WAAmB,EAC5B,IAAS,WAAmB,GACzB,EACP,CAEF,IAAK,GAAM,CAAC,EAAK,KAAQ,EAAS,CAChC,IAAI,EAAS,EACT,IAAQ,aAAY,EAAS,SAEjC,IAAM,EAAW,EAAK,EAAK,EAAM,CAC7B,EACF,OAAO,GAAa,SAAW,EAAW,KAAK,UAAU,EAAS,CAEpE,EAAS,EAAO,QAAQ,mBAAoB,OAAO,CACnD,EAAM,KAAK,GAAG,EAAO,IAAI,EAAO,GAAG,CAErC,MAAO,oBAAwB,EAAM,KAAK,IAAI,CAAC,GAYjD,OARE,MAAM,QAAQ,EAAK,EAClB,EAAK,WAAa,aAAe,MAAM,QAAQ,EAAK,UAAU,EAEnD,MAAM,QAAQ,EAAK,CAAG,EAAO,EAAK,WAC5B,IAAK,GAAc,EAAK,EAAM,EAAM,CAAC,CAC1C,KAAK,GAAG,CAGhB,EAAK,EAAM,EAAM,EAE3B,CAEY,EACX,GAEO,EAAkB,EAAS,CAChC,cAAe,UACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,UAAW,GAAG,EAAyB,CAAC,CACzD,CAAC,CAGS,EACX,GAEO,EAAkB,EAAS,CAChC,cAAe,UACf,QAAS,EAAE,CACX,QAAS,CAAC,CAAE,GAAI,UAAW,GAAG,EAAyB,CAAC,CACzD,CAAC"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=getHTMLCustomComponents.mjs.map
|
|
1
|
+
import{n as e}from"../../html-3bo80xzx.mjs";export{e as getHTMLCustomComponents};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=html.mjs.map
|
|
1
|
+
import{t as e}from"../../html-3bo80xzx.mjs";export{e as html};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../../html-3bo80xzx.mjs";import{VOID_ELEMENTS as t,validateHTML as n}from"./validateHTML.mjs";import{HTML_TAGS as r}from"./htmlTags.mjs";export{r as HTML_TAGS,t as VOID_ELEMENTS,e as html,n as validateHTML};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cond as e}from"./condition/condition.mjs";import{enu as t}from"./enumeration/enumeration.mjs";import{gender as n}from"./gender/gender.mjs";import{
|
|
1
|
+
import{cond as e}from"./condition/condition.mjs";import{enu as t}from"./enumeration/enumeration.mjs";import{gender as n}from"./gender/gender.mjs";import{t as r}from"../html-3bo80xzx.mjs";import{VOID_ELEMENTS as i,validateHTML as a}from"./html/validateHTML.mjs";import{HTML_TAGS as o}from"./html/htmlTags.mjs";import{getInsertionValues as s}from"./insertion/getInsertionValues.mjs";import{insert as c}from"./insertion/insertion.mjs";import{getMarkdownMetadata as l}from"./markdown/getMarkdownMetadata.mjs";import{validateMarkdown as u}from"./markdown/validateMarkdown.mjs";import{md as d}from"./markdown/markdown.mjs";import{nest as f}from"./nesting/nesting.mjs";import{t as p}from"./translation/translation.mjs";export{o as HTML_TAGS,i as VOID_ELEMENTS,e as cond,t as enu,n as gender,s as getInsertionValues,l as getMarkdownMetadata,r as html,c as insert,d as md,f as nest,p as t,a as validateHTML,u as validateMarkdown};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e}from"../../getContent-DKqtIZGL.mjs";import{n as t}from"../../html-3bo80xzx.mjs";import{getMarkdownMetadata as n}from"./getMarkdownMetadata.mjs";import{NodeType as r,formatNodeType as i}from"@intlayer/types/nodeType";const a=async e=>{if(typeof e==`string`||typeof e==`object`)return e;if(typeof e==`function`)return e();if(typeof e.then==`function`)return await e},o=(o,s)=>i(r.Markdown,o,{metadata:async()=>{let t=e(await a(o),{dictionaryKey:``,keyPath:[]});if(typeof t==`string`)return n(t)},tags:(()=>{if(s)return s;if(typeof o==`string`)return t(o);let e;if(typeof o==`function`?e=o():typeof o.then==`function`&&(e=async()=>t(await o)),typeof e==`string`)return t(e);try{return t(JSON.stringify(o))}catch{return[]}})()});export{o as md};
|
|
2
2
|
//# sourceMappingURL=markdown.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.mjs","names":[],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<NodeType.Markdown, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.Markdown, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.mjs","names":[],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<NodeType.Markdown, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.Markdown, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":"sOA8BA,MAAM,EAAe,KAAO,IAAiB,CAC3C,GAAI,OAAO,GAAY,UAAY,OAAO,GAAY,SACpD,OAAO,EAGT,GAAI,OAAO,GAAY,WACrB,OAAO,GAAS,CAElB,GAAI,OAAO,EAAQ,MAAS,WAC1B,OAAO,MAAM,GAgBX,GAIJ,EACA,IAuDO,EAAe,EAAS,SAAU,EAAS,CAChD,SAtDe,SAAY,CAG3B,IAAM,EAAc,EAFG,MAAM,EAAa,EAAQ,CAEH,CAC7C,cAAe,GACf,QAAS,EAAE,CACZ,CAAC,CAEF,GAAI,OAAO,GAAgB,SAYzB,OAAO,EAAoB,EAAY,EAmCzC,UA/B0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SACrB,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,KAMU,CACtB,CAAC"}
|
package/dist/esm/utils/intl.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{ENGLISH as e}from"@intlayer/types/locales";const t=(t,n)=>{let r=t?String(t):e;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}});export{i as CachedIntl,i as Intl,a as bindIntl,r as createCachedIntl};
|
|
2
2
|
//# sourceMappingURL=intl.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intl.mjs","names":[],"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":"0CAsEA,MAAM,GACJ,EACA,IACW,CACX,IAAM,EAAY,EAAU,OAAO,EAAQ,CAAG,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,E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../../../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":"kDAsEA,MAAM,GACJ,EACA,IACW,CACX,IAAM,EAAY,EAAU,OAAO,EAAQ,CAAG,EAM9C,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,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number | boolean | null | JsonValue[] | {
|
|
5
|
+
[key: string]: JsonValue;
|
|
6
|
+
};
|
|
7
|
+
declare const intlayerToICUFormatter: (message: Dictionary["content"]) => JsonValue;
|
|
8
|
+
declare const icuToIntlayerFormatter: (message: Dictionary["content"]) => JsonValue;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { icuToIntlayerFormatter as n, intlayerToICUFormatter as r, JsonValue as t };
|
|
11
|
+
//# sourceMappingURL=ICU-tA3ZHN5U.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICU-tA3ZHN5U.d.ts","names":[],"sources":["../../src/messageFormat/ICU.ts"],"mappings":";;;KA8CY,SAAA,sCAKR,SAAA;EAAA,CACG,GAAA,WAAc,SAAA;AAAA;AAAA,cAyeR,sBAAA,GACX,OAAA,EAAS,UAAA,gBACR,SAAA;AAAA,cAQU,sBAAA,GACX,OAAA,EAAS,UAAA,gBACR,SAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkIsURLAbsolute-CTf3JFU6.d.ts","names":[],"sources":["../../src/utils/checkIsURLAbsolute.ts"],"mappings":";cAAa,kBAAA,GAAsB,GAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
+
|
|
3
|
+
//#region src/formatters/compact.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Formats a numeric value using compact notation (e.g., 1K, 1M, 1B)
|
|
6
|
+
* based on locale and formatting options.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* compact({ value: 1200 }); // "1.2K"
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* compact({ value: "1000000", locale: Locales.FRENCH, compactDisplay: "long" });
|
|
13
|
+
* // "1 million"
|
|
14
|
+
*/
|
|
15
|
+
declare const compact: (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
16
|
+
locale?: LocalesValues;
|
|
17
|
+
}) => string;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { compact as t };
|
|
20
|
+
//# sourceMappingURL=compact-IHXcM4pT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compact-IHXcM4pT.d.ts","names":[],"sources":["../../src/formatters/compact.ts"],"mappings":";;;;;AAeA;;;;;;;;;cAAa,OAAA,GACX,KAAA,mBACA,OAAA,GAAU,IAAA,CAAK,mBAAA;EAAwB,MAAA,GAAS,aAAA;AAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { D as MarkdownContext, O as MarkdownOptions, c as CompileOptions, k as MarkdownRuntime } from "./types-C2Om0aEM.js";
|
|
2
|
+
|
|
3
|
+
//#region src/markdown/compiler.d.ts
|
|
4
|
+
declare const compile: (markdown: string, ctx: MarkdownContext<any>, options?: MarkdownOptions) => unknown;
|
|
5
|
+
declare const createCompiler: (ctx: MarkdownContext<any>) => (markdown: string, options?: MarkdownOptions) => unknown;
|
|
6
|
+
declare const compileWithOptions: (markdown: string, runtime: MarkdownRuntime, options?: CompileOptions<any>) => unknown;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { compileWithOptions as n, createCompiler as r, compile as t };
|
|
9
|
+
//# sourceMappingURL=compiler-DFiAsUdH.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler-DFiAsUdH.d.ts","names":[],"sources":["../../src/markdown/compiler.ts"],"mappings":";;;cA0/Ba,OAAA,GACX,QAAA,UACA,GAAA,EAAK,eAAA,OACL,OAAA,GAAS,eAAA;AAAA,cA+NE,cAAA,GACV,GAAA,EAAK,eAAA,WACL,QAAA,UAAkB,OAAA,GAAU,eAAA;AAAA,cAGlB,kBAAA,GACX,QAAA,UACA,OAAA,EAAS,eAAA,EACT,OAAA,GAAS,cAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NodeType, TypedNodeModel } from "@intlayer/types/nodeType";
|
|
2
|
+
|
|
3
|
+
//#region src/transpiler/condition/condition.d.ts
|
|
4
|
+
type ConditionContentStates<Content> = Record<`${boolean}`, Content> & {
|
|
5
|
+
fallback?: Content;
|
|
6
|
+
};
|
|
7
|
+
type ConditionContent<Content = unknown> = TypedNodeModel<NodeType.Condition, ConditionContentStates<Content>>;
|
|
8
|
+
/**
|
|
9
|
+
* Function intended to be used to build intlayer dictionaries.
|
|
10
|
+
*
|
|
11
|
+
* Allow to pick a content based on a condition.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* cond({
|
|
17
|
+
* 'true': 'The condition is validated',
|
|
18
|
+
* 'false': 'The condition is not validated',
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* The last key provided will be used as the fallback value.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
declare const condition: <Content>(content?: ConditionContentStates<Content>) => TypedNodeModel<NodeType.Condition, ConditionContentStates<Content>, {}>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ConditionContentStates as n, condition as r, ConditionContent as t };
|
|
28
|
+
//# sourceMappingURL=condition-BDUtoh_1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition-BDUtoh_1.d.ts","names":[],"sources":["../../src/transpiler/condition/condition.ts"],"mappings":";;;KAGY,sBAAA,YAAkC,MAAA,eAAqB,OAAA;EACjE,QAAA,GAAW,OAAA;AAAA;AAAA,KAGD,gBAAA,sBAAsC,cAAA,CAChD,QAAA,CAAS,SAAA,EACT,sBAAA,CAAuB,OAAA;;;;;;;;;;;;;AAFzB;;;;;cAsBM,SAAA,YAAsB,OAAA,GAAU,sBAAA,CAAuB,OAAA,MAAQ,cAAA,CAAA,QAAA,CAAA,SAAA,EAAA,sBAAA,CAAA,OAAA"}
|