@generaltranslation/react-core 1.8.21 → 2.0.0-odysseus.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/components-rsc.cjs.min.cjs +2 -0
  3. package/dist/components-rsc.cjs.min.cjs.map +1 -0
  4. package/dist/components-rsc.d.ts +531 -0
  5. package/dist/components-rsc.d.ts.map +1 -0
  6. package/dist/components-rsc.esm.min.mjs +2 -0
  7. package/dist/components-rsc.esm.min.mjs.map +1 -0
  8. package/dist/components.cjs.min.cjs +2 -0
  9. package/dist/components.cjs.min.cjs.map +1 -0
  10. package/dist/components.d.ts +495 -0
  11. package/dist/components.d.ts.map +1 -0
  12. package/dist/components.esm.min.mjs +2 -0
  13. package/dist/components.esm.min.mjs.map +1 -0
  14. package/dist/hooks.cjs.min.cjs +2 -0
  15. package/dist/hooks.cjs.min.cjs.map +1 -0
  16. package/dist/hooks.d.ts +130 -0
  17. package/dist/hooks.d.ts.map +1 -0
  18. package/dist/hooks.esm.min.mjs +2 -0
  19. package/dist/hooks.esm.min.mjs.map +1 -0
  20. package/dist/pure.cjs.min.cjs +2 -0
  21. package/dist/pure.cjs.min.cjs.map +1 -0
  22. package/dist/pure.d.ts +677 -0
  23. package/dist/pure.d.ts.map +1 -0
  24. package/dist/pure.esm.min.mjs +2 -0
  25. package/dist/pure.esm.min.mjs.map +1 -0
  26. package/package.json +40 -35
  27. package/dist/errors.cjs.min.cjs +0 -2
  28. package/dist/errors.cjs.min.cjs.map +0 -1
  29. package/dist/errors.d.ts +0 -5
  30. package/dist/errors.d.ts.map +0 -1
  31. package/dist/errors.esm.min.mjs +0 -2
  32. package/dist/errors.esm.min.mjs.map +0 -1
  33. package/dist/index.cjs.min.cjs +0 -2
  34. package/dist/index.cjs.min.cjs.map +0 -1
  35. package/dist/index.d.ts +0 -1385
  36. package/dist/index.d.ts.map +0 -1
  37. package/dist/index.esm.min.mjs +0 -2
  38. package/dist/index.esm.min.mjs.map +0 -1
  39. package/dist/internal.cjs.min.cjs +0 -2
  40. package/dist/internal.cjs.min.cjs.map +0 -1
  41. package/dist/internal.d.ts +0 -765
  42. package/dist/internal.d.ts.map +0 -1
  43. package/dist/internal.esm.min.mjs +0 -2
  44. package/dist/internal.esm.min.mjs.map +0 -1
  45. package/dist/types.d.ts +0 -437
  46. package/dist/types.d.ts.map +0 -1
