@intlayer/core 9.0.0-canary.2 → 9.0.0-canary.20
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/deepTransformPlugins/getEditedContent.cjs +2 -1
- package/dist/cjs/deepTransformPlugins/getEditedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -1
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/index.cjs +4 -3
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -2
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs +9 -12
- package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +0 -1
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs +116 -101
- package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
- package/dist/cjs/formatters/compact.cjs +1 -2
- package/dist/cjs/formatters/compact.cjs.map +1 -1
- package/dist/cjs/formatters/currency.cjs +1 -2
- package/dist/cjs/formatters/currency.cjs.map +1 -1
- package/dist/cjs/formatters/date.cjs +1 -3
- package/dist/cjs/formatters/date.cjs.map +1 -1
- package/dist/cjs/formatters/list.cjs +1 -2
- package/dist/cjs/formatters/list.cjs.map +1 -1
- package/dist/cjs/formatters/number.cjs +1 -2
- package/dist/cjs/formatters/number.cjs.map +1 -1
- package/dist/cjs/formatters/percentage.cjs +1 -2
- package/dist/cjs/formatters/percentage.cjs.map +1 -1
- package/dist/cjs/formatters/relativeTime.cjs +1 -2
- package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
- package/dist/cjs/formatters/units.cjs +1 -2
- package/dist/cjs/formatters/units.cjs.map +1 -1
- package/dist/cjs/index.cjs +14 -3
- package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/deepTransform.cjs +3 -2
- package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/getContent.cjs +0 -1
- package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/plugins.cjs +12 -10
- package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
- package/dist/cjs/interpreter/getDictionary.cjs +5 -5
- package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
- package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
- package/dist/cjs/interpreter/getGender.cjs.map +1 -1
- package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
- package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
- package/dist/cjs/interpreter/getIntlayer.cjs +4 -4
- package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
- package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
- package/dist/cjs/interpreter/getPlural.cjs +1 -1
- package/dist/cjs/interpreter/getPlural.cjs.map +1 -1
- package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
- package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
- package/dist/cjs/localization/comparePaths.cjs +75 -0
- package/dist/cjs/localization/comparePaths.cjs.map +1 -0
- package/dist/cjs/localization/domainUtils.cjs +82 -0
- package/dist/cjs/localization/domainUtils.cjs.map +1 -0
- package/dist/cjs/localization/generateSitemap.cjs +2 -1
- package/dist/cjs/localization/generateSitemap.cjs.map +1 -1
- package/dist/cjs/localization/getBrowserLocale.cjs +7 -4
- package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
- package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
- package/dist/cjs/localization/getLocale.cjs +0 -1
- package/dist/cjs/localization/getLocale.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
- package/dist/cjs/localization/getLocalizedUrl.cjs +7 -15
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
- package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
- package/dist/cjs/localization/getPathWithoutLocale.cjs +2 -3
- package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
- package/dist/cjs/localization/getPrefix.cjs +6 -11
- package/dist/cjs/localization/getPrefix.cjs.map +1 -1
- package/dist/cjs/localization/index.cjs +8 -0
- package/dist/cjs/localization/localeDetector.cjs +2 -1
- package/dist/cjs/localization/localeDetector.cjs.map +1 -1
- package/dist/cjs/localization/localeMapper.cjs +0 -1
- package/dist/cjs/localization/localeMapper.cjs.map +1 -1
- package/dist/cjs/localization/localeResolver.cjs +0 -1
- package/dist/cjs/localization/localeResolver.cjs.map +1 -1
- package/dist/cjs/localization/rewriteUtils.cjs +3 -2
- package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
- package/dist/cjs/localization/validatePrefix.cjs +2 -2
- package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
- package/dist/cjs/markdown/compiler.cjs +2 -1
- package/dist/cjs/markdown/compiler.cjs.map +1 -1
- package/dist/cjs/markdown/constants.cjs.map +1 -1
- package/dist/cjs/markdown/parser.cjs.map +1 -1
- package/dist/cjs/markdown/renderer.cjs.map +1 -1
- package/dist/cjs/markdown/utils.cjs.map +1 -1
- package/dist/cjs/messageFormat/ICU.cjs +15 -9
- package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
- package/dist/cjs/messageFormat/i18next.cjs +12 -7
- package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
- package/dist/cjs/messageFormat/index.cjs +2 -0
- package/dist/cjs/messageFormat/navigatePath.cjs +38 -0
- package/dist/cjs/messageFormat/navigatePath.cjs.map +1 -0
- package/dist/cjs/messageFormat/po.cjs.map +1 -1
- package/dist/cjs/messageFormat/resolveMessage.cjs +11 -8
- package/dist/cjs/messageFormat/resolveMessage.cjs.map +1 -1
- package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
- package/dist/cjs/messageFormat/vue-i18n.cjs +2 -1
- package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
- package/dist/cjs/transpiler/condition/condition.cjs +0 -1
- package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
- package/dist/cjs/transpiler/enumeration/enumeration.cjs +0 -1
- package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
- package/dist/cjs/transpiler/file/file.cjs +2 -2
- package/dist/cjs/transpiler/file/file.cjs.map +1 -1
- package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
- package/dist/cjs/transpiler/gender/gender.cjs +0 -1
- package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
- package/dist/cjs/transpiler/html/html.cjs +0 -1
- package/dist/cjs/transpiler/html/html.cjs.map +1 -1
- package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
- package/dist/cjs/transpiler/html/validateHTML.cjs +1 -1
- package/dist/cjs/transpiler/html/validateHTML.cjs.map +1 -1
- package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
- package/dist/cjs/transpiler/insertion/insertion.cjs +0 -1
- package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/markdown.cjs +0 -1
- package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/validateMarkdown.cjs.map +1 -1
- package/dist/cjs/transpiler/nesting/nesting.cjs +0 -1
- package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
- package/dist/cjs/transpiler/plural/plural.cjs +0 -1
- package/dist/cjs/transpiler/plural/plural.cjs.map +1 -1
- package/dist/cjs/transpiler/translation/translation.cjs +0 -1
- package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
- package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
- package/dist/cjs/utils/cookieExpiry.cjs.map +1 -1
- package/dist/cjs/utils/getCookie.cjs.map +1 -1
- package/dist/cjs/utils/intl.cjs +101 -26
- package/dist/cjs/utils/intl.cjs.map +1 -1
- package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
- package/dist/cjs/utils/localeStorage.cjs +4 -5
- package/dist/cjs/utils/localeStorage.cjs.map +1 -1
- package/dist/cjs/utils/parseYaml.cjs +1 -1
- package/dist/cjs/utils/parseYaml.cjs.map +1 -1
- package/dist/cjs/utils/stringifyYaml.cjs +1 -1
- package/dist/cjs/utils/stringifyYaml.cjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getEditedContent.mjs +2 -1
- package/dist/esm/deepTransformPlugins/getEditedContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -1
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/index.mjs +2 -2
- package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -1
- package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs +10 -12
- package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs +113 -99
- package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
- package/dist/esm/formatters/compact.mjs +1 -1
- package/dist/esm/formatters/compact.mjs.map +1 -1
- package/dist/esm/formatters/currency.mjs +1 -1
- package/dist/esm/formatters/currency.mjs.map +1 -1
- package/dist/esm/formatters/date.mjs +1 -2
- package/dist/esm/formatters/date.mjs.map +1 -1
- package/dist/esm/formatters/list.mjs +1 -1
- package/dist/esm/formatters/list.mjs.map +1 -1
- package/dist/esm/formatters/number.mjs +1 -1
- package/dist/esm/formatters/number.mjs.map +1 -1
- package/dist/esm/formatters/percentage.mjs +1 -1
- package/dist/esm/formatters/percentage.mjs.map +1 -1
- package/dist/esm/formatters/relativeTime.mjs +1 -1
- package/dist/esm/formatters/relativeTime.mjs.map +1 -1
- package/dist/esm/formatters/units.mjs +1 -1
- package/dist/esm/formatters/units.mjs.map +1 -1
- package/dist/esm/index.mjs +5 -2
- package/dist/esm/interpreter/getCondition.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/deepTransform.mjs +3 -2
- package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/plugins.mjs +12 -10
- package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
- package/dist/esm/interpreter/getDictionary.mjs +5 -5
- package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
- package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
- package/dist/esm/interpreter/getGender.mjs.map +1 -1
- package/dist/esm/interpreter/getHTML.mjs.map +1 -1
- package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
- package/dist/esm/interpreter/getIntlayer.mjs +4 -3
- package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
- package/dist/esm/interpreter/getNesting.mjs.map +1 -1
- package/dist/esm/interpreter/getPlural.mjs +1 -1
- package/dist/esm/interpreter/getPlural.mjs.map +1 -1
- package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
- package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
- package/dist/esm/localization/comparePaths.mjs +73 -0
- package/dist/esm/localization/comparePaths.mjs.map +1 -0
- package/dist/esm/localization/domainUtils.mjs +77 -0
- package/dist/esm/localization/domainUtils.mjs.map +1 -0
- package/dist/esm/localization/generateSitemap.mjs +2 -1
- package/dist/esm/localization/generateSitemap.mjs.map +1 -1
- package/dist/esm/localization/getBrowserLocale.mjs +7 -3
- package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
- package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
- package/dist/esm/localization/getLocale.mjs.map +1 -1
- package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
- package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
- package/dist/esm/localization/getLocaleName.mjs.map +1 -1
- package/dist/esm/localization/getLocalizedUrl.mjs +7 -14
- package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
- package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
- package/dist/esm/localization/getPathWithoutLocale.mjs +2 -2
- package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
- package/dist/esm/localization/getPrefix.mjs +6 -10
- package/dist/esm/localization/getPrefix.mjs.map +1 -1
- package/dist/esm/localization/index.mjs +3 -1
- package/dist/esm/localization/localeDetector.mjs +2 -1
- package/dist/esm/localization/localeDetector.mjs.map +1 -1
- package/dist/esm/localization/localeMapper.mjs.map +1 -1
- package/dist/esm/localization/localeResolver.mjs.map +1 -1
- package/dist/esm/localization/rewriteUtils.mjs +3 -2
- package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
- package/dist/esm/localization/validatePrefix.mjs +2 -2
- package/dist/esm/localization/validatePrefix.mjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs +2 -1
- package/dist/esm/markdown/compiler.mjs.map +1 -1
- package/dist/esm/markdown/constants.mjs.map +1 -1
- package/dist/esm/markdown/parser.mjs.map +1 -1
- package/dist/esm/markdown/renderer.mjs.map +1 -1
- package/dist/esm/markdown/utils.mjs.map +1 -1
- package/dist/esm/messageFormat/ICU.mjs +15 -9
- package/dist/esm/messageFormat/ICU.mjs.map +1 -1
- package/dist/esm/messageFormat/i18next.mjs +12 -7
- package/dist/esm/messageFormat/i18next.mjs.map +1 -1
- package/dist/esm/messageFormat/index.mjs +2 -1
- package/dist/esm/messageFormat/navigatePath.mjs +36 -0
- package/dist/esm/messageFormat/navigatePath.mjs.map +1 -0
- package/dist/esm/messageFormat/po.mjs.map +1 -1
- package/dist/esm/messageFormat/resolveMessage.mjs +11 -8
- package/dist/esm/messageFormat/resolveMessage.mjs.map +1 -1
- package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
- package/dist/esm/messageFormat/vue-i18n.mjs +2 -1
- package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
- package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
- package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
- package/dist/esm/transpiler/file/file.mjs +2 -1
- package/dist/esm/transpiler/file/file.mjs.map +1 -1
- package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
- package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
- package/dist/esm/transpiler/html/html.mjs.map +1 -1
- package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
- package/dist/esm/transpiler/html/validateHTML.mjs +1 -1
- package/dist/esm/transpiler/html/validateHTML.mjs.map +1 -1
- package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
- package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/validateMarkdown.mjs.map +1 -1
- package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
- package/dist/esm/transpiler/plural/plural.mjs.map +1 -1
- package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
- package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
- package/dist/esm/utils/cookieExpiry.mjs.map +1 -1
- package/dist/esm/utils/getCookie.mjs.map +1 -1
- package/dist/esm/utils/intl.mjs +100 -25
- package/dist/esm/utils/intl.mjs.map +1 -1
- package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
- package/dist/esm/utils/localeStorage.mjs +4 -4
- package/dist/esm/utils/localeStorage.mjs.map +1 -1
- package/dist/esm/utils/parseYaml.mjs +1 -1
- package/dist/esm/utils/parseYaml.mjs.map +1 -1
- package/dist/esm/utils/stringifyYaml.mjs +1 -1
- package/dist/esm/utils/stringifyYaml.mjs.map +1 -1
- package/dist/types/deepTransformPlugins/getEditedContent.d.ts +0 -1
- package/dist/types/deepTransformPlugins/getEditedContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +12 -14
- package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +12 -14
- package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +12 -14
- package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts +1 -1
- package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getMaskContent.d.ts +1 -1
- package/dist/types/deepTransformPlugins/getMaskContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts +1 -1
- package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts +0 -1
- package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts +1 -1
- package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/getSplittedContent.d.ts +1 -2
- package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +1 -1
- package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts +1 -2
- package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts +0 -1
- package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +0 -1
- package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +0 -1
- package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/getEmptyNode.d.ts +0 -1
- package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/getNodeChildren.d.ts +0 -1
- package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/getNodeType.d.ts +0 -1
- package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/index.d.ts +2 -2
- package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts +0 -1
- package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts +1 -2
- package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts +0 -1
- package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +1 -2
- package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts +59 -36
- package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts +0 -1
- package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts +1 -2
- package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +1 -1
- package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts +0 -1
- package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +1 -1
- package/dist/types/formatters/compact.d.ts +0 -1
- package/dist/types/formatters/compact.d.ts.map +1 -1
- package/dist/types/formatters/currency.d.ts +0 -1
- package/dist/types/formatters/currency.d.ts.map +1 -1
- package/dist/types/formatters/date.d.ts +0 -1
- package/dist/types/formatters/date.d.ts.map +1 -1
- package/dist/types/formatters/index.d.ts +2 -2
- package/dist/types/formatters/list.d.ts +0 -1
- package/dist/types/formatters/list.d.ts.map +1 -1
- package/dist/types/formatters/number.d.ts +1 -5
- package/dist/types/formatters/number.d.ts.map +1 -1
- package/dist/types/formatters/percentage.d.ts +1 -5
- package/dist/types/formatters/percentage.d.ts.map +1 -1
- package/dist/types/formatters/relativeTime.d.ts +0 -1
- package/dist/types/formatters/relativeTime.d.ts.map +1 -1
- package/dist/types/formatters/units.d.ts +0 -1
- package/dist/types/formatters/units.d.ts.map +1 -1
- package/dist/types/index.d.ts +15 -3
- package/dist/types/interpreter/getCondition.d.ts +1 -0
- package/dist/types/interpreter/getCondition.d.ts.map +1 -1
- package/dist/types/interpreter/getContent/deepTransform.d.ts +0 -1
- package/dist/types/interpreter/getContent/deepTransform.d.ts.map +1 -1
- package/dist/types/interpreter/getContent/getContent.d.ts +0 -1
- package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
- package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/interpreter/getDictionary.d.ts +6 -6
- package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
- package/dist/types/interpreter/getEnumeration.d.ts +1 -0
- package/dist/types/interpreter/getEnumeration.d.ts.map +1 -1
- package/dist/types/interpreter/getGender.d.ts +1 -0
- package/dist/types/interpreter/getGender.d.ts.map +1 -1
- package/dist/types/interpreter/getHTML.d.ts.map +1 -1
- package/dist/types/interpreter/getInsertion.d.ts +2 -1
- package/dist/types/interpreter/getInsertion.d.ts.map +1 -1
- package/dist/types/interpreter/getIntlayer.d.ts +2 -2
- package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
- package/dist/types/interpreter/getNesting.d.ts +2 -1
- package/dist/types/interpreter/getNesting.d.ts.map +1 -1
- package/dist/types/interpreter/getPlural.d.ts +0 -1
- package/dist/types/interpreter/getPlural.d.ts.map +1 -1
- package/dist/types/interpreter/getTranslation.d.ts +0 -1
- package/dist/types/interpreter/getTranslation.d.ts.map +1 -1
- package/dist/types/interpreter/index.d.ts +1 -0
- package/dist/types/interpreter/splitAndJoinInsertion.d.ts.map +1 -1
- package/dist/types/localization/comparePaths.d.ts +65 -0
- package/dist/types/localization/comparePaths.d.ts.map +1 -0
- package/dist/types/localization/domainUtils.d.ts +69 -0
- package/dist/types/localization/domainUtils.d.ts.map +1 -0
- package/dist/types/localization/generateSitemap.d.ts +6 -4
- package/dist/types/localization/generateSitemap.d.ts.map +1 -1
- package/dist/types/localization/getBrowserLocale.d.ts +0 -1
- package/dist/types/localization/getBrowserLocale.d.ts.map +1 -1
- package/dist/types/localization/getHTMLTextDir.d.ts +0 -1
- package/dist/types/localization/getHTMLTextDir.d.ts.map +1 -1
- package/dist/types/localization/getLocale.d.ts +0 -1
- package/dist/types/localization/getLocale.d.ts.map +1 -1
- package/dist/types/localization/getLocaleFromPath.d.ts +0 -1
- package/dist/types/localization/getLocaleFromPath.d.ts.map +1 -1
- package/dist/types/localization/getLocaleLang.d.ts +0 -1
- package/dist/types/localization/getLocaleLang.d.ts.map +1 -1
- package/dist/types/localization/getLocaleName.d.ts +0 -1
- package/dist/types/localization/getLocaleName.d.ts.map +1 -1
- package/dist/types/localization/getLocalizedUrl.d.ts +0 -1
- package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -1
- package/dist/types/localization/getMultilingualUrls.d.ts +0 -1
- package/dist/types/localization/getMultilingualUrls.d.ts.map +1 -1
- package/dist/types/localization/getPathWithoutLocale.d.ts +0 -1
- package/dist/types/localization/getPathWithoutLocale.d.ts.map +1 -1
- package/dist/types/localization/getPrefix.d.ts +2 -3
- package/dist/types/localization/getPrefix.d.ts.map +1 -1
- package/dist/types/localization/index.d.ts +3 -1
- package/dist/types/localization/localeDetector.d.ts +0 -1
- package/dist/types/localization/localeDetector.d.ts.map +1 -1
- package/dist/types/localization/localeMapper.d.ts +3 -4
- package/dist/types/localization/localeMapper.d.ts.map +1 -1
- package/dist/types/localization/localeResolver.d.ts +0 -1
- package/dist/types/localization/localeResolver.d.ts.map +1 -1
- package/dist/types/localization/rewriteUtils.d.ts +2 -3
- package/dist/types/localization/rewriteUtils.d.ts.map +1 -1
- package/dist/types/localization/validatePrefix.d.ts +0 -1
- package/dist/types/localization/validatePrefix.d.ts.map +1 -1
- package/dist/types/markdown/compiler.d.ts +0 -1
- package/dist/types/markdown/compiler.d.ts.map +1 -1
- package/dist/types/markdown/constants.d.ts +48 -38
- package/dist/types/markdown/constants.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +2 -1
- package/dist/types/markdown/parser.d.ts +0 -1
- package/dist/types/markdown/parser.d.ts.map +1 -1
- package/dist/types/markdown/renderer.d.ts +0 -1
- package/dist/types/markdown/renderer.d.ts.map +1 -1
- package/dist/types/markdown/types.d.ts +44 -24
- package/dist/types/markdown/types.d.ts.map +1 -1
- package/dist/types/markdown/utils.d.ts +3 -4
- package/dist/types/markdown/utils.d.ts.map +1 -1
- package/dist/types/messageFormat/ICU.d.ts +2 -3
- package/dist/types/messageFormat/ICU.d.ts.map +1 -1
- package/dist/types/messageFormat/i18next.d.ts +2 -3
- package/dist/types/messageFormat/i18next.d.ts.map +1 -1
- package/dist/types/messageFormat/index.d.ts +2 -1
- package/dist/types/messageFormat/navigatePath.d.ts +22 -0
- package/dist/types/messageFormat/navigatePath.d.ts.map +1 -0
- package/dist/types/messageFormat/po.d.ts +2 -3
- package/dist/types/messageFormat/po.d.ts.map +1 -1
- package/dist/types/messageFormat/resolveMessage.d.ts +0 -1
- package/dist/types/messageFormat/resolveMessage.d.ts.map +1 -1
- package/dist/types/messageFormat/verify-icu-format.d.ts +1 -1
- package/dist/types/messageFormat/vue-i18n.d.ts +2 -3
- package/dist/types/messageFormat/vue-i18n.d.ts.map +1 -1
- package/dist/types/transpiler/condition/condition.d.ts +0 -1
- package/dist/types/transpiler/condition/condition.d.ts.map +1 -1
- package/dist/types/transpiler/enumeration/enumeration.d.ts +0 -1
- package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
- package/dist/types/transpiler/file/file.d.ts +0 -1
- package/dist/types/transpiler/file/file.d.ts.map +1 -1
- package/dist/types/transpiler/file/fileBrowser.d.ts +0 -1
- package/dist/types/transpiler/file/fileBrowser.d.ts.map +1 -1
- package/dist/types/transpiler/gender/gender.d.ts +0 -1
- package/dist/types/transpiler/gender/gender.d.ts.map +1 -1
- package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts.map +1 -1
- package/dist/types/transpiler/html/html.d.ts +0 -1
- package/dist/types/transpiler/html/html.d.ts.map +1 -1
- package/dist/types/transpiler/html/htmlTags.d.ts +1 -1
- package/dist/types/transpiler/html/htmlTags.d.ts.map +1 -1
- package/dist/types/transpiler/html/validateHTML.d.ts.map +1 -1
- package/dist/types/transpiler/index.d.ts +11 -1
- package/dist/types/transpiler/insertion/getInsertionValues.d.ts.map +1 -1
- package/dist/types/transpiler/insertion/insertion.d.ts +0 -1
- package/dist/types/transpiler/insertion/insertion.d.ts.map +1 -1
- package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts.map +1 -1
- package/dist/types/transpiler/markdown/index.d.ts +1 -1
- package/dist/types/transpiler/markdown/markdown.d.ts +0 -1
- package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -1
- package/dist/types/transpiler/markdown/validateMarkdown.d.ts +0 -1
- package/dist/types/transpiler/markdown/validateMarkdown.d.ts.map +1 -1
- package/dist/types/transpiler/nesting/nesting.d.ts +4 -4
- package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -1
- package/dist/types/transpiler/plural/plural.d.ts +0 -1
- package/dist/types/transpiler/plural/plural.d.ts.map +1 -1
- package/dist/types/transpiler/translation/translation.d.ts +0 -1
- package/dist/types/transpiler/translation/translation.d.ts.map +1 -1
- package/dist/types/utils/checkIsURLAbsolute.d.ts.map +1 -1
- package/dist/types/utils/cookieExpiry.d.ts +1 -2
- package/dist/types/utils/cookieExpiry.d.ts.map +1 -1
- package/dist/types/utils/getCookie.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -2
- package/dist/types/utils/intl.d.ts +49 -5
- package/dist/types/utils/intl.d.ts.map +1 -1
- package/dist/types/utils/isSameKeyPath.d.ts +0 -1
- package/dist/types/utils/isSameKeyPath.d.ts.map +1 -1
- package/dist/types/utils/isValidReactElement.d.ts.map +1 -1
- package/dist/types/utils/localeStorage.d.ts +1 -2
- package/dist/types/utils/localeStorage.d.ts.map +1 -1
- package/dist/types/utils/parseYaml.d.ts.map +1 -1
- package/dist/types/utils/stringifyYaml.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNodeType.cjs","names":["NodeTypes","isValidElement"],"sources":["../../../src/dictionaryManipulator/getNodeType.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { isValidElement } from '../utils/isValidReactElement';\n\n/**\n * Type guard to check if content is a TypedNode\n */\nconst isTypedNode = (content: unknown): content is TypedNode => {\n return (\n typeof content === 'object' &&\n content !== null &&\n 'nodeType' in content &&\n typeof (content as TypedNode).nodeType === 'string'\n );\n};\n\n/**\n * Type guard to check if content is a valid NodeType\n */\nconst isValidNodeType = (nodeType: string): nodeType is NodeType => {\n return [\n NodeTypes.TRANSLATION,\n NodeTypes.ENUMERATION,\n NodeTypes.PLURAL,\n NodeTypes.CONDITION,\n NodeTypes.INSERTION,\n NodeTypes.FILE,\n NodeTypes.OBJECT,\n NodeTypes.ARRAY,\n NodeTypes.NESTED,\n NodeTypes.REACT_NODE,\n NodeTypes.MARKDOWN,\n NodeTypes.HTML,\n NodeTypes.TEXT,\n NodeTypes.NUMBER,\n NodeTypes.BOOLEAN,\n NodeTypes.GENDER,\n NodeTypes.NULL,\n NodeTypes.UNKNOWN,\n ].includes(nodeType as NodeType);\n};\n\nexport const getNodeType = (content: ContentNode): NodeType => {\n if (typeof content === 'string') {\n return NodeTypes.TEXT;\n }\n\n if (isTypedNode(content)) {\n const nodeType = content.nodeType;\n if (isValidNodeType(nodeType)) {\n return nodeType;\n }\n // Fallback for unknown node types\n return NodeTypes.UNKNOWN;\n }\n\n if (Array.isArray(content)) {\n return NodeTypes.ARRAY;\n }\n\n if (isValidElement(content)) {\n return NodeTypes.REACT_NODE;\n }\n\n if (typeof content === 'number') {\n return NodeTypes.NUMBER;\n }\n\n if (typeof content === 'boolean') {\n return NodeTypes.BOOLEAN;\n }\n\n if (content && typeof content === 'object') {\n return NodeTypes.OBJECT;\n }\n\n if (content === null) {\n return NodeTypes.NULL;\n }\n\n return NodeTypes.UNKNOWN;\n};\n"],"mappings":";;;;;;;;;;AASA,MAAM,eAAe,YAA2C;
|
|
1
|
+
{"version":3,"file":"getNodeType.cjs","names":["NodeTypes","isValidElement"],"sources":["../../../src/dictionaryManipulator/getNodeType.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';\n\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { isValidElement } from '../utils/isValidReactElement';\n\n/**\n * Type guard to check if content is a TypedNode\n */\nconst isTypedNode = (content: unknown): content is TypedNode => {\n return (\n typeof content === 'object' &&\n content !== null &&\n 'nodeType' in content &&\n typeof (content as TypedNode).nodeType === 'string'\n );\n};\n\n/**\n * Type guard to check if content is a valid NodeType\n */\nconst isValidNodeType = (nodeType: string): nodeType is NodeType => {\n return [\n NodeTypes.TRANSLATION,\n NodeTypes.ENUMERATION,\n NodeTypes.PLURAL,\n NodeTypes.CONDITION,\n NodeTypes.INSERTION,\n NodeTypes.FILE,\n NodeTypes.OBJECT,\n NodeTypes.ARRAY,\n NodeTypes.NESTED,\n NodeTypes.REACT_NODE,\n NodeTypes.MARKDOWN,\n NodeTypes.HTML,\n NodeTypes.TEXT,\n NodeTypes.NUMBER,\n NodeTypes.BOOLEAN,\n NodeTypes.GENDER,\n NodeTypes.NULL,\n NodeTypes.UNKNOWN,\n ].includes(nodeType as NodeType);\n};\n\nexport const getNodeType = (content: ContentNode): NodeType => {\n if (typeof content === 'string') {\n return NodeTypes.TEXT;\n }\n\n if (isTypedNode(content)) {\n const nodeType = content.nodeType;\n if (isValidNodeType(nodeType)) {\n return nodeType;\n }\n // Fallback for unknown node types\n return NodeTypes.UNKNOWN;\n }\n\n if (Array.isArray(content)) {\n return NodeTypes.ARRAY;\n }\n\n if (isValidElement(content)) {\n return NodeTypes.REACT_NODE;\n }\n\n if (typeof content === 'number') {\n return NodeTypes.NUMBER;\n }\n\n if (typeof content === 'boolean') {\n return NodeTypes.BOOLEAN;\n }\n\n if (content && typeof content === 'object') {\n return NodeTypes.OBJECT;\n }\n\n if (content === null) {\n return NodeTypes.NULL;\n }\n\n return NodeTypes.UNKNOWN;\n};\n"],"mappings":";;;;;;;;;;AASA,MAAM,eAAe,YAA2C;CAC9D,OACE,OAAO,YAAY,YACnB,YAAY,QACZ,cAAc,WACd,OAAQ,QAAsB,aAAa;AAE/C;;;;AAKA,MAAM,mBAAmB,aAA2C;CAClE,OAAO;EACLA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;EACVA,yBAAU;CACZ,CAAC,CAAC,SAAS,QAAoB;AACjC;AAEA,MAAa,eAAe,YAAmC;CAC7D,IAAI,OAAO,YAAY,UACrB,OAAOA,yBAAU;CAGnB,IAAI,YAAY,OAAO,GAAG;EACxB,MAAM,WAAW,QAAQ;EACzB,IAAI,gBAAgB,QAAQ,GAC1B,OAAO;EAGT,OAAOA,yBAAU;CACnB;CAEA,IAAI,MAAM,QAAQ,OAAO,GACvB,OAAOA,yBAAU;CAGnB,IAAIC,iDAAe,OAAO,GACxB,OAAOD,yBAAU;CAGnB,IAAI,OAAO,YAAY,UACrB,OAAOA,yBAAU;CAGnB,IAAI,OAAO,YAAY,WACrB,OAAOA,yBAAU;CAGnB,IAAI,WAAW,OAAO,YAAY,UAChC,OAAOA,yBAAU;CAGnB,IAAI,YAAY,MACd,OAAOA,yBAAU;CAGnB,OAAOA,yBAAU;AACnB"}
|
|
@@ -20,14 +20,14 @@ exports.QUALIFIER_ORDER = require_dictionaryManipulator_qualifiedDictionary.QUAL
|
|
|
20
20
|
exports.editDictionaryByKeyPath = require_dictionaryManipulator_editDictionaryByKeyPath.editDictionaryByKeyPath;
|
|
21
21
|
exports.getContentNodeByKeyPath = require_dictionaryManipulator_getContentNodeByKeyPath.getContentNodeByKeyPath;
|
|
22
22
|
exports.getDefaultNode = require_dictionaryManipulator_getDefaultNode.getDefaultNode;
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.getDictionaryQualifierSegments = require_dictionaryManipulator_qualifiedDictionary.getDictionaryQualifierSegments;
|
|
23
|
+
exports.getDictionaryCompositeIds = require_dictionaryManipulator_qualifiedDictionary.getDictionaryCompositeIds;
|
|
24
|
+
exports.getDictionaryQualifierIds = require_dictionaryManipulator_qualifiedDictionary.getDictionaryQualifierIds;
|
|
26
25
|
exports.getDictionaryQualifierTypes = require_dictionaryManipulator_qualifiedDictionary.getDictionaryQualifierTypes;
|
|
27
26
|
exports.getDictionarySelectorCacheKey = require_dictionaryManipulator_qualifiedDictionary.getDictionarySelectorCacheKey;
|
|
28
27
|
exports.getEmptyNode = require_dictionaryManipulator_getEmptyNode.getEmptyNode;
|
|
29
28
|
exports.getNodeChildren = require_dictionaryManipulator_getNodeChildren.getNodeChildren;
|
|
30
29
|
exports.getNodeType = require_dictionaryManipulator_getNodeType.getNodeType;
|
|
30
|
+
exports.getVariantIds = require_dictionaryManipulator_qualifiedDictionary.getVariantIds;
|
|
31
31
|
exports.isQualifiedDictionaryGroup = require_dictionaryManipulator_qualifiedDictionary.isQualifiedDictionaryGroup;
|
|
32
32
|
exports.isQualifiedDynamicLoaderMap = require_dictionaryManipulator_qualifiedDictionary.isQualifiedDynamicLoaderMap;
|
|
33
33
|
exports.mergeDictionaries = require_dictionaryManipulator_mergeDictionaries.mergeDictionaries;
|
|
@@ -42,4 +42,5 @@ exports.renameContentNodeByKeyPath = require_dictionaryManipulator_renameContent
|
|
|
42
42
|
exports.resolveQualifiedDictionary = require_dictionaryManipulator_qualifiedDictionary.resolveQualifiedDictionary;
|
|
43
43
|
exports.resolveQualifiedDynamicContent = require_dictionaryManipulator_qualifiedDictionary.resolveQualifiedDynamicContent;
|
|
44
44
|
exports.resolveQualifiedDynamicContentAsync = require_dictionaryManipulator_qualifiedDictionary.resolveQualifiedDynamicContentAsync;
|
|
45
|
+
exports.serializeVariant = require_dictionaryManipulator_qualifiedDictionary.serializeVariant;
|
|
45
46
|
exports.updateNodeChildren = require_dictionaryManipulator_updateNodeChildren.updateNodeChildren;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_deepTransformPlugins_getMultilingualDictionary = require('../deepTransformPlugins/getMultilingualDictionary.cjs');
|
|
4
3
|
const require_dictionaryManipulator_getNodeType = require('./getNodeType.cjs');
|
|
5
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
@@ -24,7 +23,7 @@ const customMerge = (destination, source) => {
|
|
|
24
23
|
if (Array.isArray(destination) && Array.isArray(source)) return arrayMerge(destination, source);
|
|
25
24
|
if (typeof destination === "object" && typeof source === "object") {
|
|
26
25
|
const result = {};
|
|
27
|
-
const allKeys = new Set([...Object.keys(destination), ...Object.keys(source)]);
|
|
26
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(destination), ...Object.keys(source)]);
|
|
28
27
|
for (const key of allKeys) result[key] = customMerge(destination[key], source[key]);
|
|
29
28
|
return result;
|
|
30
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeDictionaries.cjs","names":["getNodeType","getMultilingualDictionary"],"sources":["../../../src/dictionaryManipulator/mergeDictionaries.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport { getMultilingualDictionary } from '../deepTransformPlugins';\nimport { getNodeType } from './getNodeType';\n\n// Extended type that includes arrays for internal merge operations\ntype MergeableContent = ContentNode | ContentNode[];\n\nconst checkTypesMatch = (\n object1: ContentNode,\n object2: ContentNode,\n object2LocalId: LocalDictionaryId | undefined,\n dictionaryKey: string,\n path: string[] = []\n): void => {\n const appLogger = getAppLogger({ log });\n\n // If either side is missing/undefined, allow merge without error\n if (\n object1 === undefined ||\n object1 === null ||\n object2 === undefined ||\n object2 === null\n )\n return;\n\n const type1 = getNodeType(object1);\n const type2 = getNodeType(object2);\n\n // Unknown types are treated as flexible; skip strict mismatch reporting\n if (type1 === 'unknown' || type2 === 'unknown') return;\n\n if (type1 !== type2) {\n appLogger(\n [\n `Error: Dictionary ${colorizeKey(dictionaryKey)} has a multiple content files with type mismatch at path \"${path.join('.')}\": Cannot merge ${type1} with ${type2} while merging ${object2LocalId}`,\n ],\n {\n level: 'error',\n }\n );\n\n return;\n }\n};\n\n// Custom merge function that prefers destination (first dictionary) values\nconst customMerge = (\n destination: ContentNode,\n source: ContentNode\n): MergeableContent => {\n // If destination is undefined/null, use source\n if (destination === undefined || destination === null) {\n return source;\n }\n\n // If source is undefined/null, use destination\n if (source === undefined || source === null) {\n return destination;\n }\n\n // For primitive values, prefer destination (first dictionary)\n if (typeof destination !== 'object' || typeof source !== 'object') {\n return destination;\n }\n\n // For arrays, use our custom array merge\n if (Array.isArray(destination) && Array.isArray(source)) {\n return arrayMerge(\n destination as ContentNode[],\n source as ContentNode[]\n ) as MergeableContent;\n }\n\n // For objects, recursively merge with our custom logic\n if (typeof destination === 'object' && typeof source === 'object') {\n const result: Record<string, MergeableContent> = {};\n const allKeys = new Set([\n ...Object.keys(destination as unknown as Record<string, ContentNode>),\n ...Object.keys(source as unknown as Record<string, ContentNode>),\n ]);\n\n for (const key of allKeys) {\n result[key] = customMerge(\n (destination as unknown as Record<string, ContentNode>)[key],\n (source as unknown as Record<string, ContentNode>)[key]\n );\n }\n\n return result as unknown as MergeableContent;\n }\n\n // Fallback to destination\n return destination;\n};\n\n// Custom array merge strategy that merges arrays by key when present, otherwise by index\nconst arrayMerge = (\n destinationArray: ContentNode[],\n sourceArray: ContentNode[]\n): MergeableContent[] => {\n // Check if both arrays contain only primitives\n const destHasOnlyPrimitives = destinationArray.every(\n (item) => typeof item !== 'object' || item === null\n );\n const sourceHasOnlyPrimitives = sourceArray.every(\n (item) => typeof item !== 'object' || item === null\n );\n\n // If both arrays contain only primitives, use the source array (second dictionary)\n if (destHasOnlyPrimitives && sourceHasOnlyPrimitives) {\n return sourceArray;\n }\n\n // Otherwise, merge by index with object merging logic\n const result: MergeableContent[] = [];\n const maxLength = Math.max(destinationArray.length, sourceArray.length);\n\n for (let i = 0; i < maxLength; i++) {\n const destItem = destinationArray[i];\n const sourceItem = sourceArray[i];\n\n if (destItem === undefined && sourceItem === undefined) {\n } else if (destItem === undefined) {\n // Only source exists, add it\n result.push(sourceItem);\n } else if (sourceItem === undefined) {\n // Only destination exists, add it\n result.push(destItem);\n } else {\n // Both exist, merge them\n if (\n typeof destItem === 'object' &&\n typeof sourceItem === 'object' &&\n destItem !== null &&\n sourceItem !== null\n ) {\n // Check if both objects have a 'key' property for keyed merging\n if (\n 'key' in destItem &&\n 'key' in sourceItem &&\n (destItem as Record<string, string>).key ===\n (sourceItem as Record<string, string>).key\n ) {\n // Merge objects with same key, preferring destination (first dictionary) values\n result.push(customMerge(destItem, sourceItem));\n } else {\n // Merge objects by index, preferring destination (first dictionary) values\n result.push(customMerge(destItem, sourceItem));\n }\n } else {\n // For primitives or non-objects, use destination value (first dictionary)\n result.push(destItem);\n }\n }\n }\n\n return result;\n};\n\nexport const mergeDictionaries = (dictionaries: Dictionary[]): Dictionary => {\n const localIds = Array.from(\n new Set<LocalDictionaryId>(\n dictionaries.filter((dict) => dict.localId).map((dict) => dict.localId!)\n )\n );\n\n if (!dictionaries[0] || dictionaries.length <= 1) {\n return dictionaries[0]!;\n }\n\n const dictionariesKeys = dictionaries.map((dict) => dict.key);\n\n // Check if all dictionaries have the same key\n if (new Set(dictionariesKeys).size !== 1) {\n throw new Error('All dictionaries must have the same key');\n }\n\n let mergedContent: Dictionary['content'] = dictionaries[0].content;\n\n for (let i = 1; i < dictionaries.length; i++) {\n const dict = dictionaries[i];\n\n if (!dict) continue;\n\n // If the dictionary is a per-locale dictionary, transform it to a partial multilingual dictionary\n const currentDictionary = getMultilingualDictionary(dict);\n\n // Check types before merging\n checkTypesMatch(\n mergedContent,\n currentDictionary.content,\n currentDictionary.localId,\n currentDictionary.key,\n []\n );\n\n mergedContent = customMerge(\n mergedContent,\n currentDictionary.content\n ) as ContentNode;\n }\n\n const mergedDictionary: Dictionary = {\n key: dictionaries[0].key,\n content: mergedContent,\n localIds,\n };\n\n return mergedDictionary;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mergeDictionaries.cjs","names":["getNodeType","getMultilingualDictionary"],"sources":["../../../src/dictionaryManipulator/mergeDictionaries.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types/dictionary';\nimport { getMultilingualDictionary } from '../deepTransformPlugins';\nimport { getNodeType } from './getNodeType';\n\n// Extended type that includes arrays for internal merge operations\ntype MergeableContent = ContentNode | ContentNode[];\n\nconst checkTypesMatch = (\n object1: ContentNode,\n object2: ContentNode,\n object2LocalId: LocalDictionaryId | undefined,\n dictionaryKey: string,\n path: string[] = []\n): void => {\n const appLogger = getAppLogger({ log });\n\n // If either side is missing/undefined, allow merge without error\n if (\n object1 === undefined ||\n object1 === null ||\n object2 === undefined ||\n object2 === null\n )\n return;\n\n const type1 = getNodeType(object1);\n const type2 = getNodeType(object2);\n\n // Unknown types are treated as flexible; skip strict mismatch reporting\n if (type1 === 'unknown' || type2 === 'unknown') return;\n\n if (type1 !== type2) {\n appLogger(\n [\n `Error: Dictionary ${colorizeKey(dictionaryKey)} has a multiple content files with type mismatch at path \"${path.join('.')}\": Cannot merge ${type1} with ${type2} while merging ${object2LocalId}`,\n ],\n {\n level: 'error',\n }\n );\n\n return;\n }\n};\n\n// Custom merge function that prefers destination (first dictionary) values\nconst customMerge = (\n destination: ContentNode,\n source: ContentNode\n): MergeableContent => {\n // If destination is undefined/null, use source\n if (destination === undefined || destination === null) {\n return source;\n }\n\n // If source is undefined/null, use destination\n if (source === undefined || source === null) {\n return destination;\n }\n\n // For primitive values, prefer destination (first dictionary)\n if (typeof destination !== 'object' || typeof source !== 'object') {\n return destination;\n }\n\n // For arrays, use our custom array merge\n if (Array.isArray(destination) && Array.isArray(source)) {\n return arrayMerge(\n destination as ContentNode[],\n source as ContentNode[]\n ) as MergeableContent;\n }\n\n // For objects, recursively merge with our custom logic\n if (typeof destination === 'object' && typeof source === 'object') {\n const result: Record<string, MergeableContent> = {};\n const allKeys = new Set([\n ...Object.keys(destination as unknown as Record<string, ContentNode>),\n ...Object.keys(source as unknown as Record<string, ContentNode>),\n ]);\n\n for (const key of allKeys) {\n result[key] = customMerge(\n (destination as unknown as Record<string, ContentNode>)[key],\n (source as unknown as Record<string, ContentNode>)[key]\n );\n }\n\n return result as unknown as MergeableContent;\n }\n\n // Fallback to destination\n return destination;\n};\n\n// Custom array merge strategy that merges arrays by key when present, otherwise by index\nconst arrayMerge = (\n destinationArray: ContentNode[],\n sourceArray: ContentNode[]\n): MergeableContent[] => {\n // Check if both arrays contain only primitives\n const destHasOnlyPrimitives = destinationArray.every(\n (item) => typeof item !== 'object' || item === null\n );\n const sourceHasOnlyPrimitives = sourceArray.every(\n (item) => typeof item !== 'object' || item === null\n );\n\n // If both arrays contain only primitives, use the source array (second dictionary)\n if (destHasOnlyPrimitives && sourceHasOnlyPrimitives) {\n return sourceArray;\n }\n\n // Otherwise, merge by index with object merging logic\n const result: MergeableContent[] = [];\n const maxLength = Math.max(destinationArray.length, sourceArray.length);\n\n for (let i = 0; i < maxLength; i++) {\n const destItem = destinationArray[i];\n const sourceItem = sourceArray[i];\n\n if (destItem === undefined && sourceItem === undefined) {\n } else if (destItem === undefined) {\n // Only source exists, add it\n result.push(sourceItem);\n } else if (sourceItem === undefined) {\n // Only destination exists, add it\n result.push(destItem);\n } else {\n // Both exist, merge them\n if (\n typeof destItem === 'object' &&\n typeof sourceItem === 'object' &&\n destItem !== null &&\n sourceItem !== null\n ) {\n // Check if both objects have a 'key' property for keyed merging\n if (\n 'key' in destItem &&\n 'key' in sourceItem &&\n (destItem as Record<string, string>).key ===\n (sourceItem as Record<string, string>).key\n ) {\n // Merge objects with same key, preferring destination (first dictionary) values\n result.push(customMerge(destItem, sourceItem));\n } else {\n // Merge objects by index, preferring destination (first dictionary) values\n result.push(customMerge(destItem, sourceItem));\n }\n } else {\n // For primitives or non-objects, use destination value (first dictionary)\n result.push(destItem);\n }\n }\n }\n\n return result;\n};\n\nexport const mergeDictionaries = (dictionaries: Dictionary[]): Dictionary => {\n const localIds = Array.from(\n new Set<LocalDictionaryId>(\n dictionaries.filter((dict) => dict.localId).map((dict) => dict.localId!)\n )\n );\n\n if (!dictionaries[0] || dictionaries.length <= 1) {\n return dictionaries[0]!;\n }\n\n const dictionariesKeys = dictionaries.map((dict) => dict.key);\n\n // Check if all dictionaries have the same key\n if (new Set(dictionariesKeys).size !== 1) {\n throw new Error('All dictionaries must have the same key');\n }\n\n let mergedContent: Dictionary['content'] = dictionaries[0].content;\n\n for (let i = 1; i < dictionaries.length; i++) {\n const dict = dictionaries[i];\n\n if (!dict) continue;\n\n // If the dictionary is a per-locale dictionary, transform it to a partial multilingual dictionary\n const currentDictionary = getMultilingualDictionary(dict);\n\n // Check types before merging\n checkTypesMatch(\n mergedContent,\n currentDictionary.content,\n currentDictionary.localId,\n currentDictionary.key,\n []\n );\n\n mergedContent = customMerge(\n mergedContent,\n currentDictionary.content\n ) as ContentNode;\n }\n\n const mergedDictionary: Dictionary = {\n key: dictionaries[0].key,\n content: mergedContent,\n localIds,\n };\n\n return mergedDictionary;\n};\n"],"mappings":";;;;;;;AAaA,MAAM,mBACJ,SACA,SACA,gBACA,eACA,OAAiB,CAAC,MACT;CACT,MAAM,sDAAyB,EAAE,gCAAI,CAAC;CAGtC,IACE,YAAY,UACZ,YAAY,QACZ,YAAY,UACZ,YAAY,MAEZ;CAEF,MAAM,QAAQA,sDAAY,OAAO;CACjC,MAAM,QAAQA,sDAAY,OAAO;CAGjC,IAAI,UAAU,aAAa,UAAU,WAAW;CAEhD,IAAI,UAAU,OAAO;EACnB,UACE,CACE,8DAAiC,aAAa,EAAE,4DAA4D,KAAK,KAAK,GAAG,EAAE,kBAAkB,MAAM,QAAQ,MAAM,iBAAiB,gBACpL,GACA,EACE,OAAO,QACT,CACF;EAEA;CACF;AACF;AAGA,MAAM,eACJ,aACA,WACqB;CAErB,IAAI,gBAAgB,UAAa,gBAAgB,MAC/C,OAAO;CAIT,IAAI,WAAW,UAAa,WAAW,MACrC,OAAO;CAIT,IAAI,OAAO,gBAAgB,YAAY,OAAO,WAAW,UACvD,OAAO;CAIT,IAAI,MAAM,QAAQ,WAAW,KAAK,MAAM,QAAQ,MAAM,GACpD,OAAO,WACL,aACA,MACF;CAIF,IAAI,OAAO,gBAAgB,YAAY,OAAO,WAAW,UAAU;EACjE,MAAM,SAA2C,CAAC;EAClD,MAAM,0BAAU,IAAI,IAAI,CACtB,GAAG,OAAO,KAAK,WAAqD,GACpE,GAAG,OAAO,KAAK,MAAgD,CACjE,CAAC;EAED,KAAK,MAAM,OAAO,SAChB,OAAO,OAAO,YACX,YAAuD,MACvD,OAAkD,IACrD;EAGF,OAAO;CACT;CAGA,OAAO;AACT;AAGA,MAAM,cACJ,kBACA,gBACuB;CAEvB,MAAM,wBAAwB,iBAAiB,OAC5C,SAAS,OAAO,SAAS,YAAY,SAAS,IACjD;CACA,MAAM,0BAA0B,YAAY,OACzC,SAAS,OAAO,SAAS,YAAY,SAAS,IACjD;CAGA,IAAI,yBAAyB,yBAC3B,OAAO;CAIT,MAAM,SAA6B,CAAC;CACpC,MAAM,YAAY,KAAK,IAAI,iBAAiB,QAAQ,YAAY,MAAM;CAEtE,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,KAAK;EAClC,MAAM,WAAW,iBAAiB;EAClC,MAAM,aAAa,YAAY;EAE/B,IAAI,aAAa,UAAa,eAAe,QAAW,CACxD,OAAO,IAAI,aAAa,QAEtB,OAAO,KAAK,UAAU;OACjB,IAAI,eAAe,QAExB,OAAO,KAAK,QAAQ;OAGpB,IACE,OAAO,aAAa,YACpB,OAAO,eAAe,YACtB,aAAa,QACb,eAAe,MAGf,IACE,SAAS,YACT,SAAS,cACR,SAAoC,QAClC,WAAsC,KAGzC,OAAO,KAAK,YAAY,UAAU,UAAU,CAAC;OAG7C,OAAO,KAAK,YAAY,UAAU,UAAU,CAAC;OAI/C,OAAO,KAAK,QAAQ;CAG1B;CAEA,OAAO;AACT;AAEA,MAAa,qBAAqB,iBAA2C;CAC3E,MAAM,WAAW,MAAM,KACrB,IAAI,IACF,aAAa,QAAQ,SAAS,KAAK,OAAO,CAAC,CAAC,KAAK,SAAS,KAAK,OAAQ,CACzE,CACF;CAEA,IAAI,CAAC,aAAa,MAAM,aAAa,UAAU,GAC7C,OAAO,aAAa;CAGtB,MAAM,mBAAmB,aAAa,KAAK,SAAS,KAAK,GAAG;CAG5D,IAAI,IAAI,IAAI,gBAAgB,CAAC,CAAC,SAAS,GACrC,MAAM,IAAI,MAAM,yCAAyC;CAG3D,IAAI,gBAAuC,aAAa,EAAE,CAAC;CAE3D,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAC5C,MAAM,OAAO,aAAa;EAE1B,IAAI,CAAC,MAAM;EAGX,MAAM,oBAAoBC,iFAA0B,IAAI;EAGxD,gBACE,eACA,kBAAkB,SAClB,kBAAkB,SAClB,kBAAkB,KAClB,CAAC,CACH;EAEA,gBAAgB,YACd,eACA,kBAAkB,OACpB;CACF;CAQA,OAAO;EALL,KAAK,aAAa,EAAE,CAAC;EACrB,SAAS;EACT;CAGoB;AACxB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_dictionaryManipulator_qualifiedDictionary = require('./qualifiedDictionary.cjs');
|
|
4
3
|
const require_dictionaryManipulator_mergeDictionaries = require('./mergeDictionaries.cjs');
|
|
5
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
@@ -13,7 +12,7 @@ let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
|
13
12
|
* `mergeDictionaries` (single merged dictionary).
|
|
14
13
|
* - At least one dictionary declares a qualifier → the group's dimension set is
|
|
15
14
|
* the union of every declared dimension (in canonical order
|
|
16
|
-
* `variant →
|
|
15
|
+
* `variant → item`). Dictionaries are grouped by their composite id
|
|
17
16
|
* (one segment per dimension), merged within each group (locale completion /
|
|
18
17
|
* priority overrides preserved), and a `QualifiedDictionaryGroup` is returned.
|
|
19
18
|
* Unqualified siblings act as shared base content merged into every entry.
|
|
@@ -31,27 +30,26 @@ const mergeQualifiedDictionaries = (dictionaries) => {
|
|
|
31
30
|
const baseDictionaries = [];
|
|
32
31
|
const entriesDictionaries = /* @__PURE__ */ new Map();
|
|
33
32
|
dictionaries.forEach((dictionary, index) => {
|
|
34
|
-
if (perDictionaryTypes[index]
|
|
33
|
+
if (perDictionaryTypes[index]?.length === 0) {
|
|
35
34
|
baseDictionaries.push(dictionary);
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
37
|
+
const compositeIds = require_dictionaryManipulator_qualifiedDictionary.getDictionaryCompositeIds(dictionary, groupQualifierTypes);
|
|
38
|
+
if (compositeIds === void 0) {
|
|
40
39
|
appLogger(`Dictionary ${(0, _intlayer_config_logger.colorizeKey)(dictionary.key)} declares (${perDictionaryTypes[index].join(", ")}) but the key's dimensions are (${groupQualifierTypes.join(", ")}); every entry must declare all of them. Entry ignored${dictionary.filePath ? ` - ${dictionary.filePath}` : ""}.`, { level: "error" });
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
for (const compositeId of compositeIds) {
|
|
43
|
+
const existingEntries = entriesDictionaries.get(compositeId) ?? [];
|
|
44
|
+
existingEntries.push(dictionary);
|
|
45
|
+
entriesDictionaries.set(compositeId, existingEntries);
|
|
46
|
+
}
|
|
46
47
|
});
|
|
47
48
|
const content = {};
|
|
48
|
-
const metaByCompositeId = {};
|
|
49
|
-
const declaresMeta = groupQualifierTypes.includes("meta");
|
|
50
49
|
let importMode;
|
|
51
50
|
for (const [compositeId, qualifiedDictionaries] of entriesDictionaries) {
|
|
52
51
|
content[compositeId] = require_dictionaryManipulator_mergeDictionaries.mergeDictionaries([...qualifiedDictionaries, ...baseDictionaries]).content;
|
|
53
52
|
const [firstQualified] = qualifiedDictionaries;
|
|
54
|
-
if (declaresMeta && firstQualified?.meta !== void 0) metaByCompositeId[compositeId] = firstQualified.meta;
|
|
55
53
|
importMode ??= firstQualified?.importMode;
|
|
56
54
|
}
|
|
57
55
|
const localIds = Array.from(new Set(dictionaries.filter((dictionary) => dictionary.localId).map((dictionary) => dictionary.localId)));
|
|
@@ -59,7 +57,6 @@ const mergeQualifiedDictionaries = (dictionaries) => {
|
|
|
59
57
|
key: dictionaries[0].key,
|
|
60
58
|
qualifierTypes: groupQualifierTypes,
|
|
61
59
|
content,
|
|
62
|
-
...declaresMeta && { meta: metaByCompositeId },
|
|
63
60
|
...importMode !== void 0 && { importMode },
|
|
64
61
|
localIds
|
|
65
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeQualifiedDictionaries.cjs","names":["getDictionaryQualifierTypes","QUALIFIER_ORDER","mergeDictionaries","
|
|
1
|
+
{"version":3,"file":"mergeQualifiedDictionaries.cjs","names":["getDictionaryQualifierTypes","QUALIFIER_ORDER","mergeDictionaries","getDictionaryCompositeIds"],"sources":["../../../src/dictionaryManipulator/mergeQualifiedDictionaries.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport type {\n Dictionary,\n DictionaryQualifierType,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport { mergeDictionaries } from './mergeDictionaries';\nimport {\n getDictionaryCompositeIds,\n getDictionaryQualifierTypes,\n QUALIFIER_ORDER,\n} from './qualifiedDictionary';\n\n/**\n * Merges sibling dictionaries sharing the same key, honouring qualifiers.\n *\n * - No dictionary declares a qualifier → behaves exactly like\n * `mergeDictionaries` (single merged dictionary).\n * - At least one dictionary declares a qualifier → the group's dimension set is\n * the union of every declared dimension (in canonical order\n * `variant → item`). Dictionaries are grouped by their composite id\n * (one segment per dimension), merged within each group (locale completion /\n * priority overrides preserved), and a `QualifiedDictionaryGroup` is returned.\n * Unqualified siblings act as shared base content merged into every entry.\n *\n * Every qualified entry must declare ALL dimensions of the group; an entry that\n * declares only a subset is ambiguous and is rejected with an error log.\n */\nexport const mergeQualifiedDictionaries = (\n dictionaries: Dictionary[]\n): Dictionary | QualifiedDictionaryGroup => {\n const perDictionaryTypes = dictionaries.map(getDictionaryQualifierTypes);\n\n const declaredDimensions = new Set<DictionaryQualifierType>();\n for (const types of perDictionaryTypes) {\n for (const type of types) declaredDimensions.add(type);\n }\n\n // Canonical order, restricted to the dimensions actually declared.\n const groupQualifierTypes = QUALIFIER_ORDER.filter((qualifierType) =>\n declaredDimensions.has(qualifierType)\n );\n\n if (groupQualifierTypes.length === 0) {\n return mergeDictionaries(dictionaries);\n }\n\n const appLogger = getAppLogger({ log });\n\n const baseDictionaries: Dictionary[] = [];\n const entriesDictionaries = new Map<string, Dictionary[]>();\n\n dictionaries.forEach((dictionary, index) => {\n if (perDictionaryTypes[index]?.length === 0) {\n baseDictionaries.push(dictionary);\n return;\n }\n\n // A dictionary may map to several composite ids (array variant fan-out):\n // its content is registered under every id it lists.\n const compositeIds = getDictionaryCompositeIds(\n dictionary,\n groupQualifierTypes\n );\n\n if (compositeIds === undefined) {\n appLogger(\n `Dictionary ${colorizeKey(dictionary.key)} declares (${perDictionaryTypes[index].join(', ')}) but the key's dimensions are (${groupQualifierTypes.join(', ')}); every entry must declare all of them. Entry ignored${dictionary.filePath ? ` - ${dictionary.filePath}` : ''}.`,\n { level: 'error' }\n );\n return;\n }\n\n for (const compositeId of compositeIds) {\n const existingEntries = entriesDictionaries.get(compositeId) ?? [];\n existingEntries.push(dictionary);\n entriesDictionaries.set(compositeId, existingEntries);\n }\n });\n\n // `content` maps each composite id to its resolved content node directly; the\n // qualifier coordinates live in the key, not in a per-entry wrapper. For an\n // object variant the variant segment is the canonical serialization of the\n // object, so it fully identifies the entry — no side-map is needed.\n const content: Record<string, unknown> = {};\n\n let importMode: Dictionary['importMode'];\n\n for (const [compositeId, qualifiedDictionaries] of entriesDictionaries) {\n // Unqualified siblings act as shared base content: appended last so the\n // qualified entries take precedence (mergeDictionaries prefers first).\n const mergedEntry = mergeDictionaries([\n ...qualifiedDictionaries,\n ...baseDictionaries,\n ]);\n\n content[compositeId] = mergedEntry.content;\n\n const [firstQualified] = qualifiedDictionaries;\n\n importMode ??= firstQualified?.importMode;\n }\n\n const localIds = Array.from(\n new Set(\n dictionaries\n .filter((dictionary) => dictionary.localId)\n .map((dictionary) => dictionary.localId!)\n )\n );\n\n return {\n key: dictionaries[0]!.key,\n qualifierTypes: groupQualifierTypes,\n content,\n ...(importMode !== undefined && { importMode }),\n localIds,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,8BACX,iBAC0C;CAC1C,MAAM,qBAAqB,aAAa,IAAIA,6EAA2B;CAEvE,MAAM,qCAAqB,IAAI,IAA6B;CAC5D,KAAK,MAAM,SAAS,oBAClB,KAAK,MAAM,QAAQ,OAAO,mBAAmB,IAAI,IAAI;CAIvD,MAAM,sBAAsBC,kEAAgB,QAAQ,kBAClD,mBAAmB,IAAI,aAAa,CACtC;CAEA,IAAI,oBAAoB,WAAW,GACjC,OAAOC,kEAAkB,YAAY;CAGvC,MAAM,sDAAyB,EAAE,gCAAI,CAAC;CAEtC,MAAM,mBAAiC,CAAC;CACxC,MAAM,sCAAsB,IAAI,IAA0B;CAE1D,aAAa,SAAS,YAAY,UAAU;EAC1C,IAAI,mBAAmB,MAAM,EAAE,WAAW,GAAG;GAC3C,iBAAiB,KAAK,UAAU;GAChC;EACF;EAIA,MAAM,eAAeC,4EACnB,YACA,mBACF;EAEA,IAAI,iBAAiB,QAAW;GAC9B,UACE,uDAA0B,WAAW,GAAG,EAAE,aAAa,mBAAmB,MAAM,CAAC,KAAK,IAAI,EAAE,kCAAkC,oBAAoB,KAAK,IAAI,EAAE,wDAAwD,WAAW,WAAW,MAAM,WAAW,aAAa,GAAG,IAC5Q,EAAE,OAAO,QAAQ,CACnB;GACA;EACF;EAEA,KAAK,MAAM,eAAe,cAAc;GACtC,MAAM,kBAAkB,oBAAoB,IAAI,WAAW,KAAK,CAAC;GACjE,gBAAgB,KAAK,UAAU;GAC/B,oBAAoB,IAAI,aAAa,eAAe;EACtD;CACF,CAAC;CAMD,MAAM,UAAmC,CAAC;CAE1C,IAAI;CAEJ,KAAK,MAAM,CAAC,aAAa,0BAA0B,qBAAqB;EAQtE,QAAQ,eALYD,kEAAkB,CACpC,GAAG,uBACH,GAAG,gBACL,CAEiC,CAAC,CAAC;EAEnC,MAAM,CAAC,kBAAkB;EAEzB,eAAe,gBAAgB;CACjC;CAEA,MAAM,WAAW,MAAM,KACrB,IAAI,IACF,aACG,QAAQ,eAAe,WAAW,OAAO,CAAC,CAC1C,KAAK,eAAe,WAAW,OAAQ,CAC5C,CACF;CAEA,OAAO;EACL,KAAK,aAAa,EAAE,CAAE;EACtB,gBAAgB;EAChB;EACA,GAAI,eAAe,UAAa,EAAE,WAAW;EAC7C;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeDictionary.cjs","names":["t","getPerLocaleDictionary","orderDictionaries"],"sources":["../../../src/dictionaryManipulator/normalizeDictionary.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getPerLocaleDictionary } from '../deepTransformPlugins';\nimport { t } from '../transpiler/translation';\nimport { orderDictionaries } from './orderDictionaries';\n\nexport const normalizeDictionary = (\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Dictionary => {\n const { locales } = configuration.internationalization;\n\n const parsedDictionary = JSON.parse(JSON.stringify(dictionary));\n\n // If the dictionary is a per-locale dictionary, transform it to a partial multilingual dictionary\n if (dictionary.locale) {\n return {\n ...dictionary,\n locale: undefined,\n content: t({\n [dictionary.locale]: dictionary.content,\n }),\n };\n }\n\n const perLocaleContent = locales.reduce(\n (acc, locale) => {\n const perLocaleDictionary = getPerLocaleDictionary(\n parsedDictionary,\n locale\n );\n\n acc[locale] = perLocaleDictionary.content;\n return acc;\n },\n {} as Record<Locale, Dictionary['content']>\n );\n\n return {\n ...dictionary,\n content: t(perLocaleContent),\n };\n};\n\nexport const normalizeDictionaries = (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Dictionary[] => {\n const orderedDictionaries = orderDictionaries(dictionaries, configuration);\n\n const structuredDictionaries = orderedDictionaries.map((dictionary) =>\n normalizeDictionary(dictionary, configuration)\n );\n\n return structuredDictionaries;\n};\n"],"mappings":";;;;;;AAOA,MAAa,uBACX,YACA,kBACe;CACf,MAAM,EAAE,YAAY,cAAc;CAElC,MAAM,mBAAmB,KAAK,MAAM,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"normalizeDictionary.cjs","names":["t","getPerLocaleDictionary","orderDictionaries"],"sources":["../../../src/dictionaryManipulator/normalizeDictionary.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getPerLocaleDictionary } from '../deepTransformPlugins';\nimport { t } from '../transpiler/translation';\nimport { orderDictionaries } from './orderDictionaries';\n\nexport const normalizeDictionary = (\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Dictionary => {\n const { locales } = configuration.internationalization;\n\n const parsedDictionary = JSON.parse(JSON.stringify(dictionary));\n\n // If the dictionary is a per-locale dictionary, transform it to a partial multilingual dictionary\n if (dictionary.locale) {\n return {\n ...dictionary,\n locale: undefined,\n content: t({\n [dictionary.locale]: dictionary.content,\n }),\n };\n }\n\n const perLocaleContent = locales.reduce(\n (acc, locale) => {\n const perLocaleDictionary = getPerLocaleDictionary(\n parsedDictionary,\n locale\n );\n\n acc[locale] = perLocaleDictionary.content;\n return acc;\n },\n {} as Record<Locale, Dictionary['content']>\n );\n\n return {\n ...dictionary,\n content: t(perLocaleContent),\n };\n};\n\nexport const normalizeDictionaries = (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Dictionary[] => {\n const orderedDictionaries = orderDictionaries(dictionaries, configuration);\n\n const structuredDictionaries = orderedDictionaries.map((dictionary) =>\n normalizeDictionary(dictionary, configuration)\n );\n\n return structuredDictionaries;\n};\n"],"mappings":";;;;;;AAOA,MAAa,uBACX,YACA,kBACe;CACf,MAAM,EAAE,YAAY,cAAc;CAElC,MAAM,mBAAmB,KAAK,MAAM,KAAK,UAAU,UAAU,CAAC;CAG9D,IAAI,WAAW,QACb,OAAO;EACL,GAAG;EACH,QAAQ;EACR,SAASA,6CAAE,GACR,WAAW,SAAS,WAAW,QAClC,CAAC;CACH;CAGF,MAAM,mBAAmB,QAAQ,QAC9B,KAAK,WAAW;EAMf,IAAI,UALwBC,wEAC1B,kBACA,MAG8B,CAAC,CAAC;EAClC,OAAO;CACT,GACA,CAAC,CACH;CAEA,OAAO;EACL,GAAG;EACH,SAASD,6CAAE,gBAAgB;CAC7B;AACF;AAEA,MAAa,yBACX,cACA,kBACiB;CAOjB,OAN4BE,kEAAkB,cAAc,aAEX,CAAC,CAAC,KAAK,eACtD,oBAAoB,YAAY,aAAa,CAGnB;AAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orderDictionaries.cjs","names":["editor"],"sources":["../../../src/dictionaryManipulator/orderDictionaries.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * Orders dictionaries based on the dictionary priority strategy.\n *\n * @param dictionaries - Array of dictionaries to order\n * @param priorityStrategy - The priority strategy ('local_first' or 'distant_first')\n * @returns Ordered array of dictionaries\n */\nexport const orderDictionaries = (\n dictionaries: Dictionary[],\n config?: {\n editor: {\n dictionaryPriorityStrategy: 'local_first' | 'distant_first';\n };\n }\n): Dictionary[] => {\n const dictionaryPriorityStrategy =\n config?.editor?.dictionaryPriorityStrategy ??\n editor.dictionaryPriorityStrategy;\n\n if (dictionaries.length <= 1) {\n return dictionaries;\n }\n\n // Stabilize original indices to preserve relative order for complete ties\n const withIndex = dictionaries.map((dictionary, index) => ({\n dictionary,\n index,\n }));\n\n const getPriority = (dictionary: Dictionary): number => {\n const p = dictionary.priority ?? 0;\n\n return Number.isFinite(p) ? p : 0;\n };\n\n const getLocationWeight = (d: Dictionary): number => {\n const location = d.location;\n\n // undefined location should always be last\n if (location === undefined) {\n return 2;\n }\n\n if (dictionaryPriorityStrategy === 'distant_first') {\n // distant should come first\n return location === 'remote' ? 0 : 1;\n }\n // default: local_first\n return location === 'local' ? 0 : 1;\n };\n\n withIndex.sort((a, b) => {\n // 1) Non-autoFilled before autoFilled (autoFilled have lower precedence)\n const aAuto = a.dictionary.filled ? 1 : 0;\n const bAuto = b.dictionary.filled ? 1 : 0;\n if (aAuto !== bAuto) return aAuto - bAuto; // 0 before 1\n\n // 2) Higher priority first (larger number wins)\n const aP = getPriority(a.dictionary);\n const bP = getPriority(b.dictionary);\n if (aP !== bP) return bP - aP; // descending\n\n // 3) Location according to strategy\n const aLocation = getLocationWeight(a.dictionary);\n const bLocation = getLocationWeight(b.dictionary);\n if (aLocation !== bLocation) return aLocation - bLocation;\n\n // 4) Stable fallback by original index\n return a.index - b.index;\n });\n\n return withIndex.map(({ dictionary }) => dictionary);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"orderDictionaries.cjs","names":["editor"],"sources":["../../../src/dictionaryManipulator/orderDictionaries.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\n\n/**\n * Orders dictionaries based on the dictionary priority strategy.\n *\n * @param dictionaries - Array of dictionaries to order\n * @param priorityStrategy - The priority strategy ('local_first' or 'distant_first')\n * @returns Ordered array of dictionaries\n */\nexport const orderDictionaries = (\n dictionaries: Dictionary[],\n config?: {\n editor: {\n dictionaryPriorityStrategy: 'local_first' | 'distant_first';\n };\n }\n): Dictionary[] => {\n const dictionaryPriorityStrategy =\n config?.editor?.dictionaryPriorityStrategy ??\n editor.dictionaryPriorityStrategy;\n\n if (dictionaries.length <= 1) {\n return dictionaries;\n }\n\n // Stabilize original indices to preserve relative order for complete ties\n const withIndex = dictionaries.map((dictionary, index) => ({\n dictionary,\n index,\n }));\n\n const getPriority = (dictionary: Dictionary): number => {\n const p = dictionary.priority ?? 0;\n\n return Number.isFinite(p) ? p : 0;\n };\n\n const getLocationWeight = (d: Dictionary): number => {\n const location = d.location;\n\n // undefined location should always be last\n if (location === undefined) {\n return 2;\n }\n\n if (dictionaryPriorityStrategy === 'distant_first') {\n // distant should come first\n return location === 'remote' ? 0 : 1;\n }\n // default: local_first\n return location === 'local' ? 0 : 1;\n };\n\n withIndex.sort((a, b) => {\n // 1) Non-autoFilled before autoFilled (autoFilled have lower precedence)\n const aAuto = a.dictionary.filled ? 1 : 0;\n const bAuto = b.dictionary.filled ? 1 : 0;\n if (aAuto !== bAuto) return aAuto - bAuto; // 0 before 1\n\n // 2) Higher priority first (larger number wins)\n const aP = getPriority(a.dictionary);\n const bP = getPriority(b.dictionary);\n if (aP !== bP) return bP - aP; // descending\n\n // 3) Location according to strategy\n const aLocation = getLocationWeight(a.dictionary);\n const bLocation = getLocationWeight(b.dictionary);\n if (aLocation !== bLocation) return aLocation - bLocation;\n\n // 4) Stable fallback by original index\n return a.index - b.index;\n });\n\n return withIndex.map(({ dictionary }) => dictionary);\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,qBACX,cACA,WAKiB;CACjB,MAAM,6BACJ,QAAQ,QAAQ,8BAChBA,8BAAO;CAET,IAAI,aAAa,UAAU,GACzB,OAAO;CAIT,MAAM,YAAY,aAAa,KAAK,YAAY,WAAW;EACzD;EACA;CACF,EAAE;CAEF,MAAM,eAAe,eAAmC;EACtD,MAAM,IAAI,WAAW,YAAY;EAEjC,OAAO,OAAO,SAAS,CAAC,IAAI,IAAI;CAClC;CAEA,MAAM,qBAAqB,MAA0B;EACnD,MAAM,WAAW,EAAE;EAGnB,IAAI,aAAa,QACf,OAAO;EAGT,IAAI,+BAA+B,iBAEjC,OAAO,aAAa,WAAW,IAAI;EAGrC,OAAO,aAAa,UAAU,IAAI;CACpC;CAEA,UAAU,MAAM,GAAG,MAAM;EAEvB,MAAM,QAAQ,EAAE,WAAW,SAAS,IAAI;EACxC,MAAM,QAAQ,EAAE,WAAW,SAAS,IAAI;EACxC,IAAI,UAAU,OAAO,OAAO,QAAQ;EAGpC,MAAM,KAAK,YAAY,EAAE,UAAU;EACnC,MAAM,KAAK,YAAY,EAAE,UAAU;EACnC,IAAI,OAAO,IAAI,OAAO,KAAK;EAG3B,MAAM,YAAY,kBAAkB,EAAE,UAAU;EAChD,MAAM,YAAY,kBAAkB,EAAE,UAAU;EAChD,IAAI,cAAc,WAAW,OAAO,YAAY;EAGhD,OAAO,EAAE,QAAQ,EAAE;CACrB,CAAC;CAED,OAAO,UAAU,KAAK,EAAE,iBAAiB,UAAU;AACrD"}
|
|
@@ -2,100 +2,125 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
//#region src/dictionaryManipulator/qualifiedDictionary.ts
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Canonical order of qualifier dimensions. A key that declares both dimensions
|
|
6
|
+
* always nests them in this order, with `item` innermost so it can act as the
|
|
7
|
+
* collection (array) axis.
|
|
7
8
|
*/
|
|
8
|
-
const
|
|
9
|
-
"locale",
|
|
10
|
-
"item",
|
|
11
|
-
"variant"
|
|
12
|
-
];
|
|
13
|
-
/**
|
|
14
|
-
* Canonical order of qualifier dimensions. A key that declares several
|
|
15
|
-
* dimensions always nests them in this order, with `item` innermost so it can
|
|
16
|
-
* act as the collection (array) axis.
|
|
17
|
-
*/
|
|
18
|
-
const QUALIFIER_ORDER = [
|
|
19
|
-
"variant",
|
|
20
|
-
"meta",
|
|
21
|
-
"item"
|
|
22
|
-
];
|
|
9
|
+
const QUALIFIER_ORDER = ["variant", "item"];
|
|
23
10
|
/**
|
|
24
11
|
* Separator joining per-dimension ids into a composite entry id. Also used as
|
|
25
12
|
* the chunk path separator in dynamic mode.
|
|
26
13
|
*/
|
|
27
14
|
const COMPOSITE_ID_SEPARATOR = "/";
|
|
28
15
|
/**
|
|
16
|
+
* Characters kept verbatim in an encoded qualifier segment. Everything else is
|
|
17
|
+
* percent-encoded so a segment can never contain the composite-id separator
|
|
18
|
+
* (`/`), path-hostile characters (`\` `:` `*` `?` `"` `<` `>` `|`, control
|
|
19
|
+
* chars), or characters that would break the generated loader modules (`'`).
|
|
20
|
+
*/
|
|
21
|
+
const SEGMENT_UNSAFE_CHARS = /[^A-Za-z0-9._&=-]/g;
|
|
22
|
+
/**
|
|
23
|
+
* Stricter set for the components of an object variant: also encodes `&` and
|
|
24
|
+
* `=` so the `field=value&field=value` serialization stays unambiguous.
|
|
25
|
+
*/
|
|
26
|
+
const COMPONENT_UNSAFE_CHARS = /[^A-Za-z0-9._-]/g;
|
|
27
|
+
/** Percent-encodes one UTF-16 code unit as a fixed-width `%XXXX` run. */
|
|
28
|
+
const percentEncodeChar = (char) => `%${char.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")}`;
|
|
29
|
+
const encodeSegmentText = (raw, unsafeChars) => {
|
|
30
|
+
if (raw === "") return "%";
|
|
31
|
+
const encoded = raw.replace(unsafeChars, percentEncodeChar);
|
|
32
|
+
if (encoded === "." || encoded === "..") return encoded.replace(/\./g, "%002E");
|
|
33
|
+
return encoded;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Canonical serialization of a single variant value into its identity string —
|
|
37
|
+
* the variant segment of a composite id, the chunk directory name in dynamic
|
|
38
|
+
* mode, and the runtime matching key.
|
|
39
|
+
*
|
|
40
|
+
* - `undefined` → `'default'` (the implicit fallback variant)
|
|
41
|
+
* - a string → the string itself (a named variant)
|
|
42
|
+
* - an object → its sorted `key=value` pairs joined by `&`
|
|
43
|
+
* (e.g. `{ userId: '123', id: 'abc' }` → `'id=abc&userId=123'`)
|
|
44
|
+
*
|
|
45
|
+
* Characters that are unsafe in file paths or generated code are
|
|
46
|
+
* percent-encoded (fixed-width `%XXXX` runs, injective). Common names —
|
|
47
|
+
* letters, digits, `-` `_` `.` — are left untouched. Both the declaration and
|
|
48
|
+
* the selector go through this function, so encoding never affects matching.
|
|
49
|
+
*
|
|
50
|
+
* Two variants resolve to the same entry iff their serializations are equal, so
|
|
51
|
+
* an object variant in a selector must equal the one declared on the dictionary.
|
|
52
|
+
*/
|
|
53
|
+
const serializeVariant = (variant) => {
|
|
54
|
+
if (variant === void 0) return "default";
|
|
55
|
+
if (typeof variant === "string") return encodeSegmentText(variant, SEGMENT_UNSAFE_CHARS);
|
|
56
|
+
return Object.keys(variant).sort().map((field) => `${encodeSegmentText(field, COMPONENT_UNSAFE_CHARS)}=${encodeSegmentText(String(variant[field]), COMPONENT_UNSAFE_CHARS)}`).join("&");
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Normalizes the `variant` field of a dictionary into the list of variant ids
|
|
60
|
+
* the declaration registers under. A single value yields one id; an **array**
|
|
61
|
+
* fans out into one id per element (duplicates collapsed). Returns `undefined`
|
|
62
|
+
* when the dictionary does not declare the variant dimension (no `variant`
|
|
63
|
+
* field, or an empty array).
|
|
64
|
+
*/
|
|
65
|
+
const getVariantIds = (variant) => {
|
|
66
|
+
if (variant === void 0) return void 0;
|
|
67
|
+
const values = Array.isArray(variant) ? variant : [variant];
|
|
68
|
+
if (values.length === 0) return void 0;
|
|
69
|
+
return [...new Set(values.map(serializeVariant))];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
29
72
|
* Returns the qualifier dimensions declared on a dictionary, in canonical
|
|
30
|
-
* order (`variant →
|
|
73
|
+
* order (`variant → item`). Empty when the dictionary is unqualified
|
|
31
74
|
* (plain dictionary or shared base content of a qualified group).
|
|
32
75
|
*/
|
|
33
76
|
const getDictionaryQualifierTypes = (dictionary) => {
|
|
34
77
|
const declaredQualifiers = [];
|
|
35
|
-
if (
|
|
36
|
-
if (dictionary.meta !== void 0) declaredQualifiers.push("meta");
|
|
78
|
+
if (getVariantIds(dictionary.variant) !== void 0) declaredQualifiers.push("variant");
|
|
37
79
|
if (typeof dictionary.item === "number") declaredQualifiers.push("item");
|
|
38
80
|
return declaredQualifiers;
|
|
39
81
|
};
|
|
40
82
|
/**
|
|
41
|
-
* Returns the qualifier
|
|
42
|
-
* dimension —
|
|
83
|
+
* Returns the qualifier identifiers of a dictionary for the given qualifier
|
|
84
|
+
* dimension — the candidate segments of the composite entry ids.
|
|
43
85
|
*
|
|
44
|
-
* - 'variant' → the variant
|
|
45
|
-
* -
|
|
46
|
-
* - 'item' → the item index as
|
|
86
|
+
* - 'variant' → the serialized variant id(s); an array variant yields one id
|
|
87
|
+
* per element (declaration-side fan-out)
|
|
88
|
+
* - 'item' → the item index as a single-element list
|
|
47
89
|
*/
|
|
48
|
-
const
|
|
49
|
-
if (qualifierType === "variant") return dictionary.variant;
|
|
50
|
-
|
|
51
|
-
const metaId = dictionary.meta?.id;
|
|
52
|
-
return metaId === void 0 ? void 0 : String(metaId);
|
|
53
|
-
}
|
|
54
|
-
return dictionary.item === void 0 ? void 0 : String(dictionary.item);
|
|
90
|
+
const getDictionaryQualifierIds = (dictionary, qualifierType) => {
|
|
91
|
+
if (qualifierType === "variant") return getVariantIds(dictionary.variant);
|
|
92
|
+
return dictionary.item === void 0 ? void 0 : [String(dictionary.item)];
|
|
55
93
|
};
|
|
56
94
|
/**
|
|
57
|
-
*
|
|
58
|
-
* dimension
|
|
59
|
-
*
|
|
95
|
+
* Builds every composite entry id of a dictionary — the cartesian product of
|
|
96
|
+
* its per-dimension id lists, joined in canonical order. A dictionary with a
|
|
97
|
+
* plain (non-array) variant yields exactly one id; an array variant fans out
|
|
98
|
+
* into one id per element. `undefined` when a dimension of the set is missing.
|
|
60
99
|
*/
|
|
61
|
-
const
|
|
62
|
-
|
|
100
|
+
const getDictionaryCompositeIds = (dictionary, qualifierTypes) => {
|
|
101
|
+
let compositeIds = [""];
|
|
63
102
|
for (const qualifierType of qualifierTypes) {
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
103
|
+
const ids = getDictionaryQualifierIds(dictionary, qualifierType);
|
|
104
|
+
if (ids === void 0) return void 0;
|
|
105
|
+
compositeIds = compositeIds.flatMap((prefix) => ids.map((id) => prefix === "" ? id : `${prefix}${"/"}${id}`));
|
|
67
106
|
}
|
|
68
|
-
return
|
|
107
|
+
return compositeIds;
|
|
69
108
|
};
|
|
70
109
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* Checks that every declared meta field is provided and equal in the selector.
|
|
77
|
-
* Reserved keys (`locale`, `item`, `variant`) are skipped; `meta.id` is part of
|
|
78
|
-
* the equality check.
|
|
110
|
+
* Tests whether a composite entry id matches a selector across every declared
|
|
111
|
+
* dimension. Segments are compared in their encoded form (both the stored id
|
|
112
|
+
* and the selector go through {@link serializeVariant}). The `item` dimension
|
|
113
|
+
* matches any value when the selector does not provide one (open collection
|
|
114
|
+
* axis).
|
|
79
115
|
*/
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
return
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
return providedValue !== void 0 && String(providedValue) === String(declaredValue);
|
|
116
|
+
const compositeIdMatchesSelector = (compositeId, qualifierTypes, selector) => {
|
|
117
|
+
const segments = compositeId.split("/");
|
|
118
|
+
return qualifierTypes.every((qualifierType, index) => {
|
|
119
|
+
if (qualifierType === "variant") return segments[index] === serializeVariant(selector?.variant);
|
|
120
|
+
return selector?.item === void 0 || segments[index] === String(selector.item);
|
|
86
121
|
});
|
|
87
122
|
};
|
|
88
123
|
/**
|
|
89
|
-
* Tests whether a group entry matches a selector across every declared
|
|
90
|
-
* dimension. The `item` dimension matches any value when the selector does not
|
|
91
|
-
* provide one (open collection axis).
|
|
92
|
-
*/
|
|
93
|
-
const entryMatchesSelector = (entry, qualifierTypes, selector) => qualifierTypes.every((qualifierType) => {
|
|
94
|
-
if (qualifierType === "variant") return entry.variant === (selector?.variant ?? "default");
|
|
95
|
-
if (qualifierType === "item") return selector?.item === void 0 || String(entry.item) === String(selector.item);
|
|
96
|
-
return metaFieldsMatch(entry.meta, selector);
|
|
97
|
-
});
|
|
98
|
-
/**
|
|
99
124
|
* Type guard discriminating a `QualifiedDictionaryGroup` (merge output of a
|
|
100
125
|
* qualified key) from a plain `Dictionary`. Both carry a `content` field; only
|
|
101
126
|
* the group declares `qualifierTypes`, which is therefore the discriminator.
|
|
@@ -104,12 +129,13 @@ const isQualifiedDictionaryGroup = (value) => typeof value === "object" && value
|
|
|
104
129
|
/**
|
|
105
130
|
* Reconstructs a resolvable {@link Dictionary} from a single entry of a
|
|
106
131
|
* qualified group: the content node stored under its composite id, plus the
|
|
107
|
-
* qualifier coordinates decoded from that id (`variant`, `item`)
|
|
108
|
-
* preserved `meta` object for the meta dimension.
|
|
132
|
+
* qualifier coordinates decoded from that id (`variant`, `item`).
|
|
109
133
|
*
|
|
110
|
-
* This keeps the resolver's
|
|
111
|
-
* `{ key, content, variant?, item
|
|
112
|
-
*
|
|
134
|
+
* This keeps the resolver's transform code unchanged: it still sees a
|
|
135
|
+
* `{ key, content, variant?, item? }` shape, even though the stored format no
|
|
136
|
+
* longer duplicates those fields per entry. The `variant` coordinate stays in
|
|
137
|
+
* its serialized (encoded) form, e.g. `'id=abc&userId=123'` — matching happens
|
|
138
|
+
* on the composite id segments, never on this reconstructed field.
|
|
113
139
|
*/
|
|
114
140
|
const reconstructQualifiedEntry = (group, compositeId) => {
|
|
115
141
|
const segments = compositeId.split("/");
|
|
@@ -121,10 +147,6 @@ const reconstructQualifiedEntry = (group, compositeId) => {
|
|
|
121
147
|
if (qualifierType === "variant") entry.variant = segments[index];
|
|
122
148
|
else if (qualifierType === "item") entry.item = Number(segments[index]);
|
|
123
149
|
});
|
|
124
|
-
if (group.qualifierTypes.includes("meta")) {
|
|
125
|
-
const metaIndex = group.qualifierTypes.indexOf("meta");
|
|
126
|
-
entry.meta = group.meta?.[compositeId] ?? { id: segments[metaIndex] };
|
|
127
|
-
}
|
|
128
150
|
return entry;
|
|
129
151
|
};
|
|
130
152
|
/**
|
|
@@ -134,8 +156,8 @@ const reconstructQualifiedEntry = (group, compositeId) => {
|
|
|
134
156
|
* - Plain dictionary → returned as-is (selector ignored)
|
|
135
157
|
* - `item` declared but not selected → every matching entry ordered by index
|
|
136
158
|
* - `item` selected → the matching entry or null
|
|
137
|
-
* - `variant` defaults to the `default` entry when not selected
|
|
138
|
-
*
|
|
159
|
+
* - `variant` defaults to the `default` entry when not selected; an object
|
|
160
|
+
* variant resolves only when the selector provides an equal object
|
|
139
161
|
*
|
|
140
162
|
* Dimensions compose: e.g. a variant × item key with `{ variant: 'promo' }`
|
|
141
163
|
* returns every promo item as an array; adding `{ item: 2 }` narrows to one.
|
|
@@ -143,9 +165,8 @@ const reconstructQualifiedEntry = (group, compositeId) => {
|
|
|
143
165
|
const resolveQualifiedDictionary = (dictionaryOrGroup, selector) => {
|
|
144
166
|
if (!isQualifiedDictionaryGroup(dictionaryOrGroup)) return dictionaryOrGroup;
|
|
145
167
|
const { qualifierTypes, content } = dictionaryOrGroup;
|
|
146
|
-
if (qualifierTypes.includes("meta") && selector?.id === void 0) return null;
|
|
147
168
|
const itemAxisOpen = qualifierTypes.includes("item") && selector?.item === void 0;
|
|
148
|
-
const matchedEntries = Object.keys(content).
|
|
169
|
+
const matchedEntries = Object.keys(content).filter((compositeId) => compositeIdMatchesSelector(compositeId, qualifierTypes, selector)).map((compositeId) => reconstructQualifiedEntry(dictionaryOrGroup, compositeId));
|
|
149
170
|
if (itemAxisOpen) return matchedEntries.sort((left, right) => (left.item ?? 0) - (right.item ?? 0));
|
|
150
171
|
return matchedEntries[0] ?? null;
|
|
151
172
|
};
|
|
@@ -166,7 +187,10 @@ const parseDictionarySelector = (localeOrSelector) => {
|
|
|
166
187
|
*/
|
|
167
188
|
const getDictionarySelectorCacheKey = (selector) => {
|
|
168
189
|
if (!selector) return "";
|
|
169
|
-
return Object.keys(selector).filter((selectorKey) => selectorKey !== "locale").sort().map((selectorKey) =>
|
|
190
|
+
return Object.keys(selector).filter((selectorKey) => selectorKey !== "locale").sort().map((selectorKey) => {
|
|
191
|
+
const value = selector[selectorKey];
|
|
192
|
+
return `${selectorKey}:${selectorKey === "variant" ? serializeVariant(value) : String(value)}`;
|
|
193
|
+
}).join("|");
|
|
170
194
|
};
|
|
171
195
|
/**
|
|
172
196
|
* Marker property carrying the ordered qualifier dimensions on a dynamic loader
|
|
@@ -177,7 +201,7 @@ const getDictionarySelectorCacheKey = (selector) => {
|
|
|
177
201
|
const QUALIFIER_DYNAMIC_TYPES_KEY = "__intlayerQualifierTypes";
|
|
178
202
|
/**
|
|
179
203
|
* Type guard discriminating a qualified dynamic loader map (collections /
|
|
180
|
-
* variants
|
|
204
|
+
* variants, possibly combined) from a plain dynamic loader map.
|
|
181
205
|
*/
|
|
182
206
|
const isQualifiedDynamicLoaderMap = (value) => typeof value === "object" && value !== null && "__intlayerQualifierTypes" in value;
|
|
183
207
|
/**
|
|
@@ -194,11 +218,6 @@ const collectQualifiedChunks = (loaderMap, key, locale, selector) => {
|
|
|
194
218
|
missed: true,
|
|
195
219
|
chunks: []
|
|
196
220
|
};
|
|
197
|
-
if (qualifierTypes.includes("meta") && selector?.id === void 0) return {
|
|
198
|
-
itemAxisOpen,
|
|
199
|
-
missed: true,
|
|
200
|
-
chunks: []
|
|
201
|
-
};
|
|
202
221
|
const chunks = [];
|
|
203
222
|
const walk = (node, dimensions, segments) => {
|
|
204
223
|
if (dimensions.length === 0) {
|
|
@@ -214,7 +233,7 @@ const collectQualifiedChunks = (loaderMap, key, locale, selector) => {
|
|
|
214
233
|
for (const segment of Object.keys(tree).sort((left, right) => Number(left) - Number(right))) walk(tree[segment], rest, [...segments, segment]);
|
|
215
234
|
return true;
|
|
216
235
|
}
|
|
217
|
-
const segment = dimension === "variant" ? selector?.variant
|
|
236
|
+
const segment = dimension === "variant" ? serializeVariant(selector?.variant) : String(selector?.item);
|
|
218
237
|
const child = tree[segment];
|
|
219
238
|
if (!child) return false;
|
|
220
239
|
return walk(child, rest, [...segments, segment]);
|
|
@@ -226,20 +245,15 @@ const collectQualifiedChunks = (loaderMap, key, locale, selector) => {
|
|
|
226
245
|
};
|
|
227
246
|
};
|
|
228
247
|
/**
|
|
229
|
-
* Whether a loaded chunk satisfies the selector's meta fields (no-op unless the
|
|
230
|
-
* key declares a `meta` dimension).
|
|
231
|
-
*/
|
|
232
|
-
const chunkMatchesMeta = (loaderMap, dictionary, selector) => !loaderMap["__intlayerQualifierTypes"].includes("meta") || metaFieldsMatch(dictionary.meta, selector);
|
|
233
|
-
/**
|
|
234
248
|
* Resolves the content of a qualified dynamic loader map against a selector,
|
|
235
249
|
* loading only the chunk(s) the selector actually targets.
|
|
236
250
|
*
|
|
237
251
|
* Walks the nested loader tree one dimension at a time (canonical order
|
|
238
|
-
* `variant →
|
|
239
|
-
*
|
|
240
|
-
* given — expands into every sibling chunk (the collection
|
|
241
|
-
*
|
|
242
|
-
*
|
|
252
|
+
* `variant → item`): `variant` defaults to `default` (or descends by the
|
|
253
|
+
* serialized object identity), and `item` either narrows to the selected index
|
|
254
|
+
* or — when no item is given — expands into every sibling chunk (the collection
|
|
255
|
+
* axis). Semantics mirror {@link resolveQualifiedDictionary} so dynamic and
|
|
256
|
+
* static modes behave alike.
|
|
243
257
|
*
|
|
244
258
|
* The Suspense mechanism is injected through `loadChunk` so the same logic
|
|
245
259
|
* serves both the client (suspender cache) and the server (`react.use`). Every
|
|
@@ -257,7 +271,7 @@ const resolveQualifiedDynamicContent = (params) => {
|
|
|
257
271
|
const { loaderMap, key, locale, selector, loadChunk, transform } = params;
|
|
258
272
|
const { itemAxisOpen, missed, chunks } = collectQualifiedChunks(loaderMap, key, locale, selector);
|
|
259
273
|
if (missed) return itemAxisOpen ? [] : null;
|
|
260
|
-
const dictionaries = chunks.map(({ cacheKey, loader }) => loadChunk(cacheKey, loader()))
|
|
274
|
+
const dictionaries = chunks.map(({ cacheKey, loader }) => loadChunk(cacheKey, loader()));
|
|
261
275
|
if (itemAxisOpen) return dictionaries.map(transform);
|
|
262
276
|
const [dictionary] = dictionaries;
|
|
263
277
|
return dictionary ? transform(dictionary) : null;
|
|
@@ -277,7 +291,7 @@ const resolveQualifiedDynamicContentAsync = async (params) => {
|
|
|
277
291
|
const { loaderMap, key, locale, selector, transform } = params;
|
|
278
292
|
const { itemAxisOpen, missed, chunks } = collectQualifiedChunks(loaderMap, key, locale, selector);
|
|
279
293
|
if (missed) return itemAxisOpen ? [] : null;
|
|
280
|
-
const dictionaries =
|
|
294
|
+
const dictionaries = await Promise.all(chunks.map(({ loader }) => loader()));
|
|
281
295
|
if (itemAxisOpen) return dictionaries.map(transform);
|
|
282
296
|
const [dictionary] = dictionaries;
|
|
283
297
|
return dictionary ? transform(dictionary) : null;
|
|
@@ -287,11 +301,11 @@ const resolveQualifiedDynamicContentAsync = async (params) => {
|
|
|
287
301
|
exports.COMPOSITE_ID_SEPARATOR = COMPOSITE_ID_SEPARATOR;
|
|
288
302
|
exports.QUALIFIER_DYNAMIC_TYPES_KEY = QUALIFIER_DYNAMIC_TYPES_KEY;
|
|
289
303
|
exports.QUALIFIER_ORDER = QUALIFIER_ORDER;
|
|
290
|
-
exports.
|
|
291
|
-
exports.
|
|
292
|
-
exports.getDictionaryQualifierSegments = getDictionaryQualifierSegments;
|
|
304
|
+
exports.getDictionaryCompositeIds = getDictionaryCompositeIds;
|
|
305
|
+
exports.getDictionaryQualifierIds = getDictionaryQualifierIds;
|
|
293
306
|
exports.getDictionaryQualifierTypes = getDictionaryQualifierTypes;
|
|
294
307
|
exports.getDictionarySelectorCacheKey = getDictionarySelectorCacheKey;
|
|
308
|
+
exports.getVariantIds = getVariantIds;
|
|
295
309
|
exports.isQualifiedDictionaryGroup = isQualifiedDictionaryGroup;
|
|
296
310
|
exports.isQualifiedDynamicLoaderMap = isQualifiedDynamicLoaderMap;
|
|
297
311
|
exports.parseDictionarySelector = parseDictionarySelector;
|
|
@@ -299,4 +313,5 @@ exports.reconstructQualifiedEntry = reconstructQualifiedEntry;
|
|
|
299
313
|
exports.resolveQualifiedDictionary = resolveQualifiedDictionary;
|
|
300
314
|
exports.resolveQualifiedDynamicContent = resolveQualifiedDynamicContent;
|
|
301
315
|
exports.resolveQualifiedDynamicContentAsync = resolveQualifiedDynamicContentAsync;
|
|
316
|
+
exports.serializeVariant = serializeVariant;
|
|
302
317
|
//# sourceMappingURL=qualifiedDictionary.cjs.map
|