generaltranslation 9.1.13 → 9.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/api.cjs +9 -0
  3. package/dist/api.d.cts +1 -0
  4. package/dist/api.d.mts +1 -0
  5. package/dist/api.d.ts +1 -0
  6. package/dist/api.js +1 -0
  7. package/dist/api.mjs +2 -0
  8. package/dist/{derive-C3nzgrzy.mjs → derive-BEA36WQM.mjs} +5 -3
  9. package/dist/derive-BEA36WQM.mjs.map +1 -0
  10. package/dist/{derive-bDBg-KyF.cjs → derive-Yxp38Tjn.cjs} +3 -2
  11. package/dist/derive-Yxp38Tjn.cjs.map +1 -0
  12. package/dist/{file-D7gKavRj.cjs → file-B37WkCqM.cjs} +6 -6
  13. package/dist/file-B37WkCqM.cjs.map +1 -0
  14. package/dist/{file-Cgk1Xk9d.mjs → file-Dga6cyM8.mjs} +6 -6
  15. package/dist/file-Dga6cyM8.mjs.map +1 -0
  16. package/dist/id.d.cts +1 -1
  17. package/dist/id.d.mts +1 -1
  18. package/dist/index.cjs +131 -26
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.mts +1 -1
  22. package/dist/index.mjs +109 -5
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/internal.cjs +17 -9
  25. package/dist/internal.cjs.map +1 -1
  26. package/dist/internal.d.cts +18 -6
  27. package/dist/internal.d.mts +18 -6
  28. package/dist/internal.d.ts +1 -0
  29. package/dist/internal.js +1 -0
  30. package/dist/internal.mjs +3 -3
  31. package/dist/openapi.json +6190 -0
  32. package/dist/{runtime-hWpzl6v_.mjs → runtime-CqKaoInO.mjs} +23 -114
  33. package/dist/runtime-CqKaoInO.mjs.map +1 -0
  34. package/dist/{runtime-DoOLkKJT.cjs → runtime-DeF1Ef5w.cjs} +45 -136
  35. package/dist/{runtime-DoOLkKJT.cjs.map → runtime-DeF1Ef5w.cjs.map} +1 -1
  36. package/dist/runtime.cjs +1 -1
  37. package/dist/runtime.d.cts +1 -1
  38. package/dist/runtime.d.mts +1 -1
  39. package/dist/runtime.mjs +1 -1
  40. package/dist/settings/settingsUrls.d.ts +2 -2
  41. package/dist/settings/settingsUrls.js +2 -2
  42. package/dist/translate/api.d.ts +4 -1
  43. package/dist/translate/api.js +4 -1
  44. package/dist/translate/translateMany.js +34 -13
  45. package/dist/translate/utils/apiRequest.js +3 -3
  46. package/dist/translate/utils/fetchWithTimeout.js +7 -2
  47. package/dist/translate/utils/unwrapApiResult.d.ts +15 -0
  48. package/dist/translate/utils/unwrapApiResult.js +30 -0
  49. package/dist/{types-C8sSACgY.d.mts → types-BUNfoXph.d.mts} +6 -6
  50. package/dist/{types-DO3dc8ST.d.cts → types-Do446qa9.d.cts} +6 -6
  51. package/dist/types-dir/api/file.d.ts +4 -4
  52. package/dist/types-dir/api/file.js +5 -5
  53. package/dist/types.cjs +1 -1
  54. package/dist/types.d.cts +1 -1
  55. package/dist/types.d.mts +1 -1
  56. package/dist/types.mjs +1 -1
  57. package/dist/{api-rqq7klYe.mjs → unwrapApiResult-BzGfPw75.mjs} +24 -6
  58. package/dist/unwrapApiResult-BzGfPw75.mjs.map +1 -0
  59. package/dist/{api-tMgy8sHj.cjs → unwrapApiResult-Dv6Mfw_K.cjs} +41 -11
  60. package/dist/unwrapApiResult-Dv6Mfw_K.cjs.map +1 -0
  61. package/dist/utils/isSupportedFileFormatTransform.js +1 -0
  62. package/package.json +16 -2
  63. package/dist/api-rqq7klYe.mjs.map +0 -1
  64. package/dist/api-tMgy8sHj.cjs.map +0 -1
  65. package/dist/derive-C3nzgrzy.mjs.map +0 -1
  66. package/dist/derive-bDBg-KyF.cjs.map +0 -1
  67. package/dist/file-Cgk1Xk9d.mjs.map +0 -1
  68. package/dist/file-D7gKavRj.cjs.map +0 -1
  69. package/dist/runtime-hWpzl6v_.mjs.map +0 -1
@@ -1,5 +1,5 @@
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
1
  import * as _$_generaltranslation_api0 from "@generaltranslation/api";
2
+ 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";
3
3
 
4
4
  //#region src/types-dir/api/entry.d.ts
5
5
  /**
@@ -229,10 +229,10 @@ type FileFormat = _$_generaltranslation_api0.FileFormat;
229
229
  * base64-encoded, so the usual UTF-8 encode/decode steps are skipped and the
230
230
  * bytes reach the API unaltered.
231
231
  *
232
- * LOTTIE qualifies because it is a zip bundle. DOT_STRINGS qualifies because
233
- * older Xcode wrote `.strings` as UTF-16: the API chooses a decoder from the
234
- * byte order mark, and a UTF-8 round trip anywhere in between replaces those
235
- * bytes with U+FFFD.
232
+ * LOTTIE qualifies because it is a zip bundle. Apple's `.strings` and
233
+ * `.stringsdict` do not: they are text in whichever encoding Xcode wrote, and
234
+ * the client decodes that to UTF-8 before upload and restores it on write, so
235
+ * only the client ever handles their bytes.
236
236
  */
