generaltranslation 9.1.7 → 9.1.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 +9 -0
- package/dist/{derive-CM6w3hKI.cjs → derive-1duzCbcf.cjs} +3 -2
- package/dist/derive-1duzCbcf.cjs.map +1 -0
- package/dist/{derive-C7Gc7al2.mjs → derive-DV9XWTyV.mjs} +3 -2
- package/dist/derive-DV9XWTyV.mjs.map +1 -0
- package/dist/file-BO51iVUx.cjs.map +1 -1
- package/dist/file-CY2B-8Wr.mjs.map +1 -1
- package/dist/id.d.cts +1 -1
- package/dist/id.d.mts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.mts +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/runtime.d.cts +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/{types-CIpn1IRu.d.cts → types-B4GoI2-J.d.mts} +3 -2
- package/dist/{types-DVvoNXAh.d.mts → types-O9wUKsiq.d.cts} +3 -2
- package/dist/types-dir/api/file.d.ts +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/utils/isSupportedFileFormatTransform.js +1 -0
- package/package.json +2 -1
- package/dist/derive-C7Gc7al2.mjs.map +0 -1
- package/dist/derive-CM6w3hKI.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# generaltranslation
|
|
2
2
|
|
|
3
|
+
## 9.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2178](https://github.com/generaltranslation/gt/pull/2178) [`34845f9`](https://github.com/generaltranslation/gt/commit/34845f92d64fd9c94a712e4710e8958022066b7b) Thanks [@chenxin-yan](https://github.com/chenxin-yan)! - Add the generated TypeScript SDK for the General Translation API, derive the core `FileFormat` type from its OpenAPI-generated contract, and retry requests according to method safety and the configured backoff policy.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`34845f9`](https://github.com/generaltranslation/gt/commit/34845f92d64fd9c94a712e4710e8958022066b7b)]:
|
|
10
|
+
- @generaltranslation/api@0.0.1
|
|
11
|
+
|
|
3
12
|
## 9.1.7
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -13,7 +13,8 @@ const SUPPORTED_TRANSFORMATIONS = {
|
|
|
13
13
|
HTML: ["HTML"],
|
|
14
14
|
TXT: ["TXT"],
|
|
15
15
|
TWILIO_CONTENT_JSON: ["TWILIO_CONTENT_JSON"],
|
|
16
|
-
LOTTIE: ["LOTTIE"]
|
|
16
|
+
LOTTIE: ["LOTTIE"],
|
|
17
|
+
SVG: ["SVG"]
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* This function checks if a file format transformation is supported during translation
|
|
@@ -276,4 +277,4 @@ Object.defineProperty(exports, "traverseIcu", {
|
|
|
276
277
|
}
|
|
277
278
|
});
|
|
278
279
|
|
|
279
|
-
//# sourceMappingURL=derive-
|
|
280
|
+
//# sourceMappingURL=derive-1duzCbcf.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-1duzCbcf.cjs","names":["TYPE","TYPE"],"sources":["../src/utils/isSupportedFileFormatTransform.ts","../src/utils/base64.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"],"sourcesContent":["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 LOTTIE: ['LOTTIE'],\n SVG: ['SVG'],\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","// 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 {\n parse,\n TYPE,\n type MessageFormatElement,\n type ParserOptions,\n} from '@generaltranslation/icu';\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 { TYPE, type MessageFormatElement } from '@generaltranslation/icu';\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 * Marks content as derivable by the GT compiler and CLI.\n *\n * Use `derive()` when a translation string or context needs content that is\n * computed from source code, but should still be discovered during extraction\n * instead of treated as a runtime interpolation variable. The CLI attempts to\n * resolve the derivable expression into every possible static value and\n * includes those values in the source content that gets translated.\n *\n * `derive()` returns its argument unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `derive()` calls to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\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 derive for translation extraction.\n * @returns {T} The same content, unchanged at runtime.\n */\nexport function derive<T extends string | boolean | number | null | undefined>(\n content: T\n): T {\n return content;\n}\n"],"mappings":";;AAEA,MAAM,4BAA4B;CAChC,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,OAAO;CACd,IAAI,CAAC,KAAK;CAEV,KAAK,CAAC,OAAO,KAAK;CAClB,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,qBAAqB,CAAC,sBAAsB;CAC5C,QAAQ,CAAC,SAAS;CAClB,KAAK,CAAC,MAAM;CACb;;;;;;;AAQD,SAAgB,+BACd,MACA,IACS;AAET,QAD4C,0BAA0B,OACpD,SAAS,GAAG,IAAI;;;;AC9BpC,SAAgB,OAAO,MAAsB;AAC3C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,MAAM,OAAO,CAAC,SAAS,SAAS;CAGrD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK;CAC5C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,WAAU,OAAO,aAAa,MAAM,GAAG;A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MAAM,oBAAoB,OAAO,OAAO,aAAa;AAErD,KAAI,sBAAsB,GAExB,QAAO;CAIT,IAAI,mBAAmB;AACvB,MAAK,IAAI,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,IACtC,KAAI,aAAa,KAAK,OAAO,GAAG,EAAE;AAChC,qBAAmB;AACnB;;AAKJ,UACE,OAAO,MAAM,GAAG,kBAAkB,GAClC,MACA,OAAO,MAAM,mBAAmB,mBAAmB,EAAE,GACrD,MACA,OAAO,MAAM,mBAAmB,EAAE;AAEpC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfT,SAAgB,WACd,UACA,SACQ;CAGR,MAAM,kBAAkB,WADE,YAAY,OAAO,YAAY,GAAG,CACR,CAAC;CAGrD,IAAI,cAAc;AAClB,KAAI,SAAS,MAEX,eAAc,IAAI,oBAAoB,IADhB,YAAY,QAAQ,MACa,CAAC;AAI1D,QAAO,IAAI,eAAe,WAAW,kBAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfrE,SAAgB,OACd,SACG;AACH,QAAO"}
|
|
@@ -13,7 +13,8 @@ const SUPPORTED_TRANSFORMATIONS = {
|
|
|
13
13
|
HTML: ["HTML"],
|
|
14
14
|
TXT: ["TXT"],
|
|
15
15
|
TWILIO_CONTENT_JSON: ["TWILIO_CONTENT_JSON"],
|
|
16
|
-
LOTTIE: ["LOTTIE"]
|
|
16
|
+
LOTTIE: ["LOTTIE"],
|
|
17
|
+
SVG: ["SVG"]
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* This function checks if a file format transformation is supported during translation
|
|
@@ -217,4 +218,4 @@ function derive(content) {
|
|
|
217
218
|
//#endregion
|
|
218
219
|
export { isGTUnindexedSelectElement as a, decode as c, isGTIndexedSelectElement as i, encode as l, declareVar as n, VAR_IDENTIFIER as o, decodeVars as r, traverseIcu as s, derive as t, isSupportedFileFormatTransform as u };
|
|
219
220
|
|
|
220
|
-
//# sourceMappingURL=derive-
|
|
221
|
+
//# sourceMappingURL=derive-DV9XWTyV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-DV9XWTyV.mjs","names":[],"sources":["../src/utils/isSupportedFileFormatTransform.ts","../src/utils/base64.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"],"sourcesContent":["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 LOTTIE: ['LOTTIE'],\n SVG: ['SVG'],\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","// 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 {\n parse,\n TYPE,\n type MessageFormatElement,\n type ParserOptions,\n} from '@generaltranslation/icu';\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 { TYPE, type MessageFormatElement } from '@generaltranslation/icu';\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 * Marks content as derivable by the GT compiler and CLI.\n *\n * Use `derive()` when a translation string or context needs content that is\n * computed from source code, but should still be discovered during extraction\n * instead of treated as a runtime interpolation variable. The CLI attempts to\n * resolve the derivable expression into every possible static value and\n * includes those values in the source content that gets translated.\n *\n * `derive()` returns its argument unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `derive()` calls to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\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 derive for translation extraction.\n * @returns {T} The same content, unchanged at runtime.\n */\nexport function derive<T extends string | boolean | number | null | undefined>(\n content: T\n): T {\n return content;\n}\n"],"mappings":";;AAEA,MAAM,4BAA4B;CAChC,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,OAAO;CACd,IAAI,CAAC,KAAK;CAEV,KAAK,CAAC,OAAO,KAAK;CAClB,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,IAAI,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Aa,EAAE;AACrB,MAAK,IAAI,IAAI,GAAG,IAAI,kBAAkB,QAAQ,KAAK;AACjD,aAAW,KAAK,UAAU,MAAM,eAAe,kBAAkB,GAAG,MAAM,CAAC;AAC3E,aAAW,KAAK,kBAAkB,GAAG,MAAM;AAC3C,kBAAgB,kBAAkB,GAAG;;AAEvC,KAAI,gBAAgB,UAAU,OAC5B,YAAW,KAAK,UAAU,MAAM,cAAc,CAAC;AAIjD,QAFqB,WAAW,KAAK,GAElB;;;;;;;;;;;;;;;ACnDrB,SAAgB,YAAY,QAAwB;CAElD,IAAI,SAAS,OAAO,QAAQ,MAAM,KAAK;CAGvC,MAAM,eAAe;CACrB,MAAM,oBAAoB,OAAO,OAAO,aAAa;AAErD,KAAI,sBAAsB,GAExB,QAAO;CAIT,IAAI,mBAAmB;AACvB,MAAK,IAAI,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,IACtC,KAAI,aAAa,KAAK,OAAO,GAAG,EAAE;AAChC,qBAAmB;AACnB;;AAKJ,UACE,OAAO,MAAM,GAAG,kBAAkB,GAClC,MACA,OAAO,MAAM,mBAAmB,mBAAmB,EAAE,GACrD,MACA,OAAO,MAAM,mBAAmB,EAAE;AAEpC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfT,SAAgB,WACd,UACA,SACQ;CAGR,MAAM,kBAAkB,WADE,YAAY,OAAO,YAAY,GAAG,CACR,CAAC;CAGrD,IAAI,cAAc;AAClB,KAAI,SAAS,MAEX,eAAc,IAAI,oBAAoB,IADhB,YAAY,QAAQ,MACa,CAAC;AAI1D,QAAO,IAAI,eAAe,WAAW,kBAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfrE,SAAgB,OACd,SACG;AACH,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-BO51iVUx.cjs","names":[],"sources":["../src/types-dir/api/file.ts"],"sourcesContent":["import type { DataFormat } from '@generaltranslation/format/types';\nimport { Updates } from './enqueueFiles';\nimport type { JsonObject } from './json';\n\nexport type FileFormat
|
|
1
|
+
{"version":3,"file":"file-BO51iVUx.cjs","names":[],"sources":["../src/types-dir/api/file.ts"],"sourcesContent":["import type { DataFormat } from '@generaltranslation/format/types';\nimport { Updates } from './enqueueFiles';\nimport type { JsonObject } from './json';\n\nexport type FileFormat = import('@generaltranslation/api').FileFormat;\n\n/**\n * File formats whose content is binary (e.g. zip bundles) rather than text.\n * Their content travels through the pipeline already base64-encoded, so the\n * usual UTF-8 encode/decode steps must be skipped to avoid corrupting bytes.\n */\nexport const BINARY_FILE_FORMATS: ReadonlySet<FileFormat> = new Set<FileFormat>(\n ['LOTTIE']\n);\n\n/**\n * Whether a file format's content is binary (carried as base64 end-to-end)\n * rather than a UTF-8 text string.\n */\nexport function isBinaryFileFormat(fileFormat: FileFormat): boolean {\n return BINARY_FILE_FORMATS.has(fileFormat);\n}\n\n/**\n * Metadata for files or entries.\n */\nexport type FormatMetadata = JsonObject | Updates[number]['metadata'];\n\n/**\n * File object structure for uploading files.\n * @see {@link FileReferenceOptionalBranchId}\n * @property {string} content - Content of the file.\n * @property {string} locale - The locale of the file (e.g. 'en', 'de', 'es', etc.)\n * @property {FormatMetadata} [formatMetadata] - Optional metadata for the file, specific to the format of the file\n * @property {string} [incomingBranchId] - The ID of the incoming branch of the file.\n * @property {string} [checkedOutBranchId] - The ID of the checked-out branch of the file.\n */\nexport type FileToUpload = Omit<FileReference, 'branchId'> & {\n content: string;\n locale: string;\n // Optional output format requested for generated translations.\n transformFormat?: FileFormat;\n formatMetadata?: FormatMetadata;\n branchId?: string;\n incomingBranchId?: string;\n checkedOutBranchId?: string;\n};\n\n/**\n * File object structure for referencing files.\n * @property {string} fileId - The ID of the file.\n * @property {string} versionId - The ID of the version of the file\n * @property {string} branchId - The ID of the branch of the file\n * @property {string} locale - The locale of the file (e.g. 'en', 'de', 'es', etc.)\n * @property {string} fileName - The name of the file.\n * @property {FileFormat} fileFormat - The format of the file (JSON, MDX, MD, etc.).\n * @property {DataFormat} [dataFormat] - Optional format of the data within the file.\n */\nexport type FileReference = {\n fileId: string;\n versionId: string;\n branchId: string;\n fileName: string;\n fileFormat: FileFormat;\n // Optional output format requested for generated translations.\n transformFormat?: FileFormat;\n dataFormat?: DataFormat;\n};\n\n/**\n * File reference object structure for referencing files.\n * @see {@link FileReference}\n * @property {string} [branchId] - The ID of the branch of the file\n */\nexport type FileReferenceIds = Omit<\n FileReference,\n 'branchId' | 'fileName' | 'fileFormat' | 'dataFormat'\n> & {\n branchId?: string;\n fileName?: string;\n fileFormat?: FileFormat;\n transformFormat?: FileFormat;\n dataFormat?: DataFormat;\n};\n"],"mappings":";;;;;;AAWA,MAAa,sBAA+C,IAAI,IAC9D,CAAC,SAAS,CACX;;;;;AAMD,SAAgB,mBAAmB,YAAiC;AAClE,QAAO,oBAAoB,IAAI,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-CY2B-8Wr.mjs","names":[],"sources":["../src/types-dir/api/file.ts"],"sourcesContent":["import type { DataFormat } from '@generaltranslation/format/types';\nimport { Updates } from './enqueueFiles';\nimport type { JsonObject } from './json';\n\nexport type FileFormat
|
|
1
|
+
{"version":3,"file":"file-CY2B-8Wr.mjs","names":[],"sources":["../src/types-dir/api/file.ts"],"sourcesContent":["import type { DataFormat } from '@generaltranslation/format/types';\nimport { Updates } from './enqueueFiles';\nimport type { JsonObject } from './json';\n\nexport type FileFormat = import('@generaltranslation/api').FileFormat;\n\n/**\n * File formats whose content is binary (e.g. zip bundles) rather than text.\n * Their content travels through the pipeline already base64-encoded, so the\n * usual UTF-8 encode/decode steps must be skipped to avoid corrupting bytes.\n */\nexport const BINARY_FILE_FORMATS: ReadonlySet<FileFormat> = new Set<FileFormat>(\n ['LOTTIE']\n);\n\n/**\n * Whether a file format's content is binary (carried as base64 end-to-end)\n * rather than a UTF-8 text string.\n */\nexport function isBinaryFileFormat(fileFormat: FileFormat): boolean {\n return BINARY_FILE_FORMATS.has(fileFormat);\n}\n\n/**\n * Metadata for files or entries.\n */\nexport type FormatMetadata = JsonObject | Updates[number]['metadata'];\n\n/**\n * File object structure for uploading files.\n * @see {@link FileReferenceOptionalBranchId}\n * @property {string} content - Content of the file.\n * @property {string} locale - The locale of the file (e.g. 'en', 'de', 'es', etc.)\n * @property {FormatMetadata} [formatMetadata] - Optional metadata for the file, specific to the format of the file\n * @property {string} [incomingBranchId] - The ID of the incoming branch of the file.\n * @property {string} [checkedOutBranchId] - The ID of the checked-out branch of the file.\n */\nexport type FileToUpload = Omit<FileReference, 'branchId'> & {\n content: string;\n locale: string;\n // Optional output format requested for generated translations.\n transformFormat?: FileFormat;\n formatMetadata?: FormatMetadata;\n branchId?: string;\n incomingBranchId?: string;\n checkedOutBranchId?: string;\n};\n\n/**\n * File object structure for referencing files.\n * @property {string} fileId - The ID of the file.\n * @property {string} versionId - The ID of the version of the file\n * @property {string} branchId - The ID of the branch of the file\n * @property {string} locale - The locale of the file (e.g. 'en', 'de', 'es', etc.)\n * @property {string} fileName - The name of the file.\n * @property {FileFormat} fileFormat - The format of the file (JSON, MDX, MD, etc.).\n * @property {DataFormat} [dataFormat] - Optional format of the data within the file.\n */\nexport type FileReference = {\n fileId: string;\n versionId: string;\n branchId: string;\n fileName: string;\n fileFormat: FileFormat;\n // Optional output format requested for generated translations.\n transformFormat?: FileFormat;\n dataFormat?: DataFormat;\n};\n\n/**\n * File reference object structure for referencing files.\n * @see {@link FileReference}\n * @property {string} [branchId] - The ID of the branch of the file\n */\nexport type FileReferenceIds = Omit<\n FileReference,\n 'branchId' | 'fileName' | 'fileFormat' | 'dataFormat'\n> & {\n branchId?: string;\n fileName?: string;\n fileFormat?: FileFormat;\n transformFormat?: FileFormat;\n dataFormat?: DataFormat;\n};\n"],"mappings":";;;;;;AAWA,MAAa,sBAA+C,IAAI,IAC9D,CAAC,SAAS,CACX;;;;;AAMD,SAAgB,mBAAmB,YAAiC;AAClE,QAAO,oBAAoB,IAAI,WAAW"}
|
package/dist/id.d.cts
CHANGED
package/dist/id.d.mts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_api = require("./api-tMgy8sHj.cjs");
|
|
3
3
|
const require_runtime = require("./runtime-DoOLkKJT.cjs");
|
|
4
|
-
const require_derive = require("./derive-
|
|
4
|
+
const require_derive = require("./derive-1duzCbcf.cjs");
|
|
5
5
|
const require_file = require("./file-BO51iVUx.cjs");
|
|
6
6
|
let _generaltranslation_format = require("@generaltranslation/format");
|
|
7
7
|
//#region src/translate/setupProject.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as UploadFilesOptions, A as AwaitJobsOptions, F as MoveMapping, H as FileDataResult, L as ProcessMovesOptions, N as CheckJobStatusResult, Q as FileUpload, R as ProcessMovesResponse, U as BranchQuery, V as FileDataQuery, W as BranchDataResult, X as PublishFileEntry, Y as DownloadFileOptions, Z as PublishFilesResult, _t as EnqueueFilesResult, at as CreateTagResult, bt as FileQuery, ct as DownloadFileBatchRequest, et as UploadFilesResponse, it as CreateTagOptions, j as AwaitJobsResult, k as SubmitUserEditDiffsPayload, lt as DownloadFileBatchResult, mt as FileReferenceIds, nt as SetupProjectOptions, ot as EnqueueFilesOptions, rt as SetupProjectResult, st as DownloadFileBatchOptions, tt as SetupProjectFileReference, xt as FileQueryResult, yt as CheckFileTranslationsOptions, z as GetOrphanedFilesResult } from "./types-
|
|
1
|
+
import { $ as UploadFilesOptions, A as AwaitJobsOptions, F as MoveMapping, H as FileDataResult, L as ProcessMovesOptions, N as CheckJobStatusResult, Q as FileUpload, R as ProcessMovesResponse, U as BranchQuery, V as FileDataQuery, W as BranchDataResult, X as PublishFileEntry, Y as DownloadFileOptions, Z as PublishFilesResult, _t as EnqueueFilesResult, at as CreateTagResult, bt as FileQuery, ct as DownloadFileBatchRequest, et as UploadFilesResponse, it as CreateTagOptions, j as AwaitJobsResult, k as SubmitUserEditDiffsPayload, lt as DownloadFileBatchResult, mt as FileReferenceIds, nt as SetupProjectOptions, ot as EnqueueFilesOptions, rt as SetupProjectResult, st as DownloadFileBatchOptions, tt as SetupProjectFileReference, xt as FileQueryResult, yt as CheckFileTranslationsOptions, z as GetOrphanedFilesResult } from "./types-O9wUKsiq.cjs";
|
|
2
2
|
import { GTConstructorParams, GTRuntime } from "./runtime.cjs";
|
|
3
3
|
import { n as declareVar, r as decodeVars, t as derive } from "./derive-DBCCXTmL.cjs";
|
|
4
4
|
import { LocaleConfig, LocaleConfigConstructorParams, determineLocale, formatCurrency, formatCutoff, formatDateTime, formatList, formatListToParts, formatMessage, formatNum, formatRelativeTime, formatRelativeTimeFromDate, getLocaleDirection, getLocaleEmoji, getLocaleName, getLocaleProperties, getRegionProperties, isSameDialect, isSameLanguage, isSupersetLocale, isValidLocale, requiresTranslation, resolveAliasLocale, resolveCanonicalLocale, standardizeLocale } from "@generaltranslation/format";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as UploadFilesOptions, A as AwaitJobsOptions, F as MoveMapping, H as FileDataResult, L as ProcessMovesOptions, N as CheckJobStatusResult, Q as FileUpload, R as ProcessMovesResponse, U as BranchQuery, V as FileDataQuery, W as BranchDataResult, X as PublishFileEntry, Y as DownloadFileOptions, Z as PublishFilesResult, _t as EnqueueFilesResult, at as CreateTagResult, bt as FileQuery, ct as DownloadFileBatchRequest, et as UploadFilesResponse, it as CreateTagOptions, j as AwaitJobsResult, k as SubmitUserEditDiffsPayload, lt as DownloadFileBatchResult, mt as FileReferenceIds, nt as SetupProjectOptions, ot as EnqueueFilesOptions, rt as SetupProjectResult, st as DownloadFileBatchOptions, tt as SetupProjectFileReference, xt as FileQueryResult, yt as CheckFileTranslationsOptions, z as GetOrphanedFilesResult } from "./types-
|
|
1
|
+
import { $ as UploadFilesOptions, A as AwaitJobsOptions, F as MoveMapping, H as FileDataResult, L as ProcessMovesOptions, N as CheckJobStatusResult, Q as FileUpload, R as ProcessMovesResponse, U as BranchQuery, V as FileDataQuery, W as BranchDataResult, X as PublishFileEntry, Y as DownloadFileOptions, Z as PublishFilesResult, _t as EnqueueFilesResult, at as CreateTagResult, bt as FileQuery, ct as DownloadFileBatchRequest, et as UploadFilesResponse, it as CreateTagOptions, j as AwaitJobsResult, k as SubmitUserEditDiffsPayload, lt as DownloadFileBatchResult, mt as FileReferenceIds, nt as SetupProjectOptions, ot as EnqueueFilesOptions, rt as SetupProjectResult, st as DownloadFileBatchOptions, tt as SetupProjectFileReference, xt as FileQueryResult, yt as CheckFileTranslationsOptions, z as GetOrphanedFilesResult } from "./types-B4GoI2-J.mjs";
|
|
2
2
|
import { GTConstructorParams, GTRuntime } from "./runtime.mjs";
|
|
3
3
|
import { n as declareVar, r as decodeVars, t as derive } from "./derive-texIAHzc.mjs";
|
|
4
4
|
import { LocaleConfig, LocaleConfigConstructorParams, determineLocale, formatCurrency, formatCutoff, formatDateTime, formatList, formatListToParts, formatMessage, formatNum, formatRelativeTime, formatRelativeTimeFromDate, getLocaleDirection, getLocaleEmoji, getLocaleName, getLocaleProperties, getRegionProperties, isSameDialect, isSameLanguage, isSupersetLocale, isValidLocale, requiresTranslation, resolveAliasLocale, resolveCanonicalLocale, standardizeLocale } from "@generaltranslation/format";
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as defaultTimeout } from "./api-rqq7klYe.mjs";
|
|
2
2
|
import { a as validateResponse, c as noSourceLocaleProvidedError, i as handleFetchError, l as noTargetLocaleProvidedError, n as apiRequest, o as fetchWithTimeout, r as generateRequestHeaders, s as gtInstanceLogger, t as GTRuntime } from "./runtime-hWpzl6v_.mjs";
|
|
3
|
-
import { c as decode, l as encode, n as declareVar, r as decodeVars, t as derive, u as isSupportedFileFormatTransform } from "./derive-
|
|
3
|
+
import { c as decode, l as encode, n as declareVar, r as decodeVars, t as derive, u as isSupportedFileFormatTransform } from "./derive-DV9XWTyV.mjs";
|
|
4
4
|
import { n as isBinaryFileFormat } from "./file-CY2B-8Wr.mjs";
|
|
5
5
|
import { LocaleConfig, determineLocale, formatCurrency, formatCutoff, formatDateTime, formatList, formatListToParts, formatMessage, formatNum, formatRelativeTime, formatRelativeTimeFromDate, getLocaleDirection, getLocaleEmoji, getLocaleName, getLocaleProperties, getRegionProperties, isSameDialect, isSameLanguage, isSupersetLocale, isValidLocale, requiresTranslation, resolveAliasLocale, resolveCanonicalLocale, standardizeLocale } from "@generaltranslation/format";
|
|
6
6
|
//#region src/translate/setupProject.ts
|
package/dist/internal.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_api = require("./api-tMgy8sHj.cjs");
|
|
3
|
-
const require_derive = require("./derive-
|
|
3
|
+
const require_derive = require("./derive-1duzCbcf.cjs");
|
|
4
4
|
const require_isVariable = require("./isVariable-I3nllgeI.cjs");
|
|
5
5
|
let _generaltranslation_icu = require("@generaltranslation/icu");
|
|
6
6
|
let _generaltranslation_format_internal = require("@generaltranslation/format/internal");
|
package/dist/internal.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as VariableType, D as VariableTransformationSuffix, Mt as RuntimeTranslateManyOptions, S as Variable, ft as FileFormat, g as LocaleProperties, h as JsxElement, m as JsxChildren, p as JsxChild } from "./types-
|
|
1
|
+
import { C as VariableType, D as VariableTransformationSuffix, Mt as RuntimeTranslateManyOptions, S as Variable, ft as FileFormat, g as LocaleProperties, h as JsxElement, m as JsxChildren, p as JsxChild } from "./types-O9wUKsiq.cjs";
|
|
2
2
|
import { n as declareVar, r as decodeVars, t as derive } from "./derive-DBCCXTmL.cjs";
|
|
3
3
|
import { IcuMessage } from "@generaltranslation/format/types";
|
|
4
4
|
|
package/dist/internal.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as VariableType, D as VariableTransformationSuffix, Mt as RuntimeTranslateManyOptions, S as Variable, ft as FileFormat, g as LocaleProperties, h as JsxElement, m as JsxChildren, p as JsxChild } from "./types-
|
|
1
|
+
import { C as VariableType, D as VariableTransformationSuffix, Mt as RuntimeTranslateManyOptions, S as Variable, ft as FileFormat, g as LocaleProperties, h as JsxElement, m as JsxChildren, p as JsxChild } from "./types-B4GoI2-J.mjs";
|
|
2
2
|
import { n as declareVar, r as decodeVars, t as derive } from "./derive-texIAHzc.mjs";
|
|
3
3
|
import { IcuMessage } from "@generaltranslation/format/types";
|
|
4
4
|
|
package/dist/internal.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as createDiagnosticMessage, c as libraryDefaultLocale, i as defaultRuntimeApiUrl, n as defaultBaseUrl, o as formatDiagnosticErrorDetails, r as defaultCacheUrl, t as API_VERSION } from "./api-rqq7klYe.mjs";
|
|
2
|
-
import { a as isGTUnindexedSelectElement, c as decode, i as isGTIndexedSelectElement, l as encode, n as declareVar, o as VAR_IDENTIFIER, r as decodeVars, s as traverseIcu, t as derive, u as isSupportedFileFormatTransform } from "./derive-
|
|
2
|
+
import { a as isGTUnindexedSelectElement, c as decode, i as isGTIndexedSelectElement, l as encode, n as declareVar, o as VAR_IDENTIFIER, r as decodeVars, s as traverseIcu, t as derive, u as isSupportedFileFormatTransform } from "./derive-DV9XWTyV.mjs";
|
|
3
3
|
import { t as isVariable } from "./isVariable-8-Wy5FnX.mjs";
|
|
4
4
|
import { TYPE, printAST } from "@generaltranslation/icu";
|
|
5
5
|
import { getCachedPluralRules } from "@generaltranslation/format/internal";
|
package/dist/runtime.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as TranslateManyResult, K as TranslationError, Nt as TranslateManyEntry, Pt as TranslateOptions, q as TranslationResult, x as TranslationRequestConfig } from "./types-
|
|
1
|
+
import { G as TranslateManyResult, K as TranslationError, Nt as TranslateManyEntry, Pt as TranslateOptions, q as TranslationResult, x as TranslationRequestConfig } from "./types-O9wUKsiq.cjs";
|
|
2
2
|
import { CustomMapping, CustomRegionMapping, CutoffFormatOptions, FormatVariables, LocaleProperties, StringFormat } from "@generaltranslation/format/types";
|
|
3
3
|
import { LocaleConfig } from "@generaltranslation/format";
|
|
4
4
|
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as TranslateManyResult, K as TranslationError, Nt as TranslateManyEntry, Pt as TranslateOptions, q as TranslationResult, x as TranslationRequestConfig } from "./types-
|
|
1
|
+
import { G as TranslateManyResult, K as TranslationError, Nt as TranslateManyEntry, Pt as TranslateOptions, q as TranslationResult, x as TranslationRequestConfig } from "./types-B4GoI2-J.mjs";
|
|
2
2
|
import { LocaleConfig } from "@generaltranslation/format";
|
|
3
3
|
import { CustomMapping, CustomRegionMapping, CutoffFormatOptions, FormatVariables, LocaleProperties, StringFormat } from "@generaltranslation/format/types";
|
|
4
4
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Content, CustomMapping, CustomMapping as CustomMapping$1, CustomRegionMapping as CustomRegionMapping$1, CutoffFormatOptions as CutoffFormatOptions$1, DataFormat, DataFormat as DataFormat$1, FormatVariables as FormatVariables$1, GTProp, HTML_CONTENT_PROPS, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, I18nextMessage as I18nextMessage$1, IcuMessage, IcuMessage as IcuMessage$1, JsxChild, JsxChildren, JsxChildren as JsxChildren$1, JsxElement, LocaleProperties as LocaleProperties$1, StringContent, StringFormat as StringFormat$1, StringMessage, StringMessage as StringMessage$1, Variable, VariableType } from "@generaltranslation/format/types";
|
|
2
|
+
import * as _$_generaltranslation_api0 from "@generaltranslation/api";
|
|
2
3
|
|
|
3
4
|
//#region src/types-dir/api/entry.d.ts
|
|
4
5
|
/**
|
|
@@ -222,7 +223,7 @@ type EnqueueFilesResult = {
|
|
|
222
223
|
};
|
|
223
224
|
//#endregion
|
|
224
225
|
//#region src/types-dir/api/file.d.ts
|
|
225
|
-
type FileFormat =
|
|
226
|
+
type FileFormat = _$_generaltranslation_api0.FileFormat;
|
|
226
227
|
/**
|
|
227
228
|
* File formats whose content is binary (e.g. zip bundles) rather than text.
|
|
228
229
|
* Their content travels through the pipeline already base64-encoded, so the
|
|
@@ -643,4 +644,4 @@ type TranslationRequestConfig = {
|
|
|
643
644
|
};
|
|
644
645
|
//#endregion
|
|
645
646
|
export { UploadFilesOptions as $, AwaitJobsOptions as A, ActionType as At, OrphanedFile as B, VariableType as C, JsonPrimitive as Ct, VariableTransformationSuffix as D, GTOutputFileConfig as Dt, TransformationPrefix as E, GTFilesConfig as Et, MoveMapping as F, TranslateManyResult as G, FileDataResult as H, MoveResult as I, TranslationResultReference as J, TranslationError as K, ProcessMovesOptions as L, JobResult as M, RuntimeTranslateManyOptions as Mt, CheckJobStatusResult as N, TranslateManyEntry as Nt, SubmitUserEditDiff as O, GTParsingFlags as Ot, JobStatus as P, TranslateOptions as Pt, FileUpload as Q, ProcessMovesResponse as R, Variable as S, JsonObject as St, Transformation as T, GTConfig as Tt, BranchQuery as U, FileDataQuery as V, BranchDataResult as W, PublishFileEntry as X, DownloadFileOptions as Y, PublishFilesResult as Z, Metadata as _, EnqueueFilesResult as _t, DataFormat$1 as a, CreateTagResult as at, StringMessage$1 as b, FileQuery as bt, HTML_CONTENT_PROPS as c, DownloadFileBatchRequest as ct, I18nextMessage$1 as d, BINARY_FILE_FORMATS as dt, UploadFilesResponse as et, IcuMessage$1 as f, FileFormat as ft, LocaleProperties$1 as g, isBinaryFileFormat as gt, JsxElement as h, FileToUpload as ht, CutoffFormatOptions$1 as i, CreateTagOptions as it, AwaitJobsResult as j, EntryMetadata as jt, SubmitUserEditDiffsPayload as k, HashMetadata as kt, HtmlContentPropKeysRecord as l, DownloadFileBatchResult as lt, JsxChildren$1 as m, FileReferenceIds as mt, CustomMapping$1 as n, SetupProjectOptions as nt, FormatVariables$1 as o, EnqueueFilesOptions as ot, JsxChild as p, FileReference as pt, TranslationResult as q, CustomRegionMapping$1 as r, SetupProjectResult as rt, GTProp as s, DownloadFileBatchOptions as st, Content as t, SetupProjectFileReference as tt, HtmlContentPropValuesRecord as u, DownloadedFile as ut, StringContent as v, Updates as vt, InjectionType as w, JsonValue as wt, TranslationRequestConfig as x, FileQueryResult as xt, StringFormat$1 as y, CheckFileTranslationsOptions as yt, GetOrphanedFilesResult as z };
|
|
646
|
-
//# sourceMappingURL=types-
|
|
647
|
+
//# sourceMappingURL=types-B4GoI2-J.d.mts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Content, CustomMapping, CustomMapping as CustomMapping$1, CustomRegionMapping as CustomRegionMapping$1, CutoffFormatOptions as CutoffFormatOptions$1, DataFormat, DataFormat as DataFormat$1, FormatVariables as FormatVariables$1, GTProp, HTML_CONTENT_PROPS, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, I18nextMessage as I18nextMessage$1, IcuMessage, IcuMessage as IcuMessage$1, JsxChild, JsxChildren, JsxChildren as JsxChildren$1, JsxElement, LocaleProperties as LocaleProperties$1, StringContent, StringFormat as StringFormat$1, StringMessage, StringMessage as StringMessage$1, Variable, VariableType } from "@generaltranslation/format/types";
|
|
2
|
+
import * as _$_generaltranslation_api0 from "@generaltranslation/api";
|
|
2
3
|
|
|
3
4
|
//#region src/types-dir/api/entry.d.ts
|
|
4
5
|
/**
|
|
@@ -222,7 +223,7 @@ type EnqueueFilesResult = {
|
|
|
222
223
|
};
|
|
223
224
|
//#endregion
|
|
224
225
|
//#region src/types-dir/api/file.d.ts
|
|
225
|
-
type FileFormat =
|
|
226
|
+
type FileFormat = _$_generaltranslation_api0.FileFormat;
|
|
226
227
|
/**
|
|
227
228
|
* File formats whose content is binary (e.g. zip bundles) rather than text.
|
|
228
229
|
* Their content travels through the pipeline already base64-encoded, so the
|
|
@@ -643,4 +644,4 @@ type TranslationRequestConfig = {
|
|
|
643
644
|
};
|
|
644
645
|
//#endregion
|
|
645
646
|
export { UploadFilesOptions as $, AwaitJobsOptions as A, ActionType as At, OrphanedFile as B, VariableType as C, JsonPrimitive as Ct, VariableTransformationSuffix as D, GTOutputFileConfig as Dt, TransformationPrefix as E, GTFilesConfig as Et, MoveMapping as F, TranslateManyResult as G, FileDataResult as H, MoveResult as I, TranslationResultReference as J, TranslationError as K, ProcessMovesOptions as L, JobResult as M, RuntimeTranslateManyOptions as Mt, CheckJobStatusResult as N, TranslateManyEntry as Nt, SubmitUserEditDiff as O, GTParsingFlags as Ot, JobStatus as P, TranslateOptions as Pt, FileUpload as Q, ProcessMovesResponse as R, Variable as S, JsonObject as St, Transformation as T, GTConfig as Tt, BranchQuery as U, FileDataQuery as V, BranchDataResult as W, PublishFileEntry as X, DownloadFileOptions as Y, PublishFilesResult as Z, Metadata as _, EnqueueFilesResult as _t, DataFormat$1 as a, CreateTagResult as at, StringMessage$1 as b, FileQuery as bt, HTML_CONTENT_PROPS as c, DownloadFileBatchRequest as ct, I18nextMessage$1 as d, BINARY_FILE_FORMATS as dt, UploadFilesResponse as et, IcuMessage$1 as f, FileFormat as ft, LocaleProperties$1 as g, isBinaryFileFormat as gt, JsxElement as h, FileToUpload as ht, CutoffFormatOptions$1 as i, CreateTagOptions as it, AwaitJobsResult as j, EntryMetadata as jt, SubmitUserEditDiffsPayload as k, HashMetadata as kt, HtmlContentPropKeysRecord as l, DownloadFileBatchResult as lt, JsxChildren$1 as m, FileReferenceIds as mt, CustomMapping$1 as n, SetupProjectOptions as nt, FormatVariables$1 as o, EnqueueFilesOptions as ot, JsxChild as p, FileReference as pt, TranslationResult as q, CustomRegionMapping$1 as r, SetupProjectResult as rt, GTProp as s, DownloadFileBatchOptions as st, Content as t, SetupProjectFileReference as tt, HtmlContentPropValuesRecord as u, DownloadedFile as ut, StringContent as v, Updates as vt, InjectionType as w, JsonValue as wt, TranslationRequestConfig as x, FileQueryResult as xt, StringFormat$1 as y, CheckFileTranslationsOptions as yt, GetOrphanedFilesResult as z };
|
|
646
|
-
//# sourceMappingURL=types-
|
|
647
|
+
//# sourceMappingURL=types-O9wUKsiq.d.cts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DataFormat } from '@generaltranslation/format/types';
|
|
2
2
|
import { Updates } from './enqueueFiles';
|
|
3
3
|
import type { JsonObject } from './json';
|
|
4
|
-
export type FileFormat = '
|
|
4
|
+
export type FileFormat = import('@generaltranslation/api').FileFormat;
|
|
5
5
|
/**
|
|
6
6
|
* File formats whose content is binary (e.g. zip bundles) rather than text.
|
|
7
7
|
* Their content travels through the pipeline already base64-encoded, so the
|
package/dist/types.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as AwaitJobsOptions, At as ActionType, B as OrphanedFile, C as VariableType, Ct as JsonPrimitive, D as VariableTransformationSuffix, Dt as GTOutputFileConfig, E as TransformationPrefix, Et as GTFilesConfig, F as MoveMapping, G as TranslateManyResult, H as FileDataResult, I as MoveResult, J as TranslationResultReference, K as TranslationError, L as ProcessMovesOptions, M as JobResult, N as CheckJobStatusResult, Nt as TranslateManyEntry, O as SubmitUserEditDiff, Ot as GTParsingFlags, P as JobStatus, Q as FileUpload, R as ProcessMovesResponse, S as Variable, St as JsonObject, T as Transformation, Tt as GTConfig, U as BranchQuery, V as FileDataQuery, W as BranchDataResult, X as PublishFileEntry, Y as DownloadFileOptions, Z as PublishFilesResult, _ as Metadata, _t as EnqueueFilesResult, a as DataFormat, at as CreateTagResult, b as StringMessage, c as HTML_CONTENT_PROPS, d as I18nextMessage, dt as BINARY_FILE_FORMATS, f as IcuMessage, ft as FileFormat, g as LocaleProperties, gt as isBinaryFileFormat, h as JsxElement, ht as FileToUpload, i as CutoffFormatOptions, it as CreateTagOptions, j as AwaitJobsResult, jt as EntryMetadata, k as SubmitUserEditDiffsPayload, kt as HashMetadata, l as HtmlContentPropKeysRecord, lt as DownloadFileBatchResult, m as JsxChildren, n as CustomMapping, o as FormatVariables, ot as EnqueueFilesOptions, p as JsxChild, pt as FileReference, q as TranslationResult, r as CustomRegionMapping, s as GTProp, st as DownloadFileBatchOptions, t as Content, tt as SetupProjectFileReference, u as HtmlContentPropValuesRecord, ut as DownloadedFile, v as StringContent, vt as Updates, w as InjectionType, wt as JsonValue, x as TranslationRequestConfig, y as StringFormat, yt as CheckFileTranslationsOptions, z as GetOrphanedFilesResult } from "./types-
|
|
1
|
+
import { A as AwaitJobsOptions, At as ActionType, B as OrphanedFile, C as VariableType, Ct as JsonPrimitive, D as VariableTransformationSuffix, Dt as GTOutputFileConfig, E as TransformationPrefix, Et as GTFilesConfig, F as MoveMapping, G as TranslateManyResult, H as FileDataResult, I as MoveResult, J as TranslationResultReference, K as TranslationError, L as ProcessMovesOptions, M as JobResult, N as CheckJobStatusResult, Nt as TranslateManyEntry, O as SubmitUserEditDiff, Ot as GTParsingFlags, P as JobStatus, Q as FileUpload, R as ProcessMovesResponse, S as Variable, St as JsonObject, T as Transformation, Tt as GTConfig, U as BranchQuery, V as FileDataQuery, W as BranchDataResult, X as PublishFileEntry, Y as DownloadFileOptions, Z as PublishFilesResult, _ as Metadata, _t as EnqueueFilesResult, a as DataFormat, at as CreateTagResult, b as StringMessage, c as HTML_CONTENT_PROPS, d as I18nextMessage, dt as BINARY_FILE_FORMATS, f as IcuMessage, ft as FileFormat, g as LocaleProperties, gt as isBinaryFileFormat, h as JsxElement, ht as FileToUpload, i as CutoffFormatOptions, it as CreateTagOptions, j as AwaitJobsResult, jt as EntryMetadata, k as SubmitUserEditDiffsPayload, kt as HashMetadata, l as HtmlContentPropKeysRecord, lt as DownloadFileBatchResult, m as JsxChildren, n as CustomMapping, o as FormatVariables, ot as EnqueueFilesOptions, p as JsxChild, pt as FileReference, q as TranslationResult, r as CustomRegionMapping, s as GTProp, st as DownloadFileBatchOptions, t as Content, tt as SetupProjectFileReference, u as HtmlContentPropValuesRecord, ut as DownloadedFile, v as StringContent, vt as Updates, w as InjectionType, wt as JsonValue, x as TranslationRequestConfig, y as StringFormat, yt as CheckFileTranslationsOptions, z as GetOrphanedFilesResult } from "./types-O9wUKsiq.cjs";
|
|
2
2
|
export { AwaitJobsOptions, AwaitJobsResult, BINARY_FILE_FORMATS, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, CreateTagOptions, CreateTagResult, CustomMapping, CustomRegionMapping, CutoffFormatOptions, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileUpload, FormatVariables, GTConfig, GTFilesConfig, GTOutputFileConfig, GTParsingFlags, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, InjectionType, JobResult, JobStatus, JsonObject, JsonPrimitive, JsonValue, JsxChild, JsxChildren, JsxElement, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, SetupProjectFileReference, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, Updates, Variable, VariableTransformationSuffix, VariableType, isBinaryFileFormat };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as AwaitJobsOptions, At as ActionType, B as OrphanedFile, C as VariableType, Ct as JsonPrimitive, D as VariableTransformationSuffix, Dt as GTOutputFileConfig, E as TransformationPrefix, Et as GTFilesConfig, F as MoveMapping, G as TranslateManyResult, H as FileDataResult, I as MoveResult, J as TranslationResultReference, K as TranslationError, L as ProcessMovesOptions, M as JobResult, N as CheckJobStatusResult, Nt as TranslateManyEntry, O as SubmitUserEditDiff, Ot as GTParsingFlags, P as JobStatus, Q as FileUpload, R as ProcessMovesResponse, S as Variable, St as JsonObject, T as Transformation, Tt as GTConfig, U as BranchQuery, V as FileDataQuery, W as BranchDataResult, X as PublishFileEntry, Y as DownloadFileOptions, Z as PublishFilesResult, _ as Metadata, _t as EnqueueFilesResult, a as DataFormat, at as CreateTagResult, b as StringMessage, c as HTML_CONTENT_PROPS, d as I18nextMessage, dt as BINARY_FILE_FORMATS, f as IcuMessage, ft as FileFormat, g as LocaleProperties, gt as isBinaryFileFormat, h as JsxElement, ht as FileToUpload, i as CutoffFormatOptions, it as CreateTagOptions, j as AwaitJobsResult, jt as EntryMetadata, k as SubmitUserEditDiffsPayload, kt as HashMetadata, l as HtmlContentPropKeysRecord, lt as DownloadFileBatchResult, m as JsxChildren, n as CustomMapping, o as FormatVariables, ot as EnqueueFilesOptions, p as JsxChild, pt as FileReference, q as TranslationResult, r as CustomRegionMapping, s as GTProp, st as DownloadFileBatchOptions, t as Content, tt as SetupProjectFileReference, u as HtmlContentPropValuesRecord, ut as DownloadedFile, v as StringContent, vt as Updates, w as InjectionType, wt as JsonValue, x as TranslationRequestConfig, y as StringFormat, yt as CheckFileTranslationsOptions, z as GetOrphanedFilesResult } from "./types-
|
|
1
|
+
import { A as AwaitJobsOptions, At as ActionType, B as OrphanedFile, C as VariableType, Ct as JsonPrimitive, D as VariableTransformationSuffix, Dt as GTOutputFileConfig, E as TransformationPrefix, Et as GTFilesConfig, F as MoveMapping, G as TranslateManyResult, H as FileDataResult, I as MoveResult, J as TranslationResultReference, K as TranslationError, L as ProcessMovesOptions, M as JobResult, N as CheckJobStatusResult, Nt as TranslateManyEntry, O as SubmitUserEditDiff, Ot as GTParsingFlags, P as JobStatus, Q as FileUpload, R as ProcessMovesResponse, S as Variable, St as JsonObject, T as Transformation, Tt as GTConfig, U as BranchQuery, V as FileDataQuery, W as BranchDataResult, X as PublishFileEntry, Y as DownloadFileOptions, Z as PublishFilesResult, _ as Metadata, _t as EnqueueFilesResult, a as DataFormat, at as CreateTagResult, b as StringMessage, c as HTML_CONTENT_PROPS, d as I18nextMessage, dt as BINARY_FILE_FORMATS, f as IcuMessage, ft as FileFormat, g as LocaleProperties, gt as isBinaryFileFormat, h as JsxElement, ht as FileToUpload, i as CutoffFormatOptions, it as CreateTagOptions, j as AwaitJobsResult, jt as EntryMetadata, k as SubmitUserEditDiffsPayload, kt as HashMetadata, l as HtmlContentPropKeysRecord, lt as DownloadFileBatchResult, m as JsxChildren, n as CustomMapping, o as FormatVariables, ot as EnqueueFilesOptions, p as JsxChild, pt as FileReference, q as TranslationResult, r as CustomRegionMapping, s as GTProp, st as DownloadFileBatchOptions, t as Content, tt as SetupProjectFileReference, u as HtmlContentPropValuesRecord, ut as DownloadedFile, v as StringContent, vt as Updates, w as InjectionType, wt as JsonValue, x as TranslationRequestConfig, y as StringFormat, yt as CheckFileTranslationsOptions, z as GetOrphanedFilesResult } from "./types-B4GoI2-J.mjs";
|
|
2
2
|
export { AwaitJobsOptions, AwaitJobsResult, BINARY_FILE_FORMATS, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, CreateTagOptions, CreateTagResult, CustomMapping, CustomRegionMapping, CutoffFormatOptions, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileUpload, FormatVariables, GTConfig, GTFilesConfig, GTOutputFileConfig, GTParsingFlags, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, InjectionType, JobResult, JobStatus, JsonObject, JsonPrimitive, JsonValue, JsxChild, JsxChildren, JsxElement, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, SetupProjectFileReference, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, Updates, Variable, VariableTransformationSuffix, VariableType, isBinaryFileFormat };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generaltranslation",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.8",
|
|
4
4
|
"description": "A language toolkit for AI developers",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@noble/hashes": "^2.2.0",
|
|
43
|
+
"@generaltranslation/api": "0.0.1",
|
|
43
44
|
"@generaltranslation/icu": "0.1.2",
|
|
44
45
|
"@generaltranslation/format": "0.1.8"
|
|
45
46
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"derive-C7Gc7al2.mjs","names":[],"sources":["../src/utils/isSupportedFileFormatTransform.ts","../src/utils/base64.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"],"sourcesContent":["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 LOTTIE: ['LOTTIE'],\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","// 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 {\n parse,\n TYPE,\n type MessageFormatElement,\n type ParserOptions,\n} from '@generaltranslation/icu';\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 { TYPE, type MessageFormatElement } from '@generaltranslation/icu';\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 * Marks content as derivable by the GT compiler and CLI.\n *\n * Use `derive()` when a translation string or context needs content that is\n * computed from source code, but should still be discovered during extraction\n * instead of treated as a runtime interpolation variable. The CLI attempts to\n * resolve the derivable expression into every possible static value and\n * includes those values in the source content that gets translated.\n *\n * `derive()` returns its argument unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `derive()` calls to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\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 derive for translation extraction.\n * @returns {T} The same content, unchanged at runtime.\n */\nexport function derive<T extends string | boolean | number | null | undefined>(\n content: T\n): T {\n return content;\n}\n"],"mappings":";;AAEA,MAAM,4BAA4B;CAChC,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,OAAO;CACd,IAAI,CAAC,KAAK;CAEV,KAAK,CAAC,OAAO,KAAK;CAClB,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,qBAAqB,CAAC,sBAAsB;CAC5C,QAAQ,CAAC,SAAS;CACnB;;;;;;;AAQD,SAAgB,+BACd,MACA,IACS;AAET,QAD4C,0BAA0B,OACpD,SAAS,GAAG,IAAI;;;;AC7BpC,SAAgB,OAAO,MAAsB;AAC3C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,MAAM,OAAO,CAAC,SAAS,SAAS;CAGrD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK;CAC5C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,WAAU,OAAO,aAAa,MAAM,GAAG;AAEzC,QAAO,KAAK,OAAO;;AAIrB,SAAgB,OAAO,QAAwB;AAC7C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,QAAQ,SAAS,CAAC,SAAS,OAAO;CAGvD,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,QAAQ,IAAI,WAA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AmB,mBAAmB,EAAE,GACrD,MACA,OAAO,MAAM,mBAAmB,EAAE;AAEpC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfT,SAAgB,WACd,UACA,SACQ;CAGR,MAAM,kBAAkB,WADE,YAAY,OAAO,YAAY,GAAG,CACR,CAAC;CAGrD,IAAI,cAAc;AAClB,KAAI,SAAS,MAEX,eAAc,IAAI,oBAAoB,IADhB,YAAY,QAAQ,MACa,CAAC;AAI1D,QAAO,IAAI,eAAe,WAAW,kBAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACfrE,SAAgB,OACd,SACG;AACH,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"derive-CM6w3hKI.cjs","names":["TYPE","TYPE"],"sources":["../src/utils/isSupportedFileFormatTransform.ts","../src/utils/base64.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"],"sourcesContent":["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 LOTTIE: ['LOTTIE'],\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","// 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 {\n parse,\n TYPE,\n type MessageFormatElement,\n type ParserOptions,\n} from '@generaltranslation/icu';\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 { TYPE, type MessageFormatElement } from '@generaltranslation/icu';\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 * Marks content as derivable by the GT compiler and CLI.\n *\n * Use `derive()` when a translation string or context needs content that is\n * computed from source code, but should still be discovered during extraction\n * instead of treated as a runtime interpolation variable. The CLI attempts to\n * resolve the derivable expression into every possible static value and\n * includes those values in the source content that gets translated.\n *\n * `derive()` returns its argument unchanged at runtime.\n *\n * Run `gt validate` after adding or changing `derive()` calls to verify that\n * each derivable expression can be resolved by the CLI before translating or\n * building.\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 derive for translation extraction.\n * @returns {T} The same content, unchanged at runtime.\n */\nexport function derive<T extends string | boolean | number | null | undefined>(\n content: T\n): T {\n return content;\n}\n"],"mappings":";;AAEA,MAAM,4BAA4B;CAChC,QAAQ,CAAC,SAAS;CAClB,MAAM,CAAC,OAAO;CACd,IAAI,CAAC,KAAK;CAEV,KAAK,CAAC,OAAO,KAAK;CAClB,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,IAAI,CAAC,KAAK;CACV,MAAM,CAAC,OAAO;CACd,KAAK,CAAC,MAAM;CACZ,qBAAqB,CAAC,sBAAsB;CAC5C,QAAQ,CAAC,SAAS;CACnB;;;;;;;AAQD,SAAgB,+BACd,MACA,IACS;AAET,QAD4C,0BAA0B,OACpD,SAAS,GAAG,IAAI;;;;AC7BpC,SAAgB,OAAO,MAAsB;AAC3C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,MAAM,OAAO,CAAC,SAAS,SAAS;CAGrD,MAAM,QAAQ,IAAI,aAAa,CAAC,OAAO,KAAK;CAC5C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,WAAU,OAAO,aAAa,MAAM,GAAG;AAEzC,QAAO,KAAK,OAAO;;AAIrB,SAAgB,OAAO,QAAwB;AAC7C,KAAI,OAAO,WAAW,YAEpB,QAAO,OAAO,KAAK,QAAQ,SAAS,CAAC,SAAS,OAAO;CAGvD,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,OAAO;AAC3C,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IACjC,OAAM,KAAK,OAAO,WAAW,EAAE;AAEjC,QAAO,IAAI,aAAa,CAAC,OAAO,MAAM;;;;;;;;;;;;;ACPxC,SAAgB,YAA4C,EAC1D,WACA,aACA,SACA,SAAS,EA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