gt-react 11.0.12 → 11.0.13
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 +9 -0
- package/dist/index.client.cjs +1 -0
- package/dist/index.client.cjs.map +1 -1
- package/dist/index.client.d.cts +50 -4
- package/dist/index.client.d.cts.map +1 -1
- package/dist/index.client.d.mts +48 -2
- package/dist/index.client.d.mts.map +1 -1
- package/dist/index.client.mjs +1 -1
- package/dist/index.client.mjs.map +1 -1
- package/dist/index.server.cjs +11 -0
- package/dist/index.server.cjs.map +1 -1
- package/dist/index.server.d.cts +52 -4
- package/dist/index.server.d.cts.map +1 -1
- package/dist/index.server.d.mts +50 -2
- package/dist/index.server.d.mts.map +1 -1
- package/dist/index.server.mjs +11 -1
- package/dist/index.server.mjs.map +1 -1
- package/dist/index.types.d.cts +50 -4
- package/dist/index.types.d.cts.map +1 -1
- package/dist/index.types.d.mts +48 -2
- package/dist/index.types.d.mts.map +1 -1
- package/package.json +4 -4
package/dist/index.server.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { InternalRegionSelectorOptions, useCustomMapping, useDefaultLocale, useE
|
|
|
5
5
|
import { Branch, Currency, DateTime, Derive, GtInternalTranslateJsx, GtInternalVar, InternalGTProviderProps, Num, Plural, RelativeTime, T, Var } from "@generaltranslation/react-core/components";
|
|
6
6
|
import React, { ReactNode } from "react";
|
|
7
7
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
8
|
-
import { I18nCacheConstructorParams } from "gt-i18n/internal/types";
|
|
8
|
+
import { I18nCacheConstructorParams, LocaleCandidates as LocaleCandidates$1, WritableConditionStoreInterface } from "gt-i18n/internal/types";
|
|
9
9
|
import { GTTranslationOptions, RuntimeTranslationOptions, SyncResolutionFunction, SyncResolutionFunctionWithFallback } from "gt-i18n/types";
|
|
10
10
|
|
|
11
11
|
//#region src/i18n-cache/types.d.ts
|
|
@@ -50,12 +50,58 @@ type BrowserConditionStoreParams = WritableConditionStoreParams & {
|
|
|
50
50
|
_getEnableI18n?: GetEnableI18n;
|
|
51
51
|
_reload?: ReloadType;
|
|
52
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Condition store implementation for Browser.
|
|
55
|
+
*/
|
|
56
|
+
declare class BrowserConditionStore implements WritableConditionStoreInterface {
|
|
57
|
+
private customReload;
|
|
58
|
+
private customGetLocale?;
|
|
59
|
+
private customGetRegion?;
|
|
60
|
+
private customGetEnableI18n?;
|
|
61
|
+
constructor(config: BrowserConditionStoreParams);
|
|
62
|
+
getLocale: () => string;
|
|
63
|
+
setLocale: (locale: LocaleCandidates$1) => void;
|
|
64
|
+
getRegion: () => string | undefined;
|
|
65
|
+
setRegion: (region: string | undefined) => void;
|
|
66
|
+
getEnableI18n: () => boolean;
|
|
67
|
+
setEnableI18n: (enableI18n: boolean) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Soft locale update
|
|
70
|
+
*/
|
|
71
|
+
updateLocale: (locale: LocaleCandidates$1) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Soft region update
|
|
74
|
+
*/
|
|
75
|
+
updateRegion: (region: string | undefined) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Soft enableI18n update
|
|
78
|
+
*/
|
|
79
|
+
updateEnableI18n: (enableI18n: boolean) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Condition store updates come from either the server or the client.
|
|
82
|
+
* Trigger this reload when we update a value in the condition store from
|
|
83
|
+
* the client.
|
|
84
|
+
*/
|
|
85
|
+
reload: () => void;
|
|
86
|
+
}
|
|
53
87
|
//#endregion
|
|
54
88
|
//#region src/condition-store/createBrowserConditionStore.d.ts
|
|
55
89
|
type CreateBrowserConditionStoreParams = Omit<BrowserConditionStoreParams, 'locale' | 'enableI18n'> & {
|
|
56
90
|
locale?: LocaleCandidates;
|
|
57
91
|
enableI18n?: boolean;
|
|
58
92
|
};
|
|
93
|
+
/**
|
|
94
|
+
* Factory to create a BrowserConditionStore for Singleton
|
|
95
|
+
*
|
|
96
|
+
* This exists so we can keep the locale param as required in the constructor
|
|
97
|
+
*
|
|
98
|
+
* Server-provided props are the first candidates for hydration consistency.
|
|
99
|
+
* Cookies fill in missing values to persist state across page reloads.
|
|
100
|
+
*
|
|
101
|
+
* Cookie names come from the I18nConfig singleton so custom names passed to
|
|
102
|
+
* initializeGT() apply here without being threaded through provider props.
|
|
103
|
+
*/
|
|
104
|
+
declare function createOrUpdateBrowserConditionStore$1(config: CreateBrowserConditionStoreParams): BrowserConditionStore;
|
|
59
105
|
//#endregion
|
|
60
106
|
//#region src/setup/initializeGTSPA.d.ts
|
|
61
107
|
type InitializeGTSPAParams = I18nConfigParams & BrowserI18nCacheParams & CreateBrowserConditionStoreParams;
|
|
@@ -266,8 +312,10 @@ type RegionSelectorProps = {
|
|
|
266
312
|
//#endregion
|
|
267
313
|
//#region src/index.server.d.ts
|
|
268
314
|
type InitializeGTSPA = typeof initializeGTSPA$1;
|
|
315
|
+
type CreateOrUpdateBrowserConditionStore = typeof createOrUpdateBrowserConditionStore$1;
|
|
269
316
|
declare const initializeGTSPA: InitializeGTSPA;
|
|
317
|
+
declare const createOrUpdateBrowserConditionStore: CreateOrUpdateBrowserConditionStore;
|
|
270
318
|
declare function Tx(_props: TxProps): Promise<ReactNode>;
|
|
271
319
|
//#endregion
|
|
272
|
-
export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RenderPipeline, type RenderPreparedT, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
|
|
320
|
+
export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RenderPipeline, type RenderPreparedT, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createOrUpdateBrowserConditionStore, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
|
|
273
321
|
//# sourceMappingURL=index.server.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.d.mts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/utils/TxProps.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/provider/GTProviderProps.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"mappings":";;;;;;;;;;;;;;KAGY,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;AFfjC;;KEqBY,2BAAA,GAA8B,4BAAA;EACxC,UAAA,GAAa,SAAA;EACb,UAAA,GAAa,SAAA;EACb,cAAA,GAAiB,aAAA;EACjB,OAAA,GAAU,UAAA;AAAA;;;
|
|
1
|
+
{"version":3,"file":"index.server.d.mts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/utils/TxProps.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/provider/GTProviderProps.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"mappings":";;;;;;;;;;;;;;KAGY,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;AFfjC;;KEqBY,2BAAA,GAA8B,4BAAA;EACxC,UAAA,GAAa,SAAA;EACb,UAAA,GAAa,SAAA;EACb,cAAA,GAAiB,aAAA;EACjB,OAAA,GAAU,UAAA;AAAA;;;AFvBZ;cE6Ba,qBAAA,YAAiC,+BAAA;EAAA,QACpC,YAAA;EAAA,QACA,eAAA;EAAA,QACA,eAAA;EAAA,QACA,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AAG,MAAA,EAAQ,OAAA,GAAU,OAAA,CAAQ,SAAA"}
|
package/dist/index.server.mjs
CHANGED
|
@@ -269,6 +269,13 @@ function RegionSelector({ regions: _regions, customMapping, prioritizeCurrentLoc
|
|
|
269
269
|
}
|
|
270
270
|
//#endregion
|
|
271
271
|
//#region src/index.server.ts
|
|
272
|
+
const createBrowserConditionStoreServerError = createDiagnosticMessage({
|
|
273
|
+
source: "gt-react",
|
|
274
|
+
severity: "Error",
|
|
275
|
+
whatHappened: "createOrUpdateBrowserConditionStore() cannot be called from the server runtime entry point",
|
|
276
|
+
why: "createOrUpdateBrowserConditionStore() initializes browser-only condition state.",
|
|
277
|
+
fix: "Call createOrUpdateBrowserConditionStore() from the browser runtime entry point."
|
|
278
|
+
});
|
|
272
279
|
const initializeGTSPA = async () => {
|
|
273
280
|
throw new Error(createDiagnosticMessage({
|
|
274
281
|
source: "gt-react",
|
|
@@ -278,10 +285,13 @@ const initializeGTSPA = async () => {
|
|
|
278
285
|
fix: "Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point."
|
|
279
286
|
}));
|
|
280
287
|
};
|
|
288
|
+
const createOrUpdateBrowserConditionStore = () => {
|
|
289
|
+
throw new Error(createBrowserConditionStoreServerError);
|
|
290
|
+
};
|
|
281
291
|
async function Tx(_props) {
|
|
282
292
|
throw new Error("Tx is only supported via RSC");
|
|
283
293
|
}
|
|
284
294
|
//#endregion
|
|
285
|
-
export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, RegionSelector, RelativeTime, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
|
|
295
|
+
export { Branch, Currency, DateTime, Derive, ServerGTProvider as GTProvider, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, LocaleSelector, Num, Plural, ReactI18nCache, RegionSelector, RelativeTime, T, Tx, Var, createOrUpdateBrowserConditionStore, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
|
|
286
296
|
|
|
287
297
|
//# sourceMappingURL=index.server.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.mjs","names":["useSetLocale","useSetRegion","useSetLocale"],"sources":["../../core/dist/api-BOEGbEF6.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(config: InitializeGTParams): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"🇺🇸\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAA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wB;EACtB,QAAQ;EACR,UAAU;EACV,cACE;EACF,KAAK;EACL,KAAK;EACN,CAAC,CACH;;AAuBH,eAAsB,GAAG,QAAqC;AAC5D,OAAM,IAAI,MAAM,+BAA+B"}
|
|
1
|
+
{"version":3,"file":"index.server.mjs","names":["useSetLocale","useSetRegion","useSetLocale"],"sources":["../../core/dist/api-BOEGbEF6.mjs","../src/setup/runtimeCredentials.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/hooks/useHandleMissingTranslations.ts","../src/provider/ServerGTProvider.tsx","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/index.server.ts"],"sourcesContent":["//#region src/settings/settings.ts\nconst libraryDefaultLocale = \"en\";\nconst defaultTimeout = 6e4;\n//#endregion\n//#region src/logging/diagnostics.ts\nfunction ensureSentence(text) {\n\tconst trimmed = text.trim();\n\tif (!trimmed) return \"\";\n\treturn /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\nfunction stripSentence(text) {\n\tconst trimmed = text.trim();\n\tlet end = trimmed.length;\n\twhile (end > 0) {\n\t\tconst char = trimmed[end - 1];\n\t\tif (char !== \".\" && char !== \"!\" && char !== \"?\") break;\n\t\tend -= 1;\n\t}\n\treturn trimmed.slice(0, end);\n}\nfunction lowercaseFirstWord(text) {\n\treturn text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());\n}\nfunction formatDetails(details) {\n\tif (!details) return \"\";\n\tconst detailText = Array.isArray(details) ? details.join(\", \") : details;\n\tif (!detailText.trim()) return \"\";\n\treturn ensureSentence(`Details: ${detailText}`);\n}\nfunction formatDiagnosticErrorDetails(error) {\n\tif (error == null) return void 0;\n\treturn String(error);\n}\nfunction createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {\n\tconst prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : \"\";\n\tconst whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;\n\tconst shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n\tconst messageParts = [\n\t\twhatAndWhy,\n\t\treassurance,\n\t\tshouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,\n\t\tshouldCombineWayOut ? void 0 : wayOut,\n\t\tformatDetails(details)\n\t].filter((part) => !!part).map(ensureSentence);\n\tif (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);\n\tconst message = messageParts.join(\" \");\n\treturn prefix ? `${prefix} ${message}` : message;\n}\n//#endregion\n//#region src/settings/settingsUrls.ts\nconst defaultCacheUrl = \"https://cdn.gtx.dev\";\nconst defaultBaseUrl = \"https://api2.gtx.dev\";\nconst defaultRuntimeApiUrl = \"https://runtime2.gtx.dev\";\n//#endregion\n//#region src/translate/api.ts\nconst API_VERSION = \"2026-03-06.v1\";\n//#endregion\nexport { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };\n\n//# sourceMappingURL=api-BOEGbEF6.mjs.map","import { getRuntimeEnvironment } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\ntype RuntimeCredentials = Pick<I18nConfigParams, 'projectId' | 'devApiKey'>;\ntype RuntimeEnv = {\n DEV?: boolean;\n VITE_GT_PROJECT_ID?: string;\n VITE_GT_DEV_API_KEY?: string;\n};\n\nexport function addRuntimeCredentials<T extends RuntimeCredentials>(\n config: T\n): T {\n const credentials = getRuntimeCredentials();\n return {\n ...config,\n projectId: config.projectId || credentials.projectId,\n devApiKey: config.devApiKey || credentials.devApiKey,\n };\n}\n\nfunction getRuntimeCredentials(): RuntimeCredentials {\n return {\n projectId:\n readImportMetaVite(\n () =>\n (\n import.meta as ImportMeta & {\n env?: RuntimeEnv;\n }\n ).env?.VITE_GT_PROJECT_ID\n ) || readProcessEnvViteProjectId(),\n devApiKey:\n getRuntimeEnvironment() === 'development'\n ? readImportMetaVite(() =>\n (import.meta as ImportMeta & { env?: RuntimeEnv }).env?.DEV\n ? (import.meta as ImportMeta & { env?: RuntimeEnv }).env\n ?.VITE_GT_DEV_API_KEY\n : undefined\n ) || readProcessEnvViteDevApiKey()\n : undefined,\n };\n}\n\nfunction readImportMetaVite(\n readValue: () => string | undefined\n): string | undefined {\n try {\n return normalizeEnvValue(readValue());\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteProjectId(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);\n } catch {\n return undefined;\n }\n}\n\nfunction readProcessEnvViteDevApiKey(): string | undefined {\n try {\n return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);\n } catch {\n return undefined;\n }\n}\n\nfunction normalizeEnvValue(value: string | undefined): string | undefined {\n return value || undefined;\n}\n","import {\n internalInitializeGTSRA,\n type ReactInitializeGTParams,\n} from '@generaltranslation/react-core/pure';\nimport { addRuntimeCredentials } from './runtimeCredentials';\n\nexport type InitializeGTParams = ReactInitializeGTParams;\n\n/**\n * Initialize GT for server-rendered React runtimes.\n */\nexport function initializeGTSRA(config: InitializeGTParams): void {\n internalInitializeGTSRA(addRuntimeCredentials(config));\n}\n","import { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport { getCookieValue, parseAcceptLanguage } from 'gt-i18n/internal';\n\ntype RequestWithHeaders = Pick<Request, 'headers'>;\n\n/**\n * Resolve the user's locale from a Web Request.\n *\n * The configured locale cookie takes precedence over the Accept-Language\n * header. If neither contains a supported locale, the configured default\n * locale is returned.\n *\n * This is intended for incoming server requests. A Request created in the\n * browser does not automatically include document cookies or Accept-Language.\n */\nexport function parseLocale(request: RequestWithHeaders): string {\n const i18nConfig = getI18nConfig();\n const candidates: string[] = [];\n const cookieLocale = getCookieValue(\n request.headers.get('cookie'),\n i18nConfig.getLocaleCookieName()\n );\n\n if (cookieLocale) {\n candidates.push(cookieLocale);\n }\n\n candidates.push(\n ...parseAcceptLanguage(request.headers.get('accept-language'))\n );\n\n return i18nConfig.resolveSupportedLocale(candidates);\n}\n","import {\n useInternalLocaleSelector,\n useSetLocale,\n} from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a locale selector.\n * Provides locale management utilities for the application.\n *\n * @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.\n *\n * @returns {Object} An object containing locale-related utilities:\n * @returns {string} return.locale - The currently selected locale.\n * @returns {string[]} return.locales - The list of all available locales.\n * @returns {function} return.setLocale - Function to update the current locale.\n * @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.\n */\nexport function useLocaleSelector(locales?: string[]) {\n const setLocale = useSetLocale();\n return { setLocale, ...useInternalLocaleSelector(locales) };\n}\n","import {\n useInternalRegionSelector,\n useSetLocale,\n useSetRegion,\n} from '@generaltranslation/react-core/hooks';\nimport type { InternalRegionSelectorOptions } from '@generaltranslation/react-core/hooks';\n\n/**\n * Gets the list of properties for using a region selector.\n * Provides region management utilities for the application.\n *\n * @param {Object} [options] - Optional configuration object.\n * @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.\n * @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.\n * @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.\n *\n * @returns {Object} An object containing region-related utilities:\n * @returns {string | undefined} return.region - The currently selected region code.\n * @returns {function} return.setRegion - Function to update the current region.\n * @returns {string[]} return.regions - The ordered list of available region codes.\n * @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).\n * @returns {string} return.locale - The current locale.\n * @returns {function} return.setLocale - Function to update the current locale.\n */\nexport function useRegionSelector(options?: InternalRegionSelectorOptions) {\n const setRegion = useSetRegion();\n const setLocale = useSetLocale();\n return { setRegion, setLocale, ...useInternalRegionSelector(options) };\n}\n","'server-only';\n\nimport {\n OnMissingDictionaryEntry,\n OnMissingDictionaryObj,\n OnMissingTranslation,\n} from '@generaltranslation/react-core/pure';\nimport { I18nStore } from '@generaltranslation/react-core/components';\nimport { useMemo } from 'react';\n\n/**\n * Returns handle missing translation callback for server runtime\n * These DO get invoked during server render which is not pure, but this\n * is acceptable for dev hot reload because we MUST trigger a translate\n * call on the server to persist translations\n */\nexport function useHandleMissingTranslations(i18nStore: I18nStore): {\n onMissingTranslation: OnMissingTranslation;\n onMissingDictionaryEntry: OnMissingDictionaryEntry;\n onMissingDictionaryObj: OnMissingDictionaryObj;\n} {\n return useMemo(\n () => ({\n onMissingTranslation: (lookup) => i18nStore.translate(lookup),\n onMissingDictionaryEntry: (lookup) =>\n i18nStore.translateDictionaryEntry(lookup),\n onMissingDictionaryObj: (lookup) =>\n i18nStore.translateDictionaryObject(lookup),\n }),\n [i18nStore]\n );\n}\n","import {\n I18nStore,\n InternalGTProvider,\n} from '@generaltranslation/react-core/components';\nimport { ReadonlyConditionStore } from '@generaltranslation/react-core/pure';\nimport { useMemo, useRef } from 'react';\nimport type { SharedGTProviderProps } from './GTProviderProps';\nimport { useHandleMissingTranslations } from '../hooks/useHandleMissingTranslations';\n\n/**\n * Consumes snapshot from server\n * Implementation for server-side only\n */\nexport function ServerGTProvider({\n locale,\n region,\n enableI18n,\n ...props\n}: SharedGTProviderProps) {\n const conditionStore = useMemo(() => {\n return new ReadonlyConditionStore({ locale, region, enableI18n });\n }, [locale, region, enableI18n]);\n\n const i18nStoreRef = useRef<I18nStore | null>(null);\n if (i18nStoreRef.current == null) {\n i18nStoreRef.current = new I18nStore();\n }\n\n const {\n onMissingTranslation,\n onMissingDictionaryEntry,\n onMissingDictionaryObj,\n } = useHandleMissingTranslations(i18nStoreRef.current);\n\n return (\n <InternalGTProvider\n {...props}\n conditionStore={conditionStore}\n i18nStore={i18nStoreRef.current}\n onMissingTranslation={onMissingTranslation}\n onMissingDictionaryEntry={onMissingDictionaryEntry}\n onMissingDictionaryObj={onMissingDictionaryObj}\n />\n );\n}\n","import type React from 'react';\nimport { InternalLocaleSelector } from '@generaltranslation/react-core/components';\nimport { CustomMapping } from 'generaltranslation/types';\nimport { useLocaleSelector } from './useLocaleSelector';\n\n/**\n * A dropdown component that allows users to select a locale.\n * @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.\n * @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.\n * @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.\n * @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.\n */\nexport function LocaleSelector({\n locales: _locales,\n ...props\n}: LocaleSelectorProps): React.JSX.Element | null {\n // Get locale selector properties\n const { locale, locales, getLocaleProperties, setLocale } =\n useLocaleSelector(_locales);\n\n return (\n <InternalLocaleSelector\n locale={locale}\n locales={locales}\n setLocale={setLocale}\n getLocaleProperties={getLocaleProperties}\n {...props}\n />\n );\n}\n\nexport type LocaleSelectorProps = {\n locales?: string[];\n customNames?: { [key: string]: string };\n customMapping?: CustomMapping;\n [key: string]: any;\n};\n","import type React from 'react';\nimport type { ReactNode } from 'react';\nimport { InternalRegionSelector } from '@generaltranslation/react-core/components';\nimport { useRegionSelector } from './useRegionSelector';\n\n/**\n * A dropdown component that allows users to select a region.\n * @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.\n * @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.\n * @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.\n * @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.\n * @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.\n * @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.\n * @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.\n *\n * @example\n * ```tsx\n * <RegionSelector\n * regions={['US', 'CA']}\n * customMapping={{ US: { name: \"United States\", emoji: \"🇺🇸\" } }}\n * placeholder=\"Select a region\"\n * />\n * ```\n */\nexport function RegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n asLocaleSelector = false,\n ...props\n}: RegionSelectorProps): React.JSX.Element | null {\n // Get region selector properties\n const { region, regions, regionData, locale, setRegion, setLocale } =\n useRegionSelector({\n regions: _regions,\n customMapping,\n prioritizeCurrentLocaleRegion,\n sortRegionsAlphabetically,\n });\n\n const changeRegion = (region: string) => {\n if (asLocaleSelector) {\n const regionLocale = regionData.get(region)?.locale;\n // setRegion reloads the page; update the locale cookie first\n if (regionLocale && locale !== regionLocale) setLocale(regionLocale);\n }\n setRegion(region);\n };\n\n return (\n <InternalRegionSelector\n region={region}\n regions={regions}\n regionData={regionData}\n setRegion={changeRegion}\n {...props}\n />\n );\n}\n\nexport type RegionSelectorProps = {\n regions?: string[];\n placeholder?: ReactNode;\n customMapping?: {\n [region: string]:\n | string\n | { name?: string; emoji?: string; locale?: string };\n };\n prioritizeCurrentLocaleRegion?: boolean;\n sortRegionsAlphabetically?: boolean;\n asLocaleSelector?: boolean;\n [key: string]: any;\n};\n","'use client';\n\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport type { ReactNode } from 'react';\nimport type { TxProps } from './utils/TxProps';\n\n// SSR/context-capable React runtime surface. This entrypoint may import hooks,\n// providers, and context modules, so it must be consumed as a client boundary by\n// React Server Component frameworks.\n\nexport { initializeGTSRA as initializeGT } from './setup/initializeGTSRA';\nexport { parseLocale } from './functions/parseLocale';\nexport { useLocaleSelector } from './components/useLocaleSelector';\nexport { useRegionSelector } from './components/useRegionSelector';\n\ntype InitializeGTSPA = typeof import('./setup/initializeGTSPA').initializeGTSPA;\ntype CreateOrUpdateBrowserConditionStore =\n typeof import('./condition-store/createBrowserConditionStore').createOrUpdateBrowserConditionStore;\n\nconst createBrowserConditionStoreServerError = createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'createOrUpdateBrowserConditionStore() cannot be called from the server runtime entry point',\n why: 'createOrUpdateBrowserConditionStore() initializes browser-only condition state.',\n fix: 'Call createOrUpdateBrowserConditionStore() from the browser runtime entry point.',\n});\n\nexport const initializeGTSPA: InitializeGTSPA = async () => {\n throw new Error(\n createDiagnosticMessage({\n source: 'gt-react',\n severity: 'Error',\n whatHappened:\n 'initializeGTSPA() cannot be called from the server runtime entry point',\n why: 'initializeGTSPA() initializes browser-only SPA state and translation cache behavior.',\n fix: 'Use initializeGT() for server-rendered React runtimes or import initializeGTSPA from the browser entry point.',\n })\n );\n};\n\nexport const createOrUpdateBrowserConditionStore: CreateOrUpdateBrowserConditionStore =\n () => {\n throw new Error(createBrowserConditionStoreServerError);\n };\n\n// ===== Components ===== //\nexport { ServerGTProvider as GTProvider } from './provider/ServerGTProvider';\nexport { LocaleSelector } from './components/LocaleSelector';\nexport { RegionSelector } from './components/RegionSelector';\n\n// ===== Components ===== //\nexport {\n Branch,\n Plural,\n Derive,\n GtInternalTranslateJsx,\n GtInternalVar,\n T,\n Currency,\n DateTime,\n RelativeTime,\n Var,\n Num,\n} from '@generaltranslation/react-core/components';\n\nexport async function Tx(_props: TxProps): Promise<ReactNode> {\n throw new Error('Tx is only supported via RSC');\n}\n\n// ===== Hooks ===== //\nexport {\n useLocale,\n useRegion,\n useCustomMapping,\n useDefaultLocale,\n useEnableI18n,\n useLocales,\n useFormatLocales,\n useGT,\n useMessages,\n useTranslations,\n useLocaleDirection,\n useLocaleProperties,\n useSetLocale,\n useSetRegion,\n useSetEnableI18n,\n} from '@generaltranslation/react-core/hooks';\n\n// ===== Functions ===== //\nexport {\n msg,\n decodeMsg,\n decodeOptions,\n derive,\n declareVar,\n decodeVars,\n mFallback,\n gtFallback,\n getFormatLocales,\n getDefaultLocale,\n getLocaleProperties,\n getLocales,\n resolveCanonicalLocale,\n getReactI18nCache,\n getTranslationsSnapshot,\n getVersionId,\n createRenderPipeline,\n setReactI18nCache,\n t,\n} from '@generaltranslation/react-core/pure';\n\nexport type {\n RenderPipeline,\n RenderPreparedT,\n} from '@generaltranslation/react-core/pure';\n\nexport type { SharedGTProviderProps } from './provider/GTProviderProps';\nexport {\n GtInternalRuntimeTranslateJsx,\n GtInternalRuntimeTranslateString,\n} from 'gt-i18n/internal';\nexport type {\n GTTranslationOptions,\n RuntimeTranslationOptions,\n} from 'gt-i18n/types';\nexport type {\n SyncResolutionFunction,\n SyncResolutionFunctionWithFallback,\n} from 'gt-i18n/types';\n\n// ===== Singletons ===== //\nexport {\n ReactI18nCache,\n type ReactI18nCacheParams,\n} from '@generaltranslation/react-core/pure';\n"],"mappings":";;;;;;;;AAKA,SAAS,eAAe,MAAM;CAC7B,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAEvD,SAAS,cAAc,MAAM;CAC5B,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACf,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAER,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAE7B,SAAS,mBAAmB,MAAM;AACjC,QAAO,KAAK,QAAQ,gBAAgB,UAAU,MAAM,aAAa,CAAC;;AAEnE,SAAS,cAAc,SAAS;AAC/B,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ,KAAK,KAAK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IAAI,MAAM,+BAA+B"}
|
package/dist/index.types.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import { I18nConfigParams, ReactI18nCache, ReactI18nCacheParams, ReactInitializeGTParams, RenderPipeline, RenderPreparedT, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, mFallback, msg, resolveCanonicalLocale, setReactI18nCache, t } from "@generaltranslation/react-core/pure";
|
|
3
|
-
import { I18nCacheConstructorParams } from "gt-i18n/internal/types";
|
|
4
|
-
import { GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, LocaleCandidates, WritableConditionStoreParams } from "gt-i18n/internal";
|
|
3
|
+
import { I18nCacheConstructorParams, LocaleCandidates, WritableConditionStoreInterface } from "gt-i18n/internal/types";
|
|
4
|
+
import { GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, LocaleCandidates as LocaleCandidates$1, WritableConditionStoreParams } from "gt-i18n/internal";
|
|
5
5
|
import { GTTranslationOptions, RuntimeTranslationOptions, SyncResolutionFunction, SyncResolutionFunctionWithFallback } from "gt-i18n/types";
|
|
6
6
|
import * as _$_generaltranslation_react_core_hooks0 from "@generaltranslation/react-core/hooks";
|
|
7
7
|
import { InternalRegionSelectorOptions, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocales, useMessages, useRegion, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations } from "@generaltranslation/react-core/hooks";
|
|
@@ -59,12 +59,58 @@ type BrowserConditionStoreParams = WritableConditionStoreParams & {
|
|
|
59
59
|
_getEnableI18n?: GetEnableI18n;
|
|
60
60
|
_reload?: ReloadType;
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Condition store implementation for Browser.
|
|
64
|
+
*/
|
|
65
|
+
declare class BrowserConditionStore implements WritableConditionStoreInterface {
|
|
66
|
+
private customReload;
|
|
67
|
+
private customGetLocale?;
|
|
68
|
+
private customGetRegion?;
|
|
69
|
+
private customGetEnableI18n?;
|
|
70
|
+
constructor(config: BrowserConditionStoreParams);
|
|
71
|
+
getLocale: () => string;
|
|
72
|
+
setLocale: (locale: LocaleCandidates) => void;
|
|
73
|
+
getRegion: () => string | undefined;
|
|
74
|
+
setRegion: (region: string | undefined) => void;
|
|
75
|
+
getEnableI18n: () => boolean;
|
|
76
|
+
setEnableI18n: (enableI18n: boolean) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Soft locale update
|
|
79
|
+
*/
|
|
80
|
+
updateLocale: (locale: LocaleCandidates) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Soft region update
|
|
83
|
+
*/
|
|
84
|
+
updateRegion: (region: string | undefined) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Soft enableI18n update
|
|
87
|
+
*/
|
|
88
|
+
updateEnableI18n: (enableI18n: boolean) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Condition store updates come from either the server or the client.
|
|
91
|
+
* Trigger this reload when we update a value in the condition store from
|
|
92
|
+
* the client.
|
|
93
|
+
*/
|
|
94
|
+
reload: () => void;
|
|
95
|
+
}
|
|
62
96
|
//#endregion
|
|
63
97
|
//#region src/condition-store/createBrowserConditionStore.d.ts
|
|
64
98
|
type CreateBrowserConditionStoreParams = Omit<BrowserConditionStoreParams, 'locale' | 'enableI18n'> & {
|
|
65
|
-
locale?: LocaleCandidates;
|
|
99
|
+
locale?: LocaleCandidates$1;
|
|
66
100
|
enableI18n?: boolean;
|
|
67
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* Factory to create a BrowserConditionStore for Singleton
|
|
104
|
+
*
|
|
105
|
+
* This exists so we can keep the locale param as required in the constructor
|
|
106
|
+
*
|
|
107
|
+
* Server-provided props are the first candidates for hydration consistency.
|
|
108
|
+
* Cookies fill in missing values to persist state across page reloads.
|
|
109
|
+
*
|
|
110
|
+
* Cookie names come from the I18nConfig singleton so custom names passed to
|
|
111
|
+
* initializeGT() apply here without being threaded through provider props.
|
|
112
|
+
*/
|
|
113
|
+
declare function createOrUpdateBrowserConditionStore(config: CreateBrowserConditionStoreParams): BrowserConditionStore;
|
|
68
114
|
//#endregion
|
|
69
115
|
//#region src/setup/initializeGTSPA.d.ts
|
|
70
116
|
type InitializeGTSPAParams = I18nConfigParams & BrowserI18nCacheParams & CreateBrowserConditionStoreParams;
|
|
@@ -263,5 +309,5 @@ declare function BrowserGTProvider(props: SharedGTProviderProps): _$react_jsx_ru
|
|
|
263
309
|
//#region src/index.types.d.ts
|
|
264
310
|
declare function Tx(_props: TxProps): Promise<ReactNode>;
|
|
265
311
|
//#endregion
|
|
266
|
-
export { Branch, Currency, type CurrencyProps, DateTime, type DateTimeProps, Derive, BrowserGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, type JsxTranslationOptions, LocaleSelector, Num, type NumProps, Plural, type PluralProps, type PreparedT, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RelativeTimeFormatOptions, type RelativeTimeProps, type RenderPipeline, type RenderPreparedT, type RenderVariable, type ResolvedCurrencyProps, type ResolvedDateTimeProps, type ResolvedNumProps, type ResolvedPluralProps, type ResolvedRelativeTimeProps, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
|
|
312
|
+
export { Branch, Currency, type CurrencyProps, DateTime, type DateTimeProps, Derive, BrowserGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, type JsxTranslationOptions, LocaleSelector, Num, type NumProps, Plural, type PluralProps, type PreparedT, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RelativeTimeFormatOptions, type RelativeTimeProps, type RenderPipeline, type RenderPreparedT, type RenderVariable, type ResolvedCurrencyProps, type ResolvedDateTimeProps, type ResolvedNumProps, type ResolvedPluralProps, type ResolvedRelativeTimeProps, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createOrUpdateBrowserConditionStore, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
|
|
267
313
|
//# sourceMappingURL=index.types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.d.cts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/utils/TxProps.ts","../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/provider/GTProviderProps.ts","../src/provider/BrowserGTProvider.tsx","../src/index.types.ts"],"mappings":";;;;;;;;;;;;KAEY,OAAA,GAAU,MAAA,SAAe,SAAA;EACnC,QAAA,EAAU,SAAA;EACV,OAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;;;KCHU,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;;AHhBjC;KGsBY,2BAAA,GAA8B,4BAAA;EACxC,UAAA,GAAa,SAAA;EACb,UAAA,GAAa,SAAA;EACb,cAAA,GAAiB,aAAA;EACjB,OAAA,GAAU,UAAA;AAAA;;;
|
|
1
|
+
{"version":3,"file":"index.types.d.cts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/utils/TxProps.ts","../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/provider/GTProviderProps.ts","../src/provider/BrowserGTProvider.tsx","../src/index.types.ts"],"mappings":";;;;;;;;;;;;KAEY,OAAA,GAAU,MAAA,SAAe,SAAA;EACnC,QAAA,EAAU,SAAA;EACV,OAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;;;KCHU,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;;AHhBj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ANGED
|
@@ -5,7 +5,7 @@ import { InternalRegionSelectorOptions, useCustomMapping, useDefaultLocale, useE
|
|
|
5
5
|
import { Branch, Currency, DateTime, Derive, GtInternalTranslateJsx, GtInternalVar, InternalGTProviderProps, Num, Plural, RelativeTime, T, Var } from "@generaltranslation/react-core/components";
|
|
6
6
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
7
7
|
import React, { ReactNode } from "react";
|
|
8
|
-
import { I18nCacheConstructorParams } from "gt-i18n/internal/types";
|
|
8
|
+
import { I18nCacheConstructorParams, LocaleCandidates as LocaleCandidates$1, WritableConditionStoreInterface } from "gt-i18n/internal/types";
|
|
9
9
|
import { GTTranslationOptions, RuntimeTranslationOptions, SyncResolutionFunction, SyncResolutionFunctionWithFallback } from "gt-i18n/types";
|
|
10
10
|
import { CurrencyProps, DateTimeProps, JsxTranslationOptions, NumProps, PluralProps, PreparedT, RelativeTimeFormatOptions, RelativeTimeProps, RenderVariable, ResolvedCurrencyProps, ResolvedDateTimeProps, ResolvedNumProps, ResolvedPluralProps, ResolvedRelativeTimeProps } from "@generaltranslation/react-core/components-rsc";
|
|
11
11
|
|
|
@@ -59,12 +59,58 @@ type BrowserConditionStoreParams = WritableConditionStoreParams & {
|
|
|
59
59
|
_getEnableI18n?: GetEnableI18n;
|
|
60
60
|
_reload?: ReloadType;
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Condition store implementation for Browser.
|
|
64
|
+
*/
|
|
65
|
+
declare class BrowserConditionStore implements WritableConditionStoreInterface {
|
|
66
|
+
private customReload;
|
|
67
|
+
private customGetLocale?;
|
|
68
|
+
private customGetRegion?;
|
|
69
|
+
private customGetEnableI18n?;
|
|
70
|
+
constructor(config: BrowserConditionStoreParams);
|
|
71
|
+
getLocale: () => string;
|
|
72
|
+
setLocale: (locale: LocaleCandidates$1) => void;
|
|
73
|
+
getRegion: () => string | undefined;
|
|
74
|
+
setRegion: (region: string | undefined) => void;
|
|
75
|
+
getEnableI18n: () => boolean;
|
|
76
|
+
setEnableI18n: (enableI18n: boolean) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Soft locale update
|
|
79
|
+
*/
|
|
80
|
+
updateLocale: (locale: LocaleCandidates$1) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Soft region update
|
|
83
|
+
*/
|
|
84
|
+
updateRegion: (region: string | undefined) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Soft enableI18n update
|
|
87
|
+
*/
|
|
88
|
+
updateEnableI18n: (enableI18n: boolean) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Condition store updates come from either the server or the client.
|
|
91
|
+
* Trigger this reload when we update a value in the condition store from
|
|
92
|
+
* the client.
|
|
93
|
+
*/
|
|
94
|
+
reload: () => void;
|
|
95
|
+
}
|
|
62
96
|
//#endregion
|
|
63
97
|
//#region src/condition-store/createBrowserConditionStore.d.ts
|
|
64
98
|
type CreateBrowserConditionStoreParams = Omit<BrowserConditionStoreParams, 'locale' | 'enableI18n'> & {
|
|
65
99
|
locale?: LocaleCandidates;
|
|
66
100
|
enableI18n?: boolean;
|
|
67
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* Factory to create a BrowserConditionStore for Singleton
|
|
104
|
+
*
|
|
105
|
+
* This exists so we can keep the locale param as required in the constructor
|
|
106
|
+
*
|
|
107
|
+
* Server-provided props are the first candidates for hydration consistency.
|
|
108
|
+
* Cookies fill in missing values to persist state across page reloads.
|
|
109
|
+
*
|
|
110
|
+
* Cookie names come from the I18nConfig singleton so custom names passed to
|
|
111
|
+
* initializeGT() apply here without being threaded through provider props.
|
|
112
|
+
*/
|
|
113
|
+
declare function createOrUpdateBrowserConditionStore(config: CreateBrowserConditionStoreParams): BrowserConditionStore;
|
|
68
114
|
//#endregion
|
|
69
115
|
//#region src/setup/initializeGTSPA.d.ts
|
|
70
116
|
type InitializeGTSPAParams = I18nConfigParams & BrowserI18nCacheParams & CreateBrowserConditionStoreParams;
|
|
@@ -263,5 +309,5 @@ declare function BrowserGTProvider(props: SharedGTProviderProps): _$react_jsx_ru
|
|
|
263
309
|
//#region src/index.types.d.ts
|
|
264
310
|
declare function Tx(_props: TxProps): Promise<ReactNode>;
|
|
265
311
|
//#endregion
|
|
266
|
-
export { Branch, Currency, type CurrencyProps, DateTime, type DateTimeProps, Derive, BrowserGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, type JsxTranslationOptions, LocaleSelector, Num, type NumProps, Plural, type PluralProps, type PreparedT, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RelativeTimeFormatOptions, type RelativeTimeProps, type RenderPipeline, type RenderPreparedT, type RenderVariable, type ResolvedCurrencyProps, type ResolvedDateTimeProps, type ResolvedNumProps, type ResolvedPluralProps, type ResolvedRelativeTimeProps, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
|
|
312
|
+
export { Branch, Currency, type CurrencyProps, DateTime, type DateTimeProps, Derive, BrowserGTProvider as GTProvider, type GTTranslationOptions, GtInternalRuntimeTranslateJsx, GtInternalRuntimeTranslateString, GtInternalTranslateJsx, GtInternalVar, type JsxTranslationOptions, LocaleSelector, Num, type NumProps, Plural, type PluralProps, type PreparedT, ReactI18nCache, type ReactI18nCacheParams, RegionSelector, RelativeTime, type RelativeTimeFormatOptions, type RelativeTimeProps, type RenderPipeline, type RenderPreparedT, type RenderVariable, type ResolvedCurrencyProps, type ResolvedDateTimeProps, type ResolvedNumProps, type ResolvedPluralProps, type ResolvedRelativeTimeProps, type RuntimeTranslationOptions, type SharedGTProviderProps, type SyncResolutionFunction, type SyncResolutionFunctionWithFallback, T, Tx, Var, createOrUpdateBrowserConditionStore, createRenderPipeline, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getDefaultLocale, getFormatLocales, getLocaleProperties, getLocales, getReactI18nCache, getTranslationsSnapshot, getVersionId, gtFallback, initializeGTSRA as initializeGT, initializeGTSPA, mFallback, msg, parseLocale, resolveCanonicalLocale, setReactI18nCache, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleDirection, useLocaleProperties, useLocaleSelector, useLocales, useMessages, useRegion, useRegionSelector, useSetEnableI18n, useSetLocale, useSetRegion, useTranslations };
|
|
267
313
|
//# sourceMappingURL=index.types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.d.mts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/utils/TxProps.ts","../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/provider/GTProviderProps.ts","../src/provider/BrowserGTProvider.tsx","../src/index.types.ts"],"mappings":";;;;;;;;;;;;KAEY,OAAA,GAAU,MAAA,SAAe,SAAA;EACnC,QAAA,EAAU,SAAA;EACV,OAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;;;KCHU,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;;AHhBjC;KGsBY,2BAAA,GAA8B,4BAAA;EACxC,UAAA,GAAa,SAAA;EACb,UAAA,GAAa,SAAA;EACb,cAAA,GAAiB,aAAA;EACjB,OAAA,GAAU,UAAA;AAAA;;;
|
|
1
|
+
{"version":3,"file":"index.types.d.mts","names":["CustomMapping","LocaleProperties","Partial","Record","code","name","nativeName","languageCode","languageName","nativeLanguageName","nameWithRegionCode","nativeNameWithRegionCode","regionCode","regionName","nativeRegionName","scriptCode","scriptName","nativeScriptName","maximizedCode","maximizedName","nativeMaximizedName","minimizedCode","minimizedName","nativeMinimizedName","emoji","CustomRegionMapping","region","locale","getRegionProperties","defaultLocale","customMapping","CutoffFormatStyle","TerminatorOptions","terminator","separator","CutoffFormatOptions","maxChars","style","VariableType","Variable","k","i","v","HTML_CONTENT_PROPS","pl","ti","alt","arl","arb","ard","HtmlContentPropKeysRecord","HtmlContentPropValuesRecord","GTProp","JsxChildren","b","t","JsxElement","d","c","JsxChild","StringFormat","DataFormat","StringContent","IcuMessage","StringMessage","I18nextMessage","Content","FormatVariables","Date","S","_","a","f","g","h","l","m","n","o","p","r","s","u","x","y"],"sources":["../src/utils/TxProps.ts","../src/i18n-cache/types.ts","../src/i18n-cache/BrowserI18nCache.ts","../src/condition-store/BrowserConditionStore.ts","../src/condition-store/createBrowserConditionStore.ts","../src/setup/initializeGTSPA.ts","../src/setup/initializeGTSRA.ts","../src/functions/parseLocale.ts","../../format/dist/types-COaQnqVZ.d.cts","../src/components/useLocaleSelector.ts","../src/components/useRegionSelector.ts","../src/components/LocaleSelector.tsx","../src/components/RegionSelector.tsx","../src/provider/GTProviderProps.ts","../src/provider/BrowserGTProvider.tsx","../src/index.types.ts"],"mappings":";;;;;;;;;;;;KAEY,OAAA,GAAU,MAAA,SAAe,SAAA;EACnC,QAAA,EAAU,SAAA;EACV,OAAA;EACA,MAAA;EACA,QAAA;AAAA;;;;;;KCHU,SAAA;AAAA,KACA,SAAA;AAAA,KACA,aAAA;;;;;;KAOA,cAAA;EACV,iBAAA;EACA,gBAAA;AAAA;;;;;;KCIU,sBAAA,GAAyB,0BAAA;EACnC,cAAA,GAAiB,cAAA;AAAA;;;KCNd,oCAAA;EACH,MAAA;EACA,MAAA;EACA,UAAA;AAAA;AAAA,KAEU,UAAA,IAAc,KAAA,EAAO,oCAAA;;;;AHhBjC;KGsBY,2BAAA,GAA8B,4BAAA;EACxC,UAAA,GAAa,SAAA;EACb,UAAA,GAAa,SAAA;EACb,cAAA,GAAiB,aAAA;EACjB,OAAA,GAAU,UAAA;AAAA;;;;cAMC,qBAAA,YAAiC,+BAAA;EAAA,QACpC,YAAA;EAAA,QACA,eAAA;EAAA,QACA,eAAA;EAAA,QACA,mBAAA;cAEI,MAAA,EAAQ,2BAAA;EAsBpB,SAAA;EAIA,SAAA,GAAa,MAAA,EAAQ,kBAAA;EASrB,SAAA;EAQA,SAAA,GAAa,MAAA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;;iBCbzD,cAAA,CAAA;EACd,OAAA,EAAS,QAAA;EAAA,GACN;AAAA,GACF,mBAAA,GAAsB,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA,KAgBvB,mBAAA;EACV,OAAA;EACA,WAAA;IAAA,CAAiB,GAAA;EAAA;EACjB,aAAA,GAAgB,aAAA;EAAA,CACf,GAAA;AAAA;;;;;;;;;;;;;AXjCH;;;;;;;;;iBYsBgB,cAAA,CAAA;EACd,OAAA,EAAS,QAAA;EACT,aAAA;EACA,6BAAA;EACA,yBAAA;EACA,gBAAA;EAAA,GACG;AAAA,GACF,mBAAA,GAAsB,KAAA,CAAM,GAAA,CAAI,OAAA;AAAA,KA8BvB,mBAAA;EACV,OAAA;EACA,WAAA,GAAc,SAAA;EACd,aAAA;IAAA,CACG,MAAA;MAEK,IAAA;MAAe,KAAA;MAAgB,MAAA;IAAA;EAAA;EAEvC,6BAAA;EACA,yBAAA;EACA,gBAAA;EAAA,CACC,GAAA;AAAA;;;;;;;;;KC/DS,qBAAA,GAAwB,IAAA,CAClC,uBAAA,oCAGA,IAAA,CAAK,2BAAA;EACH,MAAA;AAAA;;;;;;;iBCFY,iBAAA,CAAkB,KAAA,EAAO,qBAAA,GAAqB,oBAAA,CAAA,GAAA,CAAA,OAAA;;;iBCoBxC,EAAA,CAAG,MAAA,EAAQ,OAAA,GAAU,OAAA,CAAQ,SAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gt-react",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.13",
|
|
4
4
|
"description": "A React library for automatic internationalization.",
|
|
5
5
|
"main": "./dist/index.server.cjs",
|
|
6
6
|
"module": "./dist/index.server.mjs",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"react-dom": ">=18.0.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
20
|
+
"generaltranslation": "9.0.3",
|
|
21
|
+
"@generaltranslation/react-core": "11.0.13",
|
|
22
|
+
"gt-i18n": "1.0.7"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|