237
237
  declare const BINARY_FILE_FORMATS: ReadonlySet<FileFormat>;
238
238
  /**
@@ -649,4 +649,4 @@ type TranslationRequestConfig = {
649
649
  };
650
650
  //#endregion
651
651
  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 };
652
- //# sourceMappingURL=types-DO3dc8ST.d.cts.map
652
+ //# sourceMappingURL=types-Do446qa9.d.cts.map
@@ -7,10 +7,10 @@ export type FileFormat = import('@generaltranslation/api').FileFormat;
7
7
  * base64-encoded, so the usual UTF-8 encode/decode steps are skipped and the
8
8
  * bytes reach the API unaltered.
9
9
  *
10
- * LOTTIE qualifies because it is a zip bundle. DOT_STRINGS qualifies because
11
- * older Xcode wrote `.strings` as UTF-16: the API chooses a decoder from the
12
- * byte order mark, and a UTF-8 round trip anywhere in between replaces those
13
- * bytes with U+FFFD.
10
+ * LOTTIE qualifies because it is a zip bundle. Apple's `.strings` and
11
+ * `.stringsdict` do not: they are text in whichever encoding Xcode wrote, and
12
+ * the client decodes that to UTF-8 before upload and restores it on write, so
13
+ * only the client ever handles their bytes.
14
14
  */
15
15
  export declare const BINARY_FILE_FORMATS: ReadonlySet<FileFormat>;
16
16
  /**
@@ -3,12 +3,12 @@
3
3
  * base64-encoded, so the usual UTF-8 encode/decode steps are skipped and the
4
4
  * bytes reach the API unaltered.
5
5
  *
6
- * LOTTIE qualifies because it is a zip bundle. DOT_STRINGS qualifies because
7
- * older Xcode wrote `.strings` as UTF-16: the API chooses a decoder from the
8
- * byte order mark, and a UTF-8 round trip anywhere in between replaces those
9
- * bytes with U+FFFD.
6
+ * LOTTIE qualifies because it is a zip bundle. Apple's `.strings` and
7
+ * `.stringsdict` do not: they are text in whichever encoding Xcode wrote, and
8
+ * the client decodes that to UTF-8 before upload and restores it on write, so
9
+ * only the client ever handles their bytes.
10
10
  */
11
- export var BINARY_FILE_FORMATS = new Set(['LOTTIE', 'DOT_STRINGS']);
11
+ export var BINARY_FILE_FORMATS = new Set(['LOTTIE']);
12
12
  /**
13
13
  * Whether a file format's content is carried as base64 end-to-end rather than
14
14
  * as a UTF-8 text string.
package/dist/types.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_file = require("./file-D7gKavRj.cjs");
2
+ const require_file = require("./file-B37WkCqM.cjs");
3
3
  let _generaltranslation_format_types = require("@generaltranslation/format/types");
4
4
  exports.BINARY_FILE_FORMATS = require_file.BINARY_FILE_FORMATS;
5
5
  Object.defineProperty(exports, "HTML_CONTENT_PROPS", {
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-DO3dc8ST.cjs";
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-Do446qa9.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-C8sSACgY.mjs";
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-BUNfoXph.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/dist/types.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as isBinaryFileFormat, t as BINARY_FILE_FORMATS } from "./file-Cgk1Xk9d.mjs";
1
+ import { n as isBinaryFileFormat, t as BINARY_FILE_FORMATS } from "./file-Dga6cyM8.mjs";
2
2
  import { HTML_CONTENT_PROPS } from "@generaltranslation/format/types";
3
3
  export { BINARY_FILE_FORMATS, HTML_CONTENT_PROPS, isBinaryFileFormat };
@@ -1,3 +1,4 @@
1
+ import { t as ApiError } from "./ApiError-CUKcz3YS.mjs";
1
2
  //#region src/settings/settings.ts
2
3
  const libraryDefaultLocale = "en";
3
4
  const defaultTimeout = 6e4;
@@ -46,12 +47,29 @@ function createDiagnosticMessage({ source, severity, whatHappened, reassurance,
46
47
  //#endregion
47
48
  //#region src/settings/settingsUrls.ts
48
49
  const defaultCacheUrl = "https://cdn.gtx.dev";
49
- const defaultBaseUrl = "https://api2.gtx.dev";
50
- const defaultRuntimeApiUrl = "https://runtime2.gtx.dev";
50
+ const defaultBaseUrl = "https://api.gtx.dev";
51
+ const defaultRuntimeApiUrl = "https://api.gtx.dev";
51
52
  //#endregion
52
- //#region src/translate/api.ts
53
- const API_VERSION = "2026-03-06.v1";
53
+ //#region src/translate/utils/unwrapApiResult.ts
54
+ function isErrorResult(error) {
55
+ return typeof error === "object" && error !== null && "error" in error && typeof error.error === "string";
56
+ }
57
+ function hasDecodedError(result) {
58
+ return isErrorResult(result.error) || typeof result.error === "string";
59
+ }
60
+ /**
61
+ * Unwraps a `@generaltranslation/api` SDK result, returning its data or
62
+ * throwing an `ApiError` built from the failed response.
63
+ */
64
+ function unwrapApiResult(result) {
65
+ if (result.data !== void 0) return result.data;
66
+ if (result.response) {
67
+ const details = isErrorResult(result.error) ? result.error.error : typeof result.error === "string" ? result.error : result.response.statusText;
68
+ throw new ApiError(details, result.response.status, details);
69
+ }
70
+ throw result.error;
71
+ }
54
72
  //#endregion
