@generaltranslation/react-core 2.0.0-odysseus.1 → 11.0.0-odysseus.9
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/CHANGELOG.md +95 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/components/branches/Branch.cjs +2 -0
- package/dist/components/branches/Branch.cjs.map +1 -0
- package/dist/components/branches/Branch.d.ts +30 -0
- package/dist/components/branches/Branch.d.ts.map +1 -0
- package/dist/components/branches/Branch.mjs +2 -0
- package/dist/components/branches/Branch.mjs.map +1 -0
- package/dist/components/branches/Plural.cjs +2 -0
- package/dist/components/branches/Plural.cjs.map +1 -0
- package/dist/components/branches/Plural.d.ts +19 -0
- package/dist/components/branches/Plural.d.ts.map +1 -0
- package/dist/components/branches/Plural.mjs +2 -0
- package/dist/components/branches/Plural.mjs.map +1 -0
- package/dist/components/branches/Plural.rsc.cjs +2 -0
- package/dist/components/branches/Plural.rsc.cjs.map +1 -0
- package/dist/components/branches/Plural.rsc.d.ts +15 -0
- package/dist/components/branches/Plural.rsc.d.ts.map +1 -0
- package/dist/components/branches/Plural.rsc.mjs +2 -0
- package/dist/components/branches/Plural.rsc.mjs.map +1 -0
- package/dist/components/branches/Plural.shared.cjs +2 -0
- package/dist/components/branches/Plural.shared.cjs.map +1 -0
- package/dist/components/branches/Plural.shared.d.ts +18 -0
- package/dist/components/branches/Plural.shared.d.ts.map +1 -0
- package/dist/components/branches/Plural.shared.mjs +2 -0
- package/dist/components/branches/Plural.shared.mjs.map +1 -0
- package/dist/components/derivation/Derive.cjs +2 -0
- package/dist/components/derivation/Derive.cjs.map +1 -0
- package/dist/components/derivation/Derive.d.ts +19 -0
- package/dist/components/derivation/Derive.d.ts.map +1 -0
- package/dist/components/derivation/Derive.mjs +2 -0
- package/dist/components/derivation/Derive.mjs.map +1 -0
- package/dist/components/helpers/InternalLocaleSelector.cjs +2 -0
- package/dist/components/helpers/InternalLocaleSelector.cjs.map +1 -0
- package/dist/components/helpers/InternalLocaleSelector.d.ts +38 -0
- package/dist/components/helpers/InternalLocaleSelector.d.ts.map +1 -0
- package/dist/components/helpers/InternalLocaleSelector.mjs +2 -0
- package/dist/components/helpers/InternalLocaleSelector.mjs.map +1 -0
- package/dist/components/helpers/InternalRegionSelector.cjs +2 -0
- package/dist/components/helpers/InternalRegionSelector.cjs.map +1 -0
- package/dist/components/helpers/InternalRegionSelector.d.ts +33 -0
- package/dist/components/helpers/InternalRegionSelector.d.ts.map +1 -0
- package/dist/components/helpers/InternalRegionSelector.mjs +2 -0
- package/dist/components/helpers/InternalRegionSelector.mjs.map +1 -0
- package/dist/components/translation/T.cjs +2 -0
- package/dist/components/translation/T.cjs.map +1 -0
- package/dist/components/translation/T.d.ts +18 -0
- package/dist/components/translation/T.d.ts.map +1 -0
- package/dist/components/translation/T.mjs +2 -0
- package/dist/components/translation/T.mjs.map +1 -0
- package/dist/components/translation/T.rsc.cjs +2 -0
- package/dist/components/translation/T.rsc.cjs.map +1 -0
- package/dist/components/translation/T.rsc.d.ts +17 -0
- package/dist/components/translation/T.rsc.d.ts.map +1 -0
- package/dist/components/translation/T.rsc.mjs +2 -0
- package/dist/components/translation/T.rsc.mjs.map +1 -0
- package/dist/components/translation/Tx.rsc.cjs +2 -0
- package/dist/components/translation/Tx.rsc.cjs.map +1 -0
- package/dist/components/translation/Tx.rsc.d.ts +17 -0
- package/dist/components/translation/Tx.rsc.d.ts.map +1 -0
- package/dist/components/translation/Tx.rsc.mjs +2 -0
- package/dist/components/translation/Tx.rsc.mjs.map +1 -0
- package/dist/components/variables/Currency.cjs +2 -0
- package/dist/components/variables/Currency.cjs.map +1 -0
- package/dist/components/variables/Currency.d.ts +18 -0
- package/dist/components/variables/Currency.d.ts.map +1 -0
- package/dist/components/variables/Currency.mjs +2 -0
- package/dist/components/variables/Currency.mjs.map +1 -0
- package/dist/components/variables/Currency.rsc.cjs +2 -0
- package/dist/components/variables/Currency.rsc.cjs.map +1 -0
- package/dist/components/variables/Currency.rsc.d.ts +14 -0
- package/dist/components/variables/Currency.rsc.d.ts.map +1 -0
- package/dist/components/variables/Currency.rsc.mjs +2 -0
- package/dist/components/variables/Currency.rsc.mjs.map +1 -0
- package/dist/components/variables/Currency.shared.cjs +2 -0
- package/dist/components/variables/Currency.shared.cjs.map +1 -0
- package/dist/components/variables/Currency.shared.d.ts +17 -0
- package/dist/components/variables/Currency.shared.d.ts.map +1 -0
- package/dist/components/variables/Currency.shared.mjs +2 -0
- package/dist/components/variables/Currency.shared.mjs.map +1 -0
- package/dist/components/variables/DateTime.cjs +2 -0
- package/dist/components/variables/DateTime.cjs.map +1 -0
- package/dist/components/variables/DateTime.d.ts +18 -0
- package/dist/components/variables/DateTime.d.ts.map +1 -0
- package/dist/components/variables/DateTime.mjs +2 -0
- package/dist/components/variables/DateTime.mjs.map +1 -0
- package/dist/components/variables/DateTime.rsc.cjs +2 -0
- package/dist/components/variables/DateTime.rsc.cjs.map +1 -0
- package/dist/components/variables/DateTime.rsc.d.ts +14 -0
- package/dist/components/variables/DateTime.rsc.d.ts.map +1 -0
- package/dist/components/variables/DateTime.rsc.mjs +2 -0
- package/dist/components/variables/DateTime.rsc.mjs.map +1 -0
- package/dist/components/variables/DateTime.shared.cjs +2 -0
- package/dist/components/variables/DateTime.shared.cjs.map +1 -0
- package/dist/components/variables/DateTime.shared.d.ts +16 -0
- package/dist/components/variables/DateTime.shared.d.ts.map +1 -0
- package/dist/components/variables/DateTime.shared.mjs +2 -0
- package/dist/components/variables/DateTime.shared.mjs.map +1 -0
- package/dist/components/variables/Num.cjs +2 -0
- package/dist/components/variables/Num.cjs.map +1 -0
- package/dist/components/variables/Num.d.ts +18 -0
- package/dist/components/variables/Num.d.ts.map +1 -0
- package/dist/components/variables/Num.mjs +2 -0
- package/dist/components/variables/Num.mjs.map +1 -0
- package/dist/components/variables/Num.rsc.cjs +2 -0
- package/dist/components/variables/Num.rsc.cjs.map +1 -0
- package/dist/components/variables/Num.rsc.d.ts +14 -0
- package/dist/components/variables/Num.rsc.d.ts.map +1 -0
- package/dist/components/variables/Num.rsc.mjs +2 -0
- package/dist/components/variables/Num.rsc.mjs.map +1 -0
- package/dist/components/variables/Num.shared.cjs +2 -0
- package/dist/components/variables/Num.shared.cjs.map +1 -0
- package/dist/components/variables/Num.shared.d.ts +16 -0
- package/dist/components/variables/Num.shared.d.ts.map +1 -0
- package/dist/components/variables/Num.shared.mjs +2 -0
- package/dist/components/variables/Num.shared.mjs.map +1 -0
- package/dist/components/variables/RelativeTime.cjs +2 -0
- package/dist/components/variables/RelativeTime.cjs.map +1 -0
- package/dist/components/variables/RelativeTime.d.ts +18 -0
- package/dist/components/variables/RelativeTime.d.ts.map +1 -0
- package/dist/components/variables/RelativeTime.mjs +2 -0
- package/dist/components/variables/RelativeTime.mjs.map +1 -0
- package/dist/components/variables/RelativeTime.rsc.cjs +2 -0
- package/dist/components/variables/RelativeTime.rsc.cjs.map +1 -0
- package/dist/components/variables/RelativeTime.rsc.d.ts +14 -0
- package/dist/components/variables/RelativeTime.rsc.d.ts.map +1 -0
- package/dist/components/variables/RelativeTime.rsc.mjs +2 -0
- package/dist/components/variables/RelativeTime.rsc.mjs.map +1 -0
- package/dist/components/variables/RelativeTime.shared.cjs +2 -0
- package/dist/components/variables/RelativeTime.shared.cjs.map +1 -0
- package/dist/components/variables/RelativeTime.shared.d.ts +20 -0
- package/dist/components/variables/RelativeTime.shared.d.ts.map +1 -0
- package/dist/components/variables/RelativeTime.shared.mjs +2 -0
- package/dist/components/variables/RelativeTime.shared.mjs.map +1 -0
- package/dist/components/variables/Var.cjs +2 -0
- package/dist/components/variables/Var.cjs.map +1 -0
- package/dist/components/variables/Var.d.ts +27 -0
- package/dist/components/variables/Var.d.ts.map +1 -0
- package/dist/components/variables/Var.mjs +2 -0
- package/dist/components/variables/Var.mjs.map +1 -0
- package/dist/components-rsc.cjs +1 -0
- package/dist/components-rsc.d.ts +32 -531
- package/dist/components-rsc.mjs +1 -0
- package/dist/components.cjs +1 -0
- package/dist/components.d.ts +14 -495
- package/dist/components.mjs +1 -0
- package/dist/condition-store/singleton-operations.cjs +2 -0
- package/dist/condition-store/singleton-operations.cjs.map +1 -0
- package/dist/condition-store/singleton-operations.d.ts +12 -0
- package/dist/condition-store/singleton-operations.d.ts.map +1 -0
- package/dist/condition-store/singleton-operations.mjs +2 -0
- package/dist/condition-store/singleton-operations.mjs.map +1 -0
- package/dist/context/InternalGTProvider.cjs +2 -0
- package/dist/context/InternalGTProvider.cjs.map +1 -0
- package/dist/context/InternalGTProvider.d.ts +39 -0
- package/dist/context/InternalGTProvider.d.ts.map +1 -0
- package/dist/context/InternalGTProvider.mjs +2 -0
- package/dist/context/InternalGTProvider.mjs.map +1 -0
- package/dist/context/context.cjs +2 -0
- package/dist/context/context.cjs.map +1 -0
- package/dist/context/context.mjs +2 -0
- package/dist/context/context.mjs.map +1 -0
- package/dist/cookies.cjs +1 -0
- package/dist/cookies.d.ts +2 -0
- package/dist/cookies.mjs +1 -0
- package/dist/functions/helpers/getTranslationsSnapshot.cjs +2 -0
- package/dist/functions/helpers/getTranslationsSnapshot.cjs.map +1 -0
- package/dist/functions/helpers/getTranslationsSnapshot.d.ts +14 -0
- package/dist/functions/helpers/getTranslationsSnapshot.d.ts.map +1 -0
- package/dist/functions/helpers/getTranslationsSnapshot.mjs +2 -0
- package/dist/functions/helpers/getTranslationsSnapshot.mjs.map +1 -0
- package/dist/functions/translation/t.cjs +2 -0
- package/dist/functions/translation/t.cjs.map +1 -0
- package/dist/functions/translation/t.d.ts +34 -0
- package/dist/functions/translation/t.d.ts.map +1 -0
- package/dist/functions/translation/t.mjs +2 -0
- package/dist/functions/translation/t.mjs.map +1 -0
- package/dist/hooks/condition-store.cjs +2 -0
- package/dist/hooks/condition-store.cjs.map +1 -0
- package/dist/hooks/condition-store.d.ts +23 -0
- package/dist/hooks/condition-store.d.ts.map +1 -0
- package/dist/hooks/condition-store.mjs +2 -0
- package/dist/hooks/condition-store.mjs.map +1 -0
- package/dist/hooks/external-store/useTrackedDictionaryObjResolver.cjs +2 -0
- package/dist/hooks/external-store/useTrackedDictionaryObjResolver.cjs.map +1 -0
- package/dist/hooks/external-store/useTrackedDictionaryObjResolver.mjs +2 -0
- package/dist/hooks/external-store/useTrackedDictionaryObjResolver.mjs.map +1 -0
- package/dist/hooks/external-store/useTrackedDictionaryResolver.cjs +2 -0
- package/dist/hooks/external-store/useTrackedDictionaryResolver.cjs.map +1 -0
- package/dist/hooks/external-store/useTrackedDictionaryResolver.mjs +2 -0
- package/dist/hooks/external-store/useTrackedDictionaryResolver.mjs.map +1 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.cjs +2 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.cjs.map +1 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.d.ts +10 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.d.ts.map +1 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.mjs +2 -0
- package/dist/hooks/external-store/useTrackedTranslationResolver.mjs.map +1 -0
- package/dist/hooks/external-store.cjs +2 -0
- package/dist/hooks/external-store.cjs.map +1 -0
- package/dist/hooks/external-store.mjs +2 -0
- package/dist/hooks/external-store.mjs.map +1 -0
- package/dist/hooks/i18n-config.cjs +2 -0
- package/dist/hooks/i18n-config.cjs.map +1 -0
- package/dist/hooks/i18n-config.d.ts +9 -0
- package/dist/hooks/i18n-config.d.ts.map +1 -0
- package/dist/hooks/i18n-config.mjs +2 -0
- package/dist/hooks/i18n-config.mjs.map +1 -0
- package/dist/hooks/useGT.cjs +2 -0
- package/dist/hooks/useGT.cjs.map +1 -0
- package/dist/hooks/useGT.d.ts +8 -0
- package/dist/hooks/useGT.d.ts.map +1 -0
- package/dist/hooks/useGT.mjs +2 -0
- package/dist/hooks/useGT.mjs.map +1 -0
- package/dist/hooks/useInternalLocaleSelector.cjs +2 -0
- package/dist/hooks/useInternalLocaleSelector.cjs.map +1 -0
- package/dist/hooks/useInternalLocaleSelector.d.ts +11 -0
- package/dist/hooks/useInternalLocaleSelector.d.ts.map +1 -0
- package/dist/hooks/useInternalLocaleSelector.mjs +2 -0
- package/dist/hooks/useInternalLocaleSelector.mjs.map +1 -0
- package/dist/hooks/useInternalRegionSelector.cjs +2 -0
- package/dist/hooks/useInternalRegionSelector.cjs.map +1 -0
- package/dist/hooks/useInternalRegionSelector.d.ts +41 -0
- package/dist/hooks/useInternalRegionSelector.d.ts.map +1 -0
- package/dist/hooks/useInternalRegionSelector.mjs +2 -0
- package/dist/hooks/useInternalRegionSelector.mjs.map +1 -0
- package/dist/hooks/useMessages.cjs +2 -0
- package/dist/hooks/useMessages.cjs.map +1 -0
- package/dist/hooks/useMessages.d.ts +8 -0
- package/dist/hooks/useMessages.d.ts.map +1 -0
- package/dist/hooks/useMessages.mjs +2 -0
- package/dist/hooks/useMessages.mjs.map +1 -0
- package/dist/hooks/useTranslations.cjs +2 -0
- package/dist/hooks/useTranslations.cjs.map +1 -0
- package/dist/hooks/useTranslations.d.ts +10 -0
- package/dist/hooks/useTranslations.d.ts.map +1 -0
- package/dist/hooks/useTranslations.mjs +2 -0
- package/dist/hooks/useTranslations.mjs.map +1 -0
- package/dist/hooks/utils/getFormatLocales.cjs +2 -0
- package/dist/hooks/utils/getFormatLocales.cjs.map +1 -0
- package/dist/hooks/utils/getFormatLocales.d.ts +13 -0
- package/dist/hooks/utils/getFormatLocales.d.ts.map +1 -0
- package/dist/hooks/utils/getFormatLocales.mjs +2 -0
- package/dist/hooks/utils/getFormatLocales.mjs.map +1 -0
- package/dist/hooks/utils/getShouldTranslate.cjs +2 -0
- package/dist/hooks/utils/getShouldTranslate.cjs.map +1 -0
- package/dist/hooks/utils/getShouldTranslate.d.ts +8 -0
- package/dist/hooks/utils/getShouldTranslate.d.ts.map +1 -0
- package/dist/hooks/utils/getShouldTranslate.mjs +2 -0
- package/dist/hooks/utils/getShouldTranslate.mjs.map +1 -0
- package/dist/hooks/utils/missing-translation.cjs +2 -0
- package/dist/hooks/utils/missing-translation.cjs.map +1 -0
- package/dist/hooks/utils/missing-translation.d.ts +10 -0
- package/dist/hooks/utils/missing-translation.d.ts.map +1 -0
- package/dist/hooks/utils/missing-translation.mjs +2 -0
- package/dist/hooks/utils/missing-translation.mjs.map +1 -0
- package/dist/hooks/utils.cjs +2 -0
- package/dist/hooks/utils.cjs.map +1 -0
- package/dist/hooks/utils.d.ts +14 -0
- package/dist/hooks/utils.d.ts.map +1 -0
- package/dist/hooks/utils.mjs +2 -0
- package/dist/hooks/utils.mjs.map +1 -0
- package/dist/hooks.cjs +1 -0
- package/dist/hooks.d.ts +9 -130
- package/dist/hooks.mjs +1 -0
- package/dist/i18n-cache/ReactI18nCache.cjs +2 -0
- package/dist/i18n-cache/ReactI18nCache.cjs.map +1 -0
- package/dist/i18n-cache/ReactI18nCache.d.ts +10 -0
- package/dist/i18n-cache/ReactI18nCache.d.ts.map +1 -0
- package/dist/i18n-cache/ReactI18nCache.mjs +2 -0
- package/dist/i18n-cache/ReactI18nCache.mjs.map +1 -0
- package/dist/i18n-cache/singleton-operations.cjs +2 -0
- package/dist/i18n-cache/singleton-operations.cjs.map +1 -0
- package/dist/i18n-cache/singleton-operations.d.ts +8 -0
- package/dist/i18n-cache/singleton-operations.d.ts.map +1 -0
- package/dist/i18n-cache/singleton-operations.mjs +2 -0
- package/dist/i18n-cache/singleton-operations.mjs.map +1 -0
- package/dist/i18n-store/I18nStore.cjs +2 -0
- package/dist/i18n-store/I18nStore.cjs.map +1 -0
- package/dist/i18n-store/I18nStore.d.ts +41 -0
- package/dist/i18n-store/I18nStore.d.ts.map +1 -0
- package/dist/i18n-store/I18nStore.mjs +2 -0
- package/dist/i18n-store/I18nStore.mjs.map +1 -0
- package/dist/i18n-store/singleton-operations.cjs +2 -0
- package/dist/i18n-store/singleton-operations.cjs.map +1 -0
- package/dist/i18n-store/singleton-operations.d.ts +9 -0
- package/dist/i18n-store/singleton-operations.d.ts.map +1 -0
- package/dist/i18n-store/singleton-operations.mjs +2 -0
- package/dist/i18n-store/singleton-operations.mjs.map +1 -0
- package/dist/i18n-store/storeTypes.d.ts +21 -0
- package/dist/i18n-store/storeTypes.d.ts.map +1 -0
- package/dist/i18n-store/useI18nStore.cjs +2 -0
- package/dist/i18n-store/useI18nStore.cjs.map +1 -0
- package/dist/i18n-store/useI18nStore.mjs +2 -0
- package/dist/i18n-store/useI18nStore.mjs.map +1 -0
- package/dist/i18n-store/utils/dictionaries.cjs +2 -0
- package/dist/i18n-store/utils/dictionaries.cjs.map +1 -0
- package/dist/i18n-store/utils/dictionaries.mjs +2 -0
- package/dist/i18n-store/utils/dictionaries.mjs.map +1 -0
- package/dist/i18n-store/utils/subscriptions.cjs +2 -0
- package/dist/i18n-store/utils/subscriptions.cjs.map +1 -0
- package/dist/i18n-store/utils/subscriptions.mjs +2 -0
- package/dist/i18n-store/utils/subscriptions.mjs.map +1 -0
- package/dist/i18n-store/utils/translations.cjs +2 -0
- package/dist/i18n-store/utils/translations.cjs.map +1 -0
- package/dist/i18n-store/utils/translations.mjs +2 -0
- package/dist/i18n-store/utils/translations.mjs.map +1 -0
- package/dist/pure.cjs +1 -0
- package/dist/pure.d.ts +31 -676
- package/dist/pure.mjs +1 -0
- package/dist/setup/i18nConfig.cjs +2 -0
- package/dist/setup/i18nConfig.cjs.map +1 -0
- package/dist/setup/i18nConfig.d.ts +21 -0
- package/dist/setup/i18nConfig.d.ts.map +1 -0
- package/dist/setup/i18nConfig.mjs +2 -0
- package/dist/setup/i18nConfig.mjs.map +1 -0
- package/dist/setup/initializeGTSPA.cjs +2 -0
- package/dist/setup/initializeGTSPA.cjs.map +1 -0
- package/dist/setup/initializeGTSPA.d.ts +16 -0
- package/dist/setup/initializeGTSPA.d.ts.map +1 -0
- package/dist/setup/initializeGTSPA.mjs +2 -0
- package/dist/setup/initializeGTSPA.mjs.map +1 -0
- package/dist/setup/initializeGTSRA.cjs +2 -0
- package/dist/setup/initializeGTSRA.cjs.map +1 -0
- package/dist/setup/initializeGTSRA.d.ts +11 -0
- package/dist/setup/initializeGTSRA.d.ts.map +1 -0
- package/dist/setup/initializeGTSRA.mjs +2 -0
- package/dist/setup/initializeGTSRA.mjs.map +1 -0
- package/dist/utils/cookies.cjs +2 -0
- package/dist/utils/cookies.cjs.map +1 -0
- package/dist/utils/cookies.d.ts +16 -0
- package/dist/utils/cookies.d.ts.map +1 -0
- package/dist/utils/cookies.mjs +2 -0
- package/dist/utils/cookies.mjs.map +1 -0
- package/dist/utils/dictionaries/flattenDictionary.cjs +2 -0
- package/dist/utils/dictionaries/flattenDictionary.cjs.map +1 -0
- package/dist/utils/dictionaries/flattenDictionary.d.ts +15 -0
- package/dist/utils/dictionaries/flattenDictionary.d.ts.map +1 -0
- package/dist/utils/dictionaries/flattenDictionary.mjs +2 -0
- package/dist/utils/dictionaries/flattenDictionary.mjs.map +1 -0
- package/dist/utils/dictionaries/getDictionaryEntry.cjs +2 -0
- package/dist/utils/dictionaries/getDictionaryEntry.cjs.map +1 -0
- package/dist/utils/dictionaries/getDictionaryEntry.d.ts +8 -0
- package/dist/utils/dictionaries/getDictionaryEntry.d.ts.map +1 -0
- package/dist/utils/dictionaries/getDictionaryEntry.mjs +2 -0
- package/dist/utils/dictionaries/getDictionaryEntry.mjs.map +1 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.cjs +2 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.cjs.map +1 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.d.ts +10 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.d.ts.map +1 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.mjs +2 -0
- package/dist/utils/dictionaries/getEntryAndMetadata.mjs.map +1 -0
- package/dist/utils/dictionaries/indexDict.cjs +2 -0
- package/dist/utils/dictionaries/indexDict.cjs.map +1 -0
- package/dist/utils/dictionaries/indexDict.mjs +2 -0
- package/dist/utils/dictionaries/indexDict.mjs.map +1 -0
- package/dist/utils/dictionaries/isDictionaryEntry.cjs +2 -0
- package/dist/utils/dictionaries/isDictionaryEntry.cjs.map +1 -0
- package/dist/utils/dictionaries/isDictionaryEntry.d.ts +12 -0
- package/dist/utils/dictionaries/isDictionaryEntry.d.ts.map +1 -0
- package/dist/utils/dictionaries/isDictionaryEntry.mjs +2 -0
- package/dist/utils/dictionaries/isDictionaryEntry.mjs.map +1 -0
- package/dist/utils/dictionaries/mergeDictionaries.cjs +2 -0
- package/dist/utils/dictionaries/mergeDictionaries.cjs.map +1 -0
- package/dist/utils/dictionaries/mergeDictionaries.d.ts +7 -0
- package/dist/utils/dictionaries/mergeDictionaries.d.ts.map +1 -0
- package/dist/utils/dictionaries/mergeDictionaries.mjs +2 -0
- package/dist/utils/dictionaries/mergeDictionaries.mjs.map +1 -0
- package/dist/utils/internal/addGTIdentifier.cjs +2 -0
- package/dist/utils/internal/addGTIdentifier.cjs.map +1 -0
- package/dist/utils/internal/addGTIdentifier.d.ts +8 -0
- package/dist/utils/internal/addGTIdentifier.d.ts.map +1 -0
- package/dist/utils/internal/addGTIdentifier.mjs +2 -0
- package/dist/utils/internal/addGTIdentifier.mjs.map +1 -0
- package/dist/utils/internal/removeInjectedT.cjs +2 -0
- package/dist/utils/internal/removeInjectedT.cjs.map +1 -0
- package/dist/utils/internal/removeInjectedT.mjs +2 -0
- package/dist/utils/internal/removeInjectedT.mjs.map +1 -0
- package/dist/utils/internal/writeChildrenAsObjects.cjs +2 -0
- package/dist/utils/internal/writeChildrenAsObjects.cjs.map +1 -0
- package/dist/utils/internal/writeChildrenAsObjects.d.ts +14 -0
- package/dist/utils/internal/writeChildrenAsObjects.d.ts.map +1 -0
- package/dist/utils/internal/writeChildrenAsObjects.mjs +2 -0
- package/dist/utils/internal/writeChildrenAsObjects.mjs.map +1 -0
- package/dist/utils/plurals/getPluralBranch.cjs +2 -0
- package/dist/utils/plurals/getPluralBranch.cjs.map +1 -0
- package/dist/utils/plurals/getPluralBranch.d.ts +12 -0
- package/dist/utils/plurals/getPluralBranch.d.ts.map +1 -0
- package/dist/utils/plurals/getPluralBranch.mjs +2 -0
- package/dist/utils/plurals/getPluralBranch.mjs.map +1 -0
- package/dist/utils/rendering/createRenderPipeline.cjs +2 -0
- package/dist/utils/rendering/createRenderPipeline.cjs.map +1 -0
- package/dist/utils/rendering/createRenderPipeline.d.ts +18 -0
- package/dist/utils/rendering/createRenderPipeline.d.ts.map +1 -0
- package/dist/utils/rendering/createRenderPipeline.mjs +2 -0
- package/dist/utils/rendering/createRenderPipeline.mjs.map +1 -0
- package/dist/utils/rendering/createRenderVariable.cjs +2 -0
- package/dist/utils/rendering/createRenderVariable.cjs.map +1 -0
- package/dist/utils/rendering/createRenderVariable.d.ts +46 -0
- package/dist/utils/rendering/createRenderVariable.d.ts.map +1 -0
- package/dist/utils/rendering/createRenderVariable.mjs +2 -0
- package/dist/utils/rendering/createRenderVariable.mjs.map +1 -0
- package/dist/utils/rendering/getDefaultRenderSettings.cjs +2 -0
- package/dist/utils/rendering/getDefaultRenderSettings.cjs.map +1 -0
- package/dist/utils/rendering/getDefaultRenderSettings.d.ts +10 -0
- package/dist/utils/rendering/getDefaultRenderSettings.d.ts.map +1 -0
- package/dist/utils/rendering/getDefaultRenderSettings.mjs +2 -0
- package/dist/utils/rendering/getDefaultRenderSettings.mjs.map +1 -0
- package/dist/utils/rendering/getGTTag.cjs +2 -0
- package/dist/utils/rendering/getGTTag.cjs.map +1 -0
- package/dist/utils/rendering/getGTTag.mjs +2 -0
- package/dist/utils/rendering/getGTTag.mjs.map +1 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.cjs +2 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.cjs.map +1 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.d.ts +12 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.d.ts.map +1 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.mjs +2 -0
- package/dist/utils/rendering/renderDefaultChildren.shared.mjs.map +1 -0
- package/dist/utils/rendering/renderPipeline.cjs +2 -0
- package/dist/utils/rendering/renderPipeline.cjs.map +1 -0
- package/dist/utils/rendering/renderPipeline.mjs +2 -0
- package/dist/utils/rendering/renderPipeline.mjs.map +1 -0
- package/dist/utils/rendering/renderPipeline.rsc.cjs +2 -0
- package/dist/utils/rendering/renderPipeline.rsc.cjs.map +1 -0
- package/dist/utils/rendering/renderPipeline.rsc.d.ts +11 -0
- package/dist/utils/rendering/renderPipeline.rsc.d.ts.map +1 -0
- package/dist/utils/rendering/renderPipeline.rsc.mjs +2 -0
- package/dist/utils/rendering/renderPipeline.rsc.mjs.map +1 -0
- package/dist/utils/rendering/renderPreparedT.shared.cjs +2 -0
- package/dist/utils/rendering/renderPreparedT.shared.cjs.map +1 -0
- package/dist/utils/rendering/renderPreparedT.shared.d.ts +16 -0
- package/dist/utils/rendering/renderPreparedT.shared.d.ts.map +1 -0
- package/dist/utils/rendering/renderPreparedT.shared.mjs +2 -0
- package/dist/utils/rendering/renderPreparedT.shared.mjs.map +1 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.cjs +2 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.cjs.map +1 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.d.ts +13 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.d.ts.map +1 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.mjs +2 -0
- package/dist/utils/rendering/renderTranslatedChildren.shared.mjs.map +1 -0
- package/dist/utils/translation/prepareT.shared.cjs +2 -0
- package/dist/utils/translation/prepareT.shared.cjs.map +1 -0
- package/dist/utils/translation/prepareT.shared.d.ts +40 -0
- package/dist/utils/translation/prepareT.shared.d.ts.map +1 -0
- package/dist/utils/translation/prepareT.shared.mjs +2 -0
- package/dist/utils/translation/prepareT.shared.mjs.map +1 -0
- package/dist/utils/translation/usePrepareT.cjs +2 -0
- package/dist/utils/translation/usePrepareT.cjs.map +1 -0
- package/dist/utils/translation/usePrepareT.mjs +2 -0
- package/dist/utils/translation/usePrepareT.mjs.map +1 -0
- package/dist/utils/types.d.ts +106 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/utils.cjs +2 -0
- package/dist/utils/utils.cjs.map +1 -0
- package/dist/utils/utils.mjs +2 -0
- package/dist/utils/utils.mjs.map +1 -0
- package/dist/utils/variables/_getVariableProps.cjs +2 -0
- package/dist/utils/variables/_getVariableProps.cjs.map +1 -0
- package/dist/utils/variables/_getVariableProps.d.ts +13 -0
- package/dist/utils/variables/_getVariableProps.d.ts.map +1 -0
- package/dist/utils/variables/_getVariableProps.mjs +2 -0
- package/dist/utils/variables/_getVariableProps.mjs.map +1 -0
- package/dist/utils/variables/getVariableName.cjs +2 -0
- package/dist/utils/variables/getVariableName.cjs.map +1 -0
- package/dist/utils/variables/getVariableName.d.ts +12 -0
- package/dist/utils/variables/getVariableName.d.ts.map +1 -0
- package/dist/utils/variables/getVariableName.mjs +2 -0
- package/dist/utils/variables/getVariableName.mjs.map +1 -0
- package/package.json +24 -13
- package/dist/components-rsc.cjs.min.cjs +0 -2
- package/dist/components-rsc.cjs.min.cjs.map +0 -1
- package/dist/components-rsc.d.ts.map +0 -1
- package/dist/components-rsc.esm.min.mjs +0 -2
- package/dist/components-rsc.esm.min.mjs.map +0 -1
- package/dist/components.cjs.min.cjs +0 -2
- package/dist/components.cjs.min.cjs.map +0 -1
- package/dist/components.d.ts.map +0 -1
- package/dist/components.esm.min.mjs +0 -2
- package/dist/components.esm.min.mjs.map +0 -1
- package/dist/hooks.cjs.min.cjs +0 -2
- package/dist/hooks.cjs.min.cjs.map +0 -1
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.esm.min.mjs +0 -2
- package/dist/hooks.esm.min.mjs.map +0 -1
- package/dist/pure.cjs.min.cjs +0 -2
- package/dist/pure.cjs.min.cjs.map +0 -1
- package/dist/pure.d.ts.map +0 -1
- package/dist/pure.esm.min.mjs +0 -2
- package/dist/pure.esm.min.mjs.map +0 -1
package/dist/pure.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getPluralBranch as e}from"./utils/plurals/getPluralBranch.mjs";import{addGTIdentifier as t}from"./utils/internal/addGTIdentifier.mjs";import{getVariableName as n}from"./utils/variables/getVariableName.mjs";import{writeChildrenAsObjects as r}from"./utils/internal/writeChildrenAsObjects.mjs";import{flattenDictionary as i}from"./utils/dictionaries/flattenDictionary.mjs";import{getVariableProps as a}from"./utils/variables/_getVariableProps.mjs";import{getFormatLocales as o}from"./hooks/utils/getFormatLocales.mjs";import{getReactI18nCache as s,setReactI18nCache as c}from"./i18n-cache/singleton-operations.mjs";import{getTranslationsSnapshot as l}from"./functions/helpers/getTranslationsSnapshot.mjs";import{ReactI18nConfig as u,getI18nConfig as d,initializeI18nConfig as f,setI18nConfig as p}from"./setup/i18nConfig.mjs";import{getReadonlyConditionStoreWithFallback as m,setConditionStore as h}from"./condition-store/singleton-operations.mjs";import{t as g}from"./functions/translation/t.mjs";import{createRenderPipeline as _}from"./utils/rendering/createRenderPipeline.mjs";import{defaultEnableI18nCookieName as v,defaultLocaleCookieName as y,defaultRegionCookieName as b}from"./utils/cookies.mjs";import{getDictionaryEntry as x,isValidDictionaryEntry as S}from"./utils/dictionaries/getDictionaryEntry.mjs";import{getEntryAndMetadata as C}from"./utils/dictionaries/getEntryAndMetadata.mjs";import{isDictionaryEntry as w}from"./utils/dictionaries/isDictionaryEntry.mjs";import{mergeDictionaries as T}from"./utils/dictionaries/mergeDictionaries.mjs";import{getDefaultRenderSettings as E}from"./utils/rendering/getDefaultRenderSettings.mjs";import{ReactI18nCache as D}from"./i18n-cache/ReactI18nCache.mjs";import{internalInitializeGTSRA as O}from"./setup/initializeGTSRA.mjs";import{I18nStore as k}from"./i18n-store/I18nStore.mjs";import{getI18nStore as A,isI18nStoreInitialized as j,setI18nStore as M}from"./i18n-store/singleton-operations.mjs";import{internalInitializeGTSPA as N}from"./setup/initializeGTSPA.mjs";import{declareVar as P,decodeMsg as F,decodeOptions as I,decodeVars as L,derive as R,getDefaultLocale as z,getGTClass as B,getLocaleProperties as V,getLocales as H,getVersionId as U,gtFallback as W,mFallback as G,msg as K}from"gt-i18n";import{ReadonlyConditionStore as q,WritableConditionStore as J}from"gt-i18n/internal";export{k as I18nStore,D as ReactI18nCache,u as ReactI18nConfig,q as ReadonlyConditionStore,J as WritableConditionStore,t as addGTIdentifier,_ as createRenderPipeline,P as declareVar,F as decodeMsg,I as decodeOptions,L as decodeVars,v as defaultEnableI18nCookieName,y as defaultLocaleCookieName,b as defaultRegionCookieName,R as derive,i as flattenDictionary,z as getDefaultLocale,E as getDefaultRenderSettings,x as getDictionaryEntry,C as getEntryAndMetadata,o as getFormatLocales,B as getGTClass,d as getI18nConfig,A as getI18nStore,V as getLocaleProperties,H as getLocales,e as getPluralBranch,s as getReactI18nCache,m as getReadonlyConditionStoreWithFallback,l as getTranslationsSnapshot,n as getVariableName,a as getVariableProps,U as getVersionId,W as gtFallback,O as initializeGT,f as initializeI18nConfig,N as internalInitializeGTSPA,O as internalInitializeGTSRA,w as isDictionaryEntry,j as isI18nStoreInitialized,S as isValidDictionaryEntry,G as mFallback,T as mergeDictionaries,K as msg,p as setI18nConfig,M as setI18nStore,c as setReactI18nCache,h as setReadonlyConditionStore,g as t,r as writeChildrenAsObjects};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`generaltranslation/internal`),t=require(`gt-i18n/internal`);const n=`server-render`,r=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var i=class extends t.I18nConfig{renderStrategy;constructor(e={},t=n){super(e),c(t),Object.defineProperty(this,r,{value:!0}),this.renderStrategy=t}getRenderStrategy(){return this.renderStrategy}};function a(){let n=(0,t.getI18nConfig)();if(l(n))return n;throw Error((0,e.createDiagnosticMessage)({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read ReactI18nConfig after base I18nConfig setup.`,why:`the internal I18nConfig singleton was initialized without react-core render strategy support`,fix:`Initialize GT through gt-react or @generaltranslation/react-core/pure.`}))}function o(e){(0,t.setI18nConfig)(e)}function s(e={},t=n){let r=new i(e,t);return o(r),r}function c(t){if(!(t===`SPA`||t===`server-render`))throw Error((0,e.createDiagnosticMessage)({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Invalid React render strategy.`,why:`the render strategy must be "SPA" or "server-render", but received "${String(t)}"`,fix:`Initialize GT through gt-react or pass a valid render strategy.`}))}function l(e){if(e instanceof i)return!0;let t=e;return t[r]===!0&&typeof t.getRenderStrategy==`function`}exports.ReactI18nConfig=i,exports.getI18nConfig=a,exports.initializeI18nConfig=s,exports.setI18nConfig=o;
|
|
2
|
+
//# sourceMappingURL=i18nConfig.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18nConfig.cjs","names":["I18nConfig"],"sources":["../../src/setup/i18nConfig.ts"],"sourcesContent":["import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getI18nConfig as getBaseI18nConfig,\n I18nConfig,\n setI18nConfig as setBaseI18nConfig,\n} from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\n/**\n * Helps us distinguish behavior for SPA vs server-rendered apps.\n * - server-rendered apps must use context\n * - SPA apps can synchronously access the locale\n */\nexport type RenderStrategy = 'SPA' | 'server-render';\n\nconst defaultRenderStrategy: RenderStrategy = 'server-render';\nconst reactI18nConfigBrand = Symbol.for(\n 'generaltranslation.react-core.ReactI18nConfig'\n);\n\nexport class ReactI18nConfig extends I18nConfig {\n private renderStrategy: RenderStrategy;\n\n constructor(\n params: I18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n ) {\n super(params);\n validateRenderStrategy(renderStrategy);\n Object.defineProperty(this, reactI18nConfigBrand, { value: true });\n this.renderStrategy = renderStrategy;\n }\n\n getRenderStrategy(): RenderStrategy {\n return this.renderStrategy;\n }\n}\n\nexport function getI18nConfig(): ReactI18nConfig {\n const i18nConfig = getBaseI18nConfig();\n if (isReactI18nConfig(i18nConfig)) {\n return i18nConfig;\n }\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read ReactI18nConfig after base I18nConfig setup.',\n why: 'the internal I18nConfig singleton was initialized without react-core render strategy support',\n fix: 'Initialize GT through gt-react or @generaltranslation/react-core/pure.',\n })\n );\n}\n\nexport function setI18nConfig(nextI18nConfig: ReactI18nConfig): void {\n setBaseI18nConfig(nextI18nConfig);\n}\n\nexport function initializeI18nConfig(\n params: I18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n): ReactI18nConfig {\n const nextI18nConfig = new ReactI18nConfig(params, renderStrategy);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n\nfunction validateRenderStrategy(\n renderStrategy: RenderStrategy\n): asserts renderStrategy is RenderStrategy {\n if (renderStrategy === 'SPA' || renderStrategy === 'server-render') return;\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Invalid React render strategy.',\n why: `the render strategy must be \"SPA\" or \"server-render\", but received \"${String(renderStrategy)}\"`,\n fix: 'Initialize GT through gt-react or pass a valid render strategy.',\n })\n );\n}\n\nfunction isReactI18nConfig(\n i18nConfig: I18nConfig\n): i18nConfig is ReactI18nConfig {\n if (i18nConfig instanceof ReactI18nConfig) return true;\n\n const maybeReactI18nConfig = i18nConfig as I18nConfig &\n Record<PropertyKey, unknown>;\n return (\n maybeReactI18nConfig[reactI18nConfigBrand] === true &&\n typeof maybeReactI18nConfig.getRenderStrategy === 'function'\n );\n}\n"],"mappings":"wHAeA,MAAM,EAAwC,gBACxC,EAAuB,OAAO,IAClC,gDACD,CAED,IAAa,EAAb,cAAqCA,EAAAA,UAAW,CAC9C,eAEA,YACE,EAA2B,EAAE,CAC7B,EAAiC,EACjC,CACA,MAAM,EAAO,CACb,EAAuB,EAAe,CACtC,OAAO,eAAe,KAAM,EAAsB,CAAE,MAAO,GAAM,CAAC,CAClE,KAAK,eAAiB,EAGxB,mBAAoC,CAClC,OAAO,KAAK,iBAIhB,SAAgB,GAAiC,CAC/C,IAAM,GAAA,EAAA,EAAA,gBAAgC,CACtC,GAAI,EAAkB,EAAW,CAC/B,OAAO,EAET,MAAU,OAAA,EAAA,EAAA,yBACgB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,2DACd,IAAK,+FACL,IAAK,yEACN,CAAC,CACH,CAGH,SAAgB,EAAc,EAAuC,EACnE,EAAA,EAAA,eAAkB,EAAe,CAGnC,SAAgB,EACd,EAA2B,EAAE,CAC7B,EAAiC,EAChB,CACjB,IAAM,EAAiB,IAAI,EAAgB,EAAQ,EAAe,CAElE,OADA,EAAc,EAAe,CACtB,EAGT,SAAS,EACP,EAC0C,CACtC,SAAmB,OAAS,IAAmB,iBACnD,MAAU,OAAA,EAAA,EAAA,yBACgB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,iCACd,IAAK,uEAAuE,OAAO,EAAe,CAAC,GACnG,IAAK,kEACN,CAAC,CACH,CAGH,SAAS,EACP,EAC+B,CAC/B,GAAI,aAAsB,EAAiB,MAAO,GAElD,IAAM,EAAuB,EAE7B,OACE,EAAqB,KAA0B,IAC/C,OAAO,EAAqB,mBAAsB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { I18nConfigParams } from "gt-i18n/internal/types";
|
|
2
|
+
import { I18nConfig } from "gt-i18n/internal";
|
|
3
|
+
|
|
4
|
+
//#region src/setup/i18nConfig.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Helps us distinguish behavior for SPA vs server-rendered apps.
|
|
7
|
+
* - server-rendered apps must use context
|
|
8
|
+
* - SPA apps can synchronously access the locale
|
|
9
|
+
*/
|
|
10
|
+
type RenderStrategy = 'SPA' | 'server-render';
|
|
11
|
+
declare class ReactI18nConfig extends I18nConfig {
|
|
12
|
+
private renderStrategy;
|
|
13
|
+
constructor(params?: I18nConfigParams, renderStrategy?: RenderStrategy);
|
|
14
|
+
getRenderStrategy(): RenderStrategy;
|
|
15
|
+
}
|
|
16
|
+
declare function getI18nConfig(): ReactI18nConfig;
|
|
17
|
+
declare function setI18nConfig(nextI18nConfig: ReactI18nConfig): void;
|
|
18
|
+
declare function initializeI18nConfig(params?: I18nConfigParams, renderStrategy?: RenderStrategy): ReactI18nConfig;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ReactI18nConfig, getI18nConfig, initializeI18nConfig, setI18nConfig };
|
|
21
|
+
//# sourceMappingURL=i18nConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18nConfig.d.ts","names":[],"sources":["../../src/setup/i18nConfig.ts"],"mappings":";;;;;;AAaA;;;KAAY,cAAA;AAAA,cAOC,eAAA,SAAwB,UAAA;EAAA,QAC3B,cAAA;cAGN,MAAA,GAAQ,gBAAA,EACR,cAAA,GAAgB,cAAA;EAQlB,iBAAA,CAAA,GAAqB,cAAA;AAAA;AAAA,iBAKP,aAAA,CAAA,GAAiB,eAAA;AAAA,iBAgBjB,aAAA,CAAc,cAAA,EAAgB,eAAA;AAAA,iBAI9B,oBAAA,CACd,MAAA,GAAQ,gBAAA,EACR,cAAA,GAAgB,cAAA,GACf,eAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createDiagnosticMessage as e}from"generaltranslation/internal";import{I18nConfig as t,getI18nConfig as n,setI18nConfig as r}from"gt-i18n/internal";const i=`server-render`,a=Symbol.for(`generaltranslation.react-core.ReactI18nConfig`);var o=class extends t{renderStrategy;constructor(e={},t=i){super(e),u(t),Object.defineProperty(this,a,{value:!0}),this.renderStrategy=t}getRenderStrategy(){return this.renderStrategy}};function s(){let t=n();if(d(t))return t;throw Error(e({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Cannot read ReactI18nConfig after base I18nConfig setup.`,why:`the internal I18nConfig singleton was initialized without react-core render strategy support`,fix:`Initialize GT through gt-react or @generaltranslation/react-core/pure.`}))}function c(e){r(e)}function l(e={},t=i){let n=new o(e,t);return c(n),n}function u(t){if(!(t===`SPA`||t===`server-render`))throw Error(e({source:`@generaltranslation/react-core`,severity:`Error`,whatHappened:`Invalid React render strategy.`,why:`the render strategy must be "SPA" or "server-render", but received "${String(t)}"`,fix:`Initialize GT through gt-react or pass a valid render strategy.`}))}function d(e){if(e instanceof o)return!0;let t=e;return t[a]===!0&&typeof t.getRenderStrategy==`function`}export{o as ReactI18nConfig,s as getI18nConfig,l as initializeI18nConfig,c as setI18nConfig};
|
|
2
|
+
//# sourceMappingURL=i18nConfig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18nConfig.mjs","names":["getI18nConfig","getBaseI18nConfig","setI18nConfig"],"sources":["../../src/setup/i18nConfig.ts"],"sourcesContent":["import { createDiagnosticMessage } from 'generaltranslation/internal';\nimport {\n getI18nConfig as getBaseI18nConfig,\n I18nConfig,\n setI18nConfig as setBaseI18nConfig,\n} from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\n/**\n * Helps us distinguish behavior for SPA vs server-rendered apps.\n * - server-rendered apps must use context\n * - SPA apps can synchronously access the locale\n */\nexport type RenderStrategy = 'SPA' | 'server-render';\n\nconst defaultRenderStrategy: RenderStrategy = 'server-render';\nconst reactI18nConfigBrand = Symbol.for(\n 'generaltranslation.react-core.ReactI18nConfig'\n);\n\nexport class ReactI18nConfig extends I18nConfig {\n private renderStrategy: RenderStrategy;\n\n constructor(\n params: I18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n ) {\n super(params);\n validateRenderStrategy(renderStrategy);\n Object.defineProperty(this, reactI18nConfigBrand, { value: true });\n this.renderStrategy = renderStrategy;\n }\n\n getRenderStrategy(): RenderStrategy {\n return this.renderStrategy;\n }\n}\n\nexport function getI18nConfig(): ReactI18nConfig {\n const i18nConfig = getBaseI18nConfig();\n if (isReactI18nConfig(i18nConfig)) {\n return i18nConfig;\n }\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Cannot read ReactI18nConfig after base I18nConfig setup.',\n why: 'the internal I18nConfig singleton was initialized without react-core render strategy support',\n fix: 'Initialize GT through gt-react or @generaltranslation/react-core/pure.',\n })\n );\n}\n\nexport function setI18nConfig(nextI18nConfig: ReactI18nConfig): void {\n setBaseI18nConfig(nextI18nConfig);\n}\n\nexport function initializeI18nConfig(\n params: I18nConfigParams = {},\n renderStrategy: RenderStrategy = defaultRenderStrategy\n): ReactI18nConfig {\n const nextI18nConfig = new ReactI18nConfig(params, renderStrategy);\n setI18nConfig(nextI18nConfig);\n return nextI18nConfig;\n}\n\nfunction validateRenderStrategy(\n renderStrategy: RenderStrategy\n): asserts renderStrategy is RenderStrategy {\n if (renderStrategy === 'SPA' || renderStrategy === 'server-render') return;\n throw new Error(\n createDiagnosticMessage({\n source: '@generaltranslation/react-core',\n severity: 'Error',\n whatHappened: 'Invalid React render strategy.',\n why: `the render strategy must be \"SPA\" or \"server-render\", but received \"${String(renderStrategy)}\"`,\n fix: 'Initialize GT through gt-react or pass a valid render strategy.',\n })\n );\n}\n\nfunction isReactI18nConfig(\n i18nConfig: I18nConfig\n): i18nConfig is ReactI18nConfig {\n if (i18nConfig instanceof ReactI18nConfig) return true;\n\n const maybeReactI18nConfig = i18nConfig as I18nConfig &\n Record<PropertyKey, unknown>;\n return (\n maybeReactI18nConfig[reactI18nConfigBrand] === true &&\n typeof maybeReactI18nConfig.getRenderStrategy === 'function'\n );\n}\n"],"mappings":"0JAeA,MAAM,EAAwC,gBACxC,EAAuB,OAAO,IAClC,gDACD,CAED,IAAa,EAAb,cAAqC,CAAW,CAC9C,eAEA,YACE,EAA2B,EAAE,CAC7B,EAAiC,EACjC,CACA,MAAM,EAAO,CACb,EAAuB,EAAe,CACtC,OAAO,eAAe,KAAM,EAAsB,CAAE,MAAO,GAAM,CAAC,CAClE,KAAK,eAAiB,EAGxB,mBAAoC,CAClC,OAAO,KAAK,iBAIhB,SAAgBA,GAAiC,CAC/C,IAAM,EAAaC,GAAmB,CACtC,GAAI,EAAkB,EAAW,CAC/B,OAAO,EAET,MAAU,MACR,EAAwB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,2DACd,IAAK,+FACL,IAAK,yEACN,CAAC,CACH,CAGH,SAAgBC,EAAc,EAAuC,CACnE,EAAkB,EAAe,CAGnC,SAAgB,EACd,EAA2B,EAAE,CAC7B,EAAiC,EAChB,CACjB,IAAM,EAAiB,IAAI,EAAgB,EAAQ,EAAe,CAElE,OADA,EAAc,EAAe,CACtB,EAGT,SAAS,EACP,EAC0C,CACtC,SAAmB,OAAS,IAAmB,iBACnD,MAAU,MACR,EAAwB,CACtB,OAAQ,iCACR,SAAU,QACV,aAAc,iCACd,IAAK,uEAAuE,OAAO,EAAe,CAAC,GACnG,IAAK,kEACN,CAAC,CACH,CAGH,SAAS,EACP,EAC+B,CAC/B,GAAI,aAAsB,EAAiB,MAAO,GAElD,IAAM,EAAuB,EAE7B,OACE,EAAqB,KAA0B,IAC/C,OAAO,EAAqB,mBAAsB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../i18n-cache/singleton-operations.cjs`),t=require(`./i18nConfig.cjs`),n=require(`../condition-store/singleton-operations.cjs`),r=require(`../i18n-store/I18nStore.cjs`),i=require(`../i18n-store/singleton-operations.cjs`);let a=require(`gt-i18n/internal`);function o(o){(0,a.setupGTServicesEnabled)(o),t.initializeI18nConfig(o,`SPA`),e.setReactI18nCache(new a.I18nCache(o)),n.setConditionStore(new a.WritableConditionStore(o)),i.setI18nStore(new r.I18nStore)}exports.internalInitializeGTSPA=o;
|
|
2
|
+
//# sourceMappingURL=initializeGTSPA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializeGTSPA.cjs","names":["I18nCache","WritableConditionStore","I18nStore"],"sources":["../../src/setup/initializeGTSPA.ts"],"sourcesContent":["import {\n I18nCache,\n setupGTServicesEnabled,\n WritableConditionStore,\n} from 'gt-i18n/internal';\nimport type {\n GTServicesEnabledParams,\n I18nConfigParams,\n WritableConditionStoreParams,\n} from 'gt-i18n/internal/types';\nimport type { Translation } from 'gt-i18n/types';\nimport { setReactI18nCache } from '../i18n-cache/singleton-operations';\nimport type { ReactI18nCacheParams } from '../i18n-cache/ReactI18nCache';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport { setReadonlyConditionStore } from '../condition-store/singleton-operations';\nimport { setI18nStore } from '../i18n-store/singleton-operations';\nimport { initializeI18nConfig } from './i18nConfig';\n\n/**\n * Initialize GT for an SPA\n * - i18nCache\n * - conditionStore\n * - i18nStore\n *\n * @deprecated moved to /react and /react-native\n */\nexport function internalInitializeGTSPA(\n config: I18nConfigParams &\n GTServicesEnabledParams &\n ReactI18nCacheParams &\n WritableConditionStoreParams\n): void {\n setupGTServicesEnabled(config);\n initializeI18nConfig(config, 'SPA');\n\n const i18nCache = new I18nCache<Translation>(config);\n setReactI18nCache(i18nCache);\n\n const conditionStore = new WritableConditionStore(config);\n setReadonlyConditionStore(conditionStore);\n\n const i18nStore = new I18nStore();\n setI18nStore(i18nStore);\n}\n"],"mappings":"6TA0BA,SAAgB,EACd,EAIM,EACN,EAAA,EAAA,wBAAuB,EAAO,CAC9B,EAAA,qBAAqB,EAAQ,MAAM,CAGnC,EAAA,kBAAkB,IADIA,EAAAA,UAAuB,EAClB,CAAC,CAG5B,EAAA,kBAA0B,IADCC,EAAAA,uBAAuB,EACV,CAAC,CAGzC,EAAA,aAAa,IADSC,EAAAA,UACC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactI18nCacheParams } from "../i18n-cache/ReactI18nCache.js";
|
|
2
|
+
import { GTServicesEnabledParams, I18nConfigParams, WritableConditionStoreParams } from "gt-i18n/internal/types";
|
|
3
|
+
|
|
4
|
+
//#region src/setup/initializeGTSPA.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Initialize GT for an SPA
|
|
7
|
+
* - i18nCache
|
|
8
|
+
* - conditionStore
|
|
9
|
+
* - i18nStore
|
|
10
|
+
*
|
|
11
|
+
* @deprecated moved to /react and /react-native
|
|
12
|
+
*/
|
|
13
|
+
declare function internalInitializeGTSPA(config: I18nConfigParams & GTServicesEnabledParams & ReactI18nCacheParams & WritableConditionStoreParams): void;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { internalInitializeGTSPA };
|
|
16
|
+
//# sourceMappingURL=initializeGTSPA.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializeGTSPA.d.ts","names":[],"sources":["../../src/setup/initializeGTSPA.ts"],"mappings":";;;;;;AA0BA;;;;;;iBAAgB,uBAAA,CACd,MAAA,EAAQ,gBAAA,GACN,uBAAA,GACA,oBAAA,GACA,4BAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{setReactI18nCache as e}from"../i18n-cache/singleton-operations.mjs";import{initializeI18nConfig as t}from"./i18nConfig.mjs";import{setConditionStore as n}from"../condition-store/singleton-operations.mjs";import{I18nStore as r}from"../i18n-store/I18nStore.mjs";import{setI18nStore as i}from"../i18n-store/singleton-operations.mjs";import{I18nCache as a,WritableConditionStore as o,setupGTServicesEnabled as s}from"gt-i18n/internal";function c(c){s(c),t(c,`SPA`),e(new a(c)),n(new o(c)),i(new r)}export{c as internalInitializeGTSPA};
|
|
2
|
+
//# sourceMappingURL=initializeGTSPA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializeGTSPA.mjs","names":[],"sources":["../../src/setup/initializeGTSPA.ts"],"sourcesContent":["import {\n I18nCache,\n setupGTServicesEnabled,\n WritableConditionStore,\n} from 'gt-i18n/internal';\nimport type {\n GTServicesEnabledParams,\n I18nConfigParams,\n WritableConditionStoreParams,\n} from 'gt-i18n/internal/types';\nimport type { Translation } from 'gt-i18n/types';\nimport { setReactI18nCache } from '../i18n-cache/singleton-operations';\nimport type { ReactI18nCacheParams } from '../i18n-cache/ReactI18nCache';\nimport { I18nStore } from '../i18n-store/I18nStore';\nimport { setReadonlyConditionStore } from '../condition-store/singleton-operations';\nimport { setI18nStore } from '../i18n-store/singleton-operations';\nimport { initializeI18nConfig } from './i18nConfig';\n\n/**\n * Initialize GT for an SPA\n * - i18nCache\n * - conditionStore\n * - i18nStore\n *\n * @deprecated moved to /react and /react-native\n */\nexport function internalInitializeGTSPA(\n config: I18nConfigParams &\n GTServicesEnabledParams &\n ReactI18nCacheParams &\n WritableConditionStoreParams\n): void {\n setupGTServicesEnabled(config);\n initializeI18nConfig(config, 'SPA');\n\n const i18nCache = new I18nCache<Translation>(config);\n setReactI18nCache(i18nCache);\n\n const conditionStore = new WritableConditionStore(config);\n setReadonlyConditionStore(conditionStore);\n\n const i18nStore = new I18nStore();\n setI18nStore(i18nStore);\n}\n"],"mappings":"sbA0BA,SAAgB,EACd,EAIM,CACN,EAAuB,EAAO,CAC9B,EAAqB,EAAQ,MAAM,CAGnC,EAAkB,IADI,EAAuB,EAClB,CAAC,CAG5B,EAA0B,IADC,EAAuB,EACV,CAAC,CAGzC,EAAa,IADS,EACC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../i18n-cache/singleton-operations.cjs`),t=require(`./i18nConfig.cjs`),n=require(`../i18n-cache/ReactI18nCache.cjs`);let r=require(`gt-i18n/internal`);function i(i){(0,r.setupGTServicesEnabled)(i),t.initializeI18nConfig(i,`server-render`),e.setReactI18nCache(new n.ReactI18nCache(i))}exports.internalInitializeGTSRA=i;
|
|
2
|
+
//# sourceMappingURL=initializeGTSRA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializeGTSRA.cjs","names":["ReactI18nCache"],"sources":["../../src/setup/initializeGTSRA.ts"],"sourcesContent":["import { setupGTServicesEnabled } from 'gt-i18n/internal';\nimport type {\n GTServicesEnabledParams,\n I18nConfigParams,\n} from 'gt-i18n/internal/types';\nimport type { ReactI18nCacheParams } from '../i18n-cache/ReactI18nCache';\nimport { setReactI18nCache } from '../i18n-cache/singleton-operations';\nimport { ReactI18nCache } from '../i18n-cache/ReactI18nCache';\nimport { initializeI18nConfig } from './i18nConfig';\n\n/**\n * Validation and setup for read only properties\n */\nexport function internalInitializeGTSRA(\n config: I18nConfigParams & GTServicesEnabledParams & ReactI18nCacheParams\n): void {\n setupGTServicesEnabled(config);\n initializeI18nConfig(config, 'server-render');\n\n const i18nCache = new ReactI18nCache(config);\n setReactI18nCache(i18nCache);\n}\n"],"mappings":"qNAaA,SAAgB,EACd,EACM,EACN,EAAA,EAAA,wBAAuB,EAAO,CAC9B,EAAA,qBAAqB,EAAQ,gBAAgB,CAG7C,EAAA,kBAAkB,IADIA,EAAAA,eAAe,EACV,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactI18nCacheParams } from "../i18n-cache/ReactI18nCache.js";
|
|
2
|
+
import { GTServicesEnabledParams, I18nConfigParams } from "gt-i18n/internal/types";
|
|
3
|
+
|
|
4
|
+
//#region src/setup/initializeGTSRA.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Validation and setup for read only properties
|
|
7
|
+
*/
|
|
8
|
+
declare function internalInitializeGTSRA(config: I18nConfigParams & GTServicesEnabledParams & ReactI18nCacheParams): void;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { internalInitializeGTSRA };
|
|
11
|
+
//# sourceMappingURL=initializeGTSRA.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializeGTSRA.d.ts","names":[],"sources":["../../src/setup/initializeGTSRA.ts"],"mappings":";;;;;;AAaA;iBAAgB,uBAAA,CACd,MAAA,EAAQ,gBAAA,GAAmB,uBAAA,GAA0B,oBAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{setReactI18nCache as e}from"../i18n-cache/singleton-operations.mjs";import{initializeI18nConfig as t}from"./i18nConfig.mjs";import{ReactI18nCache as n}from"../i18n-cache/ReactI18nCache.mjs";import{setupGTServicesEnabled as r}from"gt-i18n/internal";function i(i){r(i),t(i,`server-render`),e(new n(i))}export{i as internalInitializeGTSRA};
|
|
2
|
+
//# sourceMappingURL=initializeGTSRA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializeGTSRA.mjs","names":[],"sources":["../../src/setup/initializeGTSRA.ts"],"sourcesContent":["import { setupGTServicesEnabled } from 'gt-i18n/internal';\nimport type {\n GTServicesEnabledParams,\n I18nConfigParams,\n} from 'gt-i18n/internal/types';\nimport type { ReactI18nCacheParams } from '../i18n-cache/ReactI18nCache';\nimport { setReactI18nCache } from '../i18n-cache/singleton-operations';\nimport { ReactI18nCache } from '../i18n-cache/ReactI18nCache';\nimport { initializeI18nConfig } from './i18nConfig';\n\n/**\n * Validation and setup for read only properties\n */\nexport function internalInitializeGTSRA(\n config: I18nConfigParams & GTServicesEnabledParams & ReactI18nCacheParams\n): void {\n setupGTServicesEnabled(config);\n initializeI18nConfig(config, 'server-render');\n\n const i18nCache = new ReactI18nCache(config);\n setReactI18nCache(i18nCache);\n}\n"],"mappings":"+PAaA,SAAgB,EACd,EACM,CACN,EAAuB,EAAO,CAC9B,EAAqB,EAAQ,gBAAgB,CAG7C,EAAkB,IADI,EAAe,EACV,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.cjs","names":[],"sources":["../../src/utils/cookies.ts"],"sourcesContent":["/**\n * Cookie name for tracking the user's selected locale.\n */\nexport const defaultLocaleCookieName = 'generaltranslation.locale';\n\n/**\n * Cookie name for tracking the user's selected region.\n */\nexport const defaultRegionCookieName = 'generaltranslation.region';\n\n/**\n * Cookie name for persisting the enableI18n feature flag.\n */\nexport const defaultEnableI18nCookieName = 'generaltranslation.enable-i18n';\n"],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/utils/cookies.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Cookie name for tracking the user's selected locale.
|
|
4
|
+
*/
|
|
5
|
+
declare const defaultLocaleCookieName = "generaltranslation.locale";
|
|
6
|
+
/**
|
|
7
|
+
* Cookie name for tracking the user's selected region.
|
|
8
|
+
*/
|
|
9
|
+
declare const defaultRegionCookieName = "generaltranslation.region";
|
|
10
|
+
/**
|
|
11
|
+
* Cookie name for persisting the enableI18n feature flag.
|
|
12
|
+
*/
|
|
13
|
+
declare const defaultEnableI18nCookieName = "generaltranslation.enable-i18n";
|
|
14
|
+
//#endregion
|
|
15
|
+
export { defaultEnableI18nCookieName, defaultLocaleCookieName, defaultRegionCookieName };
|
|
16
|
+
//# sourceMappingURL=cookies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.d.ts","names":[],"sources":["../../src/utils/cookies.ts"],"mappings":";;AAGA;;cAAa,uBAAA;;;AAKb;cAAa,uBAAA;;;;cAKA,2BAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.mjs","names":[],"sources":["../../src/utils/cookies.ts"],"sourcesContent":["/**\n * Cookie name for tracking the user's selected locale.\n */\nexport const defaultLocaleCookieName = 'generaltranslation.locale';\n\n/**\n * Cookie name for tracking the user's selected region.\n */\nexport const defaultRegionCookieName = 'generaltranslation.region';\n\n/**\n * Cookie name for persisting the enableI18n feature flag.\n */\nexport const defaultEnableI18nCookieName = 'generaltranslation.enable-i18n';\n"],"mappings":"AAGA,MAAa,EAA0B,4BAK1B,EAA0B,4BAK1B,EAA8B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./indexDict.cjs`),t=e=>`Duplicate key found in dictionary: "${e}"`;function n(r,i=``){let a={};for(let o in r)if(Object.prototype.hasOwnProperty.call(r,o)){let s=i?`${i}.${o}`:o;if(typeof e.get(r,o)==`object`&&e.get(r,o)!==null&&!Array.isArray(e.get(r,o))){let i=n(e.get(r,o),s);for(let e in i){if(Object.prototype.hasOwnProperty.call(a,e))throw Error(t(e));a[e]=i[e]}}else{if(Object.prototype.hasOwnProperty.call(a,s))throw Error(t(s));a[s]=e.get(r,o)}}return a}exports.flattenDictionary=n;
|
|
2
|
+
//# sourceMappingURL=flattenDictionary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenDictionary.cjs","names":["get"],"sources":["../../../src/utils/dictionaries/flattenDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionaryEntry,\n FlattenedDictionary,\n} from '../types';\nimport { get } from './indexDict';\n\nconst createDuplicateKeyError = (key: string) =>\n `Duplicate key found in dictionary: \"${key}\"`;\n\n/**\n * Flattens a nested dictionary by concatenating nested keys.\n * Throws an error if two keys result in the same flattened key.\n * @param {Record<string, any>} dictionary - The dictionary to flatten.\n * @param {string} [prefix=''] - The prefix for nested keys.\n * @returns {Record<string, React.ReactNode>} The flattened dictionary object.\n * @throws {Error} If two keys result in the same flattened key.\n */\nexport function flattenDictionary(\n dictionary: Dictionary,\n prefix: string = ''\n): FlattenedDictionary {\n const flattened: FlattenedDictionary = {};\n for (const key in dictionary) {\n if (Object.prototype.hasOwnProperty.call(dictionary, key)) {\n const newKey = prefix ? `${prefix}.${key}` : key;\n if (\n typeof get(dictionary, key) === 'object' &&\n get(dictionary, key) !== null &&\n !Array.isArray(get(dictionary, key))\n ) {\n const nestedFlattened = flattenDictionary(\n get(dictionary, key) as Dictionary,\n newKey\n );\n for (const flatKey in nestedFlattened) {\n if (Object.prototype.hasOwnProperty.call(flattened, flatKey)) {\n throw new Error(createDuplicateKeyError(flatKey));\n }\n flattened[flatKey] = nestedFlattened[flatKey];\n }\n } else {\n if (Object.prototype.hasOwnProperty.call(flattened, newKey)) {\n throw new Error(createDuplicateKeyError(newKey));\n }\n flattened[newKey] = get(dictionary, key) as DictionaryEntry;\n }\n }\n }\n return flattened;\n}\n"],"mappings":"mCAOM,EAA2B,GAC/B,uCAAuC,EAAI,GAU7C,SAAgB,EACd,EACA,EAAiB,GACI,CACrB,IAAM,EAAiC,EAAE,CACzC,IAAK,IAAM,KAAO,EAChB,GAAI,OAAO,UAAU,eAAe,KAAK,EAAY,EAAI,CAAE,CACzD,IAAM,EAAS,EAAS,GAAG,EAAO,GAAG,IAAQ,EAC7C,GACE,OAAOA,EAAAA,IAAI,EAAY,EAAI,EAAK,UAChCA,EAAAA,IAAI,EAAY,EAAI,GAAK,MACzB,CAAC,MAAM,QAAQA,EAAAA,IAAI,EAAY,EAAI,CAAC,CACpC,CACA,IAAM,EAAkB,EACtBA,EAAAA,IAAI,EAAY,EAAI,CACpB,EACD,CACD,IAAK,IAAM,KAAW,EAAiB,CACrC,GAAI,OAAO,UAAU,eAAe,KAAK,EAAW,EAAQ,CAC1D,MAAU,MAAM,EAAwB,EAAQ,CAAC,CAEnD,EAAU,GAAW,EAAgB,QAElC,CACL,GAAI,OAAO,UAAU,eAAe,KAAK,EAAW,EAAO,CACzD,MAAU,MAAM,EAAwB,EAAO,CAAC,CAElD,EAAU,GAAUA,EAAAA,IAAI,EAAY,EAAI,EAI9C,OAAO"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Dictionary, FlattenedDictionary } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/dictionaries/flattenDictionary.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Flattens a nested dictionary by concatenating nested keys.
|
|
6
|
+
* Throws an error if two keys result in the same flattened key.
|
|
7
|
+
* @param {Record<string, any>} dictionary - The dictionary to flatten.
|
|
8
|
+
* @param {string} [prefix=''] - The prefix for nested keys.
|
|
9
|
+
* @returns {Record<string, React.ReactNode>} The flattened dictionary object.
|
|
10
|
+
* @throws {Error} If two keys result in the same flattened key.
|
|
11
|
+
*/
|
|
12
|
+
declare function flattenDictionary(dictionary: Dictionary, prefix?: string): FlattenedDictionary;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { flattenDictionary };
|
|
15
|
+
//# sourceMappingURL=flattenDictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenDictionary.d.ts","names":[],"sources":["../../../src/utils/dictionaries/flattenDictionary.ts"],"mappings":";;;;;AAkBA;;;;;;iBAAgB,iBAAA,CACd,UAAA,EAAY,UAAA,EACZ,MAAA,YACC,mBAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{get as e}from"./indexDict.mjs";const t=e=>`Duplicate key found in dictionary: "${e}"`;function n(r,i=``){let a={};for(let o in r)if(Object.prototype.hasOwnProperty.call(r,o)){let s=i?`${i}.${o}`:o;if(typeof e(r,o)==`object`&&e(r,o)!==null&&!Array.isArray(e(r,o))){let i=n(e(r,o),s);for(let e in i){if(Object.prototype.hasOwnProperty.call(a,e))throw Error(t(e));a[e]=i[e]}}else{if(Object.prototype.hasOwnProperty.call(a,s))throw Error(t(s));a[s]=e(r,o)}}return a}export{n as flattenDictionary};
|
|
2
|
+
//# sourceMappingURL=flattenDictionary.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenDictionary.mjs","names":[],"sources":["../../../src/utils/dictionaries/flattenDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionaryEntry,\n FlattenedDictionary,\n} from '../types';\nimport { get } from './indexDict';\n\nconst createDuplicateKeyError = (key: string) =>\n `Duplicate key found in dictionary: \"${key}\"`;\n\n/**\n * Flattens a nested dictionary by concatenating nested keys.\n * Throws an error if two keys result in the same flattened key.\n * @param {Record<string, any>} dictionary - The dictionary to flatten.\n * @param {string} [prefix=''] - The prefix for nested keys.\n * @returns {Record<string, React.ReactNode>} The flattened dictionary object.\n * @throws {Error} If two keys result in the same flattened key.\n */\nexport function flattenDictionary(\n dictionary: Dictionary,\n prefix: string = ''\n): FlattenedDictionary {\n const flattened: FlattenedDictionary = {};\n for (const key in dictionary) {\n if (Object.prototype.hasOwnProperty.call(dictionary, key)) {\n const newKey = prefix ? `${prefix}.${key}` : key;\n if (\n typeof get(dictionary, key) === 'object' &&\n get(dictionary, key) !== null &&\n !Array.isArray(get(dictionary, key))\n ) {\n const nestedFlattened = flattenDictionary(\n get(dictionary, key) as Dictionary,\n newKey\n );\n for (const flatKey in nestedFlattened) {\n if (Object.prototype.hasOwnProperty.call(flattened, flatKey)) {\n throw new Error(createDuplicateKeyError(flatKey));\n }\n flattened[flatKey] = nestedFlattened[flatKey];\n }\n } else {\n if (Object.prototype.hasOwnProperty.call(flattened, newKey)) {\n throw new Error(createDuplicateKeyError(newKey));\n }\n flattened[newKey] = get(dictionary, key) as DictionaryEntry;\n }\n }\n }\n return flattened;\n}\n"],"mappings":"sCAOA,MAAM,EAA2B,GAC/B,uCAAuC,EAAI,GAU7C,SAAgB,EACd,EACA,EAAiB,GACI,CACrB,IAAM,EAAiC,EAAE,CACzC,IAAK,IAAM,KAAO,EAChB,GAAI,OAAO,UAAU,eAAe,KAAK,EAAY,EAAI,CAAE,CACzD,IAAM,EAAS,EAAS,GAAG,EAAO,GAAG,IAAQ,EAC7C,GACE,OAAO,EAAI,EAAY,EAAI,EAAK,UAChC,EAAI,EAAY,EAAI,GAAK,MACzB,CAAC,MAAM,QAAQ,EAAI,EAAY,EAAI,CAAC,CACpC,CACA,IAAM,EAAkB,EACtB,EAAI,EAAY,EAAI,CACpB,EACD,CACD,IAAK,IAAM,KAAW,EAAiB,CACrC,GAAI,OAAO,UAAU,eAAe,KAAK,EAAW,EAAQ,CAC1D,MAAU,MAAM,EAAwB,EAAQ,CAAC,CAEnD,EAAU,GAAW,EAAgB,QAElC,CACL,GAAI,OAAO,UAAU,eAAe,KAAK,EAAW,EAAO,CACzD,MAAU,MAAM,EAAwB,EAAO,CAAC,CAElD,EAAU,GAAU,EAAI,EAAY,EAAI,EAI9C,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./indexDict.cjs`);function t(e){if(typeof e==`string`)return!0;if(Array.isArray(e)){if(typeof e?.[0]!=`string`)return!1;let t=e?.[1];if(t===void 0||t&&typeof t==`object`)return!0}return!1}function n(t,n){let r=t,i=n.split(`.`);for(let t of i){if(typeof r!=`object`&&!Array.isArray(r))return;r=e.get(r,t)}return r}exports.getDictionaryEntry=n,exports.isValidDictionaryEntry=t;
|
|
2
|
+
//# sourceMappingURL=getDictionaryEntry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDictionaryEntry.cjs","names":["get"],"sources":["../../../src/utils/dictionaries/getDictionaryEntry.ts"],"sourcesContent":["import type { Dictionary, DictionaryEntry } from '../types';\nimport { get } from './indexDict';\n\nexport function isValidDictionaryEntry(\n value: unknown\n): value is DictionaryEntry {\n if (typeof value === 'string') {\n return true;\n }\n\n if (Array.isArray(value)) {\n if (typeof value?.[0] !== 'string') {\n return false;\n }\n const provisionalMetadata = value?.[1];\n if (typeof provisionalMetadata === 'undefined') return true;\n if (provisionalMetadata && typeof provisionalMetadata === 'object')\n return true;\n }\n\n return false;\n}\n\nexport function getDictionaryEntry<T extends Dictionary>(\n dictionary: T,\n id: string\n): Dictionary | DictionaryEntry | undefined {\n let current: Dictionary | DictionaryEntry = dictionary;\n const dictionaryPath = id.split('.');\n for (const key of dictionaryPath) {\n if (typeof current !== 'object' && !Array.isArray(current)) {\n return undefined;\n }\n current = get(current as Dictionary, key);\n }\n return current;\n}\n"],"mappings":"mCAGA,SAAgB,EACd,EAC0B,CAC1B,GAAI,OAAO,GAAU,SACnB,MAAO,GAGT,GAAI,MAAM,QAAQ,EAAM,CAAE,CACxB,GAAI,OAAO,IAAQ,IAAO,SACxB,MAAO,GAET,IAAM,EAAsB,IAAQ,GAEpC,GADW,IAAwB,QAC/B,GAAuB,OAAO,GAAwB,SACxD,MAAO,GAGX,MAAO,GAGT,SAAgB,EACd,EACA,EAC0C,CAC1C,IAAI,EAAwC,EACtC,EAAiB,EAAG,MAAM,IAAI,CACpC,IAAK,IAAM,KAAO,EAAgB,CAChC,GAAI,OAAO,GAAY,UAAY,CAAC,MAAM,QAAQ,EAAQ,CACxD,OAEF,EAAUA,EAAAA,IAAI,EAAuB,EAAI,CAE3C,OAAO"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Dictionary, DictionaryEntry } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/dictionaries/getDictionaryEntry.d.ts
|
|
4
|
+
declare function isValidDictionaryEntry(value: unknown): value is DictionaryEntry;
|
|
5
|
+
declare function getDictionaryEntry<T extends Dictionary>(dictionary: T, id: string): Dictionary | DictionaryEntry | undefined;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getDictionaryEntry, isValidDictionaryEntry };
|
|
8
|
+
//# sourceMappingURL=getDictionaryEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDictionaryEntry.d.ts","names":[],"sources":["../../../src/utils/dictionaries/getDictionaryEntry.ts"],"mappings":";;;iBAGgB,sBAAA,CACd,KAAA,YACC,KAAA,IAAS,eAAA;AAAA,iBAkBI,kBAAA,WAA6B,UAAA,CAAA,CAC3C,UAAA,EAAY,CAAA,EACZ,EAAA,WACC,UAAA,GAAa,eAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{get as e}from"./indexDict.mjs";function t(e){if(typeof e==`string`)return!0;if(Array.isArray(e)){if(typeof e?.[0]!=`string`)return!1;let t=e?.[1];if(t===void 0||t&&typeof t==`object`)return!0}return!1}function n(t,n){let r=t,i=n.split(`.`);for(let t of i){if(typeof r!=`object`&&!Array.isArray(r))return;r=e(r,t)}return r}export{n as getDictionaryEntry,t as isValidDictionaryEntry};
|
|
2
|
+
//# sourceMappingURL=getDictionaryEntry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDictionaryEntry.mjs","names":[],"sources":["../../../src/utils/dictionaries/getDictionaryEntry.ts"],"sourcesContent":["import type { Dictionary, DictionaryEntry } from '../types';\nimport { get } from './indexDict';\n\nexport function isValidDictionaryEntry(\n value: unknown\n): value is DictionaryEntry {\n if (typeof value === 'string') {\n return true;\n }\n\n if (Array.isArray(value)) {\n if (typeof value?.[0] !== 'string') {\n return false;\n }\n const provisionalMetadata = value?.[1];\n if (typeof provisionalMetadata === 'undefined') return true;\n if (provisionalMetadata && typeof provisionalMetadata === 'object')\n return true;\n }\n\n return false;\n}\n\nexport function getDictionaryEntry<T extends Dictionary>(\n dictionary: T,\n id: string\n): Dictionary | DictionaryEntry | undefined {\n let current: Dictionary | DictionaryEntry = dictionary;\n const dictionaryPath = id.split('.');\n for (const key of dictionaryPath) {\n if (typeof current !== 'object' && !Array.isArray(current)) {\n return undefined;\n }\n current = get(current as Dictionary, key);\n }\n return current;\n}\n"],"mappings":"sCAGA,SAAgB,EACd,EAC0B,CAC1B,GAAI,OAAO,GAAU,SACnB,MAAO,GAGT,GAAI,MAAM,QAAQ,EAAM,CAAE,CACxB,GAAI,OAAO,IAAQ,IAAO,SACxB,MAAO,GAET,IAAM,EAAsB,IAAQ,GAEpC,GADW,IAAwB,QAC/B,GAAuB,OAAO,GAAwB,SACxD,MAAO,GAGX,MAAO,GAGT,SAAgB,EACd,EACA,EAC0C,CAC1C,IAAI,EAAwC,EACtC,EAAiB,EAAG,MAAM,IAAI,CACpC,IAAK,IAAM,KAAO,EAAgB,CAChC,GAAI,OAAO,GAAY,UAAY,CAAC,MAAM,QAAQ,EAAQ,CACxD,OAEF,EAAU,EAAI,EAAuB,EAAI,CAE3C,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEntryAndMetadata.cjs","names":[],"sources":["../../../src/utils/dictionaries/getEntryAndMetadata.ts"],"sourcesContent":["import type { DictionaryEntry, MetaEntry } from '../types';\n\nexport function getEntryAndMetadata(value: DictionaryEntry): {\n entry: string;\n metadata?: MetaEntry;\n} {\n if (Array.isArray(value)) {\n if (value.length === 1) {\n return { entry: value[0] };\n }\n if (value.length === 2) {\n return { entry: value[0], metadata: value[1] as MetaEntry };\n }\n }\n return { entry: value };\n}\n"],"mappings":"AAEA,SAAgB,EAAoB,EAGlC,CACA,GAAI,MAAM,QAAQ,EAAM,CAAE,CACxB,GAAI,EAAM,SAAW,EACnB,MAAO,CAAE,MAAO,EAAM,GAAI,CAE5B,GAAI,EAAM,SAAW,EACnB,MAAO,CAAE,MAAO,EAAM,GAAI,SAAU,EAAM,GAAiB,CAG/D,MAAO,CAAE,MAAO,EAAO"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DictionaryEntry, MetaEntry } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/dictionaries/getEntryAndMetadata.d.ts
|
|
4
|
+
declare function getEntryAndMetadata(value: DictionaryEntry): {
|
|
5
|
+
entry: string;
|
|
6
|
+
metadata?: MetaEntry;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getEntryAndMetadata };
|
|
10
|
+
//# sourceMappingURL=getEntryAndMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEntryAndMetadata.d.ts","names":[],"sources":["../../../src/utils/dictionaries/getEntryAndMetadata.ts"],"mappings":";;;iBAEgB,mBAAA,CAAoB,KAAA,EAAO,eAAA;EACzC,KAAA;EACA,QAAA,GAAW,SAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEntryAndMetadata.mjs","names":[],"sources":["../../../src/utils/dictionaries/getEntryAndMetadata.ts"],"sourcesContent":["import type { DictionaryEntry, MetaEntry } from '../types';\n\nexport function getEntryAndMetadata(value: DictionaryEntry): {\n entry: string;\n metadata?: MetaEntry;\n} {\n if (Array.isArray(value)) {\n if (value.length === 1) {\n return { entry: value[0] };\n }\n if (value.length === 2) {\n return { entry: value[0], metadata: value[1] as MetaEntry };\n }\n }\n return { entry: value };\n}\n"],"mappings":"AAEA,SAAgB,EAAoB,EAGlC,CACA,GAAI,MAAM,QAAQ,EAAM,CAAE,CACxB,GAAI,EAAM,SAAW,EACnB,MAAO,CAAE,MAAO,EAAM,GAAI,CAE5B,GAAI,EAAM,SAAW,EACnB,MAAO,CAAE,MAAO,EAAM,GAAI,SAAU,EAAM,GAAiB,CAG/D,MAAO,CAAE,MAAO,EAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexDict.cjs","names":[],"sources":["../../../src/utils/dictionaries/indexDict.ts"],"sourcesContent":["import type { Dictionary, DictionaryEntry } from '../types';\n\n/**\n * @description A function that gets a value from a dictionary, only one level\n * @param dictionary - dictionary to get the value from\n * @param id - id of the value to get\n */\nexport function get(dictionary: Dictionary, id: string | number) {\n if (dictionary == null) {\n throw new Error('Cannot index into an undefined dictionary');\n }\n if (Array.isArray(dictionary)) {\n return dictionary[id as number];\n }\n return dictionary[id as string];\n}\n\n/**\n * @description A function that sets a value in a dictionary\n * @param dictionary - dictionary to set the value in\n * @param id - id of the value to set\n * @param value - value to set\n */\nexport function set(\n dictionary: Dictionary,\n id: string | number,\n value: Dictionary | DictionaryEntry\n) {\n if (Array.isArray(dictionary)) {\n dictionary[id as number] = value;\n } else {\n (dictionary as Record<string, Dictionary | DictionaryEntry>)[id as string] =\n value;\n }\n}\n"],"mappings":"AAOA,SAAgB,EAAI,EAAwB,EAAqB,CAC/D,GAAI,GAAc,KAChB,MAAU,MAAM,4CAA4C,CAK9D,OAFS,EAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexDict.mjs","names":[],"sources":["../../../src/utils/dictionaries/indexDict.ts"],"sourcesContent":["import type { Dictionary, DictionaryEntry } from '../types';\n\n/**\n * @description A function that gets a value from a dictionary, only one level\n * @param dictionary - dictionary to get the value from\n * @param id - id of the value to get\n */\nexport function get(dictionary: Dictionary, id: string | number) {\n if (dictionary == null) {\n throw new Error('Cannot index into an undefined dictionary');\n }\n if (Array.isArray(dictionary)) {\n return dictionary[id as number];\n }\n return dictionary[id as string];\n}\n\n/**\n * @description A function that sets a value in a dictionary\n * @param dictionary - dictionary to set the value in\n * @param id - id of the value to set\n * @param value - value to set\n */\nexport function set(\n dictionary: Dictionary,\n id: string | number,\n value: Dictionary | DictionaryEntry\n) {\n if (Array.isArray(dictionary)) {\n dictionary[id as number] = value;\n } else {\n (dictionary as Record<string, Dictionary | DictionaryEntry>)[id as string] =\n value;\n }\n}\n"],"mappings":"AAOA,SAAgB,EAAI,EAAwB,EAAqB,CAC/D,GAAI,GAAc,KAChB,MAAU,MAAM,4CAA4C,CAK9D,OAFS,EAAW"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){return e===void 0?!1:typeof e==`string`?!0:Array.isArray(e)?!(e.length!==1&&e.length!==2||typeof e[0]!=`string`||e.length===2&&(typeof e[1]!=`object`||e[1]===null||!(`$context`in e[1])&&!(`$maxChars`in e[1])&&!(`$_hash`in e[1]))):!1}exports.isDictionaryEntry=e;
|
|
2
|
+
//# sourceMappingURL=isDictionaryEntry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDictionaryEntry.cjs","names":[],"sources":["../../../src/utils/dictionaries/isDictionaryEntry.ts"],"sourcesContent":["import type { Dictionary, DictionaryEntry } from '../types';\n\n/**\n * Type guard function that checks if a value is a DictionaryEntry\n * @param value - The value to check\n * @returns true if the value is a DictionaryEntry, false otherwise\n */\nexport function isDictionaryEntry(\n value: Dictionary | DictionaryEntry | undefined\n): value is DictionaryEntry {\n if (value === undefined) {\n return false;\n }\n\n // Check if it's a string (Entry)\n if (typeof value === 'string') {\n return true;\n }\n\n // Check if it's an array\n if (Array.isArray(value)) {\n // Must have 1 or 2 elements\n if (value.length !== 1 && value.length !== 2) {\n return false;\n }\n\n // First element must be a string (Entry)\n if (typeof value[0] !== 'string') {\n return false;\n }\n\n // If there's a second element, it must be an object (MetaEntry)\n if (\n value.length === 2 &&\n (typeof value[1] !== 'object' ||\n value[1] === null ||\n (!('$context' in value[1]) &&\n !('$maxChars' in value[1]) &&\n !('$_hash' in value[1])))\n ) {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n"],"mappings":"AAOA,SAAgB,EACd,EAC0B,CAqC1B,OApCI,IAAU,IAAA,GACL,GAIL,OAAO,GAAU,SACZ,GAIL,MAAM,QAAQ,EAAM,CAYtB,EAVI,EAAM,SAAW,GAAK,EAAM,SAAW,GAKvC,OAAO,EAAM,IAAO,UAMtB,EAAM,SAAW,IAChB,OAAO,EAAM,IAAO,UACnB,EAAM,KAAO,MACZ,EAAE,aAAc,EAAM,KACrB,EAAE,cAAe,EAAM,KACvB,EAAE,WAAY,EAAM,MAQrB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dictionary, DictionaryEntry } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/dictionaries/isDictionaryEntry.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Type guard function that checks if a value is a DictionaryEntry
|
|
6
|
+
* @param value - The value to check
|
|
7
|
+
* @returns true if the value is a DictionaryEntry, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
declare function isDictionaryEntry(value: Dictionary | DictionaryEntry | undefined): value is DictionaryEntry;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { isDictionaryEntry };
|
|
12
|
+
//# sourceMappingURL=isDictionaryEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDictionaryEntry.d.ts","names":[],"sources":["../../../src/utils/dictionaries/isDictionaryEntry.ts"],"mappings":";;;;;AAOA;;;iBAAgB,iBAAA,CACd,KAAA,EAAO,UAAA,GAAa,eAAA,eACnB,KAAA,IAAS,eAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){return e===void 0?!1:typeof e==`string`?!0:Array.isArray(e)?!(e.length!==1&&e.length!==2||typeof e[0]!=`string`||e.length===2&&(typeof e[1]!=`object`||e[1]===null||!(`$context`in e[1])&&!(`$maxChars`in e[1])&&!(`$_hash`in e[1]))):!1}export{e as isDictionaryEntry};
|
|
2
|
+
//# sourceMappingURL=isDictionaryEntry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDictionaryEntry.mjs","names":[],"sources":["../../../src/utils/dictionaries/isDictionaryEntry.ts"],"sourcesContent":["import type { Dictionary, DictionaryEntry } from '../types';\n\n/**\n * Type guard function that checks if a value is a DictionaryEntry\n * @param value - The value to check\n * @returns true if the value is a DictionaryEntry, false otherwise\n */\nexport function isDictionaryEntry(\n value: Dictionary | DictionaryEntry | undefined\n): value is DictionaryEntry {\n if (value === undefined) {\n return false;\n }\n\n // Check if it's a string (Entry)\n if (typeof value === 'string') {\n return true;\n }\n\n // Check if it's an array\n if (Array.isArray(value)) {\n // Must have 1 or 2 elements\n if (value.length !== 1 && value.length !== 2) {\n return false;\n }\n\n // First element must be a string (Entry)\n if (typeof value[0] !== 'string') {\n return false;\n }\n\n // If there's a second element, it must be an object (MetaEntry)\n if (\n value.length === 2 &&\n (typeof value[1] !== 'object' ||\n value[1] === null ||\n (!('$context' in value[1]) &&\n !('$maxChars' in value[1]) &&\n !('$_hash' in value[1])))\n ) {\n return false;\n }\n\n return true;\n }\n\n return false;\n}\n"],"mappings":"AAOA,SAAgB,EACd,EAC0B,CAqC1B,OApCI,IAAU,IAAA,GACL,GAIL,OAAO,GAAU,SACZ,GAIL,MAAM,QAAQ,EAAM,CAYtB,EAVI,EAAM,SAAW,GAAK,EAAM,SAAW,GAKvC,OAAO,EAAM,IAAO,UAMtB,EAAM,SAAW,IAChB,OAAO,EAAM,IAAO,UACnB,EAAM,KAAO,MACZ,EAAE,aAAc,EAAM,KACrB,EAAE,cAAe,EAAM,KACvB,EAAE,WAAY,EAAM,MAQrB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`./indexDict.cjs`),t=require(`./isDictionaryEntry.cjs`),n=e=>typeof e==`string`||Array.isArray(e),r=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function i(a,o){if(Array.isArray(a))return a.map((e,n)=>t.isDictionaryEntry(e)?o[n]:i(e,o[n]));let s={...Object.fromEntries(Object.entries(a).filter(([,e])=>n(e))),...Object.fromEntries(Object.entries(o).filter(([,e])=>n(e)))},c=Object.entries(a).filter(([,e])=>r(e)).map(([e])=>e),l=Object.entries(o).filter(([,e])=>r(e)).map(([e])=>e),u=new Set([...c,...l]);for(let t of u)s[t]=i(e.get(a,t)||{},e.get(o,t)||{});return s}exports.mergeDictionaries=i;
|
|
2
|
+
//# sourceMappingURL=mergeDictionaries.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeDictionaries.cjs","names":["isDictionaryEntry","get"],"sources":["../../../src/utils/dictionaries/mergeDictionaries.ts"],"sourcesContent":["import type { Dictionary, DictionaryEntry } from '../types';\nimport { get } from './indexDict';\nimport { isDictionaryEntry } from './isDictionaryEntry';\n\nconst isPrimitiveOrArray = (value: unknown): boolean =>\n typeof value === 'string' || Array.isArray(value);\n\nconst isObjectDictionary = (value: unknown): boolean =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport function mergeDictionaries(\n defaultLocaleDictionary: Dictionary,\n localeDictionary: Dictionary\n): Dictionary {\n if (Array.isArray(defaultLocaleDictionary)) {\n return defaultLocaleDictionary.map((value, key) => {\n if (isDictionaryEntry(value)) {\n return (localeDictionary as (Dictionary | DictionaryEntry)[])[key];\n }\n return mergeDictionaries(\n value as Dictionary,\n (localeDictionary as (Dictionary | DictionaryEntry)[])[\n key\n ] as Dictionary\n );\n });\n }\n\n const mergedDictionary: Dictionary = {\n ...Object.fromEntries(\n Object.entries(defaultLocaleDictionary).filter(([, value]) =>\n isPrimitiveOrArray(value)\n )\n ),\n ...Object.fromEntries(\n Object.entries(localeDictionary).filter(([, value]) =>\n isPrimitiveOrArray(value)\n )\n ),\n };\n\n const defaultDictionaryKeys = Object.entries(defaultLocaleDictionary)\n .filter(([, value]) => isObjectDictionary(value))\n .map(([key]) => key);\n\n const localeDictionaryKeys = Object.entries(localeDictionary)\n .filter(([, value]) => isObjectDictionary(value))\n .map(([key]) => key);\n\n const allKeys = new Set([...defaultDictionaryKeys, ...localeDictionaryKeys]);\n for (const key of allKeys) {\n mergedDictionary[key] = mergeDictionaries(\n (get(defaultLocaleDictionary, key) || {}) as Dictionary,\n (get(localeDictionary, key) || {}) as Dictionary\n );\n }\n\n return mergedDictionary;\n}\n"],"mappings":"wEAIM,EAAsB,GAC1B,OAAO,GAAU,UAAY,MAAM,QAAQ,EAAM,CAE7C,EAAsB,GAC1B,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,EAAM,CAEtE,SAAgB,EACd,EACA,EACY,CACZ,GAAI,MAAM,QAAQ,EAAwB,CACxC,OAAO,EAAwB,KAAK,EAAO,IACrCA,EAAAA,kBAAkB,EAAM,CAClB,EAAsD,GAEzD,EACL,EACC,EACC,GAEH,CACD,CAGJ,IAAM,EAA+B,CACnC,GAAG,OAAO,YACR,OAAO,QAAQ,EAAwB,CAAC,QAAQ,EAAG,KACjD,EAAmB,EAAM,CAC1B,CACF,CACD,GAAG,OAAO,YACR,OAAO,QAAQ,EAAiB,CAAC,QAAQ,EAAG,KAC1C,EAAmB,EAAM,CAC1B,CACF,CACF,CAEK,EAAwB,OAAO,QAAQ,EAAwB,CAClE,QAAQ,EAAG,KAAW,EAAmB,EAAM,CAAC,CAChD,KAAK,CAAC,KAAS,EAAI,CAEhB,EAAuB,OAAO,QAAQ,EAAiB,CAC1D,QAAQ,EAAG,KAAW,EAAmB,EAAM,CAAC,CAChD,KAAK,CAAC,KAAS,EAAI,CAEhB,EAAU,IAAI,IAAI,CAAC,GAAG,EAAuB,GAAG,EAAqB,CAAC,CAC5E,IAAK,IAAM,KAAO,EAChB,EAAiB,GAAO,EACrBC,EAAAA,IAAI,EAAyB,EAAI,EAAI,EAAE,CACvCA,EAAAA,IAAI,EAAkB,EAAI,EAAI,EAAE,CAClC,CAGH,OAAO"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Dictionary } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/dictionaries/mergeDictionaries.d.ts
|
|
4
|
+
declare function mergeDictionaries(defaultLocaleDictionary: Dictionary, localeDictionary: Dictionary): Dictionary;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { mergeDictionaries };
|
|
7
|
+
//# sourceMappingURL=mergeDictionaries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeDictionaries.d.ts","names":[],"sources":["../../../src/utils/dictionaries/mergeDictionaries.ts"],"mappings":";;;iBAUgB,iBAAA,CACd,uBAAA,EAAyB,UAAA,EACzB,gBAAA,EAAkB,UAAA,GACjB,UAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{get as e}from"./indexDict.mjs";import{isDictionaryEntry as t}from"./isDictionaryEntry.mjs";const n=e=>typeof e==`string`||Array.isArray(e),r=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function i(a,o){if(Array.isArray(a))return a.map((e,n)=>t(e)?o[n]:i(e,o[n]));let s={...Object.fromEntries(Object.entries(a).filter(([,e])=>n(e))),...Object.fromEntries(Object.entries(o).filter(([,e])=>n(e)))},c=Object.entries(a).filter(([,e])=>r(e)).map(([e])=>e),l=Object.entries(o).filter(([,e])=>r(e)).map(([e])=>e),u=new Set([...c,...l]);for(let t of u)s[t]=i(e(a,t)||{},e(o,t)||{});return s}export{i as mergeDictionaries};
|
|
2
|
+
//# sourceMappingURL=mergeDictionaries.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeDictionaries.mjs","names":[],"sources":["../../../src/utils/dictionaries/mergeDictionaries.ts"],"sourcesContent":["import type { Dictionary, DictionaryEntry } from '../types';\nimport { get } from './indexDict';\nimport { isDictionaryEntry } from './isDictionaryEntry';\n\nconst isPrimitiveOrArray = (value: unknown): boolean =>\n typeof value === 'string' || Array.isArray(value);\n\nconst isObjectDictionary = (value: unknown): boolean =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport function mergeDictionaries(\n defaultLocaleDictionary: Dictionary,\n localeDictionary: Dictionary\n): Dictionary {\n if (Array.isArray(defaultLocaleDictionary)) {\n return defaultLocaleDictionary.map((value, key) => {\n if (isDictionaryEntry(value)) {\n return (localeDictionary as (Dictionary | DictionaryEntry)[])[key];\n }\n return mergeDictionaries(\n value as Dictionary,\n (localeDictionary as (Dictionary | DictionaryEntry)[])[\n key\n ] as Dictionary\n );\n });\n }\n\n const mergedDictionary: Dictionary = {\n ...Object.fromEntries(\n Object.entries(defaultLocaleDictionary).filter(([, value]) =>\n isPrimitiveOrArray(value)\n )\n ),\n ...Object.fromEntries(\n Object.entries(localeDictionary).filter(([, value]) =>\n isPrimitiveOrArray(value)\n )\n ),\n };\n\n const defaultDictionaryKeys = Object.entries(defaultLocaleDictionary)\n .filter(([, value]) => isObjectDictionary(value))\n .map(([key]) => key);\n\n const localeDictionaryKeys = Object.entries(localeDictionary)\n .filter(([, value]) => isObjectDictionary(value))\n .map(([key]) => key);\n\n const allKeys = new Set([...defaultDictionaryKeys, ...localeDictionaryKeys]);\n for (const key of allKeys) {\n mergedDictionary[key] = mergeDictionaries(\n (get(defaultLocaleDictionary, key) || {}) as Dictionary,\n (get(localeDictionary, key) || {}) as Dictionary\n );\n }\n\n return mergedDictionary;\n}\n"],"mappings":"kGAIA,MAAM,EAAsB,GAC1B,OAAO,GAAU,UAAY,MAAM,QAAQ,EAAM,CAE7C,EAAsB,GAC1B,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,EAAM,CAEtE,SAAgB,EACd,EACA,EACY,CACZ,GAAI,MAAM,QAAQ,EAAwB,CACxC,OAAO,EAAwB,KAAK,EAAO,IACrC,EAAkB,EAAM,CAClB,EAAsD,GAEzD,EACL,EACC,EACC,GAEH,CACD,CAGJ,IAAM,EAA+B,CACnC,GAAG,OAAO,YACR,OAAO,QAAQ,EAAwB,CAAC,QAAQ,EAAG,KACjD,EAAmB,EAAM,CAC1B,CACF,CACD,GAAG,OAAO,YACR,OAAO,QAAQ,EAAiB,CAAC,QAAQ,EAAG,KAC1C,EAAmB,EAAM,CAC1B,CACF,CACF,CAEK,EAAwB,OAAO,QAAQ,EAAwB,CAClE,QAAQ,EAAG,KAAW,EAAmB,EAAM,CAAC,CAChD,KAAK,CAAC,KAAS,EAAI,CAEhB,EAAuB,OAAO,QAAQ,EAAiB,CAC1D,QAAQ,EAAG,KAAW,EAAmB,EAAM,CAAC,CAChD,KAAK,CAAC,KAAS,EAAI,CAEhB,EAAU,IAAI,IAAI,CAAC,GAAG,EAAuB,GAAG,EAAqB,CAAC,CAC5E,IAAK,IAAM,KAAO,EAChB,EAAiB,GAAO,EACrB,EAAI,EAAyB,EAAI,EAAI,EAAE,CACvC,EAAI,EAAkB,EAAI,EAAI,EAAE,CAClC,CAGH,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`../../_virtual/_rolldown/runtime.cjs`);let t=require(`generaltranslation/internal`),n=require(`react`);n=e.__toESM(n);function r(e,i=0){let a=i,o=e=>{let{type:n,props:i}=e;a+=1;let o={id:a,injectionType:`manual`},s;try{s=typeof n==`function`?n._gtt:void 0}catch{}if(s){let e=s.split(`-`);if((e[1]===`automatic`||e[2]===`automatic`)&&(o.injectionType=`automatic`),e[0]===`translate`&&(e[0]=`fragment`),e[0]===`variable`&&(o.variableType=e?.[1]||`variable`),e[0]===`plural`){let e=Object.entries(i).reduce((e,[n,i])=>((0,t.isAcceptedPluralForm)(n)&&(e[n]=r(i,a)),e),{});Object.keys(e).length&&(o.branches=e)}if(e[0]===`branch`){let{children:e,branch:t,...n}=i,s=Object.fromEntries(Object.entries(n).filter(([e])=>!e.startsWith(`data-`))),c=Object.entries(s).reduce((e,[t,n])=>(e[t]=r(n,a),e),{});Object.keys(c).length&&(o.branches=c)}o.transformation=e[0]}return o};function s(e){let{props:t}=e,r=o(e),i={...t,"data-_gt":r};return t.children&&!r.variableType&&(i.children=l(t.children)),e.type===n.default.Fragment&&(i[`data-_gt`].transformation=`fragment`),n.default.cloneElement(e,i)}function c(e){return(0,n.isValidElement)(e)?s(e):e}function l(e){return Array.isArray(e)?n.default.Children.map(e,c):c(e)}return l(e)}exports.addGTIdentifier=r;
|
|
2
|
+
//# sourceMappingURL=addGTIdentifier.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addGTIdentifier.cjs","names":["React"],"sources":["../../../src/utils/internal/addGTIdentifier.ts"],"sourcesContent":["import React, { ReactElement, isValidElement, ReactNode } from 'react';\nimport { isAcceptedPluralForm } from 'generaltranslation/internal';\nimport {\n GTTag,\n TaggedChild,\n TaggedChildren,\n TaggedElement,\n TaggedElementProps,\n} from '../types';\nimport {\n Transformation,\n TransformationPrefix,\n VariableTransformationSuffix,\n} from 'generaltranslation/types';\n\ntype GTComponentType = {\n _gtt?: Transformation;\n};\n\nexport function addGTIdentifier(\n children: ReactNode,\n startingIndex: number = 0\n): TaggedChildren {\n // Object to keep track of the current index for GT IDs\n let index = startingIndex;\n\n /**\n * Function to create a GTTag object for a ReactElement\n * @param child - The ReactElement for which the GTTag is created\n * @returns - The GTTag object\n */\n const createGTTag = (child: ReactElement<Record<string, unknown>>): GTTag => {\n const { type, props } = child;\n index += 1;\n const result: GTTag = { id: index, injectionType: 'manual' };\n let transformation: Transformation | undefined;\n try {\n transformation =\n typeof type === 'function' ? (type as GTComponentType)._gtt : undefined;\n } catch {\n /* empty */\n }\n if (transformation) {\n const transformationParts = transformation.split('-');\n // If the component was inserted automatically by the compiler\n if (\n transformationParts[1] === 'automatic' ||\n transformationParts[2] === 'automatic'\n ) {\n result.injectionType = 'automatic';\n }\n\n if (transformationParts[0] === 'translate') {\n // Convert nested <T> to fragments\n // This will nullify translation specific attributes of child, i.e. id, context, etc.\n transformationParts[0] = 'fragment';\n }\n if (transformationParts[0] === 'variable') {\n result.variableType =\n (transformationParts?.[1] as VariableTransformationSuffix) ||\n 'variable';\n }\n if (transformationParts[0] === 'plural') {\n const pluralBranches = Object.entries(props).reduce(\n (acc, [branchName, branch]) => {\n if (isAcceptedPluralForm(branchName)) {\n (acc as Record<string, TaggedChildren>)[branchName] =\n addGTIdentifier(branch as ReactNode, index);\n }\n return acc;\n },\n {} as Record<string, TaggedChildren>\n );\n if (Object.keys(pluralBranches).length)\n result.branches = pluralBranches;\n }\n if (transformationParts[0] === 'branch') {\n const { children: _children, branch: _branch, ...branches } = props;\n // Filter out data-* attributes injected by build tools\n const filteredBranches = Object.fromEntries(\n Object.entries(branches).filter(([key]) => !key.startsWith('data-'))\n );\n const resultBranches = Object.entries(filteredBranches).reduce(\n (acc, [branchName, branch]) => {\n (acc as Record<string, TaggedChildren>)[branchName] =\n addGTIdentifier(branch as ReactNode, index);\n return acc;\n },\n {} as Record<string, TaggedChildren>\n );\n if (Object.keys(resultBranches).length)\n result.branches = resultBranches;\n }\n result.transformation = transformationParts[0] as TransformationPrefix;\n }\n return result;\n };\n\n function handleSingleChildElement(\n child: ReactElement<Record<string, unknown>>\n ): TaggedElement {\n const { props } = child;\n\n // Create new props for the element, including the GT identifier and a key\n const generaltranslation: GTTag = createGTTag(child);\n const newProps: TaggedElementProps = {\n ...props,\n 'data-_gt': generaltranslation,\n };\n if (props.children && !generaltranslation.variableType) {\n newProps.children = handleChildren(props.children as ReactNode);\n }\n if (child.type === React.Fragment) {\n newProps['data-_gt'].transformation = 'fragment';\n }\n return React.cloneElement(child, newProps) as TaggedElement;\n }\n\n function handleSingleChild(child: ReactNode): TaggedChild {\n if (isValidElement(child)) {\n return handleSingleChildElement(\n child as ReactElement<Record<string, unknown>>\n );\n }\n return child;\n }\n\n function handleChildren(children: ReactNode): TaggedChildren {\n if (Array.isArray(children)) {\n return React.Children.map(children, handleSingleChild);\n } else {\n return handleSingleChild(children);\n }\n }\n\n return handleChildren(children);\n}\n"],"mappings":"uIAmBA,SAAgB,EACd,EACA,EAAwB,EACR,CAEhB,IAAI,EAAQ,EAON,EAAe,GAAwD,CAC3E,GAAM,CAAE,OAAM,SAAU,EACxB,GAAS,EACT,IAAM,EAAgB,CAAE,GAAI,EAAO,cAAe,SAAU,CACxD,EACJ,GAAI,CACF,EACE,OAAO,GAAS,WAAc,EAAyB,KAAO,IAAA,QAC1D,EAGR,GAAI,EAAgB,CAClB,IAAM,EAAsB,EAAe,MAAM,IAAI,CAmBrD,IAhBE,EAAoB,KAAO,aAC3B,EAAoB,KAAO,eAE3B,EAAO,cAAgB,aAGrB,EAAoB,KAAO,cAG7B,EAAoB,GAAK,YAEvB,EAAoB,KAAO,aAC7B,EAAO,aACJ,IAAsB,IACvB,YAEA,EAAoB,KAAO,SAAU,CACvC,IAAM,EAAiB,OAAO,QAAQ,EAAM,CAAC,QAC1C,EAAK,CAAC,EAAY,OACjB,EAAA,EAAA,sBAAyB,EAAW,GACjC,EAAuC,GACtC,EAAgB,EAAqB,EAAM,EAExC,GAET,EAAE,CACH,CACG,OAAO,KAAK,EAAe,CAAC,SAC9B,EAAO,SAAW,GAEtB,GAAI,EAAoB,KAAO,SAAU,CACvC,GAAM,CAAE,SAAU,EAAW,OAAQ,EAAS,GAAG,GAAa,EAExD,EAAmB,OAAO,YAC9B,OAAO,QAAQ,EAAS,CAAC,QAAQ,CAAC,KAAS,CAAC,EAAI,WAAW,QAAQ,CAAC,CACrE,CACK,EAAiB,OAAO,QAAQ,EAAiB,CAAC,QACrD,EAAK,CAAC,EAAY,MAChB,EAAuC,GACtC,EAAgB,EAAqB,EAAM,CACtC,GAET,EAAE,CACH,CACG,OAAO,KAAK,EAAe,CAAC,SAC9B,EAAO,SAAW,GAEtB,EAAO,eAAiB,EAAoB,GAE9C,OAAO,GAGT,SAAS,EACP,EACe,CACf,GAAM,CAAE,SAAU,EAGZ,EAA4B,EAAY,EAAM,CAC9C,EAA+B,CACnC,GAAG,EACH,WAAY,EACb,CAOD,OANI,EAAM,UAAY,CAAC,EAAmB,eACxC,EAAS,SAAW,EAAe,EAAM,SAAsB,EAE7D,EAAM,OAASA,EAAAA,QAAM,WACvB,EAAS,YAAY,eAAiB,YAEjCA,EAAAA,QAAM,aAAa,EAAO,EAAS,CAG5C,SAAS,EAAkB,EAA+B,CAMxD,OALA,EAAA,EAAA,gBAAmB,EAAM,CAChB,EACL,EACD,CAEI,EAGT,SAAS,EAAe,EAAqC,CAIzD,OAHE,MAAM,QAAQ,EAAS,CAClBA,EAAAA,QAAM,SAAS,IAAI,EAAU,EAAkB,CAE/C,EAAkB,EAAS,CAItC,OAAO,EAAe,EAAS"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TaggedChildren } from "../types.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/internal/addGTIdentifier.d.ts
|
|
5
|
+
declare function addGTIdentifier(children: ReactNode, startingIndex?: number): TaggedChildren;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { addGTIdentifier };
|
|
8
|
+
//# sourceMappingURL=addGTIdentifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addGTIdentifier.d.ts","names":[],"sources":["../../../src/utils/internal/addGTIdentifier.ts"],"mappings":";;;;iBAmBgB,eAAA,CACd,QAAA,EAAU,SAAA,EACV,aAAA,YACC,cAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{isAcceptedPluralForm as e}from"generaltranslation/internal";import t,{isValidElement as n}from"react";function r(i,a=0){let o=a,s=t=>{let{type:n,props:i}=t;o+=1;let a={id:o,injectionType:`manual`},s;try{s=typeof n==`function`?n._gtt:void 0}catch{}if(s){let t=s.split(`-`);if((t[1]===`automatic`||t[2]===`automatic`)&&(a.injectionType=`automatic`),t[0]===`translate`&&(t[0]=`fragment`),t[0]===`variable`&&(a.variableType=t?.[1]||`variable`),t[0]===`plural`){let t=Object.entries(i).reduce((t,[n,i])=>(e(n)&&(t[n]=r(i,o)),t),{});Object.keys(t).length&&(a.branches=t)}if(t[0]===`branch`){let{children:e,branch:t,...n}=i,s=Object.fromEntries(Object.entries(n).filter(([e])=>!e.startsWith(`data-`))),c=Object.entries(s).reduce((e,[t,n])=>(e[t]=r(n,o),e),{});Object.keys(c).length&&(a.branches=c)}a.transformation=t[0]}return a};function c(e){let{props:n}=e,r=s(e),i={...n,"data-_gt":r};return n.children&&!r.variableType&&(i.children=u(n.children)),e.type===t.Fragment&&(i[`data-_gt`].transformation=`fragment`),t.cloneElement(e,i)}function l(e){return n(e)?c(e):e}function u(e){return Array.isArray(e)?t.Children.map(e,l):l(e)}return u(i)}export{r as addGTIdentifier};
|
|
2
|
+
//# sourceMappingURL=addGTIdentifier.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addGTIdentifier.mjs","names":[],"sources":["../../../src/utils/internal/addGTIdentifier.ts"],"sourcesContent":["import React, { ReactElement, isValidElement, ReactNode } from 'react';\nimport { isAcceptedPluralForm } from 'generaltranslation/internal';\nimport {\n GTTag,\n TaggedChild,\n TaggedChildren,\n TaggedElement,\n TaggedElementProps,\n} from '../types';\nimport {\n Transformation,\n TransformationPrefix,\n VariableTransformationSuffix,\n} from 'generaltranslation/types';\n\ntype GTComponentType = {\n _gtt?: Transformation;\n};\n\nexport function addGTIdentifier(\n children: ReactNode,\n startingIndex: number = 0\n): TaggedChildren {\n // Object to keep track of the current index for GT IDs\n let index = startingIndex;\n\n /**\n * Function to create a GTTag object for a ReactElement\n * @param child - The ReactElement for which the GTTag is created\n * @returns - The GTTag object\n */\n const createGTTag = (child: ReactElement<Record<string, unknown>>): GTTag => {\n const { type, props } = child;\n index += 1;\n const result: GTTag = { id: index, injectionType: 'manual' };\n let transformation: Transformation | undefined;\n try {\n transformation =\n typeof type === 'function' ? (type as GTComponentType)._gtt : undefined;\n } catch {\n /* empty */\n }\n if (transformation) {\n const transformationParts = transformation.split('-');\n // If the component was inserted automatically by the compiler\n if (\n transformationParts[1] === 'automatic' ||\n transformationParts[2] === 'automatic'\n ) {\n result.injectionType = 'automatic';\n }\n\n if (transformationParts[0] === 'translate') {\n // Convert nested <T> to fragments\n // This will nullify translation specific attributes of child, i.e. id, context, etc.\n transformationParts[0] = 'fragment';\n }\n if (transformationParts[0] === 'variable') {\n result.variableType =\n (transformationParts?.[1] as VariableTransformationSuffix) ||\n 'variable';\n }\n if (transformationParts[0] === 'plural') {\n const pluralBranches = Object.entries(props).reduce(\n (acc, [branchName, branch]) => {\n if (isAcceptedPluralForm(branchName)) {\n (acc as Record<string, TaggedChildren>)[branchName] =\n addGTIdentifier(branch as ReactNode, index);\n }\n return acc;\n },\n {} as Record<string, TaggedChildren>\n );\n if (Object.keys(pluralBranches).length)\n result.branches = pluralBranches;\n }\n if (transformationParts[0] === 'branch') {\n const { children: _children, branch: _branch, ...branches } = props;\n // Filter out data-* attributes injected by build tools\n const filteredBranches = Object.fromEntries(\n Object.entries(branches).filter(([key]) => !key.startsWith('data-'))\n );\n const resultBranches = Object.entries(filteredBranches).reduce(\n (acc, [branchName, branch]) => {\n (acc as Record<string, TaggedChildren>)[branchName] =\n addGTIdentifier(branch as ReactNode, index);\n return acc;\n },\n {} as Record<string, TaggedChildren>\n );\n if (Object.keys(resultBranches).length)\n result.branches = resultBranches;\n }\n result.transformation = transformationParts[0] as TransformationPrefix;\n }\n return result;\n };\n\n function handleSingleChildElement(\n child: ReactElement<Record<string, unknown>>\n ): TaggedElement {\n const { props } = child;\n\n // Create new props for the element, including the GT identifier and a key\n const generaltranslation: GTTag = createGTTag(child);\n const newProps: TaggedElementProps = {\n ...props,\n 'data-_gt': generaltranslation,\n };\n if (props.children && !generaltranslation.variableType) {\n newProps.children = handleChildren(props.children as ReactNode);\n }\n if (child.type === React.Fragment) {\n newProps['data-_gt'].transformation = 'fragment';\n }\n return React.cloneElement(child, newProps) as TaggedElement;\n }\n\n function handleSingleChild(child: ReactNode): TaggedChild {\n if (isValidElement(child)) {\n return handleSingleChildElement(\n child as ReactElement<Record<string, unknown>>\n );\n }\n return child;\n }\n\n function handleChildren(children: ReactNode): TaggedChildren {\n if (Array.isArray(children)) {\n return React.Children.map(children, handleSingleChild);\n } else {\n return handleSingleChild(children);\n }\n }\n\n return handleChildren(children);\n}\n"],"mappings":"6GAmBA,SAAgB,EACd,EACA,EAAwB,EACR,CAEhB,IAAI,EAAQ,EAON,EAAe,GAAwD,CAC3E,GAAM,CAAE,OAAM,SAAU,EACxB,GAAS,EACT,IAAM,EAAgB,CAAE,GAAI,EAAO,cAAe,SAAU,CACxD,EACJ,GAAI,CACF,EACE,OAAO,GAAS,WAAc,EAAyB,KAAO,IAAA,QAC1D,EAGR,GAAI,EAAgB,CAClB,IAAM,EAAsB,EAAe,MAAM,IAAI,CAmBrD,IAhBE,EAAoB,KAAO,aAC3B,EAAoB,KAAO,eAE3B,EAAO,cAAgB,aAGrB,EAAoB,KAAO,cAG7B,EAAoB,GAAK,YAEvB,EAAoB,KAAO,aAC7B,EAAO,aACJ,IAAsB,IACvB,YAEA,EAAoB,KAAO,SAAU,CACvC,IAAM,EAAiB,OAAO,QAAQ,EAAM,CAAC,QAC1C,EAAK,CAAC,EAAY,MACb,EAAqB,EAAW,GACjC,EAAuC,GACtC,EAAgB,EAAqB,EAAM,EAExC,GAET,EAAE,CACH,CACG,OAAO,KAAK,EAAe,CAAC,SAC9B,EAAO,SAAW,GAEtB,GAAI,EAAoB,KAAO,SAAU,CACvC,GAAM,CAAE,SAAU,EAAW,OAAQ,EAAS,GAAG,GAAa,EAExD,EAAmB,OAAO,YAC9B,OAAO,QAAQ,EAAS,CAAC,QAAQ,CAAC,KAAS,CAAC,EAAI,WAAW,QAAQ,CAAC,CACrE,CACK,EAAiB,OAAO,QAAQ,EAAiB,CAAC,QACrD,EAAK,CAAC,EAAY,MAChB,EAAuC,GACtC,EAAgB,EAAqB,EAAM,CACtC,GAET,EAAE,CACH,CACG,OAAO,KAAK,EAAe,CAAC,SAC9B,EAAO,SAAW,GAEtB,EAAO,eAAiB,EAAoB,GAE9C,OAAO,GAGT,SAAS,EACP,EACe,CACf,GAAM,CAAE,SAAU,EAGZ,EAA4B,EAAY,EAAM,CAC9C,EAA+B,CACnC,GAAG,EACH,WAAY,EACb,CAOD,OANI,EAAM,UAAY,CAAC,EAAmB,eACxC,EAAS,SAAW,EAAe,EAAM,SAAsB,EAE7D,EAAM,OAAS,EAAM,WACvB,EAAS,YAAY,eAAiB,YAEjC,EAAM,aAAa,EAAO,EAAS,CAG5C,SAAS,EAAkB,EAA+B,CAMxD,OALI,EAAe,EAAM,CAChB,EACL,EACD,CAEI,EAGT,SAAS,EAAe,EAAqC,CAIzD,OAHE,MAAM,QAAQ,EAAS,CAClB,EAAM,SAAS,IAAI,EAAU,EAAkB,CAE/C,EAAkB,EAAS,CAItC,OAAO,EAAe,EAAS"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`generaltranslation/internal`),t=require(`react`);function n(e){return a(e,0)}function r(n,r){let{type:c,props:l}=n,u=o(c);if(typeof l!=`object`||!l)return n;if(u){let{componentType:o,injectionType:c}=u;if(o===`variable`)return n;if(o===`branch`)return(0,t.cloneElement)(n,{...Object.entries(l).reduce((e,[t,n])=>(t!==`branch`&&!t.startsWith(`data-`)?e[t]=i(n,r):e[t]=n,e),{})});if(o===`plural`)return(0,t.cloneElement)(n,{...Object.entries(l).reduce((t,[n,a])=>((0,e.isAcceptedPluralForm)(n)||n===`children`?t[n]=i(a,r):t[n]=a,t),{})});if(o===`derive`)return(0,t.cloneElement)(n,{...l,...`children`in l&&{children:a(l.children,r+1)}});if(o===`translate`&&c===`automatic`&&r>0)return`children`in l?a(l.children,r):void 0;o===`translate`&&c===`automatic`&&console.warn(s)}return(0,t.cloneElement)(n,{...l,...`children`in l&&{children:a(l.children,r)}})}function i(e,n){return(0,t.isValidElement)(e)?r(e,n):e}function a(e,n){return Array.isArray(e)?t.Children.map(e,e=>i(e,n)):i(e,n)}function o(e){let t=typeof e==`function`&&`_gtt`in e?e._gtt:void 0;if(t==null||typeof t!=`string`)return;let n=t.split(`-`);return{componentType:n[0],injectionType:n[1]===`automatic`||n[2]===`automatic`?`automatic`:`manual`}}const s=`'@generaltranslation/react-core Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;exports.removeInjectedT=n;
|
|
2
|
+
//# sourceMappingURL=removeInjectedT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeInjectedT.cjs","names":["Children"],"sources":["../../../src/utils/internal/removeInjectedT.ts"],"sourcesContent":["import { isAcceptedPluralForm } from 'generaltranslation/internal';\nimport { InjectionType, TransformationPrefix } from 'generaltranslation/types';\nimport {\n ReactNode,\n ReactElement,\n isValidElement,\n cloneElement,\n Children,\n} from 'react';\n\n/**\n * Remove injected _T components at runtime. This is only for i18n-context T components to use.\n * This is necessary because when dealing with deriving fragmented content. The compiler will always\n * inject a `_T` component.\n *\n * Only remove if within a `<Derive>` component as this scopes this behavior\n * to only where it can actually appear.\n */\nexport function removeInjectedT(children: ReactNode): ReactNode {\n return handleChildren(children, 0);\n}\n\n// ----- Core Logic ----- //\n\n/**\n * Traverses a single child element and removes the injected _T component.\n * @param child - The child element to traverse.\n * @param derivationDepth - The depth of the derivation.\n * @returns The traversed child element.\n *\n * Derivation depth is used for tracking whether or not to apply the _T removal transformation.\n *\n * Rules:\n * 1. Variable components (Var, Num, Currency, DateTime) - hands off\n * 2. Branching components (Branch, Plural) - explore respective branches\n * 3. Derivation components (Derive) - add/remove derivation depth\n * 4. Translation components (T) - remove _T if within a derivation context\n * 5. Then move on to processing the element's children\n */\nfunction handleSingleChildElement(\n child: ReactElement,\n derivationDepth: number\n): ReactNode {\n const { type: elementType, props: elementProps } = child;\n const transformation = getTransformation(elementType);\n // unlikely edge case: encountered an element with props that cannot be processed\n if (typeof elementProps !== 'object' || elementProps === null) {\n return child;\n }\n\n if (transformation) {\n const { componentType, injectionType } = transformation;\n\n // (1) If the element is a variable component, hands off\n if (componentType === 'variable') {\n return child;\n }\n\n // (2) If the element is a branching component, explore respective branches\n else if (componentType === 'branch') {\n // Traverse into each branch (this also includes the children property)\n const newProps = Object.entries(elementProps).reduce<\n Record<string, unknown>\n >((acc, [branchName, branch]) => {\n if (branchName !== 'branch' && !branchName.startsWith('data-')) {\n acc[branchName] = handleSingleChild(branch, derivationDepth);\n } else {\n // Skip recursion on non-translated branches\n acc[branchName] = branch;\n }\n return acc;\n }, {});\n\n return cloneElement(child, {\n ...newProps,\n });\n } else if (componentType === 'plural') {\n // Traverse into each branch (this also includes the children property)\n const newProps = Object.entries(elementProps).reduce<\n Record<string, unknown>\n >((acc, [branchName, branch]) => {\n if (isAcceptedPluralForm(branchName) || branchName === 'children') {\n acc[branchName] = handleSingleChild(branch, derivationDepth);\n } else {\n // Skip Recursion on non-translated branches\n acc[branchName] = branch;\n }\n return acc;\n }, {});\n\n return cloneElement(child, {\n ...newProps,\n });\n }\n\n // (3) If the element is a derivation component, add/remove derivation depth\n else if (componentType === 'derive') {\n return cloneElement(child, {\n ...elementProps,\n ...('children' in elementProps && {\n children: handleChildren(\n elementProps.children as ReactNode,\n derivationDepth + 1\n ),\n }),\n });\n }\n\n // (4) If the element is a translation component, remove _T if within a derivation context, just return the children\n else if (\n componentType === 'translate' &&\n injectionType === 'automatic' &&\n derivationDepth > 0\n ) {\n return 'children' in elementProps\n ? handleChildren(elementProps.children as ReactNode, derivationDepth)\n : undefined;\n }\n\n // Note: componentType === 'translate': means that there is a <_T> inside of a <T>/<_T>\n else if (componentType === 'translate' && injectionType === 'automatic') {\n console.warn(warnNestedInternalTComponent);\n }\n }\n\n // (5) Recurse into children\n return cloneElement(child, {\n ...elementProps,\n ...('children' in elementProps && {\n children: handleChildren(\n elementProps.children as ReactNode,\n derivationDepth\n ),\n }),\n });\n}\n\n// ----- Traversal ----- //\n\n/**\n * Traverses a single child react node and removes the injected _T component.\n */\nfunction handleSingleChild(\n child: ReactNode,\n derivationDepth: number\n): ReactNode {\n if (isValidElement(child)) {\n return handleSingleChildElement(child, derivationDepth);\n }\n return child;\n}\n\n/**\n * Traverses an array of children and removes the injected _T component.\n *\n */\nfunction handleChildren(\n children: ReactNode,\n derivationDepth: number\n): ReactNode {\n if (Array.isArray(children)) {\n return Children.map(children, (child) =>\n handleSingleChild(child, derivationDepth)\n );\n }\n return handleSingleChild(children, derivationDepth);\n}\n\n// ----- Helper Functions ----- //\n\n/**\n * Extracts the transformation from the element type.\n * @param elementType - The element type to extract the transformation from.\n * @returns The transformation.\n */\nfunction getTransformation(elementType: ReactElement['type']):\n | {\n componentType: TransformationPrefix;\n injectionType: InjectionType;\n }\n | undefined {\n // Extract transformation string\n const transformation =\n typeof elementType === 'function' && '_gtt' in elementType\n ? elementType._gtt\n : undefined;\n if (transformation == null || typeof transformation !== 'string')\n return undefined;\n\n // Extract metadata from transformation string\n const parts = transformation.split('-');\n const componentType = parts[0] as TransformationPrefix;\n const injectionType =\n parts[1] === 'automatic' || parts[2] === 'automatic'\n ? 'automatic'\n : 'manual';\n\n return {\n componentType,\n injectionType,\n };\n}\n\nconst warnNestedInternalTComponent = `'@generaltranslation/react-core Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;\n"],"mappings":"gHAkBA,SAAgB,EAAgB,EAAgC,CAC9D,OAAO,EAAe,EAAU,EAAE,CAoBpC,SAAS,EACP,EACA,EACW,CACX,GAAM,CAAE,KAAM,EAAa,MAAO,GAAiB,EAC7C,EAAiB,EAAkB,EAAY,CAErD,GAAI,OAAO,GAAiB,WAAY,EACtC,OAAO,EAGT,GAAI,EAAgB,CAClB,GAAM,CAAE,gBAAe,iBAAkB,EAGzC,GAAI,IAAkB,WACpB,OAAO,KAIA,IAAkB,SAczB,OAAA,EAAA,EAAA,cAAoB,EAAO,CACzB,GAbe,OAAO,QAAQ,EAAa,CAAC,QAE3C,EAAK,CAAC,EAAY,MACf,IAAe,UAAY,CAAC,EAAW,WAAW,QAAQ,CAC5D,EAAI,GAAc,EAAkB,EAAQ,EAAgB,CAG5D,EAAI,GAAc,EAEb,GACN,EAAE,CAGQ,CACZ,CAAC,IACO,IAAkB,SAc3B,OAAA,EAAA,EAAA,cAAoB,EAAO,CACzB,GAbe,OAAO,QAAQ,EAAa,CAAC,QAE3C,EAAK,CAAC,EAAY,OACnB,EAAA,EAAA,sBAAyB,EAAW,EAAI,IAAe,WACrD,EAAI,GAAc,EAAkB,EAAQ,EAAgB,CAG5D,EAAI,GAAc,EAEb,GACN,EAAE,CAGQ,CACZ,CAAC,IAIK,IAAkB,SACzB,OAAA,EAAA,EAAA,cAAoB,EAAO,CACzB,GAAG,EACH,GAAI,aAAc,GAAgB,CAChC,SAAU,EACR,EAAa,SACb,EAAkB,EACnB,CACF,CACF,CAAC,IAKF,IAAkB,aAClB,IAAkB,aAClB,EAAkB,EAElB,MAAO,aAAc,EACjB,EAAe,EAAa,SAAuB,EAAgB,CACnE,IAAA,GAIG,IAAkB,aAAe,IAAkB,aAC1D,QAAQ,KAAK,EAA6B,CAK9C,OAAA,EAAA,EAAA,cAAoB,EAAO,CACzB,GAAG,EACH,GAAI,aAAc,GAAgB,CAChC,SAAU,EACR,EAAa,SACb,EACD,CACF,CACF,CAAC,CAQJ,SAAS,EACP,EACA,EACW,CAIX,OAHA,EAAA,EAAA,gBAAmB,EAAM,CAChB,EAAyB,EAAO,EAAgB,CAElD,EAOT,SAAS,EACP,EACA,EACW,CAMX,OALI,MAAM,QAAQ,EAAS,CAClBA,EAAAA,SAAS,IAAI,EAAW,GAC7B,EAAkB,EAAO,EAAgB,CAC1C,CAEI,EAAkB,EAAU,EAAgB,CAUrD,SAAS,EAAkB,EAKb,CAEZ,IAAM,EACJ,OAAO,GAAgB,YAAc,SAAU,EAC3C,EAAY,KACZ,IAAA,GACN,GAAI,GAAkB,MAAQ,OAAO,GAAmB,SACtD,OAGF,IAAM,EAAQ,EAAe,MAAM,IAAI,CAOvC,MAAO,CACL,cAPoB,EAAM,GAQ1B,cANA,EAAM,KAAO,aAAe,EAAM,KAAO,YACrC,YACA,SAKL,CAGH,MAAM,EAA+B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{isAcceptedPluralForm as e}from"generaltranslation/internal";import{Children as t,cloneElement as n,isValidElement as r}from"react";function i(e){return s(e,0)}function a(t,r){let{type:i,props:a}=t,u=c(i);if(typeof a!=`object`||!a)return t;if(u){let{componentType:i,injectionType:c}=u;if(i===`variable`)return t;if(i===`branch`)return n(t,{...Object.entries(a).reduce((e,[t,n])=>(t!==`branch`&&!t.startsWith(`data-`)?e[t]=o(n,r):e[t]=n,e),{})});if(i===`plural`)return n(t,{...Object.entries(a).reduce((t,[n,i])=>(e(n)||n===`children`?t[n]=o(i,r):t[n]=i,t),{})});if(i===`derive`)return n(t,{...a,...`children`in a&&{children:s(a.children,r+1)}});if(i===`translate`&&c===`automatic`&&r>0)return`children`in a?s(a.children,r):void 0;i===`translate`&&c===`automatic`&&console.warn(l)}return n(t,{...a,...`children`in a&&{children:s(a.children,r)}})}function o(e,t){return r(e)?a(e,t):e}function s(e,n){return Array.isArray(e)?t.map(e,e=>o(e,n)):o(e,n)}function c(e){let t=typeof e==`function`&&`_gtt`in e?e._gtt:void 0;if(t==null||typeof t!=`string`)return;let n=t.split(`-`);return{componentType:n[0],injectionType:n[1]===`automatic`||n[2]===`automatic`?`automatic`:`manual`}}const l=`'@generaltranslation/react-core Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;export{i as removeInjectedT};
|
|
2
|
+
//# sourceMappingURL=removeInjectedT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeInjectedT.mjs","names":[],"sources":["../../../src/utils/internal/removeInjectedT.ts"],"sourcesContent":["import { isAcceptedPluralForm } from 'generaltranslation/internal';\nimport { InjectionType, TransformationPrefix } from 'generaltranslation/types';\nimport {\n ReactNode,\n ReactElement,\n isValidElement,\n cloneElement,\n Children,\n} from 'react';\n\n/**\n * Remove injected _T components at runtime. This is only for i18n-context T components to use.\n * This is necessary because when dealing with deriving fragmented content. The compiler will always\n * inject a `_T` component.\n *\n * Only remove if within a `<Derive>` component as this scopes this behavior\n * to only where it can actually appear.\n */\nexport function removeInjectedT(children: ReactNode): ReactNode {\n return handleChildren(children, 0);\n}\n\n// ----- Core Logic ----- //\n\n/**\n * Traverses a single child element and removes the injected _T component.\n * @param child - The child element to traverse.\n * @param derivationDepth - The depth of the derivation.\n * @returns The traversed child element.\n *\n * Derivation depth is used for tracking whether or not to apply the _T removal transformation.\n *\n * Rules:\n * 1. Variable components (Var, Num, Currency, DateTime) - hands off\n * 2. Branching components (Branch, Plural) - explore respective branches\n * 3. Derivation components (Derive) - add/remove derivation depth\n * 4. Translation components (T) - remove _T if within a derivation context\n * 5. Then move on to processing the element's children\n */\nfunction handleSingleChildElement(\n child: ReactElement,\n derivationDepth: number\n): ReactNode {\n const { type: elementType, props: elementProps } = child;\n const transformation = getTransformation(elementType);\n // unlikely edge case: encountered an element with props that cannot be processed\n if (typeof elementProps !== 'object' || elementProps === null) {\n return child;\n }\n\n if (transformation) {\n const { componentType, injectionType } = transformation;\n\n // (1) If the element is a variable component, hands off\n if (componentType === 'variable') {\n return child;\n }\n\n // (2) If the element is a branching component, explore respective branches\n else if (componentType === 'branch') {\n // Traverse into each branch (this also includes the children property)\n const newProps = Object.entries(elementProps).reduce<\n Record<string, unknown>\n >((acc, [branchName, branch]) => {\n if (branchName !== 'branch' && !branchName.startsWith('data-')) {\n acc[branchName] = handleSingleChild(branch, derivationDepth);\n } else {\n // Skip recursion on non-translated branches\n acc[branchName] = branch;\n }\n return acc;\n }, {});\n\n return cloneElement(child, {\n ...newProps,\n });\n } else if (componentType === 'plural') {\n // Traverse into each branch (this also includes the children property)\n const newProps = Object.entries(elementProps).reduce<\n Record<string, unknown>\n >((acc, [branchName, branch]) => {\n if (isAcceptedPluralForm(branchName) || branchName === 'children') {\n acc[branchName] = handleSingleChild(branch, derivationDepth);\n } else {\n // Skip Recursion on non-translated branches\n acc[branchName] = branch;\n }\n return acc;\n }, {});\n\n return cloneElement(child, {\n ...newProps,\n });\n }\n\n // (3) If the element is a derivation component, add/remove derivation depth\n else if (componentType === 'derive') {\n return cloneElement(child, {\n ...elementProps,\n ...('children' in elementProps && {\n children: handleChildren(\n elementProps.children as ReactNode,\n derivationDepth + 1\n ),\n }),\n });\n }\n\n // (4) If the element is a translation component, remove _T if within a derivation context, just return the children\n else if (\n componentType === 'translate' &&\n injectionType === 'automatic' &&\n derivationDepth > 0\n ) {\n return 'children' in elementProps\n ? handleChildren(elementProps.children as ReactNode, derivationDepth)\n : undefined;\n }\n\n // Note: componentType === 'translate': means that there is a <_T> inside of a <T>/<_T>\n else if (componentType === 'translate' && injectionType === 'automatic') {\n console.warn(warnNestedInternalTComponent);\n }\n }\n\n // (5) Recurse into children\n return cloneElement(child, {\n ...elementProps,\n ...('children' in elementProps && {\n children: handleChildren(\n elementProps.children as ReactNode,\n derivationDepth\n ),\n }),\n });\n}\n\n// ----- Traversal ----- //\n\n/**\n * Traverses a single child react node and removes the injected _T component.\n */\nfunction handleSingleChild(\n child: ReactNode,\n derivationDepth: number\n): ReactNode {\n if (isValidElement(child)) {\n return handleSingleChildElement(child, derivationDepth);\n }\n return child;\n}\n\n/**\n * Traverses an array of children and removes the injected _T component.\n *\n */\nfunction handleChildren(\n children: ReactNode,\n derivationDepth: number\n): ReactNode {\n if (Array.isArray(children)) {\n return Children.map(children, (child) =>\n handleSingleChild(child, derivationDepth)\n );\n }\n return handleSingleChild(children, derivationDepth);\n}\n\n// ----- Helper Functions ----- //\n\n/**\n * Extracts the transformation from the element type.\n * @param elementType - The element type to extract the transformation from.\n * @returns The transformation.\n */\nfunction getTransformation(elementType: ReactElement['type']):\n | {\n componentType: TransformationPrefix;\n injectionType: InjectionType;\n }\n | undefined {\n // Extract transformation string\n const transformation =\n typeof elementType === 'function' && '_gtt' in elementType\n ? elementType._gtt\n : undefined;\n if (transformation == null || typeof transformation !== 'string')\n return undefined;\n\n // Extract metadata from transformation string\n const parts = transformation.split('-');\n const componentType = parts[0] as TransformationPrefix;\n const injectionType =\n parts[1] === 'automatic' || parts[2] === 'automatic'\n ? 'automatic'\n : 'manual';\n\n return {\n componentType,\n injectionType,\n };\n}\n\nconst warnNestedInternalTComponent = `'@generaltranslation/react-core Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;\n"],"mappings":"0IAkBA,SAAgB,EAAgB,EAAgC,CAC9D,OAAO,EAAe,EAAU,EAAE,CAoBpC,SAAS,EACP,EACA,EACW,CACX,GAAM,CAAE,KAAM,EAAa,MAAO,GAAiB,EAC7C,EAAiB,EAAkB,EAAY,CAErD,GAAI,OAAO,GAAiB,WAAY,EACtC,OAAO,EAGT,GAAI,EAAgB,CAClB,GAAM,CAAE,gBAAe,iBAAkB,EAGzC,GAAI,IAAkB,WACpB,OAAO,KAIA,IAAkB,SAczB,OAAO,EAAa,EAAO,CACzB,GAbe,OAAO,QAAQ,EAAa,CAAC,QAE3C,EAAK,CAAC,EAAY,MACf,IAAe,UAAY,CAAC,EAAW,WAAW,QAAQ,CAC5D,EAAI,GAAc,EAAkB,EAAQ,EAAgB,CAG5D,EAAI,GAAc,EAEb,GACN,EAAE,CAGQ,CACZ,CAAC,IACO,IAAkB,SAc3B,OAAO,EAAa,EAAO,CACzB,GAbe,OAAO,QAAQ,EAAa,CAAC,QAE3C,EAAK,CAAC,EAAY,MACf,EAAqB,EAAW,EAAI,IAAe,WACrD,EAAI,GAAc,EAAkB,EAAQ,EAAgB,CAG5D,EAAI,GAAc,EAEb,GACN,EAAE,CAGQ,CACZ,CAAC,IAIK,IAAkB,SACzB,OAAO,EAAa,EAAO,CACzB,GAAG,EACH,GAAI,aAAc,GAAgB,CAChC,SAAU,EACR,EAAa,SACb,EAAkB,EACnB,CACF,CACF,CAAC,IAKF,IAAkB,aAClB,IAAkB,aAClB,EAAkB,EAElB,MAAO,aAAc,EACjB,EAAe,EAAa,SAAuB,EAAgB,CACnE,IAAA,GAIG,IAAkB,aAAe,IAAkB,aAC1D,QAAQ,KAAK,EAA6B,CAK9C,OAAO,EAAa,EAAO,CACzB,GAAG,EACH,GAAI,aAAc,GAAgB,CAChC,SAAU,EACR,EAAa,SACb,EACD,CACF,CACF,CAAC,CAQJ,SAAS,EACP,EACA,EACW,CAIX,OAHI,EAAe,EAAM,CAChB,EAAyB,EAAO,EAAgB,CAElD,EAOT,SAAS,EACP,EACA,EACW,CAMX,OALI,MAAM,QAAQ,EAAS,CAClB,EAAS,IAAI,EAAW,GAC7B,EAAkB,EAAO,EAAgB,CAC1C,CAEI,EAAkB,EAAU,EAAgB,CAUrD,SAAS,EAAkB,EAKb,CAEZ,IAAM,EACJ,OAAO,GAAgB,YAAc,SAAU,EAC3C,EAAY,KACZ,IAAA,GACN,GAAI,GAAkB,MAAQ,OAAO,GAAmB,SACtD,OAGF,IAAM,EAAQ,EAAe,MAAM,IAAI,CAOvC,MAAO,CACL,cAPoB,EAAM,GAQ1B,cANA,EAAM,KAAO,aAAe,EAAM,KAAO,YACrC,YACA,SAKL,CAGH,MAAM,EAA+B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../variables/getVariableName.cjs`),t=require(`../utils.cjs`);let n=require(`generaltranslation/internal`),r=require(`@generaltranslation/format/types`);const i=e=>{if(!e)return``;let{type:t,props:n}=e;if(t&&typeof t==`function`){if(`displayName`in t&&typeof t.displayName==`string`&&t.displayName)return t.displayName;if(`name`in t&&typeof t.name==`string`&&t.name)return t.name}return t&&typeof t==`string`?t:n.href?`a`:n[`data-_gt`]?.id?`C${n[`data-_gt`].id}`:`function`},a=(e,t,n)=>{let i=Object.entries(r.HTML_CONTENT_PROPS).reduce((e,[n,r])=>{let i=t[r];return typeof i==`string`&&(e[n]=i),e},{});if(e===`plural`&&n){let e={};Object.entries(n).forEach(([t,n])=>{e[t]=c(n)}),i={...i,b:e,t:`p`}}if(e===`branch`&&n){let e={};Object.entries(n).forEach(([t,n])=>{e[t]=c(n)}),i={...i,b:e,t:`b`}}return Object.keys(i).length?i:void 0},o=t=>{let{props:o}=t,s={t:i(t)};if(o[`data-_gt`]){let t=o[`data-_gt`],i=t.transformation;if(i===`variable`){let r=t.variableType||`variable`,i=e.getVariableName(o,r),a=(0,n.minifyVariableType)(r);return{i:t.id,k:i,v:a}}s.i=t.id,s.d=a(i,o,t.branches);let l=Object.entries(r.HTML_CONTENT_PROPS).reduce((e,[t,n])=>{let r=o[n];return typeof r==`string`&&(e[t]=r),e},{});if(i===`plural`&&t.branches){let e={};Object.entries(t.branches).forEach(([t,n])=>{e[t]=c(n)}),l={...l,b:e,t:`p`}}if(i===`branch`&&t.branches){let e={};Object.entries(t.branches).forEach(([t,n])=>{e[t]=c(n)}),l={...l,b:e,t:`b`}}s.d=Object.keys(l).length?l:void 0}return o.children&&(s.c=c(o.children)),s},s=e=>t.isValidTaggedElement(e)?o(e):typeof e==`number`?e.toString():e;function c(e){return Array.isArray(e)?e.map(s):s(e)}exports.writeChildrenAsObjects=c;
|
|
2
|
+
//# sourceMappingURL=writeChildrenAsObjects.cjs.map
|