@intlayer/core 4.1.11 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +97 -0
- package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -0
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +46 -0
- package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -0
- package/dist/cjs/dictionaryManipulator/getSectionType.cjs +57 -0
- package/dist/cjs/dictionaryManipulator/getSectionType.cjs.map +1 -0
- package/dist/cjs/dictionaryManipulator/index.cjs +31 -0
- package/dist/cjs/dictionaryManipulator/index.cjs.map +1 -0
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +64 -0
- package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -0
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +73 -0
- package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -0
- package/dist/cjs/index.cjs +17 -47
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/{transpiler/content_transformers/enumeration/getEnumerationContent.cjs → interpreter/getCondition.cjs} +10 -10
- package/dist/cjs/interpreter/getCondition.cjs.map +1 -0
- package/dist/cjs/interpreter/getContent/deepTransform.cjs +66 -0
- package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -0
- package/dist/cjs/{transpiler/content_transformers/translation/translation.cjs → interpreter/getContent/getContent.cjs} +22 -23
- package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -0
- package/dist/cjs/interpreter/getContent/index.cjs +27 -0
- package/dist/cjs/interpreter/getContent/index.cjs.map +1 -0
- package/dist/cjs/interpreter/getContent/plugins.cjs +111 -0
- package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -0
- package/dist/cjs/interpreter/getDictionary.cjs +42 -0
- package/dist/cjs/interpreter/getDictionary.cjs.map +1 -0
- package/dist/cjs/{transpiler/content_transformers/enumeration/findMatchingCondition.cjs → interpreter/getEnumeration.cjs} +12 -7
- package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -0
- package/dist/cjs/interpreter/getIntlayer.cjs +51 -0
- package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -0
- package/dist/cjs/interpreter/getIntlayerAsync.cjs +37 -0
- package/dist/cjs/interpreter/getIntlayerAsync.cjs.map +1 -0
- package/dist/cjs/interpreter/getNesting.cjs +44 -0
- package/dist/cjs/interpreter/getNesting.cjs.map +1 -0
- package/dist/cjs/{transpiler/content_transformers/translation/getTranslationContent.cjs → interpreter/getTranslation.cjs} +11 -8
- package/dist/cjs/interpreter/getTranslation.cjs.map +1 -0
- package/dist/cjs/interpreter/index.cjs +39 -0
- package/dist/cjs/interpreter/index.cjs.map +1 -0
- package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -0
- package/dist/cjs/localization/getLocaleLang.cjs.map +1 -0
- package/dist/cjs/localization/getLocaleName.cjs.map +1 -0
- package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -0
- package/dist/cjs/{getMultilingualUrls.cjs → localization/getMultilingualUrls.cjs} +1 -1
- package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -0
- package/dist/cjs/{getPathWithoutLocale.cjs → localization/getPathWithoutLocale.cjs} +1 -1
- package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -0
- package/dist/cjs/localization/index.cjs +50 -0
- package/dist/cjs/localization/index.cjs.map +1 -0
- package/dist/cjs/localization/localeDetector.cjs.map +1 -0
- package/dist/cjs/localization/localeList.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/ar.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/du.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/en.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/es.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/fr.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/hi.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/it.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/ja.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/ko.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/ownLocalesName.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/pt.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/ru.cjs.map +1 -0
- package/dist/cjs/localization/localeNames/zh.cjs.map +1 -0
- package/dist/cjs/transpiler/condition/condition.cjs +33 -0
- package/dist/cjs/transpiler/condition/condition.cjs.map +1 -0
- package/dist/cjs/transpiler/{content_transformers → condition}/index.cjs +4 -6
- package/dist/cjs/transpiler/condition/index.cjs.map +1 -0
- package/dist/cjs/transpiler/{content_transformers/enumeration → enumeration}/enumeration.cjs +5 -15
- package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -0
- package/dist/cjs/transpiler/{content_transformers/enumeration → enumeration}/index.cjs +1 -5
- package/dist/cjs/transpiler/enumeration/index.cjs.map +1 -0
- package/dist/cjs/transpiler/index.cjs +10 -2
- package/dist/cjs/transpiler/index.cjs.map +1 -1
- package/dist/cjs/transpiler/markdown/index.cjs +23 -0
- package/dist/cjs/transpiler/markdown/index.cjs.map +1 -0
- package/dist/cjs/transpiler/{content_transformers/translation/types.cjs → markdown/markdown.cjs} +11 -7
- package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -0
- package/dist/cjs/transpiler/nesting/index.cjs +23 -0
- package/dist/cjs/transpiler/nesting/index.cjs.map +1 -0
- package/dist/cjs/transpiler/nesting/nesting.cjs +36 -0
- package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -0
- package/dist/cjs/transpiler/{content_transformers/translation → translation}/index.cjs +0 -2
- package/dist/cjs/transpiler/translation/index.cjs.map +1 -0
- package/dist/cjs/transpiler/translation/translation.cjs +33 -0
- package/dist/cjs/transpiler/translation/translation.cjs.map +1 -0
- package/dist/cjs/{types/declarationContent.cjs → transpiler/translation/types.cjs} +3 -3
- package/dist/cjs/transpiler/translation/types.cjs.map +1 -0
- package/dist/cjs/types/dictionary.cjs.map +1 -1
- package/dist/cjs/types/index.cjs +7 -9
- package/dist/cjs/types/index.cjs.map +1 -1
- package/dist/cjs/types/keyPath.cjs.map +1 -1
- package/dist/cjs/types/nodeType.cjs +3 -0
- package/dist/cjs/types/nodeType.cjs.map +1 -1
- package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -0
- package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
- package/dist/cjs/utils/isValidReactElement.cjs +30 -0
- package/dist/cjs/utils/isValidReactElement.cjs.map +1 -0
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +73 -0
- package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -0
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +22 -0
- package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -0
- package/dist/esm/dictionaryManipulator/getSectionType.mjs +33 -0
- package/dist/esm/dictionaryManipulator/getSectionType.mjs.map +1 -0
- package/dist/esm/dictionaryManipulator/index.mjs +6 -0
- package/dist/esm/dictionaryManipulator/index.mjs.map +1 -0
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +40 -0
- package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -0
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +49 -0
- package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -0
- package/dist/esm/index.mjs +8 -34
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/interpreter/getCondition.mjs +9 -0
- package/dist/esm/interpreter/getCondition.mjs.map +1 -0
- package/dist/esm/interpreter/getContent/deepTransform.mjs +42 -0
- package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -0
- package/dist/esm/interpreter/getContent/getContent.mjs +27 -0
- package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -0
- package/dist/esm/interpreter/getContent/index.mjs +4 -0
- package/dist/esm/interpreter/getContent/index.mjs.map +1 -0
- package/dist/esm/interpreter/getContent/plugins.mjs +84 -0
- package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -0
- package/dist/esm/interpreter/getDictionary.mjs +18 -0
- package/dist/esm/interpreter/getDictionary.mjs.map +1 -0
- package/dist/esm/{transpiler/content_transformers/enumeration/findMatchingCondition.mjs → interpreter/getEnumeration.mjs} +7 -3
- package/dist/esm/interpreter/getEnumeration.mjs.map +1 -0
- package/dist/esm/interpreter/getIntlayer.mjs +17 -0
- package/dist/esm/interpreter/getIntlayer.mjs.map +1 -0
- package/dist/esm/interpreter/getIntlayerAsync.mjs +13 -0
- package/dist/esm/interpreter/getIntlayerAsync.mjs.map +1 -0
- package/dist/esm/interpreter/getNesting.mjs +20 -0
- package/dist/esm/interpreter/getNesting.mjs.map +1 -0
- package/dist/esm/interpreter/getTranslation.mjs +10 -0
- package/dist/esm/interpreter/getTranslation.mjs.map +1 -0
- package/dist/esm/interpreter/index.mjs +10 -0
- package/dist/esm/interpreter/index.mjs.map +1 -0
- package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -0
- package/dist/esm/localization/getLocaleLang.mjs.map +1 -0
- package/dist/esm/localization/getLocaleName.mjs.map +1 -0
- package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -0
- package/dist/esm/{getMultilingualUrls.mjs → localization/getMultilingualUrls.mjs} +1 -1
- package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -0
- package/dist/esm/{getPathWithoutLocale.mjs → localization/getPathWithoutLocale.mjs} +1 -1
- package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -0
- package/dist/esm/localization/index.mjs +19 -0
- package/dist/esm/localization/index.mjs.map +1 -0
- package/dist/esm/localization/localeDetector.mjs.map +1 -0
- package/dist/esm/localization/localeList.mjs.map +1 -0
- package/dist/esm/localization/localeNames/ar.mjs.map +1 -0
- package/dist/esm/localization/localeNames/du.mjs.map +1 -0
- package/dist/esm/localization/localeNames/en.mjs.map +1 -0
- package/dist/esm/localization/localeNames/es.mjs.map +1 -0
- package/dist/esm/localization/localeNames/fr.mjs.map +1 -0
- package/dist/esm/localization/localeNames/hi.mjs.map +1 -0
- package/dist/esm/localization/localeNames/it.mjs.map +1 -0
- package/dist/esm/localization/localeNames/ja.mjs.map +1 -0
- package/dist/esm/localization/localeNames/ko.mjs.map +1 -0
- package/dist/esm/localization/localeNames/ownLocalesName.mjs.map +1 -0
- package/dist/esm/localization/localeNames/pt.mjs.map +1 -0
- package/dist/esm/localization/localeNames/ru.mjs.map +1 -0
- package/dist/esm/localization/localeNames/zh.mjs.map +1 -0
- package/dist/esm/transpiler/condition/condition.mjs +9 -0
- package/dist/esm/transpiler/condition/condition.mjs.map +1 -0
- package/dist/esm/transpiler/condition/index.mjs +2 -0
- package/dist/esm/transpiler/condition/index.mjs.map +1 -0
- package/dist/esm/transpiler/enumeration/enumeration.mjs +9 -0
- package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -0
- package/dist/esm/transpiler/enumeration/index.mjs +2 -0
- package/dist/esm/transpiler/enumeration/index.mjs.map +1 -0
- package/dist/esm/transpiler/index.mjs +5 -1
- package/dist/esm/transpiler/index.mjs.map +1 -1
- package/dist/esm/transpiler/markdown/index.mjs +2 -0
- package/dist/esm/transpiler/markdown/index.mjs.map +1 -0
- package/dist/esm/transpiler/markdown/markdown.mjs +9 -0
- package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -0
- package/dist/esm/transpiler/nesting/index.mjs +2 -0
- package/dist/esm/transpiler/nesting/index.mjs.map +1 -0
- package/dist/esm/transpiler/nesting/nesting.mjs +12 -0
- package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -0
- package/dist/esm/transpiler/translation/index.mjs +3 -0
- package/dist/esm/transpiler/translation/index.mjs.map +1 -0
- package/dist/esm/transpiler/translation/translation.mjs +9 -0
- package/dist/esm/transpiler/translation/translation.mjs.map +1 -0
- package/dist/esm/transpiler/translation/types.mjs +1 -0
- package/dist/esm/types/index.mjs +3 -4
- package/dist/esm/types/index.mjs.map +1 -1
- package/dist/esm/types/nodeType.mjs +3 -0
- package/dist/esm/types/nodeType.mjs.map +1 -1
- package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -0
- package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
- package/dist/esm/utils/isValidReactElement.mjs +6 -0
- package/dist/esm/utils/isValidReactElement.mjs.map +1 -0
- package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts +4 -0
- package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +1 -0
- package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +4 -0
- package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +1 -0
- package/dist/types/dictionaryManipulator/getSectionType.d.ts +4 -0
- package/dist/types/dictionaryManipulator/getSectionType.d.ts.map +1 -0
- package/dist/types/dictionaryManipulator/index.d.ts +6 -0
- package/dist/types/dictionaryManipulator/index.d.ts.map +1 -0
- package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts +4 -0
- package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +1 -0
- package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts +4 -0
- package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -13
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interpreter/getCondition.d.ts +25 -0
- package/dist/types/interpreter/getCondition.d.ts.map +1 -0
- package/dist/types/interpreter/getContent/deepTransform.d.ts +8 -0
- package/dist/types/interpreter/getContent/deepTransform.d.ts.map +1 -0
- package/dist/types/interpreter/getContent/getContent.d.ts +11 -0
- package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -0
- package/dist/types/interpreter/getContent/index.d.ts +4 -0
- package/dist/types/interpreter/getContent/index.d.ts.map +1 -0
- package/dist/types/interpreter/getContent/plugins.d.ts +106 -0
- package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -0
- package/dist/types/interpreter/getDictionary.d.ts +13 -0
- package/dist/types/interpreter/getDictionary.d.ts.map +1 -0
- package/dist/types/interpreter/getEnumeration.d.ts +57 -0
- package/dist/types/interpreter/getEnumeration.d.ts.map +1 -0
- package/dist/types/interpreter/getIntlayer.d.ts +6 -0
- package/dist/types/interpreter/getIntlayer.d.ts.map +1 -0
- package/dist/types/interpreter/getIntlayerAsync.d.ts +13 -0
- package/dist/types/interpreter/getIntlayerAsync.d.ts.map +1 -0
- package/dist/types/interpreter/getNesting.d.ts +18 -0
- package/dist/types/interpreter/getNesting.d.ts.map +1 -0
- package/dist/types/{transpiler/content_transformers/translation/getTranslationContent.d.ts → interpreter/getTranslation.d.ts} +8 -8
- package/dist/types/interpreter/getTranslation.d.ts.map +1 -0
- package/dist/types/interpreter/index.d.ts +10 -0
- package/dist/types/interpreter/index.d.ts.map +1 -0
- package/dist/types/{getHTMLTextDir.d.ts → localization/getHTMLTextDir.d.ts} +1 -1
- package/dist/types/localization/getHTMLTextDir.d.ts.map +1 -0
- package/dist/types/{getLocaleLang.d.ts → localization/getLocaleLang.d.ts} +1 -1
- package/dist/types/localization/getLocaleLang.d.ts.map +1 -0
- package/dist/types/{getLocaleName.d.ts → localization/getLocaleName.d.ts} +1 -1
- package/dist/types/localization/getLocaleName.d.ts.map +1 -0
- package/dist/types/{getLocalizedUrl.d.ts → localization/getLocalizedUrl.d.ts} +1 -1
- package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -0
- package/dist/types/{getMultilingualUrls.d.ts → localization/getMultilingualUrls.d.ts} +1 -1
- package/dist/types/localization/getMultilingualUrls.d.ts.map +1 -0
- package/dist/types/{getPathWithoutLocale.d.ts → localization/getPathWithoutLocale.d.ts} +1 -1
- package/dist/types/localization/getPathWithoutLocale.d.ts.map +1 -0
- package/dist/types/localization/index.d.ts +9 -0
- package/dist/types/localization/index.d.ts.map +1 -0
- package/dist/types/localization/localeDetector.d.ts.map +1 -0
- package/dist/types/localization/localeList.d.ts.map +1 -0
- package/dist/types/localization/localeNames/ar.d.ts.map +1 -0
- package/dist/types/localization/localeNames/du.d.ts.map +1 -0
- package/dist/types/localization/localeNames/en.d.ts.map +1 -0
- package/dist/types/localization/localeNames/es.d.ts.map +1 -0
- package/dist/types/localization/localeNames/fr.d.ts.map +1 -0
- package/dist/types/localization/localeNames/hi.d.ts.map +1 -0
- package/dist/types/localization/localeNames/it.d.ts.map +1 -0
- package/dist/types/localization/localeNames/ja.d.ts.map +1 -0
- package/dist/types/localization/localeNames/ko.d.ts.map +1 -0
- package/dist/types/localization/localeNames/ownLocalesName.d.ts.map +1 -0
- package/dist/types/localization/localeNames/pt.d.ts.map +1 -0
- package/dist/types/localization/localeNames/ru.d.ts.map +1 -0
- package/dist/types/localization/localeNames/zh.d.ts.map +1 -0
- package/dist/types/transpiler/condition/condition.d.ts +35 -0
- package/dist/types/transpiler/condition/condition.d.ts.map +1 -0
- package/dist/types/transpiler/condition/index.d.ts +2 -0
- package/dist/types/transpiler/condition/index.d.ts.map +1 -0
- package/dist/types/transpiler/enumeration/enumeration.d.ts +58 -0
- package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -0
- package/dist/types/transpiler/enumeration/index.d.ts +2 -0
- package/dist/types/transpiler/enumeration/index.d.ts.map +1 -0
- package/dist/types/transpiler/index.d.ts +5 -1
- package/dist/types/transpiler/index.d.ts.map +1 -1
- package/dist/types/transpiler/markdown/index.d.ts +2 -0
- package/dist/types/transpiler/markdown/index.d.ts.map +1 -0
- package/dist/types/transpiler/markdown/markdown.d.ts +21 -0
- package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -0
- package/dist/types/transpiler/nesting/index.d.ts +2 -0
- package/dist/types/transpiler/nesting/index.d.ts.map +1 -0
- package/dist/types/transpiler/nesting/nesting.d.ts +54 -0
- package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -0
- package/dist/types/transpiler/translation/index.d.ts +3 -0
- package/dist/types/transpiler/translation/index.d.ts.map +1 -0
- package/dist/types/transpiler/{content_transformers/translation → translation}/translation.d.ts +2 -2
- package/dist/types/transpiler/translation/translation.d.ts.map +1 -0
- package/dist/types/transpiler/{content_transformers/translation → translation}/types.d.ts +4 -5
- package/dist/types/transpiler/translation/types.d.ts.map +1 -0
- package/dist/types/types/dictionary.d.ts +36 -7
- package/dist/types/types/dictionary.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +3 -4
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/keyPath.d.ts +17 -1
- package/dist/types/types/keyPath.d.ts.map +1 -1
- package/dist/types/types/nodeType.d.ts +4 -1
- package/dist/types/types/nodeType.d.ts.map +1 -1
- package/dist/types/utils/checkIsURLAbsolute.d.ts.map +1 -0
- package/dist/types/utils/isSameKeyPath.d.ts.map +1 -1
- package/dist/types/utils/isValidReactElement.d.ts +9 -0
- package/dist/types/utils/isValidReactElement.d.ts.map +1 -0
- package/package.json +10 -7
- package/dist/cjs/checkIsURLAbsolute.cjs.map +0 -1
- package/dist/cjs/getHTMLTextDir.cjs.map +0 -1
- package/dist/cjs/getLocaleLang.cjs.map +0 -1
- package/dist/cjs/getLocaleName.cjs.map +0 -1
- package/dist/cjs/getLocalizedUrl.cjs.map +0 -1
- package/dist/cjs/getMultilingualUrls.cjs.map +0 -1
- package/dist/cjs/getPathWithoutLocale.cjs.map +0 -1
- package/dist/cjs/localeDetector.cjs.map +0 -1
- package/dist/cjs/localeList.cjs.map +0 -1
- package/dist/cjs/localeNames/ar.cjs.map +0 -1
- package/dist/cjs/localeNames/du.cjs.map +0 -1
- package/dist/cjs/localeNames/en.cjs.map +0 -1
- package/dist/cjs/localeNames/es.cjs.map +0 -1
- package/dist/cjs/localeNames/fr.cjs.map +0 -1
- package/dist/cjs/localeNames/hi.cjs.map +0 -1
- package/dist/cjs/localeNames/it.cjs.map +0 -1
- package/dist/cjs/localeNames/ja.cjs.map +0 -1
- package/dist/cjs/localeNames/ko.cjs.map +0 -1
- package/dist/cjs/localeNames/ownLocalesName.cjs.map +0 -1
- package/dist/cjs/localeNames/pt.cjs.map +0 -1
- package/dist/cjs/localeNames/ru.cjs.map +0 -1
- package/dist/cjs/localeNames/zh.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/enumeration.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/findMatchingCondition.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/getEnumerationContent.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/enumeration/index.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/index.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/translation/getTranslationContent.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/translation/index.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/translation/translation.cjs.map +0 -1
- package/dist/cjs/transpiler/content_transformers/translation/types.cjs.map +0 -1
- package/dist/cjs/types/declarationContent.cjs.map +0 -1
- package/dist/esm/checkIsURLAbsolute.mjs.map +0 -1
- package/dist/esm/getHTMLTextDir.mjs.map +0 -1
- package/dist/esm/getLocaleLang.mjs.map +0 -1
- package/dist/esm/getLocaleName.mjs.map +0 -1
- package/dist/esm/getLocalizedUrl.mjs.map +0 -1
- package/dist/esm/getMultilingualUrls.mjs.map +0 -1
- package/dist/esm/getPathWithoutLocale.mjs.map +0 -1
- package/dist/esm/localeDetector.mjs.map +0 -1
- package/dist/esm/localeList.mjs.map +0 -1
- package/dist/esm/localeNames/ar.mjs.map +0 -1
- package/dist/esm/localeNames/du.mjs.map +0 -1
- package/dist/esm/localeNames/en.mjs.map +0 -1
- package/dist/esm/localeNames/es.mjs.map +0 -1
- package/dist/esm/localeNames/fr.mjs.map +0 -1
- package/dist/esm/localeNames/hi.mjs.map +0 -1
- package/dist/esm/localeNames/it.mjs.map +0 -1
- package/dist/esm/localeNames/ja.mjs.map +0 -1
- package/dist/esm/localeNames/ko.mjs.map +0 -1
- package/dist/esm/localeNames/ownLocalesName.mjs.map +0 -1
- package/dist/esm/localeNames/pt.mjs.map +0 -1
- package/dist/esm/localeNames/ru.mjs.map +0 -1
- package/dist/esm/localeNames/zh.mjs.map +0 -1
- package/dist/esm/transpiler/content_transformers/enumeration/enumeration.mjs +0 -19
- package/dist/esm/transpiler/content_transformers/enumeration/enumeration.mjs.map +0 -1
- package/dist/esm/transpiler/content_transformers/enumeration/findMatchingCondition.mjs.map +0 -1
- package/dist/esm/transpiler/content_transformers/enumeration/getEnumerationContent.mjs +0 -9
- package/dist/esm/transpiler/content_transformers/enumeration/getEnumerationContent.mjs.map +0 -1
- package/dist/esm/transpiler/content_transformers/enumeration/index.mjs +0 -4
- package/dist/esm/transpiler/content_transformers/enumeration/index.mjs.map +0 -1
- package/dist/esm/transpiler/content_transformers/index.mjs +0 -3
- package/dist/esm/transpiler/content_transformers/index.mjs.map +0 -1
- package/dist/esm/transpiler/content_transformers/translation/getTranslationContent.mjs +0 -7
- package/dist/esm/transpiler/content_transformers/translation/getTranslationContent.mjs.map +0 -1
- package/dist/esm/transpiler/content_transformers/translation/index.mjs +0 -4
- package/dist/esm/transpiler/content_transformers/translation/index.mjs.map +0 -1
- package/dist/esm/transpiler/content_transformers/translation/translation.mjs +0 -23
- package/dist/esm/transpiler/content_transformers/translation/translation.mjs.map +0 -1
- package/dist/esm/transpiler/content_transformers/translation/types.mjs +0 -5
- package/dist/esm/transpiler/content_transformers/translation/types.mjs.map +0 -1
- package/dist/esm/types/declarationContent.mjs +0 -1
- package/dist/types/checkIsURLAbsolute.d.ts.map +0 -1
- package/dist/types/getHTMLTextDir.d.ts.map +0 -1
- package/dist/types/getLocaleLang.d.ts.map +0 -1
- package/dist/types/getLocaleName.d.ts.map +0 -1
- package/dist/types/getLocalizedUrl.d.ts.map +0 -1
- package/dist/types/getMultilingualUrls.d.ts.map +0 -1
- package/dist/types/getPathWithoutLocale.d.ts.map +0 -1
- package/dist/types/localeDetector.d.ts.map +0 -1
- package/dist/types/localeList.d.ts.map +0 -1
- package/dist/types/localeNames/ar.d.ts.map +0 -1
- package/dist/types/localeNames/du.d.ts.map +0 -1
- package/dist/types/localeNames/en.d.ts.map +0 -1
- package/dist/types/localeNames/es.d.ts.map +0 -1
- package/dist/types/localeNames/fr.d.ts.map +0 -1
- package/dist/types/localeNames/hi.d.ts.map +0 -1
- package/dist/types/localeNames/it.d.ts.map +0 -1
- package/dist/types/localeNames/ja.d.ts.map +0 -1
- package/dist/types/localeNames/ko.d.ts.map +0 -1
- package/dist/types/localeNames/ownLocalesName.d.ts.map +0 -1
- package/dist/types/localeNames/pt.d.ts.map +0 -1
- package/dist/types/localeNames/ru.d.ts.map +0 -1
- package/dist/types/localeNames/zh.d.ts.map +0 -1
- package/dist/types/transpiler/content_transformers/enumeration/enumeration.d.ts +0 -38
- package/dist/types/transpiler/content_transformers/enumeration/enumeration.d.ts.map +0 -1
- package/dist/types/transpiler/content_transformers/enumeration/findMatchingCondition.d.ts +0 -30
- package/dist/types/transpiler/content_transformers/enumeration/findMatchingCondition.d.ts.map +0 -1
- package/dist/types/transpiler/content_transformers/enumeration/getEnumerationContent.d.ts +0 -29
- package/dist/types/transpiler/content_transformers/enumeration/getEnumerationContent.d.ts.map +0 -1
- package/dist/types/transpiler/content_transformers/enumeration/index.d.ts +0 -4
- package/dist/types/transpiler/content_transformers/enumeration/index.d.ts.map +0 -1
- package/dist/types/transpiler/content_transformers/index.d.ts +0 -3
- package/dist/types/transpiler/content_transformers/index.d.ts.map +0 -1
- package/dist/types/transpiler/content_transformers/translation/getTranslationContent.d.ts.map +0 -1
- package/dist/types/transpiler/content_transformers/translation/index.d.ts +0 -4
- package/dist/types/transpiler/content_transformers/translation/index.d.ts.map +0 -1
- package/dist/types/transpiler/content_transformers/translation/translation.d.ts.map +0 -1
- package/dist/types/transpiler/content_transformers/translation/types.d.ts.map +0 -1
- package/dist/types/types/declarationContent.d.ts +0 -27
- package/dist/types/types/declarationContent.d.ts.map +0 -1
- /package/dist/cjs/{getHTMLTextDir.cjs → localization/getHTMLTextDir.cjs} +0 -0
- /package/dist/cjs/{getLocaleLang.cjs → localization/getLocaleLang.cjs} +0 -0
- /package/dist/cjs/{getLocaleName.cjs → localization/getLocaleName.cjs} +0 -0
- /package/dist/cjs/{getLocalizedUrl.cjs → localization/getLocalizedUrl.cjs} +0 -0
- /package/dist/cjs/{localeDetector.cjs → localization/localeDetector.cjs} +0 -0
- /package/dist/cjs/{localeList.cjs → localization/localeList.cjs} +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/ar.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/du.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/en.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/es.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/fr.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/hi.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/it.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/ja.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/ko.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/ownLocalesName.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/pt.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/ru.cjs +0 -0
- /package/dist/cjs/{localeNames → localization/localeNames}/zh.cjs +0 -0
- /package/dist/cjs/{checkIsURLAbsolute.cjs → utils/checkIsURLAbsolute.cjs} +0 -0
- /package/dist/esm/{getHTMLTextDir.mjs → localization/getHTMLTextDir.mjs} +0 -0
- /package/dist/esm/{getLocaleLang.mjs → localization/getLocaleLang.mjs} +0 -0
- /package/dist/esm/{getLocaleName.mjs → localization/getLocaleName.mjs} +0 -0
- /package/dist/esm/{getLocalizedUrl.mjs → localization/getLocalizedUrl.mjs} +0 -0
- /package/dist/esm/{localeDetector.mjs → localization/localeDetector.mjs} +0 -0
- /package/dist/esm/{localeList.mjs → localization/localeList.mjs} +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/ar.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/du.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/en.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/es.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/fr.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/hi.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/it.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/ja.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/ko.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/ownLocalesName.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/pt.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/ru.mjs +0 -0
- /package/dist/esm/{localeNames → localization/localeNames}/zh.mjs +0 -0
- /package/dist/esm/{types/declarationContent.mjs.map → transpiler/translation/types.mjs.map} +0 -0
- /package/dist/esm/{checkIsURLAbsolute.mjs → utils/checkIsURLAbsolute.mjs} +0 -0
- /package/dist/types/{localeDetector.d.ts → localization/localeDetector.d.ts} +0 -0
- /package/dist/types/{localeList.d.ts → localization/localeList.d.ts} +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/ar.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/du.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/en.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/es.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/fr.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/hi.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/it.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/ja.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/ko.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/ownLocalesName.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/pt.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/ru.d.ts +0 -0
- /package/dist/types/{localeNames → localization/localeNames}/zh.d.ts +0 -0
- /package/dist/types/{checkIsURLAbsolute.d.ts → utils/checkIsURLAbsolute.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["// @ts-ignore intlayer declared for module augmentation\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type { DictionaryKeys } from '../../types/dictionary';\nimport { NodeType } from '../../types/index';\nimport type { DeepTransformContent } from '../../interpreter';\n\n/**\n * Recursively builds dot-notation strings for all valid paths in T.\n * Example:\n * type X = { a: { b: { c: string }}, d: number };\n * DotPath<X> = \"a\" | \"a.b\" | \"a.b.c\" | \"d\"\n */\nexport type DotPath<T> = T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object\n ? // Either just K, or K + '.' + deeper path\n `${K}` | `${K}.${DotPath<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\ntype DeepReplace<T, From, To> = T extends From\n ? To\n : T extends object\n ? { [K in keyof T]: DeepReplace<T[K], From, To> }\n : T;\n\n/** Build all valid dot-notation strings for a dictionary entry. */\nexport type ValidDotPathsFor<K extends DictionaryKeys> = DotPath<\n DeepReplace<\n DeepTransformContent<IntlayerDictionaryTypesConnector[K]['content']>,\n // Replace ReactElement type with string\n {\n type: any;\n props: any;\n key: any;\n },\n string\n >\n>;\n\nexport type NestedContentState<K extends DictionaryKeys> = {\n dictionaryKey: K;\n\n /**\n * Path must match existing keys in IntlayerDictionaryTypesConnector[K].\n * Can be either:\n * - \"dot.dot.dot\" format\n */\n path?: ValidDotPathsFor<K>;\n};\n\nexport type NestedContent<K extends DictionaryKeys = never> = {\n nodeType: NodeType.Nested;\n [NodeType.Nested]: NestedContentState<K>;\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to extract the content of another dictionary and nest it in the current dictionary.\n *\n * Usage:\n *\n * ```ts\n * nest(\"dictionaryKey\");\n * nest(\"dictionaryKey\", \"path.to.content\");\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n */\nconst nesting = <K extends DictionaryKeys>(\n dictionaryKey: K,\n path?: ValidDotPathsFor<K>\n): NestedContent<K> => ({\n nodeType: NodeType.Nested,\n [NodeType.Nested]: {\n dictionaryKey,\n path,\n },\n});\n\nexport { nesting as nest };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAyB;AAqEzB,MAAM,UAAU,CACd,eACA,UACsB;AAAA,EACtB,UAAU,sBAAS;AAAA,EACnB,CAAC,sBAAS,MAAM,GAAG;AAAA,IACjB;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -16,12 +16,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var translation_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(translation_exports);
|
|
18
18
|
__reExport(translation_exports, require('./translation.cjs'), module.exports);
|
|
19
|
-
__reExport(translation_exports, require('./getTranslationContent.cjs'), module.exports);
|
|
20
19
|
__reExport(translation_exports, require('./types.cjs'), module.exports);
|
|
21
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
21
|
0 && (module.exports = {
|
|
23
22
|
...require('./translation.cjs'),
|
|
24
|
-
...require('./getTranslationContent.cjs'),
|
|
25
23
|
...require('./types.cjs')
|
|
26
24
|
});
|
|
27
25
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/translation/index.ts"],"sourcesContent":["export * from './translation';\nexport * from './types';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,0BAAd;AACA,gCAAc,oBADd;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var translation_exports = {};
|
|
20
|
+
__export(translation_exports, {
|
|
21
|
+
t: () => translation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(translation_exports);
|
|
24
|
+
var import_types = require('../../types/index.cjs');
|
|
25
|
+
const translation = (content) => ({
|
|
26
|
+
nodeType: import_types.NodeType.Translation,
|
|
27
|
+
[import_types.NodeType.Translation]: content
|
|
28
|
+
});
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
t
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=translation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import { NodeType } from '../../types/index';\nimport type { LanguageContent, TranslationContent } from './types';\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <Content = string>(content?: LanguageContent<Content>) =>\n ({\n nodeType: NodeType.Translation,\n [NodeType.Translation]: content,\n }) as TranslationContent<Content>;\n\nexport { translation as t };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AAuBzB,MAAM,cAAc,CAAmB,aACpC;AAAA,EACC,UAAU,sBAAS;AAAA,EACnB,CAAC,sBAAS,WAAW,GAAG;AAC1B;","names":[]}
|
|
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
return to;
|
|
13
13
|
};
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var
|
|
16
|
-
module.exports = __toCommonJS(
|
|
17
|
-
//# sourceMappingURL=
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/translation/types.ts"],"sourcesContent":["/** @ts-nocheck */\n\nimport type { LocalesValues } from '@intlayer/config/client';\n// @ts-ignore intlayer declared for module augmentation\nimport type { IConfigLocales } from 'intlayer';\nimport type { NodeType } from '../../types/index';\n\n/**\n * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n * If not, it will return never\n */\nexport type ConfigLocales = keyof IConfigLocales<unknown>;\n\n/**\n * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n * If not, it will return all available locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...\n */\nexport type CustomLocales = ConfigLocales extends never\n ? LocalesValues\n : ConfigLocales;\n\n/**\n * Record of locales and content\n *\n * const myVar1: LanguageContent<string> = {\n * \"en\": \"\",\n * \"fr\": \"\"\n * }\n *\n * const myVar2: LanguageContent<{age: number, name: string}> = {\n * \"en\": {age: 1, name: \"test\"},\n * \"fr\": {age: 1, name: \"test\"}\n * }\n */\nexport type TranslationContentState<Content = unknown> = Partial<\n Record<LocalesValues, Content>\n>;\n\n/**\n * Valid\n * const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {\n * \"en\": \"test\",\n * \"fr\": \"test\"\n * }\n *\n * const test: CustomizableLanguageContent<number> = {\n * \"fr\": 1,\n * \"en\": 1,\n * ... any other available locale\n * }\n *\n * Invalid\n *\n * const test: CustomizableLanguageContent<string> = {\n * \"en\": \"test\",\n * \"fr\": \"test\",\n * \"sss\": \"test\" // Does not exist in Locales\n * }\n *\n * const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {\n * \"fr\": \"test\"\n * // Locales.ENGLISH is missing\n * }\n *\n */\nexport type LanguageContent<Content = string> = ConfigLocales extends never\n ? IConfigLocales<Content>\n : TranslationContentState<Content>;\n\nexport type TranslationContent<Content = unknown> = {\n nodeType: NodeType.Translation;\n [NodeType.Translation]: LanguageContent<Content>;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/dictionary.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/types/dictionary.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// @ts-ignore intlayer declared for module augmentation\nimport { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport type {\n ConditionContent,\n EnumerationContent,\n MarkdownContent,\n NestedContent,\n TranslationContent,\n} from '../transpiler/index';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\nexport type TypedNode<NodeType = never> =\n | TranslationContent<NodeType>\n | EnumerationContent<NodeType>\n | ConditionContent<NodeType>\n | MarkdownContent\n | NestedContent<DictionaryKeys>;\n\nexport type BaseNode = string | number | bigint | boolean | null | undefined;\n\nexport type FetchableContentNode<NodeType = ContentNode> = (\n args?: any\n) => ContentNode<NodeType> | Promise<ContentNode<NodeType>>;\n\nexport type ContentNode<NodeType = never, FetchableNode = false> =\n | NodeType\n | TypedNode<NodeType>\n | { [paramKey: string | number]: ContentNode<NodeType[keyof NodeType]> }\n | ((args?: any) => ContentNode<NodeType>)\n | (FetchableNode extends true ? FetchableContentNode<NodeType> : never);\n\ntype IsArray<T> = T extends any[] ? true : false;\n\ntype ReplaceContentValueArray<T> = T extends (infer U)[]\n ? ReplaceContentValue<U>[]\n : ReplaceContentValue<T>;\n\n// Utility type that performs recursive replacement\ntype ReplaceContentValue<NodeType, FetchableNode = true> = {\n [P in keyof NodeType]: IsArray<NodeType[P]> extends true\n ? ReplaceContentValueArray<NodeType[P]>\n : NodeType[P] extends object\n ? ReplaceContentValue<NodeType[P]>\n : ContentNode<NodeType[P], FetchableNode>;\n};\n\nexport type Dictionary<NodeType = undefined, FetchableNode = false> = {\n $schema?: string;\n key: string;\n title?: string;\n description?: string;\n availableVersions?: string[];\n version?: string;\n filePath?: string;\n tags?: string[];\n content: NodeType extends undefined // Applying the generic to replace ContentValue with Replacement\n ? ContentNode<any, FetchableNode>\n : ReplaceContentValue<NodeType>;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/cjs/types/index.cjs
CHANGED
|
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
6
|
var __copyProps = (to, from, except, desc) => {
|
|
11
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -15,15 +11,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
11
|
}
|
|
16
12
|
return to;
|
|
17
13
|
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
16
|
var types_exports = {};
|
|
20
|
-
__export(types_exports, {
|
|
21
|
-
NodeType: () => import_nodeType.NodeType
|
|
22
|
-
});
|
|
23
17
|
module.exports = __toCommonJS(types_exports);
|
|
24
|
-
|
|
18
|
+
__reExport(types_exports, require('./dictionary.cjs'), module.exports);
|
|
19
|
+
__reExport(types_exports, require('./nodeType.cjs'), module.exports);
|
|
20
|
+
__reExport(types_exports, require('./keyPath.cjs'), module.exports);
|
|
25
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
22
|
0 && (module.exports = {
|
|
27
|
-
|
|
23
|
+
...require('./dictionary.cjs'),
|
|
24
|
+
...require('./nodeType.cjs'),
|
|
25
|
+
...require('./keyPath.cjs')
|
|
28
26
|
});
|
|
29
27
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["export * from './dictionary';\nexport * from './nodeType';\nexport * from './keyPath';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,yBAAd;AACA,0BAAc,uBADd;AAEA,0BAAc,sBAFd;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/keyPath.ts"],"sourcesContent":["import type { NodeType } from './nodeType';\n\nexport type ObjectNode = {\n type: NodeType.Object;\n key: string;\n};\n\nexport type ArrayNode = {\n type: NodeType.Array;\n key: number;\n};\n\nexport type EnumerationNode = {\n type: NodeType.Enumeration;\n key: string;\n};\n\nexport type TranslationNode = {\n type: NodeType.Translation;\n key: string;\n};\n\nexport type KeyPath =\n | ObjectNode\n | ArrayNode\n | TranslationNode\n | EnumerationNode;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/types/keyPath.ts"],"sourcesContent":["import type { NodeType } from './nodeType';\n\nexport type ObjectNode = {\n type: NodeType.Object;\n key: string;\n};\n\nexport type ArrayNode = {\n type: NodeType.Array;\n key: number;\n};\n\nexport type EnumerationNode = {\n type: NodeType.Enumeration;\n key: string;\n};\n\nexport type TranslationNode = {\n type: NodeType.Translation;\n key: string;\n};\n\nexport type ConditionNode = {\n type: NodeType.Condition;\n key: string;\n};\n\nexport type MarkdownNode = {\n type: NodeType.Markdown;\n key?: undefined;\n};\n\nexport type ReactNode = {\n type: NodeType.ReactNode;\n key?: undefined;\n};\n\nexport type NestedNode = {\n type: NodeType.Nested;\n key?: undefined;\n};\n\nexport type KeyPath =\n | ObjectNode\n | ArrayNode\n | TranslationNode\n | EnumerationNode\n | MarkdownNode\n | ReactNode\n | ConditionNode\n | NestedNode;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -24,10 +24,13 @@ module.exports = __toCommonJS(nodeType_exports);
|
|
|
24
24
|
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
25
25
|
NodeType2["Translation"] = "translation";
|
|
26
26
|
NodeType2["Enumeration"] = "enumeration";
|
|
27
|
+
NodeType2["Condition"] = "condition";
|
|
27
28
|
NodeType2["Object"] = "object";
|
|
28
29
|
NodeType2["Array"] = "array";
|
|
29
30
|
NodeType2["Text"] = "text";
|
|
31
|
+
NodeType2["Nested"] = "nested";
|
|
30
32
|
NodeType2["ReactNode"] = "reactNode";
|
|
33
|
+
NodeType2["Markdown"] = "markdown";
|
|
31
34
|
return NodeType2;
|
|
32
35
|
})(NodeType || {});
|
|
33
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["export enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Object = 'object',\n Array = 'array',\n Text = 'text',\n ReactNode = 'reactNode',\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,eAAY;
|
|
1
|
+
{"version":3,"sources":["../../../src/types/nodeType.ts"],"sourcesContent":["export enum NodeType {\n Translation = 'translation',\n Enumeration = 'enumeration',\n Condition = 'condition',\n Object = 'object',\n Array = 'array',\n Text = 'text',\n Nested = 'nested',\n ReactNode = 'reactNode',\n Markdown = 'markdown',\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,UAAO;AACP,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,eAAY;AACZ,EAAAA,UAAA,cAAW;AATD,SAAAA;AAAA,GAAA;","names":["NodeType"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/checkIsURLAbsolute.ts"],"sourcesContent":["export const checkIsURLAbsolute = (url: string): boolean =>\n /^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(url);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,qBAAqB,CAAC,QACjC,4BAA4B,KAAK,GAAG;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/isSameKeyPath.ts"],"sourcesContent":["import type { KeyPath } from '../types';\n\nexport const isSameKeyPath = (keyPath1: KeyPath[], keyPath2: KeyPath[]) =>\n keyPath1.every(\n (element, index) =>\n keyPath2[index] &&\n keyPath2[index].key
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/isSameKeyPath.ts"],"sourcesContent":["import type { KeyPath } from '../types';\n\ntype KeyPathWithKey = KeyPath & { key: string };\n\nexport const isSameKeyPath = (keyPath1: KeyPath[], keyPath2: KeyPath[]) =>\n keyPath1.every(\n (element, index) =>\n keyPath2[index] &&\n (keyPath2[index] as KeyPathWithKey).key ===\n (element as KeyPathWithKey).key &&\n keyPath2[index].type === element.type\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,gBAAgB,CAAC,UAAqB,aACjD,SAAS;AAAA,EACP,CAAC,SAAS,UACR,SAAS,KAAK,KACb,SAAS,KAAK,EAAqB,QACjC,QAA2B,OAC9B,SAAS,KAAK,EAAE,SAAS,QAAQ;AACrC;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var isValidReactElement_exports = {};
|
|
20
|
+
__export(isValidReactElement_exports, {
|
|
21
|
+
isValidElement: () => isValidElement
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(isValidReactElement_exports);
|
|
24
|
+
const REACT_ELEMENT_TYPE = Symbol.for("react.element");
|
|
25
|
+
const isValidElement = (object) => typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
isValidElement
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=isValidReactElement.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/isValidReactElement.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nconst REACT_ELEMENT_TYPE = Symbol.for('react.element');\n\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param object\n * @return True if `object` is a ReactElement.\n * @final\n */\n\nexport const isValidElement = (object: any): boolean =>\n typeof object === 'object' &&\n object !== null &&\n object.$$typeof === REACT_ELEMENT_TYPE;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,MAAM,qBAAqB,OAAO,IAAI,eAAe;AAU9C,MAAM,iBAAiB,CAAC,WAC7B,OAAO,WAAW,YAClB,WAAW,QACX,OAAO,aAAa;","names":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { NodeType } from "../types/index.mjs";
|
|
2
|
+
const editDictionaryByKeyPath = (dictionaryContent, keyPath, newValue) => {
|
|
3
|
+
let currentValue = dictionaryContent;
|
|
4
|
+
let parentValue = null;
|
|
5
|
+
let lastKeys = [];
|
|
6
|
+
for (const keyObj of keyPath) {
|
|
7
|
+
parentValue = currentValue;
|
|
8
|
+
if (keyObj.type === NodeType.Object) {
|
|
9
|
+
lastKeys = [keyObj.key];
|
|
10
|
+
if (!currentValue[keyObj.key]) {
|
|
11
|
+
currentValue = {
|
|
12
|
+
...currentValue,
|
|
13
|
+
[keyObj.key]: {}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
currentValue = currentValue[keyObj.key];
|
|
17
|
+
} else if (keyObj.type === NodeType.Array) {
|
|
18
|
+
lastKeys = [keyObj.key];
|
|
19
|
+
if (!currentValue[keyObj.key]) {
|
|
20
|
+
currentValue[keyObj.key] = {};
|
|
21
|
+
}
|
|
22
|
+
currentValue = currentValue[keyObj.key];
|
|
23
|
+
} else if (keyObj.type === NodeType.Translation) {
|
|
24
|
+
lastKeys = [NodeType.Translation, keyObj.key];
|
|
25
|
+
if (!currentValue[NodeType.Translation]) {
|
|
26
|
+
currentValue[NodeType.Translation] = {
|
|
27
|
+
...currentValue[NodeType.Translation],
|
|
28
|
+
[keyObj.key]: newValue
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
currentValue = currentValue[NodeType.Translation][keyObj.key];
|
|
32
|
+
} else if (keyObj.type === NodeType.Enumeration) {
|
|
33
|
+
lastKeys = [NodeType.Enumeration, keyObj.key];
|
|
34
|
+
if (!currentValue[NodeType.Enumeration]) {
|
|
35
|
+
currentValue[NodeType.Enumeration] = {
|
|
36
|
+
...currentValue[NodeType.Enumeration],
|
|
37
|
+
[keyObj.key]: newValue
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
currentValue = currentValue[NodeType.Enumeration][keyObj.key];
|
|
41
|
+
} else if (keyObj.type === NodeType.Markdown) {
|
|
42
|
+
lastKeys = [NodeType.Markdown];
|
|
43
|
+
if (!currentValue[NodeType.Markdown]) {
|
|
44
|
+
currentValue[NodeType.Markdown] = newValue;
|
|
45
|
+
}
|
|
46
|
+
currentValue = currentValue[NodeType.Markdown];
|
|
47
|
+
} else if (keyObj.type === NodeType.Nested) {
|
|
48
|
+
lastKeys = [NodeType.Nested];
|
|
49
|
+
if (!currentValue[NodeType.Nested]) {
|
|
50
|
+
currentValue[NodeType.Nested] = newValue;
|
|
51
|
+
}
|
|
52
|
+
currentValue = currentValue[NodeType.Nested];
|
|
53
|
+
}
|
|
54
|
+
if (parentValue && lastKeys.length > 0) {
|
|
55
|
+
for (const key of lastKeys.slice(0, -1)) {
|
|
56
|
+
parentValue = parentValue[key];
|
|
57
|
+
}
|
|
58
|
+
if (
|
|
59
|
+
// Remove the field if the new value is undefined
|
|
60
|
+
typeof newValue === "undefined"
|
|
61
|
+
) {
|
|
62
|
+
delete parentValue[lastKeys[lastKeys.length - 1]];
|
|
63
|
+
} else {
|
|
64
|
+
parentValue[lastKeys[lastKeys.length - 1]] = newValue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return dictionaryContent;
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
editDictionaryByKeyPath
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=editDictionaryByKeyPath.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type KeyPath, NodeType } from '../types';\nimport type { ContentNode } from '../types/dictionary';\n\ntype LastKeyType = string | number;\n\nexport const editDictionaryByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n newValue: ContentNode\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKeys: LastKeyType[] = [];\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object) {\n lastKeys = [keyObj.key];\n\n if (!currentValue[keyObj.key]) {\n currentValue = {\n ...currentValue,\n [keyObj.key]: {},\n };\n }\n currentValue = currentValue[keyObj.key];\n } else if (keyObj.type === NodeType.Array) {\n lastKeys = [keyObj.key];\n\n if (!currentValue[keyObj.key]) {\n currentValue[keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.key];\n } else if (keyObj.type === NodeType.Translation) {\n lastKeys = [NodeType.Translation, keyObj.key];\n\n if (!currentValue[NodeType.Translation]) {\n currentValue[NodeType.Translation] = {\n ...currentValue[NodeType.Translation],\n [keyObj.key]: newValue,\n };\n }\n currentValue = currentValue[NodeType.Translation][keyObj.key];\n } else if (keyObj.type === NodeType.Enumeration) {\n lastKeys = [NodeType.Enumeration, keyObj.key];\n\n if (!currentValue[NodeType.Enumeration]) {\n currentValue[NodeType.Enumeration] = {\n ...currentValue[NodeType.Enumeration],\n [keyObj.key]: newValue,\n };\n }\n currentValue = currentValue[NodeType.Enumeration][keyObj.key];\n } else if (keyObj.type === NodeType.Markdown) {\n lastKeys = [NodeType.Markdown];\n if (!currentValue[NodeType.Markdown]) {\n currentValue[NodeType.Markdown] = newValue;\n }\n currentValue = currentValue[NodeType.Markdown];\n } else if (keyObj.type === NodeType.Nested) {\n lastKeys = [NodeType.Nested];\n if (!currentValue[NodeType.Nested]) {\n currentValue[NodeType.Nested] = newValue;\n }\n currentValue = currentValue[NodeType.Nested];\n }\n\n // Assign the new value to the last key of the parent\n if (parentValue && lastKeys.length > 0) {\n for (const key of lastKeys.slice(0, -1)) {\n parentValue = parentValue[key];\n }\n if (\n // Remove the field if the new value is undefined\n typeof newValue === 'undefined'\n ) {\n delete parentValue[lastKeys[lastKeys.length - 1]];\n } else {\n parentValue[lastKeys[lastKeys.length - 1]] = newValue;\n }\n }\n }\n return dictionaryContent;\n};\n"],"mappings":"AACA,SAAuB,gBAAgB;AAKhC,MAAM,0BAA0B,CACrC,mBACA,SACA,aACgB;AAChB,MAAI,eAAoB;AACxB,MAAI,cAAmB;AACvB,MAAI,WAA0B,CAAC;AAE/B,aAAW,UAAU,SAAS;AAC5B,kBAAc;AAEd,QAAI,OAAO,SAAS,SAAS,QAAQ;AACnC,iBAAW,CAAC,OAAO,GAAG;AAEtB,UAAI,CAAC,aAAa,OAAO,GAAG,GAAG;AAC7B,uBAAe;AAAA,UACb,GAAG;AAAA,UACH,CAAC,OAAO,GAAG,GAAG,CAAC;AAAA,QACjB;AAAA,MACF;AACA,qBAAe,aAAa,OAAO,GAAG;AAAA,IACxC,WAAW,OAAO,SAAS,SAAS,OAAO;AACzC,iBAAW,CAAC,OAAO,GAAG;AAEtB,UAAI,CAAC,aAAa,OAAO,GAAG,GAAG;AAC7B,qBAAa,OAAO,GAAG,IAAI,CAAC;AAAA,MAC9B;AACA,qBAAe,aAAa,OAAO,GAAG;AAAA,IACxC,WAAW,OAAO,SAAS,SAAS,aAAa;AAC/C,iBAAW,CAAC,SAAS,aAAa,OAAO,GAAG;AAE5C,UAAI,CAAC,aAAa,SAAS,WAAW,GAAG;AACvC,qBAAa,SAAS,WAAW,IAAI;AAAA,UACnC,GAAG,aAAa,SAAS,WAAW;AAAA,UACpC,CAAC,OAAO,GAAG,GAAG;AAAA,QAChB;AAAA,MACF;AACA,qBAAe,aAAa,SAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,SAAS,aAAa;AAC/C,iBAAW,CAAC,SAAS,aAAa,OAAO,GAAG;AAE5C,UAAI,CAAC,aAAa,SAAS,WAAW,GAAG;AACvC,qBAAa,SAAS,WAAW,IAAI;AAAA,UACnC,GAAG,aAAa,SAAS,WAAW;AAAA,UACpC,CAAC,OAAO,GAAG,GAAG;AAAA,QAChB;AAAA,MACF;AACA,qBAAe,aAAa,SAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,SAAS,UAAU;AAC5C,iBAAW,CAAC,SAAS,QAAQ;AAC7B,UAAI,CAAC,aAAa,SAAS,QAAQ,GAAG;AACpC,qBAAa,SAAS,QAAQ,IAAI;AAAA,MACpC;AACA,qBAAe,aAAa,SAAS,QAAQ;AAAA,IAC/C,WAAW,OAAO,SAAS,SAAS,QAAQ;AAC1C,iBAAW,CAAC,SAAS,MAAM;AAC3B,UAAI,CAAC,aAAa,SAAS,MAAM,GAAG;AAClC,qBAAa,SAAS,MAAM,IAAI;AAAA,MAClC;AACA,qBAAe,aAAa,SAAS,MAAM;AAAA,IAC7C;AAGA,QAAI,eAAe,SAAS,SAAS,GAAG;AACtC,iBAAW,OAAO,SAAS,MAAM,GAAG,EAAE,GAAG;AACvC,sBAAc,YAAY,GAAG;AAAA,MAC/B;AACA;AAAA;AAAA,QAEE,OAAO,aAAa;AAAA,QACpB;AACA,eAAO,YAAY,SAAS,SAAS,SAAS,CAAC,CAAC;AAAA,MAClD,OAAO;AACL,oBAAY,SAAS,SAAS,SAAS,CAAC,CAAC,IAAI;AAAA,MAC/C;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NodeType } from "../types/index.mjs";
|
|
2
|
+
const getContentNodeByKeyPath = (dictionaryContent, keyPath) => {
|
|
3
|
+
let currentValue = JSON.parse(JSON.stringify(dictionaryContent ?? {}));
|
|
4
|
+
for (const keyObj of keyPath) {
|
|
5
|
+
if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {
|
|
6
|
+
currentValue = currentValue?.[keyObj.key];
|
|
7
|
+
} else if (keyObj.type === NodeType.Translation) {
|
|
8
|
+
currentValue = currentValue?.[NodeType.Translation][keyObj.key];
|
|
9
|
+
} else if (keyObj.type === NodeType.Enumeration) {
|
|
10
|
+
currentValue = currentValue?.[NodeType.Enumeration][keyObj.key];
|
|
11
|
+
} else if (keyObj.type === NodeType.Condition) {
|
|
12
|
+
currentValue = currentValue[NodeType.Condition];
|
|
13
|
+
} else if (keyObj.type === NodeType.Markdown) {
|
|
14
|
+
currentValue = currentValue[NodeType.Markdown];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return currentValue;
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
getContentNodeByKeyPath
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=getContentNodeByKeyPath.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../types';\nimport type { ContentNode } from '../types/dictionary';\n\nexport const getContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = JSON.parse(JSON.stringify(dictionaryContent ?? {}));\n\n for (const keyObj of keyPath) {\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n currentValue = currentValue?.[keyObj.key];\n } else if (keyObj.type === NodeType.Translation) {\n currentValue = currentValue?.[NodeType.Translation][keyObj.key];\n } else if (keyObj.type === NodeType.Enumeration) {\n currentValue = currentValue?.[NodeType.Enumeration][keyObj.key];\n } else if (keyObj.type === NodeType.Condition) {\n currentValue = currentValue[NodeType.Condition];\n } else if (keyObj.type === NodeType.Markdown) {\n currentValue = currentValue[NodeType.Markdown];\n }\n }\n\n return currentValue as ContentNode;\n};\n"],"mappings":"AAAA,SAAuB,gBAAgB;AAGhC,MAAM,0BAA0B,CACrC,mBACA,YACgB;AAChB,MAAI,eAAoB,KAAK,MAAM,KAAK,UAAU,qBAAqB,CAAC,CAAC,CAAC;AAE1E,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,SAAS,SAAS,UAAU,OAAO,SAAS,SAAS,OAAO;AACrE,qBAAe,eAAe,OAAO,GAAG;AAAA,IAC1C,WAAW,OAAO,SAAS,SAAS,aAAa;AAC/C,qBAAe,eAAe,SAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAChE,WAAW,OAAO,SAAS,SAAS,aAAa;AAC/C,qBAAe,eAAe,SAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAChE,WAAW,OAAO,SAAS,SAAS,WAAW;AAC7C,qBAAe,aAAa,SAAS,SAAS;AAAA,IAChD,WAAW,OAAO,SAAS,SAAS,UAAU;AAC5C,qBAAe,aAAa,SAAS,QAAQ;AAAA,IAC/C;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NodeType } from "../types/index.mjs";
|
|
2
|
+
import { isValidElement } from "../utils/isValidReactElement.mjs";
|
|
3
|
+
const getSectionType = (section) => {
|
|
4
|
+
if (typeof section === "string") {
|
|
5
|
+
return NodeType.Text;
|
|
6
|
+
}
|
|
7
|
+
if (section?.nodeType === NodeType.Translation) {
|
|
8
|
+
return NodeType.Translation;
|
|
9
|
+
}
|
|
10
|
+
if (section?.nodeType === NodeType.Enumeration) {
|
|
11
|
+
return NodeType.Enumeration;
|
|
12
|
+
}
|
|
13
|
+
if (section?.nodeType === NodeType.Condition) {
|
|
14
|
+
return NodeType.Condition;
|
|
15
|
+
}
|
|
16
|
+
if (section?.nodeType === NodeType.Markdown) {
|
|
17
|
+
return NodeType.Markdown;
|
|
18
|
+
}
|
|
19
|
+
if (section?.nodeType === NodeType.Nested) {
|
|
20
|
+
return NodeType.Nested;
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(section)) {
|
|
23
|
+
return NodeType.Array;
|
|
24
|
+
}
|
|
25
|
+
if (isValidElement(section)) {
|
|
26
|
+
return NodeType.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
return NodeType.Object;
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
getSectionType
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=getSectionType.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/getSectionType.ts"],"sourcesContent":["import type {\n TranslationContent,\n EnumerationContent,\n ConditionContent,\n MarkdownContent,\n NestedContent,\n} from '../transpiler';\nimport { NodeType, type DictionaryKeys } from '../types';\nimport type { ContentNode } from '../types/dictionary';\nimport { isValidElement } from '../utils/isValidReactElement';\n\nexport const getSectionType = (section: ContentNode): NodeType => {\n if (typeof section === 'string') {\n return NodeType.Text;\n }\n\n if (\n (section as TranslationContent<unknown>)?.nodeType === NodeType.Translation\n ) {\n return NodeType.Translation;\n }\n\n if (\n (section as EnumerationContent<unknown>)?.nodeType === NodeType.Enumeration\n ) {\n return NodeType.Enumeration;\n }\n\n if ((section as ConditionContent<unknown>)?.nodeType === NodeType.Condition) {\n return NodeType.Condition;\n }\n\n if ((section as MarkdownContent)?.nodeType === NodeType.Markdown) {\n return NodeType.Markdown;\n }\n\n if (\n (section as NestedContent<DictionaryKeys>)?.nodeType === NodeType.Nested\n ) {\n return NodeType.Nested;\n }\n\n if (Array.isArray(section)) {\n return NodeType.Array;\n }\n\n if (isValidElement(section)) {\n return NodeType.ReactNode;\n }\n\n return NodeType.Object;\n};\n"],"mappings":"AAOA,SAAS,gBAAqC;AAE9C,SAAS,sBAAsB;AAExB,MAAM,iBAAiB,CAAC,YAAmC;AAChE,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO,SAAS;AAAA,EAClB;AAEA,MACG,SAAyC,aAAa,SAAS,aAChE;AACA,WAAO,SAAS;AAAA,EAClB;AAEA,MACG,SAAyC,aAAa,SAAS,aAChE;AACA,WAAO,SAAS;AAAA,EAClB;AAEA,MAAK,SAAuC,aAAa,SAAS,WAAW;AAC3E,WAAO,SAAS;AAAA,EAClB;AAEA,MAAK,SAA6B,aAAa,SAAS,UAAU;AAChE,WAAO,SAAS;AAAA,EAClB;AAEA,MACG,SAA2C,aAAa,SAAS,QAClE;AACA,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,WAAO,SAAS;AAAA,EAClB;AAEA,MAAI,eAAe,OAAO,GAAG;AAC3B,WAAO,SAAS;AAAA,EAClB;AAEA,SAAO,SAAS;AAClB;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./editDictionaryByKeyPath.mjs";
|
|
2
|
+
export * from "./getContentNodeByKeyPath.mjs";
|
|
3
|
+
export * from "./getSectionType.mjs";
|
|
4
|
+
export * from "./removeContentNodeByKeyPath.mjs";
|
|
5
|
+
export * from "./renameContentNodeByKeyPath.mjs";
|
|
6
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/index.ts"],"sourcesContent":["export * from './editDictionaryByKeyPath';\nexport * from './getContentNodeByKeyPath';\nexport * from './getSectionType';\nexport * from './removeContentNodeByKeyPath';\nexport * from './renameContentNodeByKeyPath';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NodeType } from "../types/index.mjs";
|
|
2
|
+
const removeContentNodeByKeyPath = (dictionaryContent, keyPath) => {
|
|
3
|
+
let currentValue = dictionaryContent;
|
|
4
|
+
let parentValue = null;
|
|
5
|
+
let lastKey = null;
|
|
6
|
+
for (const keyObj of keyPath) {
|
|
7
|
+
parentValue = currentValue;
|
|
8
|
+
if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {
|
|
9
|
+
lastKey = keyObj.key;
|
|
10
|
+
currentValue = currentValue[keyObj.key];
|
|
11
|
+
} else if (keyObj.type === NodeType.Translation) {
|
|
12
|
+
lastKey = NodeType.Translation;
|
|
13
|
+
currentValue = currentValue[NodeType.Translation][keyObj.key];
|
|
14
|
+
} else if (keyObj.type === NodeType.Enumeration) {
|
|
15
|
+
lastKey = NodeType.Enumeration;
|
|
16
|
+
currentValue = currentValue[NodeType.Enumeration][keyObj.key];
|
|
17
|
+
} else if (keyObj.type === NodeType.Condition) {
|
|
18
|
+
lastKey = NodeType.Condition;
|
|
19
|
+
currentValue = currentValue[NodeType.Condition];
|
|
20
|
+
} else if (keyObj.type === NodeType.Markdown) {
|
|
21
|
+
lastKey = NodeType.Markdown;
|
|
22
|
+
currentValue = currentValue[NodeType.Markdown];
|
|
23
|
+
} else if (keyObj.type === NodeType.ReactNode) {
|
|
24
|
+
lastKey = NodeType.ReactNode;
|
|
25
|
+
currentValue = currentValue[NodeType.ReactNode];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (parentValue && lastKey !== null) {
|
|
29
|
+
if (Array.isArray(parentValue)) {
|
|
30
|
+
parentValue.splice(lastKey, 1);
|
|
31
|
+
} else {
|
|
32
|
+
delete parentValue[lastKey];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return dictionaryContent;
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
removeContentNodeByKeyPath
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=removeContentNodeByKeyPath.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/removeContentNodeByKeyPath.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../types';\nimport type { ContentNode } from '../types/dictionary';\n\nexport const removeContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n } else if (keyObj.type === NodeType.Translation) {\n lastKey = NodeType.Translation;\n currentValue = currentValue[NodeType.Translation][keyObj.key];\n } else if (keyObj.type === NodeType.Enumeration) {\n lastKey = NodeType.Enumeration;\n currentValue = currentValue[NodeType.Enumeration][keyObj.key];\n } else if (keyObj.type === NodeType.Condition) {\n lastKey = NodeType.Condition;\n currentValue = currentValue[NodeType.Condition];\n } else if (keyObj.type === NodeType.Markdown) {\n lastKey = NodeType.Markdown;\n currentValue = currentValue[NodeType.Markdown];\n } else if (keyObj.type === NodeType.ReactNode) {\n lastKey = NodeType.ReactNode;\n currentValue = currentValue[NodeType.ReactNode];\n }\n }\n\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue.splice(lastKey as unknown as number, 1);\n } else {\n delete parentValue[lastKey];\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":"AAAA,SAAuB,gBAAgB;AAGhC,MAAM,6BAA6B,CACxC,mBACA,YACgB;AAChB,MAAI,eAAoB;AACxB,MAAI,cAAmB;AACvB,MAAI,UAAkC;AAEtC,aAAW,UAAU,SAAS;AAC5B,kBAAc;AAEd,QAAI,OAAO,SAAS,SAAS,UAAU,OAAO,SAAS,SAAS,OAAO;AACrE,gBAAU,OAAO;AACjB,qBAAe,aAAa,OAAO,GAAG;AAAA,IACxC,WAAW,OAAO,SAAS,SAAS,aAAa;AAC/C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,SAAS,aAAa;AAC/C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,SAAS,WAAW;AAC7C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,SAAS;AAAA,IAChD,WAAW,OAAO,SAAS,SAAS,UAAU;AAC5C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,QAAQ;AAAA,IAC/C,WAAW,OAAO,SAAS,SAAS,WAAW;AAC7C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,SAAS;AAAA,IAChD;AAAA,EACF;AAEA,MAAI,eAAe,YAAY,MAAM;AACnC,QAAI,MAAM,QAAQ,WAAW,GAAG;AAC9B,kBAAY,OAAO,SAA8B,CAAC;AAAA,IACpD,OAAO;AACL,aAAO,YAAY,OAAO;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NodeType } from "../types/index.mjs";
|
|
2
|
+
const renameContentNodeByKeyPath = (dictionaryContent, newKey, keyPath) => {
|
|
3
|
+
let currentValue = dictionaryContent;
|
|
4
|
+
let parentValue = null;
|
|
5
|
+
let lastKey = null;
|
|
6
|
+
for (const keyObj of keyPath) {
|
|
7
|
+
parentValue = currentValue;
|
|
8
|
+
if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {
|
|
9
|
+
lastKey = keyObj.key;
|
|
10
|
+
currentValue = currentValue[keyObj.key];
|
|
11
|
+
} else if (keyObj.type === NodeType.Translation) {
|
|
12
|
+
lastKey = NodeType.Translation;
|
|
13
|
+
currentValue = currentValue[NodeType.Translation][keyObj.key];
|
|
14
|
+
} else if (keyObj.type === NodeType.Enumeration) {
|
|
15
|
+
lastKey = NodeType.Enumeration;
|
|
16
|
+
currentValue = currentValue[NodeType.Enumeration][keyObj.key];
|
|
17
|
+
} else if (keyObj.type === NodeType.Condition) {
|
|
18
|
+
lastKey = NodeType.Condition;
|
|
19
|
+
currentValue = currentValue[NodeType.Condition];
|
|
20
|
+
} else if (keyObj.type === NodeType.Markdown) {
|
|
21
|
+
lastKey = NodeType.Markdown;
|
|
22
|
+
currentValue = currentValue[NodeType.Markdown];
|
|
23
|
+
} else if (keyObj.type === NodeType.ReactNode) {
|
|
24
|
+
lastKey = NodeType.ReactNode;
|
|
25
|
+
currentValue = currentValue[NodeType.ReactNode];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (parentValue && lastKey !== null) {
|
|
29
|
+
if (Array.isArray(parentValue)) {
|
|
30
|
+
parentValue[lastKey] = currentValue;
|
|
31
|
+
} else {
|
|
32
|
+
const newParentValue = {};
|
|
33
|
+
for (const key of Object.keys(parentValue)) {
|
|
34
|
+
if (key === lastKey && typeof newKey !== "undefined") {
|
|
35
|
+
newParentValue[newKey] = currentValue;
|
|
36
|
+
} else {
|
|
37
|
+
newParentValue[key] = parentValue[key];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
Object.keys(parentValue).forEach((key) => delete parentValue[key]);
|
|
41
|
+
Object.assign(parentValue, newParentValue);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return dictionaryContent;
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
renameContentNodeByKeyPath
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=renameContentNodeByKeyPath.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/dictionaryManipulator/renameContentNodeByKeyPath.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '../types';\nimport type { ContentNode } from '../types/dictionary';\n\nexport const renameContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n newKey: KeyPath['key'],\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n } else if (keyObj.type === NodeType.Translation) {\n lastKey = NodeType.Translation;\n currentValue = currentValue[NodeType.Translation][keyObj.key];\n } else if (keyObj.type === NodeType.Enumeration) {\n lastKey = NodeType.Enumeration;\n currentValue = currentValue[NodeType.Enumeration][keyObj.key];\n } else if (keyObj.type === NodeType.Condition) {\n lastKey = NodeType.Condition;\n currentValue = currentValue[NodeType.Condition];\n } else if (keyObj.type === NodeType.Markdown) {\n lastKey = NodeType.Markdown;\n currentValue = currentValue[NodeType.Markdown];\n } else if (keyObj.type === NodeType.ReactNode) {\n lastKey = NodeType.ReactNode;\n currentValue = currentValue[NodeType.ReactNode];\n }\n }\n\n // Assign the new value to the last key of the parent while preserving the order\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue[lastKey as number] = currentValue;\n } else {\n const newParentValue: any = {};\n for (const key of Object.keys(parentValue)) {\n if (key === lastKey && typeof newKey !== 'undefined') {\n newParentValue[newKey] = currentValue;\n } else {\n newParentValue[key] = parentValue[key];\n }\n }\n // Replace the contents of parentValue with newParentValue\n Object.keys(parentValue).forEach((key) => delete parentValue[key]);\n Object.assign(parentValue, newParentValue);\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":"AAAA,SAAuB,gBAAgB;AAGhC,MAAM,6BAA6B,CACxC,mBACA,QACA,YACgB;AAChB,MAAI,eAAoB;AACxB,MAAI,cAAmB;AACvB,MAAI,UAAkC;AAEtC,aAAW,UAAU,SAAS;AAC5B,kBAAc;AAEd,QAAI,OAAO,SAAS,SAAS,UAAU,OAAO,SAAS,SAAS,OAAO;AACrE,gBAAU,OAAO;AACjB,qBAAe,aAAa,OAAO,GAAG;AAAA,IACxC,WAAW,OAAO,SAAS,SAAS,aAAa;AAC/C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,SAAS,aAAa;AAC/C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,SAAS,WAAW;AAC7C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,SAAS;AAAA,IAChD,WAAW,OAAO,SAAS,SAAS,UAAU;AAC5C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,QAAQ;AAAA,IAC/C,WAAW,OAAO,SAAS,SAAS,WAAW;AAC7C,gBAAU,SAAS;AACnB,qBAAe,aAAa,SAAS,SAAS;AAAA,IAChD;AAAA,EACF;AAGA,MAAI,eAAe,YAAY,MAAM;AACnC,QAAI,MAAM,QAAQ,WAAW,GAAG;AAC9B,kBAAY,OAAiB,IAAI;AAAA,IACnC,OAAO;AACL,YAAM,iBAAsB,CAAC;AAC7B,iBAAW,OAAO,OAAO,KAAK,WAAW,GAAG;AAC1C,YAAI,QAAQ,WAAW,OAAO,WAAW,aAAa;AACpD,yBAAe,MAAM,IAAI;AAAA,QAC3B,OAAO;AACL,yBAAe,GAAG,IAAI,YAAY,GAAG;AAAA,QACvC;AAAA,MACF;AAEA,aAAO,KAAK,WAAW,EAAE,QAAQ,CAAC,QAAQ,OAAO,YAAY,GAAG,CAAC;AACjE,aAAO,OAAO,aAAa,cAAc;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,35 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { getLocaleName } from "./getLocaleName.mjs";
|
|
10
|
-
import { getHTMLTextDir } from "./getHTMLTextDir.mjs";
|
|
11
|
-
import { getLocaleLang } from "./getLocaleLang.mjs";
|
|
12
|
-
import { localeList } from "./localeList.mjs";
|
|
13
|
-
import { isSameKeyPath } from "./utils/isSameKeyPath.mjs";
|
|
14
|
-
import { localeDetector } from "./localeDetector.mjs";
|
|
15
|
-
import { getPathWithoutLocale } from "./getPathWithoutLocale.mjs";
|
|
16
|
-
import { getMultilingualUrls } from "./getMultilingualUrls.mjs";
|
|
17
|
-
import { getLocalizedUrl } from "./getLocalizedUrl.mjs";
|
|
18
|
-
export {
|
|
19
|
-
NodeType,
|
|
20
|
-
enu,
|
|
21
|
-
findMatchingCondition,
|
|
22
|
-
getEnumerationContent,
|
|
23
|
-
getHTMLTextDir,
|
|
24
|
-
getLocaleLang,
|
|
25
|
-
getLocaleName,
|
|
26
|
-
getLocalizedUrl,
|
|
27
|
-
getMultilingualUrls,
|
|
28
|
-
getPathWithoutLocale,
|
|
29
|
-
getTranslationContent,
|
|
30
|
-
isSameKeyPath,
|
|
31
|
-
localeDetector,
|
|
32
|
-
localeList,
|
|
33
|
-
t
|
|
34
|
-
};
|
|
1
|
+
export * from "./transpiler/index.mjs";
|
|
2
|
+
export * from "./interpreter/index.mjs";
|
|
3
|
+
export * from "./dictionaryManipulator/index.mjs";
|
|
4
|
+
export * from "./types/index.mjs";
|
|
5
|
+
export * from "./utils/isSameKeyPath.mjs";
|
|
6
|
+
export * from "./utils/checkIsURLAbsolute.mjs";
|
|
7
|
+
export * from "./utils/isValidReactElement.mjs";
|
|
8
|
+
export * from "./localization/index.mjs";
|
|
35
9
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './transpiler/index';\nexport * from './interpreter/index';\nexport * from './dictionaryManipulator/index';\nexport * from './types/index';\nexport * from './utils/isSameKeyPath';\nexport * from './utils/checkIsURLAbsolute';\nexport * from './utils/isValidReactElement';\nexport * from './localization/index';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const getCondition = (conditionContent, state) => {
|
|
2
|
+
const stateList = Object.keys(conditionContent);
|
|
3
|
+
const fallbackState = stateList[stateList.length - 1];
|
|
4
|
+
return conditionContent[`${state}`] ?? conditionContent["fallback"] ?? conditionContent[fallbackState];
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
getCondition
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=getCondition.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/interpreter/getCondition.ts"],"sourcesContent":["import type { ConditionContentStates } from '../transpiler/condition/condition';\n\n/**\n * Allow to pick a content based on a condition.\n *\n * Usage:\n *\n * ```ts\n * const content = getCondition({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * }, true);\n * // 'The condition is validated'\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n * ```ts\n * const content = getCondition({\n * 'false': 'The condition is not validated',\n * 'true': 'The condition is validated',\n * }, undefined);\n * // 'The condition is validated'\n */\nexport const getCondition = <Content>(\n conditionContent: ConditionContentStates<Content>,\n state?: boolean\n): Content => {\n const stateList = Object.keys(conditionContent);\n const fallbackState = stateList[\n stateList.length - 1\n ] as keyof typeof conditionContent;\n\n // Default or error handling if no keys match\n return (\n conditionContent[`${state}` as keyof typeof conditionContent] ??\n conditionContent['fallback'] ??\n (conditionContent[fallbackState] as Content)\n );\n};\n"],"mappings":"AAwBO,MAAM,eAAe,CAC1B,kBACA,UACY;AACZ,QAAM,YAAY,OAAO,KAAK,gBAAgB;AAC9C,QAAM,gBAAgB,UACpB,UAAU,SAAS,CACrB;AAGA,SACE,iBAAiB,GAAG,KAAK,EAAmC,KAC5D,iBAAiB,UAAU,KAC1B,iBAAiB,aAAa;AAEnC;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { NodeType } from "../../types/index.mjs";
|
|
2
|
+
const deepTransformNode = (node, props) => {
|
|
3
|
+
for (const plugin of props.plugins ?? []) {
|
|
4
|
+
if (plugin.canHandle(node)) {
|
|
5
|
+
return plugin.transform(
|
|
6
|
+
node,
|
|
7
|
+
props,
|
|
8
|
+
(node2, props2) => deepTransformNode(node2, props2)
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (node === null || typeof node !== "object") {
|
|
13
|
+
return node;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(node)) {
|
|
16
|
+
return node.map((child, index) => {
|
|
17
|
+
const childProps = {
|
|
18
|
+
...props,
|
|
19
|
+
content: child,
|
|
20
|
+
keyPath: [
|
|
21
|
+
...props.keyPath,
|
|
22
|
+
{ type: NodeType.Array, key: index }
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
return deepTransformNode(child, childProps);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const result = {};
|
|
29
|
+
for (const key in node) {
|
|
30
|
+
const childProps = {
|
|
31
|
+
...props,
|
|
32
|
+
content: node[key],
|
|
33
|
+
keyPath: [...props.keyPath, { type: NodeType.Object, key }]
|
|
34
|
+
};
|
|
35
|
+
result[key] = deepTransformNode(node[key], childProps);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
deepTransformNode
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=deepTransform.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type KeyPath, NodeType } from '../../types/index';\nimport { NodeProps } from './plugins';\n\n/**\n * Recursively traverses a node (object/array/primitive).\n * Applies the *first* plugin that can transform a node, then stops descending further.\n * If no plugin transforms it, it recurses into its children.\n */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n content: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Array, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n // If no plugin transforms it, we keep traversing its properties.\n const result: Record<string, any> = {};\n for (const key in node) {\n const childProps = {\n ...props,\n content: node[key],\n keyPath: [...props.keyPath, { type: NodeType.Object, key } as KeyPath],\n };\n result[key] = deepTransformNode(node[key], childProps);\n }\n\n return result;\n};\n"],"mappings":"AACA,SAAuB,gBAAgB;AAQhC,MAAM,oBAAoB,CAAC,MAAW,UAA0B;AAErE,aAAW,UAAU,MAAM,WAAW,CAAC,GAAG;AACxC,QAAI,OAAO,UAAU,IAAI,GAAG;AAE1B,aAAO,OAAO;AAAA,QAAU;AAAA,QAAM;AAAA,QAAO,CAACA,OAAWC,WAC/C,kBAAkBD,OAAMC,MAAK;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAGA,MAAI,SAAS,QAAQ,OAAO,SAAS,UAAU;AAC7C,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,WAAO,KAAK,IAAI,CAAC,OAAO,UAAU;AAChC,YAAM,aAAa;AAAA,QACjB,GAAG;AAAA,QACH,SAAS;AAAA,QACT,SAAS;AAAA,UACP,GAAG,MAAM;AAAA,UACT,EAAE,MAAM,SAAS,OAAO,KAAK,MAAM;AAAA,QACrC;AAAA,MACF;AACA,aAAO,kBAAkB,OAAO,UAAU;AAAA,IAC5C,CAAC;AAAA,EACH;AAGA,QAAM,SAA8B,CAAC;AACrC,aAAW,OAAO,MAAM;AACtB,UAAM,aAAa;AAAA,MACjB,GAAG;AAAA,MACH,SAAS,KAAK,GAAG;AAAA,MACjB,SAAS,CAAC,GAAG,MAAM,SAAS,EAAE,MAAM,SAAS,QAAQ,IAAI,CAAY;AAAA,IACvE;AACA,WAAO,GAAG,IAAI,kBAAkB,KAAK,GAAG,GAAG,UAAU;AAAA,EACvD;AAEA,SAAO;AACT;","names":["node","props"]}
|