generaltranslation 8.2.12 → 8.2.14
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 +19 -0
- package/dist/{ApiError-IYfaOR30.mjs → ApiError-0DxxIHLp.mjs} +1 -1
- package/dist/{ApiError-CZ45tkW6.cjs.map → ApiError-0DxxIHLp.mjs.map} +1 -1
- package/dist/{ApiError-CZ45tkW6.cjs → ApiError-D-IBuHj6.cjs} +1 -1
- package/dist/{ApiError-IYfaOR30.mjs.map → ApiError-D-IBuHj6.cjs.map} +1 -1
- package/dist/LocaleConfig.d.ts +1 -0
- package/dist/LocaleConfig.js +1 -0
- package/dist/backwards-compatability/dataConversion.d.ts +23 -0
- package/dist/backwards-compatability/dataConversion.js +207 -0
- package/dist/backwards-compatability/oldHashJsxChildren.d.ts +23 -0
- package/dist/backwards-compatability/oldHashJsxChildren.js +79 -0
- package/dist/backwards-compatability/oldTypes.d.ts +21 -0
- package/dist/backwards-compatability/oldTypes.js +1 -0
- package/dist/backwards-compatability/typeChecking.d.ts +21 -0
- package/dist/backwards-compatability/typeChecking.js +61 -0
- package/dist/{base64-2fu94Klt.cjs → base64-C6BHySOc.cjs} +17 -1
- package/dist/base64-C6BHySOc.cjs.map +1 -0
- package/dist/{base64-DH0STixb.mjs → base64-CWITCfhU.mjs} +6 -2
- package/dist/base64-CWITCfhU.mjs.map +1 -0
- package/dist/core.cjs +9 -8
- package/dist/core.d.cts +1 -2
- package/dist/core.d.mts +1 -2
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1 -0
- package/dist/core.mjs +2 -2
- package/dist/derive/condenseVars.d.ts +7 -0
- package/dist/derive/condenseVars.js +30 -0
- package/dist/derive/declareVar.d.ts +26 -0
- package/dist/derive/declareVar.js +38 -0
- package/dist/derive/decodeVars.d.ts +9 -0
- package/dist/derive/decodeVars.js +52 -0
- package/dist/derive/derive.d.ts +53 -0
- package/dist/derive/derive.js +55 -0
- package/dist/derive/extractVars.d.ts +9 -0
- package/dist/derive/extractVars.js +34 -0
- package/dist/derive/index.d.ts +7 -0
- package/dist/derive/index.js +7 -0
- package/dist/derive/indexVars.d.ts +6 -0
- package/dist/derive/indexVars.js +52 -0
- package/dist/derive/utils/constants.d.ts +2 -0
- package/dist/derive/utils/constants.js +2 -0
- package/dist/derive/utils/regex.d.ts +2 -0
- package/dist/derive/utils/regex.js +4 -0
- package/dist/derive/utils/sanitizeVar.d.ts +12 -0
- package/dist/derive/utils/sanitizeVar.js +38 -0
- package/dist/derive/utils/traverseHelpers.d.ts +4 -0
- package/dist/derive/utils/traverseHelpers.js +22 -0
- package/dist/derive/utils/traverseIcu.d.ts +20 -0
- package/dist/derive/utils/traverseIcu.js +49 -0
- package/dist/derive/utils/types.d.ts +23 -0
- package/dist/derive/utils/types.js +1 -0
- package/dist/errors/ApiError.d.ts +7 -0
- package/dist/errors/ApiError.js +33 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +1 -0
- package/dist/errors.mjs +1 -1
- package/dist/id/hashSource.d.ts +25 -0
- package/dist/id/hashSource.js +98 -0
- package/dist/id/hashTemplate.d.ts +4 -0
- package/dist/id/hashTemplate.js +6 -0
- package/dist/id/types.d.ts +7 -0
- package/dist/id/types.js +1 -0
- package/dist/{id-CyiXsQrY.cjs → id-C2orn1MA.cjs} +2 -2
- package/dist/{id-CyiXsQrY.cjs.map → id-C2orn1MA.cjs.map} +1 -1
- package/dist/{id-DbD7K-HL.mjs → id-DEaFhGqX.mjs} +2 -2
- package/dist/{id-DbD7K-HL.mjs.map → id-DEaFhGqX.mjs.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.d.ts +3 -0
- package/dist/id.js +3 -0
- package/dist/id.mjs +1 -1
- package/dist/index.cjs +368 -385
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -242
- package/dist/index.d.mts +4 -242
- package/dist/index.d.ts +786 -0
- package/dist/index.js +1345 -0
- package/dist/index.mjs +215 -352
- package/dist/index.mjs.map +1 -1
- package/dist/internal.cjs +7 -7
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +7 -6
- package/dist/internal.d.mts +7 -6
- package/dist/internal.d.ts +19 -0
- package/dist/internal.js +17 -0
- package/dist/internal.mjs +5 -5
- package/dist/internal.mjs.map +1 -1
- package/dist/{isVariable-B08mggBy.cjs → isVariable-Ba1gLXdB.cjs} +1 -1
- package/dist/{isVariable-B08mggBy.cjs.map → isVariable-Ba1gLXdB.cjs.map} +1 -1
- package/dist/{isVariable-CYsKFHvR.mjs → isVariable-fAKEB7gF.mjs} +1 -1
- package/dist/{isVariable-CYsKFHvR.mjs.map → isVariable-fAKEB7gF.mjs.map} +1 -1
- package/dist/locales/getPluralForm.d.ts +9 -0
- package/dist/locales/getPluralForm.js +63 -0
- package/dist/logging/errors.d.ts +10 -0
- package/dist/logging/errors.js +29 -0
- package/dist/logging/logger.d.ts +118 -0
- package/dist/logging/logger.js +256 -0
- package/dist/projects/getProjectData.d.ts +1 -0
- package/dist/projects/getProjectData.js +87 -0
- package/dist/settings/plurals.d.ts +3 -0
- package/dist/settings/plurals.js +14 -0
- package/dist/settings/settings.d.ts +2 -0
- package/dist/settings/settings.js +2 -0
- package/dist/settings/settingsUrls.d.ts +3 -0
- package/dist/settings/settingsUrls.js +3 -0
- package/dist/translate/api.d.ts +1 -0
- package/dist/translate/api.js +1 -0
- package/dist/translate/awaitJobs.d.ts +19 -0
- package/dist/translate/awaitJobs.js +112 -0
- package/dist/translate/checkJobStatus.d.ts +8 -0
- package/dist/translate/checkJobStatus.js +55 -0
- package/dist/translate/createBranch.d.ts +10 -0
- package/dist/translate/createBranch.js +53 -0
- package/dist/translate/createTag.d.ts +19 -0
- package/dist/translate/createTag.js +67 -0
- package/dist/translate/downloadFileBatch.d.ts +1 -0
- package/dist/translate/downloadFileBatch.js +77 -0
- package/dist/translate/enqueueFiles.d.ts +8 -0
- package/dist/translate/enqueueFiles.js +96 -0
- package/dist/translate/getOrphanedFiles.d.ts +8 -0
- package/dist/translate/getOrphanedFiles.js +97 -0
- package/dist/translate/processFileMoves.d.ts +25 -0
- package/dist/translate/processFileMoves.js +90 -0
- package/dist/translate/publishFiles.d.ts +17 -0
- package/dist/translate/publishFiles.js +56 -0
- package/dist/translate/queryBranchData.d.ts +3 -0
- package/dist/translate/queryBranchData.js +53 -0
- package/dist/translate/queryFileData.d.ts +42 -0
- package/dist/translate/queryFileData.js +71 -0
- package/dist/translate/querySourceFile.d.ts +1 -0
- package/dist/translate/querySourceFile.js +67 -0
- package/dist/translate/setupProject.d.ts +11 -0
- package/dist/translate/setupProject.js +63 -0
- package/dist/translate/submitUserEditDiffs.d.ts +12 -0
- package/dist/translate/submitUserEditDiffs.js +68 -0
- package/dist/translate/translateMany.d.ts +1 -0
- package/dist/translate/translateMany.js +103 -0
- package/dist/translate/uploadSourceFiles.d.ts +1 -0
- package/dist/translate/uploadSourceFiles.js +87 -0
- package/dist/translate/uploadTranslations.d.ts +1 -0
- package/dist/translate/uploadTranslations.js +101 -0
- package/dist/translate/utils/apiRequest.d.ts +1 -0
- package/dist/translate/utils/apiRequest.js +130 -0
- package/dist/translate/utils/batch.d.ts +52 -0
- package/dist/translate/utils/batch.js +126 -0
- package/dist/translate/utils/fetchWithTimeout.d.ts +1 -0
- package/dist/translate/utils/fetchWithTimeout.js +93 -0
- package/dist/translate/utils/generateRequestHeaders.d.ts +2 -0
- package/dist/translate/utils/generateRequestHeaders.js +26 -0
- package/dist/translate/utils/handleFetchError.d.ts +1 -0
- package/dist/translate/utils/handleFetchError.js +12 -0
- package/dist/translate/utils/validateFileFormatTransform.d.ts +16 -0
- package/dist/translate/utils/validateFileFormatTransform.js +29 -0
- package/dist/translate/utils/validateResponse.d.ts +1 -0
- package/dist/translate/utils/validateResponse.js +72 -0
- package/dist/{types-V5rqd1WR.d.cts → types-73XFwmhH.d.mts} +39 -115
- package/dist/{types-BsGsgJWF.d.mts → types-YrrGRHBP.d.cts} +39 -115
- package/dist/types-dir/api/branch.d.ts +10 -0
- package/dist/types-dir/api/branch.js +1 -0
- package/dist/types-dir/api/checkFileTranslations.d.ts +37 -0
- package/dist/types-dir/api/checkFileTranslations.js +1 -0
- package/dist/types-dir/api/downloadFile.d.ts +3 -0
- package/dist/types-dir/api/downloadFile.js +1 -0
- package/dist/types-dir/api/downloadFileBatch.d.ts +35 -0
- package/dist/types-dir/api/downloadFileBatch.js +1 -0
- package/dist/types-dir/api/enqueueEntries.d.ts +21 -0
- package/dist/types-dir/api/enqueueEntries.js +1 -0
- package/dist/types-dir/api/enqueueFiles.d.ts +70 -0
- package/dist/types-dir/api/enqueueFiles.js +1 -0
- package/dist/types-dir/api/entry.d.ts +39 -0
- package/dist/types-dir/api/entry.js +1 -0
- package/dist/types-dir/api/fetchTranslations.d.ts +12 -0
- package/dist/types-dir/api/fetchTranslations.js +1 -0
- package/dist/types-dir/api/file.d.ts +57 -0
- package/dist/types-dir/api/file.js +1 -0
- package/dist/types-dir/api/json.d.ts +5 -0
- package/dist/types-dir/api/json.js +1 -0
- package/dist/types-dir/api/project.d.ts +7 -0
- package/dist/types-dir/api/project.js +1 -0
- package/dist/types-dir/api/translate.d.ts +34 -0
- package/dist/types-dir/api/translate.js +1 -0
- package/dist/types-dir/api/translateMany.d.ts +5 -0
- package/dist/types-dir/api/translateMany.js +1 -0
- package/dist/types-dir/api/translationStatus.d.ts +9 -0
- package/dist/types-dir/api/translationStatus.js +1 -0
- package/dist/types-dir/api/uploadFiles.d.ts +44 -0
- package/dist/types-dir/api/uploadFiles.js +1 -0
- package/dist/types-dir/transformations.d.ts +8 -0
- package/dist/types-dir/transformations.js +1 -0
- package/dist/types.cjs +7 -16
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +127 -0
- package/dist/types.js +1 -0
- package/dist/types.mjs +1 -15
- package/dist/utils/base64.d.ts +2 -0
- package/dist/utils/base64.js +28 -0
- package/dist/utils/isSupportedFileFormatTransform.d.ts +8 -0
- package/dist/utils/isSupportedFileFormatTransform.js +26 -0
- package/dist/utils/isVariable.d.ts +2 -0
- package/dist/utils/isVariable.js +22 -0
- package/dist/utils/minify.d.ts +2 -0
- package/dist/utils/minify.js +10 -0
- package/dist/utils/stableStringify.d.ts +1 -0
- package/dist/utils/stableStringify.js +40 -0
- package/package.json +5 -4
- package/dist/IntlCache-CAW8tKhd.cjs +0 -212
- package/dist/IntlCache-CAW8tKhd.cjs.map +0 -1
- package/dist/IntlCache-WZk0rKvj.mjs +0 -195
- package/dist/IntlCache-WZk0rKvj.mjs.map +0 -1
- package/dist/base64-2fu94Klt.cjs.map +0 -1
- package/dist/base64-DH0STixb.mjs.map +0 -1
- package/dist/core-7RJsqw6c.mjs +0 -1498
- package/dist/core-7RJsqw6c.mjs.map +0 -1
- package/dist/core-CGhlXrrK.d.mts +0 -209
- package/dist/core-CST4J4WU.cjs +0 -1677
- package/dist/core-CST4J4WU.cjs.map +0 -1
- package/dist/core-D-E8qhLn.d.cts +0 -209
- package/dist/types.cjs.map +0 -1
- package/dist/types.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# generaltranslation
|
|
2
2
|
|
|
3
|
+
## 8.2.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1397](https://github.com/generaltranslation/gt/pull/1397) [`73f3ac1`](https://github.com/generaltranslation/gt/commit/73f3ac1308df11c1e6230c13c1999bfc5f6afc99) Thanks [@bgub](https://github.com/bgub)! - Extract locale and formatting primitives into the new `@generaltranslation/format` package and update `generaltranslation/core` to re-export the shared helpers.
|
|
8
|
+
|
|
9
|
+
- [#1408](https://github.com/generaltranslation/gt/pull/1408) [`425d3e4`](https://github.com/generaltranslation/gt/commit/425d3e4e6c61afd108c65c27f7693ba2470b33c6) Thanks [@bgub](https://github.com/bgub)! - Use @generaltranslation/format directly for shared formatting and locale helpers.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`73f3ac1`](https://github.com/generaltranslation/gt/commit/73f3ac1308df11c1e6230c13c1999bfc5f6afc99)]:
|
|
12
|
+
- @generaltranslation/format@0.1.0
|
|
13
|
+
|
|
14
|
+
## 8.2.13
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#1379](https://github.com/generaltranslation/gt/pull/1379) [`e88fd39`](https://github.com/generaltranslation/gt/commit/e88fd399683868d5af1fe2b0ba2974fe5b17d7a7) Thanks [@bgub](https://github.com/bgub)! - Tighten public and API metadata types, and handle metadata entries without hashes in the CLI.
|
|
19
|
+
|
|
20
|
+
- [#1387](https://github.com/generaltranslation/gt/pull/1387) [`95f852a`](https://github.com/generaltranslation/gt/commit/95f852ae086ac79d2c446f4d3072d8fd18688796) Thanks [@bgub](https://github.com/bgub)! - Reduce explicit any usage in core and Next.js types.
|
|
21
|
+
|
|
3
22
|
## 8.2.12
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiError-
|
|
1
|
+
{"version":3,"file":"ApiError-0DxxIHLp.mjs","names":[],"sources":["../src/errors/ApiError.ts"],"sourcesContent":["export class ApiError extends Error {\n public code: number;\n public message: string;\n\n constructor(error: string, code: number, message: string) {\n super(error);\n this.name = 'ApiError';\n this.code = code;\n this.message = message;\n }\n\n getCode() {\n return this.code;\n }\n\n getMessage() {\n return this.message;\n }\n}\n"],"mappings":";AAAA,IAAa,WAAb,cAA8B,MAAM;CAIlC,YAAY,OAAe,MAAc,SAAiB;AACxD,QAAM,MAAM;AACZ,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,UAAU;;CAGjB,UAAU;AACR,SAAO,KAAK;;CAGd,aAAa;AACX,SAAO,KAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiError-
|
|
1
|
+
{"version":3,"file":"ApiError-D-IBuHj6.cjs","names":[],"sources":["../src/errors/ApiError.ts"],"sourcesContent":["export class ApiError extends Error {\n public code: number;\n public message: string;\n\n constructor(error: string, code: number, message: string) {\n super(error);\n this.name = 'ApiError';\n this.code = code;\n this.message = message;\n }\n\n getCode() {\n return this.code;\n }\n\n getMessage() {\n return this.message;\n }\n}\n"],"mappings":";AAAA,IAAa,WAAb,cAA8B,MAAM;CAIlC,YAAY,OAAe,MAAc,SAAiB;AACxD,QAAM,MAAM;AACZ,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,UAAU;;CAGjB,UAAU;AACR,SAAO,KAAK;;CAGd,aAAa;AACX,SAAO,KAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LocaleConfig, type LocaleConfigConstructorParams, } from '@generaltranslation/format';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LocaleConfig, } from '@generaltranslation/format';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Variable as VariableObject, VariableType } from '../types';
|
|
2
|
+
import { OldBranchType, OldGTProp, OldJsxChild, OldJsxChildren, OldJsxElement, OldVariableObject, OldVariableType } from './oldTypes.js';
|
|
3
|
+
import { GTProp, JsxChild, JsxChildren, JsxElement } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Convert request data from old format to new format
|
|
6
|
+
*/
|
|
7
|
+
export declare function getNewJsxChild(child: OldJsxChild): JsxChild;
|
|
8
|
+
export declare function getNewJsxChildren(children: OldJsxChildren): JsxChildren;
|
|
9
|
+
export declare function getNewJsxElement(element: OldJsxElement): JsxElement;
|
|
10
|
+
export declare function getNewBranchType(branch: OldBranchType): 'b' | 'p';
|
|
11
|
+
export declare function getNewVariableType(variable: OldVariableType): VariableType;
|
|
12
|
+
export declare function getNewVariableObject(variable: OldVariableObject): VariableObject;
|
|
13
|
+
export declare function getNewGTProp(dataGT: OldGTProp): GTProp;
|
|
14
|
+
/**
|
|
15
|
+
* Convert response data from current format to old format
|
|
16
|
+
*/
|
|
17
|
+
export declare function getOldJsxChild(child: JsxChild): OldJsxChild;
|
|
18
|
+
export declare function getOldJsxChildren(children: JsxChildren | OldJsxChildren): OldJsxChildren;
|
|
19
|
+
export declare function getOldJsxElement(element: JsxElement): OldJsxElement;
|
|
20
|
+
export declare function getOldBranchType(branch: 'b' | 'p'): OldBranchType;
|
|
21
|
+
export declare function getOldVariableType(variable: VariableType): OldVariableType;
|
|
22
|
+
export declare function getOldVariableObject(variable: VariableObject): OldVariableObject;
|
|
23
|
+
export declare function getOldGTProp(dataGT: GTProp, i: number): OldGTProp;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { isOldJsxChildren, isNewVariableObject, isOldVariableObject, } from './typeChecking';
|
|
13
|
+
/**
|
|
14
|
+
* Convert request data from old format to new format
|
|
15
|
+
*/
|
|
16
|
+
export function getNewJsxChild(child) {
|
|
17
|
+
// string (end case)
|
|
18
|
+
if (typeof child === 'string') {
|
|
19
|
+
return child;
|
|
20
|
+
}
|
|
21
|
+
// VariableObject
|
|
22
|
+
if (isOldVariableObject(child)) {
|
|
23
|
+
return getNewVariableObject(child);
|
|
24
|
+
}
|
|
25
|
+
// JsxElement
|
|
26
|
+
return getNewJsxElement(child);
|
|
27
|
+
}
|
|
28
|
+
export function getNewJsxChildren(children) {
|
|
29
|
+
// string (end case)
|
|
30
|
+
if (typeof children === 'string') {
|
|
31
|
+
return children;
|
|
32
|
+
}
|
|
33
|
+
// Array
|
|
34
|
+
if (Array.isArray(children)) {
|
|
35
|
+
return children.map(getNewJsxChild);
|
|
36
|
+
}
|
|
37
|
+
// Object
|
|
38
|
+
return getNewJsxChild(children);
|
|
39
|
+
}
|
|
40
|
+
export function getNewJsxElement(element) {
|
|
41
|
+
var _a;
|
|
42
|
+
// string (end case)
|
|
43
|
+
if (typeof element === 'string') {
|
|
44
|
+
return element;
|
|
45
|
+
}
|
|
46
|
+
// type
|
|
47
|
+
var t = undefined;
|
|
48
|
+
if (element.type != null) {
|
|
49
|
+
t = element.type;
|
|
50
|
+
}
|
|
51
|
+
// children
|
|
52
|
+
var c = undefined;
|
|
53
|
+
if (((_a = element.props) === null || _a === void 0 ? void 0 : _a.children) != null) {
|
|
54
|
+
c = getNewJsxChildren(element.props.children);
|
|
55
|
+
}
|
|
56
|
+
return __assign(__assign(__assign({}, (t && { t: t })), (c && { c: c })), { d: getNewGTProp(element.props['data-_gt']), i: element.props['data-_gt'].id });
|
|
57
|
+
}
|
|
58
|
+
export function getNewBranchType(branch) {
|
|
59
|
+
if (branch === 'branch') {
|
|
60
|
+
return 'b';
|
|
61
|
+
}
|
|
62
|
+
return 'p';
|
|
63
|
+
}
|
|
64
|
+
export function getNewVariableType(variable) {
|
|
65
|
+
switch (variable) {
|
|
66
|
+
case 'number':
|
|
67
|
+
return 'n';
|
|
68
|
+
case 'variable':
|
|
69
|
+
return 'v';
|
|
70
|
+
case 'datetime':
|
|
71
|
+
return 'd';
|
|
72
|
+
case 'currency':
|
|
73
|
+
return 'c';
|
|
74
|
+
default:
|
|
75
|
+
return 'v';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function getNewVariableObject(variable) {
|
|
79
|
+
// variable type
|
|
80
|
+
var v = undefined;
|
|
81
|
+
if (variable.variable != null) {
|
|
82
|
+
v = getNewVariableType(variable.variable);
|
|
83
|
+
}
|
|
84
|
+
// variable id
|
|
85
|
+
var i = undefined;
|
|
86
|
+
if (variable.id != null) {
|
|
87
|
+
i = variable.id;
|
|
88
|
+
}
|
|
89
|
+
return __assign(__assign({ k: variable.key }, (v && { v: v })), (i && { i: i }));
|
|
90
|
+
}
|
|
91
|
+
export function getNewGTProp(dataGT) {
|
|
92
|
+
// branches
|
|
93
|
+
var b = undefined;
|
|
94
|
+
if (dataGT.branches) {
|
|
95
|
+
b = Object.fromEntries(Object.entries(dataGT.branches).map(function (_a) {
|
|
96
|
+
var key = _a[0], value = _a[1];
|
|
97
|
+
return [
|
|
98
|
+
key,
|
|
99
|
+
getNewJsxChildren(value),
|
|
100
|
+
];
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
// transformation
|
|
104
|
+
var t;
|
|
105
|
+
if (dataGT.transformation) {
|
|
106
|
+
t = getNewBranchType(dataGT.transformation);
|
|
107
|
+
}
|
|
108
|
+
return __assign(__assign({}, (b && { b: b })), (t && { t: t }));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Convert response data from current format to old format
|
|
112
|
+
*/
|
|
113
|
+
export function getOldJsxChild(child) {
|
|
114
|
+
// string (end case)
|
|
115
|
+
if (typeof child === 'string') {
|
|
116
|
+
return child;
|
|
117
|
+
}
|
|
118
|
+
// VariableObject
|
|
119
|
+
if (isNewVariableObject(child)) {
|
|
120
|
+
return getOldVariableObject(child);
|
|
121
|
+
}
|
|
122
|
+
// JsxElement
|
|
123
|
+
return getOldJsxElement(child);
|
|
124
|
+
}
|
|
125
|
+
export function getOldJsxChildren(children) {
|
|
126
|
+
// if children is already old, return it
|
|
127
|
+
if (isOldJsxChildren(children)) {
|
|
128
|
+
return children;
|
|
129
|
+
}
|
|
130
|
+
// string (end case)
|
|
131
|
+
if (typeof children === 'string') {
|
|
132
|
+
return children;
|
|
133
|
+
}
|
|
134
|
+
// Array
|
|
135
|
+
if (Array.isArray(children)) {
|
|
136
|
+
return children.map(getOldJsxChild);
|
|
137
|
+
}
|
|
138
|
+
// Object
|
|
139
|
+
return getOldJsxChild(children);
|
|
140
|
+
}
|
|
141
|
+
export function getOldJsxElement(element) {
|
|
142
|
+
// type (can assume that type will exist here)
|
|
143
|
+
var type = element.t;
|
|
144
|
+
// children
|
|
145
|
+
var children = undefined;
|
|
146
|
+
if (element.c != null) {
|
|
147
|
+
children = getOldJsxChildren(element.c);
|
|
148
|
+
}
|
|
149
|
+
// data-_gt (can assume id will exist here)
|
|
150
|
+
var dataGT = getOldGTProp(element.d || {}, element.i);
|
|
151
|
+
return {
|
|
152
|
+
type: type,
|
|
153
|
+
props: { children: children, 'data-_gt': dataGT },
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export function getOldBranchType(branch) {
|
|
157
|
+
if (branch === 'b') {
|
|
158
|
+
return 'branch';
|
|
159
|
+
}
|
|
160
|
+
return 'plural';
|
|
161
|
+
}
|
|
162
|
+
export function getOldVariableType(variable) {
|
|
163
|
+
switch (variable) {
|
|
164
|
+
case 'n':
|
|
165
|
+
return 'number';
|
|
166
|
+
case 'v':
|
|
167
|
+
return 'variable';
|
|
168
|
+
case 'd':
|
|
169
|
+
return 'datetime';
|
|
170
|
+
case 'c':
|
|
171
|
+
return 'currency';
|
|
172
|
+
default:
|
|
173
|
+
return 'variable';
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
export function getOldVariableObject(variable) {
|
|
177
|
+
// variable type
|
|
178
|
+
var v = undefined;
|
|
179
|
+
if (variable.v != null) {
|
|
180
|
+
v = getOldVariableType(variable.v);
|
|
181
|
+
}
|
|
182
|
+
// variable id
|
|
183
|
+
var i = undefined;
|
|
184
|
+
if (variable.i != null) {
|
|
185
|
+
i = variable.i;
|
|
186
|
+
}
|
|
187
|
+
return __assign(__assign({ key: variable.k }, (v && { variable: v })), (i && { id: i }));
|
|
188
|
+
}
|
|
189
|
+
export function getOldGTProp(dataGT, i) {
|
|
190
|
+
// transformation
|
|
191
|
+
var transformation = undefined;
|
|
192
|
+
if (dataGT.t != null) {
|
|
193
|
+
transformation = getOldBranchType(dataGT.t);
|
|
194
|
+
}
|
|
195
|
+
// branches
|
|
196
|
+
var branches = undefined;
|
|
197
|
+
if (dataGT.b != null) {
|
|
198
|
+
branches = Object.fromEntries(Object.entries(dataGT.b).map(function (_a) {
|
|
199
|
+
var key = _a[0], value = _a[1];
|
|
200
|
+
return [
|
|
201
|
+
key,
|
|
202
|
+
getOldJsxChildren(value),
|
|
203
|
+
];
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
return __assign(__assign({ id: i }, (transformation && { transformation: transformation })), (branches && { branches: branches }));
|
|
207
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OldJsxChildren } from './oldTypes';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates a unique hash for a given string using SHA-256.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} string - The string to be hashed.
|
|
6
|
+
* @returns {string} The resulting hash as a hexadecimal string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function oldHashString(string: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Calculates a unique ID for the given children objects by hashing their sanitized JSON string representation.
|
|
11
|
+
*
|
|
12
|
+
* @param {any} childrenAsObjects - The children objects to be hashed.
|
|
13
|
+
* @param {string} context - The context for the children.
|
|
14
|
+
* @param {string} id - The ID for the JSX children object.
|
|
15
|
+
* @param {function} hashFunction - Custom hash function.
|
|
16
|
+
* @returns {string} - The unique hash of the children.
|
|
17
|
+
*/
|
|
18
|
+
export declare function oldHashJsxChildren({ source, context, id, dataFormat, }: {
|
|
19
|
+
source: OldJsxChildren;
|
|
20
|
+
context?: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
dataFormat: string;
|
|
23
|
+
}, hashFunction?: (string: string) => string): string;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Functions provided to other GT libraries
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import { stableStringify as stringify } from '../utils/stableStringify';
|
|
14
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
15
|
+
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils.js';
|
|
16
|
+
// ----- FUNCTIONS ----- //
|
|
17
|
+
/**
|
|
18
|
+
* Calculates a unique hash for a given string using SHA-256.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} string - The string to be hashed.
|
|
21
|
+
* @returns {string} The resulting hash as a hexadecimal string.
|
|
22
|
+
*/
|
|
23
|
+
export function oldHashString(string) {
|
|
24
|
+
return bytesToHex(sha256(utf8ToBytes(string)));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Calculates a unique ID for the given children objects by hashing their sanitized JSON string representation.
|
|
28
|
+
*
|
|
29
|
+
* @param {any} childrenAsObjects - The children objects to be hashed.
|
|
30
|
+
* @param {string} context - The context for the children.
|
|
31
|
+
* @param {string} id - The ID for the JSX children object.
|
|
32
|
+
* @param {function} hashFunction - Custom hash function.
|
|
33
|
+
* @returns {string} - The unique hash of the children.
|
|
34
|
+
*/
|
|
35
|
+
export function oldHashJsxChildren(_a, hashFunction) {
|
|
36
|
+
var source = _a.source, context = _a.context, id = _a.id, dataFormat = _a.dataFormat;
|
|
37
|
+
if (hashFunction === void 0) { hashFunction = oldHashString; }
|
|
38
|
+
var unhashedKey = stringify(__assign(__assign(__assign({ source: sanitizeJsxChildren(source) }, (id && { id: id })), (context && { context: context })), (dataFormat && { dataFormat: dataFormat })));
|
|
39
|
+
return hashFunction(unhashedKey);
|
|
40
|
+
}
|
|
41
|
+
var sanitizeChild = function (child) {
|
|
42
|
+
var _a, _b, _c, _d;
|
|
43
|
+
if (child && typeof child === 'object') {
|
|
44
|
+
if ('props' in child) {
|
|
45
|
+
var newChild = {};
|
|
46
|
+
var dataGt = (_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a['data-_gt'];
|
|
47
|
+
if (dataGt === null || dataGt === void 0 ? void 0 : dataGt.branches) {
|
|
48
|
+
// The only thing that prevents sanitizeJsx from being stable is
|
|
49
|
+
// the order of the keys in the branches object.
|
|
50
|
+
// We don't sort them because stable-stringify sorts them anyways
|
|
51
|
+
newChild.branches = Object.fromEntries(Object.entries(dataGt.branches).map(function (_a) {
|
|
52
|
+
var key = _a[0], value = _a[1];
|
|
53
|
+
return [
|
|
54
|
+
key,
|
|
55
|
+
sanitizeJsxChildren(value),
|
|
56
|
+
];
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
if ((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.children) {
|
|
60
|
+
newChild.children = sanitizeJsxChildren(child.props.children);
|
|
61
|
+
}
|
|
62
|
+
if ((_d = (_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c['data-_gt']) === null || _d === void 0 ? void 0 : _d.transformation) {
|
|
63
|
+
newChild.transformation = child.props['data-_gt'].transformation;
|
|
64
|
+
}
|
|
65
|
+
return newChild;
|
|
66
|
+
}
|
|
67
|
+
if ('key' in child) {
|
|
68
|
+
return __assign({ key: child.key }, (child.variable && {
|
|
69
|
+
variable: child.variable,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return child;
|
|
74
|
+
};
|
|
75
|
+
function sanitizeJsxChildren(childrenAsObjects) {
|
|
76
|
+
return Array.isArray(childrenAsObjects)
|
|
77
|
+
? childrenAsObjects.map(sanitizeChild)
|
|
78
|
+
: sanitizeChild(childrenAsObjects);
|
|
79
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type OldBranchType = 'branch' | 'plural';
|
|
2
|
+
export type OldGTProp = {
|
|
3
|
+
id: number;
|
|
4
|
+
transformation?: OldBranchType;
|
|
5
|
+
branches?: Record<string, OldJsxChildren>;
|
|
6
|
+
};
|
|
7
|
+
export type OldJsxElement = {
|
|
8
|
+
type: string;
|
|
9
|
+
props: {
|
|
10
|
+
children?: OldJsxChildren;
|
|
11
|
+
'data-_gt': OldGTProp;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type OldVariableType = 'number' | 'variable' | 'datetime' | 'currency';
|
|
15
|
+
export type OldVariableObject = {
|
|
16
|
+
variable?: OldVariableType;
|
|
17
|
+
key: string;
|
|
18
|
+
id?: number;
|
|
19
|
+
};
|
|
20
|
+
export type OldJsxChild = OldJsxElement | OldVariableObject | string;
|
|
21
|
+
export type OldJsxChildren = OldJsxChild | OldJsxChild[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { JsxChild, JsxChildren } from '../types';
|
|
2
|
+
import { OldJsxChild, OldJsxChildren, OldVariableObject } from './oldTypes.js';
|
|
3
|
+
import { Variable as VariableObject } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a JSX child is an old variable object format
|
|
6
|
+
* @param child - The JSX child to check.
|
|
7
|
+
* @returns True if the child is an old variable object (has 'key' property)
|
|
8
|
+
*/
|
|
9
|
+
export declare function isOldVariableObject(child: OldJsxChild | JsxChild): child is OldVariableObject;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a JSX child is a new variable object format
|
|
12
|
+
* @param child - The JSX child to check.
|
|
13
|
+
* @returns True if the child is a new variable object (has 'k' property)
|
|
14
|
+
*/
|
|
15
|
+
export declare function isNewVariableObject(child: OldJsxChild | JsxChild): child is VariableObject;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if JSX children follow the old format
|
|
18
|
+
* @param children - The JSX children to check (can be string, array, or single child)
|
|
19
|
+
* @returns True if all children are in the old format.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isOldJsxChildren(children: OldJsxChildren | JsxChildren): children is OldJsxChildren;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a JSX child is an old variable object format
|
|
3
|
+
* @param child - The JSX child to check.
|
|
4
|
+
* @returns True if the child is an old variable object (has 'key' property)
|
|
5
|
+
*/
|
|
6
|
+
export function isOldVariableObject(child) {
|
|
7
|
+
return typeof child === 'object' && child != null && 'key' in child;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a JSX child is a new variable object format
|
|
11
|
+
* @param child - The JSX child to check.
|
|
12
|
+
* @returns True if the child is a new variable object (has 'k' property)
|
|
13
|
+
*/
|
|
14
|
+
export function isNewVariableObject(child) {
|
|
15
|
+
return typeof child === 'object' && child != null && 'k' in child;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a JSX child is an old JSX element format
|
|
19
|
+
* @param child - The JSX child to check.
|
|
20
|
+
* @returns True if the child is an old JSX element (has 'type' and 'props' properties)
|
|
21
|
+
*/
|
|
22
|
+
function isOldJsxElement(child) {
|
|
23
|
+
return (typeof child === 'object' &&
|
|
24
|
+
child != null &&
|
|
25
|
+
'type' in child &&
|
|
26
|
+
'props' in child);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Checks if a JSX child follows the old format (string, old variable object, or old JSX element)
|
|
30
|
+
* @param child - The JSX child to check.
|
|
31
|
+
* @returns True if the child is in the old format.
|
|
32
|
+
*/
|
|
33
|
+
function isOldJsxChild(child) {
|
|
34
|
+
// string
|
|
35
|
+
if (typeof child === 'string') {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
// variable object
|
|
39
|
+
if (isOldVariableObject(child)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
// element
|
|
43
|
+
return isOldJsxElement(child);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Checks if JSX children follow the old format
|
|
47
|
+
* @param children - The JSX children to check (can be string, array, or single child)
|
|
48
|
+
* @returns True if all children are in the old format.
|
|
49
|
+
*/
|
|
50
|
+
export function isOldJsxChildren(children) {
|
|
51
|
+
// string
|
|
52
|
+
if (typeof children === 'string') {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
// array
|
|
56
|
+
if (Array.isArray(children)) {
|
|
57
|
+
return !children.some(function (child) { return !isOldJsxChild(child); });
|
|
58
|
+
}
|
|
59
|
+
// object
|
|
60
|
+
return isOldJsxChild(children);
|
|
61
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
//#region src/settings/settings.ts
|
|
2
|
+
const libraryDefaultLocale = "en";
|
|
3
|
+
const defaultTimeout = 6e4;
|
|
4
|
+
//#endregion
|
|
1
5
|
//#region src/settings/settingsUrls.ts
|
|
2
6
|
const defaultCacheUrl = "https://cdn.gtx.dev";
|
|
3
7
|
const defaultBaseUrl = "https://api2.gtx.dev";
|
|
@@ -89,6 +93,12 @@ Object.defineProperty(exports, "defaultRuntimeApiUrl", {
|
|
|
89
93
|
return defaultRuntimeApiUrl;
|
|
90
94
|
}
|
|
91
95
|
});
|
|
96
|
+
Object.defineProperty(exports, "defaultTimeout", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function() {
|
|
99
|
+
return defaultTimeout;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
92
102
|
Object.defineProperty(exports, "encode", {
|
|
93
103
|
enumerable: true,
|
|
94
104
|
get: function() {
|
|
@@ -101,6 +111,12 @@ Object.defineProperty(exports, "isSupportedFileFormatTransform", {
|
|
|
101
111
|
return isSupportedFileFormatTransform;
|
|
102
112
|
}
|
|
103
113
|
});
|
|
114
|
+
Object.defineProperty(exports, "libraryDefaultLocale", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function() {
|
|
117
|
+
return libraryDefaultLocale;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
104
120
|
Object.defineProperty(exports, "validateFileFormatTransforms", {
|
|
105
121
|
enumerable: true,
|
|
106
122
|
get: function() {
|
|
@@ -108,4 +124,4 @@ Object.defineProperty(exports, "validateFileFormatTransforms", {
|
|
|
108
124
|
}
|
|
109
125
|
});
|
|
110
126
|
|
|
111
|
-
//# sourceMappingURL=base64-
|
|
127
|
+
//# sourceMappingURL=base64-C6BHySOc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64-C6BHySOc.cjs","names":[],"sources":["../src/settings/settings.ts","../src/settings/settingsUrls.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/utils/base64.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\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","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,uBAAuB;AACpC,MAAa,iBAAiB;;;ACD9B,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"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
//#region src/settings/settings.ts
|
|
2
|
+
const libraryDefaultLocale = "en";
|
|
3
|
+
const defaultTimeout = 6e4;
|
|
4
|
+
//#endregion
|
|
1
5
|
//#region src/settings/settingsUrls.ts
|
|
2
6
|
const defaultCacheUrl = "https://cdn.gtx.dev";
|
|
3
7
|
const defaultBaseUrl = "https://api2.gtx.dev";
|
|
@@ -65,6 +69,6 @@ function decode(base64) {
|
|
|
65
69
|
return new TextDecoder().decode(bytes);
|
|
66
70
|
}
|
|
67
71
|
//#endregion
|
|
68
|
-
export { defaultBaseUrl as a, isSupportedFileFormatTransform as i, encode as n, defaultCacheUrl as o, validateFileFormatTransforms as r, defaultRuntimeApiUrl as s, decode as t };
|
|
72
|
+
export { defaultBaseUrl as a, defaultTimeout as c, isSupportedFileFormatTransform as i, libraryDefaultLocale as l, encode as n, defaultCacheUrl as o, validateFileFormatTransforms as r, defaultRuntimeApiUrl as s, decode as t };
|
|
69
73
|
|
|
70
|
-
//# sourceMappingURL=base64-
|
|
74
|
+
//# sourceMappingURL=base64-CWITCfhU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64-CWITCfhU.mjs","names":[],"sources":["../src/settings/settings.ts","../src/settings/settingsUrls.ts","../src/utils/isSupportedFileFormatTransform.ts","../src/translate/utils/validateFileFormatTransform.ts","../src/utils/base64.ts"],"sourcesContent":["export const libraryDefaultLocale = 'en' as const;\nexport const defaultTimeout = 60000;\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","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,uBAAuB;AACpC,MAAa,iBAAiB;;;ACD9B,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"}
|
package/dist/core.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var _generaltranslation_format = require("@generaltranslation/format");
|
|
2
|
+
Object.keys(_generaltranslation_format).forEach(function(k) {
|
|
3
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return _generaltranslation_format[k];
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
});
|
package/dist/core.d.cts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { LocaleConfig, LocaleConfigConstructorParams, formatCutoff, formatMessage, isValidLocale, resolveCanonicalLocale, standardizeLocale };
|
|
1
|
+
export * from "@generaltranslation/format";
|
package/dist/core.d.mts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { LocaleConfig, LocaleConfigConstructorParams, formatCutoff, formatMessage, isValidLocale, resolveCanonicalLocale, standardizeLocale };
|
|
1
|
+
export * from "@generaltranslation/format";
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@generaltranslation/format';
|
package/dist/core.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@generaltranslation/format';
|
package/dist/core.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
export * from "@generaltranslation/format";
|
|
2
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given an indexed ICU string, condenses any select to an argument
|
|
3
|
+
* indexVars('Hello {_gt_1, select, other {World}}') => 'Hello {_gt_1}'
|
|
4
|
+
* @param {string} icuString - The ICU string to condense.
|
|
5
|
+
* @returns {string} The condensed ICU string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function condenseVars(icuString: string): string;
|