@intlayer/core 8.1.2 → 8.1.3-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/utils/index.d.ts +8 -0
- package/package.json +65 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMaskContent.cjs","names":["deepTransformNode"],"sources":["../../../src/deepTransformPlugins/getMaskContent.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\nimport { deepTransformNode, type Plugins } from '../interpreter';\n\nconst passTypedNodePlugin: Plugins = {\n id: 'pass-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node, props, deepTransformNode) =>\n deepTransformNode(node[node.nodeType], props),\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const buildMaskPlugin: Plugins = {\n id: 'build-mask-plugin',\n canHandle: (node) => typeof node === 'string' || typeof node === 'number',\n transform: () => true,\n};\n\nexport const getMaskContent = (source: Dictionary): any => ({\n ...source,\n content: deepTransformNode(source.content, {\n dictionaryKey: source.key,\n keyPath: [],\n plugins: [passTypedNodePlugin, buildMaskPlugin],\n }),\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getMaskContent.cjs","names":["deepTransformNode"],"sources":["../../../src/deepTransformPlugins/getMaskContent.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\nimport { deepTransformNode, type Plugins } from '../interpreter';\n\nconst passTypedNodePlugin: Plugins = {\n id: 'pass-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node, props, deepTransformNode) =>\n deepTransformNode(node[node.nodeType], props),\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const buildMaskPlugin: Plugins = {\n id: 'build-mask-plugin',\n canHandle: (node) => typeof node === 'string' || typeof node === 'number',\n transform: () => true,\n};\n\nexport const getMaskContent = (source: Dictionary): any => ({\n ...source,\n content: deepTransformNode(source.content, {\n dictionaryKey: source.key,\n keyPath: [],\n plugins: [passTypedNodePlugin, buildMaskPlugin],\n }),\n});\n"],"mappings":"kIAGM,EAA+B,CACnC,GAAI,yBACJ,UAAY,GACV,OAAO,GAAS,UAAY,OAAO,GAAM,UAAa,SACxD,WAAY,EAAM,EAAO,IACvB,EAAkB,EAAK,EAAK,UAAW,EAAM,CAChD,CAGY,EAA2B,CACtC,GAAI,oBACJ,UAAY,GAAS,OAAO,GAAS,UAAY,OAAO,GAAS,SACjE,cAAiB,GAClB,CAEY,EAAkB,IAA6B,CAC1D,GAAG,EACH,QAASA,EAAAA,kBAAkB,EAAO,QAAS,CACzC,cAAe,EAAO,IACtB,QAAS,EAAE,CACX,QAAS,CAAC,EAAqB,EAAgB,CAChD,CAAC,CACH"}
|
|
@@ -1,83 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_interpreter_getContent_deepTransform = require('../interpreter/getContent/deepTransform.cjs');
|
|
4
|
-
let _intlayer_types = require("@intlayer/types");
|
|
5
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
6
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
7
|
-
|
|
8
|
-
//#region src/deepTransformPlugins/getMissingLocalesContent.ts
|
|
9
|
-
const getDeepKeyPaths = (obj, prefix = []) => {
|
|
10
|
-
if (typeof obj !== "object" || obj === null) return [];
|
|
11
|
-
if (Array.isArray(obj)) return [];
|
|
12
|
-
return Object.keys(obj).flatMap((key) => {
|
|
13
|
-
const newPath = [...prefix, key];
|
|
14
|
-
return [newPath, ...getDeepKeyPaths(obj[key], newPath)];
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
const hasDeepKeyPath = (obj, keyPath) => {
|
|
18
|
-
let current = obj;
|
|
19
|
-
for (const key of keyPath) {
|
|
20
|
-
if (current === void 0 || current === null || typeof current !== "object") return false;
|
|
21
|
-
if (!(key in current)) return false;
|
|
22
|
-
current = current[key];
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
};
|
|
26
|
-
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
27
|
-
const checkMissingLocalesPlugin = (locales, onMissingLocale) => ({
|
|
28
|
-
id: "check-missing-locales-plugin",
|
|
29
|
-
canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types.NodeType.Translation,
|
|
30
|
-
transform: (node, props, deepTransformNode) => {
|
|
31
|
-
const translations = node[_intlayer_types.NodeType.Translation];
|
|
32
|
-
const allKeys = /* @__PURE__ */ new Set();
|
|
33
|
-
for (const locale of locales) if (translations[locale]) getDeepKeyPaths(translations[locale]).forEach((path) => {
|
|
34
|
-
allKeys.add(JSON.stringify(path));
|
|
35
|
-
});
|
|
36
|
-
for (const locale of locales) {
|
|
37
|
-
if (!translations[locale]) {
|
|
38
|
-
onMissingLocale(locale);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
for (const pathStr of allKeys) {
|
|
42
|
-
const path = JSON.parse(pathStr);
|
|
43
|
-
if (!hasDeepKeyPath(translations[locale], path)) {
|
|
44
|
-
onMissingLocale(locale);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
for (const key in translations) {
|
|
50
|
-
const child = translations[key];
|
|
51
|
-
deepTransformNode(child, {
|
|
52
|
-
...props,
|
|
53
|
-
children: child
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return node;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
/**
|
|
60
|
-
* Return the content of a node with only the translation plugin.
|
|
61
|
-
*
|
|
62
|
-
* @param node The node to transform.
|
|
63
|
-
* @param locales The locales to check for missing translations.
|
|
64
|
-
*/
|
|
65
|
-
const getMissingLocalesContent = (node, locales = _intlayer_config_built.default?.internationalization?.locales, nodeProps) => {
|
|
66
|
-
const missingLocales = /* @__PURE__ */ new Set();
|
|
67
|
-
const plugins = [checkMissingLocalesPlugin(locales, (locale) => missingLocales.add(locale)), ...nodeProps.plugins ?? []];
|
|
68
|
-
require_interpreter_getContent_deepTransform.deepTransformNode(node, {
|
|
69
|
-
...nodeProps,
|
|
70
|
-
plugins
|
|
71
|
-
});
|
|
72
|
-
return Array.from(missingLocales);
|
|
73
|
-
};
|
|
74
|
-
const getMissingLocalesContentFromDictionary = (dictionary, locales = _intlayer_config_built.default?.internationalization?.locales) => getMissingLocalesContent(dictionary.content, locales, {
|
|
75
|
-
dictionaryKey: dictionary.key,
|
|
76
|
-
keyPath: []
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
//#endregion
|
|
80
|
-
exports.checkMissingLocalesPlugin = checkMissingLocalesPlugin;
|
|
81
|
-
exports.getMissingLocalesContent = getMissingLocalesContent;
|
|
82
|
-
exports.getMissingLocalesContentFromDictionary = getMissingLocalesContentFromDictionary;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../interpreter/getContent/deepTransform.cjs`);let n=require(`@intlayer/types`),r=require(`@intlayer/config/built`);r=e.__toESM(r);const i=(e,t=[])=>typeof e!=`object`||!e||Array.isArray(e)?[]:Object.keys(e).flatMap(n=>{let r=[...t,n];return[r,...i(e[n],r)]}),a=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n||!(e in n))return!1;n=n[e]}return!0},o=(e,t)=>({id:`check-missing-locales-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===n.NodeType.Translation,transform:(r,o,s)=>{let c=r[n.NodeType.Translation],l=new Set;for(let t of e)c[t]&&i(c[t]).forEach(e=>{l.add(JSON.stringify(e))});for(let n of e){if(!c[n]){t(n);continue}for(let e of l){let r=JSON.parse(e);if(!a(c[n],r)){t(n);break}}}for(let e in c){let t=c[e];s(t,{...o,children:t})}return r}}),s=(e,n=r.default?.internationalization?.locales,i)=>{let a=new Set,s=[o(n,e=>a.add(e)),...i.plugins??[]];return t.deepTransformNode(e,{...i,plugins:s}),Array.from(a)},c=(e,t=r.default?.internationalization?.locales)=>s(e.content,t,{dictionaryKey:e.key,keyPath:[]});exports.checkMissingLocalesPlugin=o,exports.getMissingLocalesContent=s,exports.getMissingLocalesContentFromDictionary=c;
|
|
83
2
|
//# sourceMappingURL=getMissingLocalesContent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMissingLocalesContent.cjs","names":["NodeType","configuration"],"sources":["../../../src/deepTransformPlugins/getMissingLocalesContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types';\nimport {\n type ContentNode,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport type { DeepTransformContent, NodeProps, Plugins } from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport type { TranslationContent } from '../transpiler';\n\nconst getDeepKeyPaths = (obj: any, prefix: string[] = []): string[][] => {\n if (typeof obj !== 'object' || obj === null) {\n return [];\n }\n\n // Skip array indices - arrays of different lengths shouldn't trigger missing translations\n // Each locale can have arrays with different numbers of elements (e.g., keywords)\n if (Array.isArray(obj)) {\n return [];\n }\n\n return Object.keys(obj).flatMap((key) => {\n const newPath = [...prefix, key];\n return [newPath, ...getDeepKeyPaths(obj[key], newPath)];\n });\n};\n\nconst hasDeepKeyPath = (obj: any, keyPath: string[]): boolean => {\n let current = obj;\n for (const key of keyPath) {\n if (\n current === undefined ||\n current === null ||\n typeof current !== 'object'\n ) {\n return false;\n }\n if (!(key in current)) {\n return false;\n }\n current = current[key];\n }\n\n return true;\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const checkMissingLocalesPlugin = (\n locales: Locale[],\n onMissingLocale: (locale: Locale) => void\n): Plugins => ({\n id: 'check-missing-locales-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const translations = node[NodeType.Translation] as Record<string, any>;\n const allKeys = new Set<string>();\n\n for (const locale of locales) {\n if (translations[locale]) {\n getDeepKeyPaths(translations[locale]).forEach((path) => {\n allKeys.add(JSON.stringify(path));\n });\n }\n }\n\n for (const locale of locales) {\n if (!translations[locale]) {\n onMissingLocale(locale);\n continue;\n }\n\n for (const pathStr of allKeys) {\n const path = JSON.parse(pathStr);\n if (!hasDeepKeyPath(translations[locale], path)) {\n onMissingLocale(locale);\n break;\n }\n }\n }\n\n // Continue traversal inside the translation values, but avoid re-applying this plugin on the same node\n for (const key in translations) {\n const child = translations[key];\n deepTransformNode(child, {\n ...props,\n children: child,\n });\n }\n\n // Return the original node; the return value is ignored by the caller\n return node;\n },\n});\n\n/**\n * Return the content of a node with only the translation plugin.\n *\n * @param node The node to transform.\n * @param locales The locales to check for missing translations.\n */\nexport const getMissingLocalesContent = <T extends ContentNode>(\n node: T,\n locales: LocalesValues[] = configuration?.internationalization?.locales,\n nodeProps: NodeProps\n): Locale[] => {\n const missingLocales = new Set<Locale>();\n\n const plugins: Plugins[] = [\n checkMissingLocalesPlugin(locales as Locale[], (locale) =>\n missingLocales.add(locale)\n ),\n ...(nodeProps.plugins ?? []),\n ];\n\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n\n return Array.from(missingLocales);\n};\n\nexport const getMissingLocalesContentFromDictionary = (\n dictionary: Dictionary,\n locales: LocalesValues[] = configuration?.internationalization?.locales\n) =>\n getMissingLocalesContent(dictionary.content, locales, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n });\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getMissingLocalesContent.cjs","names":["NodeType","configuration"],"sources":["../../../src/deepTransformPlugins/getMissingLocalesContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types';\nimport {\n type ContentNode,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport type { DeepTransformContent, NodeProps, Plugins } from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport type { TranslationContent } from '../transpiler';\n\nconst getDeepKeyPaths = (obj: any, prefix: string[] = []): string[][] => {\n if (typeof obj !== 'object' || obj === null) {\n return [];\n }\n\n // Skip array indices - arrays of different lengths shouldn't trigger missing translations\n // Each locale can have arrays with different numbers of elements (e.g., keywords)\n if (Array.isArray(obj)) {\n return [];\n }\n\n return Object.keys(obj).flatMap((key) => {\n const newPath = [...prefix, key];\n return [newPath, ...getDeepKeyPaths(obj[key], newPath)];\n });\n};\n\nconst hasDeepKeyPath = (obj: any, keyPath: string[]): boolean => {\n let current = obj;\n for (const key of keyPath) {\n if (\n current === undefined ||\n current === null ||\n typeof current !== 'object'\n ) {\n return false;\n }\n if (!(key in current)) {\n return false;\n }\n current = current[key];\n }\n\n return true;\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const checkMissingLocalesPlugin = (\n locales: Locale[],\n onMissingLocale: (locale: Locale) => void\n): Plugins => ({\n id: 'check-missing-locales-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const translations = node[NodeType.Translation] as Record<string, any>;\n const allKeys = new Set<string>();\n\n for (const locale of locales) {\n if (translations[locale]) {\n getDeepKeyPaths(translations[locale]).forEach((path) => {\n allKeys.add(JSON.stringify(path));\n });\n }\n }\n\n for (const locale of locales) {\n if (!translations[locale]) {\n onMissingLocale(locale);\n continue;\n }\n\n for (const pathStr of allKeys) {\n const path = JSON.parse(pathStr);\n if (!hasDeepKeyPath(translations[locale], path)) {\n onMissingLocale(locale);\n break;\n }\n }\n }\n\n // Continue traversal inside the translation values, but avoid re-applying this plugin on the same node\n for (const key in translations) {\n const child = translations[key];\n deepTransformNode(child, {\n ...props,\n children: child,\n });\n }\n\n // Return the original node; the return value is ignored by the caller\n return node;\n },\n});\n\n/**\n * Return the content of a node with only the translation plugin.\n *\n * @param node The node to transform.\n * @param locales The locales to check for missing translations.\n */\nexport const getMissingLocalesContent = <T extends ContentNode>(\n node: T,\n locales: LocalesValues[] = configuration?.internationalization?.locales,\n nodeProps: NodeProps\n): Locale[] => {\n const missingLocales = new Set<Locale>();\n\n const plugins: Plugins[] = [\n checkMissingLocalesPlugin(locales as Locale[], (locale) =>\n missingLocales.add(locale)\n ),\n ...(nodeProps.plugins ?? []),\n ];\n\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n\n return Array.from(missingLocales);\n};\n\nexport const getMissingLocalesContentFromDictionary = (\n dictionary: Dictionary,\n locales: LocalesValues[] = configuration?.internationalization?.locales\n) =>\n getMissingLocalesContent(dictionary.content, locales, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n });\n"],"mappings":"qQAYA,MAAM,GAAmB,EAAU,EAAmB,EAAE,GAClD,OAAO,GAAQ,WAAY,GAM3B,MAAM,QAAQ,EAAI,CACb,EAAE,CAGJ,OAAO,KAAK,EAAI,CAAC,QAAS,GAAQ,CACvC,IAAM,EAAU,CAAC,GAAG,EAAQ,EAAI,CAChC,MAAO,CAAC,EAAS,GAAG,EAAgB,EAAI,GAAM,EAAQ,CAAC,EACvD,CAGE,GAAkB,EAAU,IAA+B,CAC/D,IAAI,EAAU,EACd,IAAK,IAAM,KAAO,EAAS,CAQzB,GAJE,OAAO,GAAY,WAFnB,GAME,EAAE,KAAO,GACX,MAAO,GAET,EAAU,EAAQ,GAGpB,MAAO,IAII,GACX,EACA,KACa,CACb,GAAI,+BACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAaA,EAAAA,SAAS,YAC1D,WAAY,EAA0B,EAAO,IAAsB,CACjE,IAAM,EAAe,EAAKA,EAAAA,SAAS,aAC7B,EAAU,IAAI,IAEpB,IAAK,IAAM,KAAU,EACf,EAAa,IACf,EAAgB,EAAa,GAAQ,CAAC,QAAS,GAAS,CACtD,EAAQ,IAAI,KAAK,UAAU,EAAK,CAAC,EACjC,CAIN,IAAK,IAAM,KAAU,EAAS,CAC5B,GAAI,CAAC,EAAa,GAAS,CACzB,EAAgB,EAAO,CACvB,SAGF,IAAK,IAAM,KAAW,EAAS,CAC7B,IAAM,EAAO,KAAK,MAAM,EAAQ,CAChC,GAAI,CAAC,EAAe,EAAa,GAAS,EAAK,CAAE,CAC/C,EAAgB,EAAO,CACvB,QAMN,IAAK,IAAM,KAAO,EAAc,CAC9B,IAAM,EAAQ,EAAa,GAC3B,EAAkB,EAAO,CACvB,GAAG,EACH,SAAU,EACX,CAAC,CAIJ,OAAO,GAEV,EAQY,GACX,EACA,EAA2BC,EAAAA,SAAe,sBAAsB,QAChE,IACa,CACb,IAAM,EAAiB,IAAI,IAErB,EAAqB,CACzB,EAA0B,EAAsB,GAC9C,EAAe,IAAI,EAAO,CAC3B,CACD,GAAI,EAAU,SAAW,EAAE,CAC5B,CAOD,OALA,EAAA,kBAAkB,EAAM,CACtB,GAAG,EACH,UACD,CAAC,CAEK,MAAM,KAAK,EAAe,EAGtB,GACX,EACA,EAA2BA,EAAAA,SAAe,sBAAsB,UAEhE,EAAyB,EAAW,QAAS,EAAS,CACpD,cAAe,EAAW,IAC1B,QAAS,EAAE,CACZ,CAAC"}
|
|
@@ -1,88 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_interpreter_getContent_deepTransform = require('../interpreter/getContent/deepTransform.cjs');
|
|
3
|
-
const require_transpiler_translation_translation = require('../transpiler/translation/translation.cjs');
|
|
4
|
-
|
|
5
|
-
//#region src/deepTransformPlugins/getMultilingualDictionary.ts
|
|
6
|
-
/**
|
|
7
|
-
* Transform a per-locale dictionary into a multilingual dictionary.
|
|
8
|
-
*
|
|
9
|
-
* Example:
|
|
10
|
-
* ```json
|
|
11
|
-
* {
|
|
12
|
-
* "key": "about-page",
|
|
13
|
-
* "locale": "en",
|
|
14
|
-
* "content": {
|
|
15
|
-
* "myContent": "English content"
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* ```json
|
|
21
|
-
* {
|
|
22
|
-
* "key": "about-page",
|
|
23
|
-
* "content": {
|
|
24
|
-
* "myContent": t({
|
|
25
|
-
* "en": "English content",
|
|
26
|
-
* })
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
const getMultilingualDictionary = (dictionary) => {
|
|
32
|
-
if (!dictionary.locale) return dictionary;
|
|
33
|
-
const locale = dictionary.locale;
|
|
34
|
-
const transformedContent = require_interpreter_getContent_deepTransform.deepTransformNode(JSON.parse(JSON.stringify(dictionary.content)), {
|
|
35
|
-
dictionaryKey: dictionary.key,
|
|
36
|
-
keyPath: [],
|
|
37
|
-
plugins: [{
|
|
38
|
-
id: "traverse-typed-node-plugin",
|
|
39
|
-
canHandle: (node) => typeof node === "object" && typeof node?.nodeType === "string",
|
|
40
|
-
transform: (node, props, transformFn) => {
|
|
41
|
-
const nodeType = node.nodeType;
|
|
42
|
-
const inner = structuredClone(node[nodeType]);
|
|
43
|
-
if (typeof inner !== "object" || inner === null) {
|
|
44
|
-
const transformed = transformFn(inner, {
|
|
45
|
-
...props,
|
|
46
|
-
children: inner,
|
|
47
|
-
keyPath: [...props.keyPath, {
|
|
48
|
-
type: nodeType,
|
|
49
|
-
key: nodeType
|
|
50
|
-
}]
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
...node,
|
|
54
|
-
[nodeType]: transformed
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
for (const key in inner) {
|
|
58
|
-
const childProps = {
|
|
59
|
-
...props,
|
|
60
|
-
children: inner[key],
|
|
61
|
-
keyPath: [...props.keyPath, {
|
|
62
|
-
type: nodeType,
|
|
63
|
-
key
|
|
64
|
-
}]
|
|
65
|
-
};
|
|
66
|
-
inner[key] = transformFn(inner[key], childProps);
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
...node,
|
|
70
|
-
[nodeType]: inner
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
id: "wrap-primitive-in-translation",
|
|
75
|
-
canHandle: (node) => typeof node === "string" || typeof node === "number" || typeof node === "boolean",
|
|
76
|
-
transform: (node) => require_transpiler_translation_translation.t({ [locale]: node })
|
|
77
|
-
}]
|
|
78
|
-
});
|
|
79
|
-
const { locale: _omitLocale, ...rest } = dictionary;
|
|
80
|
-
return {
|
|
81
|
-
...rest,
|
|
82
|
-
content: transformedContent
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
//#endregion
|
|
87
|
-
exports.getMultilingualDictionary = getMultilingualDictionary;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../interpreter/getContent/deepTransform.cjs`),t=require(`../transpiler/translation/translation.cjs`),n=n=>{if(!n.locale)return n;let r=n.locale,i=e.deepTransformNode(JSON.parse(JSON.stringify(n.content)),{dictionaryKey:n.key,keyPath:[],plugins:[{id:`traverse-typed-node-plugin`,canHandle:e=>typeof e==`object`&&typeof e?.nodeType==`string`,transform:(e,t,n)=>{let r=e.nodeType,i=structuredClone(e[r]);if(typeof i!=`object`||!i){let a=n(i,{...t,children:i,keyPath:[...t.keyPath,{type:r,key:r}]});return{...e,[r]:a}}for(let e in i){let a={...t,children:i[e],keyPath:[...t.keyPath,{type:r,key:e}]};i[e]=n(i[e],a)}return{...e,[r]:i}}},{id:`wrap-primitive-in-translation`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,transform:e=>t.t({[r]:e})}]}),{locale:a,...o}=n;return{...o,content:i}};exports.getMultilingualDictionary=n;
|
|
88
2
|
//# sourceMappingURL=getMultilingualDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMultilingualDictionary.cjs","names":["deepTransformNode","t"],"sources":["../../../src/deepTransformPlugins/getMultilingualDictionary.ts"],"sourcesContent":["import type { Dictionary, KeyPath, NodeType, TypedNode } from '@intlayer/types';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { t } from '../transpiler';\n\n/**\n * Transform a per-locale dictionary into a multilingual dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"myContent\": \"English content\"\n * }\n * }\n * ```\n *\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"content\": {\n * \"myContent\": t({\n * \"en\": \"English content\",\n * })\n * }\n * }\n * ```\n */\nexport const getMultilingualDictionary = (\n dictionary: Dictionary\n): Dictionary => {\n if (!dictionary.locale) {\n return dictionary;\n }\n\n const locale = dictionary.locale;\n\n const wrapPrimitiveInTranslationPlugin: Plugins = {\n id: 'wrap-primitive-in-translation',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: (node) => t({ [locale]: node } as Record<string, unknown>),\n };\n\n const traverseTypedNodePlugin: Plugins = {\n id: 'traverse-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof (node as any)?.nodeType === 'string',\n transform: (node: TypedNode, props, transformFn) => {\n const nodeType = (node as any).nodeType as NodeType;\n const inner = structuredClone(\n (node as any)[nodeType as unknown as keyof TypedNode] as any\n );\n\n if (typeof inner !== 'object' || inner === null) {\n const transformed = transformFn(inner, {\n ...props,\n children: inner,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformed,\n };\n }\n\n for (const key in inner) {\n const childProps: NodeProps = {\n ...props,\n children: inner[key as unknown as keyof typeof inner],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n inner[key as unknown as keyof typeof inner] = transformFn(\n inner[key as unknown as keyof typeof inner],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: inner };\n },\n };\n\n const transformedContent = deepTransformNode(\n JSON.parse(JSON.stringify(dictionary.content)),\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [traverseTypedNodePlugin, wrapPrimitiveInTranslationPlugin],\n }\n );\n\n const { locale: _omitLocale, ...rest } = dictionary as any;\n return {\n ...rest,\n content: transformedContent,\n } as Dictionary;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getMultilingualDictionary.cjs","names":["deepTransformNode","t"],"sources":["../../../src/deepTransformPlugins/getMultilingualDictionary.ts"],"sourcesContent":["import type { Dictionary, KeyPath, NodeType, TypedNode } from '@intlayer/types';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { t } from '../transpiler';\n\n/**\n * Transform a per-locale dictionary into a multilingual dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"myContent\": \"English content\"\n * }\n * }\n * ```\n *\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"content\": {\n * \"myContent\": t({\n * \"en\": \"English content\",\n * })\n * }\n * }\n * ```\n */\nexport const getMultilingualDictionary = (\n dictionary: Dictionary\n): Dictionary => {\n if (!dictionary.locale) {\n return dictionary;\n }\n\n const locale = dictionary.locale;\n\n const wrapPrimitiveInTranslationPlugin: Plugins = {\n id: 'wrap-primitive-in-translation',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: (node) => t({ [locale]: node } as Record<string, unknown>),\n };\n\n const traverseTypedNodePlugin: Plugins = {\n id: 'traverse-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof (node as any)?.nodeType === 'string',\n transform: (node: TypedNode, props, transformFn) => {\n const nodeType = (node as any).nodeType as NodeType;\n const inner = structuredClone(\n (node as any)[nodeType as unknown as keyof TypedNode] as any\n );\n\n if (typeof inner !== 'object' || inner === null) {\n const transformed = transformFn(inner, {\n ...props,\n children: inner,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformed,\n };\n }\n\n for (const key in inner) {\n const childProps: NodeProps = {\n ...props,\n children: inner[key as unknown as keyof typeof inner],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n inner[key as unknown as keyof typeof inner] = transformFn(\n inner[key as unknown as keyof typeof inner],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: inner };\n },\n };\n\n const transformedContent = deepTransformNode(\n JSON.parse(JSON.stringify(dictionary.content)),\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [traverseTypedNodePlugin, wrapPrimitiveInTranslationPlugin],\n }\n );\n\n const { locale: _omitLocale, ...rest } = dictionary as any;\n return {\n ...rest,\n content: transformedContent,\n } as Dictionary;\n};\n"],"mappings":"yLAiCa,EACX,GACe,CACf,GAAI,CAAC,EAAW,OACd,OAAO,EAGT,IAAM,EAAS,EAAW,OAoDpB,EAAqBA,EAAAA,kBACzB,KAAK,MAAM,KAAK,UAAU,EAAW,QAAQ,CAAC,CAC9C,CACE,cAAe,EAAW,IAC1B,QAAS,EAAE,CACX,QAAS,CA9C4B,CACvC,GAAI,6BACJ,UAAY,GACV,OAAO,GAAS,UAAY,OAAQ,GAAc,UAAa,SACjE,WAAY,EAAiB,EAAO,IAAgB,CAClD,IAAM,EAAY,EAAa,SACzB,EAAQ,gBACX,EAAa,GACf,CAED,GAAI,OAAO,GAAU,WAAY,EAAgB,CAC/C,IAAM,EAAc,EAAY,EAAO,CACrC,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAU,IAAK,EAAU,CAClC,CACF,CAAC,CACF,MAAO,CACL,GAAG,GACF,GAAyC,EAC3C,CAGH,IAAK,IAAM,KAAO,EAAO,CACvB,IAAM,EAAwB,CAC5B,GAAG,EACH,SAAU,EAAM,GAChB,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAU,MAAK,CAAY,CAChE,CACD,EAAM,GAAwC,EAC5C,EAAM,GACN,EACD,CAGH,MAAO,CAAE,GAAG,GAAO,GAAyC,EAAO,EAEtE,CAhDiD,CAChD,GAAI,gCACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,UAClB,UAAY,GAASC,EAAAA,EAAE,EAAG,GAAS,EAAM,CAA4B,CACtE,CAgDuE,CACrE,CACF,CAEK,CAAE,OAAQ,EAAa,GAAG,GAAS,EACzC,MAAO,CACL,GAAG,EACH,QAAS,EACV"}
|
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_interpreter_getContent_deepTransform = require('../interpreter/getContent/deepTransform.cjs');
|
|
3
|
-
|
|
4
|
-
//#region src/deepTransformPlugins/getReplacedValuesContent.ts
|
|
5
|
-
const replaceValuesPlugin = (value) => ({
|
|
6
|
-
id: "replace-values-plugin",
|
|
7
|
-
canHandle: (node) => typeof node === "string" || typeof node === "number" || typeof node === "boolean",
|
|
8
|
-
transform: () => value
|
|
9
|
-
});
|
|
10
|
-
const skipTypedNodePlugin = {
|
|
11
|
-
id: "skip-typed-node-plugin",
|
|
12
|
-
canHandle: (node) => typeof node === "object" && typeof node?.nodeType === "string",
|
|
13
|
-
transform: (node, props, deepTransformNode) => {
|
|
14
|
-
const nodeType = node.nodeType;
|
|
15
|
-
const result = structuredClone(node[nodeType]);
|
|
16
|
-
if (typeof result !== "object" || result === null) {
|
|
17
|
-
const transformedResult = deepTransformNode(result, {
|
|
18
|
-
...props,
|
|
19
|
-
children: result,
|
|
20
|
-
keyPath: [...props.keyPath, {
|
|
21
|
-
type: nodeType,
|
|
22
|
-
key: nodeType
|
|
23
|
-
}]
|
|
24
|
-
});
|
|
25
|
-
return {
|
|
26
|
-
...node,
|
|
27
|
-
[nodeType]: transformedResult
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
for (const key in result) {
|
|
31
|
-
const childProps = {
|
|
32
|
-
...props,
|
|
33
|
-
children: result[key],
|
|
34
|
-
keyPath: [...props.keyPath, {
|
|
35
|
-
type: nodeType,
|
|
36
|
-
key
|
|
37
|
-
}]
|
|
38
|
-
};
|
|
39
|
-
result[key] = deepTransformNode(result[key], childProps);
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
...node,
|
|
43
|
-
[nodeType]: result
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const getReplacedValuesContent = (node, value, nodeProps) => {
|
|
48
|
-
const plugins = [
|
|
49
|
-
skipTypedNodePlugin,
|
|
50
|
-
replaceValuesPlugin(value),
|
|
51
|
-
...nodeProps.plugins ?? []
|
|
52
|
-
];
|
|
53
|
-
return require_interpreter_getContent_deepTransform.deepTransformNode(JSON.parse(JSON.stringify(node)), {
|
|
54
|
-
...nodeProps,
|
|
55
|
-
plugins
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
exports.getReplacedValuesContent = getReplacedValuesContent;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../interpreter/getContent/deepTransform.cjs`),t=e=>({id:`replace-values-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,transform:()=>e}),n={id:`skip-typed-node-plugin`,canHandle:e=>typeof e==`object`&&typeof e?.nodeType==`string`,transform:(e,t,n)=>{let r=e.nodeType,i=structuredClone(e[r]);if(typeof i!=`object`||!i){let a=n(i,{...t,children:i,keyPath:[...t.keyPath,{type:r,key:r}]});return{...e,[r]:a}}for(let e in i){let a={...t,children:i[e],keyPath:[...t.keyPath,{type:r,key:e}]};i[e]=n(i[e],a)}return{...e,[r]:i}}},r=(r,i,a)=>{let o=[n,t(i),...a.plugins??[]];return e.deepTransformNode(JSON.parse(JSON.stringify(r)),{...a,plugins:o})};exports.getReplacedValuesContent=r;
|
|
61
2
|
//# sourceMappingURL=getReplacedValuesContent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getReplacedValuesContent.cjs","names":["deepTransformNode"],"sources":["../../../src/deepTransformPlugins/getReplacedValuesContent.ts"],"sourcesContent":["import type {\n ContentNode,\n KeyPath,\n NodeType,\n TypedNode,\n} from '@intlayer/types';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\n\nconst replaceValuesPlugin = (value: string | number | boolean): Plugins => ({\n id: 'replace-values-plugin',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: () => value,\n});\n\nconst skipTypedNodePlugin: Plugins = {\n id: 'skip-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node: TypedNode, props, deepTransformNode) => {\n const nodeType = node.nodeType as NodeType;\n const result = structuredClone(\n node[nodeType as unknown as keyof TypedNode] as any\n );\n\n // If the result is a primitive value (string, number, boolean),\n // we need to transform it directly instead of iterating over its properties\n if (typeof result !== 'object' || result === null) {\n const transformedResult = deepTransformNode(result, {\n ...props,\n children: result,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformedResult,\n };\n }\n\n // For objects and arrays, iterate over their properties\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: result };\n },\n};\n\nexport const getReplacedValuesContent = (\n node: ContentNode,\n value: string | number | boolean,\n nodeProps: NodeProps\n) => {\n const plugins: Plugins[] = [\n skipTypedNodePlugin,\n replaceValuesPlugin(value),\n ...(nodeProps.plugins ?? []),\n ];\n\n const JSONNode = JSON.parse(JSON.stringify(node));\n\n return deepTransformNode(JSONNode, {\n ...nodeProps,\n plugins,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getReplacedValuesContent.cjs","names":["deepTransformNode"],"sources":["../../../src/deepTransformPlugins/getReplacedValuesContent.ts"],"sourcesContent":["import type {\n ContentNode,\n KeyPath,\n NodeType,\n TypedNode,\n} from '@intlayer/types';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\n\nconst replaceValuesPlugin = (value: string | number | boolean): Plugins => ({\n id: 'replace-values-plugin',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: () => value,\n});\n\nconst skipTypedNodePlugin: Plugins = {\n id: 'skip-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node: TypedNode, props, deepTransformNode) => {\n const nodeType = node.nodeType as NodeType;\n const result = structuredClone(\n node[nodeType as unknown as keyof TypedNode] as any\n );\n\n // If the result is a primitive value (string, number, boolean),\n // we need to transform it directly instead of iterating over its properties\n if (typeof result !== 'object' || result === null) {\n const transformedResult = deepTransformNode(result, {\n ...props,\n children: result,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformedResult,\n };\n }\n\n // For objects and arrays, iterate over their properties\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: result };\n },\n};\n\nexport const getReplacedValuesContent = (\n node: ContentNode,\n value: string | number | boolean,\n nodeProps: NodeProps\n) => {\n const plugins: Plugins[] = [\n skipTypedNodePlugin,\n replaceValuesPlugin(value),\n ...(nodeProps.plugins ?? []),\n ];\n\n const JSONNode = JSON.parse(JSON.stringify(node));\n\n return deepTransformNode(JSONNode, {\n ...nodeProps,\n plugins,\n });\n};\n"],"mappings":"kIAYM,EAAuB,IAA+C,CAC1E,GAAI,wBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,UAClB,cAAiB,EAClB,EAEK,EAA+B,CACnC,GAAI,yBACJ,UAAY,GACV,OAAO,GAAS,UAAY,OAAO,GAAM,UAAa,SACxD,WAAY,EAAiB,EAAO,IAAsB,CACxD,IAAM,EAAW,EAAK,SAChB,EAAS,gBACb,EAAK,GACN,CAID,GAAI,OAAO,GAAW,WAAY,EAAiB,CACjD,IAAM,EAAoB,EAAkB,EAAQ,CAClD,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAU,IAAK,EAAU,CAClC,CACF,CAAC,CACF,MAAO,CACL,GAAG,GACF,GAAyC,EAC3C,CAIH,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAa,CACjB,GAAG,EACH,SAAU,EAAO,GACjB,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAU,MAAK,CAAY,CAChE,CACD,EAAO,GAAyC,EAC9C,EAAO,GACP,EACD,CAGH,MAAO,CAAE,GAAG,GAAO,GAAyC,EAAQ,EAEvE,CAEY,GACX,EACA,EACA,IACG,CACH,IAAM,EAAqB,CACzB,EACA,EAAoB,EAAM,CAC1B,GAAI,EAAU,SAAW,EAAE,CAC5B,CAID,OAAOA,EAAAA,kBAFU,KAAK,MAAM,KAAK,UAAU,EAAK,CAAC,CAEd,CACjC,GAAG,EACH,UACD,CAAC"}
|
|
@@ -1,123 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _intlayer_types = require("@intlayer/types");
|
|
4
|
-
|
|
5
|
-
//#region src/deepTransformPlugins/getSplittedContent.ts
|
|
6
|
-
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
-
const hasNodeType = (value) => isObject(value) && typeof value.nodeType === "string";
|
|
8
|
-
const mergeValues = (a, b) => {
|
|
9
|
-
if (a === void 0) return b;
|
|
10
|
-
if (b === void 0) return a;
|
|
11
|
-
if (Array.isArray(a) && Array.isArray(b)) return [...a, ...b];
|
|
12
|
-
if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {
|
|
13
|
-
const result = { ...a };
|
|
14
|
-
for (const key of Object.keys(b)) result[key] = mergeValues(result[key], b[key]);
|
|
15
|
-
return result;
|
|
16
|
-
}
|
|
17
|
-
return b;
|
|
18
|
-
};
|
|
19
|
-
const mergeSplitResults = (base, addition) => {
|
|
20
|
-
const result = { ...base };
|
|
21
|
-
result.common = mergeValues(base.common, addition.common);
|
|
22
|
-
const localeKeys = new Set([...Object.keys(base).filter((k) => k !== "common"), ...Object.keys(addition).filter((k) => k !== "common")]);
|
|
23
|
-
for (const key of localeKeys) result[key] = mergeValues(base[key], addition[key]);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
const splitNode = (node) => {
|
|
27
|
-
if (isObject(node) && node?.nodeType === _intlayer_types.NodeType.Translation) {
|
|
28
|
-
const translations = node[_intlayer_types.NodeType.Translation];
|
|
29
|
-
const result = {};
|
|
30
|
-
for (const locale of Object.keys(translations)) {
|
|
31
|
-
const child = translations[locale];
|
|
32
|
-
const childSplit = splitNode(child);
|
|
33
|
-
const mergedForLocale = mergeValues(childSplit.common, void 0);
|
|
34
|
-
let recomposed;
|
|
35
|
-
for (const key of Object.keys(childSplit)) {
|
|
36
|
-
if (key === "common") continue;
|
|
37
|
-
recomposed = mergeValues(recomposed, childSplit[key]);
|
|
38
|
-
}
|
|
39
|
-
const finalLocaleNode = mergeValues(mergedForLocale, recomposed);
|
|
40
|
-
if (finalLocaleNode !== void 0) result[locale] = finalLocaleNode;
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
if (Array.isArray(node)) {
|
|
45
|
-
const commonArray = [];
|
|
46
|
-
const perLocaleArrays = {};
|
|
47
|
-
node.forEach((child) => {
|
|
48
|
-
const childSplit = splitNode(child);
|
|
49
|
-
if (childSplit.common !== void 0) commonArray.push(childSplit.common);
|
|
50
|
-
for (const key of Object.keys(childSplit)) {
|
|
51
|
-
if (key === "common") continue;
|
|
52
|
-
if (!perLocaleArrays[key]) perLocaleArrays[key] = [];
|
|
53
|
-
const value = childSplit[key];
|
|
54
|
-
if (value !== void 0) perLocaleArrays[key].push(value);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
const result = {};
|
|
58
|
-
if (commonArray.length > 0) result.common = commonArray;
|
|
59
|
-
for (const key of Object.keys(perLocaleArrays)) result[key] = perLocaleArrays[key];
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
if (isObject(node) && !hasNodeType(node)) {
|
|
63
|
-
let accumulated = {};
|
|
64
|
-
for (const key of Object.keys(node)) {
|
|
65
|
-
const childSplit = splitNode(node[key]);
|
|
66
|
-
if (childSplit.common !== void 0) accumulated = mergeSplitResults(accumulated, { common: { [key]: childSplit.common } });
|
|
67
|
-
for (const locale of Object.keys(childSplit)) {
|
|
68
|
-
if (locale === "common") continue;
|
|
69
|
-
accumulated = mergeSplitResults(accumulated, { [locale]: { [key]: childSplit[locale] } });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return accumulated;
|
|
73
|
-
}
|
|
74
|
-
return { common: node };
|
|
75
|
-
};
|
|
76
|
-
const getSplittedContent = (content) => {
|
|
77
|
-
const split = splitNode(content);
|
|
78
|
-
const output = {};
|
|
79
|
-
if (split.common !== void 0) output.common = split.common;
|
|
80
|
-
for (const key of Object.keys(split)) {
|
|
81
|
-
if (key === "common") continue;
|
|
82
|
-
const value = split[key];
|
|
83
|
-
if (value !== void 0) output[key] = value;
|
|
84
|
-
}
|
|
85
|
-
return output;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Splits the `content` field of a Dictionary into "common" and per-locale buckets.
|
|
89
|
-
*
|
|
90
|
-
* Given a dictionary like:
|
|
91
|
-
* ```js
|
|
92
|
-
* {
|
|
93
|
-
* key: "my-key",
|
|
94
|
-
* content: {
|
|
95
|
-
* commonContent: "common content",
|
|
96
|
-
* multilingualContent: t({
|
|
97
|
-
* en: "english content",
|
|
98
|
-
* fr: "french content",
|
|
99
|
-
* de: "german content",
|
|
100
|
-
* }),
|
|
101
|
-
* },
|
|
102
|
-
* }
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* It produces:
|
|
106
|
-
* ```js
|
|
107
|
-
* {
|
|
108
|
-
* common: { commonContent: "common content" },
|
|
109
|
-
* en: { multilingualContent: "english content" },
|
|
110
|
-
* fr: { multilingualContent: "french content" },
|
|
111
|
-
* de: { multilingualContent: "german content" },
|
|
112
|
-
* }
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* @param dictionary - The input dictionary object with possible multilingual or common content.
|
|
116
|
-
* @returns An object mapping "common" and each locale to their corresponding content subtrees.
|
|
117
|
-
*/
|
|
118
|
-
const getSplittedDictionaryContent = (dictionary) => getSplittedContent(dictionary.content);
|
|
119
|
-
|
|
120
|
-
//#endregion
|
|
121
|
-
exports.getSplittedContent = getSplittedContent;
|
|
122
|
-
exports.getSplittedDictionaryContent = getSplittedDictionaryContent;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types`);const t=e=>typeof e==`object`&&!!e&&!Array.isArray(e),n=e=>t(e)&&typeof e.nodeType==`string`,r=(e,i)=>{if(e===void 0)return i;if(i===void 0)return e;if(Array.isArray(e)&&Array.isArray(i))return[...e,...i];if(t(e)&&t(i)&&!n(e)&&!n(i)){let t={...e};for(let e of Object.keys(i))t[e]=r(t[e],i[e]);return t}return i},i=(e,t)=>{let n={...e};n.common=r(e.common,t.common);let i=new Set([...Object.keys(e).filter(e=>e!==`common`),...Object.keys(t).filter(e=>e!==`common`)]);for(let a of i)n[a]=r(e[a],t[a]);return n},a=o=>{if(t(o)&&o?.nodeType===e.NodeType.Translation){let t=o[e.NodeType.Translation],n={};for(let e of Object.keys(t)){let i=t[e],o=a(i),s=r(o.common,void 0),c;for(let e of Object.keys(o))e!==`common`&&(c=r(c,o[e]));let l=r(s,c);l!==void 0&&(n[e]=l)}return n}if(Array.isArray(o)){let e=[],t={};o.forEach(n=>{let r=a(n);r.common!==void 0&&e.push(r.common);for(let e of Object.keys(r)){if(e===`common`)continue;t[e]||(t[e]=[]);let n=r[e];n!==void 0&&t[e].push(n)}});let n={};e.length>0&&(n.common=e);for(let e of Object.keys(t))n[e]=t[e];return n}if(t(o)&&!n(o)){let e={};for(let t of Object.keys(o)){let n=a(o[t]);n.common!==void 0&&(e=i(e,{common:{[t]:n.common}}));for(let r of Object.keys(n))r!==`common`&&(e=i(e,{[r]:{[t]:n[r]}}))}return e}return{common:o}},o=e=>{let t=a(e),n={};t.common!==void 0&&(n.common=t.common);for(let e of Object.keys(t)){if(e===`common`)continue;let r=t[e];r!==void 0&&(n[e]=r)}return n},s=e=>o(e.content);exports.getSplittedContent=o,exports.getSplittedDictionaryContent=s;
|
|
123
2
|
//# sourceMappingURL=getSplittedContent.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSplittedContent.cjs","names":["NodeType"],"sources":["../../../src/deepTransformPlugins/getSplittedContent.ts"],"sourcesContent":["import {\n type ContentNode,\n type DeclaredLocales,\n type Dictionary,\n NodeType,\n} from '@intlayer/types';\n\ntype SplittedContentOutput<T = ContentNode> = Record<DeclaredLocales, T> & {\n common: T;\n};\n\ntype SplitResult = Record<string, ContentNode | undefined> & {\n common?: ContentNode;\n};\n\nconst isObject = (value: unknown): value is Record<string, any> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst hasNodeType = (value: unknown): value is { nodeType: string } =>\n isObject(value) && typeof (value as any).nodeType === 'string';\n\nconst mergeValues = (\n a: ContentNode | undefined,\n b: ContentNode | undefined\n): ContentNode | undefined => {\n if (a === undefined) return b;\n if (b === undefined) return a;\n\n if (Array.isArray(a) && Array.isArray(b)) {\n // Concatenate arrays when merging sibling results\n return [...a, ...b] as unknown as ContentNode;\n }\n\n if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {\n const result: Record<string, any> = { ...a };\n for (const key of Object.keys(b)) {\n result[key] = mergeValues(\n result[key] as unknown as ContentNode | undefined,\n (b as Record<string, any>)[key] as unknown as ContentNode | undefined\n );\n }\n return result as ContentNode;\n }\n\n // For primitives or differing structures, prefer b (more recent)\n return b;\n};\n\nconst mergeSplitResults = (\n base: SplitResult,\n addition: SplitResult\n): SplitResult => {\n const result: SplitResult = { ...base };\n\n // Merge common\n result.common = mergeValues(base.common, addition.common);\n\n // Merge each locale key present in either side\n const localeKeys = new Set<string>([\n ...Object.keys(base).filter((k) => k !== 'common'),\n ...Object.keys(addition).filter((k) => k !== 'common'),\n ]);\n\n for (const key of localeKeys) {\n // @ts-ignore: dynamic keys for locales\n result[key] = mergeValues(\n base[key] as ContentNode | undefined,\n addition[key] as ContentNode | undefined\n );\n }\n\n return result;\n};\n\nconst splitNode = (node: ContentNode): SplitResult => {\n // Translation node: allocate entirely to per-locale buckets\n if (isObject(node) && (node as any)?.nodeType === NodeType.Translation) {\n const translations = (node as any)[NodeType.Translation] as Record<\n string,\n ContentNode\n >;\n\n const result: SplitResult = {};\n for (const locale of Object.keys(translations)) {\n const child = translations[locale];\n const childSplit = splitNode(child);\n\n // The content under a translation belongs to the locale, not common\n // Merge common portion of the child (if any) into the locale as well\n const mergedForLocale = mergeValues(childSplit.common, undefined);\n\n // Compose locale content: prefer the fully rebuilt child by resolving deeper translations recursively\n // which are already split inside childSplit. We need to recompose a single node for this locale.\n // Recompose by merging all keys in childSplit except 'common' into a single node, then merge child's common.\n let recomposed: ContentNode | undefined;\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n recomposed = mergeValues(\n recomposed,\n childSplit[key] as ContentNode | undefined\n );\n }\n const finalLocaleNode = mergeValues(mergedForLocale, recomposed);\n\n if (finalLocaleNode !== undefined) {\n // @ts-ignore dynamic locale key\n result[locale] = finalLocaleNode;\n }\n }\n\n return result;\n }\n\n // Arrays: split each element and merge results index-wise\n if (Array.isArray(node)) {\n const commonArray: any[] = [];\n const perLocaleArrays: Record<string, any[]> = {};\n\n node.forEach((child) => {\n const childSplit = splitNode(child as ContentNode);\n\n if (childSplit.common !== undefined) {\n commonArray.push(childSplit.common);\n }\n\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n if (!perLocaleArrays[key]) perLocaleArrays[key] = [];\n const value = childSplit[key];\n if (value !== undefined) perLocaleArrays[key].push(value);\n }\n });\n\n const result: SplitResult = {};\n if (commonArray.length > 0)\n result.common = commonArray as unknown as ContentNode;\n for (const key of Object.keys(perLocaleArrays)) {\n // @ts-ignore dynamic locale key\n result[key] = perLocaleArrays[key] as unknown as ContentNode;\n }\n return result;\n }\n\n // Objects (non-typed): recursively split properties\n if (isObject(node) && !hasNodeType(node)) {\n let accumulated: SplitResult = {};\n\n for (const key of Object.keys(node)) {\n const childSplit = splitNode((node as any)[key] as ContentNode);\n\n // Assign property into common\n if (childSplit.common !== undefined) {\n accumulated = mergeSplitResults(accumulated, {\n common: { [key]: childSplit.common } as unknown as ContentNode,\n });\n }\n\n // Assign property into each locale bucket\n for (const locale of Object.keys(childSplit)) {\n if (locale === 'common') continue;\n accumulated = mergeSplitResults(accumulated, {\n // @ts-ignore dynamic locale key\n [locale]: { [key]: childSplit[locale] } as unknown as ContentNode,\n });\n }\n }\n\n return accumulated;\n }\n\n // Primitives or typed nodes (non-translation): entirely common\n return { common: node } as SplitResult;\n};\n\nexport const getSplittedContent = (\n content: ContentNode\n): SplittedContentOutput => {\n const split = splitNode(content);\n\n // Build final output with only defined sections\n const output: Record<string, ContentNode> = {};\n if (split.common !== undefined) {\n output.common = split.common;\n }\n for (const key of Object.keys(split)) {\n if (key === 'common') continue;\n const value = split[key] as ContentNode | undefined;\n if (value !== undefined) {\n output[key] = value;\n }\n }\n\n return output as unknown as SplittedContentOutput;\n};\n\n/**\n * Splits the `content` field of a Dictionary into \"common\" and per-locale buckets.\n *\n * Given a dictionary like:\n * ```js\n * {\n * key: \"my-key\",\n * content: {\n * commonContent: \"common content\",\n * multilingualContent: t({\n * en: \"english content\",\n * fr: \"french content\",\n * de: \"german content\",\n * }),\n * },\n * }\n * ```\n *\n * It produces:\n * ```js\n * {\n * common: { commonContent: \"common content\" },\n * en: { multilingualContent: \"english content\" },\n * fr: { multilingualContent: \"french content\" },\n * de: { multilingualContent: \"german content\" },\n * }\n * ```\n *\n * @param dictionary - The input dictionary object with possible multilingual or common content.\n * @returns An object mapping \"common\" and each locale to their corresponding content subtrees.\n */\nexport const getSplittedDictionaryContent = (\n dictionary: Dictionary\n): SplittedContentOutput<Dictionary['content']> =>\n getSplittedContent(dictionary.content);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getSplittedContent.cjs","names":["NodeType"],"sources":["../../../src/deepTransformPlugins/getSplittedContent.ts"],"sourcesContent":["import {\n type ContentNode,\n type DeclaredLocales,\n type Dictionary,\n NodeType,\n} from '@intlayer/types';\n\ntype SplittedContentOutput<T = ContentNode> = Record<DeclaredLocales, T> & {\n common: T;\n};\n\ntype SplitResult = Record<string, ContentNode | undefined> & {\n common?: ContentNode;\n};\n\nconst isObject = (value: unknown): value is Record<string, any> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst hasNodeType = (value: unknown): value is { nodeType: string } =>\n isObject(value) && typeof (value as any).nodeType === 'string';\n\nconst mergeValues = (\n a: ContentNode | undefined,\n b: ContentNode | undefined\n): ContentNode | undefined => {\n if (a === undefined) return b;\n if (b === undefined) return a;\n\n if (Array.isArray(a) && Array.isArray(b)) {\n // Concatenate arrays when merging sibling results\n return [...a, ...b] as unknown as ContentNode;\n }\n\n if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {\n const result: Record<string, any> = { ...a };\n for (const key of Object.keys(b)) {\n result[key] = mergeValues(\n result[key] as unknown as ContentNode | undefined,\n (b as Record<string, any>)[key] as unknown as ContentNode | undefined\n );\n }\n return result as ContentNode;\n }\n\n // For primitives or differing structures, prefer b (more recent)\n return b;\n};\n\nconst mergeSplitResults = (\n base: SplitResult,\n addition: SplitResult\n): SplitResult => {\n const result: SplitResult = { ...base };\n\n // Merge common\n result.common = mergeValues(base.common, addition.common);\n\n // Merge each locale key present in either side\n const localeKeys = new Set<string>([\n ...Object.keys(base).filter((k) => k !== 'common'),\n ...Object.keys(addition).filter((k) => k !== 'common'),\n ]);\n\n for (const key of localeKeys) {\n // @ts-ignore: dynamic keys for locales\n result[key] = mergeValues(\n base[key] as ContentNode | undefined,\n addition[key] as ContentNode | undefined\n );\n }\n\n return result;\n};\n\nconst splitNode = (node: ContentNode): SplitResult => {\n // Translation node: allocate entirely to per-locale buckets\n if (isObject(node) && (node as any)?.nodeType === NodeType.Translation) {\n const translations = (node as any)[NodeType.Translation] as Record<\n string,\n ContentNode\n >;\n\n const result: SplitResult = {};\n for (const locale of Object.keys(translations)) {\n const child = translations[locale];\n const childSplit = splitNode(child);\n\n // The content under a translation belongs to the locale, not common\n // Merge common portion of the child (if any) into the locale as well\n const mergedForLocale = mergeValues(childSplit.common, undefined);\n\n // Compose locale content: prefer the fully rebuilt child by resolving deeper translations recursively\n // which are already split inside childSplit. We need to recompose a single node for this locale.\n // Recompose by merging all keys in childSplit except 'common' into a single node, then merge child's common.\n let recomposed: ContentNode | undefined;\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n recomposed = mergeValues(\n recomposed,\n childSplit[key] as ContentNode | undefined\n );\n }\n const finalLocaleNode = mergeValues(mergedForLocale, recomposed);\n\n if (finalLocaleNode !== undefined) {\n // @ts-ignore dynamic locale key\n result[locale] = finalLocaleNode;\n }\n }\n\n return result;\n }\n\n // Arrays: split each element and merge results index-wise\n if (Array.isArray(node)) {\n const commonArray: any[] = [];\n const perLocaleArrays: Record<string, any[]> = {};\n\n node.forEach((child) => {\n const childSplit = splitNode(child as ContentNode);\n\n if (childSplit.common !== undefined) {\n commonArray.push(childSplit.common);\n }\n\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n if (!perLocaleArrays[key]) perLocaleArrays[key] = [];\n const value = childSplit[key];\n if (value !== undefined) perLocaleArrays[key].push(value);\n }\n });\n\n const result: SplitResult = {};\n if (commonArray.length > 0)\n result.common = commonArray as unknown as ContentNode;\n for (const key of Object.keys(perLocaleArrays)) {\n // @ts-ignore dynamic locale key\n result[key] = perLocaleArrays[key] as unknown as ContentNode;\n }\n return result;\n }\n\n // Objects (non-typed): recursively split properties\n if (isObject(node) && !hasNodeType(node)) {\n let accumulated: SplitResult = {};\n\n for (const key of Object.keys(node)) {\n const childSplit = splitNode((node as any)[key] as ContentNode);\n\n // Assign property into common\n if (childSplit.common !== undefined) {\n accumulated = mergeSplitResults(accumulated, {\n common: { [key]: childSplit.common } as unknown as ContentNode,\n });\n }\n\n // Assign property into each locale bucket\n for (const locale of Object.keys(childSplit)) {\n if (locale === 'common') continue;\n accumulated = mergeSplitResults(accumulated, {\n // @ts-ignore dynamic locale key\n [locale]: { [key]: childSplit[locale] } as unknown as ContentNode,\n });\n }\n }\n\n return accumulated;\n }\n\n // Primitives or typed nodes (non-translation): entirely common\n return { common: node } as SplitResult;\n};\n\nexport const getSplittedContent = (\n content: ContentNode\n): SplittedContentOutput => {\n const split = splitNode(content);\n\n // Build final output with only defined sections\n const output: Record<string, ContentNode> = {};\n if (split.common !== undefined) {\n output.common = split.common;\n }\n for (const key of Object.keys(split)) {\n if (key === 'common') continue;\n const value = split[key] as ContentNode | undefined;\n if (value !== undefined) {\n output[key] = value;\n }\n }\n\n return output as unknown as SplittedContentOutput;\n};\n\n/**\n * Splits the `content` field of a Dictionary into \"common\" and per-locale buckets.\n *\n * Given a dictionary like:\n * ```js\n * {\n * key: \"my-key\",\n * content: {\n * commonContent: \"common content\",\n * multilingualContent: t({\n * en: \"english content\",\n * fr: \"french content\",\n * de: \"german content\",\n * }),\n * },\n * }\n * ```\n *\n * It produces:\n * ```js\n * {\n * common: { commonContent: \"common content\" },\n * en: { multilingualContent: \"english content\" },\n * fr: { multilingualContent: \"french content\" },\n * de: { multilingualContent: \"german content\" },\n * }\n * ```\n *\n * @param dictionary - The input dictionary object with possible multilingual or common content.\n * @returns An object mapping \"common\" and each locale to their corresponding content subtrees.\n */\nexport const getSplittedDictionaryContent = (\n dictionary: Dictionary\n): SplittedContentOutput<Dictionary['content']> =>\n getSplittedContent(dictionary.content);\n"],"mappings":"iJAeA,MAAM,EAAY,GAChB,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,EAAM,CAEhE,EAAe,GACnB,EAAS,EAAM,EAAI,OAAQ,EAAc,UAAa,SAElD,GACJ,EACA,IAC4B,CAC5B,GAAI,IAAM,IAAA,GAAW,OAAO,EAC5B,GAAI,IAAM,IAAA,GAAW,OAAO,EAE5B,GAAI,MAAM,QAAQ,EAAE,EAAI,MAAM,QAAQ,EAAE,CAEtC,MAAO,CAAC,GAAG,EAAG,GAAG,EAAE,CAGrB,GAAI,EAAS,EAAE,EAAI,EAAS,EAAE,EAAI,CAAC,EAAY,EAAE,EAAI,CAAC,EAAY,EAAE,CAAE,CACpE,IAAM,EAA8B,CAAE,GAAG,EAAG,CAC5C,IAAK,IAAM,KAAO,OAAO,KAAK,EAAE,CAC9B,EAAO,GAAO,EACZ,EAAO,GACN,EAA0B,GAC5B,CAEH,OAAO,EAIT,OAAO,GAGH,GACJ,EACA,IACgB,CAChB,IAAM,EAAsB,CAAE,GAAG,EAAM,CAGvC,EAAO,OAAS,EAAY,EAAK,OAAQ,EAAS,OAAO,CAGzD,IAAM,EAAa,IAAI,IAAY,CACjC,GAAG,OAAO,KAAK,EAAK,CAAC,OAAQ,GAAM,IAAM,SAAS,CAClD,GAAG,OAAO,KAAK,EAAS,CAAC,OAAQ,GAAM,IAAM,SAAS,CACvD,CAAC,CAEF,IAAK,IAAM,KAAO,EAEhB,EAAO,GAAO,EACZ,EAAK,GACL,EAAS,GACV,CAGH,OAAO,GAGH,EAAa,GAAmC,CAEpD,GAAI,EAAS,EAAK,EAAK,GAAc,WAAaA,EAAAA,SAAS,YAAa,CACtE,IAAM,EAAgB,EAAaA,EAAAA,SAAS,aAKtC,EAAsB,EAAE,CAC9B,IAAK,IAAM,KAAU,OAAO,KAAK,EAAa,CAAE,CAC9C,IAAM,EAAQ,EAAa,GACrB,EAAa,EAAU,EAAM,CAI7B,EAAkB,EAAY,EAAW,OAAQ,IAAA,GAAU,CAK7D,EACJ,IAAK,IAAM,KAAO,OAAO,KAAK,EAAW,CACnC,IAAQ,WACZ,EAAa,EACX,EACA,EAAW,GACZ,EAEH,IAAM,EAAkB,EAAY,EAAiB,EAAW,CAE5D,IAAoB,IAAA,KAEtB,EAAO,GAAU,GAIrB,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAK,CAAE,CACvB,IAAM,EAAqB,EAAE,CACvB,EAAyC,EAAE,CAEjD,EAAK,QAAS,GAAU,CACtB,IAAM,EAAa,EAAU,EAAqB,CAE9C,EAAW,SAAW,IAAA,IACxB,EAAY,KAAK,EAAW,OAAO,CAGrC,IAAK,IAAM,KAAO,OAAO,KAAK,EAAW,CAAE,CACzC,GAAI,IAAQ,SAAU,SACjB,EAAgB,KAAM,EAAgB,GAAO,EAAE,EACpD,IAAM,EAAQ,EAAW,GACrB,IAAU,IAAA,IAAW,EAAgB,GAAK,KAAK,EAAM,GAE3D,CAEF,IAAM,EAAsB,EAAE,CAC1B,EAAY,OAAS,IACvB,EAAO,OAAS,GAClB,IAAK,IAAM,KAAO,OAAO,KAAK,EAAgB,CAE5C,EAAO,GAAO,EAAgB,GAEhC,OAAO,EAIT,GAAI,EAAS,EAAK,EAAI,CAAC,EAAY,EAAK,CAAE,CACxC,IAAI,EAA2B,EAAE,CAEjC,IAAK,IAAM,KAAO,OAAO,KAAK,EAAK,CAAE,CACnC,IAAM,EAAa,EAAW,EAAa,GAAoB,CAG3D,EAAW,SAAW,IAAA,KACxB,EAAc,EAAkB,EAAa,CAC3C,OAAQ,EAAG,GAAM,EAAW,OAAQ,CACrC,CAAC,EAIJ,IAAK,IAAM,KAAU,OAAO,KAAK,EAAW,CACtC,IAAW,WACf,EAAc,EAAkB,EAAa,EAE1C,GAAS,EAAG,GAAM,EAAW,GAAS,CACxC,CAAC,EAIN,OAAO,EAIT,MAAO,CAAE,OAAQ,EAAM,EAGZ,EACX,GAC0B,CAC1B,IAAM,EAAQ,EAAU,EAAQ,CAG1B,EAAsC,EAAE,CAC1C,EAAM,SAAW,IAAA,KACnB,EAAO,OAAS,EAAM,QAExB,IAAK,IAAM,KAAO,OAAO,KAAK,EAAM,CAAE,CACpC,GAAI,IAAQ,SAAU,SACtB,IAAM,EAAQ,EAAM,GAChB,IAAU,IAAA,KACZ,EAAO,GAAO,GAIlB,OAAO,GAkCI,EACX,GAEA,EAAmB,EAAW,QAAQ"}
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_deepTransformPlugins_getFilteredLocalesContent = require('./getFilteredLocalesContent.cjs');
|
|
3
|
-
const require_deepTransformPlugins_getFilterMissingTranslationsContent = require('./getFilterMissingTranslationsContent.cjs');
|
|
4
|
-
const require_deepTransformPlugins_getFilterTranslationsOnlyContent = require('./getFilterTranslationsOnlyContent.cjs');
|
|
5
|
-
const require_deepTransformPlugins_getLocalizedContent = require('./getLocalizedContent.cjs');
|
|
6
|
-
const require_deepTransformPlugins_getMaskContent = require('./getMaskContent.cjs');
|
|
7
|
-
const require_deepTransformPlugins_getMissingLocalesContent = require('./getMissingLocalesContent.cjs');
|
|
8
|
-
const require_deepTransformPlugins_getMultilingualDictionary = require('./getMultilingualDictionary.cjs');
|
|
9
|
-
const require_deepTransformPlugins_getReplacedValuesContent = require('./getReplacedValuesContent.cjs');
|
|
10
|
-
const require_deepTransformPlugins_getSplittedContent = require('./getSplittedContent.cjs');
|
|
11
|
-
const require_deepTransformPlugins_insertContentInDictionary = require('./insertContentInDictionary.cjs');
|
|
12
|
-
|
|
13
|
-
exports.buildMaskPlugin = require_deepTransformPlugins_getMaskContent.buildMaskPlugin;
|
|
14
|
-
exports.checkMissingLocalesPlugin = require_deepTransformPlugins_getMissingLocalesContent.checkMissingLocalesPlugin;
|
|
15
|
-
exports.filterMissingTranslationsOnlyPlugin = require_deepTransformPlugins_getFilterMissingTranslationsContent.filterMissingTranslationsOnlyPlugin;
|
|
16
|
-
exports.filterTranslationsOnlyPlugin = require_deepTransformPlugins_getFilterTranslationsOnlyContent.filterTranslationsOnlyPlugin;
|
|
17
|
-
exports.getFilterMissingTranslationsContent = require_deepTransformPlugins_getFilterMissingTranslationsContent.getFilterMissingTranslationsContent;
|
|
18
|
-
exports.getFilterMissingTranslationsDictionary = require_deepTransformPlugins_getFilterMissingTranslationsContent.getFilterMissingTranslationsDictionary;
|
|
19
|
-
exports.getFilterTranslationsOnlyContent = require_deepTransformPlugins_getFilterTranslationsOnlyContent.getFilterTranslationsOnlyContent;
|
|
20
|
-
exports.getFilterTranslationsOnlyDictionary = require_deepTransformPlugins_getFilterTranslationsOnlyContent.getFilterTranslationsOnlyDictionary;
|
|
21
|
-
exports.getFilteredLocalesContent = require_deepTransformPlugins_getFilteredLocalesContent.getFilteredLocalesContent;
|
|
22
|
-
exports.getFilteredLocalesDictionary = require_deepTransformPlugins_getFilteredLocalesContent.getFilteredLocalesDictionary;
|
|
23
|
-
exports.getLocalizedContent = require_deepTransformPlugins_getLocalizedContent.getLocalizedContent;
|
|
24
|
-
exports.getMaskContent = require_deepTransformPlugins_getMaskContent.getMaskContent;
|
|
25
|
-
exports.getMissingLocalesContent = require_deepTransformPlugins_getMissingLocalesContent.getMissingLocalesContent;
|
|
26
|
-
exports.getMissingLocalesContentFromDictionary = require_deepTransformPlugins_getMissingLocalesContent.getMissingLocalesContentFromDictionary;
|
|
27
|
-
exports.getMultilingualDictionary = require_deepTransformPlugins_getMultilingualDictionary.getMultilingualDictionary;
|
|
28
|
-
exports.getPerLocaleDictionary = require_deepTransformPlugins_getLocalizedContent.getPerLocaleDictionary;
|
|
29
|
-
exports.getReplacedValuesContent = require_deepTransformPlugins_getReplacedValuesContent.getReplacedValuesContent;
|
|
30
|
-
exports.getSplittedContent = require_deepTransformPlugins_getSplittedContent.getSplittedContent;
|
|
31
|
-
exports.getSplittedDictionaryContent = require_deepTransformPlugins_getSplittedContent.getSplittedDictionaryContent;
|
|
32
|
-
exports.insertContentInDictionary = require_deepTransformPlugins_insertContentInDictionary.insertContentInDictionary;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getFilteredLocalesContent.cjs`),t=require(`./getFilterMissingTranslationsContent.cjs`),n=require(`./getFilterTranslationsOnlyContent.cjs`),r=require(`./getLocalizedContent.cjs`),i=require(`./getMaskContent.cjs`),a=require(`./getMissingLocalesContent.cjs`),o=require(`./getMultilingualDictionary.cjs`),s=require(`./getReplacedValuesContent.cjs`),c=require(`./getSplittedContent.cjs`),l=require(`./insertContentInDictionary.cjs`);exports.buildMaskPlugin=i.buildMaskPlugin,exports.checkMissingLocalesPlugin=a.checkMissingLocalesPlugin,exports.filterMissingTranslationsOnlyPlugin=t.filterMissingTranslationsOnlyPlugin,exports.filterTranslationsOnlyPlugin=n.filterTranslationsOnlyPlugin,exports.getFilterMissingTranslationsContent=t.getFilterMissingTranslationsContent,exports.getFilterMissingTranslationsDictionary=t.getFilterMissingTranslationsDictionary,exports.getFilterTranslationsOnlyContent=n.getFilterTranslationsOnlyContent,exports.getFilterTranslationsOnlyDictionary=n.getFilterTranslationsOnlyDictionary,exports.getFilteredLocalesContent=e.getFilteredLocalesContent,exports.getFilteredLocalesDictionary=e.getFilteredLocalesDictionary,exports.getLocalizedContent=r.getLocalizedContent,exports.getMaskContent=i.getMaskContent,exports.getMissingLocalesContent=a.getMissingLocalesContent,exports.getMissingLocalesContentFromDictionary=a.getMissingLocalesContentFromDictionary,exports.getMultilingualDictionary=o.getMultilingualDictionary,exports.getPerLocaleDictionary=r.getPerLocaleDictionary,exports.getReplacedValuesContent=s.getReplacedValuesContent,exports.getSplittedContent=c.getSplittedContent,exports.getSplittedDictionaryContent=c.getSplittedDictionaryContent,exports.insertContentInDictionary=l.insertContentInDictionary;
|