55
- export { createDiagnosticMessage as a, libraryDefaultLocale as c, defaultRuntimeApiUrl as i, defaultBaseUrl as n, formatDiagnosticErrorDetails as o, defaultCacheUrl as r, defaultTimeout as s, API_VERSION as t };
73
+ export { defaultCacheUrl as a, formatDiagnosticErrorDetails as c, defaultBaseUrl as i, defaultTimeout as l, isErrorResult as n, defaultRuntimeApiUrl as o, unwrapApiResult as r, createDiagnosticMessage as s, hasDecodedError as t, libraryDefaultLocale as u };
56
74
 
57
- //# sourceMappingURL=api-rqq7klYe.mjs.map
75
+ //# sourceMappingURL=unwrapApiResult-BzGfPw75.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unwrapApiResult-BzGfPw75.mjs","names":[],"sources":["../src/settings/settings.ts","../src/logging/diagnostics.ts","../src/settings/settingsUrls.ts","../src/translate/utils/unwrapApiResult.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\n","export type DiagnosticSeverity = 'Error' | 'Warning';\n\n/**\n * Text slots follow the five-part error message model:\n * what happened, reassurance, why it happened, how to fix it, and a way out.\n * Clauses that are combined into another sentence should use their intended\n * in-sentence casing.\n */\nexport type DiagnosticMessageInput = {\n source?: string;\n severity?: DiagnosticSeverity;\n whatHappened: string;\n reassurance?: string;\n why?: string;\n fix?: string;\n wayOut?: string;\n details?: string | string[];\n docsUrl?: string;\n};\n\nfunction ensureSentence(text: string): string {\n const trimmed = text.trim();\n if (!trimmed) return '';\n return /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\n\nfunction stripSentence(text: string): string {\n const trimmed = text.trim();\n let end = trimmed.length;\n while (end > 0) {\n const char = trimmed[end - 1];\n if (char !== '.' && char !== '!' && char !== '?') break;\n end -= 1;\n }\n return trimmed.slice(0, end);\n}\n\nfunction formatDetails(details: string | string[] | undefined): string {\n if (!details) return '';\n const detailText = Array.isArray(details) ? details.join(', ') : details;\n if (!detailText.trim()) return '';\n return ensureSentence(`Details: ${detailText}`);\n}\n\nexport function formatDiagnosticErrorDetails(\n error: unknown\n): string | undefined {\n if (error == null) return undefined;\n return String(error);\n}\n\nexport function createDiagnosticMessage({\n source,\n severity,\n whatHappened,\n reassurance,\n why,\n fix,\n wayOut,\n details,\n docsUrl,\n}: DiagnosticMessageInput): string {\n const prefix = source\n ? severity\n ? `${source} ${severity}:`\n : `${source}:`\n : severity\n ? `${severity}:`\n : '';\n const whatAndWhy = why\n ? `${stripSentence(whatHappened)} because ${stripSentence(why)}`\n : whatHappened;\n const shouldCombineWayOut =\n !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n const fixAndWayOut = shouldCombineWayOut\n ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}`\n : fix;\n const messageParts = [\n whatAndWhy,\n reassurance,\n fixAndWayOut,\n shouldCombineWayOut ? undefined : wayOut,\n formatDetails(details),\n ]\n .filter((part): part is string => !!part)\n .map(ensureSentence);\n\n if (docsUrl) {\n messageParts.push(`Learn more: ${docsUrl}`);\n }\n\n const message = messageParts.join(' ');\n return prefix ? `${prefix} ${message}` : message;\n}\n","export const defaultCacheUrl = 'https://cdn.gtx.dev' as const;\nexport const defaultBaseUrl = 'https://api.gtx.dev' as const;\nexport const defaultRuntimeApiUrl = 'https://api.gtx.dev' as const;\n","import { ApiError } from '../../errors/ApiError';\n\nexport function isErrorResult(error: unknown): error is { error: string } {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'error' in error &&\n typeof error.error === 'string'\n );\n}\n\nexport function hasDecodedError(result: { error: unknown }): boolean {\n return isErrorResult(result.error) || typeof result.error === 'string';\n}\n\n/**\n * Unwraps a `@generaltranslation/api` SDK result, returning its data or\n * throwing an `ApiError` built from the failed response.\n */\nexport function unwrapApiResult<T>(result: {\n data: T | undefined;\n error: unknown;\n response?: Response;\n}): Exclude<T, undefined> {\n if (result.data !== undefined) {\n // TypeScript cannot narrow a generic T after excluding undefined; the\n // runtime guard above establishes the exact Exclude<T, undefined> result.\n return result.data as Exclude<T, undefined>;\n }\n if (result.response) {\n const details = isErrorResult(result.error)\n ? result.error.error\n : typeof result.error === 'string'\n ? result.error\n : result.response.statusText;\n throw new ApiError(details, result.response.status, details);\n }\n throw result.error;\n}\n"],"mappings":";;AAAA,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;;;ACmB9B,SAAS,eAAe,MAAsB;CAC5C,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAGxD,SAAS,cAAc,MAAsB;CAC3C,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACd,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAET,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAG9B,SAAS,cAAc,SAAgD;AACrE,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ,KAAK,KAAK,GAAG;AACjE,KAAI,CAAC,WAAW,MAAM,CAAE,QAAO;AAC/B,QAAO,eAAe,YAAY,aAAa;;AAGjD,SAAgB,6BACd,OACoB;AACpB,KAAI,SAAS,KAAM,QAAO,KAAA;AAC1B,QAAO,OAAO,MAAM;;AAGtB,SAAgB,wBAAwB,EACtC,QACA,UACA,cACA,aACA,KACA,KACA,QACA,SACA,WACiC;CACjC,MAAM,SAAS,SACX,WACE,GAAG,OAAO,GAAG,SAAS,KACtB,GAAG,OAAO,KACZ,WACE,GAAG,SAAS,KACZ;CACN,MAAM,aAAa,MACf,GAAG,cAAc,aAAa,CAAC,WAAW,cAAc,IAAI,KAC5D;CACJ,MAAM,sBACJ,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,SAAS,KAAK,cAAc,OAAO,CAAC;CAI3D,MAAM,eAAe;EACnB;EACA;EALmB,sBACjB,GAAG,cAAc,IAAI,CAAC,OAAO,cAAc,OAAO,KAClD;EAKF,sBAAsB,KAAA,IAAY;EAClC,cAAc,QAAQ;EACvB,CACE,QAAQ,SAAyB,CAAC,CAAC,KAAK,CACxC,IAAI,eAAe;AAEtB,KAAI,QACF,cAAa,KAAK,eAAe,UAAU;CAG7C,MAAM,UAAU,aAAa,KAAK,IAAI;AACtC,QAAO,SAAS,GAAG,OAAO,GAAG,YAAY;;;;AC5F3C,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;;;ACApC,SAAgB,cAAc,OAA4C;AACxE,QACE,OAAO,UAAU,YACjB,UAAU,QACV,WAAW,SACX,OAAO,MAAM,UAAU;;AAI3B,SAAgB,gBAAgB,QAAqC;AACnE,QAAO,cAAc,OAAO,MAAM,IAAI,OAAO,OAAO,UAAU;;;;;;AAOhE,SAAgB,gBAAmB,QAIT;AACxB,KAAI,OAAO,SAAS,KAAA,EAGlB,QAAO,OAAO;AAEhB,KAAI,OAAO,UAAU;EACnB,MAAM,UAAU,cAAc,OAAO,MAAM,GACvC,OAAO,MAAM,QACb,OAAO,OAAO,UAAU,WACtB,OAAO,QACP,OAAO,SAAS;AACtB,QAAM,IAAI,SAAS,SAAS,OAAO,SAAS,QAAQ,QAAQ;;AAE9D,OAAM,OAAO"}
@@ -1,3 +1,4 @@
1
+ const require_ApiError = require("./ApiError-BcjcnTAr.cjs");
1
2
  //#region src/settings/settings.ts
