generaltranslation 8.2.11 → 8.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{IntlCache-k2qfrDqB.cjs → IntlCache-CAW8tKhd.cjs} +12 -12
  3. package/dist/IntlCache-CAW8tKhd.cjs.map +1 -0
  4. package/dist/{IntlCache-Ccg_cQPR.mjs → IntlCache-WZk0rKvj.mjs} +12 -12
  5. package/dist/IntlCache-WZk0rKvj.mjs.map +1 -0
  6. package/dist/LocaleConfig.d.ts +59 -0
  7. package/dist/LocaleConfig.js +225 -0
  8. package/dist/backwards-compatability/dataConversion.d.ts +23 -0
  9. package/dist/backwards-compatability/dataConversion.js +207 -0
  10. package/dist/backwards-compatability/oldHashJsxChildren.d.ts +23 -0
  11. package/dist/backwards-compatability/oldHashJsxChildren.js +79 -0
  12. package/dist/backwards-compatability/oldTypes.d.ts +21 -0
  13. package/dist/backwards-compatability/oldTypes.js +1 -0
  14. package/dist/backwards-compatability/typeChecking.d.ts +21 -0
  15. package/dist/backwards-compatability/typeChecking.js +61 -0
  16. package/dist/{base64-CUcEPEC5.cjs → base64-2fu94Klt.cjs} +3 -3
  17. package/dist/base64-2fu94Klt.cjs.map +1 -0
  18. package/dist/{base64-C1sogiix.mjs → base64-DH0STixb.mjs} +3 -3
  19. package/dist/base64-DH0STixb.mjs.map +1 -0
  20. package/dist/cache/IntlCache.d.ts +26 -0
  21. package/dist/cache/IntlCache.js +84 -0
  22. package/dist/cache/types.d.ts +32 -0
  23. package/dist/cache/types.js +1 -0
  24. package/dist/{core-3SOQ5ND6.cjs → core-7RP541eY.cjs} +18 -20
  25. package/dist/core-7RP541eY.cjs.map +1 -0
  26. package/dist/{core-6rY3oy32.d.cts → core-I9pWGafA.d.mts} +8 -8
  27. package/dist/{core-BYVWty_t.d.mts → core-TLJoDpJP.d.cts} +8 -8
  28. package/dist/{core-Bx0m6GOp.mjs → core-isLphYAZ.mjs} +18 -20
  29. package/dist/core-isLphYAZ.mjs.map +1 -0
  30. package/dist/core.cjs +1 -1
  31. package/dist/core.d.cts +1 -1
  32. package/dist/core.d.mts +1 -1
  33. package/dist/core.d.ts +128 -0
  34. package/dist/core.js +137 -0
  35. package/dist/core.mjs +1 -1
  36. package/dist/derive/condenseVars.d.ts +7 -0
  37. package/dist/derive/condenseVars.js +30 -0
  38. package/dist/derive/declareVar.d.ts +26 -0
  39. package/dist/derive/declareVar.js +38 -0
  40. package/dist/derive/decodeVars.d.ts +9 -0
  41. package/dist/derive/decodeVars.js +52 -0
  42. package/dist/derive/derive.d.ts +53 -0
  43. package/dist/derive/derive.js +55 -0
  44. package/dist/derive/extractVars.d.ts +9 -0
  45. package/dist/derive/extractVars.js +34 -0
  46. package/dist/derive/index.d.ts +7 -0
  47. package/dist/derive/index.js +7 -0
  48. package/dist/derive/indexVars.d.ts +6 -0
  49. package/dist/derive/indexVars.js +52 -0
  50. package/dist/derive/utils/constants.d.ts +2 -0
  51. package/dist/derive/utils/constants.js +2 -0
  52. package/dist/derive/utils/regex.d.ts +2 -0
  53. package/dist/derive/utils/regex.js +4 -0
  54. package/dist/derive/utils/sanitizeVar.d.ts +12 -0
  55. package/dist/derive/utils/sanitizeVar.js +38 -0
  56. package/dist/derive/utils/traverseHelpers.d.ts +4 -0
  57. package/dist/derive/utils/traverseHelpers.js +22 -0
  58. package/dist/derive/utils/traverseIcu.d.ts +20 -0
  59. package/dist/derive/utils/traverseIcu.js +49 -0
  60. package/dist/derive/utils/types.d.ts +23 -0
  61. package/dist/derive/utils/types.js +1 -0
  62. package/dist/errors/ApiError.d.ts +7 -0
  63. package/dist/errors/ApiError.js +33 -0
  64. package/dist/errors/formattingErrors.d.ts +1 -0
  65. package/dist/errors/formattingErrors.js +3 -0
  66. package/dist/errors.d.ts +1 -0
  67. package/dist/errors.js +1 -0
  68. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +59 -0
  69. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.js +147 -0
  70. package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +4 -0
  71. package/dist/formatting/custom-formats/CutoffFormat/constants.js +30 -0
  72. package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +48 -0
  73. package/dist/formatting/custom-formats/CutoffFormat/types.js +2 -0
  74. package/dist/formatting/format.d.ts +1 -0
  75. package/dist/formatting/format.js +257 -0
  76. package/dist/id/hashSource.d.ts +25 -0
  77. package/dist/id/hashSource.js +98 -0
  78. package/dist/id/hashTemplate.d.ts +4 -0
  79. package/dist/id/hashTemplate.js +6 -0
  80. package/dist/id/types.d.ts +7 -0
  81. package/dist/id/types.js +1 -0
  82. package/dist/{id-COlX5v3V.cjs → id-CyiXsQrY.cjs} +9 -9
  83. package/dist/id-CyiXsQrY.cjs.map +1 -0
  84. package/dist/{id-BmOyfaug.mjs → id-DbD7K-HL.mjs} +9 -9
  85. package/dist/id-DbD7K-HL.mjs.map +1 -0
  86. package/dist/id.cjs +1 -1
  87. package/dist/id.d.cts +9 -9
  88. package/dist/id.d.mts +9 -9
  89. package/dist/id.d.ts +3 -0
  90. package/dist/id.js +3 -0
  91. package/dist/id.mjs +1 -1
  92. package/dist/index.cjs +140 -140
  93. package/dist/index.cjs.map +1 -1
  94. package/dist/index.d.cts +88 -88
  95. package/dist/index.d.mts +88 -88
  96. package/dist/index.d.ts +1019 -0
  97. package/dist/index.js +1664 -0
  98. package/dist/index.mjs +140 -140
  99. package/dist/index.mjs.map +1 -1
  100. package/dist/internal.cjs +41 -26
  101. package/dist/internal.cjs.map +1 -1
  102. package/dist/internal.d.cts +38 -23
  103. package/dist/internal.d.mts +38 -23
  104. package/dist/internal.d.ts +19 -0
  105. package/dist/internal.js +17 -0
  106. package/dist/internal.mjs +41 -26
  107. package/dist/internal.mjs.map +1 -1
  108. package/dist/locales/customLocaleMapping.d.ts +11 -0
  109. package/dist/locales/customLocaleMapping.js +23 -0
  110. package/dist/locales/determineLocale.d.ts +1 -0
  111. package/dist/locales/determineLocale.js +72 -0
  112. package/dist/locales/getLocaleDirection.d.ts +1 -0
  113. package/dist/locales/getLocaleDirection.js +89 -0
  114. package/dist/locales/getLocaleEmoji.d.ts +2 -0
  115. package/dist/locales/getLocaleEmoji.js +319 -0
  116. package/dist/locales/getLocaleName.d.ts +1 -0
  117. package/dist/locales/getLocaleName.js +45 -0
  118. package/dist/locales/getLocaleProperties.d.ts +32 -0
  119. package/dist/locales/getLocaleProperties.js +220 -0
  120. package/dist/locales/getPluralForm.d.ts +9 -0
  121. package/dist/locales/getPluralForm.js +63 -0
  122. package/dist/locales/getRegionProperties.d.ts +7 -0
  123. package/dist/locales/getRegionProperties.js +61 -0
  124. package/dist/locales/isSameDialect.d.ts +1 -0
  125. package/dist/locales/isSameDialect.js +41 -0
  126. package/dist/locales/isSameLanguage.d.ts +1 -0
  127. package/dist/locales/isSameLanguage.js +20 -0
  128. package/dist/locales/isSupersetLocale.d.ts +1 -0
  129. package/dist/locales/isSupersetLocale.js +22 -0
  130. package/dist/locales/isValidLocale.d.ts +1 -0
  131. package/dist/locales/isValidLocale.js +75 -0
  132. package/dist/locales/requiresTranslation.d.ts +1 -0
  133. package/dist/locales/requiresTranslation.js +32 -0
  134. package/dist/locales/resolveAliasLocale.d.ts +8 -0
  135. package/dist/locales/resolveAliasLocale.js +21 -0
  136. package/dist/locales/resolveCanonicalLocale.d.ts +8 -0
  137. package/dist/locales/resolveCanonicalLocale.js +13 -0
  138. package/dist/logging/errors.d.ts +10 -0
  139. package/dist/logging/errors.js +29 -0
  140. package/dist/logging/logger.d.ts +121 -0
  141. package/dist/logging/logger.js +259 -0
  142. package/dist/logging/warnings.d.ts +2 -0
  143. package/dist/logging/warnings.js +2 -0
  144. package/dist/projects/getProjectData.d.ts +1 -0
  145. package/dist/projects/getProjectData.js +87 -0
  146. package/dist/settings/plurals.d.ts +3 -0
  147. package/dist/settings/plurals.js +14 -0
  148. package/dist/settings/settings.d.ts +2 -0
  149. package/dist/settings/settings.js +2 -0
  150. package/dist/settings/settingsUrls.d.ts +3 -0
  151. package/dist/settings/settingsUrls.js +3 -0
  152. package/dist/translate/api.d.ts +1 -0
  153. package/dist/translate/api.js +1 -0
  154. package/dist/translate/awaitJobs.d.ts +19 -0
  155. package/dist/translate/awaitJobs.js +112 -0
  156. package/dist/translate/checkJobStatus.d.ts +8 -0
  157. package/dist/translate/checkJobStatus.js +55 -0
  158. package/dist/translate/createBranch.d.ts +10 -0
  159. package/dist/translate/createBranch.js +53 -0
  160. package/dist/translate/createTag.d.ts +19 -0
  161. package/dist/translate/createTag.js +67 -0
  162. package/dist/translate/downloadFileBatch.d.ts +1 -0
  163. package/dist/translate/downloadFileBatch.js +77 -0
  164. package/dist/translate/enqueueFiles.d.ts +8 -0
  165. package/dist/translate/enqueueFiles.js +96 -0
  166. package/dist/translate/getOrphanedFiles.d.ts +8 -0
  167. package/dist/translate/getOrphanedFiles.js +97 -0
  168. package/dist/translate/processFileMoves.d.ts +25 -0
  169. package/dist/translate/processFileMoves.js +90 -0
  170. package/dist/translate/publishFiles.d.ts +17 -0
  171. package/dist/translate/publishFiles.js +56 -0
  172. package/dist/translate/queryBranchData.d.ts +3 -0
  173. package/dist/translate/queryBranchData.js +53 -0
  174. package/dist/translate/queryFileData.d.ts +42 -0
  175. package/dist/translate/queryFileData.js +71 -0
  176. package/dist/translate/querySourceFile.d.ts +1 -0
  177. package/dist/translate/querySourceFile.js +67 -0
  178. package/dist/translate/setupProject.d.ts +11 -0
  179. package/dist/translate/setupProject.js +63 -0
  180. package/dist/translate/submitUserEditDiffs.d.ts +12 -0
  181. package/dist/translate/submitUserEditDiffs.js +68 -0
  182. package/dist/translate/translateMany.d.ts +1 -0
  183. package/dist/translate/translateMany.js +103 -0
  184. package/dist/translate/uploadSourceFiles.d.ts +1 -0
  185. package/dist/translate/uploadSourceFiles.js +87 -0
  186. package/dist/translate/uploadTranslations.d.ts +1 -0
  187. package/dist/translate/uploadTranslations.js +101 -0
  188. package/dist/translate/utils/apiRequest.d.ts +1 -0
  189. package/dist/translate/utils/apiRequest.js +130 -0
  190. package/dist/translate/utils/batch.d.ts +52 -0
  191. package/dist/translate/utils/batch.js +126 -0
  192. package/dist/translate/utils/fetchWithTimeout.d.ts +1 -0
  193. package/dist/translate/utils/fetchWithTimeout.js +93 -0
  194. package/dist/translate/utils/generateRequestHeaders.d.ts +2 -0
  195. package/dist/translate/utils/generateRequestHeaders.js +26 -0
  196. package/dist/translate/utils/handleFetchError.d.ts +1 -0
  197. package/dist/translate/utils/handleFetchError.js +12 -0
  198. package/dist/translate/utils/validateFileFormatTransform.d.ts +16 -0
  199. package/dist/translate/utils/validateFileFormatTransform.js +29 -0
  200. package/dist/translate/utils/validateResponse.d.ts +1 -0
  201. package/dist/translate/utils/validateResponse.js +72 -0
  202. package/dist/{types-Cy8q2XZX.d.mts → types-AHtYZIP-.d.mts} +63 -40
  203. package/dist/{types-NKhpChvT.d.cts → types-Bf8_Apq_.d.cts} +63 -40
  204. package/dist/types-dir/api/branch.d.ts +10 -0
  205. package/dist/types-dir/api/branch.js +1 -0
  206. package/dist/types-dir/api/checkFileTranslations.d.ts +37 -0
  207. package/dist/types-dir/api/checkFileTranslations.js +1 -0
  208. package/dist/types-dir/api/downloadFile.d.ts +3 -0
  209. package/dist/types-dir/api/downloadFile.js +1 -0
  210. package/dist/types-dir/api/downloadFileBatch.d.ts +35 -0
  211. package/dist/types-dir/api/downloadFileBatch.js +1 -0
  212. package/dist/types-dir/api/enqueueEntries.d.ts +21 -0
  213. package/dist/types-dir/api/enqueueEntries.js +1 -0
  214. package/dist/types-dir/api/enqueueFiles.d.ts +70 -0
  215. package/dist/types-dir/api/enqueueFiles.js +1 -0
  216. package/dist/types-dir/api/entry.d.ts +39 -0
  217. package/dist/types-dir/api/entry.js +1 -0
  218. package/dist/types-dir/api/fetchTranslations.d.ts +12 -0
  219. package/dist/types-dir/api/fetchTranslations.js +1 -0
  220. package/dist/types-dir/api/file.d.ts +57 -0
  221. package/dist/types-dir/api/file.js +1 -0
  222. package/dist/types-dir/api/json.d.ts +5 -0
  223. package/dist/types-dir/api/json.js +1 -0
  224. package/dist/types-dir/api/project.d.ts +7 -0
  225. package/dist/types-dir/api/project.js +1 -0
  226. package/dist/types-dir/api/translate.d.ts +34 -0
  227. package/dist/types-dir/api/translate.js +1 -0
  228. package/dist/types-dir/api/translateMany.d.ts +5 -0
  229. package/dist/types-dir/api/translateMany.js +1 -0
  230. package/dist/types-dir/api/translationStatus.d.ts +9 -0
  231. package/dist/types-dir/api/translationStatus.js +1 -0
  232. package/dist/types-dir/api/uploadFiles.d.ts +44 -0
  233. package/dist/types-dir/api/uploadFiles.js +1 -0
  234. package/dist/types-dir/jsx/content.d.ts +61 -0
  235. package/dist/types-dir/jsx/content.js +11 -0
  236. package/dist/types-dir/jsx/variables.d.ts +9 -0
  237. package/dist/types-dir/jsx/variables.js +1 -0
  238. package/dist/types-dir/transformations.d.ts +8 -0
  239. package/dist/types-dir/transformations.js +1 -0
  240. package/dist/types.cjs.map +1 -1
  241. package/dist/types.d.cts +2 -2
  242. package/dist/types.d.mts +2 -2
  243. package/dist/types.d.ts +129 -0
  244. package/dist/types.js +2 -0
  245. package/dist/types.mjs.map +1 -1
  246. package/dist/utils/base64.d.ts +2 -0
  247. package/dist/utils/base64.js +28 -0
  248. package/dist/utils/isSupportedFileFormatTransform.d.ts +8 -0
  249. package/dist/utils/isSupportedFileFormatTransform.js +26 -0
  250. package/dist/utils/isVariable.d.ts +2 -0
  251. package/dist/utils/isVariable.js +22 -0
  252. package/dist/utils/minify.d.ts +2 -0
  253. package/dist/utils/minify.js +10 -0
  254. package/dist/utils/stableStringify.d.ts +1 -0
  255. package/dist/utils/stableStringify.js +40 -0
  256. package/package.json +5 -6
  257. package/dist/IntlCache-Ccg_cQPR.mjs.map +0 -1
  258. package/dist/IntlCache-k2qfrDqB.cjs.map +0 -1
  259. package/dist/base64-C1sogiix.mjs.map +0 -1
  260. package/dist/base64-CUcEPEC5.cjs.map +0 -1
  261. package/dist/core-3SOQ5ND6.cjs.map +0 -1
  262. package/dist/core-Bx0m6GOp.mjs.map +0 -1
  263. package/dist/id-BmOyfaug.mjs.map +0 -1
  264. package/dist/id-COlX5v3V.cjs.map +0 -1
