generaltranslation 8.2.7 → 8.2.8
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 +6 -0
- package/dist/id.d.cts +1 -1
- package/dist/id.d.mts +1 -1
- package/dist/index.cjs +191 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -4
- package/dist/index.d.mts +66 -4
- package/dist/index.mjs +191 -55
- package/dist/index.mjs.map +1 -1
- package/dist/{internal-CTeI8uLd.mjs → internal-B3QbyI_5.mjs} +48 -2
- package/dist/internal-B3QbyI_5.mjs.map +1 -0
- package/dist/{internal-PCKq4YMW.cjs → internal-DIHQF9gs.cjs} +59 -1
- package/dist/internal-DIHQF9gs.cjs.map +1 -0
- package/dist/internal.cjs +3 -1
- package/dist/internal.d.cts +23 -2
- package/dist/internal.d.mts +23 -2
- package/dist/internal.mjs +2 -2
- package/dist/{types-D2fTTTvZ.d.cts → types-BJdoI1d1.d.cts} +6 -2
- package/dist/{types-fUW4_Ole.d.mts → types-DazaDJbs.d.mts} +6 -2
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +1 -1
- package/dist/internal-CTeI8uLd.mjs.map +0 -1
- package/dist/internal-PCKq4YMW.cjs.map +0 -1
|
@@ -279,6 +279,52 @@ function decode(base64) {
|
|
|
279
279
|
return new TextDecoder().decode(bytes);
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
|
+
//#region src/utils/isSupportedFileFormatTransform.ts
|
|
283
|
+
const SUPPORTED_TRANSFORMATIONS = {
|
|
284
|
+
GTJSON: ["GTJSON"],
|
|
285
|
+
JSON: ["JSON"],
|
|
286
|
+
PO: ["PO"],
|
|
287
|
+
POT: ["POT", "PO"],
|
|
288
|
+
YAML: ["YAML"],
|
|
289
|
+
MDX: ["MDX"],
|
|
290
|
+
MD: ["MD"],
|
|
291
|
+
TS: ["TS"],
|
|
292
|
+
JS: ["JS"],
|
|
293
|
+
HTML: ["HTML"],
|
|
294
|
+
TXT: ["TXT"],
|
|
295
|
+
TWILIO_CONTENT_JSON: ["TWILIO_CONTENT_JSON"]
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* This function checks if a file format transformation is supported during translation
|
|
299
|
+
* @param from - The source file format
|
|
300
|
+
* @param to - The target file format
|
|
301
|
+
* @returns True if the transformation is supported, false otherwise
|
|
302
|
+
*/
|
|
303
|
+
function isSupportedFileFormatTransform(from, to) {
|
|
304
|
+
return SUPPORTED_TRANSFORMATIONS[from]?.includes(to) ?? false;
|
|
305
|
+
}
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/translate/utils/validateFileFormatTransform.ts
|
|
308
|
+
/**
|
|
309
|
+
* Returns a user-facing validation error when a requested file format transform
|
|
310
|
+
* is missing source format context or is not currently supported.
|
|
311
|
+
*/
|
|
312
|
+
function getFileFormatTransformError(file) {
|
|
313
|
+
if (!file.transformFormat) return void 0;
|
|
314
|
+
const fileLabel = file.fileName ?? file.fileId ?? "unknown file";
|
|
315
|
+
if (!file.fileFormat) return `fileFormat is required when transformFormat is provided for ${fileLabel}`;
|
|
316
|
+
if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Validates file format transforms before sending upload/enqueue requests.
|
|
320
|
+
*/
|
|
321
|
+
function validateFileFormatTransforms(files) {
|
|
322
|
+
for (const file of files) {
|
|
323
|
+
const error = getFileFormatTransformError(file);
|
|
324
|
+
if (error) throw new Error(error);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
282
328
|
//#region src/derive/utils/traverseIcu.ts
|
|
283
329
|
/**
|
|
284
330
|
* Given an ICU string, traverse the AST and call the visitor function for each element that matches the type T
|
|
@@ -769,6 +815,6 @@ function sanitizeJsxChildren(childrenAsObjects) {
|
|
|
769
815
|
return Array.isArray(childrenAsObjects) ? childrenAsObjects.map(sanitizeChild) : sanitizeChild(childrenAsObjects);
|
|
770
816
|
}
|
|
771
817
|
//#endregion
|
|
772
|
-
export {
|
|
818
|
+
export { isSupportedFileFormatTransform as A, intlCache as B, declareStatic as C, VAR_IDENTIFIER as D, decodeVars as E, isAcceptedPluralForm as F, libraryDefaultLocale as H, pluralForms as I, defaultBaseUrl as L, encode as M, minifyVariableType as N, VAR_NAME_IDENTIFIER as O, _getPluralForm as P, defaultCacheUrl as R, indexVars as S, declareVar as T, defaultTimeout as V, isNewVariableObject as _, getNewJsxChild as a, condenseVars as b, getNewVariableObject as c, getOldGTProp as d, getOldJsxChild as f, getOldVariableType as g, getOldVariableObject as h, getNewGTProp as i, decode as j, validateFileFormatTransforms as k, getNewVariableType as l, getOldJsxElement as m, oldHashString as n, getNewJsxChildren as o, getOldJsxChildren as p, getNewBranchType as r, getNewJsxElement as s, oldHashJsxChildren as t, getOldBranchType as u, isOldJsxChildren as v, derive as w, extractVars as x, isOldVariableObject as y, defaultRuntimeApiUrl as z };
|
|
773
819
|
|
|
774
|
-
//# sourceMappingURL=internal-
|
|
820
|
+
//# sourceMappingURL=internal-B3QbyI_5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-B3QbyI_5.mjs","names":["TYPE","TYPE","stringify"],"sources":["../src/settings/settings.ts","../src/errors/formattingErrors.ts","../src/formatting/custom-formats/CutoffFormat/constants.ts","../src/formatting/custom-formats/CutoffFormat/CutoffFormat.ts","../src/cache/IntlCache.ts","../src/settings/settingsUrls.ts","../src/settings/plurals.ts","../src/locales/getPluralForm.ts","../src/utils/minify.ts","../src/utils/base64.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/derive/utils/traverseIcu.ts","../src/derive/utils/constants.ts","../src/derive/utils/regex.ts","../src/derive/utils/traverseHelpers.ts","../src/derive/decodeVars.ts","../src/derive/utils/sanitizeVar.ts","../src/derive/declareVar.ts","../src/derive/derive.ts","../src/derive/indexVars.ts","../src/derive/extractVars.ts","../src/derive/condenseVars.ts","../src/backwards-compatability/typeChecking.ts","../src/backwards-compatability/dataConversion.ts","../src/backwards-compatability/oldHashJsxChildren.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\n","export const createInvalidCutoffStyleError = (style: string) =>\n `generaltranslation Formatting Error: Invalid cutoff style: ${style}.`;\n","import { CutoffFormatStyle, ResolvedTerminatorOptions } from './types';\n\nexport const DEFAULT_CUTOFF_FORMAT_STYLE: CutoffFormatStyle = 'ellipsis';\n\nexport const DEFAULT_TERMINATOR_KEY = 'DEFAULT_TERMINATOR_KEY';\n\nexport const TERMINATOR_MAP: Record<\n CutoffFormatStyle,\n Record<string | typeof DEFAULT_TERMINATOR_KEY, ResolvedTerminatorOptions>\n> = {\n ellipsis: {\n fr: {\n terminator: '…',\n separator: '\\u202F',\n },\n zh: {\n terminator: '……',\n separator: undefined,\n },\n ja: {\n terminator: '……',\n separator: undefined,\n },\n [DEFAULT_TERMINATOR_KEY]: {\n terminator: '…',\n separator: undefined,\n },\n },\n none: {\n [DEFAULT_TERMINATOR_KEY]: {\n terminator: undefined,\n separator: undefined,\n },\n },\n};\n","import { createInvalidCutoffStyleError } from '../../../errors/formattingErrors';\nimport { libraryDefaultLocale } from '../../../settings/settings';\nimport {\n DEFAULT_CUTOFF_FORMAT_STYLE,\n DEFAULT_TERMINATOR_KEY,\n TERMINATOR_MAP,\n} from './constants';\nimport {\n CutoffFormat,\n CutoffFormatOptions,\n CutoffFormatStyle,\n PostpendedCutoffParts,\n PrependedCutoffParts,\n ResolvedCutoffFormatOptions,\n ResolvedTerminatorOptions,\n} from './types';\n\nexport class CutoffFormatConstructor implements CutoffFormat {\n private locale: string;\n private options: ResolvedCutoffFormatOptions;\n private additionLength: number;\n /**\n * Constructor\n * @param {string | string[]} locales - The locales to use for formatting.\n * @param {CutoffFormatOptions} options - The options for formatting.\n * @param {number} [option.maxChars] - The maximum number of characters to display.\n * - Undefined values are treated as no cutoff.\n * - Negative values follow .slice() behavior and terminator will be added before the value.\n * - 0 will result in an empty string.\n * - If cutoff results in an empty string, no terminator is added.\n * @param {CutoffFormatStyle} [option.style='ellipsis'] - The style of the terminator.\n * @param {string} [option.terminator] - Optional override the terminator to use.\n * @param {string} [option.separator] - Optional override the separator to use between the terminator and the value.\n * - If no terminator is provided, then separator is ignored.\n *\n * @example\n * const format = new CutoffFormat('en', { maxChars: 5 });\n * format.format('Hello, world!'); // 'Hello...'\n *\n * const format = new CutoffFormat('en', { maxChars: -3 });\n * format.format('Hello, world!'); // '...ld!'\n */\n constructor(\n locales: Intl.LocalesArgument,\n options: CutoffFormatOptions = {}\n ) {\n // Determine locale (this replicates Intl.NumberFormat behavior including silent failure)\n try {\n // Normalize locales to string\n const localesList = !locales\n ? [libraryDefaultLocale]\n : Array.isArray(locales)\n ? locales.map((l) => String(l))\n : [String(locales)];\n const canonicalLocales = Intl.getCanonicalLocales(localesList);\n this.locale = canonicalLocales.length\n ? canonicalLocales[0]\n : libraryDefaultLocale;\n } catch {\n this.locale = libraryDefaultLocale;\n }\n\n // Follows Intl.NumberFormat behavior of throwing an error when currency is invalid\n if (!TERMINATOR_MAP[options.style ?? DEFAULT_CUTOFF_FORMAT_STYLE]) {\n throw new Error(\n createInvalidCutoffStyleError(\n options.style ?? DEFAULT_CUTOFF_FORMAT_STYLE\n )\n );\n }\n\n // Resolve terminator options\n let style: CutoffFormatStyle | undefined;\n let presetTerminatorOptions: ResolvedTerminatorOptions | undefined;\n if (options.maxChars !== undefined) {\n style = options.style ?? DEFAULT_CUTOFF_FORMAT_STYLE;\n // TODO: need more sophisticated locale negotiation if we want to add support for region/script/etc.-specific terminators in the future\n const languageCode = new Intl.Locale(this.locale).language;\n presetTerminatorOptions =\n TERMINATOR_MAP[style][languageCode] ||\n TERMINATOR_MAP[style][DEFAULT_TERMINATOR_KEY];\n }\n let terminator: ResolvedTerminatorOptions['terminator'] =\n options.terminator ?? presetTerminatorOptions?.terminator;\n let separator: ResolvedTerminatorOptions['separator'] =\n terminator != null\n ? (options.separator ?? presetTerminatorOptions?.separator)\n : undefined;\n // // Remove terminator and separator if maxChars does have enough space\n this.additionLength = (terminator?.length ?? 0) + (separator?.length ?? 0);\n if (\n options.maxChars !== undefined &&\n Math.abs(options.maxChars) < this.additionLength\n ) {\n terminator = undefined;\n separator = undefined;\n }\n\n this.options = {\n maxChars: options.maxChars,\n style,\n terminator,\n separator,\n };\n }\n\n /**\n * Format a value according to the cutoff options, returning a formatted string.\n *\n * @param {string} value - The string value to format with cutoff behavior.\n * @returns {string} The formatted string with terminator applied if cutoff occurs.\n *\n * @example\n * const formatter = new CutoffFormatConstructor('en', { maxChars: 8, style: 'ellipsis' });\n * formatter.format('Hello, world!'); // Returns 'Hello, w...'\n */\n format(value: string): string {\n return this.formatToParts(value).join('');\n }\n\n /**\n * Format a value to parts according to the cutoff options, returning an array of string parts.\n * This method breaks down the formatted result into individual components for more granular control.\n *\n * @param {string} value - The string value to format with cutoff behavior.\n * @returns {PrependedCutoffParts | PostpendedCutoffParts} An array of string parts representing the formatted result.\n * - For positive maxChars: [cutoffValue, separator?, terminator?]\n * - For negative maxChars: [terminator?, separator?, cutoffValue]\n * - For no cutoff: [originalValue]\n *\n * @example\n * const formatter = new CutoffFormatConstructor('en', { maxChars: 5, style: 'ellipsis' });\n * formatter.formatToParts('Hello, world!'); // Returns ['Hello', '...']\n */\n formatToParts(value: string): PrependedCutoffParts | PostpendedCutoffParts {\n const { maxChars, terminator, separator } = this.options;\n\n // Slice our value\n // const additionLength = (terminator?.length ?? 0) + (separator?.length ?? 0);\n const adjustedChars =\n maxChars === undefined || Math.abs(maxChars) >= value.length\n ? maxChars\n : maxChars >= 0\n ? Math.max(0, maxChars - this.additionLength)\n : Math.min(0, maxChars + this.additionLength);\n const slicedValue =\n adjustedChars !== undefined && adjustedChars > -1\n ? value.slice(0, adjustedChars)\n : value.slice(adjustedChars);\n\n // No cutoff, no terminator -> value only\n if (\n maxChars == null ||\n adjustedChars == null ||\n adjustedChars === 0 ||\n terminator == null ||\n value.length <= Math.abs(maxChars)\n ) {\n return [slicedValue];\n }\n\n // Postpended cutoff\n if (adjustedChars > 0) {\n return separator != null\n ? [slicedValue, separator, terminator]\n : [slicedValue, terminator];\n }\n // Prepended cutoff\n else {\n return separator != null\n ? [terminator, separator, slicedValue]\n : [terminator, slicedValue];\n }\n }\n\n /**\n * Get the resolved options\n * @returns {ResolvedCutoffFormatOptions} The resolved options.\n */\n resolvedOptions(): ResolvedCutoffFormatOptions {\n return this.options;\n }\n}\n","import { libraryDefaultLocale } from '../settings/settings';\nimport { CutoffFormatConstructor } from '../formatting/custom-formats/CutoffFormat/CutoffFormat';\nimport {\n ConstructorType,\n CustomIntlConstructors,\n CustomIntlType,\n IntlCacheObject,\n} from './types';\n\n/**\n * Object mapping constructor names to their respective constructor functions\n * Includes all native Intl constructors plus custom ones like CutoffFormat\n */\nconst CustomIntl: CustomIntlType = {\n Collator: Intl.Collator,\n DateTimeFormat: Intl.DateTimeFormat,\n DisplayNames: Intl.DisplayNames,\n ListFormat: Intl.ListFormat,\n Locale: Intl.Locale,\n NumberFormat: Intl.NumberFormat,\n PluralRules: Intl.PluralRules,\n RelativeTimeFormat: Intl.RelativeTimeFormat,\n Segmenter: Intl.Segmenter,\n CutoffFormat: CutoffFormatConstructor,\n};\n\n/**\n * Cache for Intl and custom format instances to avoid repeated instantiation\n * Uses a two-level structure: constructor name -> cache key -> instance\n */\nclass IntlCache {\n private cache: IntlCacheObject;\n\n constructor() {\n this.cache = {};\n }\n\n /**\n * Generates a consistent cache key from locales and options\n * Handles all LocalesArgument types (string, Locale, array, undefined)\n */\n private _generateKey(locales: Intl.LocalesArgument, options = {}) {\n // Normalize locales to string representation\n const localeKey = !locales\n ? 'undefined'\n : Array.isArray(locales)\n ? locales.map((l) => String(l)).join(',')\n : String(locales);\n\n // Sort option keys to ensure consistent key generation regardless of property order\n const sortedOptions = options\n ? JSON.stringify(options, Object.keys(options).sort())\n : '{}';\n return `${localeKey}:${sortedOptions}`;\n }\n\n /**\n * Gets a cached Intl instance or creates a new one if not found\n * @param constructor The name of the Intl constructor to use\n * @param args Constructor arguments (locales, options)\n * @returns Cached or newly created Intl instance\n */\n get<K extends keyof CustomIntlConstructors>(\n constructor: K,\n ...args: ConstructorParameters<CustomIntlConstructors[K]>\n ): InstanceType<ConstructorType<K>> {\n const [locales = libraryDefaultLocale, options = {}] = args;\n const key = this._generateKey(locales, options);\n let intlObject = this.cache[constructor]?.[key];\n\n if (intlObject === undefined) {\n // Create new instance and cache it\n intlObject = new CustomIntl[constructor](...args);\n if (!this.cache[constructor]) this.cache[constructor] = {};\n this.cache[constructor][key] = intlObject;\n }\n\n return intlObject;\n }\n}\n\n/**\n * Global instance of the Intl cache for use throughout the application\n */\nexport const intlCache = new IntlCache();\n","export const defaultCacheUrl = 'https://cdn.gtx.dev' as const;\nexport const defaultBaseUrl = 'https://api2.gtx.dev' as const;\nexport const defaultRuntimeApiUrl = 'https://runtime2.gtx.dev' as const;\n","export const pluralForms = [\n 'singular',\n 'plural',\n 'dual',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n 'other',\n] as const;\nexport type PluralType = (typeof pluralForms)[number];\nexport function isAcceptedPluralForm(form: string): form is PluralType {\n return pluralForms.includes(form as (typeof pluralForms)[number]);\n}\n","import { intlCache } from '../cache/IntlCache';\nimport { pluralForms, PluralType } from '../settings/plurals';\nimport { libraryDefaultLocale } from '../settings/settings';\n\n/**\n * Given a number and a list of allowed plural forms, return the plural form that best fits the number.\n *\n * @param {number} n - The number to determine the plural form for.\n * @param {locales[]} forms - The allowed plural forms.\n * @returns {PluralType} The determined plural form, or an empty string if none fit.\n */\nexport default function _getPluralForm(\n n: number,\n forms: PluralType[] = pluralForms as any,\n locales: string[] = [libraryDefaultLocale]\n): PluralType | '' {\n const pluralRules = intlCache.get('PluralRules', locales);\n const provisionalBranchName = pluralRules.select(n);\n // aliases\n const absN = Math.abs(n);\n // 0\n if (absN === 0 && forms.includes('zero')) return 'zero'; // override\n // 1\n if (absN === 1) {\n if (forms.includes('singular')) return 'singular'; // override\n if (forms.includes('one')) return 'one'; // override\n }\n if (provisionalBranchName === 'one' && forms.includes('singular'))\n return 'singular';\n // 2\n if (absN === 2) {\n if (forms.includes('dual')) return 'dual'; // override\n if (forms.includes('two')) return 'two'; // override\n }\n if (provisionalBranchName === 'two' && forms.includes('dual')) return 'dual';\n // fallbacks\n if (forms.includes(provisionalBranchName)) return provisionalBranchName;\n // two\n if (provisionalBranchName === 'two' && forms.includes('dual')) return 'dual';\n if (provisionalBranchName === 'two' && forms.includes('plural'))\n return 'plural';\n if (provisionalBranchName === 'two' && forms.includes('other'))\n return 'other';\n // few\n if (provisionalBranchName === 'few' && forms.includes('plural'))\n return 'plural';\n if (provisionalBranchName === 'few' && forms.includes('other'))\n return 'other';\n // many\n if (provisionalBranchName === 'many' && forms.includes('plural'))\n return 'plural';\n if (provisionalBranchName === 'many' && forms.includes('other'))\n return 'other';\n // other\n if (provisionalBranchName === 'other' && forms.includes('plural'))\n return 'plural';\n return '';\n}\n","import { VariableTransformationSuffix, VariableType } from '../types';\n\nconst VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES = {\n variable: 'v',\n number: 'n',\n datetime: 'd',\n currency: 'c',\n 'relative-time': 'rt',\n} as const;\n\nexport function minifyVariableType(\n variableType: VariableTransformationSuffix\n): VariableType {\n return VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES[variableType];\n}\n","// Encode a string to base64\nexport function encode(data: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path\n return Buffer.from(data, 'utf8').toString('base64');\n }\n // Browser path\n const bytes = new TextEncoder().encode(data);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n// Decode a base64 string to a string\nexport function decode(base64: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path\n return Buffer.from(base64, 'base64').toString('utf8');\n }\n // Browser path\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return new TextDecoder().decode(bytes);\n}\n","import type { FileFormat } from '../types-dir/api/file';\n\nconst SUPPORTED_TRANSFORMATIONS = {\n GTJSON: ['GTJSON'],\n JSON: ['JSON'],\n PO: ['PO'],\n // POT templates can produce translated PO catalog files.\n POT: ['POT', 'PO'],\n YAML: ['YAML'],\n MDX: ['MDX'],\n MD: ['MD'],\n TS: ['TS'],\n JS: ['JS'],\n HTML: ['HTML'],\n TXT: ['TXT'],\n TWILIO_CONTENT_JSON: ['TWILIO_CONTENT_JSON'],\n} as const satisfies Record<FileFormat, FileFormat[]>;\n\n/**\n * This function checks if a file format transformation is supported during translation\n * @param from - The source file format\n * @param to - The target file format\n * @returns True if the transformation is supported, false otherwise\n */\nexport function isSupportedFileFormatTransform(\n from: FileFormat,\n to: FileFormat\n): boolean {\n const toFormats: FileFormat[] | undefined = SUPPORTED_TRANSFORMATIONS[from];\n return toFormats?.includes(to) ?? false;\n}\n","import type { FileFormat } from '../../types-dir/api/file';\nimport { isSupportedFileFormatTransform } from '../../utils/isSupportedFileFormatTransform';\n\nexport type FileFormatTransformInput = {\n fileFormat?: FileFormat;\n transformFormat?: FileFormat;\n fileName?: string;\n fileId?: string;\n};\n\n/**\n * Returns a user-facing validation error when a requested file format transform\n * is missing source format context or is not currently supported.\n */\nexport function getFileFormatTransformError(\n file: FileFormatTransformInput\n): string | undefined {\n if (!file.transformFormat) return undefined;\n const fileLabel = file.fileName ?? file.fileId ?? 'unknown file';\n if (!file.fileFormat) {\n return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n }\n if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) {\n return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n }\n return undefined;\n}\n\n/**\n * Validates file format transforms before sending upload/enqueue requests.\n */\nexport function validateFileFormatTransforms(\n files: FileFormatTransformInput[]\n): void {\n for (const file of files) {\n const error = getFileFormatTransformError(file);\n if (error) throw new Error(error);\n }\n}\n","import {\n MessageFormatElement,\n parse,\n ParserOptions,\n TYPE,\n} from '@formatjs/icu-messageformat-parser';\n\ntype TraverseIcuOptions = ParserOptions & {\n recurseIntoVisited?: boolean;\n};\n\n/**\n * Given an ICU string, traverse the AST and call the visitor function for each element that matches the type T\n * @param icu - The ICU string to traverse\n * @param shouldVisit - A function that returns true if the element should be visited\n * @param visitor - A function that is called for each element that matches the type T\n * @returns The modified AST of the ICU string\n *\n * @note This function is a heavy operation, use sparingly\n */\nexport function traverseIcu<T extends MessageFormatElement>({\n icuString,\n shouldVisit,\n visitor,\n options: { recurseIntoVisited = true, ...otherOptions },\n}: {\n icuString: string;\n shouldVisit: (element: MessageFormatElement) => element is T;\n visitor: (element: T) => void;\n options: TraverseIcuOptions;\n}): MessageFormatElement[] {\n const ast = parse(icuString, otherOptions);\n handleChildren(ast);\n return ast;\n\n function handleChildren(children: MessageFormatElement[]): void {\n children.map(handleChild);\n }\n\n function handleChild(child: MessageFormatElement) {\n // handle select var\n let visited = false;\n if (shouldVisit(child)) {\n visitor(child);\n visited = true;\n }\n // recurse on children\n if (!visited || recurseIntoVisited) {\n if (child.type === TYPE.select || child.type === TYPE.plural) {\n Object.values(child.options)\n .map((option) => option.value)\n .map(handleChildren);\n } else if (child.type === TYPE.tag) {\n handleChildren(child.children);\n }\n }\n }\n}\n","export const VAR_IDENTIFIER = '_gt_';\nexport const VAR_NAME_IDENTIFIER = '_gt_var_name';\n","import { VAR_IDENTIFIER } from './constants';\n\n// Regex for _gt_# select\nexport const GT_INDEXED_IDENTIFIER_REGEX = new RegExp(\n `^${VAR_IDENTIFIER}\\\\d+$`\n);\n\nexport const GT_UNINDEXED_IDENTIFIER_REGEX = new RegExp(`^${VAR_IDENTIFIER}$`);\n","import {\n GT_INDEXED_IDENTIFIER_REGEX,\n GT_UNINDEXED_IDENTIFIER_REGEX,\n} from './regex';\nimport { GTIndexedSelectElement, GTUnindexedSelectElement } from './types';\nimport {\n type MessageFormatElement,\n TYPE,\n} from '@formatjs/icu-messageformat-parser/types.js';\n\n// Visit any _gt_# select\nexport function isGTIndexedSelectElement(\n child: MessageFormatElement\n): child is GTIndexedSelectElement {\n return (\n child.type === TYPE.select &&\n GT_INDEXED_IDENTIFIER_REGEX.test(child.value) &&\n !!child.options.other &&\n (child.options.other.value.length === 0 ||\n (child.options.other.value.length > 0 &&\n child.options.other.value[0]?.type === TYPE.literal))\n );\n}\n\n// Visit any _gt_ select\nexport function isGTUnindexedSelectElement(\n child: MessageFormatElement\n): child is GTUnindexedSelectElement {\n return (\n child.type === TYPE.select &&\n GT_UNINDEXED_IDENTIFIER_REGEX.test(child.value) &&\n !!child.options.other &&\n (child.options.other.value.length === 0 ||\n (child.options.other.value.length > 0 &&\n child.options.other.value[0]?.type === TYPE.literal))\n );\n}\n","import { traverseIcu } from './utils/traverseIcu';\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { GTUnindexedSelectElement } from './utils/types';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\n\ntype Location = {\n start: number;\n end: number;\n value: string;\n};\n\n/**\n * Given an encoded ICU string, interpolate only _gt_ variables that have been marked with declareVar()\n * @example\n * const encodedIcu = \"Hi\" + declareVar(\"Brian\") + \", my name is {name}\"\n * // 'Hi {_gt_, select, other {Brian}}, my name is {name}'\n * decodeVars(encodedIcu)\n * // 'Hi Brian, my name is {name}'\n */\nexport function decodeVars(icuString: string): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Record the location of the variable\n const variableLocations: Location[] = [];\n function visitor(child: GTUnindexedSelectElement): void {\n variableLocations.push({\n start: child.location?.start.offset ?? 0,\n end: child.location?.end.offset ?? 0,\n value:\n child.options.other.value.length > 0\n ? child.options.other.value[0].value\n : '',\n });\n }\n\n // Find all variable identifiers\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: {\n recurseIntoVisited: false,\n captureLocation: true,\n },\n });\n\n // Construct output string\n let previousIndex = 0;\n const outputList = [];\n for (let i = 0; i < variableLocations.length; i++) {\n outputList.push(icuString.slice(previousIndex, variableLocations[i].start));\n outputList.push(variableLocations[i].value);\n previousIndex = variableLocations[i].end;\n }\n if (previousIndex < icuString.length) {\n outputList.push(icuString.slice(previousIndex));\n }\n const outputString = outputList.join('');\n\n return outputString;\n}\n","/**\n * Sanitizes string by escaping ICU syntax\n *\n * Sanitize arbitrary string so it does not break the following ICU message syntax:\n * {_gt_, select, other {string_here}}\n *\n * Escapes ICU special characters by:\n * 1. Doubling all single quotes (U+0027 ')\n * 2. Adding a single quote before the first special character ({}<>)\n * 3. Adding a single quote after the last special character ({}<>)\n */\nexport function sanitizeVar(string: string): string {\n // First, double all single quotes (both ASCII and Unicode)\n let result = string.replace(/['\\']/g, \"''\");\n\n // Find first and last positions of special characters\n const specialChars = /[{}<>]/;\n const firstSpecialIndex = result.search(specialChars);\n\n if (firstSpecialIndex === -1) {\n // No special characters, return with just doubled quotes\n return result;\n }\n\n // Find last special character position\n let lastSpecialIndex = -1;\n for (let i = result.length - 1; i >= 0; i--) {\n if (specialChars.test(result[i])) {\n lastSpecialIndex = i;\n break;\n }\n }\n\n // Insert quotes around the special character region\n result =\n result.slice(0, firstSpecialIndex) +\n \"'\" +\n result.slice(firstSpecialIndex, lastSpecialIndex + 1) +\n \"'\" +\n result.slice(lastSpecialIndex + 1);\n\n return result;\n}\n","import { VAR_IDENTIFIER, VAR_NAME_IDENTIFIER } from './utils/constants';\nimport { sanitizeVar } from './utils/sanitizeVar';\n\n/**\n * Mark as a non-translatable string. Use within a derive() call to mark content as not derivable (e.g., not possible to statically analyze).\n *\n * @example\n * function nonDerivableFunction() {\n * return Math.random();\n * }\n *\n * function derivableFunction() {\n * if (condition) {\n * return declareVar(nonDerivableFunction())\n * }\n * return 'John Doe';\n * }\n *\n * const gt = useGT();\n * gt(`My name is ${derive(derivableFunction())}`);\n *\n * @param {string | number | boolean | null | undefined} variable - The variable to sanitize.\n * @param {Object} [options] - The options for the sanitization.\n * @param {string} [options.$name] - The name of the variable.\n * @returns {string} The sanitized value.\n */\nexport function declareVar(\n variable: string | number | boolean | null | undefined,\n options?: { $name?: string }\n): string {\n // variable section\n const sanitizedVariable = sanitizeVar(String(variable ?? ''));\n const variableSection = ` other {${sanitizedVariable}}`;\n\n // name section\n let nameSection = '';\n if (options?.$name) {\n const sanitizedName = sanitizeVar(options.$name);\n nameSection = ` ${VAR_NAME_IDENTIFIER} {${sanitizedName}}`;\n }\n\n // interpolate\n return `{${VAR_IDENTIFIER}, select,${variableSection}${nameSection}}`;\n}\n","/**\n * derive() is a powerful but dangerous function which marks its argument as derivable (statically analyzable) for the compiler and CLI tool.\n *\n * This function is dangerous because it can cause the compiler and CLI tool to throw an error if the argument is not derivable.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * gt(`My name is ${derive(getSubject())}`);\n * ```\n *\n * @param {T extends string | boolean | number | null | undefined} content - Content to mark as derivable.\n * @returns content\n */\nexport function derive<T extends string | boolean | number | null | undefined>(\n content: T\n): T {\n return content;\n}\n\n/**\n * @deprecated Use derive() instead.\n *\n * declareStatic() is a powerful but dangerous function which marks its argument as derivable (statically analyzable) for the compiler and CLI tool.\n *\n * This function is dangerous because it can cause the compiler and CLI tool to throw an error if the argument is not derivable.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * gt(`My name is ${declareStatic(getSubject())}`);\n * ```\n *\n * @param {T extends string | boolean | number | null | undefined} content - Content to mark as derivable.\n * @returns content\n */\nexport const declareStatic = derive;\n","import {\n MessageFormatElement,\n PluralOrSelectOption,\n SelectElement,\n TYPE,\n} from '@formatjs/icu-messageformat-parser';\n\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { GTUnindexedSelectElement } from './utils/types';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\nimport { IcuMessage } from '../types-dir/jsx/content';\n\n// Used for temporarily tracking variable indices in the AST\nconst VAR_FLAG_SUFFIX = '_flag';\n\ninterface GTFlaggedSelectElement extends SelectElement {\n type: TYPE.select;\n value: `${typeof VAR_IDENTIFIER}${number}${typeof VAR_FLAG_SUFFIX}`;\n options: {\n other: PluralOrSelectOption;\n [key: string]: PluralOrSelectOption;\n };\n}\n\ntype Location = {\n start: number;\n end: number;\n otherStart: number;\n otherEnd: number;\n};\n\n/**\n * Given an ICU string adds identifiers to each _gt_ placeholder\n * indexVars('Hello {_gt_} {_gt_} World') => 'Hello {_gt_1_} {_gt_2_} World'\n */\nexport function indexVars(icuString: IcuMessage): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Record the location of the variable\n const variableLocations: Location[] = [];\n function visitor(child: GTUnindexedSelectElement): void {\n variableLocations.push({\n start: child.location?.start.offset ?? 0,\n end: child.location?.end.offset ?? 0,\n otherStart: child.options.other.location?.start.offset ?? 0,\n otherEnd: child.options.other.location?.end.offset ?? 0,\n });\n }\n\n // Find all variable identifiers\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false, captureLocation: true },\n });\n\n // Index each variable and collapse the other option\n const result = [];\n let current = 0;\n for (let i = 0; i < variableLocations.length; i++) {\n const { start, end, otherStart, otherEnd } = variableLocations[i];\n // Before the variable\n result.push(icuString.slice(current, start));\n // Replace the variable with the new identifier (+1 is for the curly brace)\n result.push(icuString.slice(start, start + VAR_IDENTIFIER.length + 1));\n\n // Add the new identifier\n result.push(String(i + 1));\n // After the variable\n result.push(icuString.slice(start + VAR_IDENTIFIER.length + 1, otherStart));\n // Before the other option\n result.push('{}');\n // The other option\n result.push(icuString.slice(otherEnd, end));\n current = end;\n }\n result.push(icuString.slice(current, icuString.length));\n\n return result.join('');\n}\n","import { VAR_IDENTIFIER } from './utils/constants';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { GTUnindexedSelectElement } from './utils/types';\n/**\n * Given an unindexed ICU string, extracts all the _gt_ variables and an indexed mapping of the variable to the values\n *\n * extractVars('Hello {_gt_, select, other {World}}') => { _gt_1: 'World' }\n *\n * @param {string} icuString - The ICU string to extract variables from.\n * @returns {Record<string, string>} A mapping of the variable to the value.\n */\nexport function extractVars(icuString: string): Record<string, string> {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return {};\n }\n\n // Extract all the _gt_# variables\n let index = 1;\n const variables: Record<string, string> = {};\n function visitor(child: GTUnindexedSelectElement): void {\n variables[child.value + index] = child.options.other.value.length\n ? child.options.other.value[0]?.value\n : '';\n index += 1;\n }\n\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false },\n });\n\n return variables;\n}\n","import {\n type ArgumentElement,\n TYPE,\n} from '@formatjs/icu-messageformat-parser/types.js';\nimport { printAST } from '@formatjs/icu-messageformat-parser/printer.js';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { GTIndexedSelectElement } from './utils/types';\nimport { isGTIndexedSelectElement } from './utils/traverseHelpers';\ninterface GTIndexedArgumentElement extends ArgumentElement {\n value: `${typeof VAR_IDENTIFIER}${number}`;\n}\n\n/**\n * Given an indexed ICU string, condenses any select to an argument\n * indexVars('Hello {_gt_1, select, other {World}}') => 'Hello {_gt_1}'\n * @param {string} icuString - The ICU string to condense.\n * @returns {string} The condensed ICU string.\n */\nexport function condenseVars(icuString: string): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Replace with argument\n function visitor(child: GTIndexedSelectElement): void {\n (child as unknown as GTIndexedArgumentElement).type = TYPE.argument;\n delete (child as any).options;\n }\n\n const ast = traverseIcu({\n icuString,\n shouldVisit: isGTIndexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false },\n });\n\n // Serialize\n return printAST(ast);\n}\n","import { JsxChild, JsxChildren } from '../types';\nimport {\n OldJsxChild,\n OldJsxChildren,\n OldJsxElement,\n OldVariableObject,\n} from './oldTypes.js';\nimport { Variable as VariableObject } from '../types';\n\n/**\n * Checks if a JSX child is an old variable object format\n * @param child - The JSX child to check\n * @returns True if the child is an old variable object (has 'key' property)\n */\nexport function isOldVariableObject(\n child: OldJsxChild | JsxChild\n): child is OldVariableObject {\n return typeof child === 'object' && child != null && 'key' in child;\n}\n\n/**\n * Checks if a JSX child is a new variable object format\n * @param child - The JSX child to check\n * @returns True if the child is a new variable object (has 'k' property)\n */\nexport function isNewVariableObject(\n child: OldJsxChild | JsxChild\n): child is VariableObject {\n return typeof child === 'object' && child != null && 'k' in child;\n}\n\n/**\n * Checks if a JSX child is an old JSX element format\n * @param child - The JSX child to check\n * @returns True if the child is an old JSX element (has 'type' and 'props' properties)\n */\nfunction isOldJsxElement(\n child: OldJsxChild | JsxChild\n): child is OldJsxElement {\n return (\n typeof child === 'object' &&\n child != null &&\n 'type' in child &&\n 'props' in child\n );\n}\n\n/**\n * Checks if a JSX child follows the old format (string, old variable object, or old JSX element)\n * @param child - The JSX child to check\n * @returns True if the child is in the old format\n */\nfunction isOldJsxChild(child: OldJsxChild | JsxChild): child is OldJsxChild {\n // string\n if (typeof child === 'string') {\n return true;\n }\n\n // variable object\n if (isOldVariableObject(child)) {\n return true;\n }\n\n // element\n return isOldJsxElement(child);\n}\n\n/**\n * Checks if JSX children follow the old format\n * @param children - The JSX children to check (can be string, array, or single child)\n * @returns True if all children are in the old format\n */\nexport function isOldJsxChildren(\n children: OldJsxChildren | JsxChildren\n): children is OldJsxChildren {\n // string\n if (typeof children === 'string') {\n return true;\n }\n\n // array\n if (Array.isArray(children)) {\n return !children.some((child) => !isOldJsxChild(child));\n }\n\n // object\n return isOldJsxChild(children);\n}\n","import { Variable as VariableObject, VariableType } from '../types';\nimport {\n OldBranchType,\n OldGTProp,\n OldJsxChild,\n OldJsxChildren,\n OldJsxElement,\n OldVariableObject,\n OldVariableType,\n} from './oldTypes.js';\nimport { GTProp, JsxChild, JsxChildren, JsxElement } from '../types';\nimport {\n isOldJsxChildren,\n isNewVariableObject,\n isOldVariableObject,\n} from './typeChecking';\n\n/**\n * Convert request data from old format to new format\n */\n\nexport function getNewJsxChild(child: OldJsxChild): JsxChild {\n // string (end case)\n if (typeof child === 'string') {\n return child;\n }\n\n // VariableObject\n if (isOldVariableObject(child)) {\n return getNewVariableObject(child);\n }\n\n // JsxElement\n return getNewJsxElement(child);\n}\n\nexport function getNewJsxChildren(children: OldJsxChildren): JsxChildren {\n // string (end case)\n if (typeof children === 'string') {\n return children;\n }\n\n // Array\n if (Array.isArray(children)) {\n return children.map(getNewJsxChild);\n }\n\n // Object\n return getNewJsxChild(children);\n}\n\nexport function getNewJsxElement(element: OldJsxElement): JsxElement {\n // string (end case)\n if (typeof element === 'string') {\n return element;\n }\n\n // type\n let t: string | undefined = undefined;\n if (element.type != null) {\n t = element.type;\n }\n // children\n let c: JsxChildren | undefined = undefined;\n if (element.props?.children != null) {\n c = getNewJsxChildren(element.props.children);\n }\n return {\n ...(t && { t }),\n ...(c && { c }),\n d: getNewGTProp(element.props['data-_gt']),\n i: element.props['data-_gt'].id,\n };\n}\n\nexport function getNewBranchType(branch: OldBranchType): 'b' | 'p' {\n if (branch === 'branch') {\n return 'b';\n }\n return 'p';\n}\n\nexport function getNewVariableType(variable: OldVariableType): VariableType {\n switch (variable) {\n case 'number':\n return 'n';\n case 'variable':\n return 'v';\n case 'datetime':\n return 'd';\n case 'currency':\n return 'c';\n default:\n return 'v';\n }\n}\n\nexport function getNewVariableObject(\n variable: OldVariableObject\n): VariableObject {\n // variable type\n let v: VariableType | undefined = undefined;\n if (variable.variable != null) {\n v = getNewVariableType(variable.variable);\n }\n // variable id\n let i: number | undefined = undefined;\n if (variable.id != null) {\n i = variable.id;\n }\n return {\n k: variable.key,\n ...(v && { v }),\n ...(i && { i }),\n };\n}\n\nexport function getNewGTProp(dataGT: OldGTProp): GTProp {\n // branches\n let b: Record<string, JsxChildren> | undefined = undefined;\n if (dataGT.branches) {\n b = Object.fromEntries(\n Object.entries(dataGT.branches).map(([key, value]) => [\n key,\n getNewJsxChildren(value),\n ])\n );\n }\n // transformation\n let t: 'b' | 'p' | undefined;\n if (dataGT.transformation) {\n t = getNewBranchType(dataGT.transformation);\n }\n return { ...(b && { b }), ...(t && { t }) };\n}\n\n/**\n * Convert response data from old format to new format\n */\n\nexport function getOldJsxChild(child: JsxChild): OldJsxChild {\n // string (end case)\n if (typeof child === 'string') {\n return child;\n }\n\n // VariableObject\n if (isNewVariableObject(child)) {\n return getOldVariableObject(child);\n }\n\n // JsxElement\n return getOldJsxElement(child);\n}\n\nexport function getOldJsxChildren(\n children: JsxChildren | OldJsxChildren\n): OldJsxChildren {\n // if children is already old, return it\n if (isOldJsxChildren(children)) {\n return children;\n }\n\n // string (end case)\n if (typeof children === 'string') {\n return children;\n }\n\n // Array\n if (Array.isArray(children)) {\n return children.map(getOldJsxChild);\n }\n\n // Object\n return getOldJsxChild(children);\n}\n\nexport function getOldJsxElement(element: JsxElement): OldJsxElement {\n // type (can assume that type will exist here)\n const type: string = element.t as string;\n // children\n let children: OldJsxChildren | undefined = undefined;\n if (element.c != null) {\n children = getOldJsxChildren(element.c);\n }\n // data-_gt (can assume id will exist here)\n const dataGT: OldGTProp = getOldGTProp(element.d || {}, element.i as number);\n return {\n type,\n props: { children, 'data-_gt': dataGT },\n };\n}\n\nexport function getOldBranchType(branch: 'b' | 'p'): OldBranchType {\n if (branch === 'b') {\n return 'branch';\n }\n return 'plural';\n}\n\nexport function getOldVariableType(variable: VariableType): OldVariableType {\n switch (variable) {\n case 'n':\n return 'number';\n case 'v':\n return 'variable';\n case 'd':\n return 'datetime';\n case 'c':\n return 'currency';\n default:\n return 'variable';\n }\n}\n\nexport function getOldVariableObject(\n variable: VariableObject\n): OldVariableObject {\n // variable type\n let v: OldVariableType | undefined = undefined;\n if (variable.v != null) {\n v = getOldVariableType(variable.v);\n }\n // variable id\n let i: number | undefined = undefined;\n if (variable.i != null) {\n i = variable.i;\n }\n return {\n key: variable.k,\n ...(v && { variable: v }),\n ...(i && { id: i }),\n };\n}\n\nexport function getOldGTProp(dataGT: GTProp, i: number): OldGTProp {\n // transformation\n let transformation: OldBranchType | undefined = undefined;\n if (dataGT.t != null) {\n transformation = getOldBranchType(dataGT.t);\n }\n // branches\n let branches: Record<string, OldJsxChildren> | undefined = undefined;\n if (dataGT.b != null) {\n branches = Object.fromEntries(\n Object.entries(dataGT.b).map(([key, value]) => [\n key,\n getOldJsxChildren(value),\n ])\n );\n }\n return {\n id: i,\n ...(transformation && { transformation }),\n ...(branches && { branches }),\n };\n}\n","// Functions provided to other GT libraries\n\nimport { OldJsxChild, OldJsxChildren, OldVariableObject } from './oldTypes';\nimport { stableStringify as stringify } from '../utils/stableStringify';\nimport { sha256 } from '@noble/hashes/sha2.js';\nimport { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js';\n\n// ----- FUNCTIONS ----- //\n/**\n * Calculates a unique hash for a given string using sha256.\n *\n * @param {string} string - The string to be hashed.\n * @returns {string} - The resulting hash as a hexadecimal string.\n */\nexport function oldHashString(string: string): string {\n return bytesToHex(sha256(utf8ToBytes(string)));\n}\n\n/**\n * Calculates a unique ID for the given children objects by hashing their sanitized JSON string representation.\n *\n * @param {any} childrenAsObjects - The children objects to be hashed.\n * @param {string} context - The context for the children\n * @param {string} id - The id for the JSX Children object\n * @param {function} hashFunction custom hash function\n * @returns {string} - The unique has of the children.\n */\nexport function oldHashJsxChildren(\n {\n source,\n context,\n id,\n dataFormat,\n }: {\n source: OldJsxChildren;\n context?: string;\n id?: string;\n dataFormat: string;\n },\n hashFunction: (string: string) => string = oldHashString\n): string {\n const unhashedKey = stringify({\n source: sanitizeJsxChildren(source),\n ...(id && { id }),\n ...(context && { context }),\n ...(dataFormat && { dataFormat }),\n });\n return hashFunction(unhashedKey);\n}\n\ntype SanitizedVariable = Omit<OldVariableObject, 'id'>;\n\ntype SanitizedElement = {\n branches?: {\n [k: string]: SanitizedChildren;\n };\n children?: SanitizedChildren;\n transformation?: string;\n};\ntype SanitizedChild = SanitizedElement | SanitizedVariable | string;\ntype SanitizedChildren = SanitizedChild | SanitizedChild[];\n\nconst sanitizeChild = (child: OldJsxChild): SanitizedChild => {\n if (child && typeof child === 'object') {\n if ('props' in child) {\n const newChild: SanitizedChild = {};\n const dataGt = child?.props?.['data-_gt'];\n if (dataGt?.branches) {\n // The only thing that prevents sanitizeJsx from being stable is\n // the order of the keys in the branches object.\n // We don't sort them because stable-stringify sorts them anyways\n newChild.branches = Object.fromEntries(\n Object.entries(dataGt.branches).map(([key, value]) => [\n key,\n sanitizeJsxChildren(value as OldJsxChildren),\n ])\n );\n }\n if (child?.props?.children) {\n newChild.children = sanitizeJsxChildren(child.props.children);\n }\n if (child?.props?.['data-_gt']?.transformation) {\n newChild.transformation = child.props['data-_gt'].transformation;\n }\n return newChild;\n }\n if ('key' in child) {\n return {\n key: child.key,\n ...(child.variable && {\n variable: child.variable,\n }),\n };\n }\n }\n return child as string;\n};\n\nfunction sanitizeJsxChildren(\n childrenAsObjects: OldJsxChildren\n): SanitizedChildren {\n return Array.isArray(childrenAsObjects)\n ? childrenAsObjects.map(sanitizeChild)\n : sanitizeChild(childrenAsObjects);\n}\n"],"mappings":";;;;;;;AAAA,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;;;ACD9B,MAAa,iCAAiC,UAC5C,8DAA8D,MAAM;ACGtE,MAAa,yBAAyB;AAEtC,MAAa,iBAGT;CACF,UAAU;EACR,IAAI;GACF,YAAY;G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|
|
280
280
|
//#endregion
|
|
281
|
+
//#region src/utils/isSupportedFileFormatTransform.ts
|
|
282
|
+
const SUPPORTED_TRANSFORMATIONS = {
|
|
283
|
+
GTJSON: ["GTJSON"],
|
|
284
|
+
JSON: ["JSON"],
|
|
285
|
+
PO: ["PO"],
|
|
286
|
+
POT: ["POT", "PO"],
|
|
287
|
+
YAML: ["YAML"],
|
|
288
|
+
MDX: ["MDX"],
|
|
289
|
+
MD: ["MD"],
|
|
290
|
+
TS: ["TS"],
|
|
291
|
+
JS: ["JS"],
|
|
292
|
+
HTML: ["HTML"],
|
|
293
|
+
TXT: ["TXT"],
|
|
294
|
+
TWILIO_CONTENT_JSON: ["TWILIO_CONTENT_JSON"]
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* This function checks if a file format transformation is supported during translation
|
|
298
|
+
* @param from - The source file format
|
|
299
|
+
* @param to - The target file format
|
|
300
|
+
* @returns True if the transformation is supported, false otherwise
|
|
301
|
+
*/
|
|
302
|
+
function isSupportedFileFormatTransform(from, to) {
|
|
303
|
+
return SUPPORTED_TRANSFORMATIONS[from]?.includes(to) ?? false;
|
|
304
|
+
}
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/translate/utils/validateFileFormatTransform.ts
|
|
307
|
+
/**
|
|
308
|
+
* Returns a user-facing validation error when a requested file format transform
|
|
309
|
+
* is missing source format context or is not currently supported.
|
|
310
|
+
*/
|
|
311
|
+
function getFileFormatTransformError(file) {
|
|
312
|
+
if (!file.transformFormat) return void 0;
|
|
313
|
+
const fileLabel = file.fileName ?? file.fileId ?? "unknown file";
|
|
314
|
+
if (!file.fileFormat) return `fileFormat is required when transformFormat is provided for ${fileLabel}`;
|
|
315
|
+
if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Validates file format transforms before sending upload/enqueue requests.
|
|
319
|
+
*/
|
|
320
|
+
function validateFileFormatTransforms(files) {
|
|
321
|
+
for (const file of files) {
|
|
322
|
+
const error = getFileFormatTransformError(file);
|
|
323
|
+
if (error) throw new Error(error);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
281
327
|
//#region src/derive/utils/traverseIcu.ts
|
|
282
328
|
/**
|
|
283
329
|
* Given an ICU string, traverse the AST and call the visitor function for each element that matches the type T
|
|
@@ -978,6 +1024,12 @@ Object.defineProperty(exports, "isOldVariableObject", {
|
|
|
978
1024
|
return isOldVariableObject;
|
|
979
1025
|
}
|
|
980
1026
|
});
|
|
1027
|
+
Object.defineProperty(exports, "isSupportedFileFormatTransform", {
|
|
1028
|
+
enumerable: true,
|
|
1029
|
+
get: function() {
|
|
1030
|
+
return isSupportedFileFormatTransform;
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
981
1033
|
Object.defineProperty(exports, "libraryDefaultLocale", {
|
|
982
1034
|
enumerable: true,
|
|
983
1035
|
get: function() {
|
|
@@ -1008,5 +1060,11 @@ Object.defineProperty(exports, "pluralForms", {
|
|
|
1008
1060
|
return pluralForms;
|
|
1009
1061
|
}
|
|
1010
1062
|
});
|
|
1063
|
+
Object.defineProperty(exports, "validateFileFormatTransforms", {
|
|
1064
|
+
enumerable: true,
|
|
1065
|
+
get: function() {
|
|
1066
|
+
return validateFileFormatTransforms;
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1011
1069
|
|
|
1012
|
-
//# sourceMappingURL=internal-
|
|
1070
|
+
//# sourceMappingURL=internal-DIHQF9gs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-DIHQF9gs.cjs","names":["TYPE","TYPE","TYPE","bytesToHex","sha256","utf8ToBytes","stringify"],"sources":["../src/settings/settings.ts","../src/errors/formattingErrors.ts","../src/formatting/custom-formats/CutoffFormat/constants.ts","../src/formatting/custom-formats/CutoffFormat/CutoffFormat.ts","../src/cache/IntlCache.ts","../src/settings/settingsUrls.ts","../src/settings/plurals.ts","../src/locales/getPluralForm.ts","../src/utils/minify.ts","../src/utils/base64.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/derive/utils/traverseIcu.ts","../src/derive/utils/constants.ts","../src/derive/utils/regex.ts","../src/derive/utils/traverseHelpers.ts","../src/derive/decodeVars.ts","../src/derive/utils/sanitizeVar.ts","../src/derive/declareVar.ts","../src/derive/derive.ts","../src/derive/indexVars.ts","../src/derive/extractVars.ts","../src/derive/condenseVars.ts","../src/backwards-compatability/typeChecking.ts","../src/backwards-compatability/dataConversion.ts","../src/backwards-compatability/oldHashJsxChildren.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\n","export const createInvalidCutoffStyleError = (style: string) =>\n `generaltranslation Formatting Error: Invalid cutoff style: ${style}.`;\n","import { CutoffFormatStyle, ResolvedTerminatorOptions } from './types';\n\nexport const DEFAULT_CUTOFF_FORMAT_STYLE: CutoffFormatStyle = 'ellipsis';\n\nexport const DEFAULT_TERMINATOR_KEY = 'DEFAULT_TERMINATOR_KEY';\n\nexport const TERMINATOR_MAP: Record<\n CutoffFormatStyle,\n Record<string | typeof DEFAULT_TERMINATOR_KEY, ResolvedTerminatorOptions>\n> = {\n ellipsis: {\n fr: {\n terminator: '…',\n separator: '\\u202F',\n },\n zh: {\n terminator: '……',\n separator: undefined,\n },\n ja: {\n terminator: '……',\n separator: undefined,\n },\n [DEFAULT_TERMINATOR_KEY]: {\n terminator: '…',\n separator: undefined,\n },\n },\n none: {\n [DEFAULT_TERMINATOR_KEY]: {\n terminator: undefined,\n separator: undefined,\n },\n },\n};\n","import { createInvalidCutoffStyleError } from '../../../errors/formattingErrors';\nimport { libraryDefaultLocale } from '../../../settings/settings';\nimport {\n DEFAULT_CUTOFF_FORMAT_STYLE,\n DEFAULT_TERMINATOR_KEY,\n TERMINATOR_MAP,\n} from './constants';\nimport {\n CutoffFormat,\n CutoffFormatOptions,\n CutoffFormatStyle,\n PostpendedCutoffParts,\n PrependedCutoffParts,\n ResolvedCutoffFormatOptions,\n ResolvedTerminatorOptions,\n} from './types';\n\nexport class CutoffFormatConstructor implements CutoffFormat {\n private locale: string;\n private options: ResolvedCutoffFormatOptions;\n private additionLength: number;\n /**\n * Constructor\n * @param {string | string[]} locales - The locales to use for formatting.\n * @param {CutoffFormatOptions} options - The options for formatting.\n * @param {number} [option.maxChars] - The maximum number of characters to display.\n * - Undefined values are treated as no cutoff.\n * - Negative values follow .slice() behavior and terminator will be added before the value.\n * - 0 will result in an empty string.\n * - If cutoff results in an empty string, no terminator is added.\n * @param {CutoffFormatStyle} [option.style='ellipsis'] - The style of the terminator.\n * @param {string} [option.terminator] - Optional override the terminator to use.\n * @param {string} [option.separator] - Optional override the separator to use between the terminator and the value.\n * - If no terminator is provided, then separator is ignored.\n *\n * @example\n * const format = new CutoffFormat('en', { maxChars: 5 });\n * format.format('Hello, world!'); // 'Hello...'\n *\n * const format = new CutoffFormat('en', { maxChars: -3 });\n * format.format('Hello, world!'); // '...ld!'\n */\n constructor(\n locales: Intl.LocalesArgument,\n options: CutoffFormatOptions = {}\n ) {\n // Determine locale (this replicates Intl.NumberFormat behavior including silent failure)\n try {\n // Normalize locales to string\n const localesList = !locales\n ? [libraryDefaultLocale]\n : Array.isArray(locales)\n ? locales.map((l) => String(l))\n : [String(locales)];\n const canonicalLocales = Intl.getCanonicalLocales(localesList);\n this.locale = canonicalLocales.length\n ? canonicalLocales[0]\n : libraryDefaultLocale;\n } catch {\n this.locale = libraryDefaultLocale;\n }\n\n // Follows Intl.NumberFormat behavior of throwing an error when currency is invalid\n if (!TERMINATOR_MAP[options.style ?? DEFAULT_CUTOFF_FORMAT_STYLE]) {\n throw new Error(\n createInvalidCutoffStyleError(\n options.style ?? DEFAULT_CUTOFF_FORMAT_STYLE\n )\n );\n }\n\n // Resolve terminator options\n let style: CutoffFormatStyle | undefined;\n let presetTerminatorOptions: ResolvedTerminatorOptions | undefined;\n if (options.maxChars !== undefined) {\n style = options.style ?? DEFAULT_CUTOFF_FORMAT_STYLE;\n // TODO: need more sophisticated locale negotiation if we want to add support for region/script/etc.-specific terminators in the future\n const languageCode = new Intl.Locale(this.locale).language;\n presetTerminatorOptions =\n TERMINATOR_MAP[style][languageCode] ||\n TERMINATOR_MAP[style][DEFAULT_TERMINATOR_KEY];\n }\n let terminator: ResolvedTerminatorOptions['terminator'] =\n options.terminator ?? presetTerminatorOptions?.terminator;\n let separator: ResolvedTerminatorOptions['separator'] =\n terminator != null\n ? (options.separator ?? presetTerminatorOptions?.separator)\n : undefined;\n // // Remove terminator and separator if maxChars does have enough space\n this.additionLength = (terminator?.length ?? 0) + (separator?.length ?? 0);\n if (\n options.maxChars !== undefined &&\n Math.abs(options.maxChars) < this.additionLength\n ) {\n terminator = undefined;\n separator = undefined;\n }\n\n this.options = {\n maxChars: options.maxChars,\n style,\n terminator,\n separator,\n };\n }\n\n /**\n * Format a value according to the cutoff options, returning a formatted string.\n *\n * @param {string} value - The string value to format with cutoff behavior.\n * @returns {string} The formatted string with terminator applied if cutoff occurs.\n *\n * @example\n * const formatter = new CutoffFormatConstructor('en', { maxChars: 8, style: 'ellipsis' });\n * formatter.format('Hello, world!'); // Returns 'Hello, w...'\n */\n format(value: string): string {\n return this.formatToParts(value).join('');\n }\n\n /**\n * Format a value to parts according to the cutoff options, returning an array of string parts.\n * This method breaks down the formatted result into individual components for more granular control.\n *\n * @param {string} value - The string value to format with cutoff behavior.\n * @returns {PrependedCutoffParts | PostpendedCutoffParts} An array of string parts representing the formatted result.\n * - For positive maxChars: [cutoffValue, separator?, terminator?]\n * - For negative maxChars: [terminator?, separator?, cutoffValue]\n * - For no cutoff: [originalValue]\n *\n * @example\n * const formatter = new CutoffFormatConstructor('en', { maxChars: 5, style: 'ellipsis' });\n * formatter.formatToParts('Hello, world!'); // Returns ['Hello', '...']\n */\n formatToParts(value: string): PrependedCutoffParts | PostpendedCutoffParts {\n const { maxChars, terminator, separator } = this.options;\n\n // Slice our value\n // const additionLength = (terminator?.length ?? 0) + (separator?.length ?? 0);\n const adjustedChars =\n maxChars === undefined || Math.abs(maxChars) >= value.length\n ? maxChars\n : maxChars >= 0\n ? Math.max(0, maxChars - this.additionLength)\n : Math.min(0, maxChars + this.additionLength);\n const slicedValue =\n adjustedChars !== undefined && adjustedChars > -1\n ? value.slice(0, adjustedChars)\n : value.slice(adjustedChars);\n\n // No cutoff, no terminator -> value only\n if (\n maxChars == null ||\n adjustedChars == null ||\n adjustedChars === 0 ||\n terminator == null ||\n value.length <= Math.abs(maxChars)\n ) {\n return [slicedValue];\n }\n\n // Postpended cutoff\n if (adjustedChars > 0) {\n return separator != null\n ? [slicedValue, separator, terminator]\n : [slicedValue, terminator];\n }\n // Prepended cutoff\n else {\n return separator != null\n ? [terminator, separator, slicedValue]\n : [terminator, slicedValue];\n }\n }\n\n /**\n * Get the resolved options\n * @returns {ResolvedCutoffFormatOptions} The resolved options.\n */\n resolvedOptions(): ResolvedCutoffFormatOptions {\n return this.options;\n }\n}\n","import { libraryDefaultLocale } from '../settings/settings';\nimport { CutoffFormatConstructor } from '../formatting/custom-formats/CutoffFormat/CutoffFormat';\nimport {\n ConstructorType,\n CustomIntlConstructors,\n CustomIntlType,\n IntlCacheObject,\n} from './types';\n\n/**\n * Object mapping constructor names to their respective constructor functions\n * Includes all native Intl constructors plus custom ones like CutoffFormat\n */\nconst CustomIntl: CustomIntlType = {\n Collator: Intl.Collator,\n DateTimeFormat: Intl.DateTimeFormat,\n DisplayNames: Intl.DisplayNames,\n ListFormat: Intl.ListFormat,\n Locale: Intl.Locale,\n NumberFormat: Intl.NumberFormat,\n PluralRules: Intl.PluralRules,\n RelativeTimeFormat: Intl.RelativeTimeFormat,\n Segmenter: Intl.Segmenter,\n CutoffFormat: CutoffFormatConstructor,\n};\n\n/**\n * Cache for Intl and custom format instances to avoid repeated instantiation\n * Uses a two-level structure: constructor name -> cache key -> instance\n */\nclass IntlCache {\n private cache: IntlCacheObject;\n\n constructor() {\n this.cache = {};\n }\n\n /**\n * Generates a consistent cache key from locales and options\n * Handles all LocalesArgument types (string, Locale, array, undefined)\n */\n private _generateKey(locales: Intl.LocalesArgument, options = {}) {\n // Normalize locales to string representation\n const localeKey = !locales\n ? 'undefined'\n : Array.isArray(locales)\n ? locales.map((l) => String(l)).join(',')\n : String(locales);\n\n // Sort option keys to ensure consistent key generation regardless of property order\n const sortedOptions = options\n ? JSON.stringify(options, Object.keys(options).sort())\n : '{}';\n return `${localeKey}:${sortedOptions}`;\n }\n\n /**\n * Gets a cached Intl instance or creates a new one if not found\n * @param constructor The name of the Intl constructor to use\n * @param args Constructor arguments (locales, options)\n * @returns Cached or newly created Intl instance\n */\n get<K extends keyof CustomIntlConstructors>(\n constructor: K,\n ...args: ConstructorParameters<CustomIntlConstructors[K]>\n ): InstanceType<ConstructorType<K>> {\n const [locales = libraryDefaultLocale, options = {}] = args;\n const key = this._generateKey(locales, options);\n let intlObject = this.cache[constructor]?.[key];\n\n if (intlObject === undefined) {\n // Create new instance and cache it\n intlObject = new CustomIntl[constructor](...args);\n if (!this.cache[constructor]) this.cache[constructor] = {};\n this.cache[constructor][key] = intlObject;\n }\n\n return intlObject;\n }\n}\n\n/**\n * Global instance of the Intl cache for use throughout the application\n */\nexport const intlCache = new IntlCache();\n","export const defaultCacheUrl = 'https://cdn.gtx.dev' as const;\nexport const defaultBaseUrl = 'https://api2.gtx.dev' as const;\nexport const defaultRuntimeApiUrl = 'https://runtime2.gtx.dev' as const;\n","export const pluralForms = [\n 'singular',\n 'plural',\n 'dual',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n 'other',\n] as const;\nexport type PluralType = (typeof pluralForms)[number];\nexport function isAcceptedPluralForm(form: string): form is PluralType {\n return pluralForms.includes(form as (typeof pluralForms)[number]);\n}\n","import { intlCache } from '../cache/IntlCache';\nimport { pluralForms, PluralType } from '../settings/plurals';\nimport { libraryDefaultLocale } from '../settings/settings';\n\n/**\n * Given a number and a list of allowed plural forms, return the plural form that best fits the number.\n *\n * @param {number} n - The number to determine the plural form for.\n * @param {locales[]} forms - The allowed plural forms.\n * @returns {PluralType} The determined plural form, or an empty string if none fit.\n */\nexport default function _getPluralForm(\n n: number,\n forms: PluralType[] = pluralForms as any,\n locales: string[] = [libraryDefaultLocale]\n): PluralType | '' {\n const pluralRules = intlCache.get('PluralRules', locales);\n const provisionalBranchName = pluralRules.select(n);\n // aliases\n const absN = Math.abs(n);\n // 0\n if (absN === 0 && forms.includes('zero')) return 'zero'; // override\n // 1\n if (absN === 1) {\n if (forms.includes('singular')) return 'singular'; // override\n if (forms.includes('one')) return 'one'; // override\n }\n if (provisionalBranchName === 'one' && forms.includes('singular'))\n return 'singular';\n // 2\n if (absN === 2) {\n if (forms.includes('dual')) return 'dual'; // override\n if (forms.includes('two')) return 'two'; // override\n }\n if (provisionalBranchName === 'two' && forms.includes('dual')) return 'dual';\n // fallbacks\n if (forms.includes(provisionalBranchName)) return provisionalBranchName;\n // two\n if (provisionalBranchName === 'two' && forms.includes('dual')) return 'dual';\n if (provisionalBranchName === 'two' && forms.includes('plural'))\n return 'plural';\n if (provisionalBranchName === 'two' && forms.includes('other'))\n return 'other';\n // few\n if (provisionalBranchName === 'few' && forms.includes('plural'))\n return 'plural';\n if (provisionalBranchName === 'few' && forms.includes('other'))\n return 'other';\n // many\n if (provisionalBranchName === 'many' && forms.includes('plural'))\n return 'plural';\n if (provisionalBranchName === 'many' && forms.includes('other'))\n return 'other';\n // other\n if (provisionalBranchName === 'other' && forms.includes('plural'))\n return 'plural';\n return '';\n}\n","import { VariableTransformationSuffix, VariableType } from '../types';\n\nconst VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES = {\n variable: 'v',\n number: 'n',\n datetime: 'd',\n currency: 'c',\n 'relative-time': 'rt',\n} as const;\n\nexport function minifyVariableType(\n variableType: VariableTransformationSuffix\n): VariableType {\n return VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES[variableType];\n}\n","// Encode a string to base64\nexport function encode(data: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path\n return Buffer.from(data, 'utf8').toString('base64');\n }\n // Browser path\n const bytes = new TextEncoder().encode(data);\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n// Decode a base64 string to a string\nexport function decode(base64: string): string {\n if (typeof Buffer !== 'undefined') {\n // Node.js path\n return Buffer.from(base64, 'base64').toString('utf8');\n }\n // Browser path\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return new TextDecoder().decode(bytes);\n}\n","import type { FileFormat } from '../types-dir/api/file';\n\nconst SUPPORTED_TRANSFORMATIONS = {\n GTJSON: ['GTJSON'],\n JSON: ['JSON'],\n PO: ['PO'],\n // POT templates can produce translated PO catalog files.\n POT: ['POT', 'PO'],\n YAML: ['YAML'],\n MDX: ['MDX'],\n MD: ['MD'],\n TS: ['TS'],\n JS: ['JS'],\n HTML: ['HTML'],\n TXT: ['TXT'],\n TWILIO_CONTENT_JSON: ['TWILIO_CONTENT_JSON'],\n} as const satisfies Record<FileFormat, FileFormat[]>;\n\n/**\n * This function checks if a file format transformation is supported during translation\n * @param from - The source file format\n * @param to - The target file format\n * @returns True if the transformation is supported, false otherwise\n */\nexport function isSupportedFileFormatTransform(\n from: FileFormat,\n to: FileFormat\n): boolean {\n const toFormats: FileFormat[] | undefined = SUPPORTED_TRANSFORMATIONS[from];\n return toFormats?.includes(to) ?? false;\n}\n","import type { FileFormat } from '../../types-dir/api/file';\nimport { isSupportedFileFormatTransform } from '../../utils/isSupportedFileFormatTransform';\n\nexport type FileFormatTransformInput = {\n fileFormat?: FileFormat;\n transformFormat?: FileFormat;\n fileName?: string;\n fileId?: string;\n};\n\n/**\n * Returns a user-facing validation error when a requested file format transform\n * is missing source format context or is not currently supported.\n */\nexport function getFileFormatTransformError(\n file: FileFormatTransformInput\n): string | undefined {\n if (!file.transformFormat) return undefined;\n const fileLabel = file.fileName ?? file.fileId ?? 'unknown file';\n if (!file.fileFormat) {\n return `fileFormat is required when transformFormat is provided for ${fileLabel}`;\n }\n if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) {\n return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;\n }\n return undefined;\n}\n\n/**\n * Validates file format transforms before sending upload/enqueue requests.\n */\nexport function validateFileFormatTransforms(\n files: FileFormatTransformInput[]\n): void {\n for (const file of files) {\n const error = getFileFormatTransformError(file);\n if (error) throw new Error(error);\n }\n}\n","import {\n MessageFormatElement,\n parse,\n ParserOptions,\n TYPE,\n} from '@formatjs/icu-messageformat-parser';\n\ntype TraverseIcuOptions = ParserOptions & {\n recurseIntoVisited?: boolean;\n};\n\n/**\n * Given an ICU string, traverse the AST and call the visitor function for each element that matches the type T\n * @param icu - The ICU string to traverse\n * @param shouldVisit - A function that returns true if the element should be visited\n * @param visitor - A function that is called for each element that matches the type T\n * @returns The modified AST of the ICU string\n *\n * @note This function is a heavy operation, use sparingly\n */\nexport function traverseIcu<T extends MessageFormatElement>({\n icuString,\n shouldVisit,\n visitor,\n options: { recurseIntoVisited = true, ...otherOptions },\n}: {\n icuString: string;\n shouldVisit: (element: MessageFormatElement) => element is T;\n visitor: (element: T) => void;\n options: TraverseIcuOptions;\n}): MessageFormatElement[] {\n const ast = parse(icuString, otherOptions);\n handleChildren(ast);\n return ast;\n\n function handleChildren(children: MessageFormatElement[]): void {\n children.map(handleChild);\n }\n\n function handleChild(child: MessageFormatElement) {\n // handle select var\n let visited = false;\n if (shouldVisit(child)) {\n visitor(child);\n visited = true;\n }\n // recurse on children\n if (!visited || recurseIntoVisited) {\n if (child.type === TYPE.select || child.type === TYPE.plural) {\n Object.values(child.options)\n .map((option) => option.value)\n .map(handleChildren);\n } else if (child.type === TYPE.tag) {\n handleChildren(child.children);\n }\n }\n }\n}\n","export const VAR_IDENTIFIER = '_gt_';\nexport const VAR_NAME_IDENTIFIER = '_gt_var_name';\n","import { VAR_IDENTIFIER } from './constants';\n\n// Regex for _gt_# select\nexport const GT_INDEXED_IDENTIFIER_REGEX = new RegExp(\n `^${VAR_IDENTIFIER}\\\\d+$`\n);\n\nexport const GT_UNINDEXED_IDENTIFIER_REGEX = new RegExp(`^${VAR_IDENTIFIER}$`);\n","import {\n GT_INDEXED_IDENTIFIER_REGEX,\n GT_UNINDEXED_IDENTIFIER_REGEX,\n} from './regex';\nimport { GTIndexedSelectElement, GTUnindexedSelectElement } from './types';\nimport {\n type MessageFormatElement,\n TYPE,\n} from '@formatjs/icu-messageformat-parser/types.js';\n\n// Visit any _gt_# select\nexport function isGTIndexedSelectElement(\n child: MessageFormatElement\n): child is GTIndexedSelectElement {\n return (\n child.type === TYPE.select &&\n GT_INDEXED_IDENTIFIER_REGEX.test(child.value) &&\n !!child.options.other &&\n (child.options.other.value.length === 0 ||\n (child.options.other.value.length > 0 &&\n child.options.other.value[0]?.type === TYPE.literal))\n );\n}\n\n// Visit any _gt_ select\nexport function isGTUnindexedSelectElement(\n child: MessageFormatElement\n): child is GTUnindexedSelectElement {\n return (\n child.type === TYPE.select &&\n GT_UNINDEXED_IDENTIFIER_REGEX.test(child.value) &&\n !!child.options.other &&\n (child.options.other.value.length === 0 ||\n (child.options.other.value.length > 0 &&\n child.options.other.value[0]?.type === TYPE.literal))\n );\n}\n","import { traverseIcu } from './utils/traverseIcu';\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { GTUnindexedSelectElement } from './utils/types';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\n\ntype Location = {\n start: number;\n end: number;\n value: string;\n};\n\n/**\n * Given an encoded ICU string, interpolate only _gt_ variables that have been marked with declareVar()\n * @example\n * const encodedIcu = \"Hi\" + declareVar(\"Brian\") + \", my name is {name}\"\n * // 'Hi {_gt_, select, other {Brian}}, my name is {name}'\n * decodeVars(encodedIcu)\n * // 'Hi Brian, my name is {name}'\n */\nexport function decodeVars(icuString: string): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Record the location of the variable\n const variableLocations: Location[] = [];\n function visitor(child: GTUnindexedSelectElement): void {\n variableLocations.push({\n start: child.location?.start.offset ?? 0,\n end: child.location?.end.offset ?? 0,\n value:\n child.options.other.value.length > 0\n ? child.options.other.value[0].value\n : '',\n });\n }\n\n // Find all variable identifiers\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: {\n recurseIntoVisited: false,\n captureLocation: true,\n },\n });\n\n // Construct output string\n let previousIndex = 0;\n const outputList = [];\n for (let i = 0; i < variableLocations.length; i++) {\n outputList.push(icuString.slice(previousIndex, variableLocations[i].start));\n outputList.push(variableLocations[i].value);\n previousIndex = variableLocations[i].end;\n }\n if (previousIndex < icuString.length) {\n outputList.push(icuString.slice(previousIndex));\n }\n const outputString = outputList.join('');\n\n return outputString;\n}\n","/**\n * Sanitizes string by escaping ICU syntax\n *\n * Sanitize arbitrary string so it does not break the following ICU message syntax:\n * {_gt_, select, other {string_here}}\n *\n * Escapes ICU special characters by:\n * 1. Doubling all single quotes (U+0027 ')\n * 2. Adding a single quote before the first special character ({}<>)\n * 3. Adding a single quote after the last special character ({}<>)\n */\nexport function sanitizeVar(string: string): string {\n // First, double all single quotes (both ASCII and Unicode)\n let result = string.replace(/['\\']/g, \"''\");\n\n // Find first and last positions of special characters\n const specialChars = /[{}<>]/;\n const firstSpecialIndex = result.search(specialChars);\n\n if (firstSpecialIndex === -1) {\n // No special characters, return with just doubled quotes\n return result;\n }\n\n // Find last special character position\n let lastSpecialIndex = -1;\n for (let i = result.length - 1; i >= 0; i--) {\n if (specialChars.test(result[i])) {\n lastSpecialIndex = i;\n break;\n }\n }\n\n // Insert quotes around the special character region\n result =\n result.slice(0, firstSpecialIndex) +\n \"'\" +\n result.slice(firstSpecialIndex, lastSpecialIndex + 1) +\n \"'\" +\n result.slice(lastSpecialIndex + 1);\n\n return result;\n}\n","import { VAR_IDENTIFIER, VAR_NAME_IDENTIFIER } from './utils/constants';\nimport { sanitizeVar } from './utils/sanitizeVar';\n\n/**\n * Mark as a non-translatable string. Use within a derive() call to mark content as not derivable (e.g., not possible to statically analyze).\n *\n * @example\n * function nonDerivableFunction() {\n * return Math.random();\n * }\n *\n * function derivableFunction() {\n * if (condition) {\n * return declareVar(nonDerivableFunction())\n * }\n * return 'John Doe';\n * }\n *\n * const gt = useGT();\n * gt(`My name is ${derive(derivableFunction())}`);\n *\n * @param {string | number | boolean | null | undefined} variable - The variable to sanitize.\n * @param {Object} [options] - The options for the sanitization.\n * @param {string} [options.$name] - The name of the variable.\n * @returns {string} The sanitized value.\n */\nexport function declareVar(\n variable: string | number | boolean | null | undefined,\n options?: { $name?: string }\n): string {\n // variable section\n const sanitizedVariable = sanitizeVar(String(variable ?? ''));\n const variableSection = ` other {${sanitizedVariable}}`;\n\n // name section\n let nameSection = '';\n if (options?.$name) {\n const sanitizedName = sanitizeVar(options.$name);\n nameSection = ` ${VAR_NAME_IDENTIFIER} {${sanitizedName}}`;\n }\n\n // interpolate\n return `{${VAR_IDENTIFIER}, select,${variableSection}${nameSection}}`;\n}\n","/**\n * derive() is a powerful but dangerous function which marks its argument as derivable (statically analyzable) for the compiler and CLI tool.\n *\n * This function is dangerous because it can cause the compiler and CLI tool to throw an error if the argument is not derivable.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * gt(`My name is ${derive(getSubject())}`);\n * ```\n *\n * @param {T extends string | boolean | number | null | undefined} content - Content to mark as derivable.\n * @returns content\n */\nexport function derive<T extends string | boolean | number | null | undefined>(\n content: T\n): T {\n return content;\n}\n\n/**\n * @deprecated Use derive() instead.\n *\n * declareStatic() is a powerful but dangerous function which marks its argument as derivable (statically analyzable) for the compiler and CLI tool.\n *\n * This function is dangerous because it can cause the compiler and CLI tool to throw an error if the argument is not derivable.\n *\n * @example\n * ```jsx\n * function getSubject() {\n * return (Math.random() > 0.5) ? \"Alice\" : \"Brian\";\n * }\n * ...\n * gt(`My name is ${declareStatic(getSubject())}`);\n * ```\n *\n * @param {T extends string | boolean | number | null | undefined} content - Content to mark as derivable.\n * @returns content\n */\nexport const declareStatic = derive;\n","import {\n MessageFormatElement,\n PluralOrSelectOption,\n SelectElement,\n TYPE,\n} from '@formatjs/icu-messageformat-parser';\n\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { GTUnindexedSelectElement } from './utils/types';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\nimport { IcuMessage } from '../types-dir/jsx/content';\n\n// Used for temporarily tracking variable indices in the AST\nconst VAR_FLAG_SUFFIX = '_flag';\n\ninterface GTFlaggedSelectElement extends SelectElement {\n type: TYPE.select;\n value: `${typeof VAR_IDENTIFIER}${number}${typeof VAR_FLAG_SUFFIX}`;\n options: {\n other: PluralOrSelectOption;\n [key: string]: PluralOrSelectOption;\n };\n}\n\ntype Location = {\n start: number;\n end: number;\n otherStart: number;\n otherEnd: number;\n};\n\n/**\n * Given an ICU string adds identifiers to each _gt_ placeholder\n * indexVars('Hello {_gt_} {_gt_} World') => 'Hello {_gt_1_} {_gt_2_} World'\n */\nexport function indexVars(icuString: IcuMessage): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Record the location of the variable\n const variableLocations: Location[] = [];\n function visitor(child: GTUnindexedSelectElement): void {\n variableLocations.push({\n start: child.location?.start.offset ?? 0,\n end: child.location?.end.offset ?? 0,\n otherStart: child.options.other.location?.start.offset ?? 0,\n otherEnd: child.options.other.location?.end.offset ?? 0,\n });\n }\n\n // Find all variable identifiers\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false, captureLocation: true },\n });\n\n // Index each variable and collapse the other option\n const result = [];\n let current = 0;\n for (let i = 0; i < variableLocations.length; i++) {\n const { start, end, otherStart, otherEnd } = variableLocations[i];\n // Before the variable\n result.push(icuString.slice(current, start));\n // Replace the variable with the new identifier (+1 is for the curly brace)\n result.push(icuString.slice(start, start + VAR_IDENTIFIER.length + 1));\n\n // Add the new identifier\n result.push(String(i + 1));\n // After the variable\n result.push(icuString.slice(start + VAR_IDENTIFIER.length + 1, otherStart));\n // Before the other option\n result.push('{}');\n // The other option\n result.push(icuString.slice(otherEnd, end));\n current = end;\n }\n result.push(icuString.slice(current, icuString.length));\n\n return result.join('');\n}\n","import { VAR_IDENTIFIER } from './utils/constants';\nimport { isGTUnindexedSelectElement } from './utils/traverseHelpers';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { GTUnindexedSelectElement } from './utils/types';\n/**\n * Given an unindexed ICU string, extracts all the _gt_ variables and an indexed mapping of the variable to the values\n *\n * extractVars('Hello {_gt_, select, other {World}}') => { _gt_1: 'World' }\n *\n * @param {string} icuString - The ICU string to extract variables from.\n * @returns {Record<string, string>} A mapping of the variable to the value.\n */\nexport function extractVars(icuString: string): Record<string, string> {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return {};\n }\n\n // Extract all the _gt_# variables\n let index = 1;\n const variables: Record<string, string> = {};\n function visitor(child: GTUnindexedSelectElement): void {\n variables[child.value + index] = child.options.other.value.length\n ? child.options.other.value[0]?.value\n : '';\n index += 1;\n }\n\n traverseIcu({\n icuString,\n shouldVisit: isGTUnindexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false },\n });\n\n return variables;\n}\n","import {\n type ArgumentElement,\n TYPE,\n} from '@formatjs/icu-messageformat-parser/types.js';\nimport { printAST } from '@formatjs/icu-messageformat-parser/printer.js';\nimport { traverseIcu } from './utils/traverseIcu';\nimport { VAR_IDENTIFIER } from './utils/constants';\nimport { GTIndexedSelectElement } from './utils/types';\nimport { isGTIndexedSelectElement } from './utils/traverseHelpers';\ninterface GTIndexedArgumentElement extends ArgumentElement {\n value: `${typeof VAR_IDENTIFIER}${number}`;\n}\n\n/**\n * Given an indexed ICU string, condenses any select to an argument\n * indexVars('Hello {_gt_1, select, other {World}}') => 'Hello {_gt_1}'\n * @param {string} icuString - The ICU string to condense.\n * @returns {string} The condensed ICU string.\n */\nexport function condenseVars(icuString: string): string {\n // Check if the string contains _gt_\n if (!icuString.includes(VAR_IDENTIFIER)) {\n return icuString;\n }\n\n // Replace with argument\n function visitor(child: GTIndexedSelectElement): void {\n (child as unknown as GTIndexedArgumentElement).type = TYPE.argument;\n delete (child as any).options;\n }\n\n const ast = traverseIcu({\n icuString,\n shouldVisit: isGTIndexedSelectElement,\n visitor,\n options: { recurseIntoVisited: false },\n });\n\n // Serialize\n return printAST(ast);\n}\n","import { JsxChild, JsxChildren } from '../types';\nimport {\n OldJsxChild,\n OldJsxChildren,\n OldJsxElement,\n OldVariableObject,\n} from './oldTypes.js';\nimport { Variable as VariableObject } from '../types';\n\n/**\n * Checks if a JSX child is an old variable object format\n * @param child - The JSX child to check\n * @returns True if the child is an old variable object (has 'key' property)\n */\nexport function isOldVariableObject(\n child: OldJsxChild | JsxChild\n): child is OldVariableObject {\n return typeof child === 'object' && child != null && 'key' in child;\n}\n\n/**\n * Checks if a JSX child is a new variable object format\n * @param child - The JSX child to check\n * @returns True if the child is a new variable object (has 'k' property)\n */\nexport function isNewVariableObject(\n child: OldJsxChild | JsxChild\n): child is VariableObject {\n return typeof child === 'object' && child != null && 'k' in child;\n}\n\n/**\n * Checks if a JSX child is an old JSX element format\n * @param child - The JSX child to check\n * @returns True if the child is an old JSX element (has 'type' and 'props' properties)\n */\nfunction isOldJsxElement(\n child: OldJsxChild | JsxChild\n): child is OldJsxElement {\n return (\n typeof child === 'object' &&\n child != null &&\n 'type' in child &&\n 'props' in child\n );\n}\n\n/**\n * Checks if a JSX child follows the old format (string, old variable object, or old JSX element)\n * @param child - The JSX child to check\n * @returns True if the child is in the old format\n */\nfunction isOldJsxChild(child: OldJsxChild | JsxChild): child is OldJsxChild {\n // string\n if (typeof child === 'string') {\n return true;\n }\n\n // variable object\n if (isOldVariableObject(child)) {\n return true;\n }\n\n // element\n return isOldJsxElement(child);\n}\n\n/**\n * Checks if JSX children follow the old format\n * @param children - The JSX children to check (can be string, array, or single child)\n * @returns True if all children are in the old format\n */\nexport function isOldJsxChildren(\n children: OldJsxChildren | JsxChildren\n): children is OldJsxChildren {\n // string\n if (typeof children === 'string') {\n return true;\n }\n\n // array\n if (Array.isArray(children)) {\n return !children.some((child) => !isOldJsxChild(child));\n }\n\n // object\n return isOldJsxChild(children);\n}\n","import { Variable as VariableObject, VariableType } from '../types';\nimport {\n OldBranchType,\n OldGTProp,\n OldJsxChild,\n OldJsxChildren,\n OldJsxElement,\n OldVariableObject,\n OldVariableType,\n} from './oldTypes.js';\nimport { GTProp, JsxChild, JsxChildren, JsxElement } from '../types';\nimport {\n isOldJsxChildren,\n isNewVariableObject,\n isOldVariableObject,\n} from './typeChecking';\n\n/**\n * Convert request data from old format to new format\n */\n\nexport function getNewJsxChild(child: OldJsxChild): JsxChild {\n // string (end case)\n if (typeof child === 'string') {\n return child;\n }\n\n // VariableObject\n if (isOldVariableObject(child)) {\n return getNewVariableObject(child);\n }\n\n // JsxElement\n return getNewJsxElement(child);\n}\n\nexport function getNewJsxChildren(children: OldJsxChildren): JsxChildren {\n // string (end case)\n if (typeof children === 'string') {\n return children;\n }\n\n // Array\n if (Array.isArray(children)) {\n return children.map(getNewJsxChild);\n }\n\n // Object\n return getNewJsxChild(children);\n}\n\nexport function getNewJsxElement(element: OldJsxElement): JsxElement {\n // string (end case)\n if (typeof element === 'string') {\n return element;\n }\n\n // type\n let t: string | undefined = undefined;\n if (element.type != null) {\n t = element.type;\n }\n // children\n let c: JsxChildren | undefined = undefined;\n if (element.props?.children != null) {\n c = getNewJsxChildren(element.props.children);\n }\n return {\n ...(t && { t }),\n ...(c && { c }),\n d: getNewGTProp(element.props['data-_gt']),\n i: element.props['data-_gt'].id,\n };\n}\n\nexport function getNewBranchType(branch: OldBranchType): 'b' | 'p' {\n if (branch === 'branch') {\n return 'b';\n }\n return 'p';\n}\n\nexport function getNewVariableType(variable: OldVariableType): VariableType {\n switch (variable) {\n case 'number':\n return 'n';\n case 'variable':\n return 'v';\n case 'datetime':\n return 'd';\n case 'currency':\n return 'c';\n default:\n return 'v';\n }\n}\n\nexport function getNewVariableObject(\n variable: OldVariableObject\n): VariableObject {\n // variable type\n let v: VariableType | undefined = undefined;\n if (variable.variable != null) {\n v = getNewVariableType(variable.variable);\n }\n // variable id\n let i: number | undefined = undefined;\n if (variable.id != null) {\n i = variable.id;\n }\n return {\n k: variable.key,\n ...(v && { v }),\n ...(i && { i }),\n };\n}\n\nexport function getNewGTProp(dataGT: OldGTProp): GTProp {\n // branches\n let b: Record<string, JsxChildren> | undefined = undefined;\n if (dataGT.branches) {\n b = Object.fromEntries(\n Object.entries(dataGT.branches).map(([key, value]) => [\n key,\n getNewJsxChildren(value),\n ])\n );\n }\n // transformation\n let t: 'b' | 'p' | undefined;\n if (dataGT.transformation) {\n t = getNewBranchType(dataGT.transformation);\n }\n return { ...(b && { b }), ...(t && { t }) };\n}\n\n/**\n * Convert response data from old format to new format\n */\n\nexport function getOldJsxChild(child: JsxChild): OldJsxChild {\n // string (end case)\n if (typeof child === 'string') {\n return child;\n }\n\n // VariableObject\n if (isNewVariableObject(child)) {\n return getOldVariableObject(child);\n }\n\n // JsxElement\n return getOldJsxElement(child);\n}\n\nexport function getOldJsxChildren(\n children: JsxChildren | OldJsxChildren\n): OldJsxChildren {\n // if children is already old, return it\n if (isOldJsxChildren(children)) {\n return children;\n }\n\n // string (end case)\n if (typeof children === 'string') {\n return children;\n }\n\n // Array\n if (Array.isArray(children)) {\n return children.map(getOldJsxChild);\n }\n\n // Object\n return getOldJsxChild(children);\n}\n\nexport function getOldJsxElement(element: JsxElement): OldJsxElement {\n // type (can assume that type will exist here)\n const type: string = element.t as string;\n // children\n let children: OldJsxChildren | undefined = undefined;\n if (element.c != null) {\n children = getOldJsxChildren(element.c);\n }\n // data-_gt (can assume id will exist here)\n const dataGT: OldGTProp = getOldGTProp(element.d || {}, element.i as number);\n return {\n type,\n props: { children, 'data-_gt': dataGT },\n };\n}\n\nexport function getOldBranchType(branch: 'b' | 'p'): OldBranchType {\n if (branch === 'b') {\n return 'branch';\n }\n return 'plural';\n}\n\nexport function getOldVariableType(variable: VariableType): OldVariableType {\n switch (variable) {\n case 'n':\n return 'number';\n case 'v':\n return 'variable';\n case 'd':\n return 'datetime';\n case 'c':\n return 'currency';\n default:\n return 'variable';\n }\n}\n\nexport function getOldVariableObject(\n variable: VariableObject\n): OldVariableObject {\n // variable type\n let v: OldVariableType | undefined = undefined;\n if (variable.v != null) {\n v = getOldVariableType(variable.v);\n }\n // variable id\n let i: number | undefined = undefined;\n if (variable.i != null) {\n i = variable.i;\n }\n return {\n key: variable.k,\n ...(v && { variable: v }),\n ...(i && { id: i }),\n };\n}\n\nexport function getOldGTProp(dataGT: GTProp, i: number): OldGTProp {\n // transformation\n let transformation: OldBranchType | undefined = undefined;\n if (dataGT.t != null) {\n transformation = getOldBranchType(dataGT.t);\n }\n // branches\n let branches: Record<string, OldJsxChildren> | undefined = undefined;\n if (dataGT.b != null) {\n branches = Object.fromEntries(\n Object.entries(dataGT.b).map(([key, value]) => [\n key,\n getOldJsxChildren(value),\n ])\n );\n }\n return {\n id: i,\n ...(transformation && { transformation }),\n ...(branches && { branches }),\n };\n}\n","// Functions provided to other GT libraries\n\nimport { OldJsxChild, OldJsxChildren, OldVariableObject } from './oldTypes';\nimport { stableStringify as stringify } from '../utils/stableStringify';\nimport { sha256 } from '@noble/hashes/sha2.js';\nimport { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js';\n\n// ----- FUNCTIONS ----- //\n/**\n * Calculates a unique hash for a given string using sha256.\n *\n * @param {string} string - The string to be hashed.\n * @returns {string} - The resulting hash as a hexadecimal string.\n */\nexport function oldHashString(string: string): string {\n return bytesToHex(sha256(utf8ToBytes(string)));\n}\n\n/**\n * Calculates a unique ID for the given children objects by hashing their sanitized JSON string representation.\n *\n * @param {any} childrenAsObjects - The children objects to be hashed.\n * @param {string} context - The context for the children\n * @param {string} id - The id for the JSX Children object\n * @param {function} hashFunction custom hash function\n * @returns {string} - The unique has of the children.\n */\nexport function oldHashJsxChildren(\n {\n source,\n context,\n id,\n dataFormat,\n }: {\n source: OldJsxChildren;\n context?: string;\n id?: string;\n dataFormat: string;\n },\n hashFunction: (string: string) => string = oldHashString\n): string {\n const unhashedKey = stringify({\n source: sanitizeJsxChildren(source),\n ...(id && { id }),\n ...(context && { context }),\n ...(dataFormat && { dataFormat }),\n });\n return hashFunction(unhashedKey);\n}\n\ntype SanitizedVariable = Omit<OldVariableObject, 'id'>;\n\ntype SanitizedElement = {\n branches?: {\n [k: string]: SanitizedChildren;\n };\n children?: SanitizedChildren;\n transformation?: string;\n};\ntype SanitizedChild = SanitizedElement | SanitizedVariable | string;\ntype SanitizedChildren = SanitizedChild | SanitizedChild[];\n\nconst sanitizeChild = (child: OldJsxChild): SanitizedChild => {\n if (child && typeof child === 'object') {\n if ('props' in child) {\n const newChild: SanitizedChild = {};\n const dataGt = child?.props?.['data-_gt'];\n if (dataGt?.branches) {\n // The only thing that prevents sanitizeJsx from being stable is\n // the order of the keys in the branches object.\n // We don't sort them because stable-stringify sorts them anyways\n newChild.branches = Object.fromEntries(\n Object.entries(dataGt.branches).map(([key, value]) => [\n key,\n sanitizeJsxChildren(value as OldJsxChildren),\n ])\n );\n }\n if (child?.props?.children) {\n newChild.children = sanitizeJsxChildren(child.props.children);\n }\n if (child?.props?.['data-_gt']?.transformation) {\n newChild.transformation = child.props['data-_gt'].transformation;\n }\n return newChild;\n }\n if ('key' in child) {\n return {\n key: child.key,\n ...(child.variable && {\n variable: child.variable,\n }),\n };\n }\n }\n return child as string;\n};\n\nfunction sanitizeJsxChildren(\n childrenAsObjects: OldJsxChildren\n): Sanit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S;AAE/D,OAAI,OAAO,QAAQ,aAAa,eAC9B,UAAS,iBAAiB,MAAM,MAAM,YAAY;AAEpD,UAAO;;AAET,MAAI,SAAS,MACX,QAAO;GACL,KAAK,MAAM;GACX,GAAI,MAAM,YAAY,EACpB,UAAU,MAAM,UACjB;GACF;;AAGL,QAAO;;AAGT,SAAS,oBACP,mBACmB;AACnB,QAAO,MAAM,QAAQ,kBAAkB,GACnC,kBAAkB,IAAI,cAAc,GACpC,cAAc,kBAAkB"}
|
package/dist/internal.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_internal = require("./internal-
|
|
2
|
+
const require_internal = require("./internal-DIHQF9gs.cjs");
|
|
3
3
|
const require_sha2 = require("./sha2-DKowBr6H.cjs");
|
|
4
4
|
exports.VAR_IDENTIFIER = require_internal.VAR_IDENTIFIER;
|
|
5
5
|
exports.VAR_NAME_IDENTIFIER = require_internal.VAR_NAME_IDENTIFIER;
|
|
@@ -35,9 +35,11 @@ exports.isAcceptedPluralForm = require_internal.isAcceptedPluralForm;
|
|
|
35
35
|
exports.isNewVariableObject = require_internal.isNewVariableObject;
|
|
36
36
|
exports.isOldJsxChildren = require_internal.isOldJsxChildren;
|
|
37
37
|
exports.isOldVariableObject = require_internal.isOldVariableObject;
|
|
38
|
+
exports.isSupportedFileFormatTransform = require_internal.isSupportedFileFormatTransform;
|
|
38
39
|
exports.isVariable = require_sha2.isVariable;
|
|
39
40
|
exports.libraryDefaultLocale = require_internal.libraryDefaultLocale;
|
|
40
41
|
exports.minifyVariableType = require_internal.minifyVariableType;
|
|
41
42
|
exports.oldHashJsxChildren = require_internal.oldHashJsxChildren;
|
|
42
43
|
exports.oldHashString = require_internal.oldHashString;
|
|
43
44
|
exports.pluralForms = require_internal.pluralForms;
|
|
45
|
+
exports.validateFileFormatTransforms = require_internal.validateFileFormatTransforms;
|
package/dist/internal.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { At as VariableType, Ct as JsxChild, St as IcuMessage, Tt as JsxElement, _t as GTProp, jt as LocaleProperties, kt as Variable, l as _Content, p as VariableTransformationSuffix, wt as JsxChildren } from "./types-
|
|
1
|
+
import { At as VariableType, Ct as JsxChild, Q as FileFormat, St as IcuMessage, Tt as JsxElement, _t as GTProp, jt as LocaleProperties, kt as Variable, l as _Content, p as VariableTransformationSuffix, wt as JsxChildren } from "./types-BJdoI1d1.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/settings/settingsUrls.d.ts
|
|
4
4
|
declare const defaultCacheUrl: "https://cdn.gtx.dev";
|
|
@@ -34,6 +34,27 @@ declare function minifyVariableType(variableType: VariableTransformationSuffix):
|
|
|
34
34
|
declare function encode(data: string): string;
|
|
35
35
|
declare function decode(base64: string): string;
|
|
36
36
|
//#endregion
|
|
37
|
+
//#region src/utils/isSupportedFileFormatTransform.d.ts
|
|
38
|
+
/**
|
|
39
|
+
* This function checks if a file format transformation is supported during translation
|
|
40
|
+
* @param from - The source file format
|
|
41
|
+
* @param to - The target file format
|
|
42
|
+
* @returns True if the transformation is supported, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
declare function isSupportedFileFormatTransform(from: FileFormat, to: FileFormat): boolean;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/translate/utils/validateFileFormatTransform.d.ts
|
|
47
|
+
type FileFormatTransformInput = {
|
|
48
|
+
fileFormat?: FileFormat;
|
|
49
|
+
transformFormat?: FileFormat;
|
|
50
|
+
fileName?: string;
|
|
51
|
+
fileId?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Validates file format transforms before sending upload/enqueue requests.
|
|
55
|
+
*/
|
|
56
|
+
declare function validateFileFormatTransforms(files: FileFormatTransformInput[]): void;
|
|
57
|
+
//#endregion
|
|
37
58
|
//#region src/derive/decodeVars.d.ts
|
|
38
59
|
/**
|
|
39
60
|
* Given an encoded ICU string, interpolate only _gt_ variables that have been marked with declareVar()
|
|
@@ -238,5 +259,5 @@ declare function oldHashJsxChildren({
|
|
|
238
259
|
dataFormat: string;
|
|
239
260
|
}, hashFunction?: (string: string) => string): string;
|
|
240
261
|
//#endregion
|
|
241
|
-
export { JsxChild, JsxChildren, JsxElement, LocaleProperties, type OldBranchType, type OldGTProp, type OldJsxChild, type OldJsxChildren, type OldJsxElement, type OldVariableObject, type OldVariableType, VAR_IDENTIFIER, VAR_NAME_IDENTIFIER, _Content, condenseVars, declareStatic, declareVar, decode, decodeVars, defaultBaseUrl, defaultCacheUrl, defaultRuntimeApiUrl, defaultTimeout, derive, encode, extractVars, getNewBranchType, getNewGTProp, getNewJsxChild, getNewJsxChildren, getNewJsxElement, getNewVariableObject, getNewVariableType, getOldBranchType, getOldGTProp, getOldJsxChild, getOldJsxChildren, getOldJsxElement, getOldVariableObject, getOldVariableType, _getPluralForm as getPluralForm, indexVars, isAcceptedPluralForm, isNewVariableObject, isOldJsxChildren, isOldVariableObject, isVariable, libraryDefaultLocale, minifyVariableType, oldHashJsxChildren, oldHashString, pluralForms };
|
|
262
|
+
export { JsxChild, JsxChildren, JsxElement, LocaleProperties, type OldBranchType, type OldGTProp, type OldJsxChild, type OldJsxChildren, type OldJsxElement, type OldVariableObject, type OldVariableType, VAR_IDENTIFIER, VAR_NAME_IDENTIFIER, _Content, condenseVars, declareStatic, declareVar, decode, decodeVars, defaultBaseUrl, defaultCacheUrl, defaultRuntimeApiUrl, defaultTimeout, derive, encode, extractVars, getNewBranchType, getNewGTProp, getNewJsxChild, getNewJsxChildren, getNewJsxElement, getNewVariableObject, getNewVariableType, getOldBranchType, getOldGTProp, getOldJsxChild, getOldJsxChildren, getOldJsxElement, getOldVariableObject, getOldVariableType, _getPluralForm as getPluralForm, indexVars, isAcceptedPluralForm, isNewVariableObject, isOldJsxChildren, isOldVariableObject, isSupportedFileFormatTransform, isVariable, libraryDefaultLocale, minifyVariableType, oldHashJsxChildren, oldHashString, pluralForms, validateFileFormatTransforms };
|
|
242
263
|
//# sourceMappingURL=internal.d.cts.map
|
package/dist/internal.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { At as VariableType, Ct as JsxChild, St as IcuMessage, Tt as JsxElement, _t as GTProp, jt as LocaleProperties, kt as Variable, l as _Content, p as VariableTransformationSuffix, wt as JsxChildren } from "./types-
|
|
1
|
+
import { At as VariableType, Ct as JsxChild, Q as FileFormat, St as IcuMessage, Tt as JsxElement, _t as GTProp, jt as LocaleProperties, kt as Variable, l as _Content, p as VariableTransformationSuffix, wt as JsxChildren } from "./types-DazaDJbs.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/settings/settingsUrls.d.ts
|
|
4
4
|
declare const defaultCacheUrl: "https://cdn.gtx.dev";
|
|
@@ -34,6 +34,27 @@ declare function minifyVariableType(variableType: VariableTransformationSuffix):
|
|
|
34
34
|
declare function encode(data: string): string;
|
|
35
35
|
declare function decode(base64: string): string;
|
|
36
36
|
//#endregion
|
|
37
|
+
//#region src/utils/isSupportedFileFormatTransform.d.ts
|
|
38
|
+
/**
|
|
39
|
+
* This function checks if a file format transformation is supported during translation
|
|
40
|
+
* @param from - The source file format
|
|
41
|
+
* @param to - The target file format
|
|
42
|
+
* @returns True if the transformation is supported, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
declare function isSupportedFileFormatTransform(from: FileFormat, to: FileFormat): boolean;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/translate/utils/validateFileFormatTransform.d.ts
|
|
47
|
+
type FileFormatTransformInput = {
|
|
48
|
+
fileFormat?: FileFormat;
|
|
49
|
+
transformFormat?: FileFormat;
|
|
50
|
+
fileName?: string;
|
|
51
|
+
fileId?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Validates file format transforms before sending upload/enqueue requests.
|
|
55
|
+
*/
|
|
56
|
+
declare function validateFileFormatTransforms(files: FileFormatTransformInput[]): void;
|
|
57
|
+
//#endregion
|
|
37
58
|
//#region src/derive/decodeVars.d.ts
|
|
38
59
|
/**
|
|
39
60
|
* Given an encoded ICU string, interpolate only _gt_ variables that have been marked with declareVar()
|
|
@@ -238,5 +259,5 @@ declare function oldHashJsxChildren({
|
|
|
238
259
|
dataFormat: string;
|
|
239
260
|
}, hashFunction?: (string: string) => string): string;
|
|
240
261
|
//#endregion
|
|
241
|
-
export { JsxChild, JsxChildren, JsxElement, LocaleProperties, type OldBranchType, type OldGTProp, type OldJsxChild, type OldJsxChildren, type OldJsxElement, type OldVariableObject, type OldVariableType, VAR_IDENTIFIER, VAR_NAME_IDENTIFIER, _Content, condenseVars, declareStatic, declareVar, decode, decodeVars, defaultBaseUrl, defaultCacheUrl, defaultRuntimeApiUrl, defaultTimeout, derive, encode, extractVars, getNewBranchType, getNewGTProp, getNewJsxChild, getNewJsxChildren, getNewJsxElement, getNewVariableObject, getNewVariableType, getOldBranchType, getOldGTProp, getOldJsxChild, getOldJsxChildren, getOldJsxElement, getOldVariableObject, getOldVariableType, _getPluralForm as getPluralForm, indexVars, isAcceptedPluralForm, isNewVariableObject, isOldJsxChildren, isOldVariableObject, isVariable, libraryDefaultLocale, minifyVariableType, oldHashJsxChildren, oldHashString, pluralForms };
|
|
262
|
+
export { JsxChild, JsxChildren, JsxElement, LocaleProperties, type OldBranchType, type OldGTProp, type OldJsxChild, type OldJsxChildren, type OldJsxElement, type OldVariableObject, type OldVariableType, VAR_IDENTIFIER, VAR_NAME_IDENTIFIER, _Content, condenseVars, declareStatic, declareVar, decode, decodeVars, defaultBaseUrl, defaultCacheUrl, defaultRuntimeApiUrl, defaultTimeout, derive, encode, extractVars, getNewBranchType, getNewGTProp, getNewJsxChild, getNewJsxChildren, getNewJsxElement, getNewVariableObject, getNewVariableType, getOldBranchType, getOldGTProp, getOldJsxChild, getOldJsxChildren, getOldJsxElement, getOldVariableObject, getOldVariableType, _getPluralForm as getPluralForm, indexVars, isAcceptedPluralForm, isNewVariableObject, isOldJsxChildren, isOldVariableObject, isSupportedFileFormatTransform, isVariable, libraryDefaultLocale, minifyVariableType, oldHashJsxChildren, oldHashString, pluralForms, validateFileFormatTransforms };
|
|
242
263
|
//# sourceMappingURL=internal.d.mts.map
|
package/dist/internal.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as isSupportedFileFormatTransform, C as declareStatic, D as VAR_IDENTIFIER, E as decodeVars, F as isAcceptedPluralForm, H as libraryDefaultLocale, I as pluralForms, L as defaultBaseUrl, M as encode, N as minifyVariableType, O as VAR_NAME_IDENTIFIER, P as _getPluralForm, R as defaultCacheUrl, S as indexVars, T as declareVar, V as defaultTimeout, _ as isNewVariableObject, a as getNewJsxChild, b as condenseVars, c as getNewVariableObject, d as getOldGTProp, f as getOldJsxChild, g as getOldVariableType, h as getOldVariableObject, i as getNewGTProp, j as decode, k as validateFileFormatTransforms, l as getNewVariableType, m as getOldJsxElement, n as oldHashString, o as getNewJsxChildren, p as getOldJsxChildren, r as getNewBranchType, s as getNewJsxElement, t as oldHashJsxChildren, u as getOldBranchType, v as isOldJsxChildren, w as derive, x as extractVars, y as isOldVariableObject, z as defaultRuntimeApiUrl } from "./internal-B3QbyI_5.mjs";
|
|
2
2
|
import { n as isVariable } from "./stableStringify-DgDlE_pD.mjs";
|
|
3
|
-
export { VAR_IDENTIFIER, VAR_NAME_IDENTIFIER, condenseVars, declareStatic, declareVar, decode, decodeVars, defaultBaseUrl, defaultCacheUrl, defaultRuntimeApiUrl, defaultTimeout, derive, encode, extractVars, getNewBranchType, getNewGTProp, getNewJsxChild, getNewJsxChildren, getNewJsxElement, getNewVariableObject, getNewVariableType, getOldBranchType, getOldGTProp, getOldJsxChild, getOldJsxChildren, getOldJsxElement, getOldVariableObject, getOldVariableType, _getPluralForm as getPluralForm, indexVars, isAcceptedPluralForm, isNewVariableObject, isOldJsxChildren, isOldVariableObject, isVariable, libraryDefaultLocale, minifyVariableType, oldHashJsxChildren, oldHashString, pluralForms };
|
|
3
|
+
export { VAR_IDENTIFIER, VAR_NAME_IDENTIFIER, condenseVars, declareStatic, declareVar, decode, decodeVars, defaultBaseUrl, defaultCacheUrl, defaultRuntimeApiUrl, defaultTimeout, derive, encode, extractVars, getNewBranchType, getNewGTProp, getNewJsxChild, getNewJsxChildren, getNewJsxElement, getNewVariableObject, getNewVariableType, getOldBranchType, getOldGTProp, getOldJsxChild, getOldJsxChildren, getOldJsxElement, getOldVariableObject, getOldVariableType, _getPluralForm as getPluralForm, indexVars, isAcceptedPluralForm, isNewVariableObject, isOldJsxChildren, isOldVariableObject, isSupportedFileFormatTransform, isVariable, libraryDefaultLocale, minifyVariableType, oldHashJsxChildren, oldHashString, pluralForms, validateFileFormatTransforms };
|
|
@@ -248,7 +248,7 @@ type EnqueueFilesResult = {
|
|
|
248
248
|
};
|
|
249
249
|
//#endregion
|
|
250
250
|
//#region src/types-dir/api/file.d.ts
|
|
251
|
-
type FileFormat = 'GTJSON' | 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS' | 'HTML' | 'TXT' | 'TWILIO_CONTENT_JSON';
|
|
251
|
+
type FileFormat = 'GTJSON' | 'JSON' | 'PO' | 'POT' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS' | 'HTML' | 'TXT' | 'TWILIO_CONTENT_JSON';
|
|
252
252
|
/**
|
|
253
253
|
* Metadata for files or entries
|
|
254
254
|
*/
|
|
@@ -265,6 +265,7 @@ type FormatMetadata = Record<string, any> | Updates[number]['metadata'];
|
|
|
265
265
|
type FileToUpload = Omit<FileReference, 'branchId'> & {
|
|
266
266
|
content: string;
|
|
267
267
|
locale: string;
|
|
268
|
+
transformFormat?: FileFormat;
|
|
268
269
|
formatMetadata?: FormatMetadata;
|
|
269
270
|
branchId?: string;
|
|
270
271
|
incomingBranchId?: string;
|
|
@@ -286,6 +287,7 @@ type FileReference = {
|
|
|
286
287
|
branchId: string;
|
|
287
288
|
fileName: string;
|
|
288
289
|
fileFormat: FileFormat;
|
|
290
|
+
transformFormat?: FileFormat;
|
|
289
291
|
dataFormat?: DataFormat;
|
|
290
292
|
};
|
|
291
293
|
/**
|
|
@@ -297,6 +299,7 @@ type FileReferenceIds = Omit<FileReference, 'branchId' | 'fileName' | 'fileForma
|
|
|
297
299
|
branchId?: string;
|
|
298
300
|
fileName?: string;
|
|
299
301
|
fileFormat?: FileFormat;
|
|
302
|
+
transformFormat?: FileFormat;
|
|
300
303
|
dataFormat?: DataFormat;
|
|
301
304
|
};
|
|
302
305
|
//#endregion
|
|
@@ -386,6 +389,7 @@ type FileUpload = {
|
|
|
386
389
|
content: string;
|
|
387
390
|
fileName: string;
|
|
388
391
|
fileFormat: FileFormat;
|
|
392
|
+
transformFormat?: FileFormat;
|
|
389
393
|
dataFormat?: DataFormat;
|
|
390
394
|
locale: string;
|
|
391
395
|
formatMetadata?: GTJsonFormatMetadata;
|
|
@@ -734,4 +738,4 @@ type TranslationRequestConfig = {
|
|
|
734
738
|
};
|
|
735
739
|
//#endregion
|
|
736
740
|
export { FileReference as $, BranchDataResult as A, VariableType as At, FileUpload as B, ProcessMovesOptions as C, JsxChild as Ct, FileDataQuery as D, StringFormat as Dt, OrphanedFile as E, StringContent as Et, DownloadFileOptions as F, FetchTranslationsOptions as G, UploadFilesResponse as H, PublishFileEntry as I, DownloadFileBatchOptions as J, FetchTranslationsResult as K, PublishFilesResult as L, TranslationError as M, CustomMapping as Mt, TranslationResult as N, FileDataResult as O, StringMessage as Ot, TranslationResultReference as P, FileFormat as Q, EnqueueEntriesOptions as R, MoveResult as S, IcuMessage as St, GetOrphanedFilesResult as T, JsxElement as Tt, CreateTagOptions as U, UploadFilesOptions as V, CreateTagResult as W, DownloadFileBatchResult as X, DownloadFileBatchRequest as Y, DownloadedFile as Z, AwaitJobsResult as _, GTProp as _t, Metadata as a, CheckFileTranslationsOptions as at, JobStatus as b, HtmlContentPropValuesRecord as bt, Update as c, FileTranslationQuery as ct, Transformation as d, ActionType as dt, FileReferenceIds as et, TransformationPrefix as f, EntryMetadata as ft, AwaitJobsOptions as g, DataFormat as gt, SubmitUserEditDiffsPayload as h, Content as ht, JsxTranslationResult as i, Updates as it, TranslateManyResult as j, LocaleProperties as jt, BranchQuery as k, Variable as kt, _Content as l, TranslationStatusResult as lt, SubmitUserEditDiff as m, TranslateOptions as mt, FormatVariables as n, EnqueueFilesOptions as nt, Request as o, FileQuery as ot, VariableTransformationSuffix as p, TranslateManyEntry as pt, RetrievedTranslations as q, IcuTranslationResult as r, EnqueueFilesResult as rt, TranslationRequestConfig as s, FileQueryResult as st, ContentTranslationResult as t, FileToUpload as tt, InjectionType as u, HashMetadata as ut, JobResult as v, HTML_CONTENT_PROPS as vt, ProcessMovesResponse as w, JsxChildren as wt, MoveMapping as x, I18nextMessage as xt, CheckJobStatusResult as y, HtmlContentPropKeysRecord as yt, EnqueueEntriesResult as z };
|
|
737
|
-
//# sourceMappingURL=types-
|
|
741
|
+
//# sourceMappingURL=types-BJdoI1d1.d.cts.map
|