2
3
  const libraryDefaultLocale = "en";
3
4
  const defaultTimeout = 6e4;
@@ -46,18 +47,29 @@ function createDiagnosticMessage({ source, severity, whatHappened, reassurance,
46
47
  //#endregion
47
48
  //#region src/settings/settingsUrls.ts
48
49
  const defaultCacheUrl = "https://cdn.gtx.dev";
49
- const defaultBaseUrl = "https://api2.gtx.dev";
50
- const defaultRuntimeApiUrl = "https://runtime2.gtx.dev";
50
+ const defaultBaseUrl = "https://api.gtx.dev";
51
+ const defaultRuntimeApiUrl = "https://api.gtx.dev";
51
52
  //#endregion
52
- //#region src/translate/api.ts
53
- const API_VERSION = "2026-03-06.v1";
54
- //#endregion
55
- Object.defineProperty(exports, "API_VERSION", {
56
- enumerable: true,
57
- get: function() {
58
- return API_VERSION;
53
+ //#region src/translate/utils/unwrapApiResult.ts
54
+ function isErrorResult(error) {
55
+ return typeof error === "object" && error !== null && "error" in error && typeof error.error === "string";
56
+ }
57
+ function hasDecodedError(result) {
58
+ return isErrorResult(result.error) || typeof result.error === "string";
59
+ }
60
+ /**
61
+ * Unwraps a `@generaltranslation/api` SDK result, returning its data or
62
+ * throwing an `ApiError` built from the failed response.
63
+ */
64
+ function unwrapApiResult(result) {
65
+ if (result.data !== void 0) return result.data;
66
+ if (result.response) {
67
+ const details = isErrorResult(result.error) ? result.error.error : typeof result.error === "string" ? result.error : result.response.statusText;
68
+ throw new require_ApiError.ApiError(details, result.response.status, details);
59
69
  }
60
- });
70
+ throw result.error;
71
+ }
72
+ //#endregion
61
73
  Object.defineProperty(exports, "createDiagnosticMessage", {
62
74
  enumerable: true,
63
75
  get: function() {
@@ -94,11 +106,29 @@ Object.defineProperty(exports, "formatDiagnosticErrorDetails", {
94
106
  return formatDiagnosticErrorDetails;
95
107
  }
96
108
  });
109
+ Object.defineProperty(exports, "hasDecodedError", {
110
+ enumerable: true,
111
+ get: function() {
112
+ return hasDecodedError;
113
+ }
114
+ });
115
+ Object.defineProperty(exports, "isErrorResult", {
116
+ enumerable: true,
117
+ get: function() {
118
+ return isErrorResult;
119
+ }
120
+ });
97
121
  Object.defineProperty(exports, "libraryDefaultLocale", {
98
122
  enumerable: true,
99
123
  get: function() {
100
124
  return libraryDefaultLocale;
101
125
  }
102
126
  });
127
+ Object.defineProperty(exports, "unwrapApiResult", {
128
+ enumerable: true,
129
+ get: function() {
130
+ return unwrapApiResult;
131
+ }
132
+ });
103
133
 
104
- //# sourceMappingURL=api-tMgy8sHj.cjs.map
134
+ //# sourceMappingURL=unwrapApiResult-Dv6Mfw_K.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unwrapApiResult-Dv6Mfw_K.cjs","names":["ApiError"],"sources":["../src/settings/settings.ts","../src/logging/diagnostics.ts","../src/settings/settingsUrls.ts","../src/translate/utils/unwrapApiResult.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\n","export type DiagnosticSeverity = 'Error' | 'Warning';\n\n/**\n * Text slots follow the five-part error message model:\n * what happened, reassurance, why it happened, how to fix it, and a way out.\n * Clauses that are combined into another sentence should use their intended\n * in-sentence casing.\n */\nexport type DiagnosticMessageInput = {\n source?: string;\n severity?: DiagnosticSeverity;\n whatHappened: string;\n reassurance?: string;\n why?: string;\n fix?: string;\n wayOut?: string;\n details?: string | string[];\n docsUrl?: string;\n};\n\nfunction ensureSentence(text: string): string {\n const trimmed = text.trim();\n if (!trimmed) return '';\n return /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\n\nfunction stripSentence(text: string): string {\n const trimmed = text.trim();\n let end = trimmed.length;\n while (end > 0) {\n const char = trimmed[end - 1];\n if (char !== '.' && char !== '!' && char !== '?') break;\n end -= 1;\n }\n return trimmed.slice(0, end);\n}\n\nfunction formatDetails(details: string | string[] | undefined): string {\n if (!details) return '';\n const detailText = Array.isArray(details) ? details.join(', ') : details;\n if (!detailText.trim()) return '';\n return ensureSentence(`Details: ${detailText}`);\n}\n\nexport function formatDiagnosticErrorDetails(\n error: unknown\n): string | undefined {\n if (error == null) return undefined;\n return String(error);\n}\n\nexport function createDiagnosticMessage({\n source,\n severity,\n whatHappened,\n reassurance,\n why,\n fix,\n wayOut,\n details,\n docsUrl,\n}: DiagnosticMessageInput): string {\n const prefix = source\n ? severity\n ? `${source} ${severity}:`\n : `${source}:`\n : severity\n ? `${severity}:`\n : '';\n const whatAndWhy = why\n ? `${stripSentence(whatHappened)} because ${stripSentence(why)}`\n : whatHappened;\n const shouldCombineWayOut =\n !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n const fixAndWayOut = shouldCombineWayOut\n ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}`\n : fix;\n const messageParts = [\n whatAndWhy,\n reassurance,\n fixAndWayOut,\n shouldCombineWayOut ? undefined : wayOut,\n formatDetails(details),\n ]\n .filter((part): part is string => !!part)\n .map(ensureSentence);\n\n if (docsUrl) {\n messageParts.push(`Learn more: ${docsUrl}`);\n }\n\n const message = messageParts.join(' ');\n return prefix ? `${prefix} ${message}` : message;\n}\n","export const defaultCacheUrl = 'https://cdn.gtx.dev' as const;\nexport const defaultBaseUrl = 'https://api.gtx.dev' as const;\nexport const defaultRuntimeApiUrl = 'https://api.gtx.dev' as const;\n","import { ApiError } from '../../errors/ApiError';\n\nexport function isErrorResult(error: unknown): error is { error: string } {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'error' in error &&\n typeof error.error === 'string'\n );\n}\n\nexport function hasDecodedError(result: { error: unknown }): boolean {\n return isErrorResult(result.error) || typeof result.error === 'string';\n}\n\n/**\n * Unwraps a `@generaltranslation/api` SDK result, returning its data or\n * throwing an `ApiError` built from the failed response.\n */\nexport function unwrapApiResult<T>(result: {\n data: T | undefined;\n error: unknown;\n response?: Response;\n}): Exclude<T, undefined> {\n if (result.data !== undefined) {\n // TypeScript cannot narrow a generic T after excluding undefined; the\n // runtime guard above establishes the exact Exclude<T, undefined> result.\n return result.data as Exclude<T, undefined>;\n }\n if (result.response) {\n const details = isErrorResult(result.error)\n ? result.error.error\n : typeof result.error === 'string'\n ? result.error\n : result.response.statusText;\n throw new ApiError(details, result.response.status, details);\n }\n throw result.error;\n}\n"],"mappings":";;AAAA,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;;;ACmB9B,SAAS,eAAe,MAAsB;CAC5C,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GA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B,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;;;ACApC,SAAgB,cAAc,OAA4C;AACxE,QACE,OAAO,UAAU,YACjB,UAAU,QACV,WAAW,SACX,OAAO,MAAM,UAAU;;AAI3B,SAAgB,gBAAgB,QAAqC;AACnE,QAAO,cAAc,OAAO,MAAM,IAAI,OAAO,OAAO,UAAU;;;;;;AAOhE,SAAgB,gBAAmB,QAIT;AACxB,KAAI,OAAO,SAAS,KAAA,EAGlB,QAAO,OAAO;AAEhB,KAAI,OAAO,UAAU;EACnB,MAAM,UAAU,cAAc,OAAO,MAAM,GACvC,OAAO,MAAM,QACb,OAAO,OAAO,UAAU,WACtB,OAAO,QACP,OAAO,SAAS;AACtB,QAAM,IAAIA,iBAAAA,SAAS,SAAS,OAAO,SAAS,QAAQ,QAAQ;;AAE9D,OAAM,OAAO"}
@@ -17,6 +17,7 @@ var SUPPORTED_TRANSFORMATIONS = {
17
17
  DOT_STRINGS: ['DOT_STRINGS'],
18
18
  DOT_STRINGSDICT: ['DOT_STRINGSDICT'],
19
19
  ANDROID_STRINGS: ['ANDROID_STRINGS'],
20
+ XCSTRINGS: ['XCSTRINGS'],
20
21
  };
21
22
  /**
22
23
  * This function checks if a file format transformation is supported during translation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generaltranslation",
3
- "version": "9.1.13",
3
+ "version": "9.3.0",
4
4
  "description": "A language toolkit for AI developers",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@noble/hashes": "^2.2.0",
43
- "@generaltranslation/api": "0.0.6",
43
+ "@generaltranslation/api": "0.2.0",
44
44
  "@generaltranslation/icu": "0.1.2",
45
45
  "@generaltranslation/format": "0.1.8"
46
46
  },
@@ -65,6 +65,17 @@
65
65
  "default": "./dist/runtime.mjs"
66
66
  }
67
67
  },
68
+ "./api": {
69
+ "require": {
70
+ "types": "./dist/api.d.cts",
71
+ "default": "./dist/api.cjs"
72
+ },
73
+ "import": {
74
+ "types": "./dist/api.d.mts",
75
+ "default": "./dist/api.mjs"
76
+ }
77
+ },
78
+ "./api/openapi.json": "./dist/openapi.json",
68
79
  "./id": {
69
80
  "require": {
70
81
  "types": "./dist/id.d.cts",
@@ -111,6 +122,9 @@
111
122
  "internal": [
112
123
  "./dist/internal.d.cts"
113
124
  ],
125
+ "api": [
126
+ "./dist/api.d.cts"
127
+ ],
114
128
  "id": [
115
129
  "./dist/id.d.cts"
116
130
  ],
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-rqq7klYe.mjs","names":[],"sources":["../src/settings/settings.ts","../src/logging/diagnostics.ts","../src/settings/settingsUrls.ts","../src/translate/api.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\n","export type DiagnosticSeverity = 'Error' | 'Warning';\n\n/**\n * Text slots follow the five-part error message model:\n * what happened, reassurance, why it happened, how to fix it, and a way out.\n * Clauses that are combined into another sentence should use their intended\n * in-sentence casing.\n */\nexport type DiagnosticMessageInput = {\n source?: string;\n severity?: DiagnosticSeverity;\n whatHappened: string;\n reassurance?: string;\n why?: string;\n fix?: string;\n wayOut?: string;\n details?: string | string[];\n docsUrl?: string;\n};\n\nfunction ensureSentence(text: string): string {\n const trimmed = text.trim();\n if (!trimmed) return '';\n return /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\n\nfunction stripSentence(text: string): string {\n const trimmed = text.trim();\n let end = trimmed.length;\n while (end > 0) {\n const char = trimmed[end - 1];\n if (char !== '.' && char !== '!' && char !== '?') break;\n end -= 1;\n }\n return trimmed.slice(0, end);\n}\n\nfunction formatDetails(details: string | string[] | undefined): string {\n if (!details) return '';\n const detailText = Array.isArray(details) ? details.join(', ') : details;\n if (!detailText.trim()) return '';\n return ensureSentence(`Details: ${detailText}`);\n}\n\nexport function formatDiagnosticErrorDetails(\n error: unknown\n): string | undefined {\n if (error == null) return undefined;\n return String(error);\n}\n\nexport function createDiagnosticMessage({\n source,\n severity,\n whatHappened,\n reassurance,\n why,\n fix,\n wayOut,\n details,\n docsUrl,\n}: DiagnosticMessageInput): string {\n const prefix = source\n ? severity\n ? `${source} ${severity}:`\n : `${source}:`\n : severity\n ? `${severity}:`\n : '';\n const whatAndWhy = why\n ? `${stripSentence(whatHappened)} because ${stripSentence(why)}`\n : whatHappened;\n const shouldCombineWayOut =\n !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n const fixAndWayOut = shouldCombineWayOut\n ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}`\n : fix;\n const messageParts = [\n whatAndWhy,\n reassurance,\n fixAndWayOut,\n shouldCombineWayOut ? undefined : wayOut,\n formatDetails(details),\n ]\n .filter((part): part is string => !!part)\n .map(ensureSentence);\n\n if (docsUrl) {\n messageParts.push(`Learn more: ${docsUrl}`);\n }\n\n const message = messageParts.join(' ');\n return prefix ? `${prefix} ${message}` : message;\n}\n","export const defaultCacheUrl = 'https://cdn.gtx.dev' as const;\nexport const defaultBaseUrl = 'https://api2.gtx.dev' as const;\nexport const defaultRuntimeApiUrl = 'https://runtime2.gtx.dev' as const;\n","export const API_VERSION = '2026-03-06.v1';\n"],"mappings":";AAAA,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;;;ACmB9B,SAAS,eAAe,MAAsB;CAC5C,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAGxD,SAAS,cAAc,MAAsB;CAC3C,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACd,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAET,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAG9B,SAAS,cAAc,SAAgD;AACrE,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ,KAAK,KAAK,GAAG;AACjE,KAAI,CAAC,WAAW,MAAM,CAAE,QAAO;AAC/B,QAAO,eAAe,YAAY,aAAa;;AAGjD,SAAgB,6BACd,OACoB;AACpB,KAAI,SAAS,KAAM,QAAO,KAAA;AAC1B,QAAO,OAAO,MAAM;;AAGtB,SAAgB,wBAAwB,EACtC,QACA,UACA,cACA,aACA,KACA,KACA,QACA,SACA,WACiC;CACjC,MAAM,SAAS,SACX,WACE,GAAG,OAAO,GAAG,SAAS,KACtB,GAAG,OAAO,KACZ,WACE,GAAG,SAAS,KACZ;CACN,MAAM,aAAa,MACf,GAAG,cAAc,aAAa,CAAC,WAAW,cAAc,IAAI,KAC5D;CACJ,MAAM,sBACJ,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,SAAS,KAAK,cAAc,OAAO,CAAC;CAI3D,MAAM,eAAe;EACnB;EACA;EALmB,sBACjB,GAAG,cAAc,IAAI,CAAC,OAAO,cAAc,OAAO,KAClD;EAKF,sBAAsB,KAAA,IAAY;EAClC,cAAc,QAAQ;EACvB,CACE,QAAQ,SAAyB,CAAC,CAAC,KAAK,CACxC,IAAI,eAAe;AAEtB,KAAI,QACF,cAAa,KAAK,eAAe,UAAU;CAG7C,MAAM,UAAU,aAAa,KAAK,IAAI;AACtC,QAAO,SAAS,GAAG,OAAO,GAAG,YAAY;;;;AC5F3C,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;;;ACFpC,MAAa,cAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-tMgy8sHj.cjs","names":[],"sources":["../src/settings/settings.ts","../src/logging/diagnostics.ts","../src/settings/settingsUrls.ts","../src/translate/api.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\n","export type DiagnosticSeverity = 'Error' | 'Warning';\n\n/**\n * Text slots follow the five-part error message model:\n * what happened, reassurance, why it happened, how to fix it, and a way out.\n * Clauses that are combined into another sentence should use their intended\n * in-sentence casing.\n */\nexport type DiagnosticMessageInput = {\n source?: string;\n severity?: DiagnosticSeverity;\n whatHappened: string;\n reassurance?: string;\n why?: string;\n fix?: string;\n wayOut?: string;\n details?: string | string[];\n docsUrl?: string;\n};\n\nfunction ensureSentence(text: string): string {\n const trimmed = text.trim();\n if (!trimmed) return '';\n return /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;\n}\n\nfunction stripSentence(text: string): string {\n const trimmed = text.trim();\n let end = trimmed.length;\n while (end > 0) {\n const char = trimmed[end - 1];\n if (char !== '.' && char !== '!' && char !== '?') break;\n end -= 1;\n }\n return trimmed.slice(0, end);\n}\n\nfunction formatDetails(details: string | string[] | undefined): string {\n if (!details) return '';\n const detailText = Array.isArray(details) ? details.join(', ') : details;\n if (!detailText.trim()) return '';\n return ensureSentence(`Details: ${detailText}`);\n}\n\nexport function formatDiagnosticErrorDetails(\n error: unknown\n): string | undefined {\n if (error == null) return undefined;\n return String(error);\n}\n\nexport function createDiagnosticMessage({\n source,\n severity,\n whatHappened,\n reassurance,\n why,\n fix,\n wayOut,\n details,\n docsUrl,\n}: DiagnosticMessageInput): string {\n const prefix = source\n ? severity\n ? `${source} ${severity}:`\n : `${source}:`\n : severity\n ? `${severity}:`\n : '';\n const whatAndWhy = why\n ? `${stripSentence(whatHappened)} because ${stripSentence(why)}`\n : whatHappened;\n const shouldCombineWayOut =\n !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));\n const fixAndWayOut = shouldCombineWayOut\n ? `${stripSentence(fix)}, or ${stripSentence(wayOut)}`\n : fix;\n const messageParts = [\n whatAndWhy,\n reassurance,\n fixAndWayOut,\n shouldCombineWayOut ? undefined : wayOut,\n formatDetails(details),\n ]\n .filter((part): part is string => !!part)\n .map(ensureSentence);\n\n if (docsUrl) {\n messageParts.push(`Learn more: ${docsUrl}`);\n }\n\n const message = messageParts.join(' ');\n return prefix ? `${prefix} ${message}` : message;\n}\n","export const defaultCacheUrl = 'https://cdn.gtx.dev' as const;\nexport const defaultBaseUrl = 'https://api2.gtx.dev' as const;\nexport const defaultRuntimeApiUrl = 'https://runtime2.gtx.dev' as const;\n","export const API_VERSION = '2026-03-06.v1';\n"],"mappings":";AAAA,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;;;ACmB9B,SAAS,eAAe,MAAsB;CAC5C,MAAM,UAAU,KAAK,MAAM;AAC3B,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO,UAAU,KAAK,QAAQ,GAAG,UAAU,GAAG,QAAQ;;AAGxD,SAAS,cAAc,MAAsB;CAC3C,MAAM,UAAU,KAAK,MAAM;CAC3B,IAAI,MAAM,QAAQ;AAClB,QAAO,MAAM,GAAG;EACd,MAAM,OAAO,QAAQ,MAAM;AAC3B,MAAI,SAAS,OAAO,SAAS,OAAO,SAAS,IAAK;AAClD,SAAO;;AAET,QAAO,QAAQ,MAAM,GAAG,IAAI;;AAG9B,SAAS,cAAc,SAAgD;AACrE,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,aAAa,MAAM,QAAQ,QAAQ,GAAG,QAAQ,KAAK,KAAK,GAAG;AACjE,KAAI,CAAC,WAAW,MAAM,CAAE,QAAO;AAC/B,QAAO,eAAe,YAAY,aAAa;;AAGjD,SAAgB,6BACd,OACoB;AACpB,KAAI,SAAS,KAAM,QAAO,KAAA;AAC1B,QAAO,OAAO,MAAM;;AAGtB,SAAgB,wBAAwB,EACtC,QACA,UACA,cACA,aACA,KACA,KACA,QACA,SACA,WACiC;CACjC,MAAM,SAAS,SACX,WACE,GAAG,OAAO,GAAG,SAAS,KACtB,GAAG,OAAO,KACZ,WACE,GAAG,SAAS,KACZ;CACN,MAAM,aAAa,MACf,GAAG,cAAc,aAAa,CAAC,WAAW,cAAc,IAAI,KAC5D;CACJ,MAAM,sBACJ,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,SAAS,KAAK,cAAc,OAAO,CAAC;CAI3D,MAAM,eAAe;EACnB;EACA;EALmB,sBACjB,GAAG,cAAc,IAAI,CAAC,OAAO,cAAc,OAAO,KAClD;EAKF,sBAAsB,KAAA,IAAY;EAClC,cAAc,QAAQ;EACvB,CACE,QAAQ,SAAyB,CAAC,CAAC,KAAK,CACxC,IAAI,eAAe;AAEtB,KAAI,QACF,cAAa,KAAK,eAAe,UAAU;CAG7C,MAAM,UAAU,aAAa,KAAK,IAAI;AACtC,QAAO,SAAS,GAAG,OAAO,GAAG,YAAY;;;;AC5F3C,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,uBAAuB;;;ACFpC,MAAa,cAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"derive-C3nzgrzy.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 DOT_STRINGS: ['DOT_STRINGS'],\n DOT_STRINGSDICT: ['DOT_STRINGSDICT'],\n ANDROID_STRINGS: ['ANDROID_STRINGS'],\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;CACZ,aAAa,CAAC,cAAc;CAC5B,iBAAiB,CAAC,kBAAkB;CACpC,iBAAiB,CAAC,kBAAkB;CACrC;;;;;;;AAQD,SAAgB,+BACd,MACA,IACS;AAET,QAD4C,0BAA0B,OACpD,SAAS,GAAG,IAAI;;;;ACjCpC,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,MAA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ACA,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 +0,0 @@
1
- {"version":3,"file":"derive-bDBg-KyF.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 DOT_STRINGS: ['DOT_STRINGS'],\n DOT_STRINGSDICT: ['DOT_STRINGSDICT'],\n ANDROID_STRINGS: ['ANDROID_STRINGS'],\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;CACZ,aAAa,CAAC,cAAc;CAC5B,iBAAiB,CAAC,kBAAkB;CACpC,iBAAiB,CAAC,kBAAkB;CACrC;;;;;;;AAQD,SAAgB,+BACd,MACA,IACS;AAET,QAD4C,0BAA0B,OACpD,SAAS,GAAG,IAAI;;;;ACjCpC,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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AE;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 +0,0 @@
1
- {"version":3,"file":"file-Cgk1Xk9d.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 travels through the pipeline already\n * base64-encoded, so the usual UTF-8 encode/decode steps are skipped and the\n * bytes reach the API unaltered.\n *\n * LOTTIE qualifies because it is a zip bundle. DOT_STRINGS qualifies because\n * older Xcode wrote `.strings` as UTF-16: the API chooses a decoder from the\n * byte order mark, and a UTF-8 round trip anywhere in between replaces those\n * bytes with U+FFFD.\n */\nexport const BINARY_FILE_FORMATS: ReadonlySet<FileFormat> = new Set<FileFormat>(\n ['LOTTIE', 'DOT_STRINGS']\n);\n\n/**\n * Whether a file format's content is carried as base64 end-to-end rather than\n * as 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":";;;;;;;;;;;AAgBA,MAAa,sBAA+C,IAAI,IAC9D,CAAC,UAAU,cAAc,CAC1B;;;;;AAMD,SAAgB,mBAAmB,YAAiC;AAClE,QAAO,oBAAoB,IAAI,WAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-D7gKavRj.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 travels through the pipeline already\n * base64-encoded, so the usual UTF-8 encode/decode steps are skipped and the\n * bytes reach the API unaltered.\n *\n * LOTTIE qualifies because it is a zip bundle. DOT_STRINGS qualifies because\n * older Xcode wrote `.strings` as UTF-16: the API chooses a decoder from the\n * byte order mark, and a UTF-8 round trip anywhere in between replaces those\n * bytes with U+FFFD.\n */\nexport const BINARY_FILE_FORMATS: ReadonlySet<FileFormat> = new Set<FileFormat>(\n ['LOTTIE', 'DOT_STRINGS']\n);\n\n/**\n * Whether a file format's content is carried as base64 end-to-end rather than\n * as 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":";;;;;;;;;;;AAgBA,MAAa,sBAA+C,IAAI,IAC9D,CAAC,UAAU,cAAc,CAC1B;;;;;AAMD,SAAgB,mBAAmB,YAAiC;AAClE,QAAO,oBAAoB,IAAI,WAAW"}