@intlayer/core 8.1.2 → 8.1.3
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 +1 -29
- package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -212
- package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -94
- package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -45
- package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +1 -33
- package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMaskContent.cjs +1 -27
- package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -82
- package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs +1 -87
- package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs +1 -60
- package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -122
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/index.cjs +1 -32
- package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -106
- package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -64
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -18
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -55
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -26
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -23
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -36
- package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/index.cjs +1 -27
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -69
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs +1 -30
- package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +1 -48
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -31
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -39
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -38
- package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
- package/dist/cjs/formatters/compact.cjs +1 -25
- package/dist/cjs/formatters/compact.cjs.map +1 -1
- package/dist/cjs/formatters/currency.cjs +1 -29
- package/dist/cjs/formatters/currency.cjs.map +1 -1
- package/dist/cjs/formatters/date.cjs +1 -60
- package/dist/cjs/formatters/date.cjs.map +1 -1
- package/dist/cjs/formatters/index.cjs +1 -18
- package/dist/cjs/formatters/list.cjs +1 -30
- package/dist/cjs/formatters/list.cjs.map +1 -1
- package/dist/cjs/formatters/number.cjs +1 -18
- package/dist/cjs/formatters/number.cjs.map +1 -1
- package/dist/cjs/formatters/percentage.cjs +1 -25
- package/dist/cjs/formatters/percentage.cjs.map +1 -1
- package/dist/cjs/formatters/relativeTime.cjs +1 -33
- package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
- package/dist/cjs/formatters/units.cjs +1 -23
- package/dist/cjs/formatters/units.cjs.map +1 -1
- package/dist/cjs/getStorageAttributes.cjs +1 -134
- package/dist/cjs/getStorageAttributes.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -300
- package/dist/cjs/interpreter/getCondition.cjs +1 -27
- package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -41
- package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/getContent.cjs +1 -34
- package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/index.cjs +1 -14
- package/dist/cjs/interpreter/getContent/plugins.cjs +1 -161
- package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
- package/dist/cjs/interpreter/getDictionary.cjs +1 -24
- package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
- package/dist/cjs/interpreter/getEnumeration.cjs +1 -72
- package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
- package/dist/cjs/interpreter/getGender.cjs +1 -38
- package/dist/cjs/interpreter/getGender.cjs.map +1 -1
- package/dist/cjs/interpreter/getHTML.cjs +1 -121
- package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
- package/dist/cjs/interpreter/getInsertion.cjs +1 -22
- package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
- package/dist/cjs/interpreter/getIntlayer.cjs +1 -40
- package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
- package/dist/cjs/interpreter/getNesting.cjs +1 -36
- package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
- package/dist/cjs/interpreter/getTranslation.cjs +1 -112
- package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
- package/dist/cjs/interpreter/index.cjs +1 -31
- package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +1 -55
- package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
- package/dist/cjs/localization/getBrowserLocale.cjs +1 -143
- package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
- package/dist/cjs/localization/getHTMLTextDir.cjs +1 -64
- package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
- package/dist/cjs/localization/getLocale.cjs +1 -27
- package/dist/cjs/localization/getLocale.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleFromPath.cjs +1 -45
- package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleLang.cjs +1 -20
- package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleName.cjs +1 -10
- package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
- package/dist/cjs/localization/getLocalizedUrl.cjs +1 -82
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
- package/dist/cjs/localization/getMultilingualUrls.cjs +1 -63
- package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
- package/dist/cjs/localization/getPathWithoutLocale.cjs +1 -55
- package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
- package/dist/cjs/localization/getPrefix.cjs +1 -63
- package/dist/cjs/localization/getPrefix.cjs.map +1 -1
- package/dist/cjs/localization/index.cjs +1 -39
- package/dist/cjs/localization/localeDetector.cjs +1 -133
- package/dist/cjs/localization/localeDetector.cjs.map +1 -1
- package/dist/cjs/localization/localeMapper.cjs +1 -119
- package/dist/cjs/localization/localeMapper.cjs.map +1 -1
- package/dist/cjs/localization/localeResolver.cjs +1 -28
- package/dist/cjs/localization/localeResolver.cjs.map +1 -1
- package/dist/cjs/localization/rewriteUtils.cjs +1 -110
- package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
- package/dist/cjs/localization/validatePrefix.cjs +1 -54
- package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
- package/dist/cjs/markdown/compiler.cjs +10 -810
- package/dist/cjs/markdown/compiler.cjs.map +1 -1
- package/dist/cjs/markdown/constants.cjs +1 -328
- package/dist/cjs/markdown/constants.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +1 -120
- package/dist/cjs/markdown/parser.cjs +1 -66
- package/dist/cjs/markdown/parser.cjs.map +1 -1
- package/dist/cjs/markdown/renderer.cjs +1 -61
- package/dist/cjs/markdown/renderer.cjs.map +1 -1
- package/dist/cjs/markdown/utils.cjs +6 -391
- package/dist/cjs/markdown/utils.cjs.map +1 -1
- package/dist/cjs/messageFormat/ICU.cjs +1 -319
- package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
- package/dist/cjs/messageFormat/i18next.cjs +1 -330
- package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
- package/dist/cjs/messageFormat/index.cjs +1 -11
- package/dist/cjs/messageFormat/verify-icu-format.cjs +2 -64
- package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
- package/dist/cjs/messageFormat/vue-i18n.cjs +1 -166
- package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
- package/dist/cjs/transpiler/condition/condition.cjs +1 -26
- package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
- package/dist/cjs/transpiler/condition/index.cjs +1 -4
- package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -28
- package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
- package/dist/cjs/transpiler/enumeration/index.cjs +1 -4
- package/dist/cjs/transpiler/file/file.cjs +1 -52
- package/dist/cjs/transpiler/file/file.cjs.map +1 -1
- package/dist/cjs/transpiler/file/fileBrowser.cjs +1 -25
- package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
- package/dist/cjs/transpiler/file/index.cjs +1 -5
- package/dist/cjs/transpiler/gender/gender.cjs +1 -26
- package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
- package/dist/cjs/transpiler/gender/index.cjs +1 -4
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +1 -44
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
- package/dist/cjs/transpiler/html/html.cjs +1 -37
- package/dist/cjs/transpiler/html/html.cjs.map +1 -1
- package/dist/cjs/transpiler/html/htmlTags.cjs +1 -116
- package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
- package/dist/cjs/transpiler/html/index.cjs +1 -6
- package/dist/cjs/transpiler/index.cjs +1 -24
- package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +1 -11
- package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
- package/dist/cjs/transpiler/insertion/index.cjs +1 -6
- package/dist/cjs/transpiler/insertion/insertion.cjs +1 -36
- package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +2 -23
- package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/index.cjs +1 -6
- package/dist/cjs/transpiler/markdown/markdown.cjs +1 -54
- package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
- package/dist/cjs/transpiler/nesting/index.cjs +1 -4
- package/dist/cjs/transpiler/nesting/nesting.cjs +1 -27
- package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
- package/dist/cjs/transpiler/translation/index.cjs +1 -4
- package/dist/cjs/transpiler/translation/translation.cjs +1 -29
- package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
- package/dist/cjs/utils/checkIsURLAbsolute.cjs +1 -7
- package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
- package/dist/cjs/utils/getCookie.cjs +1 -32
- package/dist/cjs/utils/getCookie.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -0
- package/dist/cjs/utils/intl.cjs +1 -91
- package/dist/cjs/utils/intl.cjs.map +1 -1
- package/dist/cjs/utils/isSameKeyPath.cjs +1 -7
- package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
- package/dist/cjs/utils/isValidReactElement.cjs +1 -14
- package/dist/cjs/utils/isValidReactElement.cjs.map +1 -1
- package/dist/cjs/utils/localeStorage.cjs +1 -140
- package/dist/cjs/utils/localeStorage.cjs.map +1 -1
- package/dist/cjs/utils/parseYaml.cjs +16 -322
- package/dist/cjs/utils/parseYaml.cjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs +1 -207
- package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs +1 -89
- package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +1 -42
- package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +1 -31
- package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMaskContent.mjs +1 -25
- package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs +1 -77
- package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs +1 -86
- package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs +1 -59
- package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -119
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/index.mjs +1 -12
- package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs +1 -104
- package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -62
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -16
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +1 -53
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -24
- package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -21
- package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getNodeType.mjs +1 -34
- package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/index.mjs +1 -14
- package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -66
- package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs +1 -28
- package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/orderDictionaries.mjs +1 -45
- package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -29
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -37
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +1 -36
- package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
- package/dist/esm/formatters/compact.mjs +1 -22
- package/dist/esm/formatters/compact.mjs.map +1 -1
- package/dist/esm/formatters/currency.mjs +1 -26
- package/dist/esm/formatters/currency.mjs.map +1 -1
- package/dist/esm/formatters/date.mjs +1 -57
- package/dist/esm/formatters/date.mjs.map +1 -1
- package/dist/esm/formatters/index.mjs +1 -10
- package/dist/esm/formatters/list.mjs +1 -27
- package/dist/esm/formatters/list.mjs.map +1 -1
- package/dist/esm/formatters/number.mjs +1 -15
- package/dist/esm/formatters/number.mjs.map +1 -1
- package/dist/esm/formatters/percentage.mjs +1 -22
- package/dist/esm/formatters/percentage.mjs.map +1 -1
- package/dist/esm/formatters/relativeTime.mjs +1 -30
- package/dist/esm/formatters/relativeTime.mjs.map +1 -1
- package/dist/esm/formatters/units.mjs +1 -20
- package/dist/esm/formatters/units.mjs.map +1 -1
- package/dist/esm/getStorageAttributes.mjs +1 -132
- package/dist/esm/getStorageAttributes.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -82
- package/dist/esm/interpreter/getCondition.mjs +1 -25
- package/dist/esm/interpreter/getCondition.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -39
- package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/getContent.mjs +1 -31
- package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/index.mjs +1 -5
- package/dist/esm/interpreter/getContent/plugins.mjs +1 -153
- package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
- package/dist/esm/interpreter/getDictionary.mjs +1 -23
- package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
- package/dist/esm/interpreter/getEnumeration.mjs +1 -69
- package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
- package/dist/esm/interpreter/getGender.mjs +1 -36
- package/dist/esm/interpreter/getGender.mjs.map +1 -1
- package/dist/esm/interpreter/getHTML.mjs +1 -119
- package/dist/esm/interpreter/getHTML.mjs.map +1 -1
- package/dist/esm/interpreter/getInsertion.mjs +1 -20
- package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
- package/dist/esm/interpreter/getIntlayer.mjs +1 -36
- package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
- package/dist/esm/interpreter/getNesting.mjs +1 -35
- package/dist/esm/interpreter/getNesting.mjs.map +1 -1
- package/dist/esm/interpreter/getTranslation.mjs +1 -110
- package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
- package/dist/esm/interpreter/index.mjs +1 -13
- package/dist/esm/interpreter/splitAndJoinInsertion.mjs +1 -53
- package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
- package/dist/esm/localization/getBrowserLocale.mjs +1 -138
- package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
- package/dist/esm/localization/getHTMLTextDir.mjs +1 -62
- package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
- package/dist/esm/localization/getLocale.mjs +1 -24
- package/dist/esm/localization/getLocale.mjs.map +1 -1
- package/dist/esm/localization/getLocaleFromPath.mjs +1 -42
- package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
- package/dist/esm/localization/getLocaleLang.mjs +1 -18
- package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
- package/dist/esm/localization/getLocaleName.mjs +1 -9
- package/dist/esm/localization/getLocaleName.mjs.map +1 -1
- package/dist/esm/localization/getLocalizedUrl.mjs +1 -79
- package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
- package/dist/esm/localization/getMultilingualUrls.mjs +1 -60
- package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
- package/dist/esm/localization/getPathWithoutLocale.mjs +1 -52
- package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
- package/dist/esm/localization/getPrefix.mjs +1 -60
- package/dist/esm/localization/getPrefix.mjs.map +1 -1
- package/dist/esm/localization/index.mjs +1 -17
- package/dist/esm/localization/localeDetector.mjs +1 -131
- package/dist/esm/localization/localeDetector.mjs.map +1 -1
- package/dist/esm/localization/localeMapper.mjs +1 -114
- package/dist/esm/localization/localeMapper.mjs.map +1 -1
- package/dist/esm/localization/localeResolver.mjs +1 -25
- package/dist/esm/localization/localeResolver.mjs.map +1 -1
- package/dist/esm/localization/rewriteUtils.mjs +1 -104
- package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
- package/dist/esm/localization/validatePrefix.mjs +1 -51
- package/dist/esm/localization/validatePrefix.mjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs +10 -786
- package/dist/esm/markdown/compiler.mjs.map +1 -1
- package/dist/esm/markdown/constants.mjs +1 -247
- package/dist/esm/markdown/constants.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +1 -7
- package/dist/esm/markdown/parser.mjs +1 -65
- package/dist/esm/markdown/parser.mjs.map +1 -1
- package/dist/esm/markdown/renderer.mjs +1 -59
- package/dist/esm/markdown/renderer.mjs.map +1 -1
- package/dist/esm/markdown/utils.mjs +6 -361
- package/dist/esm/markdown/utils.mjs.map +1 -1
- package/dist/esm/messageFormat/ICU.mjs +1 -316
- package/dist/esm/messageFormat/ICU.mjs.map +1 -1
- package/dist/esm/messageFormat/i18next.mjs +1 -327
- package/dist/esm/messageFormat/i18next.mjs.map +1 -1
- package/dist/esm/messageFormat/index.mjs +1 -5
- package/dist/esm/messageFormat/verify-icu-format.mjs +2 -64
- package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
- package/dist/esm/messageFormat/vue-i18n.mjs +1 -163
- package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
- package/dist/esm/transpiler/condition/condition.mjs +1 -24
- package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
- package/dist/esm/transpiler/condition/index.mjs +1 -3
- package/dist/esm/transpiler/enumeration/enumeration.mjs +1 -26
- package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
- package/dist/esm/transpiler/enumeration/index.mjs +1 -3
- package/dist/esm/transpiler/file/file.mjs +1 -49
- package/dist/esm/transpiler/file/file.mjs.map +1 -1
- package/dist/esm/transpiler/file/fileBrowser.mjs +1 -24
- package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
- package/dist/esm/transpiler/file/index.mjs +1 -3
- package/dist/esm/transpiler/gender/gender.mjs +1 -24
- package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
- package/dist/esm/transpiler/gender/index.mjs +1 -3
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -43
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
- package/dist/esm/transpiler/html/html.mjs +1 -35
- package/dist/esm/transpiler/html/html.mjs.map +1 -1
- package/dist/esm/transpiler/html/htmlTags.mjs +1 -114
- package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
- package/dist/esm/transpiler/html/index.mjs +1 -4
- package/dist/esm/transpiler/index.mjs +1 -13
- package/dist/esm/transpiler/insertion/getInsertionValues.mjs +1 -9
- package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
- package/dist/esm/transpiler/insertion/index.mjs +1 -4
- package/dist/esm/transpiler/insertion/insertion.mjs +1 -34
- package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +2 -22
- package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/index.mjs +1 -4
- package/dist/esm/transpiler/markdown/markdown.mjs +1 -52
- package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
- package/dist/esm/transpiler/nesting/index.mjs +1 -3
- package/dist/esm/transpiler/nesting/nesting.mjs +1 -25
- package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
- package/dist/esm/transpiler/translation/index.mjs +1 -3
- package/dist/esm/transpiler/translation/translation.mjs +1 -27
- package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
- package/dist/esm/utils/checkIsURLAbsolute.mjs +1 -5
- package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
- package/dist/esm/utils/getCookie.mjs +1 -30
- package/dist/esm/utils/getCookie.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -0
- package/dist/esm/utils/intl.mjs +1 -86
- package/dist/esm/utils/intl.mjs.map +1 -1
- package/dist/esm/utils/isSameKeyPath.mjs +1 -5
- package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
- package/dist/esm/utils/isValidReactElement.mjs +1 -12
- package/dist/esm/utils/isValidReactElement.mjs.map +1 -1
- package/dist/esm/utils/localeStorage.mjs +1 -135
- package/dist/esm/utils/localeStorage.mjs.map +1 -1
- package/dist/esm/utils/parseYaml.mjs +16 -320
- package/dist/esm/utils/parseYaml.mjs.map +1 -1
- package/dist/types/formatters/index.d.ts +2 -1
- package/dist/types/index.d.ts +8 -2
- package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/localization/index.d.ts +2 -1
- package/dist/types/markdown/index.d.ts +4 -1
- package/dist/types/markdown/types.d.ts +1 -1
- package/dist/types/markdown/types.d.ts.map +1 -1
- package/dist/types/transpiler/translation/translation.d.ts +1 -1
- package/dist/types/utils/index.d.ts +8 -0
- package/package.json +65 -11
|
@@ -1,70 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Find the matching condition for a quantity.
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* const key = findMatchingCondition({
|
|
9
|
-
* '<=-2.3': 'You have less than -2.3',
|
|
10
|
-
* '<1': 'You have less than one',
|
|
11
|
-
* '2': 'You have two',
|
|
12
|
-
* '>=3': 'You have three or more',
|
|
13
|
-
* }, 2);
|
|
14
|
-
* // '2'
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* The order of the keys will define the priority of the content.
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* const key = findMatchingCondition({
|
|
21
|
-
* '<4': 'You have less than four',
|
|
22
|
-
* '2': 'You have two',
|
|
23
|
-
* }, 2);
|
|
24
|
-
* // '<4'
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* If no keys match, the default key is '1'.
|
|
28
|
-
*/
|
|
29
|
-
const findMatchingCondition = (enumerationContent, quantity) => {
|
|
30
|
-
const numericKeys = Object.keys(enumerationContent);
|
|
31
|
-
for (const key of numericKeys) {
|
|
32
|
-
const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity;
|
|
33
|
-
const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1));
|
|
34
|
-
const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
|
|
35
|
-
const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1));
|
|
36
|
-
const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
|
|
37
|
-
if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) return key;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Picks content from an enumeration map based on a provided quantity.
|
|
42
|
-
*
|
|
43
|
-
* Supported keys in the enumeration map:
|
|
44
|
-
* - Specific numbers: '0', '1', '2'
|
|
45
|
-
* - Comparison operators: '<5', '>=10', '<=2'
|
|
46
|
-
* - Fallback: 'fallback'
|
|
47
|
-
*
|
|
48
|
-
* The first matching key in the object's iteration order will be selected.
|
|
49
|
-
*
|
|
50
|
-
* @param enumerationContent - A map of conditions/quantities to content.
|
|
51
|
-
* @param quantity - The number to match against the conditions.
|
|
52
|
-
* @returns The matching content.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* const content = getEnumeration({
|
|
57
|
-
* '0': 'No items',
|
|
58
|
-
* '1': 'One item',
|
|
59
|
-
* '>1': 'Many items',
|
|
60
|
-
* }, 5);
|
|
61
|
-
* // 'Many items'
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
const getEnumeration = (enumerationContent, quantity) => {
|
|
65
|
-
return enumerationContent[findMatchingCondition(enumerationContent, quantity) ?? "fallback"];
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { findMatchingCondition, getEnumeration };
|
|
1
|
+
const e=(e,t)=>{let n=Object.keys(e);for(let e of n){let n=!e.startsWith(`>`)&&!e.startsWith(`<`)&&!e.startsWith(`=`)&&parseFloat(e)===t||e.startsWith(`=`)&&parseFloat(e.slice(1))===t,r=e.startsWith(`>`)&&t>parseFloat(e.slice(1)),i=e.startsWith(`>=`)&&t>=parseFloat(e.slice(2)),a=e.startsWith(`<`)&&t<parseFloat(e.slice(1)),o=e.startsWith(`<=`)&&t<=parseFloat(e.slice(2));if(n||r||i||a||o)return e}},t=(t,n)=>t[e(t,n)??`fallback`];export{e as findMatchingCondition,t as getEnumeration};
|
|
70
2
|
//# sourceMappingURL=getEnumeration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEnumeration.mjs","names":[],"sources":["../../../src/interpreter/getEnumeration.ts"],"sourcesContent":["import type { EnterFormat, EnumerationContentState } from '../transpiler';\n\n/**\n * Find the matching condition for a quantity.\n *\n * Usage:\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // '2'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // '<4'\n * ```\n *\n * If no keys match, the default key is '1'.\n */\nexport const findMatchingCondition = <Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): EnterFormat | undefined => {\n const numericKeys = Object.keys(enumerationContent);\n\n for (const key of numericKeys) {\n const isEqual =\n (!key.startsWith('>') &&\n !key.startsWith('<') &&\n !key.startsWith('=') &&\n parseFloat(key) === quantity) ||\n (key.startsWith('=') && parseFloat(key.slice(1)) === quantity);\n const isSuperior =\n key.startsWith('>') && quantity > parseFloat(key.slice(1));\n const isSuperiorOrEqual =\n key.startsWith('>=') && quantity >= parseFloat(key.slice(2));\n const isInferior =\n key.startsWith('<') && quantity < parseFloat(key.slice(1));\n const isInferiorOrEqual =\n key.startsWith('<=') && quantity <= parseFloat(key.slice(2));\n\n if (\n isEqual ||\n isSuperior ||\n isSuperiorOrEqual ||\n isInferior ||\n isInferiorOrEqual\n ) {\n return key as EnterFormat;\n }\n }\n};\n\n/**\n * Picks content from an enumeration map based on a provided quantity.\n *\n * Supported keys in the enumeration map:\n * - Specific numbers: '0', '1', '2'\n * - Comparison operators: '<5', '>=10', '<=2'\n * - Fallback: 'fallback'\n *\n * The first matching key in the object's iteration order will be selected.\n *\n * @param enumerationContent - A map of conditions/quantities to content.\n * @param quantity - The number to match against the conditions.\n * @returns The matching content.\n *\n * @example\n * ```ts\n * const content = getEnumeration({\n * '0': 'No items',\n * '1': 'One item',\n * '>1': 'Many items',\n * }, 5);\n * // 'Many items'\n * ```\n */\nexport const getEnumeration = <Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): Content => {\n const key =\n findMatchingCondition<Content>(enumerationContent, quantity) ?? 'fallback';\n\n // Default or error handling if no keys match\n return enumerationContent[key] as Content;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getEnumeration.mjs","names":[],"sources":["../../../src/interpreter/getEnumeration.ts"],"sourcesContent":["import type { EnterFormat, EnumerationContentState } from '../transpiler';\n\n/**\n * Find the matching condition for a quantity.\n *\n * Usage:\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // '2'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // '<4'\n * ```\n *\n * If no keys match, the default key is '1'.\n */\nexport const findMatchingCondition = <Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): EnterFormat | undefined => {\n const numericKeys = Object.keys(enumerationContent);\n\n for (const key of numericKeys) {\n const isEqual =\n (!key.startsWith('>') &&\n !key.startsWith('<') &&\n !key.startsWith('=') &&\n parseFloat(key) === quantity) ||\n (key.startsWith('=') && parseFloat(key.slice(1)) === quantity);\n const isSuperior =\n key.startsWith('>') && quantity > parseFloat(key.slice(1));\n const isSuperiorOrEqual =\n key.startsWith('>=') && quantity >= parseFloat(key.slice(2));\n const isInferior =\n key.startsWith('<') && quantity < parseFloat(key.slice(1));\n const isInferiorOrEqual =\n key.startsWith('<=') && quantity <= parseFloat(key.slice(2));\n\n if (\n isEqual ||\n isSuperior ||\n isSuperiorOrEqual ||\n isInferior ||\n isInferiorOrEqual\n ) {\n return key as EnterFormat;\n }\n }\n};\n\n/**\n * Picks content from an enumeration map based on a provided quantity.\n *\n * Supported keys in the enumeration map:\n * - Specific numbers: '0', '1', '2'\n * - Comparison operators: '<5', '>=10', '<=2'\n * - Fallback: 'fallback'\n *\n * The first matching key in the object's iteration order will be selected.\n *\n * @param enumerationContent - A map of conditions/quantities to content.\n * @param quantity - The number to match against the conditions.\n * @returns The matching content.\n *\n * @example\n * ```ts\n * const content = getEnumeration({\n * '0': 'No items',\n * '1': 'One item',\n * '>1': 'Many items',\n * }, 5);\n * // 'Many items'\n * ```\n */\nexport const getEnumeration = <Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): Content => {\n const key =\n findMatchingCondition<Content>(enumerationContent, quantity) ?? 'fallback';\n\n // Default or error handling if no keys match\n return enumerationContent[key] as Content;\n};\n"],"mappings":"AA6BA,MAAa,GACX,EACA,IAC4B,CAC5B,IAAM,EAAc,OAAO,KAAK,EAAmB,CAEnD,IAAK,IAAM,KAAO,EAAa,CAC7B,IAAM,EACH,CAAC,EAAI,WAAW,IAAI,EACnB,CAAC,EAAI,WAAW,IAAI,EACpB,CAAC,EAAI,WAAW,IAAI,EACpB,WAAW,EAAI,GAAK,GACrB,EAAI,WAAW,IAAI,EAAI,WAAW,EAAI,MAAM,EAAE,CAAC,GAAK,EACjD,EACJ,EAAI,WAAW,IAAI,EAAI,EAAW,WAAW,EAAI,MAAM,EAAE,CAAC,CACtD,EACJ,EAAI,WAAW,KAAK,EAAI,GAAY,WAAW,EAAI,MAAM,EAAE,CAAC,CACxD,EACJ,EAAI,WAAW,IAAI,EAAI,EAAW,WAAW,EAAI,MAAM,EAAE,CAAC,CACtD,EACJ,EAAI,WAAW,KAAK,EAAI,GAAY,WAAW,EAAI,MAAM,EAAE,CAAC,CAE9D,GACE,GACA,GACA,GACA,GACA,EAEA,OAAO,IA6BA,GACX,EACA,IAMO,EAHL,EAA+B,EAAoB,EAAS,EAAI"}
|
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
const getGenderEntry = (gender) => {
|
|
3
|
-
if (gender === "m" || gender === "male") return "male";
|
|
4
|
-
if (gender === "f" || gender === "female") return "female";
|
|
5
|
-
return "fallback";
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Allow to pick a content based on a gender.
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* const content = getGender({
|
|
14
|
-
* 'true': 'The gender is validated',
|
|
15
|
-
* 'false': 'The gender is not validated',
|
|
16
|
-
* }, true);
|
|
17
|
-
* // 'The gender is validated'
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* The last key provided will be used as the fallback value.
|
|
21
|
-
*
|
|
22
|
-
* ```ts
|
|
23
|
-
* const content = getGender({
|
|
24
|
-
* 'false': 'The gender is not validated',
|
|
25
|
-
* 'true': 'The gender is validated',
|
|
26
|
-
* }, undefined);
|
|
27
|
-
* // 'The gender is validated'
|
|
28
|
-
*/
|
|
29
|
-
const getGender = (genderContent, gender) => {
|
|
30
|
-
const stateList = Object.keys(genderContent);
|
|
31
|
-
const fallbackState = stateList[stateList.length - 1];
|
|
32
|
-
return genderContent[getGenderEntry(gender)] ?? genderContent.fallback ?? genderContent[fallbackState];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { getGender };
|
|
1
|
+
const e=e=>e===`m`||e===`male`?`male`:e===`f`||e===`female`?`female`:`fallback`,t=(t,n)=>{let r=Object.keys(t),i=r[r.length-1];return t[e(n)]??t.fallback??t[i]};export{t as getGender};
|
|
37
2
|
//# sourceMappingURL=getGender.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getGender.mjs","names":[],"sources":["../../../src/interpreter/getGender.ts"],"sourcesContent":["import type { Gender, GenderContentStates } from '../transpiler';\n\ntype GenderEntry = Gender | 'm' | 'f';\n\nconst getGenderEntry = (gender: GenderEntry): Gender => {\n if (gender === 'm' || gender === 'male') return 'male';\n if (gender === 'f' || gender === 'female') return 'female';\n return 'fallback';\n};\n\n/**\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * const content = getGender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * }, true);\n * // 'The gender is validated'\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n * ```ts\n * const content = getGender({\n * 'false': 'The gender is not validated',\n * 'true': 'The gender is validated',\n * }, undefined);\n * // 'The gender is validated'\n */\nexport const getGender = <Content>(\n genderContent: GenderContentStates<Content>,\n gender: GenderEntry\n): Content => {\n const stateList = Object.keys(genderContent);\n\n const fallbackState = stateList[\n stateList.length - 1\n ] as keyof typeof genderContent;\n\n const genderEntry = getGenderEntry(gender);\n\n // Default or error handling if no keys match\n return (\n genderContent[genderEntry as keyof typeof genderContent] ??\n genderContent.fallback ??\n (genderContent[fallbackState] as Content)\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getGender.mjs","names":[],"sources":["../../../src/interpreter/getGender.ts"],"sourcesContent":["import type { Gender, GenderContentStates } from '../transpiler';\n\ntype GenderEntry = Gender | 'm' | 'f';\n\nconst getGenderEntry = (gender: GenderEntry): Gender => {\n if (gender === 'm' || gender === 'male') return 'male';\n if (gender === 'f' || gender === 'female') return 'female';\n return 'fallback';\n};\n\n/**\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * const content = getGender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * }, true);\n * // 'The gender is validated'\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n * ```ts\n * const content = getGender({\n * 'false': 'The gender is not validated',\n * 'true': 'The gender is validated',\n * }, undefined);\n * // 'The gender is validated'\n */\nexport const getGender = <Content>(\n genderContent: GenderContentStates<Content>,\n gender: GenderEntry\n): Content => {\n const stateList = Object.keys(genderContent);\n\n const fallbackState = stateList[\n stateList.length - 1\n ] as keyof typeof genderContent;\n\n const genderEntry = getGenderEntry(gender);\n\n // Default or error handling if no keys match\n return (\n genderContent[genderEntry as keyof typeof genderContent] ??\n genderContent.fallback ??\n (genderContent[fallbackState] as Content)\n );\n};\n"],"mappings":"AAIA,MAAM,EAAkB,GAClB,IAAW,KAAO,IAAW,OAAe,OAC5C,IAAW,KAAO,IAAW,SAAiB,SAC3C,WAyBI,GACX,EACA,IACY,CACZ,IAAM,EAAY,OAAO,KAAK,EAAc,CAEtC,EAAgB,EACpB,EAAU,OAAS,GAMrB,OACE,EAJkB,EAAe,EAAO,GAKxC,EAAc,UACb,EAAc"}
|
|
@@ -1,120 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Helper to parse attributes from a tag string.
|
|
4
|
-
*/
|
|
5
|
-
const parseAttributes = (attributes) => {
|
|
6
|
-
const props = {};
|
|
7
|
-
const attrRegex = /([a-zA-Z0-9-]+)="([^"]*)"/g;
|
|
8
|
-
let match = attrRegex.exec(attributes);
|
|
9
|
-
while (match !== null) {
|
|
10
|
-
props[match[1]] = match[2];
|
|
11
|
-
match = attrRegex.exec(attributes);
|
|
12
|
-
}
|
|
13
|
-
return props;
|
|
14
|
-
};
|
|
15
|
-
const astCache = /* @__PURE__ */ new Map();
|
|
16
|
-
const parseHTML = (content) => {
|
|
17
|
-
if (astCache.has(content)) return astCache.get(content);
|
|
18
|
-
if (typeof content !== "string") return [];
|
|
19
|
-
const tagRegex = /<(\/)?([a-zA-Z0-9.-]+)([\s\S]*?)(\/?)>/g;
|
|
20
|
-
const elements = [];
|
|
21
|
-
const stack = [];
|
|
22
|
-
let lastIndex = 0;
|
|
23
|
-
let match = tagRegex.exec(content);
|
|
24
|
-
const appendChild = (child) => {
|
|
25
|
-
(stack.length > 0 ? stack[stack.length - 1].children : elements).push(child);
|
|
26
|
-
};
|
|
27
|
-
while (match !== null) {
|
|
28
|
-
const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] = match;
|
|
29
|
-
const matchIndex = match.index;
|
|
30
|
-
if (matchIndex > lastIndex) appendChild(content.slice(lastIndex, matchIndex));
|
|
31
|
-
const isClosing = isClosingRaw === "/";
|
|
32
|
-
const isSelfClosing = isSelfClosingRaw === "/" || attributesRaw.trim().endsWith("/") || fullMatch.endsWith("/>");
|
|
33
|
-
const cleanedAttributes = attributesRaw.trim().replace(/\/$/, "").trim();
|
|
34
|
-
if (isClosing) {
|
|
35
|
-
const last = stack.pop();
|
|
36
|
-
if (last) appendChild({
|
|
37
|
-
tagName: last.tagName,
|
|
38
|
-
props: last.props,
|
|
39
|
-
children: last.children
|
|
40
|
-
});
|
|
41
|
-
} else if (isSelfClosing) appendChild({
|
|
42
|
-
tagName,
|
|
43
|
-
props: parseAttributes(cleanedAttributes),
|
|
44
|
-
children: []
|
|
45
|
-
});
|
|
46
|
-
else {
|
|
47
|
-
const tagProps = parseAttributes(cleanedAttributes);
|
|
48
|
-
stack.push({
|
|
49
|
-
tagName,
|
|
50
|
-
children: [],
|
|
51
|
-
props: tagProps
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
lastIndex = matchIndex + fullMatch.length;
|
|
55
|
-
match = tagRegex.exec(content);
|
|
56
|
-
}
|
|
57
|
-
if (lastIndex < content.length) appendChild(content.slice(lastIndex));
|
|
58
|
-
while (stack.length > 0) {
|
|
59
|
-
const last = stack.pop();
|
|
60
|
-
if (last) appendChild({
|
|
61
|
-
tagName: last.tagName,
|
|
62
|
-
props: last.props,
|
|
63
|
-
children: last.children
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
astCache.set(content, elements);
|
|
67
|
-
return elements;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Interprets a string containing HTML-like tags and replaces them with provided components or strings.
|
|
71
|
-
*/
|
|
72
|
-
const getHTML = (content, values) => {
|
|
73
|
-
const ast = parseHTML(content);
|
|
74
|
-
let keyCounter = 0;
|
|
75
|
-
const renderASTNode = (node) => {
|
|
76
|
-
if (typeof node === "string") return node;
|
|
77
|
-
const { tagName, props, children } = node;
|
|
78
|
-
const renderedChildren = children.flatMap(renderASTNode);
|
|
79
|
-
const index = keyCounter++;
|
|
80
|
-
let override = values[tagName];
|
|
81
|
-
if (!override) {
|
|
82
|
-
const lowerTagName = tagName.toLowerCase();
|
|
83
|
-
const foundKey = Object.keys(values).find((key) => key.toLowerCase() === lowerTagName);
|
|
84
|
-
if (foundKey) override = values[foundKey];
|
|
85
|
-
}
|
|
86
|
-
const key = `html-tag-${tagName}-${index}`;
|
|
87
|
-
if (typeof override === "function") return override({
|
|
88
|
-
...props,
|
|
89
|
-
children: renderedChildren,
|
|
90
|
-
key
|
|
91
|
-
});
|
|
92
|
-
if (typeof override === "string") {
|
|
93
|
-
const component = values[override];
|
|
94
|
-
if (typeof component === "function") return component({
|
|
95
|
-
...props,
|
|
96
|
-
children: renderedChildren,
|
|
97
|
-
key
|
|
98
|
-
});
|
|
99
|
-
return renderedChildren;
|
|
100
|
-
}
|
|
101
|
-
if (typeof override === "object" && override !== null && "tag" in override) {
|
|
102
|
-
const { tag: targetTag, props: extraProps } = override;
|
|
103
|
-
const component = values[targetTag];
|
|
104
|
-
if (typeof component === "function") return component({
|
|
105
|
-
...props,
|
|
106
|
-
...extraProps,
|
|
107
|
-
children: renderedChildren,
|
|
108
|
-
key
|
|
109
|
-
});
|
|
110
|
-
return renderedChildren;
|
|
111
|
-
}
|
|
112
|
-
return renderedChildren;
|
|
113
|
-
};
|
|
114
|
-
const result = ast.flatMap(renderASTNode);
|
|
115
|
-
return result.length === 1 ? result[0] : result;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
//#endregion
|
|
119
|
-
export { getHTML };
|
|
1
|
+
const e=e=>{let t={},n=/([a-zA-Z0-9-]+)="([^"]*)"/g,r=n.exec(e);for(;r!==null;)t[r[1]]=r[2],r=n.exec(e);return t},t=new Map,n=n=>{if(t.has(n))return t.get(n);if(typeof n!=`string`)return[];let r=/<(\/)?([a-zA-Z0-9.-]+)([\s\S]*?)(\/?)>/g,i=[],a=[],o=0,s=r.exec(n),c=e=>{(a.length>0?a[a.length-1].children:i).push(e)};for(;s!==null;){let[t,i,l,u,d]=s,f=s.index;f>o&&c(n.slice(o,f));let p=i===`/`,m=d===`/`||u.trim().endsWith(`/`)||t.endsWith(`/>`),h=u.trim().replace(/\/$/,``).trim();if(p){let e=a.pop();e&&c({tagName:e.tagName,props:e.props,children:e.children})}else if(m)c({tagName:l,props:e(h),children:[]});else{let t=e(h);a.push({tagName:l,children:[],props:t})}o=f+t.length,s=r.exec(n)}for(o<n.length&&c(n.slice(o));a.length>0;){let e=a.pop();e&&c({tagName:e.tagName,props:e.props,children:e.children})}return t.set(n,i),i},r=(e,t)=>{let r=n(e),i=0,a=e=>{if(typeof e==`string`)return e;let{tagName:n,props:r,children:o}=e,s=o.flatMap(a),c=i++,l=t[n];if(!l){let e=n.toLowerCase(),r=Object.keys(t).find(t=>t.toLowerCase()===e);r&&(l=t[r])}let u=`html-tag-${n}-${c}`;if(typeof l==`function`)return l({...r,children:s,key:u});if(typeof l==`string`){let e=t[l];return typeof e==`function`?e({...r,children:s,key:u}):s}if(typeof l==`object`&&l&&`tag`in l){let{tag:e,props:n}=l,i=t[e];return typeof i==`function`?i({...r,...n,children:s,key:u}):s}return s},o=r.flatMap(a);return o.length===1?o[0]:o};export{r as getHTML};
|
|
120
2
|
//# sourceMappingURL=getHTML.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHTML.mjs","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"sourcesContent":["/**\n * Component function that receives properly typed props\n * Props include:\n * - children?: any[] - Array of child elements (ReactNode[], VNode[], etc.)\n * - [key: string]: any - Any HTML attributes (className, style, href, etc.)\n */\ntype Component = (props: { children?: any[]; [key: string]: any }) => any;\n\n/**\n * Component object that delegates to another component\n */\ntype ComponentObject = {\n tag: string;\n props?: Record<string, any>;\n};\n\n/**\n * Components map:\n * - Function components receive typed props\n * - String components delegate to another tag\n * - Object components delegate with additional props\n */\ntype Components = Record<string, Component | string | ComponentObject>;\n\n/**\n * Helper to parse attributes from a tag string.\n */\nconst parseAttributes = (attributes: string): Record<string, string> => {\n const props: Record<string, string> = {};\n const attrRegex = /([a-zA-Z0-9-]+)=\"([^\"]*)\"/g;\n\n let match = attrRegex.exec(attributes);\n while (match !== null) {\n props[match[1]] = match[2];\n match = attrRegex.exec(attributes);\n }\n return props;\n};\n\ntype ASTNode =\n | string\n | {\n tagName: string;\n props: Record<string, string>;\n children: ASTNode[];\n };\n\nconst astCache = new Map<string, ASTNode[]>();\n\nconst parseHTML = (content: string): ASTNode[] => {\n if (astCache.has(content)) {\n return astCache.get(content)!;\n }\n\n if (typeof content !== 'string') {\n return [];\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)([\\s\\S]*?)(\\/?)>/g;\n const elements: ASTNode[] = [];\n const stack: {\n tagName: string;\n children: ASTNode[];\n props: Record<string, string>;\n }[] = [];\n\n let lastIndex = 0;\n let match = tagRegex.exec(content);\n\n const appendChild = (child: ASTNode) => {\n const target =\n stack.length > 0 ? stack[stack.length - 1].children : elements;\n target.push(child);\n };\n\n while (match !== null) {\n const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] =\n match;\n const matchIndex = match.index;\n\n if (matchIndex > lastIndex) {\n appendChild(content.slice(lastIndex, matchIndex));\n }\n\n const isClosing = isClosingRaw === '/';\n const isSelfClosing =\n isSelfClosingRaw === '/' ||\n attributesRaw.trim().endsWith('/') ||\n fullMatch.endsWith('/>');\n\n const cleanedAttributes = attributesRaw.trim().replace(/\\/$/, '').trim();\n\n if (isClosing) {\n const last = stack.pop();\n\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n } else if (isSelfClosing) {\n const tagProps = parseAttributes(cleanedAttributes);\n appendChild({\n tagName,\n props: tagProps,\n children: [],\n });\n } else {\n const tagProps = parseAttributes(cleanedAttributes);\n stack.push({ tagName, children: [], props: tagProps });\n }\n\n lastIndex = matchIndex + fullMatch.length;\n match = tagRegex.exec(content);\n }\n\n if (lastIndex < content.length) {\n appendChild(content.slice(lastIndex));\n }\n\n // Handle unclosed tags by appending them to the root or parent\n while (stack.length > 0) {\n const last = stack.pop();\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n }\n\n astCache.set(content, elements);\n return elements;\n};\n\n/**\n * Interprets a string containing HTML-like tags and replaces them with provided components or strings.\n */\nexport const getHTML = (content: string, values: Components): any => {\n // Parse into AST (cached)\n const ast = parseHTML(content);\n\n // Render AST\n let keyCounter = 0;\n\n const renderASTNode = (node: ASTNode): any => {\n if (typeof node === 'string') {\n return node;\n }\n\n const { tagName, props, children } = node;\n const renderedChildren = children.flatMap(renderASTNode);\n const index = keyCounter++;\n\n let override = values[tagName];\n\n if (!override) {\n const lowerTagName = tagName.toLowerCase();\n const foundKey = Object.keys(values).find(\n (key) => key.toLowerCase() === lowerTagName\n );\n\n if (foundKey) override = values[foundKey];\n }\n\n const key = `html-tag-${tagName}-${index}`;\n\n if (typeof override === 'function') {\n return override({ ...props, children: renderedChildren, key });\n }\n\n if (typeof override === 'string') {\n const component = values[override];\n\n if (typeof component === 'function') {\n return component({ ...props, children: renderedChildren, key });\n }\n return renderedChildren;\n }\n\n if (\n typeof override === 'object' &&\n override !== null &&\n 'tag' in override\n ) {\n const { tag: targetTag, props: extraProps } = override as ComponentObject;\n const component = values[targetTag];\n\n if (typeof component === 'function') {\n return component({\n ...props,\n ...extraProps,\n children: renderedChildren,\n key,\n });\n }\n return renderedChildren;\n }\n\n // Default: Skip tag, render children\n return renderedChildren;\n };\n\n const result = ast.flatMap(renderASTNode);\n return result.length === 1 ? result[0] : result;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getHTML.mjs","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"sourcesContent":["/**\n * Component function that receives properly typed props\n * Props include:\n * - children?: any[] - Array of child elements (ReactNode[], VNode[], etc.)\n * - [key: string]: any - Any HTML attributes (className, style, href, etc.)\n */\ntype Component = (props: { children?: any[]; [key: string]: any }) => any;\n\n/**\n * Component object that delegates to another component\n */\ntype ComponentObject = {\n tag: string;\n props?: Record<string, any>;\n};\n\n/**\n * Components map:\n * - Function components receive typed props\n * - String components delegate to another tag\n * - Object components delegate with additional props\n */\ntype Components = Record<string, Component | string | ComponentObject>;\n\n/**\n * Helper to parse attributes from a tag string.\n */\nconst parseAttributes = (attributes: string): Record<string, string> => {\n const props: Record<string, string> = {};\n const attrRegex = /([a-zA-Z0-9-]+)=\"([^\"]*)\"/g;\n\n let match = attrRegex.exec(attributes);\n while (match !== null) {\n props[match[1]] = match[2];\n match = attrRegex.exec(attributes);\n }\n return props;\n};\n\ntype ASTNode =\n | string\n | {\n tagName: string;\n props: Record<string, string>;\n children: ASTNode[];\n };\n\nconst astCache = new Map<string, ASTNode[]>();\n\nconst parseHTML = (content: string): ASTNode[] => {\n if (astCache.has(content)) {\n return astCache.get(content)!;\n }\n\n if (typeof content !== 'string') {\n return [];\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)([\\s\\S]*?)(\\/?)>/g;\n const elements: ASTNode[] = [];\n const stack: {\n tagName: string;\n children: ASTNode[];\n props: Record<string, string>;\n }[] = [];\n\n let lastIndex = 0;\n let match = tagRegex.exec(content);\n\n const appendChild = (child: ASTNode) => {\n const target =\n stack.length > 0 ? stack[stack.length - 1].children : elements;\n target.push(child);\n };\n\n while (match !== null) {\n const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] =\n match;\n const matchIndex = match.index;\n\n if (matchIndex > lastIndex) {\n appendChild(content.slice(lastIndex, matchIndex));\n }\n\n const isClosing = isClosingRaw === '/';\n const isSelfClosing =\n isSelfClosingRaw === '/' ||\n attributesRaw.trim().endsWith('/') ||\n fullMatch.endsWith('/>');\n\n const cleanedAttributes = attributesRaw.trim().replace(/\\/$/, '').trim();\n\n if (isClosing) {\n const last = stack.pop();\n\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n } else if (isSelfClosing) {\n const tagProps = parseAttributes(cleanedAttributes);\n appendChild({\n tagName,\n props: tagProps,\n children: [],\n });\n } else {\n const tagProps = parseAttributes(cleanedAttributes);\n stack.push({ tagName, children: [], props: tagProps });\n }\n\n lastIndex = matchIndex + fullMatch.length;\n match = tagRegex.exec(content);\n }\n\n if (lastIndex < content.length) {\n appendChild(content.slice(lastIndex));\n }\n\n // Handle unclosed tags by appending them to the root or parent\n while (stack.length > 0) {\n const last = stack.pop();\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n }\n\n astCache.set(content, elements);\n return elements;\n};\n\n/**\n * Interprets a string containing HTML-like tags and replaces them with provided components or strings.\n */\nexport const getHTML = (content: string, values: Components): any => {\n // Parse into AST (cached)\n const ast = parseHTML(content);\n\n // Render AST\n let keyCounter = 0;\n\n const renderASTNode = (node: ASTNode): any => {\n if (typeof node === 'string') {\n return node;\n }\n\n const { tagName, props, children } = node;\n const renderedChildren = children.flatMap(renderASTNode);\n const index = keyCounter++;\n\n let override = values[tagName];\n\n if (!override) {\n const lowerTagName = tagName.toLowerCase();\n const foundKey = Object.keys(values).find(\n (key) => key.toLowerCase() === lowerTagName\n );\n\n if (foundKey) override = values[foundKey];\n }\n\n const key = `html-tag-${tagName}-${index}`;\n\n if (typeof override === 'function') {\n return override({ ...props, children: renderedChildren, key });\n }\n\n if (typeof override === 'string') {\n const component = values[override];\n\n if (typeof component === 'function') {\n return component({ ...props, children: renderedChildren, key });\n }\n return renderedChildren;\n }\n\n if (\n typeof override === 'object' &&\n override !== null &&\n 'tag' in override\n ) {\n const { tag: targetTag, props: extraProps } = override as ComponentObject;\n const component = values[targetTag];\n\n if (typeof component === 'function') {\n return component({\n ...props,\n ...extraProps,\n children: renderedChildren,\n key,\n });\n }\n return renderedChildren;\n }\n\n // Default: Skip tag, render children\n return renderedChildren;\n };\n\n const result = ast.flatMap(renderASTNode);\n return result.length === 1 ? result[0] : result;\n};\n"],"mappings":"AA2BA,MAAM,EAAmB,GAA+C,CACtE,IAAM,EAAgC,EAAE,CAClC,EAAY,6BAEd,EAAQ,EAAU,KAAK,EAAW,CACtC,KAAO,IAAU,MACf,EAAM,EAAM,IAAM,EAAM,GACxB,EAAQ,EAAU,KAAK,EAAW,CAEpC,OAAO,GAWH,EAAW,IAAI,IAEf,EAAa,GAA+B,CAChD,GAAI,EAAS,IAAI,EAAQ,CACvB,OAAO,EAAS,IAAI,EAAQ,CAG9B,GAAI,OAAO,GAAY,SACrB,MAAO,EAAE,CAGX,IAAM,EAAW,0CACX,EAAsB,EAAE,CACxB,EAIA,EAAE,CAEJ,EAAY,EACZ,EAAQ,EAAS,KAAK,EAAQ,CAE5B,EAAe,GAAmB,EAEpC,EAAM,OAAS,EAAI,EAAM,EAAM,OAAS,GAAG,SAAW,GACjD,KAAK,EAAM,EAGpB,KAAO,IAAU,MAAM,CACrB,GAAM,CAAC,EAAW,EAAc,EAAS,EAAe,GACtD,EACI,EAAa,EAAM,MAErB,EAAa,GACf,EAAY,EAAQ,MAAM,EAAW,EAAW,CAAC,CAGnD,IAAM,EAAY,IAAiB,IAC7B,EACJ,IAAqB,KACrB,EAAc,MAAM,CAAC,SAAS,IAAI,EAClC,EAAU,SAAS,KAAK,CAEpB,EAAoB,EAAc,MAAM,CAAC,QAAQ,MAAO,GAAG,CAAC,MAAM,CAExE,GAAI,EAAW,CACb,IAAM,EAAO,EAAM,KAAK,CAEpB,GACF,EAAY,CACV,QAAS,EAAK,QACd,MAAO,EAAK,MACZ,SAAU,EAAK,SAChB,CAAC,SAEK,EAET,EAAY,CACV,UACA,MAHe,EAAgB,EAAkB,CAIjD,SAAU,EAAE,CACb,CAAC,KACG,CACL,IAAM,EAAW,EAAgB,EAAkB,CACnD,EAAM,KAAK,CAAE,UAAS,SAAU,EAAE,CAAE,MAAO,EAAU,CAAC,CAGxD,EAAY,EAAa,EAAU,OACnC,EAAQ,EAAS,KAAK,EAAQ,CAQhC,IALI,EAAY,EAAQ,QACtB,EAAY,EAAQ,MAAM,EAAU,CAAC,CAIhC,EAAM,OAAS,GAAG,CACvB,IAAM,EAAO,EAAM,KAAK,CACpB,GACF,EAAY,CACV,QAAS,EAAK,QACd,MAAO,EAAK,MACZ,SAAU,EAAK,SAChB,CAAC,CAKN,OADA,EAAS,IAAI,EAAS,EAAS,CACxB,GAMI,GAAW,EAAiB,IAA4B,CAEnE,IAAM,EAAM,EAAU,EAAQ,CAG1B,EAAa,EAEX,EAAiB,GAAuB,CAC5C,GAAI,OAAO,GAAS,SAClB,OAAO,EAGT,GAAM,CAAE,UAAS,QAAO,YAAa,EAC/B,EAAmB,EAAS,QAAQ,EAAc,CAClD,EAAQ,IAEV,EAAW,EAAO,GAEtB,GAAI,CAAC,EAAU,CACb,IAAM,EAAe,EAAQ,aAAa,CACpC,EAAW,OAAO,KAAK,EAAO,CAAC,KAClC,GAAQ,EAAI,aAAa,GAAK,EAChC,CAEG,IAAU,EAAW,EAAO,IAGlC,IAAM,EAAM,YAAY,EAAQ,GAAG,IAEnC,GAAI,OAAO,GAAa,WACtB,OAAO,EAAS,CAAE,GAAG,EAAO,SAAU,EAAkB,MAAK,CAAC,CAGhE,GAAI,OAAO,GAAa,SAAU,CAChC,IAAM,EAAY,EAAO,GAKzB,OAHI,OAAO,GAAc,WAChB,EAAU,CAAE,GAAG,EAAO,SAAU,EAAkB,MAAK,CAAC,CAE1D,EAGT,GACE,OAAO,GAAa,UACpB,GACA,QAAS,EACT,CACA,GAAM,CAAE,IAAK,EAAW,MAAO,GAAe,EACxC,EAAY,EAAO,GAUzB,OARI,OAAO,GAAc,WAChB,EAAU,CACf,GAAG,EACH,GAAG,EACH,SAAU,EACV,MACD,CAAC,CAEG,EAIT,OAAO,GAGH,EAAS,EAAI,QAAQ,EAAc,CACzC,OAAO,EAAO,SAAW,EAAI,EAAO,GAAK"}
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Allow to insert values in a string.
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* const content = getInsertion('Hello {{name}}!', {
|
|
9
|
-
* name: 'John',
|
|
10
|
-
* });
|
|
11
|
-
* // 'Hello John!'
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
const getInsertion = (content, values) => content.replace(/\{\{\s*(.*?)\s*\}\}/g, (_, key) => {
|
|
16
|
-
return (values[key.trim()] ?? "").toString();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { getInsertion };
|
|
1
|
+
const e=(e,t)=>e.replace(/\{\{\s*(.*?)\s*\}\}/g,(e,n)=>(t[n.trim()]??``).toString());export{e as getInsertion};
|
|
21
2
|
//# sourceMappingURL=getInsertion.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInsertion.mjs","names":[],"sources":["../../../src/interpreter/getInsertion.ts"],"sourcesContent":["import type { InsertionContent } from '../transpiler';\n\n/**\n * Allow to insert values in a string.\n *\n * Usage:\n *\n * ```ts\n * const content = getInsertion('Hello {{name}}!', {\n * name: 'John',\n * });\n * // 'Hello John!'\n * ```\n *\n */\nexport const getInsertion = (\n content: string,\n values: { [K in InsertionContent['fields'][number]]: string | number }\n) =>\n content.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n });\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getInsertion.mjs","names":[],"sources":["../../../src/interpreter/getInsertion.ts"],"sourcesContent":["import type { InsertionContent } from '../transpiler';\n\n/**\n * Allow to insert values in a string.\n *\n * Usage:\n *\n * ```ts\n * const content = getInsertion('Hello {{name}}!', {\n * name: 'John',\n * });\n * // 'Hello John!'\n * ```\n *\n */\nexport const getInsertion = (\n content: string,\n values: { [K in InsertionContent['fields'][number]]: string | number }\n) =>\n content.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n });\n"],"mappings":"AAeA,MAAa,GACX,EACA,IAEA,EAAQ,QAAQ,wBAAyB,EAAG,KAElC,EADW,EAAI,MAAM,GACC,IAAI,UAAU,CAC5C"}
|
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { colorizeKey, getAppLogger } from "@intlayer/config/client";
|
|
3
|
-
import configuration from "@intlayer/config/built";
|
|
4
|
-
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
5
|
-
|
|
6
|
-
//#region src/interpreter/getIntlayer.ts
|
|
7
|
-
/**
|
|
8
|
-
* Creates a Recursive Proxy that returns the path of the accessed key
|
|
9
|
-
* stringified. This prevents the app from crashing on undefined access.
|
|
10
|
-
*/
|
|
11
|
-
const createSafeFallback = (path = "") => {
|
|
12
|
-
return new Proxy(() => path, {
|
|
13
|
-
get: (_target, prop) => {
|
|
14
|
-
if (prop === "toJSON" || prop === Symbol.toPrimitive || prop === "toString") return () => path;
|
|
15
|
-
if (prop === "then") return;
|
|
16
|
-
return createSafeFallback(path ? `${path}.${String(prop)}` : String(prop));
|
|
17
|
-
},
|
|
18
|
-
apply: () => {
|
|
19
|
-
return path;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
const getIntlayer = (key, locale, plugins) => {
|
|
24
|
-
const dictionary = getDictionaries()[key];
|
|
25
|
-
if (!dictionary) {
|
|
26
|
-
getAppLogger(configuration)(`Dictionary ${colorizeKey(key)} was not found. Using fallback proxy.`, {
|
|
27
|
-
level: "warn",
|
|
28
|
-
isVerbose: true
|
|
29
|
-
});
|
|
30
|
-
return createSafeFallback(key);
|
|
31
|
-
}
|
|
32
|
-
return getDictionary(dictionary, locale, plugins);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { getIntlayer };
|
|
1
|
+
import{getDictionary as e}from"./getDictionary.mjs";import{colorizeKey as t,getAppLogger as n}from"@intlayer/config/client";import r from"@intlayer/config/built";import{getDictionaries as i}from"@intlayer/dictionaries-entry";const a=(e=``)=>new Proxy(()=>e,{get:(t,n)=>{if(n===`toJSON`||n===Symbol.toPrimitive||n===`toString`)return()=>e;if(n!==`then`)return a(e?`${e}.${String(n)}`:String(n))},apply:()=>e}),o=(o,s,c)=>{let l=i()[o];return l?e(l,s,c):(n(r)(`Dictionary ${t(o)} was not found. Using fallback proxy.`,{level:`warn`,isVerbose:!0}),a(o))};export{o as getIntlayer};
|
|
37
2
|
//# sourceMappingURL=getIntlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.mjs","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["// packages/@intlayer/core/src/interpreter/getIntlayer.ts\n\nimport configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy(\n // Target is a function so it can be called if the dictionary expects a function\n () => path,\n {\n get: (_target, prop) => {\n // Handle common object methods to prevent infinite recursion or weird behavior\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n // If the code tries to execute the missing key as a function: t.title()\n apply: () => {\n return path;\n },\n }\n );\n};\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger(configuration);\n logger(\n `Dictionary ${colorizeKey(key as string)} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n\n if (process.env.NODE_ENV === 'development') {\n // Return the Safe Proxy\n // We initialize it with the dictionary key name so the UI shows \"my-dictionary.someKey\"\n return createSafeFallback(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getIntlayer.mjs","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["// packages/@intlayer/core/src/interpreter/getIntlayer.ts\n\nimport configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy(\n // Target is a function so it can be called if the dictionary expects a function\n () => path,\n {\n get: (_target, prop) => {\n // Handle common object methods to prevent infinite recursion or weird behavior\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n // If the code tries to execute the missing key as a function: t.title()\n apply: () => {\n return path;\n },\n }\n );\n};\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger(configuration);\n logger(\n `Dictionary ${colorizeKey(key as string)} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n\n if (process.env.NODE_ENV === 'development') {\n // Return the Safe Proxy\n // We initialize it with the dictionary key name so the UI shows \"my-dictionary.someKey\"\n return createSafeFallback(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":"iOAuBA,MAAM,GAAsB,EAAO,KAC1B,IAAI,UAEH,EACN,CACE,KAAM,EAAS,IAAS,CAEtB,GACE,IAAS,UACT,IAAS,OAAO,aAChB,IAAS,WAET,UAAa,EAEX,OAAS,OAMb,OAAO,EADU,EAAO,GAAG,EAAK,GAAG,OAAO,EAAK,GAAK,OAAO,EAAK,CAC7B,EAGrC,UACS,EAEV,CACF,CAGU,GAIX,EACA,EACA,IAKG,CAEH,IAAM,EADe,GAAiB,CACN,GAsBhC,OApBK,EAoBE,EACL,EACA,EACA,EACD,EAtBgB,EAAa,EAAc,CAExC,cAAc,EAAY,EAAc,CAAC,uCACzC,CACE,MAAO,OACP,UAAW,GACZ,CACF,CAQM,EAAmB,EAAc"}
|
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/interpreter/getNesting.ts
|
|
4
|
-
/**
|
|
5
|
-
* Extracts content from another dictionary by its key and an optional path.
|
|
6
|
-
*
|
|
7
|
-
* This allows for reusing content across different dictionaries.
|
|
8
|
-
*
|
|
9
|
-
* @param dictionaryKey - The key of the dictionary to nest.
|
|
10
|
-
* @param path - Optional dot-separated path to a specific field within the nested dictionary.
|
|
11
|
-
* @param props - Optional properties like locale and plugins.
|
|
12
|
-
* @returns The nested content.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* const content = getNesting("common", "buttons.save");
|
|
17
|
-
* // 'Save'
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
const getNesting = (dictionaryKey, path, props) => {
|
|
21
|
-
const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);
|
|
22
|
-
if (typeof path === "string") {
|
|
23
|
-
const pathArray = path.split(".");
|
|
24
|
-
let current = dictionary;
|
|
25
|
-
for (const key of pathArray) {
|
|
26
|
-
current = current?.[key];
|
|
27
|
-
if (current === void 0) return dictionary;
|
|
28
|
-
}
|
|
29
|
-
return current;
|
|
30
|
-
}
|
|
31
|
-
return dictionary;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { getNesting };
|
|
1
|
+
import{getIntlayer as e}from"./getIntlayer.mjs";const t=(t,n,r)=>{let i=e(t,r?.locale,r?.plugins);if(typeof n==`string`){let e=n.split(`.`),t=i;for(let n of e)if(t=t?.[n],t===void 0)return i;return t}return i};export{t as getNesting};
|
|
36
2
|
//# sourceMappingURL=getNesting.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNesting.mjs","names":[],"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n} from '@intlayer/types';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<DeepTransformContent<DictionaryRegistryContent<K>, S>, P>;\n\n/**\n * Extracts content from another dictionary by its key and an optional path.\n *\n * This allows for reusing content across different dictionaries.\n *\n * @param dictionaryKey - The key of the dictionary to nest.\n * @param path - Optional dot-separated path to a specific field within the nested dictionary.\n * @param props - Optional properties like locale and plugins.\n * @returns The nested content.\n *\n * @example\n * ```ts\n * const content = getNesting(\"common\", \"buttons.save\");\n * // 'Save'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getNesting.mjs","names":[],"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n} from '@intlayer/types';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<DeepTransformContent<DictionaryRegistryContent<K>, S>, P>;\n\n/**\n * Extracts content from another dictionary by its key and an optional path.\n *\n * This allows for reusing content across different dictionaries.\n *\n * @param dictionaryKey - The key of the dictionary to nest.\n * @param path - Optional dot-separated path to a specific field within the nested dictionary.\n * @param props - Optional properties like locale and plugins.\n * @returns The nested content.\n *\n * @example\n * ```ts\n * const content = getNesting(\"common\", \"buttons.save\");\n * // 'Save'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":"gDAmCA,MAAa,GACX,EACA,EACA,IAC2B,CAC3B,IAAM,EAAa,EAAY,EAAe,GAAO,OAAQ,GAAO,QAAQ,CAE5E,GAAI,OAAO,GAAS,SAAU,CAC5B,IAAM,EAAa,EAAgB,MAAM,IAAI,CACzC,EAAe,EAEnB,IAAK,IAAM,KAAO,EAIhB,GAFA,EAAU,IAAU,GAEhB,IAAY,IAAA,GACd,OAAO,EAIX,OAAO,EAIT,OAAO"}
|
|
@@ -1,111 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Check if a value is a plain object that can be safely processed.
|
|
4
|
-
* Returns false for Promises, React elements, class instances, etc.
|
|
5
|
-
*/
|
|
6
|
-
const isPlainObject = (value) => {
|
|
7
|
-
if (value === null || typeof value !== "object") return false;
|
|
8
|
-
if (value instanceof Promise || typeof value.then === "function") return false;
|
|
9
|
-
if (value.$$typeof !== void 0 || value.__v_isVNode !== void 0 || value._isVNode !== void 0 || value.isJSX !== void 0) return false;
|
|
10
|
-
const proto = Object.getPrototypeOf(value);
|
|
11
|
-
return proto === Object.prototype || proto === null || Array.isArray(value);
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Recursively merges two objects.
|
|
15
|
-
* Resembles the behavior of `defu` but respects `isPlainObject` to avoid merging React elements.
|
|
16
|
-
* Arrays are replaced, not merged.
|
|
17
|
-
*/
|
|
18
|
-
const deepMergeObjects = (target, source) => {
|
|
19
|
-
if (target === void 0) return source;
|
|
20
|
-
if (source === void 0) return target;
|
|
21
|
-
if (Array.isArray(target)) return target;
|
|
22
|
-
if (isPlainObject(target) && isPlainObject(source)) {
|
|
23
|
-
const result = { ...target };
|
|
24
|
-
for (const key of Object.keys(source)) {
|
|
25
|
-
if (key === "__proto__" || key === "constructor") continue;
|
|
26
|
-
if (Object.hasOwn(target, key)) result[key] = deepMergeObjects(target[key], source[key]);
|
|
27
|
-
else result[key] = source[key];
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
return target;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Recursively removes undefined values from an object.
|
|
35
|
-
* Handles circular references by tracking visited objects.
|
|
36
|
-
*/
|
|
37
|
-
const removeUndefinedValues = (object, visited = /* @__PURE__ */ new WeakSet()) => {
|
|
38
|
-
if (typeof object !== "object" || object === null) return object;
|
|
39
|
-
if (visited.has(object)) return object;
|
|
40
|
-
visited.add(object);
|
|
41
|
-
if (!isPlainObject(object)) return object;
|
|
42
|
-
if (Array.isArray(object)) return object.map((item) => removeUndefinedValues(item, visited));
|
|
43
|
-
const result = {};
|
|
44
|
-
for (const [key, value] of Object.entries(object)) if (value !== void 0) result[key] = removeUndefinedValues(value, visited);
|
|
45
|
-
return result;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Picks the appropriate content from a locale map based on the provided locale.
|
|
49
|
-
*
|
|
50
|
-
* It handles:
|
|
51
|
-
* 1. Exact locale match (e.g., 'en-US').
|
|
52
|
-
* 2. Generic locale fallback (e.g., 'en' if 'en-US' is not found).
|
|
53
|
-
* 3. Explicit fallback locale.
|
|
54
|
-
* 4. Deep merging of objects to ensure partial translations are complemented by fallbacks.
|
|
55
|
-
*
|
|
56
|
-
* @param languageContent - A map of locales to content.
|
|
57
|
-
* @param locale - The target locale to retrieve.
|
|
58
|
-
* @param fallback - Optional fallback locale if the target is not found.
|
|
59
|
-
* @returns The translated content.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```ts
|
|
63
|
-
* const content = getTranslation({
|
|
64
|
-
* en: 'Hello',
|
|
65
|
-
* fr: 'Bonjour',
|
|
66
|
-
* }, 'fr');
|
|
67
|
-
* // 'Bonjour'
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
const getTranslation = (languageContent, locale, fallback) => {
|
|
71
|
-
const results = [];
|
|
72
|
-
const getContent = (loc) => languageContent[loc];
|
|
73
|
-
const content = getContent(locale);
|
|
74
|
-
if (typeof content === "string") return content;
|
|
75
|
-
else if (content !== void 0) results.push(content);
|
|
76
|
-
if (locale.includes("-")) {
|
|
77
|
-
const genericLocale = locale.split("-")[0];
|
|
78
|
-
if (genericLocale in languageContent) {
|
|
79
|
-
const genericContent = getContent(genericLocale);
|
|
80
|
-
if (typeof genericContent === "string") {
|
|
81
|
-
if (results.length === 0) return genericContent;
|
|
82
|
-
} else if (genericContent !== void 0) results.push(genericContent);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (fallback !== void 0 && fallback !== locale) {
|
|
86
|
-
if (fallback in languageContent) {
|
|
87
|
-
const fallbackContent = getContent(fallback);
|
|
88
|
-
if (typeof fallbackContent === "string") {
|
|
89
|
-
if (results.length === 0) return fallbackContent;
|
|
90
|
-
} else if (fallbackContent !== void 0) results.push(fallbackContent);
|
|
91
|
-
}
|
|
92
|
-
if (fallback.includes("-")) {
|
|
93
|
-
const genericFallback = fallback.split("-")[0];
|
|
94
|
-
if (genericFallback !== locale.split("-")[0] && genericFallback in languageContent) {
|
|
95
|
-
const genericFallbackContent = getContent(genericFallback);
|
|
96
|
-
if (typeof genericFallbackContent === "string") {
|
|
97
|
-
if (results.length === 0) return genericFallbackContent;
|
|
98
|
-
} else if (genericFallbackContent !== void 0) results.push(genericFallbackContent);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (results.length === 0) return;
|
|
103
|
-
const cleanResults = results.filter((item) => typeof item !== "undefined").map((item) => removeUndefinedValues(item));
|
|
104
|
-
if (cleanResults.length === 1) return cleanResults[0];
|
|
105
|
-
if (Array.isArray(cleanResults[0])) return cleanResults[0];
|
|
106
|
-
return cleanResults.reduce((acc, curr) => deepMergeObjects(acc, curr));
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
//#endregion
|
|
110
|
-
export { getTranslation };
|
|
1
|
+
const e=e=>{if(typeof e!=`object`||!e||e instanceof Promise||typeof e.then==`function`||e.$$typeof!==void 0||e.__v_isVNode!==void 0||e._isVNode!==void 0||e.isJSX!==void 0)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Array.isArray(e)},t=(n,r)=>{if(n===void 0)return r;if(r===void 0||Array.isArray(n))return n;if(e(n)&&e(r)){let e={...n};for(let i of Object.keys(r))i===`__proto__`||i===`constructor`||(Object.hasOwn(n,i)?e[i]=t(n[i],r[i]):e[i]=r[i]);return e}return n},n=(t,r=new WeakSet)=>{if(typeof t!=`object`||!t||r.has(t)||(r.add(t),!e(t)))return t;if(Array.isArray(t))return t.map(e=>n(e,r));let i={};for(let[e,a]of Object.entries(t))a!==void 0&&(i[e]=n(a,r));return i},r=(e,r,i)=>{let a=[],o=t=>e[t],s=o(r);if(typeof s==`string`)return s;if(s!==void 0&&a.push(s),r.includes(`-`)){let t=r.split(`-`)[0];if(t in e){let e=o(t);if(typeof e==`string`){if(a.length===0)return e}else e!==void 0&&a.push(e)}}if(i!==void 0&&i!==r){if(i in e){let e=o(i);if(typeof e==`string`){if(a.length===0)return e}else e!==void 0&&a.push(e)}if(i.includes(`-`)){let t=i.split(`-`)[0];if(t!==r.split(`-`)[0]&&t in e){let e=o(t);if(typeof e==`string`){if(a.length===0)return e}else e!==void 0&&a.push(e)}}}if(a.length===0)return;let c=a.filter(e=>e!==void 0).map(e=>n(e));return c.length===1||Array.isArray(c[0])?c[0]:c.reduce((e,n)=>t(e,n))};export{r as getTranslation};
|
|
111
2
|
//# sourceMappingURL=getTranslation.mjs.map
|