gt-react-native 10.20.4 → 11.0.0-odysseus.1
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/README.md +26 -3
- package/dist/commonjs/condition-store/NativeConditionStore.js +80 -0
- package/dist/commonjs/condition-store/NativeConditionStore.js.map +1 -0
- package/dist/commonjs/hooks/condition-store.js +38 -0
- package/dist/commonjs/hooks/condition-store.js.map +1 -0
- package/dist/commonjs/hooks/selectors.js +23 -0
- package/dist/commonjs/hooks/selectors.js.map +1 -0
- package/dist/commonjs/hooks/utils.js +17 -0
- package/dist/commonjs/hooks/utils.js.map +1 -0
- package/dist/commonjs/index.js +221 -32
- package/dist/commonjs/provider/GTProvider.js +64 -15
- package/dist/commonjs/provider/GTProvider.js.map +1 -1
- package/dist/commonjs/provider/NativeGTProvider.js +31 -0
- package/dist/commonjs/provider/NativeGTProvider.js.map +1 -0
- package/dist/commonjs/provider/loadTranslations.js +27 -0
- package/dist/commonjs/provider/loadTranslations.js.map +1 -0
- package/dist/commonjs/setup/initializeGT.js +14 -0
- package/dist/commonjs/setup/initializeGT.js.map +1 -0
- package/dist/commonjs/utils/getInitialNativeConditions.js +20 -0
- package/dist/commonjs/utils/getInitialNativeConditions.js.map +1 -0
- package/dist/commonjs/utils/getLocale.js +28 -0
- package/dist/commonjs/utils/getLocale.js.map +1 -0
- package/dist/commonjs/utils/nativeStore.js +3 -3
- package/dist/commonjs/utils/nativeStore.js.map +1 -1
- package/dist/commonjs/utils/resolveLocale.js +12 -0
- package/dist/commonjs/utils/resolveLocale.js.map +1 -0
- package/dist/commonjs/utils/utils.js.map +1 -1
- package/dist/module/condition-store/NativeConditionStore.d.ts +35 -0
- package/dist/module/condition-store/NativeConditionStore.d.ts.map +1 -0
- package/dist/module/condition-store/NativeConditionStore.js +78 -0
- package/dist/module/condition-store/NativeConditionStore.js.map +1 -0
- package/dist/module/hooks/condition-store.d.ts +13 -0
- package/dist/module/hooks/condition-store.d.ts.map +1 -0
- package/dist/module/hooks/condition-store.js +34 -0
- package/dist/module/hooks/condition-store.js.map +1 -0
- package/dist/module/hooks/selectors.d.ts +39 -0
- package/dist/module/hooks/selectors.d.ts.map +1 -0
- package/dist/module/hooks/selectors.js +20 -0
- package/dist/module/hooks/selectors.js.map +1 -0
- package/dist/module/hooks/utils.d.ts +3 -0
- package/dist/module/hooks/utils.d.ts.map +1 -0
- package/dist/module/hooks/utils.js +14 -0
- package/dist/module/hooks/utils.js.map +1 -0
- package/dist/module/index.d.ts +16 -3
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +9 -2
- package/dist/module/provider/GTProvider.d.ts +10 -3
- package/dist/module/provider/GTProvider.d.ts.map +1 -1
- package/dist/module/provider/GTProvider.js +64 -11
- package/dist/module/provider/GTProvider.js.map +1 -1
- package/dist/module/provider/NativeGTProvider.d.ts +8 -0
- package/dist/module/provider/NativeGTProvider.d.ts.map +1 -0
- package/dist/module/provider/NativeGTProvider.js +29 -0
- package/dist/module/provider/NativeGTProvider.js.map +1 -0
- package/dist/module/provider/loadTranslations.d.ts +5 -0
- package/dist/module/provider/loadTranslations.d.ts.map +1 -0
- package/dist/module/provider/loadTranslations.js +25 -0
- package/dist/module/provider/loadTranslations.js.map +1 -0
- package/dist/module/setup/initializeGT.d.ts +5 -0
- package/dist/module/setup/initializeGT.d.ts.map +1 -0
- package/dist/module/setup/initializeGT.js +12 -0
- package/dist/module/setup/initializeGT.js.map +1 -0
- package/dist/module/utils/getInitialNativeConditions.d.ts +11 -0
- package/dist/module/utils/getInitialNativeConditions.d.ts.map +1 -0
- package/dist/module/utils/getInitialNativeConditions.js +17 -0
- package/dist/module/utils/getInitialNativeConditions.js.map +1 -0
- package/dist/module/utils/getLocale.d.ts +8 -0
- package/dist/module/utils/getLocale.d.ts.map +1 -0
- package/dist/module/utils/getLocale.js +26 -0
- package/dist/module/utils/getLocale.js.map +1 -0
- package/dist/module/utils/nativeStore.d.ts +1 -1
- package/dist/module/utils/nativeStore.d.ts.map +1 -1
- package/dist/module/utils/nativeStore.js +2 -2
- package/dist/module/utils/nativeStore.js.map +1 -1
- package/dist/module/utils/resolveLocale.d.ts +3 -0
- package/dist/module/utils/resolveLocale.d.ts.map +1 -0
- package/dist/module/utils/resolveLocale.js +10 -0
- package/dist/module/utils/resolveLocale.js.map +1 -0
- package/dist/module/utils/utils.d.ts +1 -1
- package/dist/module/utils/utils.d.ts.map +1 -1
- package/dist/module/utils/utils.js.map +1 -1
- package/package.json +8 -7
- package/src/condition-store/NativeConditionStore.ts +128 -0
- package/src/hooks/condition-store.ts +41 -0
- package/src/hooks/selectors.ts +17 -0
- package/src/hooks/utils.ts +14 -0
- package/src/index.tsx +74 -56
- package/src/provider/GTProvider.tsx +103 -13
- package/src/provider/NativeGTProvider.tsx +44 -0
- package/src/provider/loadTranslations.ts +34 -0
- package/src/setup/initializeGT.ts +23 -0
- package/src/utils/getInitialNativeConditions.ts +35 -0
- package/src/utils/getLocale.ts +34 -0
- package/src/utils/nativeStore.ts +3 -3
- package/src/utils/resolveLocale.ts +10 -0
- package/src/utils/utils.ts +1 -1
- package/dist/commonjs/provider/hooks/locale/useDetermineLocale.js +0 -102
- package/dist/commonjs/provider/hooks/locale/useDetermineLocale.js.map +0 -1
- package/dist/commonjs/provider/hooks/useRegionState.js +0 -35
- package/dist/commonjs/provider/hooks/useRegionState.js.map +0 -1
- package/dist/commonjs/types/config.js +0 -1
- package/dist/module/provider/hooks/locale/useDetermineLocale.d.ts +0 -4
- package/dist/module/provider/hooks/locale/useDetermineLocale.d.ts.map +0 -1
- package/dist/module/provider/hooks/locale/useDetermineLocale.js +0 -100
- package/dist/module/provider/hooks/locale/useDetermineLocale.js.map +0 -1
- package/dist/module/provider/hooks/useRegionState.d.ts +0 -3
- package/dist/module/provider/hooks/useRegionState.d.ts.map +0 -1
- package/dist/module/provider/hooks/useRegionState.js +0 -33
- package/dist/module/provider/hooks/useRegionState.js.map +0 -1
- package/dist/module/types/config.d.ts +0 -30
- package/dist/module/types/config.d.ts.map +0 -1
- package/dist/module/types/config.js +0 -1
- package/src/provider/hooks/locale/useDetermineLocale.ts +0 -220
- package/src/provider/hooks/useRegionState.ts +0 -51
- package/src/types/config.ts +0 -36
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useSetLocale, useSetRegion } from './condition-store';
|
|
2
|
+
import {
|
|
3
|
+
useInternalLocaleSelector,
|
|
4
|
+
useInternalRegionSelector,
|
|
5
|
+
} from '@generaltranslation/react-core/hooks';
|
|
6
|
+
import type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';
|
|
7
|
+
|
|
8
|
+
export function useLocaleSelector(locales?: string[]) {
|
|
9
|
+
const setLocale = useSetLocale();
|
|
10
|
+
return { setLocale, ...useInternalLocaleSelector(locales) };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useRegionSelector(options?: InternalRegionSelectorOptions) {
|
|
14
|
+
const setLocale = useSetLocale();
|
|
15
|
+
const setRegion = useSetRegion();
|
|
16
|
+
return { setLocale, setRegion, ...useInternalRegionSelector(options) };
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getVersionId } from '@generaltranslation/react-core/pure';
|
|
2
|
+
import {
|
|
3
|
+
useLocale,
|
|
4
|
+
useLocaleDirection as useCoreLocaleDirection,
|
|
5
|
+
} from '@generaltranslation/react-core/hooks';
|
|
6
|
+
|
|
7
|
+
export function useLocaleDirection(locale?: string): 'ltr' | 'rtl' {
|
|
8
|
+
const currentLocale = useLocale();
|
|
9
|
+
return useCoreLocaleDirection(locale ?? currentLocale);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useVersionId(): string | undefined {
|
|
13
|
+
return getVersionId();
|
|
14
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -1,80 +1,98 @@
|
|
|
1
1
|
import { GTProvider } from './provider/GTProvider';
|
|
2
|
+
import {
|
|
3
|
+
useSetLocale,
|
|
4
|
+
useSetRegion,
|
|
5
|
+
useSetEnableI18n,
|
|
6
|
+
} from './hooks/condition-store';
|
|
7
|
+
import { useLocaleSelector, useRegionSelector } from './hooks/selectors';
|
|
8
|
+
import { useLocaleDirection, useVersionId } from './hooks/utils';
|
|
2
9
|
import { getLocaleFromNativeStore } from './utils/nativeStore';
|
|
10
|
+
import { getLocale } from './utils/getLocale';
|
|
11
|
+
import { initializeGT } from './setup/initializeGT';
|
|
12
|
+
import type { GTProviderProps } from './provider/GTProvider';
|
|
13
|
+
import type { GetLocaleParams } from './utils/getLocale';
|
|
14
|
+
import type { InitializeGTParams } from './setup/initializeGT';
|
|
3
15
|
|
|
4
|
-
import {
|
|
16
|
+
import type {
|
|
17
|
+
DictionaryTranslationOptions,
|
|
18
|
+
InlineTranslationOptions,
|
|
19
|
+
RuntimeTranslationOptions,
|
|
20
|
+
} from '@generaltranslation/react-core/pure';
|
|
21
|
+
import type {
|
|
22
|
+
RenderPipeline,
|
|
23
|
+
RenderPreparedT,
|
|
24
|
+
} from '@generaltranslation/react-core/pure';
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
// ===== Components ===== //
|
|
28
|
+
Branch,
|
|
29
|
+
Plural,
|
|
30
|
+
Derive,
|
|
5
31
|
T,
|
|
6
|
-
useGT,
|
|
7
|
-
useTranslations,
|
|
8
|
-
useDefaultLocale,
|
|
9
|
-
useLocale,
|
|
10
|
-
useRegion,
|
|
11
|
-
Var,
|
|
12
|
-
Num,
|
|
13
32
|
Currency,
|
|
14
33
|
DateTime,
|
|
15
34
|
RelativeTime,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
35
|
+
Var,
|
|
36
|
+
Num,
|
|
37
|
+
} from '@generaltranslation/react-core/components';
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
// ===== Hooks ===== //
|
|
41
|
+
useLocale,
|
|
42
|
+
useCustomMapping,
|
|
43
|
+
useDefaultLocale,
|
|
44
|
+
useEnableI18n,
|
|
20
45
|
useLocales,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
useGTClass,
|
|
24
|
-
useLocaleProperties,
|
|
25
|
-
useRegionSelector,
|
|
26
|
-
useLocaleDirection,
|
|
46
|
+
useFormatLocales,
|
|
47
|
+
useGT,
|
|
27
48
|
useMessages,
|
|
49
|
+
useTranslations,
|
|
50
|
+
} from '@generaltranslation/react-core/hooks';
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
// ===== Functions ===== //
|
|
28
54
|
msg,
|
|
29
55
|
decodeMsg,
|
|
30
56
|
decodeOptions,
|
|
31
|
-
|
|
32
|
-
mFallback,
|
|
33
|
-
declareStatic,
|
|
57
|
+
derive,
|
|
34
58
|
declareVar,
|
|
35
59
|
decodeVars,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
mFallback,
|
|
61
|
+
gtFallback,
|
|
62
|
+
getFormatLocales,
|
|
63
|
+
getTranslationsSnapshot,
|
|
64
|
+
getReactI18nCache,
|
|
65
|
+
setReactI18nCache,
|
|
66
|
+
createRenderPipeline,
|
|
67
|
+
} from '@generaltranslation/react-core/pure';
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
useRegion,
|
|
71
|
+
useGTClass,
|
|
72
|
+
useLocaleProperties,
|
|
73
|
+
} from '@generaltranslation/react-core/hooks';
|
|
42
74
|
|
|
43
75
|
export {
|
|
44
|
-
Static,
|
|
45
|
-
Var,
|
|
46
|
-
Num,
|
|
47
|
-
Currency,
|
|
48
|
-
DateTime,
|
|
49
|
-
RelativeTime,
|
|
50
|
-
T,
|
|
51
76
|
GTProvider,
|
|
52
|
-
Plural,
|
|
53
|
-
Branch,
|
|
54
|
-
useGT,
|
|
55
|
-
useTranslations,
|
|
56
|
-
useDefaultLocale,
|
|
57
|
-
useLocale,
|
|
58
|
-
useLocales,
|
|
59
77
|
useSetLocale,
|
|
78
|
+
useSetRegion,
|
|
79
|
+
useSetEnableI18n,
|
|
60
80
|
useLocaleSelector,
|
|
61
|
-
useRegion,
|
|
62
81
|
useRegionSelector,
|
|
63
|
-
useGTClass,
|
|
64
|
-
useLocaleProperties,
|
|
65
82
|
useLocaleDirection,
|
|
66
83
|
useVersionId,
|
|
67
84
|
getLocaleFromNativeStore,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
getLocale,
|
|
86
|
+
initializeGT,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type {
|
|
90
|
+
DictionaryTranslationOptions,
|
|
91
|
+
InlineTranslationOptions,
|
|
92
|
+
RuntimeTranslationOptions,
|
|
93
|
+
RenderPipeline,
|
|
94
|
+
RenderPreparedT,
|
|
95
|
+
GTProviderProps,
|
|
96
|
+
GetLocaleParams,
|
|
97
|
+
InitializeGTParams,
|
|
80
98
|
};
|
|
@@ -1,20 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { InternalGTProviderProps } from '@generaltranslation/react-core/components';
|
|
2
|
+
import { Suspense, use, useCallback, useMemo, useState } from 'react';
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
import { ActivityIndicator, StyleSheet, View } from 'react-native';
|
|
5
|
+
import type { LocaleCandidates, Locale } from 'gt-i18n/internal/types';
|
|
6
|
+
import type {
|
|
7
|
+
NativeConditionStoreParams,
|
|
8
|
+
NativeConditionStoreState,
|
|
9
|
+
} from '../condition-store/NativeConditionStore';
|
|
10
|
+
import { getLocale } from '../utils/getLocale';
|
|
11
|
+
import {
|
|
12
|
+
getInitialEnableI18n,
|
|
13
|
+
getInitialRegion,
|
|
14
|
+
} from '../utils/getInitialNativeConditions';
|
|
15
|
+
import { resolveLocale } from '../utils/resolveLocale';
|
|
16
|
+
import { loadTranslations, type LocaleTranslations } from './loadTranslations';
|
|
17
|
+
import { NativeGTProvider } from './NativeGTProvider';
|
|
18
|
+
|
|
19
|
+
export type GTProviderProps = Omit<
|
|
20
|
+
InternalGTProviderProps,
|
|
21
|
+
'conditionStore' | 'i18nStore' | 'translations'
|
|
22
|
+
> &
|
|
23
|
+
Omit<NativeConditionStoreParams, 'locale' | '_reload'> & {
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
locale?: LocaleCandidates;
|
|
26
|
+
loadingFallback?: ReactNode;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type LoadableGTProviderProps = Omit<GTProviderProps, 'loadingFallback'>;
|
|
30
|
+
type TranslationSnapshot = Record<Locale, LocaleTranslations>;
|
|
31
|
+
|
|
32
|
+
export function GTProvider(props: GTProviderProps) {
|
|
33
|
+
const { loadingFallback, ...providerProps } = props;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Suspense fallback={loadingFallback ?? <DefaultLoadingFallback />}>
|
|
37
|
+
<LoadableGTProvider {...providerProps} />
|
|
38
|
+
</Suspense>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* This wrapper takes the place of a loader that would be present in
|
|
44
|
+
* SSR style applications.
|
|
45
|
+
*/
|
|
46
|
+
function LoadableGTProvider(props: LoadableGTProviderProps) {
|
|
47
|
+
const {
|
|
48
|
+
locale,
|
|
49
|
+
localeStoreKey,
|
|
50
|
+
region,
|
|
51
|
+
regionStoreKey,
|
|
52
|
+
enableI18n,
|
|
53
|
+
enableI18nStoreKey,
|
|
54
|
+
} = props;
|
|
55
|
+
// Keep native conditions in React state so condition-store writes trigger rerenders.
|
|
56
|
+
const [nativeConditions, setNativeConditions] =
|
|
57
|
+
useState<NativeConditionStoreState>(() => ({
|
|
58
|
+
locale: getLocale({ localeStoreKey }),
|
|
59
|
+
region: getInitialRegion({ region, regionStoreKey }),
|
|
60
|
+
enableI18n: getInitialEnableI18n({ enableI18n, enableI18nStoreKey }),
|
|
61
|
+
}));
|
|
62
|
+
const activeLocale = resolveLocale(locale ?? nativeConditions.locale);
|
|
63
|
+
const activeRegion = region ?? nativeConditions.region;
|
|
64
|
+
const activeEnableI18n = enableI18n ?? nativeConditions.enableI18n;
|
|
65
|
+
const localeTranslations = use(loadTranslations(activeLocale));
|
|
66
|
+
const translations = useMemo<TranslationSnapshot>(
|
|
67
|
+
() => ({ [activeLocale]: localeTranslations }),
|
|
68
|
+
[activeLocale, localeTranslations]
|
|
69
|
+
);
|
|
70
|
+
const reload = useCallback(
|
|
71
|
+
(state: NativeConditionStoreState) => {
|
|
72
|
+
setNativeConditions((previousState) => ({
|
|
73
|
+
locale: locale === undefined ? state.locale : previousState.locale,
|
|
74
|
+
region: region === undefined ? state.region : previousState.region,
|
|
75
|
+
enableI18n:
|
|
76
|
+
enableI18n === undefined
|
|
77
|
+
? state.enableI18n
|
|
78
|
+
: previousState.enableI18n,
|
|
79
|
+
}));
|
|
80
|
+
},
|
|
81
|
+
[enableI18n, locale, region]
|
|
82
|
+
);
|
|
6
83
|
|
|
7
|
-
export function GTProvider(props: GTProviderProps): React.JSX.Element {
|
|
8
84
|
return (
|
|
9
|
-
<
|
|
10
|
-
ssr={false}
|
|
11
|
-
environment={__DEV__ ? 'development' : 'production'}
|
|
85
|
+
<NativeGTProvider
|
|
12
86
|
{...props}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
87
|
+
locale={activeLocale}
|
|
88
|
+
region={activeRegion}
|
|
89
|
+
enableI18n={activeEnableI18n}
|
|
90
|
+
translations={translations}
|
|
91
|
+
_reload={reload}
|
|
16
92
|
/>
|
|
17
93
|
);
|
|
18
94
|
}
|
|
19
95
|
|
|
20
|
-
|
|
96
|
+
function DefaultLoadingFallback() {
|
|
97
|
+
return (
|
|
98
|
+
<View style={styles.loadingContainer}>
|
|
99
|
+
<ActivityIndicator />
|
|
100
|
+
</View>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const styles = StyleSheet.create({
|
|
105
|
+
loadingContainer: {
|
|
106
|
+
flex: 1,
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
justifyContent: 'center',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
I18nStore,
|
|
3
|
+
InternalGTProvider,
|
|
4
|
+
type InternalGTProviderProps,
|
|
5
|
+
} from '@generaltranslation/react-core/components';
|
|
6
|
+
import { useMemo, useRef } from 'react';
|
|
7
|
+
import type { LocaleCandidates } from 'gt-i18n/internal/types';
|
|
8
|
+
import type { NativeConditionStoreParams } from '../condition-store/NativeConditionStore';
|
|
9
|
+
import { NativeConditionStore } from '../condition-store/NativeConditionStore';
|
|
10
|
+
|
|
11
|
+
export type NativeGTProviderProps = Omit<
|
|
12
|
+
InternalGTProviderProps,
|
|
13
|
+
'conditionStore' | 'i18nStore'
|
|
14
|
+
> &
|
|
15
|
+
Omit<NativeConditionStoreParams, 'locale'> & {
|
|
16
|
+
locale: LocaleCandidates;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function NativeGTProvider(props: NativeGTProviderProps) {
|
|
20
|
+
const conditionStore = useMemo(() => {
|
|
21
|
+
return new NativeConditionStore(props);
|
|
22
|
+
}, [
|
|
23
|
+
props.locale,
|
|
24
|
+
props.region,
|
|
25
|
+
props.enableI18n,
|
|
26
|
+
props.localeStoreKey,
|
|
27
|
+
props.regionStoreKey,
|
|
28
|
+
props.enableI18nStoreKey,
|
|
29
|
+
props._reload,
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
const i18nStoreRef = useRef<I18nStore | null>(null);
|
|
33
|
+
if (i18nStoreRef.current == null) {
|
|
34
|
+
i18nStoreRef.current = new I18nStore();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<InternalGTProvider
|
|
39
|
+
{...props}
|
|
40
|
+
conditionStore={conditionStore}
|
|
41
|
+
i18nStore={i18nStoreRef.current}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getReactI18nCache } from '@generaltranslation/react-core/pure';
|
|
2
|
+
import type { Hash } from 'gt-i18n/internal/types';
|
|
3
|
+
import type { Translation } from 'gt-i18n/types';
|
|
4
|
+
|
|
5
|
+
export type LocaleTranslations = Record<Hash, Translation>;
|
|
6
|
+
|
|
7
|
+
const translationPromises = new WeakMap<
|
|
8
|
+
object,
|
|
9
|
+
Map<string, Promise<LocaleTranslations>>
|
|
10
|
+
>();
|
|
11
|
+
|
|
12
|
+
export function loadTranslations(locale: string): Promise<LocaleTranslations> {
|
|
13
|
+
const i18nCache = getReactI18nCache();
|
|
14
|
+
let i18nCacheTranslationPromises = translationPromises.get(i18nCache);
|
|
15
|
+
if (i18nCacheTranslationPromises == null) {
|
|
16
|
+
i18nCacheTranslationPromises = new Map();
|
|
17
|
+
translationPromises.set(i18nCache, i18nCacheTranslationPromises);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let promise = i18nCacheTranslationPromises.get(locale);
|
|
21
|
+
if (promise == null) {
|
|
22
|
+
// TODO: Support promise caching in i18nCache in a separate PR.
|
|
23
|
+
promise = i18nCache.loadTranslations(locale).catch((error: unknown) => {
|
|
24
|
+
i18nCacheTranslationPromises.delete(locale);
|
|
25
|
+
console.warn(
|
|
26
|
+
`Failed to load translations for locale "${locale}". Falling back to an empty translation snapshot.`,
|
|
27
|
+
error
|
|
28
|
+
);
|
|
29
|
+
return {};
|
|
30
|
+
});
|
|
31
|
+
i18nCacheTranslationPromises.set(locale, promise);
|
|
32
|
+
}
|
|
33
|
+
return promise;
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
initializeI18nConfig,
|
|
3
|
+
setReactI18nCache,
|
|
4
|
+
} from '@generaltranslation/react-core/pure';
|
|
5
|
+
import { ReactI18nCache } from '@generaltranslation/react-core/pure';
|
|
6
|
+
import type { ReactI18nCacheParams } from '@generaltranslation/react-core/pure';
|
|
7
|
+
import { setupGTServicesEnabled } from 'gt-i18n/internal';
|
|
8
|
+
import type {
|
|
9
|
+
GTServicesEnabledParams,
|
|
10
|
+
I18nConfigParams,
|
|
11
|
+
} from 'gt-i18n/internal/types';
|
|
12
|
+
|
|
13
|
+
export type InitializeGTParams = I18nConfigParams &
|
|
14
|
+
GTServicesEnabledParams &
|
|
15
|
+
ReactI18nCacheParams;
|
|
16
|
+
|
|
17
|
+
export function initializeGT(config: InitializeGTParams): void {
|
|
18
|
+
setupGTServicesEnabled(config);
|
|
19
|
+
initializeI18nConfig(config, 'server-render');
|
|
20
|
+
|
|
21
|
+
const i18nCache = new ReactI18nCache(config);
|
|
22
|
+
setReactI18nCache(i18nCache);
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { WritableConditionStoreParams } from 'gt-i18n/internal/types';
|
|
2
|
+
import {
|
|
3
|
+
defaultEnableI18nCookieName as defaultEnableI18nStoreKey,
|
|
4
|
+
defaultRegionCookieName as defaultRegionStoreKey,
|
|
5
|
+
} from '@generaltranslation/react-core/pure';
|
|
6
|
+
import { nativeStoreGet } from './nativeStore';
|
|
7
|
+
|
|
8
|
+
type InitialRegionParams = Pick<WritableConditionStoreParams, 'region'> & {
|
|
9
|
+
regionStoreKey?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type InitialEnableI18nParams = Pick<
|
|
13
|
+
WritableConditionStoreParams,
|
|
14
|
+
'enableI18n'
|
|
15
|
+
> & {
|
|
16
|
+
enableI18nStoreKey?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function getInitialRegion({
|
|
20
|
+
region,
|
|
21
|
+
regionStoreKey = defaultRegionStoreKey,
|
|
22
|
+
}: InitialRegionParams): string | undefined {
|
|
23
|
+
if (region !== undefined) return region;
|
|
24
|
+
return nativeStoreGet(regionStoreKey) || undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getInitialEnableI18n({
|
|
28
|
+
enableI18n,
|
|
29
|
+
enableI18nStoreKey = defaultEnableI18nStoreKey,
|
|
30
|
+
}: InitialEnableI18nParams): boolean {
|
|
31
|
+
if (enableI18n !== undefined) return enableI18n;
|
|
32
|
+
const storedEnableI18n = nativeStoreGet(enableI18nStoreKey);
|
|
33
|
+
if (storedEnableI18n === null) return true;
|
|
34
|
+
return storedEnableI18n === 'true';
|
|
35
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { LocaleCandidates } from 'gt-i18n/internal/types';
|
|
2
|
+
import { defaultLocaleCookieName as defaultLocaleStoreKey } from '@generaltranslation/react-core/pure';
|
|
3
|
+
import { getNativeLocales } from './getNativeLocales';
|
|
4
|
+
import { nativeStoreGet } from './nativeStore';
|
|
5
|
+
import { resolveLocale } from './resolveLocale';
|
|
6
|
+
|
|
7
|
+
export type GetLocaleParams = {
|
|
8
|
+
localeStoreKey?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export function getLocale({
|
|
15
|
+
localeStoreKey = defaultLocaleStoreKey,
|
|
16
|
+
}: GetLocaleParams = {}): string {
|
|
17
|
+
const candidates: string[] = [];
|
|
18
|
+
pushLocaleCandidates(candidates, nativeStoreGet(localeStoreKey));
|
|
19
|
+
candidates.push(...getNativeLocales());
|
|
20
|
+
|
|
21
|
+
return resolveLocale(candidates);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function pushLocaleCandidates(
|
|
25
|
+
target: string[],
|
|
26
|
+
locale: LocaleCandidates | null
|
|
27
|
+
) {
|
|
28
|
+
if (!locale) return;
|
|
29
|
+
if (Array.isArray(locale)) {
|
|
30
|
+
target.push(...locale);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
target.push(locale);
|
|
34
|
+
}
|
package/src/utils/nativeStore.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defaultLocaleCookieName } from '@generaltranslation/react-core/
|
|
1
|
+
import { defaultLocaleCookieName as defaultLocaleStoreKey } from '@generaltranslation/react-core/pure';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import GtReactNative from '../NativeGtReactNative';
|
|
4
4
|
import { ssrUnsupportedWarning } from '../errors-dir/warnings';
|
|
@@ -9,13 +9,13 @@ import { ssrUnsupportedWarning } from '../errors-dir/warnings';
|
|
|
9
9
|
* This reads persisted native storage directly, so it can temporarily be out of
|
|
10
10
|
* sync with React state while a locale change is in progress.
|
|
11
11
|
*
|
|
12
|
-
* If GTProvider uses a custom
|
|
12
|
+
* If GTProvider uses a custom localeStoreKey, pass that same value as the key.
|
|
13
13
|
*
|
|
14
14
|
* @param key - The key to get the locale from
|
|
15
15
|
* @returns The locale from the native store
|
|
16
16
|
*/
|
|
17
17
|
export function getLocaleFromNativeStore(
|
|
18
|
-
key =
|
|
18
|
+
key = defaultLocaleStoreKey
|
|
19
19
|
): string | null {
|
|
20
20
|
return nativeStoreGet(key);
|
|
21
21
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getI18nConfig } from 'gt-i18n/internal';
|
|
2
|
+
import type { LocaleCandidates } from 'gt-i18n/internal/types';
|
|
3
|
+
|
|
4
|
+
export function resolveLocale(candidates?: LocaleCandidates | null): string {
|
|
5
|
+
const i18nConfig = getI18nConfig();
|
|
6
|
+
return (
|
|
7
|
+
i18nConfig.determineLocale(candidates ?? undefined) ||
|
|
8
|
+
i18nConfig.getDefaultLocale()
|
|
9
|
+
);
|
|
10
|
+
}
|
package/src/utils/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AuthFromEnvParams,
|
|
3
3
|
AuthFromEnvReturn,
|
|
4
|
-
} from '@generaltranslation/react-core/
|
|
4
|
+
} from '@generaltranslation/react-core/pure';
|
|
5
5
|
|
|
6
6
|
export function readAuthFromEnv(params: AuthFromEnvParams): AuthFromEnvReturn {
|
|
7
7
|
const { projectId, devApiKey } = params;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../../../_virtual/_rolldown/runtime.js");
|
|
3
|
-
const require_errors_dir_constants = require("../../../errors-dir/constants.js");
|
|
4
|
-
const require_utils_getNativeLocales = require("../../../utils/getNativeLocales.js");
|
|
5
|
-
const require_utils_nativeStore = require("../../../utils/nativeStore.js");
|
|
6
|
-
let react = require("react");
|
|
7
|
-
let _generaltranslation_format = require("@generaltranslation/format");
|
|
8
|
-
let _generaltranslation_react_core_internal = require("@generaltranslation/react-core/internal");
|
|
9
|
-
let generaltranslation_internal = require("generaltranslation/internal");
|
|
10
|
-
let _generaltranslation_react_core_errors = require("@generaltranslation/react-core/errors");
|
|
11
|
-
//#region src/provider/hooks/locale/useDetermineLocale.ts
|
|
12
|
-
function useDetermineLocale({ locale: _locale = "", defaultLocale = generaltranslation_internal.libraryDefaultLocale, locales = [], localeCookieName = _generaltranslation_react_core_internal.defaultLocaleCookieName, ssr = false, customMapping, enableI18n }) {
|
|
13
|
-
_locale = (0, _generaltranslation_format.resolveAliasLocale)(_locale, customMapping);
|
|
14
|
-
locales = locales.map((locale) => (0, _generaltranslation_format.resolveAliasLocale)(locale, customMapping));
|
|
15
|
-
const initializeLocale = () => {
|
|
16
|
-
if (!enableI18n) return defaultLocale;
|
|
17
|
-
return (0, _generaltranslation_format.resolveAliasLocale)(ssr ? _locale ? (0, _generaltranslation_format.determineLocale)(_locale, locales, customMapping) || "" : "" : getNewLocale({
|
|
18
|
-
_locale,
|
|
19
|
-
locale: _locale,
|
|
20
|
-
locales,
|
|
21
|
-
defaultLocale,
|
|
22
|
-
localeCookieName,
|
|
23
|
-
customMapping,
|
|
24
|
-
enableI18n
|
|
25
|
-
}), customMapping);
|
|
26
|
-
};
|
|
27
|
-
const [locale, _setLocale] = (0, react.useState)(initializeLocale());
|
|
28
|
-
const [setLocale, setLocaleWithoutPersist] = createSetLocale({
|
|
29
|
-
locale,
|
|
30
|
-
locales,
|
|
31
|
-
defaultLocale,
|
|
32
|
-
localeCookieName,
|
|
33
|
-
_setLocale,
|
|
34
|
-
customMapping,
|
|
35
|
-
enableI18n
|
|
36
|
-
});
|
|
37
|
-
(0, react.useEffect)(() => {
|
|
38
|
-
setLocaleWithoutPersist(getNewLocale({
|
|
39
|
-
_locale,
|
|
40
|
-
locale,
|
|
41
|
-
locales,
|
|
42
|
-
defaultLocale,
|
|
43
|
-
localeCookieName,
|
|
44
|
-
customMapping,
|
|
45
|
-
enableI18n
|
|
46
|
-
}));
|
|
47
|
-
}, [
|
|
48
|
-
_locale,
|
|
49
|
-
locale,
|
|
50
|
-
locales,
|
|
51
|
-
defaultLocale,
|
|
52
|
-
localeCookieName,
|
|
53
|
-
customMapping,
|
|
54
|
-
enableI18n
|
|
55
|
-
]);
|
|
56
|
-
return [locale, setLocale];
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Choose a locale to use
|
|
60
|
-
* (1) use provided locale
|
|
61
|
-
* (2) use cookie locale
|
|
62
|
-
* (3) use preferred locale
|
|
63
|
-
* (5) fallback to defaultLocale
|
|
64
|
-
* Update the cookie locale to be correct
|
|
65
|
-
*/
|
|
66
|
-
function getNewLocale({ _locale, locale, locales, defaultLocale, localeCookieName, customMapping, enableI18n }) {
|
|
67
|
-
if (!enableI18n) return defaultLocale;
|
|
68
|
-
if (_locale && _locale === locale && (0, _generaltranslation_format.determineLocale)(_locale, locales, customMapping) === locale) return (0, _generaltranslation_format.resolveAliasLocale)(_locale, customMapping);
|
|
69
|
-
let storedLocale = require_utils_nativeStore.nativeStoreGet(localeCookieName);
|
|
70
|
-
if (storedLocale) storedLocale = (0, _generaltranslation_format.resolveAliasLocale)(storedLocale, customMapping);
|
|
71
|
-
let preferredLocales = require_utils_getNativeLocales.getNativeLocales();
|
|
72
|
-
if (preferredLocales.length === 0) preferredLocales = [defaultLocale];
|
|
73
|
-
preferredLocales = preferredLocales.map((l) => (0, _generaltranslation_format.resolveAliasLocale)(l, customMapping));
|
|
74
|
-
let newLocale = (0, _generaltranslation_format.determineLocale)([
|
|
75
|
-
..._locale ? [_locale] : [],
|
|
76
|
-
...storedLocale ? [storedLocale] : [],
|
|
77
|
-
...preferredLocales
|
|
78
|
-
], locales, customMapping) || defaultLocale;
|
|
79
|
-
if (newLocale) newLocale = (0, _generaltranslation_format.resolveAliasLocale)(newLocale, customMapping);
|
|
80
|
-
if (storedLocale && storedLocale !== newLocale) require_utils_nativeStore.nativeStoreSet(localeCookieName, newLocale);
|
|
81
|
-
return newLocale;
|
|
82
|
-
}
|
|
83
|
-
function createSetLocale({ locale, locales, defaultLocale, _setLocale, localeCookieName, customMapping, enableI18n }) {
|
|
84
|
-
locale = (0, _generaltranslation_format.resolveAliasLocale)(locale, customMapping);
|
|
85
|
-
const setLocaleWithoutPersist = (newLocale) => {
|
|
86
|
-
if (!enableI18n) return defaultLocale;
|
|
87
|
-
const validatedLocale = (0, _generaltranslation_format.resolveAliasLocale)((0, _generaltranslation_format.determineLocale)(newLocale, locales, customMapping) || locale || defaultLocale, customMapping);
|
|
88
|
-
if (validatedLocale !== newLocale) console.warn((0, _generaltranslation_react_core_errors.createUnsupportedLocaleWarning)(validatedLocale, newLocale, require_errors_dir_constants.PACKAGE_NAME));
|
|
89
|
-
_setLocale(validatedLocale);
|
|
90
|
-
return validatedLocale;
|
|
91
|
-
};
|
|
92
|
-
const setLocale = (newLocale) => {
|
|
93
|
-
if (!enableI18n) return;
|
|
94
|
-
newLocale = (0, _generaltranslation_format.resolveAliasLocale)(newLocale, customMapping);
|
|
95
|
-
require_utils_nativeStore.nativeStoreSet(localeCookieName, setLocaleWithoutPersist(newLocale));
|
|
96
|
-
};
|
|
97
|
-
return [setLocale, setLocaleWithoutPersist];
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
exports.useDetermineLocale = useDetermineLocale;
|
|
101
|
-
|
|
102
|
-
//# sourceMappingURL=useDetermineLocale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDetermineLocale.js","names":["libraryDefaultLocale","defaultLocaleCookieName","nativeStoreGet","getNativeLocales","PACKAGE_NAME"],"sources":["../../../../../src/provider/hooks/locale/useDetermineLocale.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport type { Dispatch, SetStateAction } from 'react';\nimport {\n determineLocale,\n resolveAliasLocale,\n} from '@generaltranslation/format';\nimport { defaultLocaleCookieName } from '@generaltranslation/react-core/internal';\nimport { libraryDefaultLocale } from 'generaltranslation/internal';\nimport type { CustomMapping } from '@generaltranslation/format/types';\nimport type {\n UseDetermineLocaleParams,\n UseDetermineLocaleReturn,\n} from '@generaltranslation/react-core/types';\nimport { createUnsupportedLocaleWarning } from '@generaltranslation/react-core/errors';\nimport { PACKAGE_NAME } from '../../../errors-dir/constants';\nimport { getNativeLocales } from '../../../utils/getNativeLocales';\nimport { nativeStoreGet, nativeStoreSet } from '../../../utils/nativeStore';\n\nexport function useDetermineLocale({\n locale: _locale = '',\n defaultLocale = libraryDefaultLocale,\n locales = [],\n localeCookieName = defaultLocaleCookieName,\n ssr = false, // not relevant\n customMapping,\n enableI18n,\n}: UseDetermineLocaleParams): UseDetermineLocaleReturn {\n // resolve alias locale\n _locale = resolveAliasLocale(_locale, customMapping);\n locales = locales.map((locale) => resolveAliasLocale(locale, customMapping));\n\n const initializeLocale = () => {\n if (!enableI18n) {\n return defaultLocale;\n }\n const result = resolveAliasLocale(\n ssr\n ? _locale\n ? determineLocale(_locale, locales, customMapping) || ''\n : ''\n : getNewLocale({\n _locale,\n locale: _locale,\n locales,\n defaultLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n }),\n customMapping\n );\n return result;\n };\n\n // maintaining the state of locale\n const [locale, _setLocale] = useState<string>(initializeLocale());\n\n // Functions for setting internal locale state\n const [setLocale, setLocaleWithoutPersist] = createSetLocale({\n locale,\n locales,\n defaultLocale,\n localeCookieName,\n _setLocale,\n customMapping,\n enableI18n,\n });\n\n // check browser for locales\n useEffect(() => {\n const newLocale = getNewLocale({\n _locale,\n locale,\n locales,\n defaultLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n });\n setLocaleWithoutPersist(newLocale);\n }, [\n _locale,\n locale,\n locales,\n defaultLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n ]);\n\n return [locale, setLocale];\n}\n\n// ----- HELPER FUNCTIONS ---- //\n\n/**\n * Choose a locale to use\n * (1) use provided locale\n * (2) use cookie locale\n * (3) use preferred locale\n * (5) fallback to defaultLocale\n * Update the cookie locale to be correct\n */\nfunction getNewLocale({\n _locale,\n locale,\n locales,\n defaultLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n}: {\n _locale: string;\n locale: string;\n locales: string[];\n defaultLocale: string;\n localeCookieName: string;\n customMapping?: CustomMapping;\n enableI18n: boolean;\n}): string {\n if (!enableI18n) {\n return defaultLocale;\n }\n // No change, return\n if (\n _locale &&\n _locale === locale &&\n determineLocale(_locale, locales, customMapping) === locale\n ) {\n return resolveAliasLocale(_locale, customMapping);\n }\n\n // Check for locale in native store\n let storedLocale = nativeStoreGet(localeCookieName);\n if (storedLocale) {\n storedLocale = resolveAliasLocale(storedLocale, customMapping);\n }\n\n // check user's configured locales\n let preferredLocales = getNativeLocales();\n if (preferredLocales.length === 0) preferredLocales = [defaultLocale];\n preferredLocales = preferredLocales.map((l) =>\n resolveAliasLocale(l, customMapping)\n );\n\n // determine locale\n let newLocale =\n determineLocale(\n [\n ...(_locale ? [_locale] : []), // prefer user passed locale\n ...(storedLocale ? [storedLocale] : []), // then prefer stored locale\n ...preferredLocales, // then prefer browser locale\n ],\n locales,\n customMapping\n ) || defaultLocale;\n if (newLocale) {\n newLocale = resolveAliasLocale(newLocale, customMapping);\n }\n\n // if stored locale not valid, change it back to whatever we use for fallback\n if (storedLocale && storedLocale !== newLocale) {\n nativeStoreSet(localeCookieName, newLocale);\n }\n\n // return new locale\n return newLocale;\n}\n\nfunction createSetLocale({\n locale,\n locales,\n defaultLocale,\n _setLocale,\n localeCookieName,\n customMapping,\n enableI18n,\n}: {\n locale: string;\n locales: string[];\n defaultLocale: string;\n localeCookieName: string;\n _setLocale: Dispatch<SetStateAction<string>>;\n customMapping?: CustomMapping;\n enableI18n: boolean;\n}): [(newLocale: string) => void, (newLocale: string) => void] {\n locale = resolveAliasLocale(locale, customMapping);\n // Just update the internal state, don't persist it\n const setLocaleWithoutPersist = (newLocale: string): string => {\n if (!enableI18n) {\n return defaultLocale;\n }\n // validate locale\n const validatedLocale = resolveAliasLocale(\n determineLocale(newLocale, locales, customMapping) ||\n locale ||\n defaultLocale,\n customMapping\n );\n if (validatedLocale !== newLocale) {\n console.warn(\n createUnsupportedLocaleWarning(validatedLocale, newLocale, PACKAGE_NAME)\n );\n }\n // persist locale\n _setLocale(validatedLocale);\n\n return validatedLocale;\n };\n // update locale and persist it in native store\n const setLocale = (newLocale: string): void => {\n if (!enableI18n) {\n return;\n }\n newLocale = resolveAliasLocale(newLocale, customMapping);\n const validatedLocale = setLocaleWithoutPersist(newLocale);\n nativeStoreSet(localeCookieName, validatedLocale);\n };\n return [setLocale, setLocaleWithoutPersist];\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAgB,mBAAmB,EACjC,QAAQ,UAAU,IAClB,gBAAgBA,4BAAAA,sBAChB,UAAU,EAAE,EACZ,mBAAmBC,wCAAAA,yBACnB,MAAM,OACN,eACA,cACqD;AAErD,YAAA,GAAA,2BAAA,oBAA6B,SAAS,cAAc;AACpD,WAAU,QAAQ,KAAK,YAAA,GAAA,2BAAA,oBAA8B,QAAQ,cAAc,CAAC;CAE5E,MAAM,yBAAyB;AAC7B,MAAI,CAAC,WACH,QAAO;AAkBT,UAAA,GAAA,2BAAA,oBAfE,MACI,WAAA,GAAA,2BAAA,iBACkB,SAAS,SAAS,cAAc,IAAI,KACpD,KACF,aAAa;GACX;GACA,QAAQ;GACR;GACA;GACA;GACA;GACA;GACD,CAAC,EACN,cAEW;;CAIf,MAAM,CAAC,QAAQ,eAAA,GAAA,MAAA,UAA+B,kBAAkB,CAAC;CAGjE,MAAM,CAAC,WAAW,2BAA2B,gBAAgB;EAC3D;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAGF,EAAA,GAAA,MAAA,iBAAgB;AAUd,0BATkB,aAAa;GAC7B;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CACgC,CAAC;IACjC;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAEF,QAAO,CAAC,QAAQ,UAAU;;;;;;;;;;AAa5B,SAAS,aAAa,EACpB,SACA,QACA,SACA,eACA,kBACA,eACA,cASS;AACT,KAAI,CAAC,WACH,QAAO;AAGT,KACE,WACA,YAAY,WAAA,GAAA,2BAAA,iBACI,SAAS,SAAS,cAAc,KAAK,OAErD,SAAA,GAAA,2BAAA,oBAA0B,SAAS,cAAc;CAInD,IAAI,eAAeC,0BAAAA,eAAe,iBAAiB;AACnD,KAAI,aACF,iBAAA,GAAA,2BAAA,oBAAkC,cAAc,cAAc;CAIhE,IAAI,mBAAmBC,+BAAAA,kBAAkB;AACzC,KAAI,iBAAiB,WAAW,EAAG,oBAAmB,CAAC,cAAc;AACrE,oBAAmB,iBAAiB,KAAK,OAAA,GAAA,2BAAA,oBACpB,GAAG,cAAc,CACrC;CAGD,IAAI,aAAA,GAAA,2BAAA,iBAEA;EACE,GAAI,UAAU,CAAC,QAAQ,GAAG,EAAE;EAC5B,GAAI,eAAe,CAAC,aAAa,GAAG,EAAE;EACtC,GAAG;EACJ,EACD,SACA,cACD,IAAI;AACP,KAAI,UACF,cAAA,GAAA,2BAAA,oBAA+B,WAAW,cAAc;AAI1D,KAAI,gBAAgB,iBAAiB,UACnC,2BAAA,eAAe,kBAAkB,UAAU;AAI7C,QAAO;;AAGT,SAAS,gBAAgB,EACvB,QACA,SACA,eACA,YACA,kBACA,eACA,cAS6D;AAC7D,WAAA,GAAA,2BAAA,oBAA4B,QAAQ,cAAc;CAElD,MAAM,2BAA2B,cAA8B;AAC7D,MAAI,CAAC,WACH,QAAO;EAGT,MAAM,mBAAA,GAAA,2BAAA,qBAAA,GAAA,2BAAA,iBACY,WAAW,SAAS,cAAc,IAChD,UACA,eACF,cACD;AACD,MAAI,oBAAoB,UACtB,SAAQ,MAAA,GAAA,sCAAA,gCACyB,iBAAiB,WAAWC,6BAAAA,aAAa,CACzE;AAGH,aAAW,gBAAgB;AAE3B,SAAO;;CAGT,MAAM,aAAa,cAA4B;AAC7C,MAAI,CAAC,WACH;AAEF,eAAA,GAAA,2BAAA,oBAA+B,WAAW,cAAc;AAExD,4BAAA,eAAe,kBADS,wBAAwB,UACA,CAAC;;AAEnD,QAAO,CAAC,WAAW,wBAAwB"}
|