package/dist/pure.d.ts ADDED
@@ -0,0 +1,677 @@
1
+ import { declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getGTClass, getLocaleProperties, getLocales, getVersionId, gtFallback, mFallback, msg } from "gt-i18n";
2
+ import React, { ReactNode } from "react";
3
+ import { Dictionary as Dictionary$1, DictionaryEntry as DictionaryEntry$1, DictionaryObject as DictionaryObject$1, DictionaryTranslationOptions, GTFunctionType, InlineTranslationOptions, InlineTranslationOptions as InlineTranslationOptions$1, LookupOptions, MFunctionType, RuntimeTranslationOptions, Translation } from "gt-i18n/types";
4
+ import { GTServicesEnabledParams, Hash, I18nCacheConstructorParams, I18nConfigParams, I18nConfigParams as I18nConfigParams$1, Locale, ReadonlyConditionStoreInterface, WritableConditionStoreParams, WritableConditionStoreParams as WritableConditionStoreParams$1 } from "gt-i18n/internal/types";
5
+ import { I18nCache, I18nConfig, ReadonlyConditionStore, WritableConditionStore } from "gt-i18n/internal";
6
+
7
+ //#region src/utils/plurals/getPluralBranch.d.ts
8
+ /**
9
+ * Main function to get the appropriate branch based on the provided number and branches.
10
+ *
11
+ * @param {number} n - The number to determine the branch for.
12
+ * @param {any} branches - The object containing possible branches.
13
+ * @returns {any} The determined branch.
14
+ */
15
+ declare function getPluralBranch<T>(n: number, locales: string[], branches: Record<string, T>): T | null;
16
+ //#endregion
17
+ //#region ../format/dist/types-COaQnqVZ.d.cts
18
+ //#endregion
19
+ //#region src/types-dir/jsx/variables.d.ts
20
+ type VariableType = 'v' | 'n' | 'd' | 'c' | 'rt';
21
+ /**
22
+ * Variables are used to store the variable name and type.
23
+ */
24
+ type Variable = {
25
+ k: string;
26
+ i?: number;
27
+ v?: VariableType;
28
+ }; //#endregion
29
+ //#region src/types-dir/jsx/content.d.ts
30
+ /**
31
+ * Map of data-_gt properties to their corresponding React props
32
+ */
33
+ declare const HTML_CONTENT_PROPS: {
34
+ readonly pl: "placeholder";
35
+ readonly ti: "title";
36
+ readonly alt: "alt";
37
+ readonly arl: "aria-label";
38
+ readonly arb: "aria-labelledby";
39
+ readonly ard: "aria-describedby";
40
+ };
41
+ type HtmlContentPropKeysRecord = Partial<Record<keyof typeof HTML_CONTENT_PROPS, string>>;
42
+ /**
43
+ * GTProp is an internal property used to contain data for translating and rendering elements.
44
+ * note, transformations are only read on the server side if they are 'plural' or 'branch'
45
+ */
46
+ type GTProp = {
47
+ b?: Record<string, JsxChildren>;
48
+ t?: 'p' | 'b';
49
+ } & HtmlContentPropKeysRecord;
50
+ type JsxElement = {
51
+ t?: string;
52
+ i?: number;
53
+ d?: GTProp;
54
+ c?: JsxChildren;
55
+ };
56
+ type JsxChild = string | JsxElement | Variable;
57
+ /**
58
+ * The format of the string content
59
+ */
60
+ /**
61
+ * A content type representing JSX elements.
62
+ */
63
+ type JsxChildren = JsxChild | JsxChild[];
64
+ /**
65
+ * A content type representing ICU messages.
66
+ */
67
+ //#endregion
68
+ //#region ../core/dist/types-CdRgQtET.d.cts
69
+ type TransformationPrefix = 'translate' | 'variable' | 'plural' | 'branch' | 'fragment' | 'derive';
70
+ type VariableTransformationSuffix = 'variable' | 'number' | 'datetime' | 'currency' | 'relative-time';
71
+ type InjectionType = 'automatic' | 'manual'; //#endregion
72
+ //#region src/types.d.ts
73
+ /**
74
+ * @deprecated Use {@link Content} instead.
75
+ */
76
+ //#endregion
77
+ //#region src/utils/types.d.ts
78
+ /**
79
+ * TaggedElement is a React element with a GTProp property.
80
+ */
81
+ type GTTag = {
82
+ id: number;
83
+ injectionType: InjectionType;
84
+ transformation?: TransformationPrefix;
85
+ branches?: Record<string, TaggedChildren>;
86
+ variableType?: VariableTransformationSuffix;
87
+ };
88
+ type TaggedElementProps = Record<string, unknown> & {
89
+ 'data-_gt': GTTag;
90
+ children?: TaggedChildren;
91
+ branch?: string | number | boolean;
92
+ n?: number;
93
+ key?: React.Key;
94
+ };
95
+ type TaggedElement = React.ReactElement<TaggedElementProps>;
96
+ type TaggedChild = Exclude<React.ReactNode, React.ReactElement> | TaggedElement;
97
+ type TaggedChildren = TaggedChild[] | TaggedChild;
98
+ /**
99
+ * Translated content types
100
+ * TODO: move these types to JsxElement etc from generaltranslation/types
101
+ * remember to omit the t property (tag name) from the translated element
102
+ */
103
+ type TranslatedElement = {
104
+ i?: number;
105
+ d?: GTProp;
106
+ c?: TranslatedChildren;
107
+ };
108
+ type TranslatedChild = TranslatedElement | string | Variable;
109
+ type TranslatedChildren = TranslatedChild | TranslatedChild[];
110
+ type Entry = string;
111
+ type MetaEntry = {
112
+ $context?: string;
113
+ $maxChars?: number;
114
+ $_hash?: string;
115
+ [key: string]: unknown;
116
+ };
117
+ type Metadata = MetaEntry;
118
+ type DictionaryEntry = Entry | [Entry] | [Entry, MetaEntry];
119
+ type Dictionary = {
120
+ [key: string]: Dictionary | DictionaryEntry;
121
+ } | (Dictionary | DictionaryEntry)[];
122
+ type FlattenedDictionary = {
123
+ [key: string]: DictionaryEntry;
124
+ };
125
+ type DictionaryContent = string;
126
+ type DictionaryObject = {
127
+ [id: string]: DictionaryContent;
128
+ };
129
+ type LocalesDictionary = {
130
+ [locale: string]: DictionaryObject;
131
+ };
132
+ type CustomLoader = (locale: string) => Promise<unknown>;
133
+ type RelativeTimeFormatOptions = Intl.RelativeTimeFormatOptions & {
134
+ unit?: Intl.RelativeTimeFormatUnit;
135
+ baseDate?: Date;
136
+ };
137
+ type VariableProps = {
138
+ /** Whether the variable was automatically injected by the compiler */variableType: VariableType;
139
+ variableValue: unknown;
140
+ variableOptions: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | RelativeTimeFormatOptions;
141
+ variableName: string;
142
+ injectionType: InjectionType;
143
+ };
144
+ type RenderVariable = ({
145
+ variableType,
146
+ variableValue,
147
+ variableOptions,
148
+ locales,
149
+ enableI18n,
150
+ injectionType
151
+ }: Omit<VariableProps, 'variableName'> & {
152
+ locales: string[];
153
+ enableI18n: boolean;
154
+ }) => React.ReactNode;
155
+ type Translations = {
156
+ [hash: string]: TranslatedChildren | null;
157
+ };
158
+ type RenderMethod = 'skeleton' | 'replace' | 'default';
159
+ type _Message = {
160
+ message: string;
161
+ $id?: string;
162
+ $context?: string;
163
+ $maxChars?: number;
164
+ $_hash?: string;
165
+ };
166
+ type _Messages = _Message[];
167
+ type AuthFromEnvParams = {
168
+ projectId?: string;
169
+ devApiKey?: string;
170
+ };
171
+ type AuthFromEnvReturn = {
172
+ projectId: string;
173
+ devApiKey?: string;
174
+ };
175
+ //#endregion
176
+ //#region src/utils/internal/addGTIdentifier.d.ts
177
+ declare function addGTIdentifier(children: ReactNode, startingIndex?: number): TaggedChildren;
178
+ //#endregion
179
+ //#region src/utils/internal/writeChildrenAsObjects.d.ts
180
+ /**
181
+ * Transforms children elements into objects, processing each child recursively if needed.
182
+ * TaggedChildren are transformed into JsxChildren
183
+ * @param {Children} children - The children to process.
184
+ * @returns {object} The processed children as objects.
185
+ */
186
+ declare function writeChildrenAsObjects(children: TaggedChildren): JsxChildren;
187
+ //#endregion
188
+ //#region src/utils/dictionaries/flattenDictionary.d.ts
189
+ /**
190
+ * Flattens a nested dictionary by concatenating nested keys.
191
+ * Throws an error if two keys result in the same flattened key.
192
+ * @param {Record<string, any>} dictionary - The dictionary to flatten.
193
+ * @param {string} [prefix=''] - The prefix for nested keys.
194
+ * @returns {Record<string, React.ReactNode>} The flattened dictionary object.
195
+ * @throws {Error} If two keys result in the same flattened key.
196
+ */
197
+ declare function flattenDictionary(dictionary: Dictionary, prefix?: string): FlattenedDictionary;
198
+ //#endregion
199
+ //#region src/utils/variables/_getVariableProps.d.ts
200
+ type VariableElementProps = {
201
+ 'data-_gt': GTTag & {
202
+ transformation: 'variable';
203
+ };
204
+ [key: string]: unknown;
205
+ };
206
+ declare function getVariableProps(props: VariableElementProps): VariableProps;
207
+ //#endregion
208
+ //#region src/utils/variables/getVariableName.d.ts
209
+ declare const defaultVariableNames: {
210
+ readonly variable: "value";
211
+ readonly number: "n";
212
+ readonly datetime: "date";
213
+ readonly currency: "cost";
214
+ readonly 'relative-time': "time";
215
+ };
216
+ declare function getVariableName(props: Record<string, unknown> | undefined, variableType: keyof typeof defaultVariableNames): string;
217
+ //#endregion
218
+ //#region src/hooks/utils/getFormatLocales.d.ts
219
+ declare function getFormatLocales({
220
+ locale,
221
+ enableI18n,
222
+ localesProp
223
+ }: {
224
+ locale: string;
225
+ enableI18n: boolean;
226
+ localesProp?: string[];
227
+ }): string[];
228
+ //#endregion
229
+ //#region src/functions/helpers/getTranslationsSnapshot.d.ts
230
+ /**
231
+ * Returns a promise of serializable cached translations that
232
+ * can be passed to a provider for hydration
233
+ *
234
+ * TODO: perhaps should be moved to /i18n if allowing for type generics
235
+ */
236
+ declare function getTranslationsSnapshot(locale: Locale): Promise<Record<Locale, Record<Hash, Translation>>>;
237
+ //#endregion
238
+ //#region src/functions/translation/t.d.ts
239
+ /**
240
+ * Translate a message
241
+ * @param {string} message - The message to translate.
242
+ * @param {InlineTranslationOptions} [options] - The options for the translation.
243
+ * @returns {string} The translated message.
244
+ *
245
+ * @example
246
+ * t('Hello, world!'); // Translates 'Hello, world!'
247
+ *
248
+ * @example
249
+ * t('Hello, {name}!', { name: 'John' }); // Translates 'Hello, John!'
250
+ *
251
+ * @example
252
+ * t`Hello, ${name}` // Translate via tagged template literal
253
+ *
254
+ */
255
+ declare const t: StringOrTemplateSyncResolutionFunction;
256
+ /**
257
+ * Overloaded type for the `t` function.
258
+ * - Tagged template: t`Hello, ${name}` (transformed by the compiler plugin at build time)
259
+ * - Function call: t("Hello, {name}", { name: "John" })
260
+ *
261
+ * {@link TemplateSyncResolutionFunction}
262
+ * {@link SyncResolutionFunction}
263
+ */
264
+ interface StringOrTemplateSyncResolutionFunction {
265
+ (strings: TemplateStringsArray, ...values: unknown[]): string;
266
+ (message: string, options?: InlineTranslationOptions$1): string;
267
+ }
268
+ //#endregion
269
+ //#region src/components/variables/Currency.shared.d.ts
270
+ type CurrencyProps = {
271
+ children: number | string | null | undefined;
272
+ currency?: string;
273
+ options?: Intl.NumberFormatOptions;
274
+ locales?: string[];
275
+ name?: string;
276
+ _locale?: string;
277
+ _enableI18n?: boolean;
278
+ };
279
+ type ResolvedCurrencyProps = CurrencyProps & {
280
+ _locale: string;
281
+ _enableI18n: boolean;
282
+ };
283
+ //#endregion
284
+ //#region src/components/variables/DateTime.shared.d.ts
285
+ type DateTimeProps = {
286
+ children: Date | null | undefined;
287
+ locales?: string[];
288
+ options?: Intl.DateTimeFormatOptions;
289
+ name?: string;
290
+ _locale?: string;
291
+ _enableI18n?: boolean;
292
+ };
293
+ type ResolvedDateTimeProps = DateTimeProps & {
294
+ _locale: string;
295
+ _enableI18n: boolean;
296
+ };
297
+ //#endregion
298
+ //#region src/components/variables/Num.shared.d.ts
299
+ type NumProps = {
300
+ children: number | string | null | undefined;
301
+ options?: Intl.NumberFormatOptions;
302
+ locales?: string[];
303
+ name?: string;
304
+ _locale?: string;
305
+ _enableI18n?: boolean;
306
+ };
307
+ type ResolvedNumProps = NumProps & {
308
+ _locale: string;
309
+ _enableI18n: boolean;
310
+ };
311
+ //#endregion
312
+ //#region src/components/variables/RelativeTime.shared.d.ts
313
+ type RelativeTimeProps = {
314
+ date?: Date | null | undefined;
315
+ children?: Date | null | undefined;
316
+ name?: string;
317
+ value?: number;
318
+ unit?: Intl.RelativeTimeFormatUnit;
319
+ baseDate?: Date;
320
+ locales?: string[];
321
+ options?: Intl.RelativeTimeFormatOptions;
322
+ _locale?: string;
323
+ _enableI18n?: boolean;
324
+ };
325
+ type ResolvedRelativeTimeProps = RelativeTimeProps & {
326
+ _locale: string;
327
+ _enableI18n: boolean;
328
+ };
329
+ //#endregion
330
+ //#region src/utils/rendering/createRenderVariable.d.ts
331
+ type RenderableNode = ReactNode | Promise<ReactNode>;
332
+ type VariableComponents = {
333
+ Currency: (props: ResolvedCurrencyProps) => RenderableNode;
334
+ GtInternalCurrency: (props: ResolvedCurrencyProps) => RenderableNode;
335
+ DateTime: (props: ResolvedDateTimeProps) => RenderableNode;
336
+ GtInternalDateTime: (props: ResolvedDateTimeProps) => RenderableNode;
337
+ Num: (props: ResolvedNumProps) => RenderableNode;
338
+ GtInternalNum: (props: ResolvedNumProps) => RenderableNode;
339
+ RelativeTime: (props: ResolvedRelativeTimeProps) => RenderableNode;
340
+ GtInternalRelativeTime: (props: ResolvedRelativeTimeProps) => RenderableNode;
341
+ Var: (props: {
342
+ children: ReactNode;
343
+ name?: string;
344
+ _locale: string;
345
+ _enableI18n: boolean;
346
+ }) => RenderableNode;
347
+ GtInternalVar: (props: {
348
+ children: ReactNode;
349
+ name?: string;
350
+ _locale: string;
351
+ _enableI18n: boolean;
352
+ }) => RenderableNode;
353
+ };
354
+ //#endregion
355
+ //#region src/utils/rendering/renderDefaultChildren.shared.d.ts
356
+ type RenderDefaultChildrenArgs = {
357
+ children: TaggedChildren;
358
+ defaultLocale: string;
359
+ enableI18n: boolean;
360
+ };
361
+ //#endregion
362
+ //#region src/utils/rendering/renderTranslatedChildren.shared.d.ts
363
+ type RenderTranslatedChildrenArgs = {
364
+ source: TaggedChildren;
365
+ target: TranslatedChildren;
366
+ locales: string[];
367
+ enableI18n: boolean;
368
+ };
369
+ //#endregion
370
+ //#region src/utils/rendering/renderPreparedT.shared.d.ts
371
+ type RenderPreparedTParams = {
372
+ taggedSourceChildren: TaggedChildren;
373
+ targetJsxChildren: JsxChildren | null | undefined;
374
+ locale: string;
375
+ defaultLocale: string;
376
+ enableI18n: boolean;
377
+ shouldTranslate: boolean;
378
+ };
379
+ //#endregion
380
+ //#region src/utils/rendering/createRenderPipeline.d.ts
381
+ type RenderPipeline = {
382
+ renderVariable: RenderVariable;
383
+ renderDefaultChildren: (args: RenderDefaultChildrenArgs) => ReactNode;
384
+ renderTranslatedChildren: (args: RenderTranslatedChildrenArgs) => ReactNode;
385
+ renderPreparedT: (args: RenderPreparedTParams) => ReactNode;
386
+ };
387
+ declare function createRenderPipeline(components: VariableComponents): RenderPipeline;
388
+ //#endregion
389
+ //#region src/utils/translation/prepareT.shared.d.ts
390
+ type RenderPreparedT = (params: RenderPreparedTParams) => ReactNode;
391
+ //#endregion
392
+ //#region src/i18n-cache/ReactI18nCache.d.ts
393
+ declare class ReactI18nCache extends I18nCache<Translation> {}
394
+ type ReactI18nCacheParams = I18nCacheConstructorParams<Translation>;
395
+ //#endregion
396
+ //#region src/i18n-cache/singleton-operations.d.ts
397
+ declare function getReactI18nCache(): ReactI18nCache;
398
+ declare function setReactI18nCache(i18nCache: ReactI18nCache): void;
399
+ //#endregion
400
+ //#region src/utils/cookies.d.ts
401
+ /**
402
+ * Cookie name for tracking the user's selected locale.
403
+ */
404
+ declare const defaultLocaleCookieName = "generaltranslation.locale";
405
+ /**
406
+ * Cookie name for tracking the user's selected region.
407
+ */
408
+ declare const defaultRegionCookieName = "generaltranslation.region";
409
+ /**
410
+ * Cookie name for persisting the enableI18n feature flag.
411
+ */
412
+ declare const defaultEnableI18nCookieName = "generaltranslation.enable-i18n";
413
+ //#endregion
414
+ //#region src/utils/dictionaries/getDictionaryEntry.d.ts
415
+ declare function isValidDictionaryEntry(value: unknown): value is DictionaryEntry;
416
+ declare function getDictionaryEntry<T extends Dictionary>(dictionary: T, id: string): Dictionary | DictionaryEntry | undefined;
417
+ //#endregion
418
+ //#region src/utils/dictionaries/getEntryAndMetadata.d.ts
419
+ declare function getEntryAndMetadata(value: DictionaryEntry): {
420
+ entry: string;
421
+ metadata?: MetaEntry;
422
+ };
423
+ //#endregion
424
+ //#region src/utils/rendering/isVariableObject.d.ts
425
+ declare function isVariableObject(obj: unknown): obj is Variable;
426
+ //#endregion
427
+ //#region src/utils/rendering/renderSkeleton.d.ts
428
+ /**
429
+ * renderSkeleton is a function that handles the rendering behavior for the skeleton loading method.
430
+ * It replaces all content with empty strings
431
+ * @returns an empty string
432
+ */
433
+ declare function renderSkeleton(): React.ReactNode;
434
+ //#endregion
435
+ //#region src/utils/dictionaries/mergeDictionaries.d.ts
436
+ declare function mergeDictionaries(defaultLocaleDictionary: Dictionary, localeDictionary: Dictionary): Dictionary;
437
+ //#endregion
438
+ //#region src/utils/rendering/getDefaultRenderSettings.d.ts
439
+ declare const getDefaultRenderSettings: (environment?: "development" | "production" | "test") => {
440
+ method: RenderMethod;
441
+ timeout: number;
442
+ };
443
+ //#endregion
444
+ //#region src/utils/promises/reactHasUse.d.ts
445
+ declare const reactHasUse: boolean;
446
+ //#endregion
447
+ //#region src/utils/dictionaries/getSubtree.d.ts
448
+ declare function getSubtree<T extends Dictionary>({
449
+ dictionary,
450
+ id
451
+ }: {
452
+ dictionary: T;
453
+ id: string;
454
+ }): Dictionary | DictionaryEntry | undefined;
455
+ /**
456
+ * @description A function that gets a subtree from a dictionary
457
+ * @param dictionary - new dictionary to get the subtree from
458
+ * @param id - id of the subtree to get
459
+ * @param sourceDictionary - source dictionary to model off of
460
+ * @returns
461
+ */
462
+ declare function getSubtreeWithCreation<T extends Dictionary>({
463
+ dictionary,
464
+ id,
465
+ sourceDictionary
466
+ }: {
467
+ dictionary: T;
468
+ id: string;
469
+ sourceDictionary: T;
470
+ }): Dictionary | DictionaryEntry | undefined;
471
+ //#endregion
472
+ //#region src/utils/dictionaries/injectEntry.d.ts
473
+ /**
474
+ * @description Injects an entry into a translations object
475
+ * @param translations - The translations object to inject the entry into
476
+ * @param entry - The entry to inject
477
+ * @param hash - The hash of the entry
478
+ * @param sourceDictionary - The source dictionary to model the new dictionary after
479
+ */
480
+ declare function injectEntry(dictionaryEntry: DictionaryEntry, dictionary: Dictionary | DictionaryEntry, id: string, sourceDictionary: Dictionary | DictionaryEntry): DictionaryEntry | undefined;
481
+ //#endregion
482
+ //#region src/utils/dictionaries/isDictionaryEntry.d.ts
483
+ /**
484
+ * Type guard function that checks if a value is a DictionaryEntry
485
+ * @param value - The value to check
486
+ * @returns true if the value is a DictionaryEntry, false otherwise
487
+ */
488
+ declare function isDictionaryEntry(value: Dictionary | DictionaryEntry | undefined): value is DictionaryEntry;
489
+ //#endregion
490
+ //#region src/utils/dictionaries/stripMetadataFromEntries.d.ts
491
+ /**
492
+ * @description Iterate over tree and remove metadata leaving just the entry
493
+ */
494
+ declare function stripMetadataFromEntries(dictionary: Dictionary): Dictionary;
495
+ //#endregion
496
+ //#region src/utils/dictionaries/injectHashes.d.ts
497
+ /**
498
+ * @description Given a dictionary, adds hashes to all dictionary entries
499
+ * @param dictionary - The dictionary to add hashes to
500
+ * @param id - The starting point of dictionary (if subtree)
501
+ */
502
+ declare function injectHashes(dictionary: Dictionary, id?: string): {
503
+ dictionary: Dictionary;
504
+ updateDictionary: boolean;
505
+ };
506
+ //#endregion
507
+ //#region src/utils/dictionaries/injectTranslations.d.ts
508
+ /**
509
+ * @description Injects translations into a dictionary
510
+ * @param dictionary - The dictionary to inject translations into
511
+ * @param translationsDictionary - The translations to inject into the dictionary
512
+ * @param translations - The translations to inject into the dictionary
513
+ * @param id - The id of the dictionary to inject translations into
514
+ */
515
+ declare function injectTranslations(dictionary: Dictionary, translationsDictionary: Dictionary, translations: Translations, missingTranslations: {
516
+ source: string;
517
+ metadata: {
518
+ $id: string;
519
+ $context?: string;
520
+ $maxChars?: number;
521
+ $_hash: string;
522
+ };
523
+ }[], prefixToRemove?: string): {
524
+ dictionary: Dictionary;
525
+ updateDictionary: boolean;
526
+ };
527
+ //#endregion
528
+ //#region src/utils/dictionaries/injectFallbacks.d.ts
529
+ /**
530
+ * @description Injects fallbacks into a dictionary
531
+ * @param dictionary - The dictionary to inject translations into
532
+ * @param translationsDictionary - The translations to inject into the dictionary
533
+ * @param translations - The translations to inject into the dictionary
534
+ * @param id - The id of the dictionary to inject translations into
535
+ */
536
+ declare function injectFallbacks(dictionary: Dictionary, translationsDictionary: Dictionary, missingTranslations: {
537
+ source: string;
538
+ metadata: {
539
+ $id: string;
540
+ $context?: string;
541
+ $maxChars?: number;
542
+ $_hash: string;
543
+ };
544
+ }[], prefixToRemove?: string): Dictionary;
545
+ //#endregion
546
+ //#region src/utils/dictionaries/injectAndMerge.d.ts
547
+ /**
548
+ * @description Given a subtree and a dictionary, injects the subtree into the dictionary at the given id
549
+ * @param dictionary - The dictionary to inject the subtree into
550
+ * @param subtree - The subtree to inject into the dictionary
551
+ * @param id - The id of the subtree to inject into the dictionary
552
+ */
553
+ declare function injectAndMerge(dictionary: Dictionary, subtree: Dictionary, id: string): Dictionary;
554
+ //#endregion
555
+ //#region src/utils/dictionaries/collectUntranslatedEntries.d.ts
556
+ /**
557
+ * @description Collects all untranslated entries from a dictionary
558
+ * @param dictionary - The dictionary to collect untranslated entries from
559
+ * @param translationsDictionary - The translated dictionary to compare against
560
+ * @param id - The id of the dictionary to collect untranslated entries from
561
+ * @returns An array of untranslated entries
562
+ */
563
+ declare function collectUntranslatedEntries(dictionary: Dictionary, translationsDictionary: Dictionary, id?: string): {
564
+ source: string;
565
+ metadata: {
566
+ $id: string;
567
+ $context?: string;
568
+ $maxChars?: number;
569
+ $_hash: string;
570
+ };
571
+ }[];
572
+ //#endregion
573
+ //#region src/setup/initializeGTSRA.d.ts
574
+ /**
575
+ * Validation and setup for read only properties
576
+ */
577
+ declare function internalInitializeGTSRA(config: I18nConfigParams$1 & GTServicesEnabledParams & ReactI18nCacheParams): void;
578
+ //#endregion
579
+ //#region src/setup/initializeGTSPA.d.ts
580
+ /**
581
+ * Initialize GT for an SPA
582
+ * - i18nCache
583
+ * - conditionStore
584
+ * - i18nStore
585
+ *
586
+ * @deprecated moved to /react and /react-native
587
+ */
588
+ declare function internalInitializeGTSPA(config: I18nConfigParams$1 & GTServicesEnabledParams & ReactI18nCacheParams & WritableConditionStoreParams$1): void;
589
+ //#endregion
590
+ //#region src/i18n-store/storeTypes.d.ts
591
+ type Unsubscribe = () => void;
592
+ type StoreListener = () => void;
593
+ type TranslateEventListener = (lookup: TranslateLookup) => void;
594
+ type TranslateLookup<T extends Translation = Translation> = {
595
+ locale: string;
596
+ message: T;
597
+ options: LookupOptions;
598
+ };
599
+ type DictionaryLookup = {
600
+ locale: string;
601
+ id: string;
602
+ };
603
+ type TranslateSnapshot<T extends Translation = Translation> = T | undefined;
604
+ type DictionaryEntrySnapshot = DictionaryEntry$1 | undefined;
605
+ type DictionaryObjectSnapshot = DictionaryObject$1 | undefined;
606
+ //#endregion
607
+ //#region src/i18n-store/I18nStore.d.ts
608
+ type DictionaryStoreListener = (event: DictionaryLookup) => void;
609
+ /**
610
+ * I18nStore gives us the ability to perform client-side updates to translations.
611
+ * Primarily useful for dev hot reload.
612
+ *
613
+ * This is the stateful primitive behind lookup subscriptions and runtime
614
+ * translation requests. It intentionally does not know whether lookups are
615
+ * being served from SPA singletons or SRA provider snapshots; that policy lives
616
+ * in LookupAdapter, not in this store.
617
+ */
618
+ declare class I18nStore {
619
+ private translateListeners;
620
+ private dictionaryEntryListeners;
621
+ private dictionaryObjectListeners;
622
+ /**
623
+ * I18nCache must be already initialized
624
+ */
625
+ constructor();
626
+ updateTranslations: (translations: Record<Locale, Record<Hash, Translation>>) => void;
627
+ updateDictionaries: (dictionaries: Record<Locale, Dictionary$1>) => void;
628
+ translate: <T extends Translation>(lookup: TranslateLookup<T>) => Promise<void>;
629
+ translateDictionaryEntry: (lookup: DictionaryLookup) => void;
630
+ translateDictionaryObject: (lookup: DictionaryLookup) => void;
631
+ subscribeToTranslate: <T extends Translation>(lookup: TranslateLookup<T>, listener: StoreListener) => Unsubscribe;
632
+ subscribeToTranslationEvents: (listener: TranslateEventListener) => Unsubscribe;
633
+ subscribeToDictionaryEntryEvents: (listener: DictionaryStoreListener) => Unsubscribe;
634
+ subscribeToDictionaryObjectEvents: (listener: DictionaryStoreListener) => Unsubscribe;
635
+ getTranslateSnapshot: <T extends Translation>(lookup: TranslateLookup<T>, translationsSnapshot?: Record<Locale, Record<Hash, Translation>>) => TranslateSnapshot<T>;
636
+ getDictionaryEntrySnapshot: (lookup: DictionaryLookup, dictionariesSnapshot?: Record<Locale, Dictionary$1>) => DictionaryEntrySnapshot;
637
+ getDictionaryObjectSnapshot: (lookup: DictionaryLookup, dictionariesSnapshot?: Record<Locale, Dictionary$1>) => DictionaryObjectSnapshot;
638
+ private emitTranslateEvent;
639
+ private emitDictionaryEvent;
640
+ }
641
+ //#endregion
642
+ //#region src/i18n-store/singleton-operations.d.ts
643
+ declare function getI18nStore(): I18nStore;
644
+ declare function setI18nStore(nextStore: I18nStore): void;
645
+ declare function isI18nStoreInitialized(): boolean;
646
+ //#endregion
647
+ //#region src/setup/i18nConfig.d.ts
648
+ /**
649
+ * Helps us distinguish behavior for SPA vs server-rendered apps.
650
+ * - server-rendered apps must use context
651
+ * - SPA apps can synchronously access the locale
652
+ */
653
+ type RenderStrategy = 'SPA' | 'server-render';
654
+ declare class ReactI18nConfig extends I18nConfig {
655
+ private renderStrategy;
656
+ constructor(params?: I18nConfigParams$1, renderStrategy?: RenderStrategy);
657
+ getRenderStrategy(): RenderStrategy;
658
+ }
659
+ declare function getI18nConfig(): ReactI18nConfig;
660
+ declare function setI18nConfig(nextI18nConfig: ReactI18nConfig): void;
661
+ declare function initializeI18nConfig(params?: I18nConfigParams$1, renderStrategy?: RenderStrategy): ReactI18nConfig;
662
+ //#endregion
663
+ //#region src/condition-store/singleton-operations.d.ts
664
+ declare const getConditionStore: () => ReadonlyConditionStoreInterface, setConditionStore: (nextConditionStore: ReadonlyConditionStoreInterface) => void, isConditionStoreInitialized: () => boolean;
665
+ /**
666
+ * Opinionated decision: add a safety wrapper around the condition store to be more forgiving in production
667
+ * TODO: perhaps this is how condition store should always be accessed
668
+ */
669
+ declare function getReadonlyConditionStoreWithFallback(): ReadonlyConditionStoreInterface;
670
+ //#endregion
671
+ //#region src/hooks/utils/missing-translation.d.ts
672
+ type OnMissingTranslation = <T extends Translation>(lookup: TranslateLookup<T>) => void;
673
+ type OnMissingDictionaryEntry = (lookup: DictionaryLookup) => void;
674
+ type OnMissingDictionaryObj = (lookup: DictionaryLookup) => void;
675
+ //#endregion
676
+ export { type AuthFromEnvParams, type AuthFromEnvReturn, type CustomLoader, type Dictionary, type DictionaryContent, type DictionaryEntry, type DictionaryLookup, type DictionaryObject, type DictionaryTranslationOptions, type Entry, type FlattenedDictionary, type GTFunctionType, type GTProp, type I18nConfigParams, I18nStore, type InlineTranslationOptions, type LocalesDictionary, type MFunctionType, type Metadata, type OnMissingDictionaryEntry, type OnMissingDictionaryObj, type OnMissingTranslation, ReactI18nCache, type ReactI18nCacheParams, ReactI18nConfig, ReadonlyConditionStore, type RelativeTimeFormatOptions, type RenderMethod, type RenderPipeline, type RenderPreparedT, type RenderVariable, type RuntimeTranslationOptions, type TranslateLookup, type TranslatedChildren, type Translations, type VariableProps, WritableConditionStore, type WritableConditionStoreParams, type _Message, type _Messages, addGTIdentifier, collectUntranslatedEntries, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, defaultEnableI18nCookieName, defaultLocaleCookieName, defaultRegionCookieName, derive, flattenDictionary, getDefaultLocale, getDefaultRenderSettings, getDictionaryEntry, getEntryAndMetadata, getFormatLocales, getGTClass, getI18nConfig, getI18nStore, getLocaleProperties, getLocales, getPluralBranch, getReactI18nCache, getReadonlyConditionStoreWithFallback, getSubtree, getSubtreeWithCreation, getTranslationsSnapshot, getVariableName, getVariableProps, getVersionId, gtFallback, internalInitializeGTSRA as initializeGT, internalInitializeGTSRA, initializeI18nConfig, injectAndMerge, injectEntry, injectFallbacks, injectHashes, injectTranslations, internalInitializeGTSPA, isDictionaryEntry, isI18nStoreInitialized, isValidDictionaryEntry, isVariableObject, mFallback, mergeDictionaries, msg, reactHasUse, renderSkeleton, setI18nConfig, setI18nStore, setReactI18nCache, setConditionStore as setReadonlyConditionStore, stripMetadataFromEntries, t, writeChildrenAsObjects };
677
+ //# sourceMappingURL=pure.d.ts.map