@@ -0,0 +1,44 @@
1
+ import { DataFormat } from '../jsx/content';
2
+ import { FileFormat, FileReference, type FormatMetadata } from './file';
3
+ /**
4
+ * Metadata stored alongside GTJSON file entries.
5
+ * Keys correspond to the entry id/hash in the GTJSON body.
6
+ */
7
+ export type GTJsonFormatMetadata = Record<string, {
8
+ context?: string;
9
+ id?: string;
10
+ domain?: string;
11
+ maxChars?: number;
12
+ dataFormat?: 'JSX' | 'ICU' | 'I18NEXT';
13
+ requestVersion?: number;
14
+ approved_at?: string | null;
15
+ approved_by?: string | null;
16
+ hash?: string;
17
+ staticId?: string;
18
+ filePaths?: string[];
19
+ }>;
20
+ export type FileUpload = {
21
+ branchId?: string;
22
+ incomingBranchId?: string;
23
+ checkedOutBranchId?: string;
24
+ content: string;
25
+ fileName: string;
26
+ fileFormat: FileFormat;
27
+ transformFormat?: FileFormat;
28
+ dataFormat?: DataFormat;
29
+ locale: string;
30
+ formatMetadata?: GTJsonFormatMetadata | FormatMetadata;
31
+ versionId?: string;
32
+ fileId?: string;
33
+ };
34
+ export type UploadFilesOptions = {
35
+ sourceLocale: string;
36
+ modelProvider?: string;
37
+ timeout?: number;
38
+ };
39
+ export type UploadFilesResponse = {
40
+ uploadedFiles: FileReference[];
41
+ count: number;
42
+ message: string;
43
+ };
44
+ export type RequiredUploadFilesOptions = UploadFilesOptions & Required<Pick<UploadFilesOptions, 'sourceLocale'>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ import { Variable } from './variables';
2
+ /**
3
+ * Map of data-_gt properties to their corresponding React props
4
+ */
5
+ export declare const HTML_CONTENT_PROPS: {
6
+ readonly pl: "placeholder";
7
+ readonly ti: "title";
8
+ readonly alt: "alt";
9
+ readonly arl: "aria-label";
10
+ readonly arb: "aria-labelledby";
11
+ readonly ard: "aria-describedby";
12
+ };
13
+ export type HtmlContentPropKeysRecord = Partial<Record<keyof typeof HTML_CONTENT_PROPS, string>>;
14
+ export type HtmlContentPropValuesRecord = Partial<Record<(typeof HTML_CONTENT_PROPS)[keyof typeof HTML_CONTENT_PROPS], string>>;
15
+ /**
16
+ * GTProp is an internal property used to contain data for translating and rendering elements.
17
+ * note, transformations are only read on the server side if they are 'plural' or 'branch'
18
+ */
19
+ export type GTProp = {
20
+ b?: Record<string, JsxChildren>;
21
+ t?: 'p' | 'b';
22
+ } & HtmlContentPropKeysRecord;
23
+ export type JsxElement = {
24
+ t?: string;
25
+ i?: number;
26
+ d?: GTProp;
27
+ c?: JsxChildren;
28
+ };
29
+ export type JsxChild = string | JsxElement | Variable;
30
+ /**
31
+ * The format of the string content
32
+ */
33
+ export type StringFormat = 'ICU' | 'I18NEXT' | 'STRING';
34
+ /**
35
+ * The format of the content.
36
+ */
37
+ export type DataFormat = 'JSX' | StringFormat;
38
+ /**
39
+ * String format content.
40
+ */
41
+ export type StringContent = IcuMessage | StringMessage | I18nextMessage;
42
+ /**
43
+ * A content type representing JSX, ICU, and I18next messages.
44
+ */
45
+ export type Content = JsxChildren | StringContent;
46
+ /**
47
+ * A content type representing JSX elements.
48
+ */
49
+ export type JsxChildren = JsxChild | JsxChild[];
50
+ /**
51
+ * A content type representing ICU messages.
52
+ */
53
+ export type IcuMessage = string;
54
+ /**
55
+ * A content type representing I18next messages.
56
+ */
57
+ export type I18nextMessage = string;
58
+ /**
59
+ * A content type representing plain strings.
60
+ */
61
+ export type StringMessage = string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Map of data-_gt properties to their corresponding React props
3
+ */
4
+ export var HTML_CONTENT_PROPS = {
5
+ pl: 'placeholder',
6
+ ti: 'title',
7
+ alt: 'alt',
8
+ arl: 'aria-label',
9
+ arb: 'aria-labelledby',
10
+ ard: 'aria-describedby',
11
+ };
@@ -0,0 +1,9 @@
1
+ export type VariableType = 'v' | 'n' | 'd' | 'c' | 'rt';
2
+ /**
3
+ * Variables are used to store the variable name and type.
4
+ */
5
+ export type Variable = {
6
+ k: string;
7
+ i?: number;
8
+ v?: VariableType;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Transformations are made from a prefix and a suffix.
3
+ */
4
+ export type Transformation = BaseTransformation | `${BaseTransformation}-${InjectionType}`;
5
+ export type BaseTransformation = 'translate-client' | 'translate-server' | 'translate-runtime' | 'variable-variable' | 'variable-currency' | 'variable-datetime' | 'variable-number' | 'variable-relative-time' | 'plural' | 'branch' | 'derive';
6
+ export type TransformationPrefix = 'translate' | 'variable' | 'plural' | 'branch' | 'fragment' | 'derive';
7
+ export type VariableTransformationSuffix = 'variable' | 'number' | 'datetime' | 'currency' | 'relative-time';
8
+ export type InjectionType = 'automatic' | 'manual';
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../src/types-dir/jsx/content.ts"],"sourcesContent":["import { Variable } from './variables';\n\n/**\n * Map of data-_gt properties to their corresponding React props\n */\nexport const HTML_CONTENT_PROPS = {\n pl: 'placeholder',\n ti: 'title',\n alt: 'alt',\n arl: 'aria-label',\n arb: 'aria-labelledby',\n ard: 'aria-describedby',\n} as const;\n\nexport type HtmlContentPropKeysRecord = Partial<\n Record<keyof typeof HTML_CONTENT_PROPS, string>\n>;\nexport type HtmlContentPropValuesRecord = Partial<\n Record<(typeof HTML_CONTENT_PROPS)[keyof typeof HTML_CONTENT_PROPS], string>\n>;\n\n/**\n * GTProp is an internal property used to contain data for translating and rendering elements.\n * note, transformations are only read on the server side if they are 'plural' or 'branch'\n */\nexport type GTProp = {\n b?: Record<string, JsxChildren>; // Branches\n t?: 'p' | 'b'; // Branch Transformation\n} & HtmlContentPropKeysRecord;\n\nexport type JsxElement = {\n t?: string; // tag name\n i?: number; // id\n d?: GTProp; // GT data\n c?: JsxChildren; // children\n};\n\nexport type JsxChild = string | JsxElement | Variable;\n\n/**\n * The format of the string content\n */\nexport type StringFormat = 'ICU' | 'I18NEXT' | 'STRING';\n\n/**\n * The format of the content\n */\nexport type DataFormat = 'JSX' | StringFormat;\n\n/**\n * String format content\n */\nexport type StringContent = IcuMessage | StringMessage | I18nextMessage;\n\n/**\n * A content type representing JSX, ICU, and I18next messages\n */\nexport type Content = JsxChildren | StringContent;\n\n/**\n * A content type representing JSX elements\n */\nexport type JsxChildren = JsxChild | JsxChild[];\n\n/**\n * A content type representing ICU messages\n */\nexport type IcuMessage = string;\n\n/**\n * A content type representing I18next messages\n */\nexport type I18nextMessage = string;\n\n/**\n * A content type representing plain strings\n */\nexport type StringMessage = string;\n"],"mappings":";;;;;AAKA,MAAa,qBAAqB;CAChC,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN"}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../src/types-dir/jsx/content.ts"],"sourcesContent":["import { Variable } from './variables';\n\n/**\n * Map of data-_gt properties to their corresponding React props\n */\nexport const HTML_CONTENT_PROPS = {\n pl: 'placeholder',\n ti: 'title',\n alt: 'alt',\n arl: 'aria-label',\n arb: 'aria-labelledby',\n ard: 'aria-describedby',\n} as const;\n\nexport type HtmlContentPropKeysRecord = Partial<\n Record<keyof typeof HTML_CONTENT_PROPS, string>\n>;\nexport type HtmlContentPropValuesRecord = Partial<\n Record<(typeof HTML_CONTENT_PROPS)[keyof typeof HTML_CONTENT_PROPS], string>\n>;\n\n/**\n * GTProp is an internal property used to contain data for translating and rendering elements.\n * note, transformations are only read on the server side if they are 'plural' or 'branch'\n */\nexport type GTProp = {\n b?: Record<string, JsxChildren>; // Branches\n t?: 'p' | 'b'; // Branch Transformation\n} & HtmlContentPropKeysRecord;\n\nexport type JsxElement = {\n t?: string; // tag name\n i?: number; // id\n d?: GTProp; // GT data\n c?: JsxChildren; // children\n};\n\nexport type JsxChild = string | JsxElement | Variable;\n\n/**\n * The format of the string content\n */\nexport type StringFormat = 'ICU' | 'I18NEXT' | 'STRING';\n\n/**\n * The format of the content.\n */\nexport type DataFormat = 'JSX' | StringFormat;\n\n/**\n * String format content.\n */\nexport type StringContent = IcuMessage | StringMessage | I18nextMessage;\n\n/**\n * A content type representing JSX, ICU, and I18next messages.\n */\nexport type Content = JsxChildren | StringContent;\n\n/**\n * A content type representing JSX elements.\n */\nexport type JsxChildren = JsxChild | JsxChild[];\n\n/**\n * A content type representing ICU messages.\n */\nexport type IcuMessage = string;\n\n/**\n * A content type representing I18next messages.\n */\nexport type I18nextMessage = string;\n\n/**\n * A content type representing plain strings.\n */\nexport type StringMessage = string;\n"],"mappings":";;;;;AAKA,MAAa,qBAAqB;CAChC,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN"}
package/dist/types.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as FileReference, A as BranchDataResult, At as Variable, B as FileUpload, C as ProcessMovesOptions, Ct as IcuMessage, D as FileDataQuery, Dt as StringContent, E as OrphanedFile, Et as JsxElement, F as DownloadFileOptions, G as FetchTranslationsOptions, I as PublishFileEntry, J as DownloadFileBatchOptions, K as FetchTranslationsResult, L as PublishFilesResult, M as TranslationError, Mt as LocaleProperties, N as TranslationResult, Nt as CustomMapping, O as FileDataResult, Ot as StringFormat, P as TranslationResultReference, Q as FileFormat, R as EnqueueEntriesOptions, S as MoveResult, St as I18nextMessage, T as GetOrphanedFilesResult, Tt as JsxChildren, U as CreateTagOptions, W as CreateTagResult, X as DownloadFileBatchResult, Z as DownloadedFile, _ as AwaitJobsResult, _t as DataFormat, a as Metadata, at as CheckFileTranslationsOptions, b as JobStatus, bt as HtmlContentPropKeysRecord, c as Update, ct as FileTranslationQuery, d as Transformation, dt as ActionType, f as TransformationPrefix, ft as EntryMetadata, g as AwaitJobsOptions, gt as Content, h as SubmitUserEditDiffsPayload, i as JsxTranslationResult, it as Updates, j as TranslateManyResult, jt as VariableType, k as BranchQuery, kt as StringMessage, l as _Content, lt as TranslationStatusResult, m as SubmitUserEditDiff, mt as TranslateManyEntry, n as FormatVariables, nt as EnqueueFilesOptions, o as Request, p as VariableTransformationSuffix, q as RetrievedTranslations, r as IcuTranslationResult, rt as EnqueueFilesResult, s as TranslationRequestConfig, t as ContentTranslationResult, tt as FileToUpload, u as InjectionType, ut as HashMetadata, v as JobResult, vt as GTProp, w as ProcessMovesResponse, wt as JsxChild, x as MoveMapping, xt as HtmlContentPropValuesRecord, y as CheckJobStatusResult, yt as HTML_CONTENT_PROPS, z as EnqueueEntriesResult } from "./types-NKhpChvT.cjs";
2
- export { AwaitJobsOptions, AwaitJobsResult, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, ContentTranslationResult, CreateTagOptions, CreateTagResult, CustomMapping, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FetchTranslationsOptions, FetchTranslationsResult, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileTranslationQuery, FileUpload, FormatVariables, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, IcuTranslationResult, InjectionType, JobResult, JobStatus, JsxChild, JsxChildren, JsxElement, JsxTranslationResult, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, Request, RetrievedTranslations, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, TranslationStatusResult, Update, Updates, Variable, VariableTransformationSuffix, VariableType, _Content };
1
+ import { $ as FileReference, A as BranchDataResult, At as StringContent, B as FileUpload, C as ProcessMovesOptions, Ct as HtmlContentPropKeysRecord, D as FileDataQuery, Dt as JsxChild, E as OrphanedFile, Et as IcuMessage, F as DownloadFileOptions, Ft as LocaleProperties, G as FetchTranslationsOptions, I as PublishFileEntry, It as CustomMapping, J as DownloadFileBatchOptions, K as FetchTranslationsResult, L as PublishFilesResult, M as TranslationError, Mt as StringMessage, N as TranslationResult, Nt as Variable, O as FileDataResult, Ot as JsxChildren, P as TranslationResultReference, Pt as VariableType, Q as FileFormat, R as EnqueueEntriesOptions, S as MoveResult, St as HTML_CONTENT_PROPS, T as GetOrphanedFilesResult, Tt as I18nextMessage, U as CreateTagOptions, W as CreateTagResult, X as DownloadFileBatchResult, Z as DownloadedFile, _ as AwaitJobsResult, _t as TranslateManyEntry, a as Metadata, at as CheckFileTranslationsOptions, b as JobStatus, bt as DataFormat, c as Update, ct as FileTranslationQuery, d as Transformation, dt as JsonValue, f as TransformationPrefix, ft as TranslationStatusResult, g as AwaitJobsOptions, h as SubmitUserEditDiffsPayload, ht as EntryMetadata, i as JsxTranslationResult, it as Updates, j as TranslateManyResult, jt as StringFormat, k as BranchQuery, kt as JsxElement, l as _Content, lt as JsonObject, m as SubmitUserEditDiff, mt as ActionType, n as FormatVariables, nt as EnqueueFilesOptions, o as Request, p as VariableTransformationSuffix, pt as HashMetadata, q as RetrievedTranslations, r as IcuTranslationResult, rt as EnqueueFilesResult, s as TranslationRequestConfig, t as ContentTranslationResult, tt as FileToUpload, u as InjectionType, ut as JsonPrimitive, v as JobResult, w as ProcessMovesResponse, wt as HtmlContentPropValuesRecord, x as MoveMapping, xt as GTProp, y as CheckJobStatusResult, yt as Content, z as EnqueueEntriesResult } from "./types-Bf8_Apq_.cjs";
2
+ export { AwaitJobsOptions, AwaitJobsResult, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, ContentTranslationResult, CreateTagOptions, CreateTagResult, CustomMapping, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FetchTranslationsOptions, FetchTranslationsResult, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileTranslationQuery, FileUpload, FormatVariables, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, IcuTranslationResult, InjectionType, JobResult, JobStatus, JsonObject, JsonPrimitive, JsonValue, JsxChild, JsxChildren, JsxElement, JsxTranslationResult, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, Request, RetrievedTranslations, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, TranslationStatusResult, Update, Updates, Variable, VariableTransformationSuffix, VariableType, _Content };
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as FileReference, A as BranchDataResult, At as Variable, B as FileUpload, C as ProcessMovesOptions, Ct as IcuMessage, D as FileDataQuery, Dt as StringContent, E as OrphanedFile, Et as JsxElement, F as DownloadFileOptions, G as FetchTranslationsOptions, I as PublishFileEntry, J as DownloadFileBatchOptions, K as FetchTranslationsResult, L as PublishFilesResult, M as TranslationError, Mt as LocaleProperties, N as TranslationResult, Nt as CustomMapping, O as FileDataResult, Ot as StringFormat, P as TranslationResultReference, Q as FileFormat, R as EnqueueEntriesOptions, S as MoveResult, St as I18nextMessage, T as GetOrphanedFilesResult, Tt as JsxChildren, U as CreateTagOptions, W as CreateTagResult, X as DownloadFileBatchResult, Z as DownloadedFile, _ as AwaitJobsResult, _t as DataFormat, a as Metadata, at as CheckFileTranslationsOptions, b as JobStatus, bt as HtmlContentPropKeysRecord, c as Update, ct as FileTranslationQuery, d as Transformation, dt as ActionType, f as TransformationPrefix, ft as EntryMetadata, g as AwaitJobsOptions, gt as Content, h as SubmitUserEditDiffsPayload, i as JsxTranslationResult, it as Updates, j as TranslateManyResult, jt as VariableType, k as BranchQuery, kt as StringMessage, l as _Content, lt as TranslationStatusResult, m as SubmitUserEditDiff, mt as TranslateManyEntry, n as FormatVariables, nt as EnqueueFilesOptions, o as Request, p as VariableTransformationSuffix, q as RetrievedTranslations, r as IcuTranslationResult, rt as EnqueueFilesResult, s as TranslationRequestConfig, t as ContentTranslationResult, tt as FileToUpload, u as InjectionType, ut as HashMetadata, v as JobResult, vt as GTProp, w as ProcessMovesResponse, wt as JsxChild, x as MoveMapping, xt as HtmlContentPropValuesRecord, y as CheckJobStatusResult, yt as HTML_CONTENT_PROPS, z as EnqueueEntriesResult } from "./types-Cy8q2XZX.mjs";
2
- export { AwaitJobsOptions, AwaitJobsResult, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, ContentTranslationResult, CreateTagOptions, CreateTagResult, CustomMapping, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FetchTranslationsOptions, FetchTranslationsResult, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileTranslationQuery, FileUpload, FormatVariables, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, IcuTranslationResult, InjectionType, JobResult, JobStatus, JsxChild, JsxChildren, JsxElement, JsxTranslationResult, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, Request, RetrievedTranslations, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, TranslationStatusResult, Update, Updates, Variable, VariableTransformationSuffix, VariableType, _Content };
1
+ import { $ as FileReference, A as BranchDataResult, At as StringContent, B as FileUpload, C as ProcessMovesOptions, Ct as HtmlContentPropKeysRecord, D as FileDataQuery, Dt as JsxChild, E as OrphanedFile, Et as IcuMessage, F as DownloadFileOptions, Ft as LocaleProperties, G as FetchTranslationsOptions, I as PublishFileEntry, It as CustomMapping, J as DownloadFileBatchOptions, K as FetchTranslationsResult, L as PublishFilesResult, M as TranslationError, Mt as StringMessage, N as TranslationResult, Nt as Variable, O as FileDataResult, Ot as JsxChildren, P as TranslationResultReference, Pt as VariableType, Q as FileFormat, R as EnqueueEntriesOptions, S as MoveResult, St as HTML_CONTENT_PROPS, T as GetOrphanedFilesResult, Tt as I18nextMessage, U as CreateTagOptions, W as CreateTagResult, X as DownloadFileBatchResult, Z as DownloadedFile, _ as AwaitJobsResult, _t as TranslateManyEntry, a as Metadata, at as CheckFileTranslationsOptions, b as JobStatus, bt as DataFormat, c as Update, ct as FileTranslationQuery, d as Transformation, dt as JsonValue, f as TransformationPrefix, ft as TranslationStatusResult, g as AwaitJobsOptions, h as SubmitUserEditDiffsPayload, ht as EntryMetadata, i as JsxTranslationResult, it as Updates, j as TranslateManyResult, jt as StringFormat, k as BranchQuery, kt as JsxElement, l as _Content, lt as JsonObject, m as SubmitUserEditDiff, mt as ActionType, n as FormatVariables, nt as EnqueueFilesOptions, o as Request, p as VariableTransformationSuffix, pt as HashMetadata, q as RetrievedTranslations, r as IcuTranslationResult, rt as EnqueueFilesResult, s as TranslationRequestConfig, t as ContentTranslationResult, tt as FileToUpload, u as InjectionType, ut as JsonPrimitive, v as JobResult, w as ProcessMovesResponse, wt as HtmlContentPropValuesRecord, x as MoveMapping, xt as GTProp, y as CheckJobStatusResult, yt as Content, z as EnqueueEntriesResult } from "./types-AHtYZIP-.mjs";
2
+ export { AwaitJobsOptions, AwaitJobsResult, BranchDataResult, BranchQuery, CheckFileTranslationsOptions, CheckJobStatusResult, Content, ContentTranslationResult, CreateTagOptions, CreateTagResult, CustomMapping, DataFormat, DownloadFileBatchOptions, DownloadFileBatchResult, DownloadFileOptions, DownloadedFile, EnqueueEntriesOptions, EnqueueEntriesResult, EnqueueFilesOptions, EnqueueFilesResult, ActionType as EntryActionType, EntryMetadata, FetchTranslationsOptions, FetchTranslationsResult, FileDataQuery, FileDataResult, FileFormat, FileReference, FileToUpload, FileTranslationQuery, FileUpload, FormatVariables, GTProp, GetOrphanedFilesResult, HTML_CONTENT_PROPS, HashMetadata, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, I18nextMessage, IcuMessage, IcuTranslationResult, InjectionType, JobResult, JobStatus, JsonObject, JsonPrimitive, JsonValue, JsxChild, JsxChildren, JsxElement, JsxTranslationResult, LocaleProperties, Metadata, MoveMapping, MoveResult, OrphanedFile, ProcessMovesOptions, ProcessMovesResponse, PublishFileEntry, PublishFilesResult, Request, RetrievedTranslations, StringContent, StringFormat, StringMessage, SubmitUserEditDiff, SubmitUserEditDiffsPayload, Transformation, TransformationPrefix, TranslateManyEntry, TranslateManyResult, TranslationError, TranslationRequestConfig, TranslationResult, TranslationResultReference, TranslationStatusResult, Update, Updates, Variable, VariableTransformationSuffix, VariableType, _Content };
@@ -0,0 +1,129 @@
1
+ import type { LocaleProperties } from './locales/getLocaleProperties';
2
+ import type { Variable, VariableType } from './types-dir/jsx/variables';
3
+ import { type IcuMessage, type I18nextMessage, type StringMessage, type StringContent, type JsxChildren, type JsxChild, type JsxElement, type GTProp, type HtmlContentPropKeysRecord, type HtmlContentPropValuesRecord, HTML_CONTENT_PROPS, type DataFormat, type Content, type StringFormat } from './types-dir/jsx/content';
4
+ import type { ActionType, EntryMetadata, TranslateManyEntry } from './types-dir/api/entry';
5
+ import type { HashMetadata } from './id/types';
6
+ export type { TranslationStatusResult } from './types-dir/api/translationStatus';
7
+ export type { JsonObject, JsonPrimitive, JsonValue, } from './types-dir/api/json';
8
+ export { IcuMessage, StringMessage, I18nextMessage, StringContent, JsxChildren, JsxChild, JsxElement, GTProp, HtmlContentPropKeysRecord, HtmlContentPropValuesRecord, HTML_CONTENT_PROPS, Variable, VariableType, LocaleProperties, DataFormat, ActionType as EntryActionType, EntryMetadata, TranslateManyEntry, Content, StringFormat, HashMetadata, };
9
+ export type { FileTranslationQuery, CheckFileTranslationsOptions, } from './types-dir/api/checkFileTranslations';
10
+ export type { DownloadFileBatchOptions, DownloadFileBatchResult, } from './types-dir/api/downloadFileBatch';
11
+ export type { FetchTranslationsOptions, FetchTranslationsResult, RetrievedTranslations, } from './types-dir/api/fetchTranslations';
12
+ export type { EnqueueFilesOptions, EnqueueFilesResult, Updates, } from './types-dir/api/enqueueFiles';
13
+ export type { CreateTagOptions, CreateTagResult } from './translate/createTag';
14
+ export type { FileToUpload } from './types-dir/api/file';
15
+ export type { FileUpload } from './types-dir/api/uploadFiles';
16
+ export type { EnqueueEntriesOptions, EnqueueEntriesResult, } from './types-dir/api/enqueueEntries';
17
+ export type { FileReference } from './types-dir/api/file';
18
+ export type { PublishFileEntry, PublishFilesResult, } from './translate/publishFiles';
19
+ export type { DownloadedFile } from './types-dir/api/downloadFileBatch';
20
+ export type { DownloadFileOptions } from './types-dir/api/downloadFile';
21
+ export type { FileFormat } from './types-dir/api/file';
22
+ export type { TranslateManyResult } from './types-dir/api/translateMany';
23
+ export type { TranslationResult, TranslationError, TranslationResultReference, } from './types-dir/api/translate';
24
+ export type { BranchDataResult } from './types-dir/api/branch';
25
+ export type { BranchQuery } from './translate/queryBranchData';
26
+ export type { FileDataQuery, FileDataResult } from './translate/queryFileData';
27
+ export type { OrphanedFile, GetOrphanedFilesResult, } from './translate/getOrphanedFiles';
28
+ export type { MoveMapping, MoveResult, ProcessMovesResponse, ProcessMovesOptions, } from './translate/processFileMoves';
29
+ export type { JobStatus, CheckJobStatusResult, } from './translate/checkJobStatus';
30
+ export type { AwaitJobsOptions, AwaitJobsResult, JobResult, } from './translate/awaitJobs';
31
+ export type { SubmitUserEditDiff, SubmitUserEditDiffsPayload, } from './translate/submitUserEditDiffs';
32
+ /**
33
+ * @deprecated Use {@link Content} instead.
34
+ */
35
+ export type _Content = string | Array<string | Variable>;
36
+ export type { Transformation, TransformationPrefix, VariableTransformationSuffix, InjectionType, } from './types-dir/transformations';
37
+ export type Metadata = {
38
+ maxChars?: number;
39
+ context?: string;
40
+ id?: string;
41
+ hash?: string;
42
+ format?: string;
43
+ dataFormat?: DataFormat;
44
+ sourceLocale?: string;
45
+ actionType?: 'standard' | 'fast' | string;
46
+ filePaths?: string[];
47
+ [key: string]: unknown;
48
+ };
49
+ export type FormatVariables = Record<string, string | number | boolean | null | undefined | Date>;
50
+ /**
51
+ * @deprecated This type is deprecated and will be removed in a future version.
52
+ */
53
+ export type Update = {
54
+ type: 'content';
55
+ data: {
56
+ source: _Content;
57
+ metadata: Metadata;
58
+ };
59
+ } | {
60
+ type: 'jsx';
61
+ data: {
62
+ source: JsxChildren;
63
+ metadata: Metadata;
64
+ };
65
+ };
66
+ /**
67
+ * @deprecated This type is deprecated and will be removed in a future version.
68
+ */
69
+ export type Request = {
70
+ type: 'content';
71
+ data: {
72
+ source: _Content;
73
+ targetLocale: string;
74
+ metadata: Metadata;
75
+ };
76
+ } | {
77
+ type: 'jsx';
78
+ data: {
79
+ source: JsxChildren;
80
+ targetLocale: string;
81
+ metadata: Metadata;
82
+ };
83
+ };
84
+ /**
85
+ * @deprecated Use {@link TranslationResult} instead.
86
+ */
87
+ export type ContentTranslationResult = {
88
+ translation: _Content;
89
+ locale: string;
90
+ reference?: {
91
+ id: string;
92
+ key: string;
93
+ };
94
+ };
95
+ /**
96
+ * @deprecated Use {@link TranslationResult} instead.
97
+ */
98
+ export type IcuTranslationResult = {
99
+ translation: string;
100
+ locale: string;
101
+ reference?: {
102
+ id: string;
103
+ key: string;
104
+ };
105
+ };
106
+ /**
107
+ * @deprecated Use {@link TranslationResult} instead.
108
+ */
109
+ export type JsxTranslationResult = {
110
+ translation: JsxChildren;
111
+ locale: string;
112
+ reference?: {
113
+ id: string;
114
+ key: string;
115
+ };
116
+ };
117
+ export type { CustomMapping } from './locales/customLocaleMapping';
118
+ /**
119
+ * TranslationRequestConfig is used to configure the translation request.
120
+ *
121
+ * @param projectId - The project ID of the translation request.
122
+ * @param baseUrl - The base URL of the translation request.
123
+ * @param apiKey - The API key of the translation request.
124
+ */
125
+ export type TranslationRequestConfig = {
126
+ projectId: string;
127
+ baseUrl?: string;
128
+ apiKey?: string;
129
+ };
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ import { HTML_CONTENT_PROPS, } from './types-dir/jsx/content';
2
+ export { HTML_CONTENT_PROPS, };
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","names":[],"sources":["../src/types-dir/jsx/content.ts"],"sourcesContent":["import { Variable } from './variables';\n\n/**\n * Map of data-_gt properties to their corresponding React props\n */\nexport const HTML_CONTENT_PROPS = {\n pl: 'placeholder',\n ti: 'title',\n alt: 'alt',\n arl: 'aria-label',\n arb: 'aria-labelledby',\n ard: 'aria-describedby',\n} as const;\n\nexport type HtmlContentPropKeysRecord = Partial<\n Record<keyof typeof HTML_CONTENT_PROPS, string>\n>;\nexport type HtmlContentPropValuesRecord = Partial<\n Record<(typeof HTML_CONTENT_PROPS)[keyof typeof HTML_CONTENT_PROPS], string>\n>;\n\n/**\n * GTProp is an internal property used to contain data for translating and rendering elements.\n * note, transformations are only read on the server side if they are 'plural' or 'branch'\n */\nexport type GTProp = {\n b?: Record<string, JsxChildren>; // Branches\n t?: 'p' | 'b'; // Branch Transformation\n} & HtmlContentPropKeysRecord;\n\nexport type JsxElement = {\n t?: string; // tag name\n i?: number; // id\n d?: GTProp; // GT data\n c?: JsxChildren; // children\n};\n\nexport type JsxChild = string | JsxElement | Variable;\n\n/**\n * The format of the string content\n */\nexport type StringFormat = 'ICU' | 'I18NEXT' | 'STRING';\n\n/**\n * The format of the content\n */\nexport type DataFormat = 'JSX' | StringFormat;\n\n/**\n * String format content\n */\nexport type StringContent = IcuMessage | StringMessage | I18nextMessage;\n\n/**\n * A content type representing JSX, ICU, and I18next messages\n */\nexport type Content = JsxChildren | StringContent;\n\n/**\n * A content type representing JSX elements\n */\nexport type JsxChildren = JsxChild | JsxChild[];\n\n/**\n * A content type representing ICU messages\n */\nexport type IcuMessage = string;\n\n/**\n * A content type representing I18next messages\n */\nexport type I18nextMessage = string;\n\n/**\n * A content type representing plain strings\n */\nexport type StringMessage = string;\n"],"mappings":";;;;AAKA,MAAa,qBAAqB;CAChC,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN"}
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../src/types-dir/jsx/content.ts"],"sourcesContent":["import { Variable } from './variables';\n\n/**\n * Map of data-_gt properties to their corresponding React props\n */\nexport const HTML_CONTENT_PROPS = {\n pl: 'placeholder',\n ti: 'title',\n alt: 'alt',\n arl: 'aria-label',\n arb: 'aria-labelledby',\n ard: 'aria-describedby',\n} as const;\n\nexport type HtmlContentPropKeysRecord = Partial<\n Record<keyof typeof HTML_CONTENT_PROPS, string>\n>;\nexport type HtmlContentPropValuesRecord = Partial<\n Record<(typeof HTML_CONTENT_PROPS)[keyof typeof HTML_CONTENT_PROPS], string>\n>;\n\n/**\n * GTProp is an internal property used to contain data for translating and rendering elements.\n * note, transformations are only read on the server side if they are 'plural' or 'branch'\n */\nexport type GTProp = {\n b?: Record<string, JsxChildren>; // Branches\n t?: 'p' | 'b'; // Branch Transformation\n} & HtmlContentPropKeysRecord;\n\nexport type JsxElement = {\n t?: string; // tag name\n i?: number; // id\n d?: GTProp; // GT data\n c?: JsxChildren; // children\n};\n\nexport type JsxChild = string | JsxElement | Variable;\n\n/**\n * The format of the string content\n */\nexport type StringFormat = 'ICU' | 'I18NEXT' | 'STRING';\n\n/**\n * The format of the content.\n */\nexport type DataFormat = 'JSX' | StringFormat;\n\n/**\n * String format content.\n */\nexport type StringContent = IcuMessage | StringMessage | I18nextMessage;\n\n/**\n * A content type representing JSX, ICU, and I18next messages.\n */\nexport type Content = JsxChildren | StringContent;\n\n/**\n * A content type representing JSX elements.\n */\nexport type JsxChildren = JsxChild | JsxChild[];\n\n/**\n * A content type representing ICU messages.\n */\nexport type IcuMessage = string;\n\n/**\n * A content type representing I18next messages.\n */\nexport type I18nextMessage = string;\n\n/**\n * A content type representing plain strings.\n */\nexport type StringMessage = string;\n"],"mappings":";;;;AAKA,MAAa,qBAAqB;CAChC,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN"}
@@ -0,0 +1,2 @@
1
+ export declare function encode(data: string): string;
2
+ export declare function decode(base64: string): string;
@@ -0,0 +1,28 @@
1
+ // Encode a string to base64
2
+ export function encode(data) {
3
+ if (typeof Buffer !== 'undefined') {
4
+ // Node.js path.
5
+ return Buffer.from(data, 'utf8').toString('base64');
6
+ }
7
+ // Browser path.
8
+ var bytes = new TextEncoder().encode(data);
9
+ var binary = '';
10
+ for (var i = 0; i < bytes.length; i++) {
11
+ binary += String.fromCharCode(bytes[i]);
12
+ }
13
+ return btoa(binary);
14
+ }
15
+ // Decode a base64 string to a string
16
+ export function decode(base64) {
17
+ if (typeof Buffer !== 'undefined') {
18
+ // Node.js path.
19
+ return Buffer.from(base64, 'base64').toString('utf8');
20
+ }
21
+ // Browser path.
22
+ var binary = atob(base64);
23
+ var bytes = new Uint8Array(binary.length);
24
+ for (var i = 0; i < binary.length; i++) {
25
+ bytes[i] = binary.charCodeAt(i);
26
+ }
27
+ return new TextDecoder().decode(bytes);
28
+ }
@@ -0,0 +1,8 @@
1
+ import type { FileFormat } from '../types-dir/api/file';
2
+ /**
3
+ * This function checks if a file format transformation is supported during translation
4
+ * @param from - The source file format.
5
+ * @param to - The target file format.
6
+ * @returns True if the transformation is supported, false otherwise
7
+ */
8
+ export declare function isSupportedFileFormatTransform(from: FileFormat, to: FileFormat): boolean;
@@ -0,0 +1,26 @@
1
+ var SUPPORTED_TRANSFORMATIONS = {
2
+ GTJSON: ['GTJSON'],
3
+ JSON: ['JSON'],
4
+ PO: ['PO'],
5
+ // POT templates can produce translated PO catalog files.
6
+ POT: ['POT', 'PO'],
7
+ YAML: ['YAML'],
8
+ MDX: ['MDX'],
9
+ MD: ['MD'],
10
+ TS: ['TS'],
11
+ JS: ['JS'],
12
+ HTML: ['HTML'],
13
+ TXT: ['TXT'],
14
+ TWILIO_CONTENT_JSON: ['TWILIO_CONTENT_JSON'],
15
+ };
16
+ /**
17
+ * This function checks if a file format transformation is supported during translation
18
+ * @param from - The source file format.
19
+ * @param to - The target file format.
20
+ * @returns True if the transformation is supported, false otherwise
21
+ */
22
+ export function isSupportedFileFormatTransform(from, to) {
23
+ var _a;
24
+ var toFormats = SUPPORTED_TRANSFORMATIONS[from];
25
+ return (_a = toFormats === null || toFormats === void 0 ? void 0 : toFormats.includes(to)) !== null && _a !== void 0 ? _a : false;
26
+ }
@@ -0,0 +1,2 @@
1
+ import { Variable } from '../types';
2
+ export default function isVariable(obj: unknown): obj is Variable;
@@ -0,0 +1,22 @@
1
+ export default function isVariable(obj) {
2
+ var variableObj = obj;
3
+ if (variableObj &&
4
+ typeof variableObj === 'object' &&
5
+ typeof variableObj.k === 'string') {
6
+ var k = Object.keys(variableObj);
7
+ if (k.length === 1)
8
+ return true;
9
+ if (k.length === 2) {
10
+ if (typeof variableObj.i === 'number')
11
+ return true;
12
+ if (typeof variableObj.v === 'string')
13
+ return true;
14
+ }
15
+ if (k.length === 3) {
16
+ if (typeof variableObj.v === 'string' &&
17
+ typeof variableObj.i === 'number')
18
+ return true;
19
+ }
20
+ }
21
+ return false;
22
+ }
@@ -0,0 +1,2 @@
1
+ import { VariableTransformationSuffix, VariableType } from '../types';
2
+ export declare function minifyVariableType(variableType: VariableTransformationSuffix): VariableType;
@@ -0,0 +1,10 @@
1
+ var VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES = {
2
+ variable: 'v',
3
+ number: 'n',
4
+ datetime: 'd',
5
+ currency: 'c',
6
+ 'relative-time': 'rt',
7
+ };
8
+ export function minifyVariableType(variableType) {
9
+ return VARIABLE_TRANSFORMATION_SUFFIXES_TO_MINIFIED_NAMES[variableType];
10
+ }
@@ -0,0 +1 @@
1
+ export declare function stableStringify(data: unknown): string;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Deterministic JSON stringification with sorted object keys.
3
+ * Drop-in replacement for `fast-json-stable-stringify` for plain
4
+ * JSON-compatible data (no toJSON, no circular references).
5
+ */
6
+ function _stringify(node) {
7
+ if (node === undefined)
8
+ return undefined;
9
+ if (node === null)
10
+ return 'null';
11
+ if (typeof node === 'number')
12
+ return isFinite(node) ? '' + node : 'null';
13
+ if (typeof node !== 'object')
14
+ return JSON.stringify(node);
15
+ if (Array.isArray(node)) {
16
+ var out_1 = '[';
17
+ for (var i = 0; i < node.length; i++) {
18
+ if (i)
19
+ out_1 += ',';
20
+ out_1 += _stringify(node[i]) || 'null';
21
+ }
22
+ return out_1 + ']';
23
+ }
24
+ var keys = Object.keys(node).sort();
25
+ var out = '';
26
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
27
+ var key = keys_1[_i];
28
+ var value = _stringify(node[key]);
29
+ if (!value)
30
+ continue;
31
+ if (out)
32
+ out += ',';
33
+ out += JSON.stringify(key) + ':' + value;
34
+ }
35
+ return '{' + out + '}';
36
+ }
37
+ export function stableStringify(data) {
38
+ var _a;
39
+ return (_a = _stringify(data)) !== null && _a !== void 0 ? _a : '';
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generaltranslation",
3
- "version": "8.2.11",
3
+ "version": "8.2.13",
4
4
  "description": "A language toolkit for AI developers",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -31,9 +31,9 @@
31
31
  },
32
32
  "homepage": "https://generaltranslation.com/",
33
33
  "devDependencies": {
34
- "@types/node": "^20.14.9",
34
+ "@types/node": "^22.13.5",
35
35
  "tsdown": "^0.21.10",
36
- "typescript": "^5.6.2"
36
+ "typescript": "^5.9.2"
37
37
  },
38
38
  "typescript": {
39
39
  "definition": "dist/index.d.cts"
@@ -148,13 +148,12 @@
148
148
  "build:release": "pnpm run build:clean",
149
149
  "build:clean": "sh ../../scripts/clean.sh && pnpm run build",
150
150
  "build": "tsdown",
151
- "lint": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\"",
152
- "lint:fix": "eslint \"src/**/*.{js,ts}\" \"./**/__tests__/**/*.{js,ts}\" --fix",
153
151
  "test": "vitest run --config=./vitest.config.ts",
154
152
  "test:watch": "vitest --config=./vitest.config.ts",
155
153
  "release": "pnpm run build:clean && pnpm publish",
156
154
  "release:alpha": "pnpm run build:clean && pnpm publish --tag alpha",
157
155
  "release:beta": "pnpm run build:clean && pnpm publish --tag beta",
158
- "release:latest": "pnpm run build:clean && pnpm publish --tag latest"
156
+ "release:latest": "pnpm run build:clean && pnpm publish --tag latest",
157
+ "typecheck": "tsc --noEmit"
159
158
  }
160
159
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlCache-Ccg_cQPR.mjs","names":[],"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"],"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"],"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;GACZ,WAAW;GACZ;EACD,IAAI;GACF,YAAY;GACZ,WAAW,KAAA;GACZ;EACD,IAAI;GACF,YAAY;GACZ,WAAW,KAAA;GACZ;GACA,yBAAyB;GACxB,YAAY;GACZ,WAAW,KAAA;GACZ;EACF;CACD,MAAM,GACH,yBAAyB;EACxB,YAAY,KAAA;EACZ,WAAW,KAAA;EACZ,EACF;CACF;;;ACjBD,IAAa,0BAAb,MAA6D;;;;;;;;;;;;;;;;;;;;;;CAyB3D,YACE,SACA,UAA+B,EAAE,EACjC;AAEA,MAAI;GAEF,MAAM,cAAc,CAAC,UACjB,CAAA,KAAsB,GACtB,MAAM,QAAQ,QAAQ,GACpB,QAAQ,KAAK,MAAM,OAAO,EAAE,CAAC,GAC7B,CAAC,OAAO,QAAQ,CAAC;GACvB,MAAM,mBAAmB,KAAK,oBAAoB,YAAY;AAC9D,QAAK,SAAS,iBAAiB,SAC3B,iBAAiB,KAAA;UAEf;AACN,QAAK,SAAA;;AAIP,MAAI,CAAC,eAAe,QAAQ,SAAA,YAC1B,OAAM,IAAI,MACR,8BACE,QAAQ,SAAA,WACT,CACF;EAIH,IAAI;EACJ,IAAI;AACJ,MAAI,QAAQ,aAAa,KAAA,GAAW;AAClC,WAAQ,QAAQ,SAAA;GAEhB,MAAM,eAAe,IAAI,KAAK,OAAO,KAAK,OAAO,CAAC;AAClD,6BACE,eAAe,OAAO,iBACtB,eAAe,OAAA;;EAEnB,IAAI,aACF,QAAQ,cAAc,yBAAyB;EACjD,IAAI,YACF,cAAc,OACT,QAAQ,aAAa,yBAAyB,YAC/C,KAAA;AAEN,OAAK,kBAAkB,YAAY,UAAU,MAAM,WAAW,UAAU;AACxE,MACE,QAAQ,aAAa,KAAA,KACrB,KAAK,IAAI,QAAQ,SAAS,GAAG,KAAK,gBAClC;AACA,gBAAa,KAAA;AACb,eAAY,KAAA;;AAGd,OAAK,UAAU;GACb,UAAU,QAAQ;GAClB;GACA;GACA;GACD;;;;;;;;;;;;CAaH,OAAO,OAAuB;AAC5B,SAAO,KAAK,cAAc,MAAM,CAAC,KAAK,GAAG;;;;;;;;;;;;;;;;CAiB3C,cAAc,OAA6D;EACzE,MAAM,EAAE,UAAU,YAAY,cAAc,KAAK;EAIjD,MAAM,gBACJ,aAAa,KAAA,KAAa,KAAK,IAAI,SAAS,IAAI,MAAM,SAClD,WACA,YAAY,IACV,KAAK,IAAI,GAAG,WAAW,KAAK,eAAe,GAC3C,KAAK,IAAI,GAAG,WAAW,KAAK,eAAe;EACnD,MAAM,cACJ,kBAAkB,KAAA,KAAa,gBAAgB,KAC3C,MAAM,MAAM,GAAG,cAAc,GAC7B,MAAM,MAAM,cAAc;AAGhC,MACE,YAAY,QACZ,iBAAiB,QACjB,kBAAkB,KAClB,cAAc,QACd,MAAM,UAAU,KAAK,IAAI,SAAS,CAElC,QAAO,CAAC,YAAY;AAItB,MAAI,gBAAgB,EAClB,QAAO,aAAa,OAChB;GAAC;GAAa;GAAW;GAAW,GACpC,CAAC,aAAa,WAAW;MAI7B,QAAO,aAAa,OAChB;GAAC;GAAY;GAAW;GAAY,GACpC,CAAC,YAAY,YAAY;;;;;;CAQjC,kBAA+C;AAC7C,SAAO,KAAK;;;;;;;;;ACvKhB,MAAM,aAA6B;CACjC,UAAU,KAAK;CACf,gBAAgB,KAAK;CACrB,cAAc,KAAK;CACnB,YAAY,KAAK;CACjB,QAAQ,KAAK;CACb,cAAc,KAAK;CACnB,aAAa,KAAK;CAClB,oBAAoB,KAAK;CACzB,WAAW,KAAK;CAChB,cAAc;CACf;;;;;AAMD,IAAM,YAAN,MAAgB;CAGd,cAAc;AACZ,OAAK,QAAQ,EAAE;;;;;;CAOjB,aAAqB,SAA+B,UAAU,EAAE,EAAE;AAYhE,SAAO,GAVW,CAAC,UACf,cACA,MAAM,QAAQ,QAAQ,GACpB,QAAQ,KAAK,MAAM,OAAO,EAAE,CAAC,CAAC,KAAK,IAAI,GACvC,OAAO,QAAQ,CAMD,GAHE,UAClB,KAAK,UAAU,SAAS,OAAO,KAAK,QAAQ,CAAC,MAAM,CAAC,GACpD;;;;;;;;CAUN,IACE,aACA,GAAG,MAC+B;EAClC,MAAM,CAAC,UAAA,MAAgC,UAAU,EAAE,IAAI;EACvD,MAAM,MAAM,KAAK,aAAa,SAAS,QAAQ;EAC/C,IAAI,aAAa,KAAK,MAAM,eAAe;AAE3C,MAAI,eAAe,KAAA,GAAW;AAE5B,gBAAa,IAAI,WAAW,aAAa,GAAG,KAAK;AACjD,OAAI,CAAC,KAAK,MAAM,aAAc,MAAK,MAAM,eAAe,EAAE;AAC1D,QAAK,MAAM,aAAa,OAAO;;AAGjC,SAAO;;;;;;AAOX,MAAa,YAAY,IAAI,WAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"IntlCache-k2qfrDqB.cjs","names":[],"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"],"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"],"mappings":"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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"base64-C1sogiix.mjs","names":[],"sources":["../src/settings/settingsUrls.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/utils/base64.ts"],"sourcesContent":["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","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","// 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"],"mappings":";AAAA,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;;;ACApC,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;CAC7C;;;;;;;AAQD,SAAgB,+BACd,MACA,IACS;AAET,QAD4C,0BAA0B,OACpD,SAAS,GAAG,IAAI;;;;;;;;ACfpC,SAAgB,4BACd,MACoB;AACpB,KAAI,CAAC,KAAK,gBAAiB,QAAO,KAAA;CAClC,MAAM,YAAY,KAAK,YAAY,KAAK,UAAU;AAClD,KAAI,CAAC,KAAK,WACR,QAAO,+DAA+D;AAExE,KAAI,CAAC,+BAA+B,KAAK,YAAY,KAAK,gBAAgB,CACxE,QAAO,sCAAsC,KAAK,WAAW,MAAM,KAAK;;;;;AAQ5E,SAAgB,6BACd,OACM;AACN,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,4BAA4B,KAAK;AAC/C,MAAI,MAAO,OAAM,IAAI,MAAM,MAAM;;;;;ACnCrC,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"}