@intlayer/core 8.1.2 → 8.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -212
- package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -94
- package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -45
- package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +1 -33
- package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMaskContent.cjs +1 -27
- package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -82
- package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs +1 -87
- package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs +1 -60
- package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -122
- package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
- package/dist/cjs/deepTransformPlugins/index.cjs +1 -32
- package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -106
- package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -64
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -18
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -55
- package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -26
- package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -23
- package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -36
- package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/index.cjs +1 -27
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -69
- package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs +1 -30
- package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +1 -48
- package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -31
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -39
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
- package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -38
- package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
- package/dist/cjs/formatters/compact.cjs +1 -25
- package/dist/cjs/formatters/compact.cjs.map +1 -1
- package/dist/cjs/formatters/currency.cjs +1 -29
- package/dist/cjs/formatters/currency.cjs.map +1 -1
- package/dist/cjs/formatters/date.cjs +1 -60
- package/dist/cjs/formatters/date.cjs.map +1 -1
- package/dist/cjs/formatters/index.cjs +1 -18
- package/dist/cjs/formatters/list.cjs +1 -30
- package/dist/cjs/formatters/list.cjs.map +1 -1
- package/dist/cjs/formatters/number.cjs +1 -18
- package/dist/cjs/formatters/number.cjs.map +1 -1
- package/dist/cjs/formatters/percentage.cjs +1 -25
- package/dist/cjs/formatters/percentage.cjs.map +1 -1
- package/dist/cjs/formatters/relativeTime.cjs +1 -33
- package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
- package/dist/cjs/formatters/units.cjs +1 -23
- package/dist/cjs/formatters/units.cjs.map +1 -1
- package/dist/cjs/getStorageAttributes.cjs +1 -134
- package/dist/cjs/getStorageAttributes.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -300
- package/dist/cjs/interpreter/getCondition.cjs +1 -27
- package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -41
- package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/getContent.cjs +1 -34
- package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
- package/dist/cjs/interpreter/getContent/index.cjs +1 -14
- package/dist/cjs/interpreter/getContent/plugins.cjs +1 -161
- package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
- package/dist/cjs/interpreter/getDictionary.cjs +1 -24
- package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
- package/dist/cjs/interpreter/getEnumeration.cjs +1 -72
- package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
- package/dist/cjs/interpreter/getGender.cjs +1 -38
- package/dist/cjs/interpreter/getGender.cjs.map +1 -1
- package/dist/cjs/interpreter/getHTML.cjs +1 -121
- package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
- package/dist/cjs/interpreter/getInsertion.cjs +1 -22
- package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
- package/dist/cjs/interpreter/getIntlayer.cjs +1 -40
- package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
- package/dist/cjs/interpreter/getNesting.cjs +1 -36
- package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
- package/dist/cjs/interpreter/getTranslation.cjs +1 -112
- package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
- package/dist/cjs/interpreter/index.cjs +1 -31
- package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +1 -55
- package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
- package/dist/cjs/localization/getBrowserLocale.cjs +1 -143
- package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
- package/dist/cjs/localization/getHTMLTextDir.cjs +1 -64
- package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
- package/dist/cjs/localization/getLocale.cjs +1 -27
- package/dist/cjs/localization/getLocale.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleFromPath.cjs +1 -45
- package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleLang.cjs +1 -20
- package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
- package/dist/cjs/localization/getLocaleName.cjs +1 -10
- package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
- package/dist/cjs/localization/getLocalizedUrl.cjs +1 -82
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
- package/dist/cjs/localization/getMultilingualUrls.cjs +1 -63
- package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
- package/dist/cjs/localization/getPathWithoutLocale.cjs +1 -55
- package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
- package/dist/cjs/localization/getPrefix.cjs +1 -63
- package/dist/cjs/localization/getPrefix.cjs.map +1 -1
- package/dist/cjs/localization/index.cjs +1 -39
- package/dist/cjs/localization/localeDetector.cjs +1 -133
- package/dist/cjs/localization/localeDetector.cjs.map +1 -1
- package/dist/cjs/localization/localeMapper.cjs +1 -119
- package/dist/cjs/localization/localeMapper.cjs.map +1 -1
- package/dist/cjs/localization/localeResolver.cjs +1 -28
- package/dist/cjs/localization/localeResolver.cjs.map +1 -1
- package/dist/cjs/localization/rewriteUtils.cjs +1 -110
- package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
- package/dist/cjs/localization/validatePrefix.cjs +1 -54
- package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
- package/dist/cjs/markdown/compiler.cjs +10 -810
- package/dist/cjs/markdown/compiler.cjs.map +1 -1
- package/dist/cjs/markdown/constants.cjs +1 -328
- package/dist/cjs/markdown/constants.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +1 -120
- package/dist/cjs/markdown/parser.cjs +1 -66
- package/dist/cjs/markdown/parser.cjs.map +1 -1
- package/dist/cjs/markdown/renderer.cjs +1 -61
- package/dist/cjs/markdown/renderer.cjs.map +1 -1
- package/dist/cjs/markdown/utils.cjs +6 -391
- package/dist/cjs/markdown/utils.cjs.map +1 -1
- package/dist/cjs/messageFormat/ICU.cjs +1 -319
- package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
- package/dist/cjs/messageFormat/i18next.cjs +1 -330
- package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
- package/dist/cjs/messageFormat/index.cjs +1 -11
- package/dist/cjs/messageFormat/verify-icu-format.cjs +2 -64
- package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
- package/dist/cjs/messageFormat/vue-i18n.cjs +1 -166
- package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
- package/dist/cjs/transpiler/condition/condition.cjs +1 -26
- package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
- package/dist/cjs/transpiler/condition/index.cjs +1 -4
- package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -28
- package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
- package/dist/cjs/transpiler/enumeration/index.cjs +1 -4
- package/dist/cjs/transpiler/file/file.cjs +1 -52
- package/dist/cjs/transpiler/file/file.cjs.map +1 -1
- package/dist/cjs/transpiler/file/fileBrowser.cjs +1 -25
- package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
- package/dist/cjs/transpiler/file/index.cjs +1 -5
- package/dist/cjs/transpiler/gender/gender.cjs +1 -26
- package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
- package/dist/cjs/transpiler/gender/index.cjs +1 -4
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +1 -44
- package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
- package/dist/cjs/transpiler/html/html.cjs +1 -37
- package/dist/cjs/transpiler/html/html.cjs.map +1 -1
- package/dist/cjs/transpiler/html/htmlTags.cjs +1 -116
- package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
- package/dist/cjs/transpiler/html/index.cjs +1 -6
- package/dist/cjs/transpiler/index.cjs +1 -24
- package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +1 -11
- package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
- package/dist/cjs/transpiler/insertion/index.cjs +1 -6
- package/dist/cjs/transpiler/insertion/insertion.cjs +1 -36
- package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +2 -23
- package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/index.cjs +1 -6
- package/dist/cjs/transpiler/markdown/markdown.cjs +1 -54
- package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
- package/dist/cjs/transpiler/nesting/index.cjs +1 -4
- package/dist/cjs/transpiler/nesting/nesting.cjs +1 -27
- package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
- package/dist/cjs/transpiler/translation/index.cjs +1 -4
- package/dist/cjs/transpiler/translation/translation.cjs +1 -29
- package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
- package/dist/cjs/utils/checkIsURLAbsolute.cjs +1 -7
- package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
- package/dist/cjs/utils/getCookie.cjs +1 -32
- package/dist/cjs/utils/getCookie.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -0
- package/dist/cjs/utils/intl.cjs +1 -91
- package/dist/cjs/utils/intl.cjs.map +1 -1
- package/dist/cjs/utils/isSameKeyPath.cjs +1 -7
- package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
- package/dist/cjs/utils/isValidReactElement.cjs +1 -14
- package/dist/cjs/utils/isValidReactElement.cjs.map +1 -1
- package/dist/cjs/utils/localeStorage.cjs +1 -140
- package/dist/cjs/utils/localeStorage.cjs.map +1 -1
- package/dist/cjs/utils/parseYaml.cjs +16 -322
- package/dist/cjs/utils/parseYaml.cjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs +1 -207
- package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs +1 -89
- package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +1 -42
- package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +1 -31
- package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMaskContent.mjs +1 -25
- package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs +1 -77
- package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs +1 -86
- package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs +1 -59
- package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -119
- package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
- package/dist/esm/deepTransformPlugins/index.mjs +1 -12
- package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs +1 -104
- package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -62
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -16
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +1 -53
- package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -24
- package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -21
- package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/getNodeType.mjs +1 -34
- package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/index.mjs +1 -14
- package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -66
- package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs +1 -28
- package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/orderDictionaries.mjs +1 -45
- package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -29
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -37
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
- package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +1 -36
- package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
- package/dist/esm/formatters/compact.mjs +1 -22
- package/dist/esm/formatters/compact.mjs.map +1 -1
- package/dist/esm/formatters/currency.mjs +1 -26
- package/dist/esm/formatters/currency.mjs.map +1 -1
- package/dist/esm/formatters/date.mjs +1 -57
- package/dist/esm/formatters/date.mjs.map +1 -1
- package/dist/esm/formatters/index.mjs +1 -10
- package/dist/esm/formatters/list.mjs +1 -27
- package/dist/esm/formatters/list.mjs.map +1 -1
- package/dist/esm/formatters/number.mjs +1 -15
- package/dist/esm/formatters/number.mjs.map +1 -1
- package/dist/esm/formatters/percentage.mjs +1 -22
- package/dist/esm/formatters/percentage.mjs.map +1 -1
- package/dist/esm/formatters/relativeTime.mjs +1 -30
- package/dist/esm/formatters/relativeTime.mjs.map +1 -1
- package/dist/esm/formatters/units.mjs +1 -20
- package/dist/esm/formatters/units.mjs.map +1 -1
- package/dist/esm/getStorageAttributes.mjs +1 -132
- package/dist/esm/getStorageAttributes.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -82
- package/dist/esm/interpreter/getCondition.mjs +1 -25
- package/dist/esm/interpreter/getCondition.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -39
- package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/getContent.mjs +1 -31
- package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
- package/dist/esm/interpreter/getContent/index.mjs +1 -5
- package/dist/esm/interpreter/getContent/plugins.mjs +1 -153
- package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
- package/dist/esm/interpreter/getDictionary.mjs +1 -23
- package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
- package/dist/esm/interpreter/getEnumeration.mjs +1 -69
- package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
- package/dist/esm/interpreter/getGender.mjs +1 -36
- package/dist/esm/interpreter/getGender.mjs.map +1 -1
- package/dist/esm/interpreter/getHTML.mjs +1 -119
- package/dist/esm/interpreter/getHTML.mjs.map +1 -1
- package/dist/esm/interpreter/getInsertion.mjs +1 -20
- package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
- package/dist/esm/interpreter/getIntlayer.mjs +1 -36
- package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
- package/dist/esm/interpreter/getNesting.mjs +1 -35
- package/dist/esm/interpreter/getNesting.mjs.map +1 -1
- package/dist/esm/interpreter/getTranslation.mjs +1 -110
- package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
- package/dist/esm/interpreter/index.mjs +1 -13
- package/dist/esm/interpreter/splitAndJoinInsertion.mjs +1 -53
- package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
- package/dist/esm/localization/getBrowserLocale.mjs +1 -138
- package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
- package/dist/esm/localization/getHTMLTextDir.mjs +1 -62
- package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
- package/dist/esm/localization/getLocale.mjs +1 -24
- package/dist/esm/localization/getLocale.mjs.map +1 -1
- package/dist/esm/localization/getLocaleFromPath.mjs +1 -42
- package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
- package/dist/esm/localization/getLocaleLang.mjs +1 -18
- package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
- package/dist/esm/localization/getLocaleName.mjs +1 -9
- package/dist/esm/localization/getLocaleName.mjs.map +1 -1
- package/dist/esm/localization/getLocalizedUrl.mjs +1 -79
- package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
- package/dist/esm/localization/getMultilingualUrls.mjs +1 -60
- package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
- package/dist/esm/localization/getPathWithoutLocale.mjs +1 -52
- package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
- package/dist/esm/localization/getPrefix.mjs +1 -60
- package/dist/esm/localization/getPrefix.mjs.map +1 -1
- package/dist/esm/localization/index.mjs +1 -17
- package/dist/esm/localization/localeDetector.mjs +1 -131
- package/dist/esm/localization/localeDetector.mjs.map +1 -1
- package/dist/esm/localization/localeMapper.mjs +1 -114
- package/dist/esm/localization/localeMapper.mjs.map +1 -1
- package/dist/esm/localization/localeResolver.mjs +1 -25
- package/dist/esm/localization/localeResolver.mjs.map +1 -1
- package/dist/esm/localization/rewriteUtils.mjs +1 -104
- package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
- package/dist/esm/localization/validatePrefix.mjs +1 -51
- package/dist/esm/localization/validatePrefix.mjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs +10 -786
- package/dist/esm/markdown/compiler.mjs.map +1 -1
- package/dist/esm/markdown/constants.mjs +1 -247
- package/dist/esm/markdown/constants.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +1 -7
- package/dist/esm/markdown/parser.mjs +1 -65
- package/dist/esm/markdown/parser.mjs.map +1 -1
- package/dist/esm/markdown/renderer.mjs +1 -59
- package/dist/esm/markdown/renderer.mjs.map +1 -1
- package/dist/esm/markdown/utils.mjs +6 -361
- package/dist/esm/markdown/utils.mjs.map +1 -1
- package/dist/esm/messageFormat/ICU.mjs +1 -316
- package/dist/esm/messageFormat/ICU.mjs.map +1 -1
- package/dist/esm/messageFormat/i18next.mjs +1 -327
- package/dist/esm/messageFormat/i18next.mjs.map +1 -1
- package/dist/esm/messageFormat/index.mjs +1 -5
- package/dist/esm/messageFormat/verify-icu-format.mjs +2 -64
- package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
- package/dist/esm/messageFormat/vue-i18n.mjs +1 -163
- package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
- package/dist/esm/transpiler/condition/condition.mjs +1 -24
- package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
- package/dist/esm/transpiler/condition/index.mjs +1 -3
- package/dist/esm/transpiler/enumeration/enumeration.mjs +1 -26
- package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
- package/dist/esm/transpiler/enumeration/index.mjs +1 -3
- package/dist/esm/transpiler/file/file.mjs +1 -49
- package/dist/esm/transpiler/file/file.mjs.map +1 -1
- package/dist/esm/transpiler/file/fileBrowser.mjs +1 -24
- package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
- package/dist/esm/transpiler/file/index.mjs +1 -3
- package/dist/esm/transpiler/gender/gender.mjs +1 -24
- package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
- package/dist/esm/transpiler/gender/index.mjs +1 -3
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -43
- package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
- package/dist/esm/transpiler/html/html.mjs +1 -35
- package/dist/esm/transpiler/html/html.mjs.map +1 -1
- package/dist/esm/transpiler/html/htmlTags.mjs +1 -114
- package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
- package/dist/esm/transpiler/html/index.mjs +1 -4
- package/dist/esm/transpiler/index.mjs +1 -13
- package/dist/esm/transpiler/insertion/getInsertionValues.mjs +1 -9
- package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
- package/dist/esm/transpiler/insertion/index.mjs +1 -4
- package/dist/esm/transpiler/insertion/insertion.mjs +1 -34
- package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +2 -22
- package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/index.mjs +1 -4
- package/dist/esm/transpiler/markdown/markdown.mjs +1 -52
- package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
- package/dist/esm/transpiler/nesting/index.mjs +1 -3
- package/dist/esm/transpiler/nesting/nesting.mjs +1 -25
- package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
- package/dist/esm/transpiler/translation/index.mjs +1 -3
- package/dist/esm/transpiler/translation/translation.mjs +1 -27
- package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
- package/dist/esm/utils/checkIsURLAbsolute.mjs +1 -5
- package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
- package/dist/esm/utils/getCookie.mjs +1 -30
- package/dist/esm/utils/getCookie.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -0
- package/dist/esm/utils/intl.mjs +1 -86
- package/dist/esm/utils/intl.mjs.map +1 -1
- package/dist/esm/utils/isSameKeyPath.mjs +1 -5
- package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
- package/dist/esm/utils/isValidReactElement.mjs +1 -12
- package/dist/esm/utils/isValidReactElement.mjs.map +1 -1
- package/dist/esm/utils/localeStorage.mjs +1 -135
- package/dist/esm/utils/localeStorage.mjs.map +1 -1
- package/dist/esm/utils/parseYaml.mjs +16 -320
- package/dist/esm/utils/parseYaml.mjs.map +1 -1
- package/dist/types/formatters/index.d.ts +2 -1
- package/dist/types/index.d.ts +8 -2
- package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
- package/dist/types/localization/index.d.ts +2 -1
- package/dist/types/markdown/index.d.ts +4 -1
- package/dist/types/markdown/types.d.ts +1 -1
- package/dist/types/markdown/types.d.ts.map +1 -1
- package/dist/types/transpiler/translation/translation.d.ts +1 -1
- package/dist/types/utils/index.d.ts +8 -0
- package/package.json +65 -11
|
@@ -1,80 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getPathWithoutLocale } from "./getPathWithoutLocale.mjs";
|
|
3
|
-
import { getPrefix } from "./getPrefix.mjs";
|
|
4
|
-
import { getCanonicalPath, getLocalizedPath, getRewriteRules } from "./rewriteUtils.mjs";
|
|
5
|
-
import { DefaultValues } from "@intlayer/config/client";
|
|
6
|
-
import configuration from "@intlayer/config/built";
|
|
7
|
-
|
|
8
|
-
//#region src/localization/getLocalizedUrl.ts
|
|
9
|
-
/**
|
|
10
|
-
* Generate URL by prefixing the given URL with the referenced locale or adding search parameters
|
|
11
|
-
* based on the routing mode. Handles both absolute and relative URLs appropriately.
|
|
12
|
-
*
|
|
13
|
-
* This function gets the locales, default locale, and routing mode from the configuration if not provided.
|
|
14
|
-
*
|
|
15
|
-
* Example:
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* // prefix-no-default mode
|
|
19
|
-
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' });
|
|
20
|
-
* // Returns '/fr/about' for the French locale
|
|
21
|
-
* // Returns '/about' for the English locale (default)
|
|
22
|
-
*
|
|
23
|
-
* // prefix-all mode
|
|
24
|
-
* getLocalizedUrl('/about', 'en', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' });
|
|
25
|
-
* // Returns '/en/about' for the English locale
|
|
26
|
-
* // Returns '/fr/about' for the French locale
|
|
27
|
-
*
|
|
28
|
-
* // search-params mode
|
|
29
|
-
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' });
|
|
30
|
-
* // Returns '/about?locale=fr' for the French locale
|
|
31
|
-
*
|
|
32
|
-
* // no-prefix mode
|
|
33
|
-
* getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' });
|
|
34
|
-
* // Returns '/about' for any locale
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @param url - The original URL string to be processed.
|
|
38
|
-
* @param currentLocale - The current locale.
|
|
39
|
-
* @param options - Configuration options
|
|
40
|
-
* @param options.locales - Optional array of supported locales. Defaults to configured locales.
|
|
41
|
-
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
42
|
-
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
43
|
-
* @returns The localized URL for the current locale.
|
|
44
|
-
*/
|
|
45
|
-
const getLocalizedUrl = (url, currentLocale, options = {}) => {
|
|
46
|
-
const { defaultLocale, mode, locales, rewrite } = {
|
|
47
|
-
defaultLocale: configuration?.internationalization?.defaultLocale ?? DefaultValues.Internationalization.DEFAULT_LOCALE,
|
|
48
|
-
mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,
|
|
49
|
-
locales: configuration?.internationalization?.locales ?? DefaultValues.Internationalization.LOCALES,
|
|
50
|
-
rewrite: configuration?.routing?.rewrite,
|
|
51
|
-
...options
|
|
52
|
-
};
|
|
53
|
-
const urlWithoutLocale = getPathWithoutLocale(url, locales);
|
|
54
|
-
const urlRewriteRules = getRewriteRules(rewrite, "url");
|
|
55
|
-
if (mode === "no-prefix") return getLocalizedPath(getCanonicalPath(urlWithoutLocale, void 0, urlRewriteRules), currentLocale, urlRewriteRules).path;
|
|
56
|
-
const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);
|
|
57
|
-
const parsedUrl = isAbsoluteUrl ? new URL(urlWithoutLocale) : new URL(urlWithoutLocale, "http://example.com");
|
|
58
|
-
const baseUrl = isAbsoluteUrl ? `${parsedUrl.protocol}//${parsedUrl.host}` : "";
|
|
59
|
-
const translatedPathname = getLocalizedPath(getCanonicalPath(parsedUrl.pathname, void 0, urlRewriteRules), currentLocale, urlRewriteRules).path;
|
|
60
|
-
if (mode === "search-params") {
|
|
61
|
-
const searchParams = new URLSearchParams(parsedUrl.search);
|
|
62
|
-
searchParams.set("locale", currentLocale.toString());
|
|
63
|
-
const queryString = searchParams.toString();
|
|
64
|
-
const pathWithQuery = queryString ? `${translatedPathname}?${queryString}` : translatedPathname;
|
|
65
|
-
return isAbsoluteUrl ? `${baseUrl}${pathWithQuery}${parsedUrl.hash}` : `${pathWithQuery}${parsedUrl.hash}`;
|
|
66
|
-
}
|
|
67
|
-
const { prefix } = getPrefix(currentLocale, {
|
|
68
|
-
defaultLocale,
|
|
69
|
-
mode,
|
|
70
|
-
locales
|
|
71
|
-
});
|
|
72
|
-
let localizedPath = `/${prefix}${translatedPathname}`;
|
|
73
|
-
localizedPath = localizedPath.replaceAll(/\/+/g, "/");
|
|
74
|
-
if (localizedPath.length > 1 && localizedPath.endsWith("/")) localizedPath = localizedPath.slice(0, -1);
|
|
75
|
-
return isAbsoluteUrl ? `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}` : `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
//#endregion
|
|
79
|
-
export { getLocalizedUrl };
|
|
1
|
+
import{checkIsURLAbsolute as e}from"../utils/checkIsURLAbsolute.mjs";import{getPathWithoutLocale as t}from"./getPathWithoutLocale.mjs";import{getPrefix as n}from"./getPrefix.mjs";import{getCanonicalPath as r,getLocalizedPath as i,getRewriteRules as a}from"./rewriteUtils.mjs";import{DefaultValues as o}from"@intlayer/config/client";import s from"@intlayer/config/built";const c=(c,l,u={})=>{let{defaultLocale:d,mode:f,locales:p,rewrite:m}={defaultLocale:s?.internationalization?.defaultLocale??o.Internationalization.DEFAULT_LOCALE,mode:s?.routing?.mode??o.Routing.ROUTING_MODE,locales:s?.internationalization?.locales??o.Internationalization.LOCALES,rewrite:s?.routing?.rewrite,...u},h=t(c,p),g=a(m,`url`);if(f===`no-prefix`)return i(r(h,void 0,g),l,g).path;let _=e(h),v=_?new URL(h):new URL(h,`http://example.com`),y=_?`${v.protocol}//${v.host}`:``,b=i(r(v.pathname,void 0,g),l,g).path;if(f===`search-params`){let e=new URLSearchParams(v.search);e.set(`locale`,l.toString());let t=e.toString(),n=t?`${b}?${t}`:b;return _?`${y}${n}${v.hash}`:`${n}${v.hash}`}let{prefix:x}=n(l,{defaultLocale:d,mode:f,locales:p}),S=`/${x}${b}`;return S=S.replaceAll(/\/+/g,`/`),S.length>1&&S.endsWith(`/`)&&(S=S.slice(0,-1)),_?`${y}${S}${v.search}${v.hash}`:`${S}${v.search}${v.hash}`};export{c as getLocalizedUrl};
|
|
80
2
|
//# sourceMappingURL=getLocalizedUrl.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocalizedUrl.mjs","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { Locale, LocalesValues, RoutingConfig } from '@intlayer/types';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\nimport { getPathWithoutLocale } from './getPathWithoutLocale';\nimport { getPrefix } from './getPrefix';\nimport {\n getCanonicalPath,\n getLocalizedPath,\n getRewriteRules,\n} from './rewriteUtils';\n\n/**\n * Generate URL by prefixing the given URL with the referenced locale or adding search parameters\n * based on the routing mode. Handles both absolute and relative URLs appropriately.\n *\n * This function gets the locales, default locale, and routing mode from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' });\n * // Returns '/fr/about' for the French locale\n * // Returns '/about' for the English locale (default)\n *\n * // prefix-all mode\n * getLocalizedUrl('/about', 'en', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' });\n * // Returns '/en/about' for the English locale\n * // Returns '/fr/about' for the French locale\n *\n * // search-params mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' });\n * // Returns '/about?locale=fr' for the French locale\n *\n * // no-prefix mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' });\n * // Returns '/about' for any locale\n * ```\n *\n * @param url - The original URL string to be processed.\n * @param currentLocale - The current locale.\n * @param options - Configuration options\n * @param options.locales - Optional array of supported locales. Defaults to configured locales.\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns The localized URL for the current locale.\n */\nexport const getLocalizedUrl = (\n url: string,\n currentLocale: LocalesValues,\n options: {\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: RoutingConfig['mode'];\n rewrite?: RoutingConfig['rewrite'];\n } = {}\n): string => {\n const { defaultLocale, mode, locales, rewrite } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n rewrite: configuration?.routing?.rewrite,\n ...options,\n };\n\n const urlWithoutLocale = getPathWithoutLocale(url, locales);\n\n const urlRewriteRules = getRewriteRules(rewrite, 'url');\n\n if (mode === 'no-prefix') {\n // Resolve to canonical path first from the potentially localized input URL\n const canonicalPathname = getCanonicalPath(\n urlWithoutLocale,\n undefined,\n urlRewriteRules\n );\n\n // Localize the canonical path for the target locale\n return getLocalizedPath(\n canonicalPathname,\n currentLocale as Locale,\n urlRewriteRules\n ).path;\n }\n\n const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);\n\n const parsedUrl = isAbsoluteUrl\n ? new URL(urlWithoutLocale)\n : new URL(urlWithoutLocale, 'http://example.com');\n\n const baseUrl = isAbsoluteUrl\n ? `${parsedUrl.protocol}//${parsedUrl.host}`\n : '';\n\n // Resolve to canonical path first\n const canonicalPathname = getCanonicalPath(\n parsedUrl.pathname,\n undefined,\n urlRewriteRules\n );\n\n // Localize the canonical path for the target locale\n const translatedPathname = getLocalizedPath(\n canonicalPathname,\n currentLocale as Locale,\n urlRewriteRules\n ).path;\n\n if (mode === 'search-params') {\n const searchParams = new URLSearchParams(parsedUrl.search);\n searchParams.set('locale', currentLocale.toString());\n\n const queryString = searchParams.toString();\n const pathWithQuery = queryString\n ? `${translatedPathname}?${queryString}`\n : translatedPathname;\n\n return isAbsoluteUrl\n ? `${baseUrl}${pathWithQuery}${parsedUrl.hash}`\n : `${pathWithQuery}${parsedUrl.hash}`;\n }\n\n const { prefix } = getPrefix(currentLocale, {\n defaultLocale,\n mode,\n locales,\n });\n\n let localizedPath = `/${prefix}${translatedPathname}`;\n\n localizedPath = localizedPath.replaceAll(/\\/+/g, '/');\n\n if (localizedPath.length > 1 && localizedPath.endsWith('/')) {\n localizedPath = localizedPath.slice(0, -1);\n }\n\n const finalUrl = isAbsoluteUrl\n ? `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`\n : `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;\n\n return finalUrl;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getLocalizedUrl.mjs","names":[],"sources":["../../../src/localization/getLocalizedUrl.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { Locale, LocalesValues, RoutingConfig } from '@intlayer/types';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\nimport { getPathWithoutLocale } from './getPathWithoutLocale';\nimport { getPrefix } from './getPrefix';\nimport {\n getCanonicalPath,\n getLocalizedPath,\n getRewriteRules,\n} from './rewriteUtils';\n\n/**\n * Generate URL by prefixing the given URL with the referenced locale or adding search parameters\n * based on the routing mode. Handles both absolute and relative URLs appropriately.\n *\n * This function gets the locales, default locale, and routing mode from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' });\n * // Returns '/fr/about' for the French locale\n * // Returns '/about' for the English locale (default)\n *\n * // prefix-all mode\n * getLocalizedUrl('/about', 'en', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' });\n * // Returns '/en/about' for the English locale\n * // Returns '/fr/about' for the French locale\n *\n * // search-params mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' });\n * // Returns '/about?locale=fr' for the French locale\n *\n * // no-prefix mode\n * getLocalizedUrl('/about', 'fr', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' });\n * // Returns '/about' for any locale\n * ```\n *\n * @param url - The original URL string to be processed.\n * @param currentLocale - The current locale.\n * @param options - Configuration options\n * @param options.locales - Optional array of supported locales. Defaults to configured locales.\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns The localized URL for the current locale.\n */\nexport const getLocalizedUrl = (\n url: string,\n currentLocale: LocalesValues,\n options: {\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: RoutingConfig['mode'];\n rewrite?: RoutingConfig['rewrite'];\n } = {}\n): string => {\n const { defaultLocale, mode, locales, rewrite } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n rewrite: configuration?.routing?.rewrite,\n ...options,\n };\n\n const urlWithoutLocale = getPathWithoutLocale(url, locales);\n\n const urlRewriteRules = getRewriteRules(rewrite, 'url');\n\n if (mode === 'no-prefix') {\n // Resolve to canonical path first from the potentially localized input URL\n const canonicalPathname = getCanonicalPath(\n urlWithoutLocale,\n undefined,\n urlRewriteRules\n );\n\n // Localize the canonical path for the target locale\n return getLocalizedPath(\n canonicalPathname,\n currentLocale as Locale,\n urlRewriteRules\n ).path;\n }\n\n const isAbsoluteUrl = checkIsURLAbsolute(urlWithoutLocale);\n\n const parsedUrl = isAbsoluteUrl\n ? new URL(urlWithoutLocale)\n : new URL(urlWithoutLocale, 'http://example.com');\n\n const baseUrl = isAbsoluteUrl\n ? `${parsedUrl.protocol}//${parsedUrl.host}`\n : '';\n\n // Resolve to canonical path first\n const canonicalPathname = getCanonicalPath(\n parsedUrl.pathname,\n undefined,\n urlRewriteRules\n );\n\n // Localize the canonical path for the target locale\n const translatedPathname = getLocalizedPath(\n canonicalPathname,\n currentLocale as Locale,\n urlRewriteRules\n ).path;\n\n if (mode === 'search-params') {\n const searchParams = new URLSearchParams(parsedUrl.search);\n searchParams.set('locale', currentLocale.toString());\n\n const queryString = searchParams.toString();\n const pathWithQuery = queryString\n ? `${translatedPathname}?${queryString}`\n : translatedPathname;\n\n return isAbsoluteUrl\n ? `${baseUrl}${pathWithQuery}${parsedUrl.hash}`\n : `${pathWithQuery}${parsedUrl.hash}`;\n }\n\n const { prefix } = getPrefix(currentLocale, {\n defaultLocale,\n mode,\n locales,\n });\n\n let localizedPath = `/${prefix}${translatedPathname}`;\n\n localizedPath = localizedPath.replaceAll(/\\/+/g, '/');\n\n if (localizedPath.length > 1 && localizedPath.endsWith('/')) {\n localizedPath = localizedPath.slice(0, -1);\n }\n\n const finalUrl = isAbsoluteUrl\n ? `${baseUrl}${localizedPath}${parsedUrl.search}${parsedUrl.hash}`\n : `${localizedPath}${parsedUrl.search}${parsedUrl.hash}`;\n\n return finalUrl;\n};\n"],"mappings":"kXAgDA,MAAa,GACX,EACA,EACA,EAKI,EAAE,GACK,CACX,GAAM,CAAE,gBAAe,OAAM,UAAS,WAAY,CAChD,cACE,GAAe,sBAAsB,eACrC,EAAc,qBAAqB,eACrC,KAAM,GAAe,SAAS,MAAQ,EAAc,QAAQ,aAC5D,QACE,GAAe,sBAAsB,SACrC,EAAc,qBAAqB,QACrC,QAAS,GAAe,SAAS,QACjC,GAAG,EACJ,CAEK,EAAmB,EAAqB,EAAK,EAAQ,CAErD,EAAkB,EAAgB,EAAS,MAAM,CAEvD,GAAI,IAAS,YASX,OAAO,EAPmB,EACxB,EACA,IAAA,GACA,EACD,CAKC,EACA,EACD,CAAC,KAGJ,IAAM,EAAgB,EAAmB,EAAiB,CAEpD,EAAY,EACd,IAAI,IAAI,EAAiB,CACzB,IAAI,IAAI,EAAkB,qBAAqB,CAE7C,EAAU,EACZ,GAAG,EAAU,SAAS,IAAI,EAAU,OACpC,GAUE,EAAqB,EAPD,EACxB,EAAU,SACV,IAAA,GACA,EACD,CAKC,EACA,EACD,CAAC,KAEF,GAAI,IAAS,gBAAiB,CAC5B,IAAM,EAAe,IAAI,gBAAgB,EAAU,OAAO,CAC1D,EAAa,IAAI,SAAU,EAAc,UAAU,CAAC,CAEpD,IAAM,EAAc,EAAa,UAAU,CACrC,EAAgB,EAClB,GAAG,EAAmB,GAAG,IACzB,EAEJ,OAAO,EACH,GAAG,IAAU,IAAgB,EAAU,OACvC,GAAG,IAAgB,EAAU,OAGnC,GAAM,CAAE,UAAW,EAAU,EAAe,CAC1C,gBACA,OACA,UACD,CAAC,CAEE,EAAgB,IAAI,IAAS,IAYjC,MAVA,GAAgB,EAAc,WAAW,OAAQ,IAAI,CAEjD,EAAc,OAAS,GAAK,EAAc,SAAS,IAAI,GACzD,EAAgB,EAAc,MAAM,EAAG,GAAG,EAG3B,EACb,GAAG,IAAU,IAAgB,EAAU,SAAS,EAAU,OAC1D,GAAG,IAAgB,EAAU,SAAS,EAAU"}
|
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DefaultValues } from "@intlayer/config/client";
|
|
3
|
-
import configuration from "@intlayer/config/built";
|
|
4
|
-
|
|
5
|
-
//#region src/localization/getMultilingualUrls.ts
|
|
6
|
-
/**
|
|
7
|
-
* Generates multilingual URLs by prefixing the given URL with each supported locale
|
|
8
|
-
* or adding search parameters based on the routing mode.
|
|
9
|
-
* Handles both absolute and relative URLs appropriately.
|
|
10
|
-
*
|
|
11
|
-
* This function gets the locales, default locale, and routing mode from the configuration if not provided.
|
|
12
|
-
*
|
|
13
|
-
* Example:
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* // prefix-no-default mode
|
|
17
|
-
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
18
|
-
* // Returns { en: '/dashboard', fr: '/fr/dashboard' }
|
|
19
|
-
*
|
|
20
|
-
* // prefix-all mode
|
|
21
|
-
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' })
|
|
22
|
-
* // Returns { en: '/en/dashboard', fr: '/fr/dashboard' }
|
|
23
|
-
*
|
|
24
|
-
* // search-params mode
|
|
25
|
-
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' })
|
|
26
|
-
* // Returns { en: '/dashboard?locale=en', fr: '/dashboard?locale=fr' }
|
|
27
|
-
*
|
|
28
|
-
* // no-prefix mode
|
|
29
|
-
* getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' })
|
|
30
|
-
* // Returns { en: '/dashboard', fr: '/dashboard' }
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @param url - The original URL string to be processed.
|
|
34
|
-
* @param options - Configuration options
|
|
35
|
-
* @param options.locales - Optional array of supported locales. Defaults to configured locales.
|
|
36
|
-
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
37
|
-
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
38
|
-
* @returns An object mapping each locale to its corresponding multilingual URL.
|
|
39
|
-
*/
|
|
40
|
-
const getMultilingualUrls = (url, options = {}) => {
|
|
41
|
-
const { defaultLocale, mode, locales, rewrite } = {
|
|
42
|
-
defaultLocale: configuration?.internationalization?.defaultLocale ?? DefaultValues.Internationalization.DEFAULT_LOCALE,
|
|
43
|
-
mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,
|
|
44
|
-
locales: configuration?.internationalization?.locales ?? DefaultValues.Internationalization.LOCALES,
|
|
45
|
-
rewrite: configuration?.routing?.rewrite,
|
|
46
|
-
...options
|
|
47
|
-
};
|
|
48
|
-
return (locales ?? []).reduce((acc, locale) => {
|
|
49
|
-
acc[locale] = getLocalizedUrl(url, locale, {
|
|
50
|
-
locales,
|
|
51
|
-
defaultLocale,
|
|
52
|
-
mode,
|
|
53
|
-
rewrite
|
|
54
|
-
});
|
|
55
|
-
return acc;
|
|
56
|
-
}, {});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
export { getMultilingualUrls };
|
|
1
|
+
import{getLocalizedUrl as e}from"./getLocalizedUrl.mjs";import{DefaultValues as t}from"@intlayer/config/client";import n from"@intlayer/config/built";const r=(r,i={})=>{let{defaultLocale:a,mode:o,locales:s,rewrite:c}={defaultLocale:n?.internationalization?.defaultLocale??t.Internationalization.DEFAULT_LOCALE,mode:n?.routing?.mode??t.Routing.ROUTING_MODE,locales:n?.internationalization?.locales??t.Internationalization.LOCALES,rewrite:n?.routing?.rewrite,...i};return(s??[]).reduce((t,n)=>(t[n]=e(r,n,{locales:s,defaultLocale:a,mode:o,rewrite:c}),t),{})};export{r as getMultilingualUrls};
|
|
61
2
|
//# sourceMappingURL=getMultilingualUrls.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMultilingualUrls.mjs","names":[],"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type {\n LocalesValues,\n RoutingConfig,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { getLocalizedUrl } from './getLocalizedUrl';\n\n/**\n * Generates multilingual URLs by prefixing the given URL with each supported locale\n * or adding search parameters based on the routing mode.\n * Handles both absolute and relative URLs appropriately.\n *\n * This function gets the locales, default locale, and routing mode from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { en: '/dashboard', fr: '/fr/dashboard' }\n *\n * // prefix-all mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { en: '/en/dashboard', fr: '/fr/dashboard' }\n *\n * // search-params mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' })\n * // Returns { en: '/dashboard?locale=en', fr: '/dashboard?locale=fr' }\n *\n * // no-prefix mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { en: '/dashboard', fr: '/dashboard' }\n * ```\n *\n * @param url - The original URL string to be processed.\n * @param options - Configuration options\n * @param options.locales - Optional array of supported locales. Defaults to configured locales.\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object mapping each locale to its corresponding multilingual URL.\n */\nexport const getMultilingualUrls = (\n url: string,\n options: {\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: RoutingConfig['mode'];\n rewrite?: RoutingConfig['rewrite'];\n } = {}\n): StrictModeLocaleMap<string> => {\n const { defaultLocale, mode, locales, rewrite } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n rewrite: configuration?.routing?.rewrite,\n ...options,\n };\n\n // Generate multilingual URLs by iterating over each locale and calling getLocalizedUrl\n const multilingualUrls = (locales ?? []).reduce<StrictModeLocaleMap<string>>(\n (acc, locale) => {\n // Get the localized URL for this locale\n const localizedUrl = getLocalizedUrl(url, locale, {\n locales,\n defaultLocale,\n mode,\n rewrite,\n });\n\n // Assign the constructed URL to the corresponding locale key\n acc[locale as unknown as keyof typeof acc] = localizedUrl;\n\n return acc;\n },\n {} as StrictModeLocaleMap<string>\n );\n\n return multilingualUrls;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getMultilingualUrls.mjs","names":[],"sources":["../../../src/localization/getMultilingualUrls.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type {\n LocalesValues,\n RoutingConfig,\n StrictModeLocaleMap,\n} from '@intlayer/types';\nimport { getLocalizedUrl } from './getLocalizedUrl';\n\n/**\n * Generates multilingual URLs by prefixing the given URL with each supported locale\n * or adding search parameters based on the routing mode.\n * Handles both absolute and relative URLs appropriately.\n *\n * This function gets the locales, default locale, and routing mode from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { en: '/dashboard', fr: '/fr/dashboard' }\n *\n * // prefix-all mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { en: '/en/dashboard', fr: '/fr/dashboard' }\n *\n * // search-params mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'search-params' })\n * // Returns { en: '/dashboard?locale=en', fr: '/dashboard?locale=fr' }\n *\n * // no-prefix mode\n * getMultilingualUrls('/dashboard', { locales: ['en', 'fr'], defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { en: '/dashboard', fr: '/dashboard' }\n * ```\n *\n * @param url - The original URL string to be processed.\n * @param options - Configuration options\n * @param options.locales - Optional array of supported locales. Defaults to configured locales.\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object mapping each locale to its corresponding multilingual URL.\n */\nexport const getMultilingualUrls = (\n url: string,\n options: {\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: RoutingConfig['mode'];\n rewrite?: RoutingConfig['rewrite'];\n } = {}\n): StrictModeLocaleMap<string> => {\n const { defaultLocale, mode, locales, rewrite } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n rewrite: configuration?.routing?.rewrite,\n ...options,\n };\n\n // Generate multilingual URLs by iterating over each locale and calling getLocalizedUrl\n const multilingualUrls = (locales ?? []).reduce<StrictModeLocaleMap<string>>(\n (acc, locale) => {\n // Get the localized URL for this locale\n const localizedUrl = getLocalizedUrl(url, locale, {\n locales,\n defaultLocale,\n mode,\n rewrite,\n });\n\n // Assign the constructed URL to the corresponding locale key\n acc[locale as unknown as keyof typeof acc] = localizedUrl;\n\n return acc;\n },\n {} as StrictModeLocaleMap<string>\n );\n\n return multilingualUrls;\n};\n"],"mappings":"sJA2CA,MAAa,GACX,EACA,EAKI,EAAE,GAC0B,CAChC,GAAM,CAAE,gBAAe,OAAM,UAAS,WAAY,CAChD,cACE,GAAe,sBAAsB,eACrC,EAAc,qBAAqB,eACrC,KAAM,GAAe,SAAS,MAAQ,EAAc,QAAQ,aAC5D,QACE,GAAe,sBAAsB,SACrC,EAAc,qBAAqB,QACrC,QAAS,GAAe,SAAS,QACjC,GAAG,EACJ,CAqBD,OAlB0B,GAAW,EAAE,EAAE,QACtC,EAAK,KAUJ,EAAI,GARiB,EAAgB,EAAK,EAAQ,CAChD,UACA,gBACA,OACA,UACD,CAAC,CAKK,GAET,EAAE,CACH"}
|
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import configuration from "@intlayer/config/built";
|
|
3
|
-
|
|
4
|
-
//#region src/localization/getPathWithoutLocale.ts
|
|
5
|
-
/**
|
|
6
|
-
* Removes the locale segment from the given URL or pathname if present.
|
|
7
|
-
* Also removes locale from search parameters if present.
|
|
8
|
-
*
|
|
9
|
-
* This function get the locales from the configuration if not provided.
|
|
10
|
-
*
|
|
11
|
-
* Example:
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* getPathWithoutLocale('/en/dashboard') // Returns '/dashboard'
|
|
15
|
-
* getPathWithoutLocale('/fr/dashboard') // Returns '/dashboard'
|
|
16
|
-
* getPathWithoutLocale('/dashboard') // Returns '/dashboard'
|
|
17
|
-
* getPathWithoutLocale('dashboard') // Returns 'dashboard'
|
|
18
|
-
* getPathWithoutLocale('/dashboard?locale=fr') // Returns '/dashboard'
|
|
19
|
-
* getPathWithoutLocale('https://example.com/en/dashboard') // Returns 'https://example.com/dashboard'
|
|
20
|
-
* getPathWithoutLocale('https://example.com/fr/dashboard') // Returns 'https://example.com/dashboard'
|
|
21
|
-
* getPathWithoutLocale('https://example.com/dashboard') // Returns 'https://example.com/dashboard'
|
|
22
|
-
* getPathWithoutLocale('https://example.com/dashboard?locale=fr') // Returns 'https://example.com/dashboard'
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @param inputUrl - The complete URL string or pathname to process.
|
|
26
|
-
* @param locales - Optional array of supported locales. Defaults to `localesDefault`.
|
|
27
|
-
* @returns The URL string or pathname without the locale segment or locale search parameter.
|
|
28
|
-
*/
|
|
29
|
-
const getPathWithoutLocale = (inputUrl, locales = configuration?.internationalization?.locales) => {
|
|
30
|
-
const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);
|
|
31
|
-
let fixedInputUrl = inputUrl;
|
|
32
|
-
if (inputUrl?.endsWith("/")) fixedInputUrl = inputUrl.slice(0, -1);
|
|
33
|
-
const url = isAbsoluteUrl ? new URL(fixedInputUrl) : new URL(fixedInputUrl, "http://example.com");
|
|
34
|
-
const pathname = url.pathname;
|
|
35
|
-
if (!pathname.startsWith("/")) url.pathname = `/${pathname}`;
|
|
36
|
-
const pathSegments = pathname.split("/");
|
|
37
|
-
const firstSegment = pathSegments[1];
|
|
38
|
-
if (locales?.includes(firstSegment)) {
|
|
39
|
-
pathSegments.splice(1, 1);
|
|
40
|
-
url.pathname = pathSegments.join("/") ?? "/";
|
|
41
|
-
}
|
|
42
|
-
const searchParams = new URLSearchParams(url.search);
|
|
43
|
-
if (searchParams.has("locale")) {
|
|
44
|
-
searchParams.delete("locale");
|
|
45
|
-
url.search = searchParams.toString();
|
|
46
|
-
}
|
|
47
|
-
if (isAbsoluteUrl) return url.toString();
|
|
48
|
-
return url.toString().replace("http://example.com", "");
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
//#endregion
|
|
52
|
-
export { getPathWithoutLocale };
|
|
1
|
+
import{checkIsURLAbsolute as e}from"../utils/checkIsURLAbsolute.mjs";import t from"@intlayer/config/built";const n=(n,r=t?.internationalization?.locales)=>{let i=e(n),a=n;n?.endsWith(`/`)&&(a=n.slice(0,-1));let o=i?new URL(a):new URL(a,`http://example.com`),s=o.pathname;s.startsWith(`/`)||(o.pathname=`/${s}`);let c=s.split(`/`),l=c[1];r?.includes(l)&&(c.splice(1,1),o.pathname=c.join(`/`)??`/`);let u=new URLSearchParams(o.search);return u.has(`locale`)&&(u.delete(`locale`),o.search=u.toString()),i?o.toString():o.toString().replace(`http://example.com`,``)};export{n as getPathWithoutLocale};
|
|
53
2
|
//# sourceMappingURL=getPathWithoutLocale.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPathWithoutLocale.mjs","names":[],"sources":["../../../src/localization/getPathWithoutLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\n\n/**\n * Removes the locale segment from the given URL or pathname if present.\n * Also removes locale from search parameters if present.\n *\n * This function get the locales from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * getPathWithoutLocale('/en/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/fr/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('dashboard') // Returns 'dashboard'\n * getPathWithoutLocale('/dashboard?locale=fr') // Returns '/dashboard'\n * getPathWithoutLocale('https://example.com/en/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/fr/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard?locale=fr') // Returns 'https://example.com/dashboard'\n * ```\n *\n * @param inputUrl - The complete URL string or pathname to process.\n * @param locales - Optional array of supported locales. Defaults to `localesDefault`.\n * @returns The URL string or pathname without the locale segment or locale search parameter.\n */\nexport const getPathWithoutLocale = (\n inputUrl: string,\n locales: LocalesValues[] = configuration?.internationalization?.locales\n): string => {\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);\n\n let fixedInputUrl = inputUrl;\n\n if (inputUrl?.endsWith('/')) {\n fixedInputUrl = inputUrl.slice(0, -1);\n }\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const url = isAbsoluteUrl\n ? new URL(fixedInputUrl)\n : new URL(fixedInputUrl, 'http://example.com');\n\n const pathname = url.pathname;\n\n // Ensure the pathname starts with '/'\n if (!pathname.startsWith('/')) {\n // If not, return the URL as is\n url.pathname = `/${pathname}`;\n }\n\n // Split the pathname to extract the first segment\n const pathSegments = pathname.split('/');\n const firstSegment = pathSegments[1]; // The segment after the first '/'\n\n // Check if the first segment is a supported locale\n if (locales?.includes(firstSegment as LocalesValues)) {\n // Remove the locale segment from the pathname\n pathSegments.splice(1, 1); // Remove the first segment\n\n // Reconstruct the pathname\n const newPathname = pathSegments.join('/') ?? '/';\n url.pathname = newPathname;\n }\n\n // Remove locale from search parameters if present\n const searchParams = new URLSearchParams(url.search);\n if (searchParams.has('locale')) {\n searchParams.delete('locale');\n url.search = searchParams.toString();\n }\n\n if (isAbsoluteUrl) {\n // Return the modified URL as a string\n return url.toString();\n }\n\n // Return the modified URL as a string\n return url.toString().replace('http://example.com', '');\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPathWithoutLocale.mjs","names":[],"sources":["../../../src/localization/getPathWithoutLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\n\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\n\n/**\n * Removes the locale segment from the given URL or pathname if present.\n * Also removes locale from search parameters if present.\n *\n * This function get the locales from the configuration if not provided.\n *\n * Example:\n *\n * ```ts\n * getPathWithoutLocale('/en/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/fr/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('/dashboard') // Returns '/dashboard'\n * getPathWithoutLocale('dashboard') // Returns 'dashboard'\n * getPathWithoutLocale('/dashboard?locale=fr') // Returns '/dashboard'\n * getPathWithoutLocale('https://example.com/en/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/fr/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard') // Returns 'https://example.com/dashboard'\n * getPathWithoutLocale('https://example.com/dashboard?locale=fr') // Returns 'https://example.com/dashboard'\n * ```\n *\n * @param inputUrl - The complete URL string or pathname to process.\n * @param locales - Optional array of supported locales. Defaults to `localesDefault`.\n * @returns The URL string or pathname without the locale segment or locale search parameter.\n */\nexport const getPathWithoutLocale = (\n inputUrl: string,\n locales: LocalesValues[] = configuration?.internationalization?.locales\n): string => {\n // Determine if the original URL is absolute (includes protocol)\n const isAbsoluteUrl = checkIsURLAbsolute(inputUrl);\n\n let fixedInputUrl = inputUrl;\n\n if (inputUrl?.endsWith('/')) {\n fixedInputUrl = inputUrl.slice(0, -1);\n }\n\n // Initialize a URL object if the URL is absolute\n // For relative URLs, use a dummy base to leverage the URL API\n const url = isAbsoluteUrl\n ? new URL(fixedInputUrl)\n : new URL(fixedInputUrl, 'http://example.com');\n\n const pathname = url.pathname;\n\n // Ensure the pathname starts with '/'\n if (!pathname.startsWith('/')) {\n // If not, return the URL as is\n url.pathname = `/${pathname}`;\n }\n\n // Split the pathname to extract the first segment\n const pathSegments = pathname.split('/');\n const firstSegment = pathSegments[1]; // The segment after the first '/'\n\n // Check if the first segment is a supported locale\n if (locales?.includes(firstSegment as LocalesValues)) {\n // Remove the locale segment from the pathname\n pathSegments.splice(1, 1); // Remove the first segment\n\n // Reconstruct the pathname\n const newPathname = pathSegments.join('/') ?? '/';\n url.pathname = newPathname;\n }\n\n // Remove locale from search parameters if present\n const searchParams = new URLSearchParams(url.search);\n if (searchParams.has('locale')) {\n searchParams.delete('locale');\n url.search = searchParams.toString();\n }\n\n if (isAbsoluteUrl) {\n // Return the modified URL as a string\n return url.toString();\n }\n\n // Return the modified URL as a string\n return url.toString().replace('http://example.com', '');\n};\n"],"mappings":"2GA6BA,MAAa,GACX,EACA,EAA2B,GAAe,sBAAsB,UACrD,CAEX,IAAM,EAAgB,EAAmB,EAAS,CAE9C,EAAgB,EAEhB,GAAU,SAAS,IAAI,GACzB,EAAgB,EAAS,MAAM,EAAG,GAAG,EAKvC,IAAM,EAAM,EACR,IAAI,IAAI,EAAc,CACtB,IAAI,IAAI,EAAe,qBAAqB,CAE1C,EAAW,EAAI,SAGhB,EAAS,WAAW,IAAI,GAE3B,EAAI,SAAW,IAAI,KAIrB,IAAM,EAAe,EAAS,MAAM,IAAI,CAClC,EAAe,EAAa,GAG9B,GAAS,SAAS,EAA8B,GAElD,EAAa,OAAO,EAAG,EAAE,CAIzB,EAAI,SADgB,EAAa,KAAK,IAAI,EAAI,KAKhD,IAAM,EAAe,IAAI,gBAAgB,EAAI,OAAO,CAYpD,OAXI,EAAa,IAAI,SAAS,GAC5B,EAAa,OAAO,SAAS,CAC7B,EAAI,OAAS,EAAa,UAAU,EAGlC,EAEK,EAAI,UAAU,CAIhB,EAAI,UAAU,CAAC,QAAQ,qBAAsB,GAAG"}
|
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import configuration from "@intlayer/config/built";
|
|
3
|
-
|
|
4
|
-
//#region src/localization/getPrefix.ts
|
|
5
|
-
/**
|
|
6
|
-
* Determines the URL prefix for a given locale based on the routing mode configuration.
|
|
7
|
-
*
|
|
8
|
-
* Example:
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* // prefix-no-default mode with default locale
|
|
12
|
-
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
13
|
-
* // Returns { prefix: '', localePrefix: undefined }
|
|
14
|
-
*
|
|
15
|
-
* // prefix-no-default mode with non-default locale
|
|
16
|
-
* getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })
|
|
17
|
-
* // Returns { prefix: '/fr', localePrefix: 'fr' }
|
|
18
|
-
*
|
|
19
|
-
* // prefix-all mode
|
|
20
|
-
* getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })
|
|
21
|
-
* // Returns { prefix: '/en', localePrefix: locale }
|
|
22
|
-
*
|
|
23
|
-
* // search-params mode
|
|
24
|
-
* getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })
|
|
25
|
-
* // Returns { prefix: '', localePrefix: undefined }
|
|
26
|
-
*
|
|
27
|
-
* // no-prefix mode
|
|
28
|
-
* getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })
|
|
29
|
-
* // Returns { prefix: '', localePrefix: undefined }
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* @param locale - The locale to check for prefix. If not provided, uses configured default locale.
|
|
33
|
-
* @param options - Configuration options
|
|
34
|
-
* @param options.defaultLocale - The default locale. Defaults to configured default locale.
|
|
35
|
-
* @param options.mode - URL routing mode for locale handling. Defaults to configured mode.
|
|
36
|
-
* @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.
|
|
37
|
-
*/
|
|
38
|
-
const getPrefix = (locale, options = {}) => {
|
|
39
|
-
const { defaultLocale, mode, locales } = {
|
|
40
|
-
defaultLocale: configuration?.internationalization?.defaultLocale ?? DefaultValues.Internationalization.DEFAULT_LOCALE,
|
|
41
|
-
mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,
|
|
42
|
-
locales: configuration?.internationalization?.locales ?? DefaultValues.Internationalization.LOCALES,
|
|
43
|
-
...options
|
|
44
|
-
};
|
|
45
|
-
if (!locale || !locales.includes(locale)) return {
|
|
46
|
-
prefix: "",
|
|
47
|
-
localePrefix: void 0
|
|
48
|
-
};
|
|
49
|
-
if (mode === "prefix-all" || mode === "prefix-no-default" && defaultLocale !== locale) return {
|
|
50
|
-
prefix: `${locale}/`,
|
|
51
|
-
localePrefix: locale
|
|
52
|
-
};
|
|
53
|
-
return {
|
|
54
|
-
prefix: "",
|
|
55
|
-
localePrefix: void 0
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
export { getPrefix };
|
|
1
|
+
import{DefaultValues as e}from"@intlayer/config/client";import t from"@intlayer/config/built";const n=(n,r={})=>{let{defaultLocale:i,mode:a,locales:o}={defaultLocale:t?.internationalization?.defaultLocale??e.Internationalization.DEFAULT_LOCALE,mode:t?.routing?.mode??e.Routing.ROUTING_MODE,locales:t?.internationalization?.locales??e.Internationalization.LOCALES,...r};return!n||!o.includes(n)?{prefix:``,localePrefix:void 0}:a===`prefix-all`||a===`prefix-no-default`&&i!==n?{prefix:`${n}/`,localePrefix:n}:{prefix:``,localePrefix:void 0}};export{n as getPrefix};
|
|
61
2
|
//# sourceMappingURL=getPrefix.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPrefix.mjs","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { Locale, LocalesValues, RoutingConfig } from '@intlayer/types';\n\nexport type GetPrefixOptions = {\n defaultLocale?: LocalesValues;\n mode?: RoutingConfig['mode'];\n};\n\nexport type GetPrefixResult = {\n /**\n * The complete base URL path with leading and trailing slashes.\n *\n * @example\n * // https://example.com/fr/about -> '/fr'\n * // https://example.com/about -> ''\n */\n prefix: string;\n /**\n * The locale identifier without slashes.\n *\n * @example\n * // https://example.com/fr/about -> 'fr'\n * // https://example.com/about -> undefined\n */\n localePrefix: Locale | undefined;\n};\n\n/**\n * Determines the URL prefix for a given locale based on the routing mode configuration.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode with default locale\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '/fr', localePrefix: 'fr' }\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { prefix: '/en', localePrefix: locale }\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { prefix: '', localePrefix: undefined }\n * ```\n *\n * @param locale - The locale to check for prefix. If not provided, uses configured default locale.\n * @param options - Configuration options\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.\n */\nexport const getPrefix = (\n locale: LocalesValues | undefined,\n options: {\n defaultLocale?: LocalesValues;\n locales?: LocalesValues[];\n mode?: RoutingConfig['mode'];\n } = {}\n): GetPrefixResult => {\n const { defaultLocale, mode, locales } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n ...options,\n };\n\n if (!locale || !locales.includes(locale)) {\n return {\n prefix: '',\n localePrefix: undefined,\n };\n }\n\n // Handle prefix-based modes (prefix-all or prefix-no-default)\n const shouldPrefix =\n mode === 'prefix-all' ||\n (mode === 'prefix-no-default' && defaultLocale !== locale);\n\n if (shouldPrefix) {\n return {\n prefix: `${locale}/`,\n localePrefix: locale as Locale,\n };\n }\n\n return {\n prefix: '',\n localePrefix: undefined,\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPrefix.mjs","names":[],"sources":["../../../src/localization/getPrefix.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport type { Locale, LocalesValues, RoutingConfig } from '@intlayer/types';\n\nexport type GetPrefixOptions = {\n defaultLocale?: LocalesValues;\n mode?: RoutingConfig['mode'];\n};\n\nexport type GetPrefixResult = {\n /**\n * The complete base URL path with leading and trailing slashes.\n *\n * @example\n * // https://example.com/fr/about -> '/fr'\n * // https://example.com/about -> ''\n */\n prefix: string;\n /**\n * The locale identifier without slashes.\n *\n * @example\n * // https://example.com/fr/about -> 'fr'\n * // https://example.com/about -> undefined\n */\n localePrefix: Locale | undefined;\n};\n\n/**\n * Determines the URL prefix for a given locale based on the routing mode configuration.\n *\n * Example:\n *\n * ```ts\n * // prefix-no-default mode with default locale\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // prefix-no-default mode with non-default locale\n * getPrefix('fr', { defaultLocale: 'en', mode: 'prefix-no-default' })\n * // Returns { prefix: '/fr', localePrefix: 'fr' }\n *\n * // prefix-all mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'prefix-all' })\n * // Returns { prefix: '/en', localePrefix: locale }\n *\n * // search-params mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'search-params' })\n * // Returns { prefix: '', localePrefix: undefined }\n *\n * // no-prefix mode\n * getPrefix('en', { defaultLocale: 'en', mode: 'no-prefix' })\n * // Returns { prefix: '', localePrefix: undefined }\n * ```\n *\n * @param locale - The locale to check for prefix. If not provided, uses configured default locale.\n * @param options - Configuration options\n * @param options.defaultLocale - The default locale. Defaults to configured default locale.\n * @param options.mode - URL routing mode for locale handling. Defaults to configured mode.\n * @returns An object containing pathPrefix, prefix, and localePrefix for the given locale.\n */\nexport const getPrefix = (\n locale: LocalesValues | undefined,\n options: {\n defaultLocale?: LocalesValues;\n locales?: LocalesValues[];\n mode?: RoutingConfig['mode'];\n } = {}\n): GetPrefixResult => {\n const { defaultLocale, mode, locales } = {\n defaultLocale:\n configuration?.internationalization?.defaultLocale ??\n DefaultValues.Internationalization.DEFAULT_LOCALE,\n mode: configuration?.routing?.mode ?? DefaultValues.Routing.ROUTING_MODE,\n locales:\n configuration?.internationalization?.locales ??\n DefaultValues.Internationalization.LOCALES,\n ...options,\n };\n\n if (!locale || !locales.includes(locale)) {\n return {\n prefix: '',\n localePrefix: undefined,\n };\n }\n\n // Handle prefix-based modes (prefix-all or prefix-no-default)\n const shouldPrefix =\n mode === 'prefix-all' ||\n (mode === 'prefix-no-default' && defaultLocale !== locale);\n\n if (shouldPrefix) {\n return {\n prefix: `${locale}/`,\n localePrefix: locale as Locale,\n };\n }\n\n return {\n prefix: '',\n localePrefix: undefined,\n };\n};\n"],"mappings":"8FA6DA,MAAa,GACX,EACA,EAII,EAAE,GACc,CACpB,GAAM,CAAE,gBAAe,OAAM,WAAY,CACvC,cACE,GAAe,sBAAsB,eACrC,EAAc,qBAAqB,eACrC,KAAM,GAAe,SAAS,MAAQ,EAAc,QAAQ,aAC5D,QACE,GAAe,sBAAsB,SACrC,EAAc,qBAAqB,QACrC,GAAG,EACJ,CAqBD,MAnBI,CAAC,GAAU,CAAC,EAAQ,SAAS,EAAO,CAC/B,CACL,OAAQ,GACR,aAAc,IAAA,GACf,CAKD,IAAS,cACR,IAAS,qBAAuB,IAAkB,EAG5C,CACL,OAAQ,GAAG,EAAO,GAClB,aAAc,EACf,CAGI,CACL,OAAQ,GACR,aAAc,IAAA,GACf"}
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
import { localeResolver } from "./
|
|
2
|
-
import { localeDetector } from "./localeDetector.mjs";
|
|
3
|
-
import { getBrowserLocale, localeStorageOptions } from "./getBrowserLocale.mjs";
|
|
4
|
-
import { getHTMLTextDir } from "./getHTMLTextDir.mjs";
|
|
5
|
-
import { getLocale } from "./getLocale.mjs";
|
|
6
|
-
import { getLocaleFromPath } from "./getLocaleFromPath.mjs";
|
|
7
|
-
import { getLocaleLang } from "./getLocaleLang.mjs";
|
|
8
|
-
import { getLocaleName } from "./getLocaleName.mjs";
|
|
9
|
-
import { getPathWithoutLocale } from "./getPathWithoutLocale.mjs";
|
|
10
|
-
import { getPrefix } from "./getPrefix.mjs";
|
|
11
|
-
import { getCanonicalPath, getInternalPath, getLocalizedPath, getRewritePath, getRewriteRules } from "./rewriteUtils.mjs";
|
|
12
|
-
import { getLocalizedUrl } from "./getLocalizedUrl.mjs";
|
|
13
|
-
import { getMultilingualUrls } from "./getMultilingualUrls.mjs";
|
|
14
|
-
import { localeFlatMap, localeMap, localeRecord } from "./localeMapper.mjs";
|
|
15
|
-
import { validatePrefix } from "./validatePrefix.mjs";
|
|
16
|
-
|
|
17
|
-
export { getBrowserLocale, getCanonicalPath, getHTMLTextDir, getInternalPath, getLocale, getLocaleFromPath, getLocaleLang, getLocaleName, getLocalizedPath, getLocalizedUrl, getMultilingualUrls, getPathWithoutLocale, getPrefix, getRewritePath, getRewriteRules, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, validatePrefix };
|
|
1
|
+
import{getStorageAttributes as e}from"../getStorageAttributes.mjs";import{localeResolver as t}from"./localeResolver.mjs";import{localeDetector as n}from"./localeDetector.mjs";import{getBrowserLocale as r,localeStorageOptions as i}from"./getBrowserLocale.mjs";import{getHTMLTextDir as a}from"./getHTMLTextDir.mjs";import{getLocale as o}from"./getLocale.mjs";import{getLocaleFromPath as s}from"./getLocaleFromPath.mjs";import{getLocaleLang as c}from"./getLocaleLang.mjs";import{getLocaleName as l}from"./getLocaleName.mjs";import{getPathWithoutLocale as u}from"./getPathWithoutLocale.mjs";import{getPrefix as d}from"./getPrefix.mjs";import{getCanonicalPath as f,getInternalPath as p,getLocalizedPath as m,getRewritePath as h,getRewriteRules as g}from"./rewriteUtils.mjs";import{getLocalizedUrl as _}from"./getLocalizedUrl.mjs";import{getMultilingualUrls as v}from"./getMultilingualUrls.mjs";import{localeFlatMap as y,localeMap as b,localeRecord as x}from"./localeMapper.mjs";import{validatePrefix as S}from"./validatePrefix.mjs";export{r as getBrowserLocale,f as getCanonicalPath,a as getHTMLTextDir,p as getInternalPath,o as getLocale,s as getLocaleFromPath,c as getLocaleLang,l as getLocaleName,m as getLocalizedPath,_ as getLocalizedUrl,v as getMultilingualUrls,u as getPathWithoutLocale,d as getPrefix,h as getRewritePath,g as getRewriteRules,e as getStorageAttributes,n as localeDetector,y as localeFlatMap,b as localeMap,x as localeRecord,t as localeResolver,i as localeStorageOptions,S as validatePrefix};
|
|
@@ -1,132 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/localization/localeDetector.ts
|
|
4
|
-
/**
|
|
5
|
-
* Constants
|
|
6
|
-
*/
|
|
7
|
-
const LANGUAGE_FORMAT_REGULAR_EXPRESSION = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
|
|
8
|
-
const DEFAULT_QUALITY_SCORE = 1;
|
|
9
|
-
/**
|
|
10
|
-
* Enumeration for specificity weights.
|
|
11
|
-
* Higher values indicate a more precise match.
|
|
12
|
-
*/
|
|
13
|
-
var SpecificityWeight = /* @__PURE__ */ function(SpecificityWeight) {
|
|
14
|
-
SpecificityWeight[SpecificityWeight["None"] = 0] = "None";
|
|
15
|
-
SpecificityWeight[SpecificityWeight["Broad"] = 1] = "Broad";
|
|
16
|
-
SpecificityWeight[SpecificityWeight["Prefix"] = 2] = "Prefix";
|
|
17
|
-
SpecificityWeight[SpecificityWeight["Exact"] = 4] = "Exact";
|
|
18
|
-
return SpecificityWeight;
|
|
19
|
-
}(SpecificityWeight || {});
|
|
20
|
-
/**
|
|
21
|
-
* Parses a single language tag string from the Accept-Language header.
|
|
22
|
-
* Example input: "en-US;q=0.8"
|
|
23
|
-
*/
|
|
24
|
-
const parseLanguageTag = (tagString, index) => {
|
|
25
|
-
const match = LANGUAGE_FORMAT_REGULAR_EXPRESSION.exec(tagString);
|
|
26
|
-
if (!match) return null;
|
|
27
|
-
const languageCode = match[1];
|
|
28
|
-
const regionCode = match[2];
|
|
29
|
-
const parameters = match[3];
|
|
30
|
-
const fullLocale = regionCode ? `${languageCode}-${regionCode}` : languageCode;
|
|
31
|
-
let qualityScore = DEFAULT_QUALITY_SCORE;
|
|
32
|
-
if (parameters) {
|
|
33
|
-
const parameterList = parameters.split(";");
|
|
34
|
-
for (const parameter of parameterList) {
|
|
35
|
-
const [key, value] = parameter.split("=");
|
|
36
|
-
if (key === "q") qualityScore = parseFloat(value);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
languageCode,
|
|
41
|
-
regionCode,
|
|
42
|
-
qualityScore,
|
|
43
|
-
originalIndex: index,
|
|
44
|
-
fullLocale
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Parses the entire Accept-Language header string into a list of preferences.
|
|
49
|
-
*/
|
|
50
|
-
const parseAcceptLanguageHeader = (headerValue) => {
|
|
51
|
-
const rawTags = headerValue.split(",");
|
|
52
|
-
const preferences = [];
|
|
53
|
-
for (let index = 0; index < rawTags.length; index++) {
|
|
54
|
-
const parsedLanguage = parseLanguageTag(rawTags[index].trim(), index);
|
|
55
|
-
if (parsedLanguage) preferences.push(parsedLanguage);
|
|
56
|
-
}
|
|
57
|
-
return preferences;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Calculates the specificity of a match between a provided language and a requested preference.
|
|
61
|
-
*/
|
|
62
|
-
const calculateMatchSpecificity = (providedLanguage, preference, providedIndex) => {
|
|
63
|
-
const parsedProvided = parseLanguageTag(providedLanguage, providedIndex);
|
|
64
|
-
if (!parsedProvided) return null;
|
|
65
|
-
let specificityScore = SpecificityWeight.None;
|
|
66
|
-
const preferenceFullLower = preference.fullLocale.toLowerCase();
|
|
67
|
-
const preferencePrefixLower = preference.languageCode.toLowerCase();
|
|
68
|
-
const providedFullLower = parsedProvided.fullLocale.toLowerCase();
|
|
69
|
-
const providedPrefixLower = parsedProvided.languageCode.toLowerCase();
|
|
70
|
-
if (preferenceFullLower === providedFullLower) specificityScore |= SpecificityWeight.Exact;
|
|
71
|
-
else if (preferencePrefixLower === providedFullLower) specificityScore |= SpecificityWeight.Prefix;
|
|
72
|
-
else if (preferenceFullLower === providedPrefixLower) specificityScore |= SpecificityWeight.Broad;
|
|
73
|
-
else if (preference.fullLocale !== "*") return null;
|
|
74
|
-
return {
|
|
75
|
-
providedIndex,
|
|
76
|
-
headerIndex: preference.originalIndex,
|
|
77
|
-
qualityScore: preference.qualityScore,
|
|
78
|
-
specificityScore
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Determines the best match for a specific available language against the list of user accepted languages.
|
|
83
|
-
*/
|
|
84
|
-
const getBestMatchForLanguage = (providedLanguage, acceptedPreferences, providedIndex) => {
|
|
85
|
-
let bestMatch = {
|
|
86
|
-
headerIndex: -1,
|
|
87
|
-
qualityScore: 0,
|
|
88
|
-
specificityScore: 0,
|
|
89
|
-
providedIndex
|
|
90
|
-
};
|
|
91
|
-
for (const preference of acceptedPreferences) {
|
|
92
|
-
const matchSpec = calculateMatchSpecificity(providedLanguage, preference, providedIndex);
|
|
93
|
-
if (matchSpec) {
|
|
94
|
-
if ((bestMatch.specificityScore - matchSpec.specificityScore || bestMatch.qualityScore - matchSpec.qualityScore || bestMatch.headerIndex - matchSpec.headerIndex) < 0) bestMatch = matchSpec;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return bestMatch;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Comparator function to sort language matches.
|
|
101
|
-
* Sorting order:
|
|
102
|
-
* 1. Quality Score (Descending)
|
|
103
|
-
* 2. Specificity Score (Descending)
|
|
104
|
-
* 3. Order in Header (Ascending - lower index is better)
|
|
105
|
-
* 4. Order in Provided List (Ascending)
|
|
106
|
-
*/
|
|
107
|
-
const compareMatchResults = (a, b) => {
|
|
108
|
-
return b.qualityScore - a.qualityScore || b.specificityScore - a.specificityScore || a.headerIndex - b.headerIndex || a.providedIndex - b.providedIndex || 0;
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Derives the list of preferred languages based on the Accept-Language header
|
|
112
|
-
* and an optional list of available languages.
|
|
113
|
-
*/
|
|
114
|
-
const getPreferredLanguages = (acceptHeader, availableLanguages) => {
|
|
115
|
-
const acceptedPreferences = parseAcceptLanguageHeader(acceptHeader === void 0 ? "*" : acceptHeader || "");
|
|
116
|
-
if (!availableLanguages) return acceptedPreferences.filter((preference) => preference.qualityScore > 0).sort((a, b) => b.qualityScore - a.qualityScore).map((preference) => preference.fullLocale);
|
|
117
|
-
return availableLanguages.map((language, index) => getBestMatchForLanguage(language, acceptedPreferences, index)).filter((result) => result.qualityScore > 0).sort(compareMatchResults).map((result) => availableLanguages[result.providedIndex]);
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Detects the locale from the request headers.
|
|
121
|
-
*
|
|
122
|
-
* Headers are provided by the browser/client and can be used to determine the user's preferred language.
|
|
123
|
-
* This function intersects the user's `Accept-Language` header with the application's available locales.
|
|
124
|
-
*/
|
|
125
|
-
const localeDetector = (headers, availableLocales, defaultLocale) => {
|
|
126
|
-
const acceptLanguageHeader = headers["accept-language"];
|
|
127
|
-
return localeResolver(getPreferredLanguages(acceptLanguageHeader, availableLocales), availableLocales, defaultLocale);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
//#endregion
|
|
131
|
-
export { getPreferredLanguages, localeDetector };
|
|
1
|
+
import{localeResolver as e}from"./localeResolver.mjs";const t=/^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;var n=function(e){return e[e.None=0]=`None`,e[e.Broad=1]=`Broad`,e[e.Prefix=2]=`Prefix`,e[e.Exact=4]=`Exact`,e}(n||{});const r=(e,n)=>{let r=t.exec(e);if(!r)return null;let i=r[1],a=r[2],o=r[3],s=a?`${i}-${a}`:i,c=1;if(o){let e=o.split(`;`);for(let t of e){let[e,n]=t.split(`=`);e===`q`&&(c=parseFloat(n))}}return{languageCode:i,regionCode:a,qualityScore:c,originalIndex:n,fullLocale:s}},i=e=>{let t=e.split(`,`),n=[];for(let e=0;e<t.length;e++){let i=r(t[e].trim(),e);i&&n.push(i)}return n},a=(e,t,i)=>{let a=r(e,i);if(!a)return null;let o=n.None,s=t.fullLocale.toLowerCase(),c=t.languageCode.toLowerCase(),l=a.fullLocale.toLowerCase(),u=a.languageCode.toLowerCase();if(s===l)o|=n.Exact;else if(c===l)o|=n.Prefix;else if(s===u)o|=n.Broad;else if(t.fullLocale!==`*`)return null;return{providedIndex:i,headerIndex:t.originalIndex,qualityScore:t.qualityScore,specificityScore:o}},o=(e,t,n)=>{let r={headerIndex:-1,qualityScore:0,specificityScore:0,providedIndex:n};for(let i of t){let t=a(e,i,n);t&&(r.specificityScore-t.specificityScore||r.qualityScore-t.qualityScore||r.headerIndex-t.headerIndex)<0&&(r=t)}return r},s=(e,t)=>t.qualityScore-e.qualityScore||t.specificityScore-e.specificityScore||e.headerIndex-t.headerIndex||e.providedIndex-t.providedIndex||0,c=(e,t)=>{let n=i(e===void 0?`*`:e||``);return t?t.map((e,t)=>o(e,n,t)).filter(e=>e.qualityScore>0).sort(s).map(e=>t[e.providedIndex]):n.filter(e=>e.qualityScore>0).sort((e,t)=>t.qualityScore-e.qualityScore).map(e=>e.fullLocale)},l=(t,n,r)=>{let i=t[`accept-language`];return e(c(i,n),n,r)};export{c as getPreferredLanguages,l as localeDetector};
|
|
132
2
|
//# sourceMappingURL=localeDetector.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeDetector.mjs","names":[],"sources":["../../../src/localization/localeDetector.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types';\nimport { localeResolver } from './localeResolver';\n\n/**\n * Constants\n */\nconst LANGUAGE_FORMAT_REGULAR_EXPRESSION =\n /^\\s*([^\\s\\-;]+)(?:-([^\\s;]+))?\\s*(?:;(.*))?$/;\nconst DEFAULT_QUALITY_SCORE = 1;\n\n/**\n * Enumeration for specificity weights.\n * Higher values indicate a more precise match.\n */\nenum SpecificityWeight {\n None = 0,\n Broad = 1, // Matches prefix (e.g., 'en' matches 'en-US')\n Prefix = 2, // Matches prefix in reverse (e.g., 'en-US' matches 'en')\n Exact = 4, // Matches exact string (e.g., 'en-US' matches 'en-US')\n}\n\n/**\n * Represents a parsed language tag from the header.\n */\ntype LanguagePreference = {\n languageCode: string;\n regionCode?: string;\n fullLocale: string;\n qualityScore: number;\n originalIndex: number;\n};\n\n/**\n * Represents the result of matching a requested language against an available language.\n */\ntype MatchResult = {\n providedIndex: number;\n headerIndex: number;\n qualityScore: number;\n specificityScore: number;\n};\n\n/**\n * Parses a single language tag string from the Accept-Language header.\n * Example input: \"en-US;q=0.8\"\n */\nconst parseLanguageTag = (\n tagString: string,\n index: number\n): LanguagePreference | null => {\n const match = LANGUAGE_FORMAT_REGULAR_EXPRESSION.exec(tagString);\n if (!match) {\n return null;\n }\n\n const languageCode = match[1];\n const regionCode = match[2];\n const parameters = match[3];\n\n // Construct the full locale string (e.g., \"en-US\" or \"en\")\n const fullLocale = regionCode\n ? `${languageCode}-${regionCode}`\n : languageCode;\n\n let qualityScore = DEFAULT_QUALITY_SCORE;\n\n // Parse parameters to find the quality score (\"q\")\n if (parameters) {\n const parameterList = parameters.split(';');\n for (const parameter of parameterList) {\n const [key, value] = parameter.split('=');\n if (key === 'q') {\n qualityScore = parseFloat(value);\n }\n }\n }\n\n return {\n languageCode,\n regionCode,\n qualityScore,\n originalIndex: index,\n fullLocale,\n };\n};\n\n/**\n * Parses the entire Accept-Language header string into a list of preferences.\n */\nconst parseAcceptLanguageHeader = (\n headerValue: string\n): LanguagePreference[] => {\n const rawTags = headerValue.split(',');\n const preferences: LanguagePreference[] = [];\n\n for (let index = 0; index < rawTags.length; index++) {\n const tag = rawTags[index].trim();\n const parsedLanguage = parseLanguageTag(tag, index);\n\n if (parsedLanguage) {\n preferences.push(parsedLanguage);\n }\n }\n\n return preferences;\n};\n\n/**\n * Calculates the specificity of a match between a provided language and a requested preference.\n */\nconst calculateMatchSpecificity = (\n providedLanguage: string,\n preference: LanguagePreference,\n providedIndex: number\n): MatchResult | null => {\n const parsedProvided = parseLanguageTag(providedLanguage, providedIndex);\n if (!parsedProvided) {\n return null;\n }\n\n let specificityScore = SpecificityWeight.None;\n\n const preferenceFullLower = preference.fullLocale.toLowerCase();\n const preferencePrefixLower = preference.languageCode.toLowerCase();\n const providedFullLower = parsedProvided.fullLocale.toLowerCase();\n const providedPrefixLower = parsedProvided.languageCode.toLowerCase();\n\n if (preferenceFullLower === providedFullLower) {\n specificityScore |= SpecificityWeight.Exact;\n } else if (preferencePrefixLower === providedFullLower) {\n specificityScore |= SpecificityWeight.Prefix;\n } else if (preferenceFullLower === providedPrefixLower) {\n specificityScore |= SpecificityWeight.Broad;\n } else if (preference.fullLocale !== '*') {\n return null;\n }\n\n return {\n providedIndex,\n headerIndex: preference.originalIndex,\n qualityScore: preference.qualityScore,\n specificityScore,\n };\n};\n\n/**\n * Determines the best match for a specific available language against the list of user accepted languages.\n */\nconst getBestMatchForLanguage = (\n providedLanguage: string,\n acceptedPreferences: LanguagePreference[],\n providedIndex: number\n): MatchResult => {\n // Initialize with a non-match priority\n let bestMatch: MatchResult = {\n headerIndex: -1,\n qualityScore: 0,\n specificityScore: 0,\n providedIndex,\n };\n\n for (const preference of acceptedPreferences) {\n const matchSpec = calculateMatchSpecificity(\n providedLanguage,\n preference,\n providedIndex\n );\n\n if (matchSpec) {\n // Compare current best match with new match\n const scoreDifference =\n bestMatch.specificityScore - matchSpec.specificityScore ||\n bestMatch.qualityScore - matchSpec.qualityScore ||\n bestMatch.headerIndex - matchSpec.headerIndex;\n\n // If the new match is better (difference < 0), update priority\n if (scoreDifference < 0) {\n bestMatch = matchSpec;\n }\n }\n }\n\n return bestMatch;\n};\n\n/**\n * Comparator function to sort language matches.\n * Sorting order:\n * 1. Quality Score (Descending)\n * 2. Specificity Score (Descending)\n * 3. Order in Header (Ascending - lower index is better)\n * 4. Order in Provided List (Ascending)\n */\nconst compareMatchResults = (a: MatchResult, b: MatchResult): number => {\n return (\n b.qualityScore - a.qualityScore ||\n b.specificityScore - a.specificityScore ||\n a.headerIndex - b.headerIndex ||\n a.providedIndex - b.providedIndex ||\n 0\n );\n};\n\n/**\n * Derives the list of preferred languages based on the Accept-Language header\n * and an optional list of available languages.\n */\nexport const getPreferredLanguages = (\n acceptHeader: string | undefined,\n availableLanguages?: string[]\n): string[] => {\n // RFC 2616 sec 14.4: no header implies '*'\n const headerValue = acceptHeader === undefined ? '*' : acceptHeader || '';\n const acceptedPreferences = parseAcceptLanguageHeader(headerValue);\n\n // If no specific languages are provided to filter against, return the header languages sorted by quality\n if (!availableLanguages) {\n return acceptedPreferences\n .filter((preference) => preference.qualityScore > 0)\n .sort((a, b) => b.qualityScore - a.qualityScore) // Simple sort by quality\n .map((preference) => preference.fullLocale);\n }\n\n // Map available languages to their match priority against the header\n const matchResults = availableLanguages.map((language, index) =>\n getBestMatchForLanguage(language, acceptedPreferences, index)\n );\n\n return matchResults\n .filter((result) => result.qualityScore > 0)\n .sort(compareMatchResults)\n .map((result) => availableLanguages[result.providedIndex]);\n};\n\n/**\n * Detects the locale from the request headers.\n *\n * Headers are provided by the browser/client and can be used to determine the user's preferred language.\n * This function intersects the user's `Accept-Language` header with the application's available locales.\n */\nexport const localeDetector = (\n headers: Record<string, string | undefined>,\n availableLocales?: Locale[],\n defaultLocale?: Locale\n): Locale => {\n const acceptLanguageHeader = headers['accept-language'];\n\n const preferredLocaleStrings = getPreferredLanguages(\n acceptLanguageHeader,\n availableLocales as string[]\n );\n\n return localeResolver(\n preferredLocaleStrings as Locale[],\n availableLocales,\n defaultLocale\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeDetector.mjs","names":[],"sources":["../../../src/localization/localeDetector.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types';\nimport { localeResolver } from './localeResolver';\n\n/**\n * Constants\n */\nconst LANGUAGE_FORMAT_REGULAR_EXPRESSION =\n /^\\s*([^\\s\\-;]+)(?:-([^\\s;]+))?\\s*(?:;(.*))?$/;\nconst DEFAULT_QUALITY_SCORE = 1;\n\n/**\n * Enumeration for specificity weights.\n * Higher values indicate a more precise match.\n */\nenum SpecificityWeight {\n None = 0,\n Broad = 1, // Matches prefix (e.g., 'en' matches 'en-US')\n Prefix = 2, // Matches prefix in reverse (e.g., 'en-US' matches 'en')\n Exact = 4, // Matches exact string (e.g., 'en-US' matches 'en-US')\n}\n\n/**\n * Represents a parsed language tag from the header.\n */\ntype LanguagePreference = {\n languageCode: string;\n regionCode?: string;\n fullLocale: string;\n qualityScore: number;\n originalIndex: number;\n};\n\n/**\n * Represents the result of matching a requested language against an available language.\n */\ntype MatchResult = {\n providedIndex: number;\n headerIndex: number;\n qualityScore: number;\n specificityScore: number;\n};\n\n/**\n * Parses a single language tag string from the Accept-Language header.\n * Example input: \"en-US;q=0.8\"\n */\nconst parseLanguageTag = (\n tagString: string,\n index: number\n): LanguagePreference | null => {\n const match = LANGUAGE_FORMAT_REGULAR_EXPRESSION.exec(tagString);\n if (!match) {\n return null;\n }\n\n const languageCode = match[1];\n const regionCode = match[2];\n const parameters = match[3];\n\n // Construct the full locale string (e.g., \"en-US\" or \"en\")\n const fullLocale = regionCode\n ? `${languageCode}-${regionCode}`\n : languageCode;\n\n let qualityScore = DEFAULT_QUALITY_SCORE;\n\n // Parse parameters to find the quality score (\"q\")\n if (parameters) {\n const parameterList = parameters.split(';');\n for (const parameter of parameterList) {\n const [key, value] = parameter.split('=');\n if (key === 'q') {\n qualityScore = parseFloat(value);\n }\n }\n }\n\n return {\n languageCode,\n regionCode,\n qualityScore,\n originalIndex: index,\n fullLocale,\n };\n};\n\n/**\n * Parses the entire Accept-Language header string into a list of preferences.\n */\nconst parseAcceptLanguageHeader = (\n headerValue: string\n): LanguagePreference[] => {\n const rawTags = headerValue.split(',');\n const preferences: LanguagePreference[] = [];\n\n for (let index = 0; index < rawTags.length; index++) {\n const tag = rawTags[index].trim();\n const parsedLanguage = parseLanguageTag(tag, index);\n\n if (parsedLanguage) {\n preferences.push(parsedLanguage);\n }\n }\n\n return preferences;\n};\n\n/**\n * Calculates the specificity of a match between a provided language and a requested preference.\n */\nconst calculateMatchSpecificity = (\n providedLanguage: string,\n preference: LanguagePreference,\n providedIndex: number\n): MatchResult | null => {\n const parsedProvided = parseLanguageTag(providedLanguage, providedIndex);\n if (!parsedProvided) {\n return null;\n }\n\n let specificityScore = SpecificityWeight.None;\n\n const preferenceFullLower = preference.fullLocale.toLowerCase();\n const preferencePrefixLower = preference.languageCode.toLowerCase();\n const providedFullLower = parsedProvided.fullLocale.toLowerCase();\n const providedPrefixLower = parsedProvided.languageCode.toLowerCase();\n\n if (preferenceFullLower === providedFullLower) {\n specificityScore |= SpecificityWeight.Exact;\n } else if (preferencePrefixLower === providedFullLower) {\n specificityScore |= SpecificityWeight.Prefix;\n } else if (preferenceFullLower === providedPrefixLower) {\n specificityScore |= SpecificityWeight.Broad;\n } else if (preference.fullLocale !== '*') {\n return null;\n }\n\n return {\n providedIndex,\n headerIndex: preference.originalIndex,\n qualityScore: preference.qualityScore,\n specificityScore,\n };\n};\n\n/**\n * Determines the best match for a specific available language against the list of user accepted languages.\n */\nconst getBestMatchForLanguage = (\n providedLanguage: string,\n acceptedPreferences: LanguagePreference[],\n providedIndex: number\n): MatchResult => {\n // Initialize with a non-match priority\n let bestMatch: MatchResult = {\n headerIndex: -1,\n qualityScore: 0,\n specificityScore: 0,\n providedIndex,\n };\n\n for (const preference of acceptedPreferences) {\n const matchSpec = calculateMatchSpecificity(\n providedLanguage,\n preference,\n providedIndex\n );\n\n if (matchSpec) {\n // Compare current best match with new match\n const scoreDifference =\n bestMatch.specificityScore - matchSpec.specificityScore ||\n bestMatch.qualityScore - matchSpec.qualityScore ||\n bestMatch.headerIndex - matchSpec.headerIndex;\n\n // If the new match is better (difference < 0), update priority\n if (scoreDifference < 0) {\n bestMatch = matchSpec;\n }\n }\n }\n\n return bestMatch;\n};\n\n/**\n * Comparator function to sort language matches.\n * Sorting order:\n * 1. Quality Score (Descending)\n * 2. Specificity Score (Descending)\n * 3. Order in Header (Ascending - lower index is better)\n * 4. Order in Provided List (Ascending)\n */\nconst compareMatchResults = (a: MatchResult, b: MatchResult): number => {\n return (\n b.qualityScore - a.qualityScore ||\n b.specificityScore - a.specificityScore ||\n a.headerIndex - b.headerIndex ||\n a.providedIndex - b.providedIndex ||\n 0\n );\n};\n\n/**\n * Derives the list of preferred languages based on the Accept-Language header\n * and an optional list of available languages.\n */\nexport const getPreferredLanguages = (\n acceptHeader: string | undefined,\n availableLanguages?: string[]\n): string[] => {\n // RFC 2616 sec 14.4: no header implies '*'\n const headerValue = acceptHeader === undefined ? '*' : acceptHeader || '';\n const acceptedPreferences = parseAcceptLanguageHeader(headerValue);\n\n // If no specific languages are provided to filter against, return the header languages sorted by quality\n if (!availableLanguages) {\n return acceptedPreferences\n .filter((preference) => preference.qualityScore > 0)\n .sort((a, b) => b.qualityScore - a.qualityScore) // Simple sort by quality\n .map((preference) => preference.fullLocale);\n }\n\n // Map available languages to their match priority against the header\n const matchResults = availableLanguages.map((language, index) =>\n getBestMatchForLanguage(language, acceptedPreferences, index)\n );\n\n return matchResults\n .filter((result) => result.qualityScore > 0)\n .sort(compareMatchResults)\n .map((result) => availableLanguages[result.providedIndex]);\n};\n\n/**\n * Detects the locale from the request headers.\n *\n * Headers are provided by the browser/client and can be used to determine the user's preferred language.\n * This function intersects the user's `Accept-Language` header with the application's available locales.\n */\nexport const localeDetector = (\n headers: Record<string, string | undefined>,\n availableLocales?: Locale[],\n defaultLocale?: Locale\n): Locale => {\n const acceptLanguageHeader = headers['accept-language'];\n\n const preferredLocaleStrings = getPreferredLanguages(\n acceptLanguageHeader,\n availableLocales as string[]\n );\n\n return localeResolver(\n preferredLocaleStrings as Locale[],\n availableLocales,\n defaultLocale\n );\n};\n"],"mappings":"sDAMA,MAAM,EACJ,+CAOF,IAAK,EAAA,SAAA,EAAL,OACE,GAAA,EAAA,KAAA,GAAA,OACA,EAAA,EAAA,MAAA,GAAA,QACA,EAAA,EAAA,OAAA,GAAA,SACA,EAAA,EAAA,MAAA,GAAA,WAJG,GAAA,EAAA,CAAA,CAgCL,MAAM,GACJ,EACA,IAC8B,CAC9B,IAAM,EAAQ,EAAmC,KAAK,EAAU,CAChE,GAAI,CAAC,EACH,OAAO,KAGT,IAAM,EAAe,EAAM,GACrB,EAAa,EAAM,GACnB,EAAa,EAAM,GAGnB,EAAa,EACf,GAAG,EAAa,GAAG,IACnB,EAEA,EAAe,EAGnB,GAAI,EAAY,CACd,IAAM,EAAgB,EAAW,MAAM,IAAI,CAC3C,IAAK,IAAM,KAAa,EAAe,CACrC,GAAM,CAAC,EAAK,GAAS,EAAU,MAAM,IAAI,CACrC,IAAQ,MACV,EAAe,WAAW,EAAM,GAKtC,MAAO,CACL,eACA,aACA,eACA,cAAe,EACf,aACD,EAMG,EACJ,GACyB,CACzB,IAAM,EAAU,EAAY,MAAM,IAAI,CAChC,EAAoC,EAAE,CAE5C,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAQ,OAAQ,IAAS,CAEnD,IAAM,EAAiB,EADX,EAAQ,GAAO,MAAM,CACY,EAAM,CAE/C,GACF,EAAY,KAAK,EAAe,CAIpC,OAAO,GAMH,GACJ,EACA,EACA,IACuB,CACvB,IAAM,EAAiB,EAAiB,EAAkB,EAAc,CACxE,GAAI,CAAC,EACH,OAAO,KAGT,IAAI,EAAmB,EAAkB,KAEnC,EAAsB,EAAW,WAAW,aAAa,CACzD,EAAwB,EAAW,aAAa,aAAa,CAC7D,EAAoB,EAAe,WAAW,aAAa,CAC3D,EAAsB,EAAe,aAAa,aAAa,CAErE,GAAI,IAAwB,EAC1B,GAAoB,EAAkB,cAC7B,IAA0B,EACnC,GAAoB,EAAkB,eAC7B,IAAwB,EACjC,GAAoB,EAAkB,cAC7B,EAAW,aAAe,IACnC,OAAO,KAGT,MAAO,CACL,gBACA,YAAa,EAAW,cACxB,aAAc,EAAW,aACzB,mBACD,EAMG,GACJ,EACA,EACA,IACgB,CAEhB,IAAI,EAAyB,CAC3B,YAAa,GACb,aAAc,EACd,iBAAkB,EAClB,gBACD,CAED,IAAK,IAAM,KAAc,EAAqB,CAC5C,IAAM,EAAY,EAChB,EACA,EACA,EACD,CAEG,IAGA,EAAU,iBAAmB,EAAU,kBACvC,EAAU,aAAe,EAAU,cACnC,EAAU,YAAc,EAAU,aAGd,IACpB,EAAY,GAKlB,OAAO,GAWH,GAAuB,EAAgB,IAEzC,EAAE,aAAe,EAAE,cACnB,EAAE,iBAAmB,EAAE,kBACvB,EAAE,YAAc,EAAE,aAClB,EAAE,cAAgB,EAAE,eACpB,EAQS,GACX,EACA,IACa,CAGb,IAAM,EAAsB,EADR,IAAiB,IAAA,GAAY,IAAM,GAAgB,GACL,CAelE,OAZK,EAQgB,EAAmB,KAAK,EAAU,IACrD,EAAwB,EAAU,EAAqB,EAAM,CAC9D,CAGE,OAAQ,GAAW,EAAO,aAAe,EAAE,CAC3C,KAAK,EAAoB,CACzB,IAAK,GAAW,EAAmB,EAAO,eAAe,CAdnD,EACJ,OAAQ,GAAe,EAAW,aAAe,EAAE,CACnD,MAAM,EAAG,IAAM,EAAE,aAAe,EAAE,aAAa,CAC/C,IAAK,GAAe,EAAW,WAAW,EAoBpC,GACX,EACA,EACA,IACW,CACX,IAAM,EAAuB,EAAQ,mBAOrC,OAAO,EALwB,EAC7B,EACA,EACD,CAIC,EACA,EACD"}
|