generaltranslation 8.2.8 → 8.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/{ApiError-4zIP-twr.cjs → ApiError-CZ45tkW6.cjs} +1 -1
- package/dist/{ApiError-4zIP-twr.cjs.map → ApiError-CZ45tkW6.cjs.map} +1 -1
- package/dist/{ApiError-Bv7vlzyQ.mjs → ApiError-IYfaOR30.mjs} +1 -1
- package/dist/{ApiError-Bv7vlzyQ.mjs.map → ApiError-IYfaOR30.mjs.map} +1 -1
- package/dist/IntlCache-Ccg_cQPR.mjs +195 -0
- package/dist/IntlCache-Ccg_cQPR.mjs.map +1 -0
- package/dist/IntlCache-k2qfrDqB.cjs +212 -0
- package/dist/IntlCache-k2qfrDqB.cjs.map +1 -0
- package/dist/base64-C1sogiix.mjs +70 -0
- package/dist/base64-C1sogiix.mjs.map +1 -0
- package/dist/base64-CUcEPEC5.cjs +111 -0
- package/dist/base64-CUcEPEC5.cjs.map +1 -0
- package/dist/core-3SOQ5ND6.cjs +1679 -0
- package/dist/core-3SOQ5ND6.cjs.map +1 -0
- package/dist/core-Bx0m6GOp.mjs +1500 -0
- package/dist/core-Bx0m6GOp.mjs.map +1 -0
- package/dist/core-CJMv4fMa.d.cts +209 -0
- package/dist/core-DtPj_ruw.d.mts +209 -0
- package/dist/core.cjs +8 -0
- package/dist/core.d.cts +2 -0
- package/dist/core.d.mts +2 -0
- package/dist/core.mjs +2 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{id-CPbVYREY.mjs → id-BmOyfaug.mjs} +2 -2
- package/dist/{id-CPbVYREY.mjs.map → id-BmOyfaug.mjs.map} +1 -1
- package/dist/{id-VXBgyXu2.cjs → id-COlX5v3V.cjs} +6 -6
- package/dist/{id-VXBgyXu2.cjs.map → id-COlX5v3V.cjs.map} +1 -1
- package/dist/id.cjs +1 -1
- package/dist/id.d.cts +1 -1
- package/dist/id.d.mts +1 -1
- package/dist/id.mjs +1 -1
- package/dist/index.cjs +60 -1519
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -162
- package/dist/index.d.mts +4 -162
- package/dist/index.mjs +8 -1443
- package/dist/index.mjs.map +1 -1
- package/dist/internal.cjs +602 -44
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.mts +1 -1
- package/dist/internal.mjs +562 -2
- package/dist/internal.mjs.map +1 -0
- package/dist/{sha2-DKowBr6H.cjs → isVariable-B08mggBy.cjs} +18 -18
- package/dist/isVariable-B08mggBy.cjs.map +1 -0
- package/dist/{stableStringify-DgDlE_pD.mjs → isVariable-CYsKFHvR.mjs} +19 -19
- package/dist/isVariable-CYsKFHvR.mjs.map +1 -0
- package/dist/{types-DazaDJbs.d.mts → types-Dfy_sRLD.d.mts} +1 -1
- package/dist/{types-BJdoI1d1.d.cts → types-mZeu4HS3.d.cts} +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +17 -1
- package/dist/internal-B3QbyI_5.mjs +0 -820
- package/dist/internal-B3QbyI_5.mjs.map +0 -1
- package/dist/internal-DIHQF9gs.cjs +0 -1070
- package/dist/internal-DIHQF9gs.cjs.map +0 -1
- package/dist/sha2-DKowBr6H.cjs.map +0 -1
- package/dist/stableStringify-DgDlE_pD.mjs.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//#region src/settings/settingsUrls.ts
|
|
2
|
+
const defaultCacheUrl = "https://cdn.gtx.dev";
|
|
3
|
+
const defaultBaseUrl = "https://api2.gtx.dev";
|
|
4
|
+
const defaultRuntimeApiUrl = "https://runtime2.gtx.dev";
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/utils/isSupportedFileFormatTransform.ts
|
|
7
|
+
const SUPPORTED_TRANSFORMATIONS = {
|
|
8
|
+
GTJSON: ["GTJSON"],
|
|
9
|
+
JSON: ["JSON"],
|
|
10
|
+
PO: ["PO"],
|
|
11
|
+
POT: ["POT", "PO"],
|
|
12
|
+
YAML: ["YAML"],
|
|
13
|
+
MDX: ["MDX"],
|
|
14
|
+
MD: ["MD"],
|
|
15
|
+
TS: ["TS"],
|
|
16
|
+
JS: ["JS"],
|
|
17
|
+
HTML: ["HTML"],
|
|
18
|
+
TXT: ["TXT"],
|
|
19
|
+
TWILIO_CONTENT_JSON: ["TWILIO_CONTENT_JSON"]
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* This function checks if a file format transformation is supported during translation
|
|
23
|
+
* @param from - The source file format
|
|
24
|
+
* @param to - The target file format
|
|
25
|
+
* @returns True if the transformation is supported, false otherwise
|
|
26
|
+
*/
|
|
27
|
+
function isSupportedFileFormatTransform(from, to) {
|
|
28
|
+
return SUPPORTED_TRANSFORMATIONS[from]?.includes(to) ?? false;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/translate/utils/validateFileFormatTransform.ts
|
|
32
|
+
/**
|
|
33
|
+
* Returns a user-facing validation error when a requested file format transform
|
|
34
|
+
* is missing source format context or is not currently supported.
|
|
35
|
+
*/
|
|
36
|
+
function getFileFormatTransformError(file) {
|
|
37
|
+
if (!file.transformFormat) return void 0;
|
|
38
|
+
const fileLabel = file.fileName ?? file.fileId ?? "unknown file";
|
|
39
|
+
if (!file.fileFormat) return `fileFormat is required when transformFormat is provided for ${fileLabel}`;
|
|
40
|
+
if (!isSupportedFileFormatTransform(file.fileFormat, file.transformFormat)) return `Unsupported file format transform: ${file.fileFormat} -> ${file.transformFormat}`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validates file format transforms before sending upload/enqueue requests.
|
|
44
|
+
*/
|
|
45
|
+
function validateFileFormatTransforms(files) {
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
const error = getFileFormatTransformError(file);
|
|
48
|
+
if (error) throw new Error(error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/utils/base64.ts
|
|
53
|
+
function encode(data) {
|
|
54
|
+
if (typeof Buffer !== "undefined") return Buffer.from(data, "utf8").toString("base64");
|
|
55
|
+
const bytes = new TextEncoder().encode(data);
|
|
56
|
+
let binary = "";
|
|
57
|
+
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
58
|
+
return btoa(binary);
|
|
59
|
+
}
|
|
60
|
+
function decode(base64) {
|
|
61
|
+
if (typeof Buffer !== "undefined") return Buffer.from(base64, "base64").toString("utf8");
|
|
62
|
+
const binary = atob(base64);
|
|
63
|
+
const bytes = new Uint8Array(binary.length);
|
|
64
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
65
|
+
return new TextDecoder().decode(bytes);
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
Object.defineProperty(exports, "decode", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function() {
|
|
71
|
+
return decode;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, "defaultBaseUrl", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function() {
|
|
77
|
+
return defaultBaseUrl;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "defaultCacheUrl", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function() {
|
|
83
|
+
return defaultCacheUrl;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(exports, "defaultRuntimeApiUrl", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function() {
|
|
89
|
+
return defaultRuntimeApiUrl;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(exports, "encode", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function() {
|
|
95
|
+
return encode;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(exports, "isSupportedFileFormatTransform", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function() {
|
|
101
|
+
return isSupportedFileFormatTransform;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, "validateFileFormatTransforms", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function() {
|
|
107
|
+
return validateFileFormatTransforms;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=base64-CUcEPEC5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64-CUcEPEC5.cjs","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,OA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