@intlayer/core 4.1.10 → 4.1.12
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 +9 -6
- 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,97 @@
|
|
|
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 editDictionaryByKeyPath_exports = {};
|
|
20
|
+
__export(editDictionaryByKeyPath_exports, {
|
|
21
|
+
editDictionaryByKeyPath: () => editDictionaryByKeyPath
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(editDictionaryByKeyPath_exports);
|
|
24
|
+
var import_types = require('../types/index.cjs');
|
|
25
|
+
const editDictionaryByKeyPath = (dictionaryContent, keyPath, newValue) => {
|
|
26
|
+
let currentValue = dictionaryContent;
|
|
27
|
+
let parentValue = null;
|
|
28
|
+
let lastKeys = [];
|
|
29
|
+
for (const keyObj of keyPath) {
|
|
30
|
+
parentValue = currentValue;
|
|
31
|
+
if (keyObj.type === import_types.NodeType.Object) {
|
|
32
|
+
lastKeys = [keyObj.key];
|
|
33
|
+
if (!currentValue[keyObj.key]) {
|
|
34
|
+
currentValue = {
|
|
35
|
+
...currentValue,
|
|
36
|
+
[keyObj.key]: {}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
currentValue = currentValue[keyObj.key];
|
|
40
|
+
} else if (keyObj.type === import_types.NodeType.Array) {
|
|
41
|
+
lastKeys = [keyObj.key];
|
|
42
|
+
if (!currentValue[keyObj.key]) {
|
|
43
|
+
currentValue[keyObj.key] = {};
|
|
44
|
+
}
|
|
45
|
+
currentValue = currentValue[keyObj.key];
|
|
46
|
+
} else if (keyObj.type === import_types.NodeType.Translation) {
|
|
47
|
+
lastKeys = [import_types.NodeType.Translation, keyObj.key];
|
|
48
|
+
if (!currentValue[import_types.NodeType.Translation]) {
|
|
49
|
+
currentValue[import_types.NodeType.Translation] = {
|
|
50
|
+
...currentValue[import_types.NodeType.Translation],
|
|
51
|
+
[keyObj.key]: newValue
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
currentValue = currentValue[import_types.NodeType.Translation][keyObj.key];
|
|
55
|
+
} else if (keyObj.type === import_types.NodeType.Enumeration) {
|
|
56
|
+
lastKeys = [import_types.NodeType.Enumeration, keyObj.key];
|
|
57
|
+
if (!currentValue[import_types.NodeType.Enumeration]) {
|
|
58
|
+
currentValue[import_types.NodeType.Enumeration] = {
|
|
59
|
+
...currentValue[import_types.NodeType.Enumeration],
|
|
60
|
+
[keyObj.key]: newValue
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
currentValue = currentValue[import_types.NodeType.Enumeration][keyObj.key];
|
|
64
|
+
} else if (keyObj.type === import_types.NodeType.Markdown) {
|
|
65
|
+
lastKeys = [import_types.NodeType.Markdown];
|
|
66
|
+
if (!currentValue[import_types.NodeType.Markdown]) {
|
|
67
|
+
currentValue[import_types.NodeType.Markdown] = newValue;
|
|
68
|
+
}
|
|
69
|
+
currentValue = currentValue[import_types.NodeType.Markdown];
|
|
70
|
+
} else if (keyObj.type === import_types.NodeType.Nested) {
|
|
71
|
+
lastKeys = [import_types.NodeType.Nested];
|
|
72
|
+
if (!currentValue[import_types.NodeType.Nested]) {
|
|
73
|
+
currentValue[import_types.NodeType.Nested] = newValue;
|
|
74
|
+
}
|
|
75
|
+
currentValue = currentValue[import_types.NodeType.Nested];
|
|
76
|
+
}
|
|
77
|
+
if (parentValue && lastKeys.length > 0) {
|
|
78
|
+
for (const key of lastKeys.slice(0, -1)) {
|
|
79
|
+
parentValue = parentValue[key];
|
|
80
|
+
}
|
|
81
|
+
if (
|
|
82
|
+
// Remove the field if the new value is undefined
|
|
83
|
+
typeof newValue === "undefined"
|
|
84
|
+
) {
|
|
85
|
+
delete parentValue[lastKeys[lastKeys.length - 1]];
|
|
86
|
+
} else {
|
|
87
|
+
parentValue[lastKeys[lastKeys.length - 1]] = newValue;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return dictionaryContent;
|
|
92
|
+
};
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
editDictionaryByKeyPath
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=editDictionaryByKeyPath.cjs.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAuC;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,sBAAS,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,sBAAS,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,sBAAS,aAAa;AAC/C,iBAAW,CAAC,sBAAS,aAAa,OAAO,GAAG;AAE5C,UAAI,CAAC,aAAa,sBAAS,WAAW,GAAG;AACvC,qBAAa,sBAAS,WAAW,IAAI;AAAA,UACnC,GAAG,aAAa,sBAAS,WAAW;AAAA,UACpC,CAAC,OAAO,GAAG,GAAG;AAAA,QAChB;AAAA,MACF;AACA,qBAAe,aAAa,sBAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,sBAAS,aAAa;AAC/C,iBAAW,CAAC,sBAAS,aAAa,OAAO,GAAG;AAE5C,UAAI,CAAC,aAAa,sBAAS,WAAW,GAAG;AACvC,qBAAa,sBAAS,WAAW,IAAI;AAAA,UACnC,GAAG,aAAa,sBAAS,WAAW;AAAA,UACpC,CAAC,OAAO,GAAG,GAAG;AAAA,QAChB;AAAA,MACF;AACA,qBAAe,aAAa,sBAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,sBAAS,UAAU;AAC5C,iBAAW,CAAC,sBAAS,QAAQ;AAC7B,UAAI,CAAC,aAAa,sBAAS,QAAQ,GAAG;AACpC,qBAAa,sBAAS,QAAQ,IAAI;AAAA,MACpC;AACA,qBAAe,aAAa,sBAAS,QAAQ;AAAA,IAC/C,WAAW,OAAO,SAAS,sBAAS,QAAQ;AAC1C,iBAAW,CAAC,sBAAS,MAAM;AAC3B,UAAI,CAAC,aAAa,sBAAS,MAAM,GAAG;AAClC,qBAAa,sBAAS,MAAM,IAAI;AAAA,MAClC;AACA,qBAAe,aAAa,sBAAS,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,46 @@
|
|
|
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 getContentNodeByKeyPath_exports = {};
|
|
20
|
+
__export(getContentNodeByKeyPath_exports, {
|
|
21
|
+
getContentNodeByKeyPath: () => getContentNodeByKeyPath
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getContentNodeByKeyPath_exports);
|
|
24
|
+
var import_types = require('../types/index.cjs');
|
|
25
|
+
const getContentNodeByKeyPath = (dictionaryContent, keyPath) => {
|
|
26
|
+
let currentValue = JSON.parse(JSON.stringify(dictionaryContent ?? {}));
|
|
27
|
+
for (const keyObj of keyPath) {
|
|
28
|
+
if (keyObj.type === import_types.NodeType.Object || keyObj.type === import_types.NodeType.Array) {
|
|
29
|
+
currentValue = currentValue?.[keyObj.key];
|
|
30
|
+
} else if (keyObj.type === import_types.NodeType.Translation) {
|
|
31
|
+
currentValue = currentValue?.[import_types.NodeType.Translation][keyObj.key];
|
|
32
|
+
} else if (keyObj.type === import_types.NodeType.Enumeration) {
|
|
33
|
+
currentValue = currentValue?.[import_types.NodeType.Enumeration][keyObj.key];
|
|
34
|
+
} else if (keyObj.type === import_types.NodeType.Condition) {
|
|
35
|
+
currentValue = currentValue[import_types.NodeType.Condition];
|
|
36
|
+
} else if (keyObj.type === import_types.NodeType.Markdown) {
|
|
37
|
+
currentValue = currentValue[import_types.NodeType.Markdown];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return currentValue;
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
getContentNodeByKeyPath
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=getContentNodeByKeyPath.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuC;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,sBAAS,UAAU,OAAO,SAAS,sBAAS,OAAO;AACrE,qBAAe,eAAe,OAAO,GAAG;AAAA,IAC1C,WAAW,OAAO,SAAS,sBAAS,aAAa;AAC/C,qBAAe,eAAe,sBAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAChE,WAAW,OAAO,SAAS,sBAAS,aAAa;AAC/C,qBAAe,eAAe,sBAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAChE,WAAW,OAAO,SAAS,sBAAS,WAAW;AAC7C,qBAAe,aAAa,sBAAS,SAAS;AAAA,IAChD,WAAW,OAAO,SAAS,sBAAS,UAAU;AAC5C,qBAAe,aAAa,sBAAS,QAAQ;AAAA,IAC/C;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
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 getSectionType_exports = {};
|
|
20
|
+
__export(getSectionType_exports, {
|
|
21
|
+
getSectionType: () => getSectionType
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getSectionType_exports);
|
|
24
|
+
var import_types = require('../types/index.cjs');
|
|
25
|
+
var import_isValidReactElement = require('../utils/isValidReactElement.cjs');
|
|
26
|
+
const getSectionType = (section) => {
|
|
27
|
+
if (typeof section === "string") {
|
|
28
|
+
return import_types.NodeType.Text;
|
|
29
|
+
}
|
|
30
|
+
if (section?.nodeType === import_types.NodeType.Translation) {
|
|
31
|
+
return import_types.NodeType.Translation;
|
|
32
|
+
}
|
|
33
|
+
if (section?.nodeType === import_types.NodeType.Enumeration) {
|
|
34
|
+
return import_types.NodeType.Enumeration;
|
|
35
|
+
}
|
|
36
|
+
if (section?.nodeType === import_types.NodeType.Condition) {
|
|
37
|
+
return import_types.NodeType.Condition;
|
|
38
|
+
}
|
|
39
|
+
if (section?.nodeType === import_types.NodeType.Markdown) {
|
|
40
|
+
return import_types.NodeType.Markdown;
|
|
41
|
+
}
|
|
42
|
+
if (section?.nodeType === import_types.NodeType.Nested) {
|
|
43
|
+
return import_types.NodeType.Nested;
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(section)) {
|
|
46
|
+
return import_types.NodeType.Array;
|
|
47
|
+
}
|
|
48
|
+
if ((0, import_isValidReactElement.isValidElement)(section)) {
|
|
49
|
+
return import_types.NodeType.ReactNode;
|
|
50
|
+
}
|
|
51
|
+
return import_types.NodeType.Object;
|
|
52
|
+
};
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
getSectionType
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=getSectionType.cjs.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,mBAA8C;AAE9C,iCAA+B;AAExB,MAAM,iBAAiB,CAAC,YAAmC;AAChE,MAAI,OAAO,YAAY,UAAU;AAC/B,WAAO,sBAAS;AAAA,EAClB;AAEA,MACG,SAAyC,aAAa,sBAAS,aAChE;AACA,WAAO,sBAAS;AAAA,EAClB;AAEA,MACG,SAAyC,aAAa,sBAAS,aAChE;AACA,WAAO,sBAAS;AAAA,EAClB;AAEA,MAAK,SAAuC,aAAa,sBAAS,WAAW;AAC3E,WAAO,sBAAS;AAAA,EAClB;AAEA,MAAK,SAA6B,aAAa,sBAAS,UAAU;AAChE,WAAO,sBAAS;AAAA,EAClB;AAEA,MACG,SAA2C,aAAa,sBAAS,QAClE;AACA,WAAO,sBAAS;AAAA,EAClB;AAEA,MAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,WAAO,sBAAS;AAAA,EAClB;AAEA,UAAI,2CAAe,OAAO,GAAG;AAC3B,WAAO,sBAAS;AAAA,EAClB;AAEA,SAAO,sBAAS;AAClB;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var dictionaryManipulator_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(dictionaryManipulator_exports);
|
|
18
|
+
__reExport(dictionaryManipulator_exports, require('./editDictionaryByKeyPath.cjs'), module.exports);
|
|
19
|
+
__reExport(dictionaryManipulator_exports, require('./getContentNodeByKeyPath.cjs'), module.exports);
|
|
20
|
+
__reExport(dictionaryManipulator_exports, require('./getSectionType.cjs'), module.exports);
|
|
21
|
+
__reExport(dictionaryManipulator_exports, require('./removeContentNodeByKeyPath.cjs'), module.exports);
|
|
22
|
+
__reExport(dictionaryManipulator_exports, require('./renameContentNodeByKeyPath.cjs'), module.exports);
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
...require('./editDictionaryByKeyPath.cjs'),
|
|
26
|
+
...require('./getContentNodeByKeyPath.cjs'),
|
|
27
|
+
...require('./getSectionType.cjs'),
|
|
28
|
+
...require('./removeContentNodeByKeyPath.cjs'),
|
|
29
|
+
...require('./renameContentNodeByKeyPath.cjs')
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=index.cjs.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;AAAA;AAAA,0CAAc,sCAAd;AACA,0CAAc,sCADd;AAEA,0CAAc,6BAFd;AAGA,0CAAc,yCAHd;AAIA,0CAAc,yCAJd;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 removeContentNodeByKeyPath_exports = {};
|
|
20
|
+
__export(removeContentNodeByKeyPath_exports, {
|
|
21
|
+
removeContentNodeByKeyPath: () => removeContentNodeByKeyPath
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(removeContentNodeByKeyPath_exports);
|
|
24
|
+
var import_types = require('../types/index.cjs');
|
|
25
|
+
const removeContentNodeByKeyPath = (dictionaryContent, keyPath) => {
|
|
26
|
+
let currentValue = dictionaryContent;
|
|
27
|
+
let parentValue = null;
|
|
28
|
+
let lastKey = null;
|
|
29
|
+
for (const keyObj of keyPath) {
|
|
30
|
+
parentValue = currentValue;
|
|
31
|
+
if (keyObj.type === import_types.NodeType.Object || keyObj.type === import_types.NodeType.Array) {
|
|
32
|
+
lastKey = keyObj.key;
|
|
33
|
+
currentValue = currentValue[keyObj.key];
|
|
34
|
+
} else if (keyObj.type === import_types.NodeType.Translation) {
|
|
35
|
+
lastKey = import_types.NodeType.Translation;
|
|
36
|
+
currentValue = currentValue[import_types.NodeType.Translation][keyObj.key];
|
|
37
|
+
} else if (keyObj.type === import_types.NodeType.Enumeration) {
|
|
38
|
+
lastKey = import_types.NodeType.Enumeration;
|
|
39
|
+
currentValue = currentValue[import_types.NodeType.Enumeration][keyObj.key];
|
|
40
|
+
} else if (keyObj.type === import_types.NodeType.Condition) {
|
|
41
|
+
lastKey = import_types.NodeType.Condition;
|
|
42
|
+
currentValue = currentValue[import_types.NodeType.Condition];
|
|
43
|
+
} else if (keyObj.type === import_types.NodeType.Markdown) {
|
|
44
|
+
lastKey = import_types.NodeType.Markdown;
|
|
45
|
+
currentValue = currentValue[import_types.NodeType.Markdown];
|
|
46
|
+
} else if (keyObj.type === import_types.NodeType.ReactNode) {
|
|
47
|
+
lastKey = import_types.NodeType.ReactNode;
|
|
48
|
+
currentValue = currentValue[import_types.NodeType.ReactNode];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (parentValue && lastKey !== null) {
|
|
52
|
+
if (Array.isArray(parentValue)) {
|
|
53
|
+
parentValue.splice(lastKey, 1);
|
|
54
|
+
} else {
|
|
55
|
+
delete parentValue[lastKey];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return dictionaryContent;
|
|
59
|
+
};
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
removeContentNodeByKeyPath
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=removeContentNodeByKeyPath.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuC;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,sBAAS,UAAU,OAAO,SAAS,sBAAS,OAAO;AACrE,gBAAU,OAAO;AACjB,qBAAe,aAAa,OAAO,GAAG;AAAA,IACxC,WAAW,OAAO,SAAS,sBAAS,aAAa;AAC/C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,sBAAS,aAAa;AAC/C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,sBAAS,WAAW;AAC7C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,SAAS;AAAA,IAChD,WAAW,OAAO,SAAS,sBAAS,UAAU;AAC5C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,QAAQ;AAAA,IAC/C,WAAW,OAAO,SAAS,sBAAS,WAAW;AAC7C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,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,73 @@
|
|
|
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 renameContentNodeByKeyPath_exports = {};
|
|
20
|
+
__export(renameContentNodeByKeyPath_exports, {
|
|
21
|
+
renameContentNodeByKeyPath: () => renameContentNodeByKeyPath
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(renameContentNodeByKeyPath_exports);
|
|
24
|
+
var import_types = require('../types/index.cjs');
|
|
25
|
+
const renameContentNodeByKeyPath = (dictionaryContent, newKey, keyPath) => {
|
|
26
|
+
let currentValue = dictionaryContent;
|
|
27
|
+
let parentValue = null;
|
|
28
|
+
let lastKey = null;
|
|
29
|
+
for (const keyObj of keyPath) {
|
|
30
|
+
parentValue = currentValue;
|
|
31
|
+
if (keyObj.type === import_types.NodeType.Object || keyObj.type === import_types.NodeType.Array) {
|
|
32
|
+
lastKey = keyObj.key;
|
|
33
|
+
currentValue = currentValue[keyObj.key];
|
|
34
|
+
} else if (keyObj.type === import_types.NodeType.Translation) {
|
|
35
|
+
lastKey = import_types.NodeType.Translation;
|
|
36
|
+
currentValue = currentValue[import_types.NodeType.Translation][keyObj.key];
|
|
37
|
+
} else if (keyObj.type === import_types.NodeType.Enumeration) {
|
|
38
|
+
lastKey = import_types.NodeType.Enumeration;
|
|
39
|
+
currentValue = currentValue[import_types.NodeType.Enumeration][keyObj.key];
|
|
40
|
+
} else if (keyObj.type === import_types.NodeType.Condition) {
|
|
41
|
+
lastKey = import_types.NodeType.Condition;
|
|
42
|
+
currentValue = currentValue[import_types.NodeType.Condition];
|
|
43
|
+
} else if (keyObj.type === import_types.NodeType.Markdown) {
|
|
44
|
+
lastKey = import_types.NodeType.Markdown;
|
|
45
|
+
currentValue = currentValue[import_types.NodeType.Markdown];
|
|
46
|
+
} else if (keyObj.type === import_types.NodeType.ReactNode) {
|
|
47
|
+
lastKey = import_types.NodeType.ReactNode;
|
|
48
|
+
currentValue = currentValue[import_types.NodeType.ReactNode];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (parentValue && lastKey !== null) {
|
|
52
|
+
if (Array.isArray(parentValue)) {
|
|
53
|
+
parentValue[lastKey] = currentValue;
|
|
54
|
+
} else {
|
|
55
|
+
const newParentValue = {};
|
|
56
|
+
for (const key of Object.keys(parentValue)) {
|
|
57
|
+
if (key === lastKey && typeof newKey !== "undefined") {
|
|
58
|
+
newParentValue[newKey] = currentValue;
|
|
59
|
+
} else {
|
|
60
|
+
newParentValue[key] = parentValue[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
Object.keys(parentValue).forEach((key) => delete parentValue[key]);
|
|
64
|
+
Object.assign(parentValue, newParentValue);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return dictionaryContent;
|
|
68
|
+
};
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
renameContentNodeByKeyPath
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=renameContentNodeByKeyPath.cjs.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;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuC;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,sBAAS,UAAU,OAAO,SAAS,sBAAS,OAAO;AACrE,gBAAU,OAAO;AACjB,qBAAe,aAAa,OAAO,GAAG;AAAA,IACxC,WAAW,OAAO,SAAS,sBAAS,aAAa;AAC/C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,sBAAS,aAAa;AAC/C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,WAAW,EAAE,OAAO,GAAG;AAAA,IAC9D,WAAW,OAAO,SAAS,sBAAS,WAAW;AAC7C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,SAAS;AAAA,IAChD,WAAW,OAAO,SAAS,sBAAS,UAAU;AAC5C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,QAAQ;AAAA,IAC/C,WAAW,OAAO,SAAS,sBAAS,WAAW;AAC7C,gBAAU,sBAAS;AACnB,qBAAe,aAAa,sBAAS,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/cjs/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,53 +11,27 @@ 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 index_exports = {};
|
|
20
|
-
__export(index_exports, {
|
|
21
|
-
NodeType: () => import_types.NodeType,
|
|
22
|
-
enu: () => import_content_transformers.enu,
|
|
23
|
-
findMatchingCondition: () => import_content_transformers.findMatchingCondition,
|
|
24
|
-
getEnumerationContent: () => import_content_transformers.getEnumerationContent,
|
|
25
|
-
getHTMLTextDir: () => import_getHTMLTextDir.getHTMLTextDir,
|
|
26
|
-
getLocaleLang: () => import_getLocaleLang.getLocaleLang,
|
|
27
|
-
getLocaleName: () => import_getLocaleName.getLocaleName,
|
|
28
|
-
getLocalizedUrl: () => import_getLocalizedUrl.getLocalizedUrl,
|
|
29
|
-
getMultilingualUrls: () => import_getMultilingualUrls.getMultilingualUrls,
|
|
30
|
-
getPathWithoutLocale: () => import_getPathWithoutLocale.getPathWithoutLocale,
|
|
31
|
-
getTranslationContent: () => import_content_transformers.getTranslationContent,
|
|
32
|
-
isSameKeyPath: () => import_isSameKeyPath.isSameKeyPath,
|
|
33
|
-
localeDetector: () => import_localeDetector.localeDetector,
|
|
34
|
-
localeList: () => import_localeList.localeList,
|
|
35
|
-
t: () => import_content_transformers.t
|
|
36
|
-
});
|
|
37
17
|
module.exports = __toCommonJS(index_exports);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var import_getPathWithoutLocale = require('./getPathWithoutLocale.cjs');
|
|
47
|
-
var import_getMultilingualUrls = require('./getMultilingualUrls.cjs');
|
|
48
|
-
var import_getLocalizedUrl = require('./getLocalizedUrl.cjs');
|
|
18
|
+
__reExport(index_exports, require('./transpiler/index.cjs'), module.exports);
|
|
19
|
+
__reExport(index_exports, require('./interpreter/index.cjs'), module.exports);
|
|
20
|
+
__reExport(index_exports, require('./dictionaryManipulator/index.cjs'), module.exports);
|
|
21
|
+
__reExport(index_exports, require('./types/index.cjs'), module.exports);
|
|
22
|
+
__reExport(index_exports, require('./utils/isSameKeyPath.cjs'), module.exports);
|
|
23
|
+
__reExport(index_exports, require('./utils/checkIsURLAbsolute.cjs'), module.exports);
|
|
24
|
+
__reExport(index_exports, require('./utils/isValidReactElement.cjs'), module.exports);
|
|
25
|
+
__reExport(index_exports, require('./localization/index.cjs'), module.exports);
|
|
49
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
27
|
0 && (module.exports = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
getMultilingualUrls,
|
|
60
|
-
getPathWithoutLocale,
|
|
61
|
-
getTranslationContent,
|
|
62
|
-
isSameKeyPath,
|
|
63
|
-
localeDetector,
|
|
64
|
-
localeList,
|
|
65
|
-
t
|
|
28
|
+
...require('./transpiler/index.cjs'),
|
|
29
|
+
...require('./interpreter/index.cjs'),
|
|
30
|
+
...require('./dictionaryManipulator/index.cjs'),
|
|
31
|
+
...require('./types/index.cjs'),
|
|
32
|
+
...require('./utils/isSameKeyPath.cjs'),
|
|
33
|
+
...require('./utils/checkIsURLAbsolute.cjs'),
|
|
34
|
+
...require('./utils/isValidReactElement.cjs'),
|
|
35
|
+
...require('./localization/index.cjs')
|
|
66
36
|
});
|
|
67
37
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.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;AAAA;AAAA,0BAAc,+BAAd;AACA,0BAAc,gCADd;AAEA,0BAAc,0CAFd;AAGA,0BAAc,0BAHd;AAIA,0BAAc,kCAJd;AAKA,0BAAc,uCALd;AAMA,0BAAc,wCANd;AAOA,0BAAc,iCAPd;","names":[]}
|
|
@@ -16,18 +16,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var getCondition_exports = {};
|
|
20
|
+
__export(getCondition_exports, {
|
|
21
|
+
getCondition: () => getCondition
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
return
|
|
23
|
+
module.exports = __toCommonJS(getCondition_exports);
|
|
24
|
+
const getCondition = (conditionContent, state) => {
|
|
25
|
+
const stateList = Object.keys(conditionContent);
|
|
26
|
+
const fallbackState = stateList[stateList.length - 1];
|
|
27
|
+
return conditionContent[`${state}`] ?? conditionContent["fallback"] ?? conditionContent[fallbackState];
|
|
28
28
|
};
|
|
29
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
30
|
0 && (module.exports = {
|
|
31
|
-
|
|
31
|
+
getCondition
|
|
32
32
|
});
|
|
33
|
-
//# sourceMappingURL=
|
|
33
|
+
//# sourceMappingURL=getCondition.cjs.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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,66 @@
|
|
|
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 deepTransform_exports = {};
|
|
20
|
+
__export(deepTransform_exports, {
|
|
21
|
+
deepTransformNode: () => deepTransformNode
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(deepTransform_exports);
|
|
24
|
+
var import_types = require('../../types/index.cjs');
|
|
25
|
+
const deepTransformNode = (node, props) => {
|
|
26
|
+
for (const plugin of props.plugins ?? []) {
|
|
27
|
+
if (plugin.canHandle(node)) {
|
|
28
|
+
return plugin.transform(
|
|
29
|
+
node,
|
|
30
|
+
props,
|
|
31
|
+
(node2, props2) => deepTransformNode(node2, props2)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (node === null || typeof node !== "object") {
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(node)) {
|
|
39
|
+
return node.map((child, index) => {
|
|
40
|
+
const childProps = {
|
|
41
|
+
...props,
|
|
42
|
+
content: child,
|
|
43
|
+
keyPath: [
|
|
44
|
+
...props.keyPath,
|
|
45
|
+
{ type: import_types.NodeType.Array, key: index }
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
return deepTransformNode(child, childProps);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const result = {};
|
|
52
|
+
for (const key in node) {
|
|
53
|
+
const childProps = {
|
|
54
|
+
...props,
|
|
55
|
+
content: node[key],
|
|
56
|
+
keyPath: [...props.keyPath, { type: import_types.NodeType.Object, key }]
|
|
57
|
+
};
|
|
58
|
+
result[key] = deepTransformNode(node[key], childProps);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
deepTransformNode
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=deepTransform.cjs.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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAuC;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,sBAAS,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,sBAAS,QAAQ,IAAI,CAAY;AAAA,IACvE;AACA,WAAO,GAAG,IAAI,kBAAkB,KAAK,GAAG,GAAG,UAAU;AAAA,EACvD;AAEA,SAAO;AACT;","names":["node","props"]}
|