@generaltranslation/compiler 1.3.24 → 1.3.25-odysseus.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 (53) hide show
  1. package/dist/config.d.ts +5 -4
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js.map +1 -1
  4. package/dist/processing/collection/processTaggedTemplateExpression.d.ts +1 -1
  5. package/dist/processing/collection/processTaggedTemplateExpression.js +1 -1
  6. package/dist/processing/collection/processTaggedTemplateExpression.js.map +1 -1
  7. package/dist/processing/jsx-insertion/processCallExpression.js.map +1 -1
  8. package/dist/processing/jsx-insertion/processProgram.d.ts.map +1 -1
  9. package/dist/processing/jsx-insertion/processProgram.js +1 -1
  10. package/dist/processing/jsx-insertion/processProgram.js.map +1 -1
  11. package/dist/processing/macro-expansion/processProgram.js +1 -1
  12. package/dist/processing/macro-expansion/processProgram.js.map +1 -1
  13. package/dist/processing/macro-expansion/processTaggedTemplateExpression.d.ts +1 -1
  14. package/dist/processing/macro-expansion/processTaggedTemplateExpression.js +1 -1
  15. package/dist/processing/macro-expansion/processTaggedTemplateExpression.js.map +1 -1
  16. package/dist/processing/runtime-translate/processProgram.d.ts.map +1 -1
  17. package/dist/processing/runtime-translate/processProgram.js +2 -1
  18. package/dist/processing/runtime-translate/processProgram.js.map +1 -1
  19. package/dist/state/utils/initializeState.d.ts.map +1 -1
  20. package/dist/state/utils/initializeState.js +6 -3
  21. package/dist/state/utils/initializeState.js.map +1 -1
  22. package/dist/transform/jsx-children/constructJsxChildren.js.map +1 -1
  23. package/dist/transform/jsx-insertion/injectJsxInsertionImport.d.ts +2 -2
  24. package/dist/transform/jsx-insertion/injectJsxInsertionImport.d.ts.map +1 -1
  25. package/dist/transform/jsx-insertion/injectJsxInsertionImport.js +4 -3
  26. package/dist/transform/jsx-insertion/injectJsxInsertionImport.js.map +1 -1
  27. package/dist/transform/macro-expansion/injectMacroImport.d.ts +2 -2
  28. package/dist/transform/macro-expansion/injectMacroImport.d.ts.map +1 -1
  29. package/dist/transform/macro-expansion/injectMacroImport.js +4 -3
  30. package/dist/transform/macro-expansion/injectMacroImport.js.map +1 -1
  31. package/dist/transform/runtime-translate/injectRuntimeTranslateImport.d.ts +3 -2
  32. package/dist/transform/runtime-translate/injectRuntimeTranslateImport.d.ts.map +1 -1
  33. package/dist/transform/runtime-translate/injectRuntimeTranslateImport.js +4 -3
  34. package/dist/transform/runtime-translate/injectRuntimeTranslateImport.js.map +1 -1
  35. package/dist/transform/validation/validateTranslationFunction.d.ts.map +1 -1
  36. package/dist/transform/validation/validateTranslationFunction.js +3 -3
  37. package/dist/transform/validation/validateTranslationFunction.js.map +1 -1
  38. package/dist/utils/constants/gt/constants.d.ts +1 -5
  39. package/dist/utils/constants/gt/constants.d.ts.map +1 -1
  40. package/dist/utils/constants/gt/constants.js +1 -5
  41. package/dist/utils/constants/gt/constants.js.map +1 -1
  42. package/dist/utils/constants/gt/helpers.d.ts +2 -1
  43. package/dist/utils/constants/gt/helpers.d.ts.map +1 -1
  44. package/dist/utils/constants/gt/helpers.js +15 -5
  45. package/dist/utils/constants/gt/helpers.js.map +1 -1
  46. package/dist/utils/constants/resolveIdentifier/isGTComponent.d.ts +1 -1
  47. package/dist/utils/constants/resolveIdentifier/isGTComponent.d.ts.map +1 -1
  48. package/dist/utils/constants/resolveIdentifier/isGTComponent.js +2 -3
  49. package/dist/utils/constants/resolveIdentifier/isGTComponent.js.map +1 -1
  50. package/dist/utils/parsing/isStringTranslationTaggedTemplate.d.ts +1 -1
  51. package/dist/utils/parsing/isStringTranslationTaggedTemplate.js +3 -3
  52. package/dist/utils/parsing/isStringTranslationTaggedTemplate.js.map +1 -1
  53. package/package.json +3 -3
@@ -1,17 +1,18 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_runtime = require("../../_virtual/_rolldown/runtime.js");
3
3
  require("../../utils/constants/gt/constants.js");
4
+ const require_utils_constants_gt_helpers = require("../../utils/constants/gt/helpers.js");
4
5
  let _babel_types = require("@babel/types");
5
6
  _babel_types = require_runtime.__toESM(_babel_types);
6
7
  //#region src/transform/jsx-insertion/injectJsxInsertionImport.ts
7
8
  /**
8
- * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react/browser'`
9
+ * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react'`
9
10
  * as the first statement in the program.
10
11
  */
11
- function injectJsxInsertionImport(path) {
12
+ function injectJsxInsertionImport(path, legacyGtReactImportSource) {
12
13
  const tName = "GtInternalTranslateJsx";
13
14
  const varName = "GtInternalVar";
14
- const importDecl = _babel_types.importDeclaration([_babel_types.importSpecifier(_babel_types.identifier(tName), _babel_types.identifier(tName)), _babel_types.importSpecifier(_babel_types.identifier(varName), _babel_types.identifier(varName))], _babel_types.stringLiteral("gt-react/browser"));
15
+ const importDecl = _babel_types.importDeclaration([_babel_types.importSpecifier(_babel_types.identifier(tName), _babel_types.identifier(tName)), _babel_types.importSpecifier(_babel_types.identifier(varName), _babel_types.identifier(varName))], _babel_types.stringLiteral(require_utils_constants_gt_helpers.getGtReactImportSource(legacyGtReactImportSource)));
15
16
  path.unshiftContainer("body", importDecl);
16
17
  }
17
18
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"injectJsxInsertionImport.js","names":["t"],"sources":["../../../src/transform/jsx-insertion/injectJsxInsertionImport.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\nimport {\n GT_COMPONENT_TYPES,\n GT_IMPORT_SOURCES,\n} from '../../utils/constants/gt/constants';\n\n/**\n * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react/browser'`\n * as the first statement in the program.\n */\nexport function injectJsxInsertionImport(path: NodePath<t.Program>): void {\n const tName = GT_COMPONENT_TYPES.GtInternalTranslateJsx;\n const varName = GT_COMPONENT_TYPES.GtInternalVar;\n\n const importDecl = t.importDeclaration(\n [\n t.importSpecifier(t.identifier(tName), t.identifier(tName)),\n t.importSpecifier(t.identifier(varName), t.identifier(varName)),\n ],\n t.stringLiteral(GT_IMPORT_SOURCES.GT_REACT_BROWSER)\n );\n\n path.unshiftContainer('body', importDecl);\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,yBAAyB,MAAiC;CACxE,MAAM,QAAA;CACN,MAAM,UAAA;CAEN,MAAM,aAAaA,aAAE,kBACnB,CACEA,aAAE,gBAAgBA,aAAE,WAAW,MAAM,EAAEA,aAAE,WAAW,MAAM,CAAC,EAC3DA,aAAE,gBAAgBA,aAAE,WAAW,QAAQ,EAAEA,aAAE,WAAW,QAAQ,CAAC,CAChE,EACDA,aAAE,cAAA,mBAAiD,CACpD;AAED,MAAK,iBAAiB,QAAQ,WAAW"}
1
+ {"version":3,"file":"injectJsxInsertionImport.js","names":["t","getGtReactImportSource"],"sources":["../../../src/transform/jsx-insertion/injectJsxInsertionImport.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\nimport { GT_COMPONENT_TYPES } from '../../utils/constants/gt/constants';\nimport { getGtReactImportSource } from '../../utils/constants/gt/helpers';\n\n/**\n * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react'`\n * as the first statement in the program.\n */\nexport function injectJsxInsertionImport(\n path: NodePath<t.Program>,\n legacyGtReactImportSource: boolean\n): void {\n const tName = GT_COMPONENT_TYPES.GtInternalTranslateJsx;\n const varName = GT_COMPONENT_TYPES.GtInternalVar;\n\n const importDecl = t.importDeclaration(\n [\n t.importSpecifier(t.identifier(tName), t.identifier(tName)),\n t.importSpecifier(t.identifier(varName), t.identifier(varName)),\n ],\n t.stringLiteral(getGtReactImportSource(legacyGtReactImportSource))\n );\n\n path.unshiftContainer('body', importDecl);\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAgB,yBACd,MACA,2BACM;CACN,MAAM,QAAA;CACN,MAAM,UAAA;CAEN,MAAM,aAAaA,aAAE,kBACnB,CACEA,aAAE,gBAAgBA,aAAE,WAAW,MAAM,EAAEA,aAAE,WAAW,MAAM,CAAC,EAC3DA,aAAE,gBAAgBA,aAAE,WAAW,QAAQ,EAAEA,aAAE,WAAW,QAAQ,CAAC,CAChE,EACDA,aAAE,cAAcC,mCAAAA,uBAAuB,0BAA0B,CAAC,CACnE;AAED,MAAK,iBAAiB,QAAQ,WAAW"}
@@ -1,7 +1,7 @@
1
1
  import * as t from '@babel/types';
2
2
  import { NodePath } from '@babel/traverse';
3
3
  /**
4
- * Inject `import { t } from 'gt-react/browser'` as the first statement in the program.
4
+ * Inject `import { t } from 'gt-react'` as the first statement in the program.
5
5
  */
6
- export declare function injectMacroImport(path: NodePath<t.Program>): void;
6
+ export declare function injectMacroImport(path: NodePath<t.Program>, legacyGtReactImportSource: boolean): void;
7
7
  //# sourceMappingURL=injectMacroImport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectMacroImport.d.ts","sourceRoot":"","sources":["../../../src/transform/macro-expansion/injectMacroImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAM3C;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CASjE"}
1
+ {"version":3,"file":"injectMacroImport.d.ts","sourceRoot":"","sources":["../../../src/transform/macro-expansion/injectMacroImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EACzB,yBAAyB,EAAE,OAAO,GACjC,IAAI,CASN"}
@@ -1,15 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_runtime = require("../../_virtual/_rolldown/runtime.js");
3
3
  require("../../utils/constants/gt/constants.js");
4
+ const require_utils_constants_gt_helpers = require("../../utils/constants/gt/helpers.js");
4
5
  let _babel_types = require("@babel/types");
5
6
  _babel_types = require_runtime.__toESM(_babel_types);
6
7
  //#region src/transform/macro-expansion/injectMacroImport.ts
7
8
  /**
8
- * Inject `import { t } from 'gt-react/browser'` as the first statement in the program.
9
+ * Inject `import { t } from 'gt-react'` as the first statement in the program.
9
10
  */
10
- function injectMacroImport(path) {
11
+ function injectMacroImport(path, legacyGtReactImportSource) {
11
12
  const tName = "t";
12
- const importDecl = _babel_types.importDeclaration([_babel_types.importSpecifier(_babel_types.identifier(tName), _babel_types.identifier(tName))], _babel_types.stringLiteral("gt-react/browser"));
13
+ const importDecl = _babel_types.importDeclaration([_babel_types.importSpecifier(_babel_types.identifier(tName), _babel_types.identifier(tName))], _babel_types.stringLiteral(require_utils_constants_gt_helpers.getGtReactImportSource(legacyGtReactImportSource)));
13
14
  path.unshiftContainer("body", importDecl);
14
15
  }
15
16
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"injectMacroImport.js","names":["t"],"sources":["../../../src/transform/macro-expansion/injectMacroImport.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\nimport {\n GT_IMPORT_SOURCES,\n GT_OTHER_FUNCTIONS,\n} from '../../utils/constants/gt/constants';\n\n/**\n * Inject `import { t } from 'gt-react/browser'` as the first statement in the program.\n */\nexport function injectMacroImport(path: NodePath<t.Program>): void {\n const tName = GT_OTHER_FUNCTIONS.t;\n\n const importDecl = t.importDeclaration(\n [t.importSpecifier(t.identifier(tName), t.identifier(tName))],\n t.stringLiteral(GT_IMPORT_SOURCES.GT_REACT_BROWSER)\n );\n\n path.unshiftContainer('body', importDecl);\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,kBAAkB,MAAiC;CACjE,MAAM,QAAA;CAEN,MAAM,aAAaA,aAAE,kBACnB,CAACA,aAAE,gBAAgBA,aAAE,WAAW,MAAM,EAAEA,aAAE,WAAW,MAAM,CAAC,CAAC,EAC7DA,aAAE,cAAA,mBAAiD,CACpD;AAED,MAAK,iBAAiB,QAAQ,WAAW"}
1
+ {"version":3,"file":"injectMacroImport.js","names":["t","getGtReactImportSource"],"sources":["../../../src/transform/macro-expansion/injectMacroImport.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\nimport { GT_OTHER_FUNCTIONS } from '../../utils/constants/gt/constants';\nimport { getGtReactImportSource } from '../../utils/constants/gt/helpers';\n\n/**\n * Inject `import { t } from 'gt-react'` as the first statement in the program.\n */\nexport function injectMacroImport(\n path: NodePath<t.Program>,\n legacyGtReactImportSource: boolean\n): void {\n const tName = GT_OTHER_FUNCTIONS.t;\n\n const importDecl = t.importDeclaration(\n [t.importSpecifier(t.identifier(tName), t.identifier(tName))],\n t.stringLiteral(getGtReactImportSource(legacyGtReactImportSource))\n );\n\n path.unshiftContainer('body', importDecl);\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,kBACd,MACA,2BACM;CACN,MAAM,QAAA;CAEN,MAAM,aAAaA,aAAE,kBACnB,CAACA,aAAE,gBAAgBA,aAAE,WAAW,MAAM,EAAEA,aAAE,WAAW,MAAM,CAAC,CAAC,EAC7DA,aAAE,cAAcC,mCAAAA,uBAAuB,0BAA0B,CAAC,CACnE;AAED,MAAK,iBAAiB,QAAQ,WAAW"}
@@ -2,10 +2,11 @@ import * as t from '@babel/types';
2
2
  import { NodePath } from '@babel/traverse';
3
3
  /**
4
4
  * Inject runtime translate import with only the specifiers needed.
5
- * `import { GtInternalRuntimeTranslateString, GtInternalRuntimeTranslateJsx } from 'gt-react/browser'`
5
+ * `import { GtInternalRuntimeTranslateString, GtInternalRuntimeTranslateJsx } from 'gt-react'`
6
6
  */
7
- export declare function injectRuntimeTranslateImport(path: NodePath<t.Program>, { needsString, needsJsx }: {
7
+ export declare function injectRuntimeTranslateImport(path: NodePath<t.Program>, { needsString, needsJsx, legacyGtReactImportSource, }: {
8
8
  needsString: boolean;
9
9
  needsJsx: boolean;
10
+ legacyGtReactImportSource: boolean;
10
11
  }): NodePath<t.ImportDeclaration> | null;
11
12
  //# sourceMappingURL=injectRuntimeTranslateImport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectRuntimeTranslateImport.d.ts","sourceRoot":"","sources":["../../../src/transform/runtime-translate/injectRuntimeTranslateImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAM3C;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EACzB,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GACrE,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAsBtC"}
1
+ {"version":3,"file":"injectRuntimeTranslateImport.d.ts","sourceRoot":"","sources":["../../../src/transform/runtime-translate/injectRuntimeTranslateImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EACzB,EACE,WAAW,EACX,QAAQ,EACR,yBAAyB,GAC1B,EAAE;IACD,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,yBAAyB,EAAE,OAAO,CAAC;CACpC,GACA,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAsBtC"}
@@ -1,14 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_runtime = require("../../_virtual/_rolldown/runtime.js");
3
3
  require("../../utils/constants/gt/constants.js");
4
+ const require_utils_constants_gt_helpers = require("../../utils/constants/gt/helpers.js");
4
5
  let _babel_types = require("@babel/types");
5
6
  _babel_types = require_runtime.__toESM(_babel_types);
6
7
  //#region src/transform/runtime-translate/injectRuntimeTranslateImport.ts
7
8
  /**
8
9
  * Inject runtime translate import with only the specifiers needed.
9
- * `import { GtInternalRuntimeTranslateString, GtInternalRuntimeTranslateJsx } from 'gt-react/browser'`
10
+ * `import { GtInternalRuntimeTranslateString, GtInternalRuntimeTranslateJsx } from 'gt-react'`
10
11
  */
11
- function injectRuntimeTranslateImport(path, { needsString, needsJsx }) {
12
+ function injectRuntimeTranslateImport(path, { needsString, needsJsx, legacyGtReactImportSource }) {
12
13
  const specifiers = [];
13
14
  if (needsString) {
14
15
  const name = "GtInternalRuntimeTranslateString";
@@ -19,7 +20,7 @@ function injectRuntimeTranslateImport(path, { needsString, needsJsx }) {
19
20
  specifiers.push(_babel_types.importSpecifier(_babel_types.identifier(name), _babel_types.identifier(name)));
20
21
  }
21
22
  if (specifiers.length === 0) return null;
22
- const importDecl = _babel_types.importDeclaration(specifiers, _babel_types.stringLiteral("gt-react/browser"));
23
+ const importDecl = _babel_types.importDeclaration(specifiers, _babel_types.stringLiteral(require_utils_constants_gt_helpers.getGtReactImportSource(legacyGtReactImportSource)));
23
24
  const [inserted] = path.unshiftContainer("body", importDecl);
24
25
  return inserted;
25
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"injectRuntimeTranslateImport.js","names":["t"],"sources":["../../../src/transform/runtime-translate/injectRuntimeTranslateImport.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\nimport {\n GT_IMPORT_SOURCES,\n GT_OTHER_FUNCTIONS,\n} from '../../utils/constants/gt/constants';\n\n/**\n * Inject runtime translate import with only the specifiers needed.\n * `import { GtInternalRuntimeTranslateString, GtInternalRuntimeTranslateJsx } from 'gt-react/browser'`\n */\nexport function injectRuntimeTranslateImport(\n path: NodePath<t.Program>,\n { needsString, needsJsx }: { needsString: boolean; needsJsx: boolean }\n): NodePath<t.ImportDeclaration> | null {\n const specifiers: t.ImportSpecifier[] = [];\n\n if (needsString) {\n const name = GT_OTHER_FUNCTIONS.GtInternalRuntimeTranslateString;\n specifiers.push(t.importSpecifier(t.identifier(name), t.identifier(name)));\n }\n\n if (needsJsx) {\n const name = GT_OTHER_FUNCTIONS.GtInternalRuntimeTranslateJsx;\n specifiers.push(t.importSpecifier(t.identifier(name), t.identifier(name)));\n }\n\n if (specifiers.length === 0) return null;\n\n const importDecl = t.importDeclaration(\n specifiers,\n t.stringLiteral(GT_IMPORT_SOURCES.GT_REACT_BROWSER)\n );\n\n const [inserted] = path.unshiftContainer('body', importDecl);\n return inserted as NodePath<t.ImportDeclaration>;\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,6BACd,MACA,EAAE,aAAa,YACuB;CACtC,MAAM,aAAkC,EAAE;AAE1C,KAAI,aAAa;EACf,MAAM,OAAA;AACN,aAAW,KAAKA,aAAE,gBAAgBA,aAAE,WAAW,KAAK,EAAEA,aAAE,WAAW,KAAK,CAAC,CAAC;;AAG5E,KAAI,UAAU;EACZ,MAAM,OAAA;AACN,aAAW,KAAKA,aAAE,gBAAgBA,aAAE,WAAW,KAAK,EAAEA,aAAE,WAAW,KAAK,CAAC,CAAC;;AAG5E,KAAI,WAAW,WAAW,EAAG,QAAO;CAEpC,MAAM,aAAaA,aAAE,kBACnB,YACAA,aAAE,cAAA,mBAAiD,CACpD;CAED,MAAM,CAAC,YAAY,KAAK,iBAAiB,QAAQ,WAAW;AAC5D,QAAO"}
1
+ {"version":3,"file":"injectRuntimeTranslateImport.js","names":["t","getGtReactImportSource"],"sources":["../../../src/transform/runtime-translate/injectRuntimeTranslateImport.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\nimport { GT_OTHER_FUNCTIONS } from '../../utils/constants/gt/constants';\nimport { getGtReactImportSource } from '../../utils/constants/gt/helpers';\n\n/**\n * Inject runtime translate import with only the specifiers needed.\n * `import { GtInternalRuntimeTranslateString, GtInternalRuntimeTranslateJsx } from 'gt-react'`\n */\nexport function injectRuntimeTranslateImport(\n path: NodePath<t.Program>,\n {\n needsString,\n needsJsx,\n legacyGtReactImportSource,\n }: {\n needsString: boolean;\n needsJsx: boolean;\n legacyGtReactImportSource: boolean;\n }\n): NodePath<t.ImportDeclaration> | null {\n const specifiers: t.ImportSpecifier[] = [];\n\n if (needsString) {\n const name = GT_OTHER_FUNCTIONS.GtInternalRuntimeTranslateString;\n specifiers.push(t.importSpecifier(t.identifier(name), t.identifier(name)));\n }\n\n if (needsJsx) {\n const name = GT_OTHER_FUNCTIONS.GtInternalRuntimeTranslateJsx;\n specifiers.push(t.importSpecifier(t.identifier(name), t.identifier(name)));\n }\n\n if (specifiers.length === 0) return null;\n\n const importDecl = t.importDeclaration(\n specifiers,\n t.stringLiteral(getGtReactImportSource(legacyGtReactImportSource))\n );\n\n const [inserted] = path.unshiftContainer('body', importDecl);\n return inserted as NodePath<t.ImportDeclaration>;\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAgB,6BACd,MACA,EACE,aACA,UACA,6BAMoC;CACtC,MAAM,aAAkC,EAAE;AAE1C,KAAI,aAAa;EACf,MAAM,OAAA;AACN,aAAW,KAAKA,aAAE,gBAAgBA,aAAE,WAAW,KAAK,EAAEA,aAAE,WAAW,KAAK,CAAC,CAAC;;AAG5E,KAAI,UAAU;EACZ,MAAM,OAAA;AACN,aAAW,KAAKA,aAAE,gBAAgBA,aAAE,WAAW,KAAK,EAAEA,aAAE,WAAW,KAAK,CAAC,CAAC;;AAG5E,KAAI,WAAW,WAAW,EAAG,QAAO;CAEpC,MAAM,aAAaA,aAAE,kBACnB,YACAA,aAAE,cAAcC,mCAAAA,uBAAuB,0BAA0B,CAAC,CACnE;CAED,MAAM,CAAC,YAAY,KAAK,iBAAiB,QAAQ,WAAW;AAC5D,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateTranslationFunction.d.ts","sourceRoot":"","sources":["../../../src/transform/validation/validateTranslationFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAKlC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOnD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,EACxC,KAAK,EAAE,cAAc,GACpB;IACD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CA0HA;AAED;;;GAGG;AAEH,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,CAAC,CAAC,cAAc,GAAG;IAC5E,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAGA;AAED;;;GAGG;AAEH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,CAAC,CAAC,cAAc,GAAG;IACxE,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAGA;AAyID;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,CAAC,CAAC,UAAU,EAClB,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,MAAM,EAAE,GACf;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAoFtB"}
1
+ {"version":3,"file":"validateTranslationFunction.d.ts","sourceRoot":"","sources":["../../../src/transform/validation/validateTranslationFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAKlC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOnD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,EACxC,KAAK,EAAE,cAAc,GACpB;IACD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CA0HA;AAED;;;GAGG;AAEH,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,CAAC,CAAC,cAAc,GAAG;IAC5E,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAGA;AAED;;;GAGG;AAEH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,CAAC,CAAC,cAAc,GAAG;IACxE,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAGA;AAyID;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,CAAC,CAAC,UAAU,EAClB,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,MAAM,EAAE,GACf;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAmFtB"}
@@ -168,11 +168,11 @@ function validateDerive(expr, state, errors) {
168
168
  errors.push("Expression does not use an allowed call expression");
169
169
  return { errors };
170
170
  }
171
- if (type !== "generaltranslation" || canonicalName !== "declareStatic" && canonicalName !== "derive") {
171
+ if (type !== "generaltranslation" || canonicalName !== "derive") {
172
172
  errors.push("Expression does not use an allowed call expression");
173
173
  return { errors };
174
174
  }
175
- validateDeclareStaticExpression(expr, errors);
175
+ validateDeriveCallExpression(expr, errors);
176
176
  return { errors };
177
177
  }
178
178
  if (_babel_types.isBinaryExpression(expr) && expr.operator === "+") {
@@ -202,7 +202,7 @@ function validateDerive(expr, state, errors) {
202
202
  * - the argument is a call expression
203
203
  * Example: derive(getName())
204
204
  */
205
- function validateDeclareStaticExpression(expr, errors) {
205
+ function validateDeriveCallExpression(expr, errors) {
206
206
  if (expr.arguments.length !== 1) {
207
207
  errors.push("derive() must have one argument");
208
208
  return { errors };
@@ -1 +1 @@
1
- {"version":3,"file":"validateTranslationFunction.js","names":["t","resolveStaticExpression","getCalleeNameFromExpression","getTrackedVariable"],"sources":["../../../src/transform/validation/validateTranslationFunction.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport {\n GT_OTHER_FUNCTIONS,\n USEGT_CALLBACK_OPTIONS,\n} from '../../utils/constants/gt/constants';\nimport { TransformState } from '../../state/types';\nimport { getCalleeNameFromExpression } from '../../utils/parsing/getCalleeNameFromExpression';\nimport {\n resolveStaticExpression,\n type ResolveStaticExpressionError,\n} from '../../utils/string-expressions/resolveStaticExpression';\nimport { getTrackedVariable } from '../getTrackedVariable';\nimport { NodePath } from '@babel/traverse';\n\n/**\n * Validate useGT_callback / getGT_callback / msg() / t()\n * - first argument must be a statically resolvable string expression\n * (string literal, template literal, binary '+' concatenation, or derive() call)\n * - second argument, if present, $id field + $context field must be a string literal\n */\nexport function validateTranslationFunction(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState\n): {\n errors: string[];\n content?: string;\n context?: string;\n hash?: string;\n id?: string;\n maxChars?: number;\n format?: string;\n hasDeriveContext?: boolean;\n} {\n const callExpr = callExprPath.node;\n const errors: string[] = [];\n\n // Validate that the function has at least 1 argument\n if (callExpr.arguments.length < 1) {\n errors.push('registration function must have at least 1 argument');\n return { errors };\n }\n\n // Validate first argument\n if (!t.isExpression(callExpr.arguments[0])) {\n errors.push(\n 'registration function must use a string literal or derive() call as the first argument. Variable content is not allowed.'\n );\n return { errors };\n }\n\n // Try to resolve the expression to a static string (handles concat, nested templates, etc.)\n const resolvedStaticExpression = resolveStaticExpression(\n callExprPath.get('arguments')[0] as NodePath<t.Expression>\n );\n // TODO: until we implement derivation, we will only need to check the first value\n const content = resolvedStaticExpression.values?.[0];\n const resolutionErrors = getResolutionErrorMessages(\n resolvedStaticExpression.errors,\n false\n );\n\n if (resolutionErrors.length > 0) {\n return { errors: resolutionErrors };\n }\n\n if (content === undefined && !state.settings.autoderive.strings) {\n // Not a static expression — check if it contains a derive() function invocation\n validateDerive(callExpr.arguments[0], state, errors);\n if (errors.length > 0) {\n errors.push(\n ...getResolutionErrorMessages(resolvedStaticExpression.errors)\n );\n errors.push(\n 'registration function must use a string literal or derive() call as the first argument. Variable content is not allowed.'\n );\n return { errors };\n }\n }\n\n // TODO: hasDeriveContext should be refactored to enforce no hash generated HERE in this function\n // instead of passing that information outside of this function.\n // We skip hash gen with autoderive, derive in content, and derive in $context. This flag is being\n // reused for all 3 cases.\n const contentHasAutoderive =\n state.settings.autoderive.strings && content === undefined;\n\n // Validate second argument\n let context: string | undefined;\n let id: string | undefined;\n let hash: string | undefined;\n let maxChars: number | undefined;\n let format: string | undefined;\n let hasDeriveContext: boolean | undefined;\n if (callExpr.arguments.length === 1) {\n return {\n errors,\n content,\n hasDeriveContext: contentHasAutoderive || undefined,\n };\n }\n if (t.isObjectExpression(callExpr.arguments[1])) {\n const objExprPath = callExprPath.get(\n 'arguments'\n )[1] as NodePath<t.ObjectExpression>;\n const contextProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$context,\n 'string-or-derive',\n state\n );\n errors.push(...contextProperty.errors);\n context = contextProperty.value as string | undefined;\n hasDeriveContext =\n contentHasAutoderive || contextProperty.hasDeriveExpression;\n const idProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$id,\n 'string'\n );\n errors.push(...idProperty.errors);\n id = idProperty.value;\n const maxCharsProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$maxChars,\n 'number'\n );\n errors.push(...maxCharsProperty.errors);\n maxChars = maxCharsProperty.value;\n const hashProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$_hash,\n 'string'\n );\n errors.push(...hashProperty.errors);\n hash = hashProperty.value;\n const formatProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$format,\n 'string'\n );\n errors.push(...formatProperty.errors);\n format = formatProperty.value;\n }\n\n return {\n errors,\n content,\n context,\n id,\n hash,\n maxChars,\n format,\n hasDeriveContext,\n };\n}\n\n/**\n * Validate useTranslations_callback / getTranslations_callback\n * - always valid (arguments can be dynamic)\n */\n// eslint-disable-next-line no-unused-vars\nexport function validateUseTranslationsCallback(_callExpr: t.CallExpression): {\n errors: string[];\n} {\n const errors: string[] = [];\n return { errors };\n}\n\n/**\n * Validate useMessages_callback / getMessages_callback\n * - always valid\n */\n// eslint-disable-next-line no-unused-vars\nexport function validateUseMessagesCallback(_callExpr: t.CallExpression): {\n errors: string[];\n} {\n const errors: string[] = [];\n return { errors };\n}\n\n/* =============================== */\n/* Helper Functions */\n/* =============================== */\n\nfunction getResolutionErrorMessages(\n errors: ResolveStaticExpressionError[],\n includeDynamic = true\n): string[] {\n return errors\n .filter((error) => includeDynamic || error.kind !== 'dynamic-expression')\n .map(({ message }) => message);\n}\n\n/**\n * Validate a property from an object expression\n * @param objExpr - The object expression to validate\n * @param name - The name of the property to validate\n * @returns The validated property\n */\nfunction validatePropertyFromObjectExpression(\n objExprPath: NodePath<t.ObjectExpression>,\n name: string,\n type: 'string'\n): { errors: string[]; value?: string };\nfunction validatePropertyFromObjectExpression(\n objExprPath: NodePath<t.ObjectExpression>,\n name: string,\n type: 'number'\n): { errors: string[]; value?: number };\nfunction validatePropertyFromObjectExpression(\n objExprPath: NodePath<t.ObjectExpression>,\n name: string,\n type: 'string-or-derive',\n state: TransformState\n): { errors: string[]; value?: string; hasDeriveExpression?: boolean };\nfunction validatePropertyFromObjectExpression(\n objExprPath: NodePath<t.ObjectExpression>,\n name: string,\n type: 'string' | 'number' | 'string-or-derive',\n state?: TransformState\n): {\n errors: string[];\n value?: string | number;\n hasDeriveExpression?: boolean;\n} {\n const result: {\n errors: string[];\n value?: string | number;\n hasDeriveExpression?: boolean;\n } = { errors: [] };\n let valuePath: NodePath<t.ObjectProperty> | undefined;\n for (const propertyPath of objExprPath.get('properties')) {\n if (!propertyPath.isObjectProperty()) {\n continue;\n }\n const property = propertyPath.node;\n if (t.isIdentifier(property.key) && property.key.name === name) {\n valuePath = propertyPath;\n break;\n }\n if (t.isStringLiteral(property.key) && property.key.value === name) {\n valuePath = propertyPath;\n break;\n }\n }\n\n // return result if no value found\n if (!valuePath) {\n return result;\n }\n\n const value = valuePath.node;\n\n // validate value\n if (!t.isExpression(value.value)) {\n result.errors.push(\n `registration function must use a string literal for its ${name} field. Variable content is not allowed.`\n );\n return result;\n }\n\n // extract value\n if (type === 'string-or-derive') {\n const resolved = resolveStaticExpression(\n valuePath.get('value') as NodePath<t.Expression>\n );\n const resolutionErrors = getResolutionErrorMessages(resolved.errors, false);\n // TODO: until we implement derivation, we will only need to check the first value\n if (resolved.values?.[0] !== undefined) {\n result.value = resolved.values[0];\n } else if (resolutionErrors.length > 0) {\n result.errors.push(...resolutionErrors);\n } else if (state) {\n // Static resolution failed — check if it's a valid derive() expression\n const deriveErrors: string[] = [];\n validateDerive(value.value, state, deriveErrors);\n if (deriveErrors.length === 0) {\n result.hasDeriveExpression = true;\n } else {\n result.errors.push(\n ...getResolutionErrorMessages(resolved.errors),\n ...deriveErrors\n );\n }\n } else {\n result.errors.push(...getResolutionErrorMessages(resolved.errors));\n }\n } else {\n const validatedValue =\n type === 'string'\n ? validateExpressionIsStringLiteral(value.value)\n : validateExpressionIsNumericLiteral(value.value);\n result.errors.push(...validatedValue.errors);\n result.value = validatedValue.value;\n }\n\n return result;\n}\n\n/**\n * Validate that an expression is a string literal\n */\nfunction validateExpressionIsStringLiteral(expr: t.Expression): {\n errors: string[];\n value?: string;\n} {\n if (t.isStringLiteral(expr)) {\n return { errors: [], value: expr.value };\n }\n if (t.isTemplateLiteral(expr) && expr.expressions.length === 0) {\n return { errors: [], value: expr.quasis[0]?.value.cooked };\n }\n return { errors: ['Expression is not a string literal'] };\n}\n\n/**\n * Validates if an expression uses the derive() function correctly\n */\nexport function validateDerive(\n expr: t.Expression,\n state: TransformState,\n errors: string[]\n): { errors: string[] } {\n if (!expr) {\n errors.push('Expression is empty');\n return { errors };\n }\n\n // 1. Direct call: derive(node)\n if (t.isCallExpression(expr)) {\n // Find the canonical function name\n const { namespaceName, functionName } = getCalleeNameFromExpression(expr);\n // Get the canonical function name\n const { canonicalName, type } = getTrackedVariable(\n state.scopeTracker,\n namespaceName,\n functionName\n );\n if (!canonicalName) {\n errors.push('Expression does not use an allowed call expression');\n return { errors };\n }\n // Validate the function is actually the GT derive function\n if (\n type !== 'generaltranslation' ||\n (canonicalName !== GT_OTHER_FUNCTIONS.declareStatic &&\n canonicalName !== GT_OTHER_FUNCTIONS.derive)\n ) {\n errors.push('Expression does not use an allowed call expression');\n return { errors };\n }\n // Validate that the call expression has exactly one argument and the argument is a call expression\n validateDeclareStaticExpression(expr, errors);\n return { errors };\n }\n\n // 2. String concatenation: \"Hello there \" + derive(getName())\n if (t.isBinaryExpression(expr) && expr.operator === '+') {\n if (!t.isExpression(expr.left) || !t.isExpression(expr.right)) {\n errors.push('Operands must be expressions');\n return { errors };\n }\n validateDerive(expr.right, state, errors);\n validateDerive(expr.left, state, errors);\n return { errors };\n }\n\n // 3. Template literal: `Hello there ${derive(getName())}` or `static text`\n if (t.isTemplateLiteral(expr)) {\n if (expr.expressions.length === 0) {\n return { errors };\n }\n if (\n !expr.expressions.some(\n (expression) =>\n t.isExpression(expression) &&\n validateDerive(expression, state, errors).errors.length === 0\n )\n ) {\n errors.push('Expression does not use an allowed call expression');\n }\n return {\n errors,\n };\n }\n\n // 4. Static literals (string, number, boolean, null)\n if (t.isStringLiteral(expr)) {\n return { errors };\n }\n\n if (t.isNumericLiteral(expr)) {\n return { errors };\n }\n\n if (t.isBooleanLiteral(expr)) {\n return { errors };\n }\n\n if (t.isNullLiteral(expr)) {\n return { errors };\n }\n\n // Fallthrough: expression type not supported (e.g., plain identifiers/variables)\n errors.push('Variables are not allowed');\n return { errors };\n}\n\n/**\n * Takes in a call expression to check if:\n * - it has exactly one argument\n * - the argument is a call expression\n * Example: derive(getName())\n */\nfunction validateDeclareStaticExpression(\n expr: t.CallExpression,\n errors: string[]\n): {\n errors: string[];\n} {\n // Validate that the function has 1 argument\n if (expr.arguments.length !== 1) {\n errors.push('derive() must have one argument');\n return { errors };\n }\n const [onlyArg] = expr.arguments;\n\n // Await expression: derive(await ...)\n if (t.isAwaitExpression(onlyArg)) {\n // Validate that the awaited expression is a call expression\n if (!t.isCallExpression(onlyArg.argument)) {\n errors.push('derive() must have a call expression as the argument');\n return { errors };\n }\n // Valid: derive(await someFunction())\n return { errors };\n }\n\n // Validate that the argument is a call expression\n if (!t.isCallExpression(onlyArg)) {\n errors.push('derive() must have a call expression as the argument');\n return { errors };\n }\n\n return { errors };\n}\n\n/**\n * Validate that an expression is a number literal\n */\nfunction validateExpressionIsNumericLiteral(expr: t.Expression): {\n errors: string[];\n value?: number;\n} {\n let candidateValue: number | undefined;\n if (t.isNumericLiteral(expr)) {\n candidateValue = expr.value;\n } else if (t.isUnaryExpression(expr) && t.isNumericLiteral(expr.argument)) {\n // Note: taking the absolute value of the number literal\n candidateValue = expr.argument.value;\n }\n\n // validate is integer\n if (candidateValue !== undefined && !Number.isInteger(candidateValue)) {\n return { errors: ['Expression is not an integer'] };\n }\n\n // no value found\n if (candidateValue === undefined) {\n return { errors: ['Expression is not a number literal'] };\n }\n\n return { errors: [], value: candidateValue };\n}\n"],"mappings":";;;;;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K,4BAA4B;AACxC,QAAO,EAAE,QAAQ;;;;;;;;AASnB,SAAS,gCACP,MACA,QAGA;AAEA,KAAI,KAAK,UAAU,WAAW,GAAG;AAC/B,SAAO,KAAK,kCAAkC;AAC9C,SAAO,EAAE,QAAQ;;CAEnB,MAAM,CAAC,WAAW,KAAK;AAGvB,KAAIA,aAAE,kBAAkB,QAAQ,EAAE;AAEhC,MAAI,CAACA,aAAE,iBAAiB,QAAQ,SAAS,EAAE;AACzC,UAAO,KAAK,uDAAuD;AACnE,UAAO,EAAE,QAAQ;;AAGnB,SAAO,EAAE,QAAQ;;AAInB,KAAI,CAACA,aAAE,iBAAiB,QAAQ,EAAE;AAChC,SAAO,KAAK,uDAAuD;AACnE,SAAO,EAAE,QAAQ;;AAGnB,QAAO,EAAE,QAAQ;;;;;AAMnB,SAAS,mCAAmC,MAG1C;CACA,IAAI;AACJ,KAAIA,aAAE,iBAAiB,KAAK,CAC1B,kBAAiB,KAAK;UACbA,aAAE,kBAAkB,KAAK,IAAIA,aAAE,iBAAiB,KAAK,SAAS,CAEvE,kBAAiB,KAAK,SAAS;AAIjC,KAAI,mBAAmB,KAAA,KAAa,CAAC,OAAO,UAAU,eAAe,CACnE,QAAO,EAAE,QAAQ,CAAC,+BAA+B,EAAE;AAIrD,KAAI,mBAAmB,KAAA,EACrB,QAAO,EAAE,QAAQ,CAAC,qCAAqC,EAAE;AAG3D,QAAO;EAAE,QAAQ,EAAE;EAAE,OAAO;EAAgB"}
1
+ {"version":3,"file":"validateTranslationFunction.js","names":["t","resolveStaticExpression","getCalleeNameFromExpression","getTrackedVariable"],"sources":["../../../src/transform/validation/validateTranslationFunction.ts"],"sourcesContent":["import * as t from '@babel/types';\nimport {\n GT_OTHER_FUNCTIONS,\n USEGT_CALLBACK_OPTIONS,\n} from '../../utils/constants/gt/constants';\nimport { TransformState } from '../../state/types';\nimport { getCalleeNameFromExpression } from '../../utils/parsing/getCalleeNameFromExpression';\nimport {\n resolveStaticExpression,\n type ResolveStaticExpressionError,\n} from '../../utils/string-expressions/resolveStaticExpression';\nimport { getTrackedVariable } from '../getTrackedVariable';\nimport { NodePath } from '@babel/traverse';\n\n/**\n * Validate useGT_callback / getGT_callback / msg() / t()\n * - first argument must be a statically resolvable string expression\n * (string literal, template literal, binary '+' concatenation, or derive() call)\n * - second argument, if present, $id field + $context field must be a string literal\n */\nexport function validateTranslationFunction(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState\n): {\n errors: string[];\n content?: string;\n context?: string;\n hash?: string;\n id?: string;\n maxChars?: number;\n format?: string;\n hasDeriveContext?: boolean;\n} {\n const callExpr = callExprPath.node;\n const errors: string[] = [];\n\n // Validate that the function has at least 1 argument\n if (callExpr.arguments.length < 1) {\n errors.push('registration function must have at least 1 argument');\n return { errors };\n }\n\n // Validate first argument\n if (!t.isExpression(callExpr.arguments[0])) {\n errors.push(\n 'registration function must use a string literal or derive() call as the first argument. Variable content is not allowed.'\n );\n return { errors };\n }\n\n // Try to resolve the expression to a static string (handles concat, nested templates, etc.)\n const resolvedStaticExpression = resolveStaticExpression(\n callExprPath.get('arguments')[0] as NodePath<t.Expression>\n );\n // TODO: until we implement derivation, we will only need to check the first value\n const content = resolvedStaticExpression.values?.[0];\n const resolutionErrors = getResolutionErrorMessages(\n resolvedStaticExpression.errors,\n false\n );\n\n if (resolutionErrors.length > 0) {\n return { errors: resolutionErrors };\n }\n\n if (content === undefined && !state.settings.autoderive.strings) {\n // Not a static expression — check if it contains a derive() function invocation\n validateDerive(callExpr.arguments[0], state, errors);\n if (errors.length > 0) {\n errors.push(\n ...getResolutionErrorMessages(resolvedStaticExpression.errors)\n );\n errors.push(\n 'registration function must use a string literal or derive() call as the first argument. Variable content is not allowed.'\n );\n return { errors };\n }\n }\n\n // TODO: hasDeriveContext should be refactored to enforce no hash generated HERE in this function\n // instead of passing that information outside of this function.\n // We skip hash gen with autoderive, derive in content, and derive in $context. This flag is being\n // reused for all 3 cases.\n const contentHasAutoderive =\n state.settings.autoderive.strings && content === undefined;\n\n // Validate second argument\n let context: string | undefined;\n let id: string | undefined;\n let hash: string | undefined;\n let maxChars: number | undefined;\n let format: string | undefined;\n let hasDeriveContext: boolean | undefined;\n if (callExpr.arguments.length === 1) {\n return {\n errors,\n content,\n hasDeriveContext: contentHasAutoderive || undefined,\n };\n }\n if (t.isObjectExpression(callExpr.arguments[1])) {\n const objExprPath = callExprPath.get(\n 'arguments'\n )[1] as NodePath<t.ObjectExpression>;\n const contextProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$context,\n 'string-or-derive',\n state\n );\n errors.push(...contextProperty.errors);\n context = contextProperty.value as string | undefined;\n hasDeriveContext =\n contentHasAutoderive || contextProperty.hasDeriveExpression;\n const idProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$id,\n 'string'\n );\n errors.push(...idProperty.errors);\n id = idProperty.value;\n const maxCharsProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$maxChars,\n 'number'\n );\n errors.push(...maxCharsProperty.errors);\n maxChars = maxCharsProperty.value;\n const hashProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$_hash,\n 'string'\n );\n errors.push(...hashProperty.errors);\n hash = hashProperty.value;\n const formatProperty = validatePropertyFromObjectExpression(\n objExprPath,\n USEGT_CALLBACK_OPTIONS.$format,\n 'string'\n );\n errors.push(...formatProperty.errors);\n format = formatProperty.value;\n }\n\n return {\n errors,\n content,\n context,\n id,\n hash,\n maxChars,\n format,\n hasDeriveContext,\n };\n}\n\n/**\n * Validate useTranslations_callback / getTranslations_callback\n * - always valid (arguments can be dynamic)\n */\n// eslint-disable-next-line no-unused-vars\nexport function validateUseTranslationsCallback(_callExpr: t.CallExpression): {\n errors: string[];\n} {\n const errors: string[] = [];\n return { errors };\n}\n\n/**\n * Validate useMessages_callback / getMessages_callback\n * - always valid\n */\n// eslint-disable-next-line no-unused-vars\nexport function validateUseMessagesCallback(_callExpr: t.CallExpression): {\n errors: string[];\n} {\n const errors: string[] = [];\n return { errors };\n}\n\n/* =============================== */\n/* Helper Functions */\n/* =============================== */\n\nfunction getResolutionErrorMessages(\n errors: ResolveStaticExpressionError[],\n includeDynamic = true\n): string[] {\n return errors\n .filter((error) => includeDynamic || error.kind !== 'dynamic-expression')\n .map(({ message }) => message);\n}\n\n/**\n * Validate a property from an object expression\n * @param objExpr - The object expression to validate\n * @param name - The name of the property to validate\n * @returns The validated property\n */\nfunction validatePropertyFromObjectExpression(\n objExprPath: NodePath<t.ObjectExpression>,\n name: string,\n type: 'string'\n): { errors: string[]; value?: string };\nfunction validatePropertyFromObjectExpression(\n objExprPath: NodePath<t.ObjectExpression>,\n name: string,\n type: 'number'\n): { errors: string[]; value?: number };\nfunction validatePropertyFromObjectExpression(\n objExprPath: NodePath<t.ObjectExpression>,\n name: string,\n type: 'string-or-derive',\n state: TransformState\n): { errors: string[]; value?: string; hasDeriveExpression?: boolean };\nfunction validatePropertyFromObjectExpression(\n objExprPath: NodePath<t.ObjectExpression>,\n name: string,\n type: 'string' | 'number' | 'string-or-derive',\n state?: TransformState\n): {\n errors: string[];\n value?: string | number;\n hasDeriveExpression?: boolean;\n} {\n const result: {\n errors: string[];\n value?: string | number;\n hasDeriveExpression?: boolean;\n } = { errors: [] };\n let valuePath: NodePath<t.ObjectProperty> | undefined;\n for (const propertyPath of objExprPath.get('properties')) {\n if (!propertyPath.isObjectProperty()) {\n continue;\n }\n const property = propertyPath.node;\n if (t.isIdentifier(property.key) && property.key.name === name) {\n valuePath = propertyPath;\n break;\n }\n if (t.isStringLiteral(property.key) && property.key.value === name) {\n valuePath = propertyPath;\n break;\n }\n }\n\n // return result if no value found\n if (!valuePath) {\n return result;\n }\n\n const value = valuePath.node;\n\n // validate value\n if (!t.isExpression(value.value)) {\n result.errors.push(\n `registration function must use a string literal for its ${name} field. Variable content is not allowed.`\n );\n return result;\n }\n\n // extract value\n if (type === 'string-or-derive') {\n const resolved = resolveStaticExpression(\n valuePath.get('value') as NodePath<t.Expression>\n );\n const resolutionErrors = getResolutionErrorMessages(resolved.errors, false);\n // TODO: until we implement derivation, we will only need to check the first value\n if (resolved.values?.[0] !== undefined) {\n result.value = resolved.values[0];\n } else if (resolutionErrors.length > 0) {\n result.errors.push(...resolutionErrors);\n } else if (state) {\n // Static expression resolution failed; check if it's a valid derive() expression.\n const deriveErrors: string[] = [];\n validateDerive(value.value, state, deriveErrors);\n if (deriveErrors.length === 0) {\n result.hasDeriveExpression = true;\n } else {\n result.errors.push(\n ...getResolutionErrorMessages(resolved.errors),\n ...deriveErrors\n );\n }\n } else {\n result.errors.push(...getResolutionErrorMessages(resolved.errors));\n }\n } else {\n const validatedValue =\n type === 'string'\n ? validateExpressionIsStringLiteral(value.value)\n : validateExpressionIsNumericLiteral(value.value);\n result.errors.push(...validatedValue.errors);\n result.value = validatedValue.value;\n }\n\n return result;\n}\n\n/**\n * Validate that an expression is a string literal\n */\nfunction validateExpressionIsStringLiteral(expr: t.Expression): {\n errors: string[];\n value?: string;\n} {\n if (t.isStringLiteral(expr)) {\n return { errors: [], value: expr.value };\n }\n if (t.isTemplateLiteral(expr) && expr.expressions.length === 0) {\n return { errors: [], value: expr.quasis[0]?.value.cooked };\n }\n return { errors: ['Expression is not a string literal'] };\n}\n\n/**\n * Validates if an expression uses the derive() function correctly\n */\nexport function validateDerive(\n expr: t.Expression,\n state: TransformState,\n errors: string[]\n): { errors: string[] } {\n if (!expr) {\n errors.push('Expression is empty');\n return { errors };\n }\n\n // 1. Direct call: derive(node)\n if (t.isCallExpression(expr)) {\n // Find the canonical function name\n const { namespaceName, functionName } = getCalleeNameFromExpression(expr);\n // Get the canonical function name\n const { canonicalName, type } = getTrackedVariable(\n state.scopeTracker,\n namespaceName,\n functionName\n );\n if (!canonicalName) {\n errors.push('Expression does not use an allowed call expression');\n return { errors };\n }\n // Validate the function is actually the GT derive function\n if (\n type !== 'generaltranslation' ||\n canonicalName !== GT_OTHER_FUNCTIONS.derive\n ) {\n errors.push('Expression does not use an allowed call expression');\n return { errors };\n }\n // Validate that the call expression has exactly one argument and the argument is a call expression\n validateDeriveCallExpression(expr, errors);\n return { errors };\n }\n\n // 2. String concatenation: \"Hello there \" + derive(getName())\n if (t.isBinaryExpression(expr) && expr.operator === '+') {\n if (!t.isExpression(expr.left) || !t.isExpression(expr.right)) {\n errors.push('Operands must be expressions');\n return { errors };\n }\n validateDerive(expr.right, state, errors);\n validateDerive(expr.left, state, errors);\n return { errors };\n }\n\n // 3. Template literal: `Hello there ${derive(getName())}` or `static text`\n if (t.isTemplateLiteral(expr)) {\n if (expr.expressions.length === 0) {\n return { errors };\n }\n if (\n !expr.expressions.some(\n (expression) =>\n t.isExpression(expression) &&\n validateDerive(expression, state, errors).errors.length === 0\n )\n ) {\n errors.push('Expression does not use an allowed call expression');\n }\n return {\n errors,\n };\n }\n\n // 4. Static literals (string, number, boolean, null)\n if (t.isStringLiteral(expr)) {\n return { errors };\n }\n\n if (t.isNumericLiteral(expr)) {\n return { errors };\n }\n\n if (t.isBooleanLiteral(expr)) {\n return { errors };\n }\n\n if (t.isNullLiteral(expr)) {\n return { errors };\n }\n\n // Fallthrough: expression type not supported (e.g., plain identifiers/variables)\n errors.push('Variables are not allowed');\n return { errors };\n}\n\n/**\n * Takes in a call expression to check if:\n * - it has exactly one argument\n * - the argument is a call expression\n * Example: derive(getName())\n */\nfunction validateDeriveCallExpression(\n expr: t.CallExpression,\n errors: string[]\n): {\n errors: string[];\n} {\n // Validate that the function has 1 argument\n if (expr.arguments.length !== 1) {\n errors.push('derive() must have one argument');\n return { errors };\n }\n const [onlyArg] = expr.arguments;\n\n // Await expression: derive(await ...)\n if (t.isAwaitExpression(onlyArg)) {\n // Validate that the awaited expression is a call expression\n if (!t.isCallExpression(onlyArg.argument)) {\n errors.push('derive() must have a call expression as the argument');\n return { errors };\n }\n // Valid: derive(await someFunction())\n return { errors };\n }\n\n // Validate that the argument is a call expression\n if (!t.isCallExpression(onlyArg)) {\n errors.push('derive() must have a call expression as the argument');\n return { errors };\n }\n\n return { errors };\n}\n\n/**\n * Validate that an expression is a number literal\n */\nfunction validateExpressionIsNumericLiteral(expr: t.Expression): {\n errors: string[];\n value?: number;\n} {\n let candidateValue: number | undefined;\n if (t.isNumericLiteral(expr)) {\n candidateValue = expr.value;\n } else if (t.isUnaryExpression(expr) && t.isNumericLiteral(expr.argument)) {\n // Note: taking the absolute value of the number literal\n candidateValue = expr.argument.value;\n }\n\n // validate is integer\n if (candidateValue !== undefined && !Number.isInteger(candidateValue)) {\n return { errors: ['Expression is not an integer'] };\n }\n\n // no value found\n if (candidateValue === undefined) {\n return { errors: ['Expression is not a number literal'] };\n }\n\n return { errors: [], value: candidateValue };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoBA,SAAgB,4BACd,cACA,OAUA;;CACA,MAAM,WAAW,aAAa;CAC9B,MAAM,SAAmB,EAAE;AAG3B,KAAI,SAAS,UAAU,SAAS,GAAG;AACjC,SAAO,KAAK,sDAAsD;AAClE,SAAO,EAAE,QAAQ;;AAInB,KAAI,CAACA,aAAE,aAAa,SAAS,UAAU,GAAG,EAAE;AAC1C,SAAO,KACL,2HACD;AACD,SAAO,EAAE,QAAQ;;CAInB,MAAM,2BAA2BC,yDAAAA,wBAC/B,aAAa,IAAI,YAAY,CAAC,GAC/B;CAED,MAAM,WAAA,wBAAU,yBAAyB,YAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAS;CAClD,MAAM,mBAAmB,2BACvB,yBAAyB,QACzB,MACD;AAED,KAAI,iBAAiB,SAAS,EAC5B,QAAO,EAAE,QAAQ,kBAAkB;AAGrC,KAAI,YAAY,KAAA,KAAa,CAAC,MAAM,SAAS,WAAW,SAAS;AAE/D,iBAAe,SAAS,UAAU,IAAI,OAAO,OAAO;AACpD,MAAI,OAAO,SAAS,GAAG;AACrB,UAAO,KACL,GAAG,2BAA2B,yBAAyB,OAAO,CAC/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,QAAO,EAAE,QAAQ,CAAC,+BAA+B,EAAE;AAIrD,KAAI,mBAAmB,KAAA,EACrB,QAAO,EAAE,QAAQ,CAAC,qCAAqC,EAAE;AAG3D,QAAO;EAAE,QAAQ,EAAE;EAAE,OAAO;EAAgB"}
@@ -9,7 +9,6 @@ export declare enum GT_COMPONENT_TYPES {
9
9
  DateTime = "DateTime",
10
10
  RelativeTime = "RelativeTime",
11
11
  Num = "Num",
12
- Static = "Static",
13
12
  Derive = "Derive",
14
13
  Branch = "Branch",
15
14
  Plural = "Plural",
@@ -36,7 +35,6 @@ export declare enum GT_FUNCTIONS_WITH_CALLBACKS {
36
35
  */
37
36
  export declare enum GT_OTHER_FUNCTIONS {
38
37
  msg = "msg",
39
- declareStatic = "declareStatic",
40
38
  t = "t",
41
39
  derive = "derive",
42
40
  GtInternalRuntimeTranslateString = "GtInternalRuntimeTranslateString",
@@ -64,7 +62,7 @@ export declare const GT_FUNCTIONS_TO_CALLBACKS: Record<GT_FUNCTIONS_WITH_CALLBAC
64
62
  /**
65
63
  * GT derive functions
66
64
  */
67
- export declare const GT_DERIVE_STRING_FUNCTIONS: readonly [GT_OTHER_FUNCTIONS.declareStatic, GT_OTHER_FUNCTIONS.derive];
65
+ export declare const GT_DERIVE_STRING_FUNCTIONS: readonly [GT_OTHER_FUNCTIONS.derive];
68
66
  /**
69
67
  * All gt functions (both regular and callback functions)
70
68
  */
@@ -74,7 +72,6 @@ export type GT_ALL_FUNCTIONS = GT_FUNCTIONS | GT_CALLBACK_FUNCTIONS | GT_COMPONE
74
72
  */
75
73
  export declare enum GT_IMPORT_SOURCES {
76
74
  GT_NEXT = "gt-next",
77
- GT_NEXT_CLIENT = "gt-next/client",
78
75
  GT_NEXT_SERVER = "gt-next/server",
79
76
  GT_REACT = "gt-react",
80
77
  GT_REACT_CLIENT = "gt-react/client",
@@ -119,7 +116,6 @@ export declare const MINIFY_CANONICAL_NAME_MAP: {
119
116
  readonly DateTime: "d";
120
117
  readonly GtInternalDateTime: "d";
121
118
  readonly RelativeTime: "rt";
122
- readonly Static: "s";
123
119
  readonly Derive: "s";
124
120
  readonly Branch: "b";
125
121
  readonly Plural: "p";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/utils/constants/gt/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,CAAC,MAAM;IACP,EAAE,OAAO;IACT,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,sBAAsB,2BAA2B;IACjD,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;CAC1C;AAED;;GAEG;AACH,oBAAY,2BAA2B;IACrC,KAAK,UAAU;IACf,KAAK,UAAU;IACf,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;CAC5B;AAED;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,GAAG,QAAQ;IACX,aAAa,kBAAkB;IAC/B,CAAC,MAAM;IACP,MAAM,WAAW;IACjB,gCAAgC,qCAAqC;IACrE,6BAA6B,kCAAkC;CAChE;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,2BAA2B,GAAG,kBAAkB,CAAC;AAC5E;;GAEG;AACH,oBAAY,qBAAqB;IAC/B,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,wBAAwB,6BAA6B;IACrD,wBAAwB,6BAA6B;IACrD,oBAAoB,yBAAyB;IAC7C,oBAAoB,yBAAyB;CAC9C;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAC5C,2BAA2B,EAC3B,qBAAqB,CAYtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,wEAG7B,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;IACjC,QAAQ,aAAa;IACrB,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;IACrC,OAAO,YAAY;CACpB;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,aAAsB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,aAA4B,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,YAAY,aAUvB,CAAC;AAEH;;GAEG;AACH,oBAAY,sBAAsB;IAChC,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;CAc5B,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/utils/constants/gt/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,CAAC,MAAM;IACP,EAAE,OAAO;IACT,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,cAAc,mBAAmB;IACjC,sBAAsB,2BAA2B;IACjD,aAAa,kBAAkB;IAC/B,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IACzC,kBAAkB,uBAAuB;CAC1C;AAED;;GAEG;AACH,oBAAY,2BAA2B;IACrC,KAAK,UAAU;IACf,KAAK,UAAU;IACf,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC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(GT_COMPONENT_TYPES) {
11
11
  GT_COMPONENT_TYPES["DateTime"] = "DateTime";
12
12
  GT_COMPONENT_TYPES["RelativeTime"] = "RelativeTime";
13
13
  GT_COMPONENT_TYPES["Num"] = "Num";
14
- GT_COMPONENT_TYPES["Static"] = "Static";
15
14
  GT_COMPONENT_TYPES["Derive"] = "Derive";
16
15
  GT_COMPONENT_TYPES["Branch"] = "Branch";
17
16
  GT_COMPONENT_TYPES["Plural"] = "Plural";
@@ -40,7 +39,6 @@ let GT_FUNCTIONS_WITH_CALLBACKS = /* @__PURE__ */ function(GT_FUNCTIONS_WITH_CAL
40
39
  */
41
40
  let GT_OTHER_FUNCTIONS = /* @__PURE__ */ function(GT_OTHER_FUNCTIONS) {
42
41
  GT_OTHER_FUNCTIONS["msg"] = "msg";
43
- GT_OTHER_FUNCTIONS["declareStatic"] = "declareStatic";
44
42
  GT_OTHER_FUNCTIONS["t"] = "t";
45
43
  GT_OTHER_FUNCTIONS["derive"] = "derive";
46
44
  GT_OTHER_FUNCTIONS["GtInternalRuntimeTranslateString"] = "GtInternalRuntimeTranslateString";
@@ -73,13 +71,12 @@ const GT_FUNCTIONS_TO_CALLBACKS = {
73
71
  /**
74
72
  * GT derive functions
75
73
  */
76
- const GT_DERIVE_STRING_FUNCTIONS = ["declareStatic", "derive"];
74
+ const GT_DERIVE_STRING_FUNCTIONS = ["derive"];
77
75
  /**
78
76
  * GT import sources
79
77
  */
80
78
  let GT_IMPORT_SOURCES = /* @__PURE__ */ function(GT_IMPORT_SOURCES) {
81
79
  GT_IMPORT_SOURCES["GT_NEXT"] = "gt-next";
82
- GT_IMPORT_SOURCES["GT_NEXT_CLIENT"] = "gt-next/client";
83
80
  GT_IMPORT_SOURCES["GT_NEXT_SERVER"] = "gt-next/server";
84
81
  GT_IMPORT_SOURCES["GT_REACT"] = "gt-react";
85
82
  GT_IMPORT_SOURCES["GT_REACT_CLIENT"] = "gt-react/client";
@@ -136,7 +133,6 @@ const MINIFY_CANONICAL_NAME_MAP = {
136
133
  ["DateTime"]: "d",
137
134
  ["GtInternalDateTime"]: "d",
138
135
  ["RelativeTime"]: "rt",
139
- ["Static"]: "s",
140
136
  ["Derive"]: "s",
141
137
  ["Branch"]: "b",
142
138
  ["Plural"]: "p"
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../../../../src/utils/constants/gt/constants.ts"],"sourcesContent":["/**\n * Different gt components\n */\nexport enum GT_COMPONENT_TYPES {\n T = 'T',\n Tx = 'Tx',\n Var = 'Var',\n Currency = 'Currency',\n DateTime = 'DateTime',\n RelativeTime = 'RelativeTime',\n Num = 'Num',\n Static = 'Static',\n Derive = 'Derive',\n Branch = 'Branch',\n Plural = 'Plural',\n LocaleSelector = 'LocaleSelector',\n GtInternalTranslateJsx = 'GtInternalTranslateJsx',\n GtInternalVar = 'GtInternalVar',\n GtInternalNum = 'GtInternalNum',\n GtInternalCurrency = 'GtInternalCurrency',\n GtInternalDateTime = 'GtInternalDateTime',\n}\n\n/**\n * GT functions that produce callbacks\n */\nexport enum GT_FUNCTIONS_WITH_CALLBACKS {\n useGT = 'useGT',\n getGT = 'getGT',\n useTranslations = 'useTranslations',\n getTranslations = 'getTranslations',\n useMessages = 'useMessages',\n getMessages = 'getMessages',\n}\n\n/**\n * Other GT functions\n */\nexport enum GT_OTHER_FUNCTIONS {\n msg = 'msg',\n declareStatic = 'declareStatic',\n t = 't',\n derive = 'derive',\n GtInternalRuntimeTranslateString = 'GtInternalRuntimeTranslateString',\n GtInternalRuntimeTranslateJsx = 'GtInternalRuntimeTranslateJsx',\n}\n\n/**\n * Different gt functions\n */\nexport type GT_FUNCTIONS = GT_FUNCTIONS_WITH_CALLBACKS | GT_OTHER_FUNCTIONS;\n/**\n * gt callback functions\n */\nexport enum GT_CALLBACK_FUNCTIONS {\n useGT_callback = 'useGT_callback',\n getGT_callback = 'getGT_callback',\n useTranslations_callback = 'useTranslations_callback',\n getTranslations_callback = 'getTranslations_callback',\n useMessages_callback = 'useMessages_callback',\n getMessages_callback = 'getMessages_callback',\n}\n\n/**\n * Maps GT Functions to their callback functions\n */\nexport const GT_FUNCTIONS_TO_CALLBACKS: Record<\n GT_FUNCTIONS_WITH_CALLBACKS,\n GT_CALLBACK_FUNCTIONS\n> = {\n [GT_FUNCTIONS_WITH_CALLBACKS.useGT]: GT_CALLBACK_FUNCTIONS.useGT_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.getGT]: GT_CALLBACK_FUNCTIONS.getGT_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.useTranslations]:\n GT_CALLBACK_FUNCTIONS.useTranslations_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.getTranslations]:\n GT_CALLBACK_FUNCTIONS.getTranslations_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.useMessages]:\n GT_CALLBACK_FUNCTIONS.useMessages_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.getMessages]:\n GT_CALLBACK_FUNCTIONS.getMessages_callback,\n};\n\n/**\n * GT derive functions\n */\nexport const GT_DERIVE_STRING_FUNCTIONS = [\n GT_OTHER_FUNCTIONS.declareStatic,\n GT_OTHER_FUNCTIONS.derive,\n] as const;\n\n/**\n * All gt functions (both regular and callback functions)\n */\nexport type GT_ALL_FUNCTIONS =\n | GT_FUNCTIONS\n | GT_CALLBACK_FUNCTIONS\n | GT_COMPONENT_TYPES;\n\n/**\n * GT import sources\n */\nexport enum GT_IMPORT_SOURCES {\n GT_NEXT = 'gt-next',\n GT_NEXT_CLIENT = 'gt-next/client',\n GT_NEXT_SERVER = 'gt-next/server',\n GT_REACT = 'gt-react',\n GT_REACT_CLIENT = 'gt-react/client',\n GT_REACT_BROWSER = 'gt-react/browser',\n GT_I18N = 'gt-i18n',\n}\n\n/**\n * Branch control props — not translatable content.\n * `branch` is the selector key; `data-*` props are HTML attributes ignored at runtime.\n * `data-*` is handled as a prefix check, not listed here.\n */\nexport const BRANCH_CONTROL_PROPS = new Set(['branch']);\n\n/**\n * Plural control props — not translatable content.\n * `n` is the count, `locales` is the locale hint.\n */\nexport const PLURAL_CONTROL_PROPS = new Set(['n', 'locales']);\n\n/**\n * Set of valid plural forms for Plural components\n */\nexport const PLURAL_FORMS = new Set([\n 'singular',\n 'plural',\n 'dual',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n 'other',\n]);\n\n/**\n * Fields that must be string literals for useGT_callback / getGT_callback\n */\nexport enum USEGT_CALLBACK_OPTIONS {\n $id = '$id',\n $context = '$context',\n $maxChars = '$maxChars',\n $_hash = '$_hash',\n $format = '$format',\n}\n\n/**\n * Maps GT Component Types to their minified names\n */\nexport const MINIFY_CANONICAL_NAME_MAP = {\n [GT_COMPONENT_TYPES.Var]: 'v',\n [GT_COMPONENT_TYPES.GtInternalVar]: 'v',\n [GT_COMPONENT_TYPES.Num]: 'n',\n [GT_COMPONENT_TYPES.GtInternalNum]: 'n',\n [GT_COMPONENT_TYPES.Currency]: 'c',\n [GT_COMPONENT_TYPES.GtInternalCurrency]: 'c',\n [GT_COMPONENT_TYPES.DateTime]: 'd',\n [GT_COMPONENT_TYPES.GtInternalDateTime]: 'd',\n [GT_COMPONENT_TYPES.RelativeTime]: 'rt',\n [GT_COMPONENT_TYPES.Static]: 's',\n [GT_COMPONENT_TYPES.Derive]: 's',\n [GT_COMPONENT_TYPES.Branch]: 'b',\n [GT_COMPONENT_TYPES.Plural]: 'p',\n} as const;\n"],"mappings":";;;;;AAGA,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,OAAA;AACA,oBAAA,QAAA;AACA,oBAAA,SAAA;AACA,oBAAA,cAAA;AACA,oBAAA,cAAA;AACA,oBAAA,kBAAA;AACA,oBAAA,SAAA;AACA,oBAAA,YAAA;AACA,oBAAA,YAAA;AACA,oBAAA,YAAA;AACA,oBAAA,YAAA;AACA,oBAAA,oBAAA;AACA,oBAAA,4BAAA;AACA,oBAAA,mBAAA;AACA,oBAAA,mBAAA;AACA,oBAAA,wBAAA;AACA,oBAAA,wBAAA;;KACD;;;;AAKD,IAAY,8BAAL,yBAAA,6BAAA;AACL,6BAAA,WAAA;AACA,6BAAA,WAAA;AACA,6BAAA,qBAAA;AACA,6BAAA,qBAAA;AACA,6BAAA,iBAAA;AACA,6BAAA,iBAAA;;KACD;;;;AAKD,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,SAAA;AACA,oBAAA,mBAAA;AACA,oBAAA,OAAA;AACA,oBAAA,YAAA;AACA,oBAAA,sCAAA;AACA,oBAAA,mCAAA;;KACD;;;;AASD,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,oBAAA;AACA,uBAAA,oBAAA;AACA,uBAAA,8BAAA;AACA,uBAAA,8BAAA;AACA,uBAAA,0BAAA;AACA,uBAAA,0BAAA;;KACD;;;;AAKD,MAAa,4BAGT;;;;;;;CAWH;;;;AAKD,MAAa,6BAA6B,CAAA,iBAAA,SAGzC;;;;AAaD,IAAY,oBAAL,yBAAA,mBAAA;AACL,mBAAA,aAAA;AACA,mBAAA,oBAAA;AACA,mBAAA,oBAAA;AACA,mBAAA,cAAA;AACA,mBAAA,qBAAA;AACA,mBAAA,sBAAA;AACA,mBAAA,aAAA;;KACD;;;;;;AAOD,MAAa,uBAAuB,IAAI,IAAI,CAAC,SAAS,CAAC;;;;;AAMvD,MAAa,uBAAuB,IAAI,IAAI,CAAC,KAAK,UAAU,CAAC;;;;AAK7D,MAAa,eAAe,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;AAKF,IAAY,yBAAL,yBAAA,wBAAA;AACL,wBAAA,SAAA;AACA,wBAAA,cAAA;AACA,wBAAA,eAAA;AACA,wBAAA,YAAA;AACA,wBAAA,aAAA;;KACD;;;;AAKD,MAAa,4BAA4B;UACb;oBACU;UACV;oBACU;eACL;yBACU;eACV;yBACU;mBACN;aACN;aACA;aACA;aACA;CAC9B"}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../../../../src/utils/constants/gt/constants.ts"],"sourcesContent":["/**\n * Different gt components\n */\nexport enum GT_COMPONENT_TYPES {\n T = 'T',\n Tx = 'Tx',\n Var = 'Var',\n Currency = 'Currency',\n DateTime = 'DateTime',\n RelativeTime = 'RelativeTime',\n Num = 'Num',\n Derive = 'Derive',\n Branch = 'Branch',\n Plural = 'Plural',\n LocaleSelector = 'LocaleSelector',\n GtInternalTranslateJsx = 'GtInternalTranslateJsx',\n GtInternalVar = 'GtInternalVar',\n GtInternalNum = 'GtInternalNum',\n GtInternalCurrency = 'GtInternalCurrency',\n GtInternalDateTime = 'GtInternalDateTime',\n}\n\n/**\n * GT functions that produce callbacks\n */\nexport enum GT_FUNCTIONS_WITH_CALLBACKS {\n useGT = 'useGT',\n getGT = 'getGT',\n useTranslations = 'useTranslations',\n getTranslations = 'getTranslations',\n useMessages = 'useMessages',\n getMessages = 'getMessages',\n}\n\n/**\n * Other GT functions\n */\nexport enum GT_OTHER_FUNCTIONS {\n msg = 'msg',\n t = 't',\n derive = 'derive',\n GtInternalRuntimeTranslateString = 'GtInternalRuntimeTranslateString',\n GtInternalRuntimeTranslateJsx = 'GtInternalRuntimeTranslateJsx',\n}\n\n/**\n * Different gt functions\n */\nexport type GT_FUNCTIONS = GT_FUNCTIONS_WITH_CALLBACKS | GT_OTHER_FUNCTIONS;\n/**\n * gt callback functions\n */\nexport enum GT_CALLBACK_FUNCTIONS {\n useGT_callback = 'useGT_callback',\n getGT_callback = 'getGT_callback',\n useTranslations_callback = 'useTranslations_callback',\n getTranslations_callback = 'getTranslations_callback',\n useMessages_callback = 'useMessages_callback',\n getMessages_callback = 'getMessages_callback',\n}\n\n/**\n * Maps GT Functions to their callback functions\n */\nexport const GT_FUNCTIONS_TO_CALLBACKS: Record<\n GT_FUNCTIONS_WITH_CALLBACKS,\n GT_CALLBACK_FUNCTIONS\n> = {\n [GT_FUNCTIONS_WITH_CALLBACKS.useGT]: GT_CALLBACK_FUNCTIONS.useGT_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.getGT]: GT_CALLBACK_FUNCTIONS.getGT_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.useTranslations]:\n GT_CALLBACK_FUNCTIONS.useTranslations_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.getTranslations]:\n GT_CALLBACK_FUNCTIONS.getTranslations_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.useMessages]:\n GT_CALLBACK_FUNCTIONS.useMessages_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.getMessages]:\n GT_CALLBACK_FUNCTIONS.getMessages_callback,\n};\n\n/**\n * GT derive functions\n */\nexport const GT_DERIVE_STRING_FUNCTIONS = [GT_OTHER_FUNCTIONS.derive] as const;\n\n/**\n * All gt functions (both regular and callback functions)\n */\nexport type GT_ALL_FUNCTIONS =\n | GT_FUNCTIONS\n | GT_CALLBACK_FUNCTIONS\n | GT_COMPONENT_TYPES;\n\n/**\n * GT import sources\n */\nexport enum GT_IMPORT_SOURCES {\n GT_NEXT = 'gt-next',\n GT_NEXT_SERVER = 'gt-next/server',\n GT_REACT = 'gt-react',\n GT_REACT_CLIENT = 'gt-react/client',\n GT_REACT_BROWSER = 'gt-react/browser',\n GT_I18N = 'gt-i18n',\n}\n\n/**\n * Branch control props — not translatable content.\n * `branch` is the selector key; `data-*` props are HTML attributes ignored at runtime.\n * `data-*` is handled as a prefix check, not listed here.\n */\nexport const BRANCH_CONTROL_PROPS = new Set(['branch']);\n\n/**\n * Plural control props — not translatable content.\n * `n` is the count, `locales` is the locale hint.\n */\nexport const PLURAL_CONTROL_PROPS = new Set(['n', 'locales']);\n\n/**\n * Set of valid plural forms for Plural components\n */\nexport const PLURAL_FORMS = new Set([\n 'singular',\n 'plural',\n 'dual',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n 'other',\n]);\n\n/**\n * Fields that must be string literals for useGT_callback / getGT_callback\n */\nexport enum USEGT_CALLBACK_OPTIONS {\n $id = '$id',\n $context = '$context',\n $maxChars = '$maxChars',\n $_hash = '$_hash',\n $format = '$format',\n}\n\n/**\n * Maps GT Component Types to their minified names\n */\nexport const MINIFY_CANONICAL_NAME_MAP = {\n [GT_COMPONENT_TYPES.Var]: 'v',\n [GT_COMPONENT_TYPES.GtInternalVar]: 'v',\n [GT_COMPONENT_TYPES.Num]: 'n',\n [GT_COMPONENT_TYPES.GtInternalNum]: 'n',\n [GT_COMPONENT_TYPES.Currency]: 'c',\n [GT_COMPONENT_TYPES.GtInternalCurrency]: 'c',\n [GT_COMPONENT_TYPES.DateTime]: 'd',\n [GT_COMPONENT_TYPES.GtInternalDateTime]: 'd',\n [GT_COMPONENT_TYPES.RelativeTime]: 'rt',\n [GT_COMPONENT_TYPES.Derive]: 's',\n [GT_COMPONENT_TYPES.Branch]: 'b',\n [GT_COMPONENT_TYPES.Plural]: 'p',\n} as const;\n"],"mappings":";;;;;AAGA,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,OAAA;AACA,oBAAA,QAAA;AACA,oBAAA,SAAA;AACA,oBAAA,cAAA;AACA,oBAAA,cAAA;AACA,oBAAA,kBAAA;AACA,oBAAA,SAAA;AACA,oBAAA,YAAA;AACA,oBAAA,YAAA;AACA,oBAAA,YAAA;AACA,oBAAA,oBAAA;AACA,oBAAA,4BAAA;AACA,oBAAA,mBAAA;AACA,oBAAA,mBAAA;AACA,oBAAA,wBAAA;AACA,oBAAA,wBAAA;;KACD;;;;AAKD,IAAY,8BAAL,yBAAA,6BAAA;AACL,6BAAA,WAAA;AACA,6BAAA,WAAA;AACA,6BAAA,qBAAA;AACA,6BAAA,qBAAA;AACA,6BAAA,iBAAA;AACA,6BAAA,iBAAA;;KACD;;;;AAKD,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,SAAA;AACA,oBAAA,OAAA;AACA,oBAAA,YAAA;AACA,oBAAA,sCAAA;AACA,oBAAA,mCAAA;;KACD;;;;AASD,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,oBAAA;AACA,uBAAA,oBAAA;AACA,uBAAA,8BAAA;AACA,uBAAA,8BAAA;AACA,uBAAA,0BAAA;AACA,uBAAA,0BAAA;;KACD;;;;AAKD,MAAa,4BAGT;;;;;;;CAWH;;;;AAKD,MAAa,6BAA6B,CAAA,SAA2B;;;;AAarE,IAAY,oBAAL,yBAAA,mBAAA;AACL,mBAAA,aAAA;AACA,mBAAA,oBAAA;AACA,mBAAA,cAAA;AACA,mBAAA,qBAAA;AACA,mBAAA,sBAAA;AACA,mBAAA,aAAA;;KACD;;;;;;AAOD,MAAa,uBAAuB,IAAI,IAAI,CAAC,SAAS,CAAC;;;;;AAMvD,MAAa,uBAAuB,IAAI,IAAI,CAAC,KAAK,UAAU,CAAC;;;;AAK7D,MAAa,eAAe,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;AAKF,IAAY,yBAAL,yBAAA,wBAAA;AACL,wBAAA,SAAA;AACA,wBAAA,cAAA;AACA,wBAAA,eAAA;AACA,wBAAA,YAAA;AACA,wBAAA,aAAA;;KACD;;;;AAKD,MAAa,4BAA4B;UACb;oBACU;UACV;oBACU;eACL;yBACU;eACV;yBACU;mBACN;aACN;aACA;aACA;CAC9B"}
@@ -49,6 +49,8 @@ export declare function isTranslationFunctionCallback(name: string): name is GT_
49
49
  * Check if it's a GT import source
50
50
  */
51
51
  export declare function isGTImportSource(name: string): name is GT_IMPORT_SOURCES;
52
+ export declare function isGTReactImportSource(name: string): name is GT_IMPORT_SOURCES.GT_REACT | GT_IMPORT_SOURCES.GT_REACT_CLIENT | GT_IMPORT_SOURCES.GT_REACT_BROWSER;
53
+ export declare function getGtReactImportSource(legacyGtReactImportSource: boolean): GT_IMPORT_SOURCES.GT_REACT | GT_IMPORT_SOURCES.GT_REACT_BROWSER;
52
54
  /**
53
55
  * Check if is a html content prop
54
56
  */
@@ -71,7 +73,6 @@ export declare const defaultVariableNames: {
71
73
  readonly Currency: "cost";
72
74
  readonly GtInternalCurrency: "cost";
73
75
  readonly Derive: "static";
74
- readonly Static: "static";
75
76
  };
76
77
  /**
77
78
  * Get the variable name
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/utils/constants/gt/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EAElB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,gBAAgB,CAiCnE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,2BAA2B,CASrC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAEtE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,kBAAkB,CAAC,CAAC,CAK9B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAc5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAI1E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAI1E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,OAAO,GAAG,OAAO,CAE7E;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,qBAAqB,CAS/B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI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AI,IAAI,kBAAkB,CAE1E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAI1E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,OAAO,GAAG,OAAO,CAE7E;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,qBAAqB,CAS/B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,iBAAiB,CAWxE;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,GACX,IAAI,IACH,iBAAiB,CAAC,QAAQ,GAC1B,iBAAiB,CAAC,eAAe,GACjC,iBAAiB,CAAC,gBAAgB,CAQrC;AAED,wBAAgB,sBAAsB,CACpC,yBAAyB,EAAE,OAAO,GACjC,iBAAiB,CAAC,QAAQ,GAAG,iBAAiB,CAAC,gBAAgB,CAIjE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,MAAM,2BAA2B,CAI3C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,GAAG,MAAM,CAM7E;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAWvB,CAAC;AAGX;;GAEG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,OAAO,oBAAoB,EAC/C,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAIR"}
@@ -21,6 +21,7 @@ function isGTFunction(name) {
21
21
  "getMessages",
22
22
  "msg",
23
23
  "t",
24
+ "derive",
24
25
  "useGT_callback",
25
26
  "getGT_callback",
26
27
  "useTranslations_callback",
@@ -30,7 +31,6 @@ function isGTFunction(name) {
30
31
  "T",
31
32
  "Tx",
32
33
  "Var",
33
- "Static",
34
34
  "Derive",
35
35
  "Currency",
36
36
  "DateTime",
@@ -94,7 +94,7 @@ function isVariableComponent(name) {
94
94
  * Check if a name is a GT derive component
95
95
  */
96
96
  function isDeriveComponent(name) {
97
- return ["Derive", "Static"].includes(name);
97
+ return name === "Derive";
98
98
  }
99
99
  /**
100
100
  * Check if a name is a GT branch component
@@ -127,7 +127,6 @@ function isTranslationFunctionCallback(name) {
127
127
  function isGTImportSource(name) {
128
128
  return [
129
129
  "gt-next",
130
- "gt-next/client",
131
130
  "gt-next/server",
132
131
  "gt-react",
133
132
  "gt-react/client",
@@ -135,6 +134,16 @@ function isGTImportSource(name) {
135
134
  "gt-i18n"
136
135
  ].includes(name);
137
136
  }
137
+ function isGTReactImportSource(name) {
138
+ return [
139
+ "gt-react",
140
+ "gt-react/client",
141
+ "gt-react/browser"
142
+ ].includes(name);
143
+ }
144
+ function getGtReactImportSource(legacyGtReactImportSource) {
145
+ return legacyGtReactImportSource ? "gt-react/browser" : "gt-react";
146
+ }
138
147
  /**
139
148
  * Check if is a html content prop
140
149
  */
@@ -160,8 +169,7 @@ const defaultVariableNames = {
160
169
  ["RelativeTime"]: "time",
161
170
  ["Currency"]: "cost",
162
171
  ["GtInternalCurrency"]: "cost",
163
- ["Derive"]: "static",
164
- ["Static"]: "static"
172
+ ["Derive"]: "static"
165
173
  };
166
174
  const baseVariablePrefix = "_gt_";
167
175
  /**
@@ -173,6 +181,7 @@ function getVariableName(variableType, id, name) {
173
181
  }
174
182
  //#endregion
175
183
  exports.defaultVariableNames = defaultVariableNames;
184
+ exports.getGtReactImportSource = getGtReactImportSource;
176
185
  exports.getVariableName = getVariableName;
177
186
  exports.isBranchComponent = isBranchComponent;
178
187
  exports.isDeriveComponent = isDeriveComponent;
@@ -180,6 +189,7 @@ exports.isGTComponent = isGTComponent;
180
189
  exports.isGTFunction = isGTFunction;
181
190
  exports.isGTFunctionWithCallbacks = isGTFunctionWithCallbacks;
182
191
  exports.isGTImportSource = isGTImportSource;
192
+ exports.isGTReactImportSource = isGTReactImportSource;
183
193
  exports.isHtmlContentProp = isHtmlContentProp;
184
194
  exports.isTranslationComponent = isTranslationComponent;
185
195
  exports.isTranslationFunction = isTranslationFunction;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","names":["GT_COMPONENT_TYPES","HTML_CONTENT_PROPS","MINIFY_CANONICAL_NAME_MAP"],"sources":["../../../../src/utils/constants/gt/helpers.ts"],"sourcesContent":["/**\n * Analysis utilities for identifying GT components and functions\n */\n\nimport {\n GT_ALL_FUNCTIONS,\n GT_CALLBACK_FUNCTIONS,\n GT_COMPONENT_TYPES,\n GT_FUNCTIONS_WITH_CALLBACKS,\n GT_IMPORT_SOURCES,\n MINIFY_CANONICAL_NAME_MAP,\n} from './constants';\nimport {\n HTML_CONTENT_PROPS,\n HtmlContentPropValuesRecord,\n} from '@generaltranslation/format/types';\n\n/**\n * Check if a name is a GT function\n * @param name - The name to check\n * @returns True if the name is a GT function\n */\nexport function isGTFunction(name: string): name is GT_ALL_FUNCTIONS {\n return [\n 'useGT',\n 'getGT',\n 'useTranslations',\n 'getTranslations',\n 'useMessages',\n 'getMessages',\n 'msg',\n 't',\n 'useGT_callback',\n 'getGT_callback',\n 'useTranslations_callback',\n 'getTranslations_callback',\n 'useMessages_callback',\n 'getMessages_callback',\n 'T',\n 'Tx',\n 'Var',\n 'Static',\n 'Derive',\n 'Currency',\n 'DateTime',\n 'RelativeTime',\n 'Num',\n 'Branch',\n 'Plural',\n 'GtInternalTranslateJsx',\n 'GtInternalVar',\n 'GtInternalNum',\n 'GtInternalCurrency',\n 'GtInternalDateTime',\n ].includes(name);\n}\n\n/**\n * Check if a name is a GT function with callbacks\n * @param name - The name to check\n * @returns True if the name is a GT function with callbacks\n */\nexport function isGTFunctionWithCallbacks(\n name: string\n): name is GT_FUNCTIONS_WITH_CALLBACKS {\n return [\n 'useGT',\n 'getGT',\n 'useTranslations',\n 'getTranslations',\n 'useMessages',\n 'getMessages',\n ].includes(name);\n}\n\n/**\n * Check if a name is a GT component\n * @param name - The name to check\n * @returns True if the name is a GT component\n */\nexport function isGTComponent(name: string): name is GT_COMPONENT_TYPES {\n return Object.values(GT_COMPONENT_TYPES).includes(name as GT_COMPONENT_TYPES);\n}\n\n/**\n * Check if a component name matches known gt-next translation components\n */\nexport function isTranslationComponent(\n name: string\n): name is GT_COMPONENT_TYPES.T {\n return [\n GT_COMPONENT_TYPES.T,\n GT_COMPONENT_TYPES.GtInternalTranslateJsx,\n ].includes(name as GT_COMPONENT_TYPES);\n}\n\n/**\n * Check if a component name matches known gt-next variable components\n */\nexport function isVariableComponent(name: string): name is GT_COMPONENT_TYPES {\n return (\n [\n GT_COMPONENT_TYPES.Var,\n GT_COMPONENT_TYPES.Num,\n GT_COMPONENT_TYPES.Currency,\n GT_COMPONENT_TYPES.DateTime,\n GT_COMPONENT_TYPES.RelativeTime,\n GT_COMPONENT_TYPES.GtInternalVar,\n GT_COMPONENT_TYPES.GtInternalNum,\n GT_COMPONENT_TYPES.GtInternalCurrency,\n GT_COMPONENT_TYPES.GtInternalDateTime,\n ] as string[]\n ).includes(name);\n}\n\n/**\n * Check if a name is a GT derive component\n */\nexport function isDeriveComponent(name: string): name is GT_COMPONENT_TYPES {\n return [GT_COMPONENT_TYPES.Derive, GT_COMPONENT_TYPES.Static].includes(\n name as GT_COMPONENT_TYPES\n );\n}\n\n/**\n * Check if a name is a GT branch component\n */\nexport function isBranchComponent(name: string): name is GT_COMPONENT_TYPES {\n return (\n [GT_COMPONENT_TYPES.Branch, GT_COMPONENT_TYPES.Plural] as string[]\n ).includes(name);\n}\n\n/**\n * Check if a name is a GT translation function\n */\nexport function isTranslationFunction(name: string): name is 'useGT' | 'getGT' {\n return ['useGT', 'getGT'].includes(name);\n}\n\n/**\n * Check if it's a translation function callback (const t = useGT())\n */\nexport function isTranslationFunctionCallback(\n name: string\n): name is GT_CALLBACK_FUNCTIONS {\n return [\n 'useGT_callback',\n 'getGT_callback',\n 'useTranslations_callback',\n 'getTranslations_callback',\n 'useMessages_callback',\n 'getMessages_callback',\n ].includes(name);\n}\n\n/**\n * Check if it's a GT import source\n */\nexport function isGTImportSource(name: string): name is GT_IMPORT_SOURCES {\n return (\n [\n GT_IMPORT_SOURCES.GT_NEXT,\n GT_IMPORT_SOURCES.GT_NEXT_CLIENT,\n GT_IMPORT_SOURCES.GT_NEXT_SERVER,\n GT_IMPORT_SOURCES.GT_REACT,\n GT_IMPORT_SOURCES.GT_REACT_CLIENT,\n GT_IMPORT_SOURCES.GT_REACT_BROWSER,\n GT_IMPORT_SOURCES.GT_I18N,\n ] as string[]\n ).includes(name);\n}\n\n/**\n * Check if is a html content prop\n */\nexport function isHtmlContentProp(\n name: string\n): name is keyof HtmlContentPropValuesRecord {\n return Object.values(HTML_CONTENT_PROPS).includes(\n name as keyof HtmlContentPropValuesRecord\n );\n}\n\n/**\n * Minify the canonical name\n */\nexport function minifyCanonicalName(canonicalName: GT_COMPONENT_TYPES): string {\n return (\n MINIFY_CANONICAL_NAME_MAP[\n canonicalName as keyof typeof MINIFY_CANONICAL_NAME_MAP\n ] || canonicalName\n );\n}\n\n/**\n * Default variable names\n */\nexport const defaultVariableNames = {\n [GT_COMPONENT_TYPES.Var]: 'value',\n [GT_COMPONENT_TYPES.GtInternalVar]: 'value',\n [GT_COMPONENT_TYPES.Num]: 'n',\n [GT_COMPONENT_TYPES.GtInternalNum]: 'n',\n [GT_COMPONENT_TYPES.DateTime]: 'date',\n [GT_COMPONENT_TYPES.GtInternalDateTime]: 'date',\n [GT_COMPONENT_TYPES.RelativeTime]: 'time',\n [GT_COMPONENT_TYPES.Currency]: 'cost',\n [GT_COMPONENT_TYPES.GtInternalCurrency]: 'cost',\n [GT_COMPONENT_TYPES.Derive]: 'static',\n [GT_COMPONENT_TYPES.Static]: 'static',\n} as const;\nconst baseVariablePrefix = '_gt_';\n\n/**\n * Get the variable name\n */\nexport function getVariableName(\n variableType: keyof typeof defaultVariableNames,\n id: number,\n name?: string\n): string {\n if (name) return name;\n const baseVariableName = defaultVariableNames[variableType] || 'value';\n return `${baseVariablePrefix}${baseVariableName}_${id}`;\n}\n"],"mappings":";;;;;;;;;;;;;AAsBA,SAAgB,aAAa,MAAwC;AACnE,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK;;;;;;;AAQlB,SAAgB,0BACd,MACqC;AACrC,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK;;;;;;;AAQlB,SAAgB,cAAc,MAA0C;AACtE,QAAO,OAAO,OAAOA,qCAAAA,mBAAmB,CAAC,SAAS,KAA2B;;;;;AAM/E,SAAgB,uBACd,MAC8B;AAC9B,QAAO,CAAA,KAAA,yBAGN,CAAC,SAAS,KAA2B;;;;;AAMxC,SAAgB,oBAAoB,MAA0C;AAC5E,QACE;;;;;;;;;;EAUC,CACD,SAAS,KAAK;;;;;AAMlB,SAAgB,kBAAkB,MAA0C;AAC1E,QAAO,CAAA,UAAA,SAAsD,CAAC,SAC5D,KACD;;;;;AAMH,SAAgB,kBAAkB,MAA0C;AAC1E,QACE,CAAA,UAAA,SAAsD,CACtD,SAAS,KAAK;;;;;AAMlB,SAAgB,sBAAsB,MAAyC;AAC7E,QAAO,CAAC,SAAS,QAAQ,CAAC,SAAS,KAAK;;;;;AAM1C,SAAgB,8BACd,MAC+B;AAC/B,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK;;;;;AAMlB,SAAgB,iBAAiB,MAAyC;AACxE,QACE;;;;;;;;EAQC,CACD,SAAS,KAAK;;;;;AAMlB,SAAgB,kBACd,MAC2C;AAC3C,QAAO,OAAO,OAAOC,iCAAAA,mBAAmB,CAAC,SACvC,KACD;;;;;AAMH,SAAgB,oBAAoB,eAA2C;AAC7E,QACEC,qCAAAA,0BACE,kBACG;;;;;AAOT,MAAa,uBAAuB;UACR;oBACU;UACV;oBACU;eACL;yBACU;mBACN;eACJ;yBACU;aACZ;aACA;CAC9B;AACD,MAAM,qBAAqB;;;;AAK3B,SAAgB,gBACd,cACA,IACA,MACQ;AACR,KAAI,KAAM,QAAO;AAEjB,QAAO,GAAG,qBADe,qBAAqB,iBAAiB,QACf,GAAG"}
1
+ {"version":3,"file":"helpers.js","names":["GT_COMPONENT_TYPES","HTML_CONTENT_PROPS","MINIFY_CANONICAL_NAME_MAP"],"sources":["../../../../src/utils/constants/gt/helpers.ts"],"sourcesContent":["/**\n * Analysis utilities for identifying GT components and functions\n */\n\nimport {\n GT_ALL_FUNCTIONS,\n GT_CALLBACK_FUNCTIONS,\n GT_COMPONENT_TYPES,\n GT_FUNCTIONS_WITH_CALLBACKS,\n GT_IMPORT_SOURCES,\n MINIFY_CANONICAL_NAME_MAP,\n} from './constants';\nimport {\n HTML_CONTENT_PROPS,\n HtmlContentPropValuesRecord,\n} from '@generaltranslation/format/types';\n\n/**\n * Check if a name is a GT function\n * @param name - The name to check\n * @returns True if the name is a GT function\n */\nexport function isGTFunction(name: string): name is GT_ALL_FUNCTIONS {\n return [\n 'useGT',\n 'getGT',\n 'useTranslations',\n 'getTranslations',\n 'useMessages',\n 'getMessages',\n 'msg',\n 't',\n 'derive',\n 'useGT_callback',\n 'getGT_callback',\n 'useTranslations_callback',\n 'getTranslations_callback',\n 'useMessages_callback',\n 'getMessages_callback',\n 'T',\n 'Tx',\n 'Var',\n 'Derive',\n 'Currency',\n 'DateTime',\n 'RelativeTime',\n 'Num',\n 'Branch',\n 'Plural',\n 'GtInternalTranslateJsx',\n 'GtInternalVar',\n 'GtInternalNum',\n 'GtInternalCurrency',\n 'GtInternalDateTime',\n ].includes(name);\n}\n\n/**\n * Check if a name is a GT function with callbacks\n * @param name - The name to check\n * @returns True if the name is a GT function with callbacks\n */\nexport function isGTFunctionWithCallbacks(\n name: string\n): name is GT_FUNCTIONS_WITH_CALLBACKS {\n return [\n 'useGT',\n 'getGT',\n 'useTranslations',\n 'getTranslations',\n 'useMessages',\n 'getMessages',\n ].includes(name);\n}\n\n/**\n * Check if a name is a GT component\n * @param name - The name to check\n * @returns True if the name is a GT component\n */\nexport function isGTComponent(name: string): name is GT_COMPONENT_TYPES {\n return Object.values(GT_COMPONENT_TYPES).includes(name as GT_COMPONENT_TYPES);\n}\n\n/**\n * Check if a component name matches known gt-next translation components\n */\nexport function isTranslationComponent(\n name: string\n): name is GT_COMPONENT_TYPES.T {\n return [\n GT_COMPONENT_TYPES.T,\n GT_COMPONENT_TYPES.GtInternalTranslateJsx,\n ].includes(name as GT_COMPONENT_TYPES);\n}\n\n/**\n * Check if a component name matches known gt-next variable components\n */\nexport function isVariableComponent(name: string): name is GT_COMPONENT_TYPES {\n return (\n [\n GT_COMPONENT_TYPES.Var,\n GT_COMPONENT_TYPES.Num,\n GT_COMPONENT_TYPES.Currency,\n GT_COMPONENT_TYPES.DateTime,\n GT_COMPONENT_TYPES.RelativeTime,\n GT_COMPONENT_TYPES.GtInternalVar,\n GT_COMPONENT_TYPES.GtInternalNum,\n GT_COMPONENT_TYPES.GtInternalCurrency,\n GT_COMPONENT_TYPES.GtInternalDateTime,\n ] as string[]\n ).includes(name);\n}\n\n/**\n * Check if a name is a GT derive component\n */\nexport function isDeriveComponent(name: string): name is GT_COMPONENT_TYPES {\n return name === GT_COMPONENT_TYPES.Derive;\n}\n\n/**\n * Check if a name is a GT branch component\n */\nexport function isBranchComponent(name: string): name is GT_COMPONENT_TYPES {\n return (\n [GT_COMPONENT_TYPES.Branch, GT_COMPONENT_TYPES.Plural] as string[]\n ).includes(name);\n}\n\n/**\n * Check if a name is a GT translation function\n */\nexport function isTranslationFunction(name: string): name is 'useGT' | 'getGT' {\n return ['useGT', 'getGT'].includes(name);\n}\n\n/**\n * Check if it's a translation function callback (const t = useGT())\n */\nexport function isTranslationFunctionCallback(\n name: string\n): name is GT_CALLBACK_FUNCTIONS {\n return [\n 'useGT_callback',\n 'getGT_callback',\n 'useTranslations_callback',\n 'getTranslations_callback',\n 'useMessages_callback',\n 'getMessages_callback',\n ].includes(name);\n}\n\n/**\n * Check if it's a GT import source\n */\nexport function isGTImportSource(name: string): name is GT_IMPORT_SOURCES {\n return (\n [\n GT_IMPORT_SOURCES.GT_NEXT,\n GT_IMPORT_SOURCES.GT_NEXT_SERVER,\n GT_IMPORT_SOURCES.GT_REACT,\n GT_IMPORT_SOURCES.GT_REACT_CLIENT,\n GT_IMPORT_SOURCES.GT_REACT_BROWSER,\n GT_IMPORT_SOURCES.GT_I18N,\n ] as string[]\n ).includes(name);\n}\n\nexport function isGTReactImportSource(\n name: string\n): name is\n | GT_IMPORT_SOURCES.GT_REACT\n | GT_IMPORT_SOURCES.GT_REACT_CLIENT\n | GT_IMPORT_SOURCES.GT_REACT_BROWSER {\n return (\n [\n GT_IMPORT_SOURCES.GT_REACT,\n GT_IMPORT_SOURCES.GT_REACT_CLIENT,\n GT_IMPORT_SOURCES.GT_REACT_BROWSER,\n ] as string[]\n ).includes(name);\n}\n\nexport function getGtReactImportSource(\n legacyGtReactImportSource: boolean\n): GT_IMPORT_SOURCES.GT_REACT | GT_IMPORT_SOURCES.GT_REACT_BROWSER {\n return legacyGtReactImportSource\n ? GT_IMPORT_SOURCES.GT_REACT_BROWSER\n : GT_IMPORT_SOURCES.GT_REACT;\n}\n\n/**\n * Check if is a html content prop\n */\nexport function isHtmlContentProp(\n name: string\n): name is keyof HtmlContentPropValuesRecord {\n return Object.values(HTML_CONTENT_PROPS).includes(\n name as keyof HtmlContentPropValuesRecord\n );\n}\n\n/**\n * Minify the canonical name\n */\nexport function minifyCanonicalName(canonicalName: GT_COMPONENT_TYPES): string {\n return (\n MINIFY_CANONICAL_NAME_MAP[\n canonicalName as keyof typeof MINIFY_CANONICAL_NAME_MAP\n ] || canonicalName\n );\n}\n\n/**\n * Default variable names\n */\nexport const defaultVariableNames = {\n [GT_COMPONENT_TYPES.Var]: 'value',\n [GT_COMPONENT_TYPES.GtInternalVar]: 'value',\n [GT_COMPONENT_TYPES.Num]: 'n',\n [GT_COMPONENT_TYPES.GtInternalNum]: 'n',\n [GT_COMPONENT_TYPES.DateTime]: 'date',\n [GT_COMPONENT_TYPES.GtInternalDateTime]: 'date',\n [GT_COMPONENT_TYPES.RelativeTime]: 'time',\n [GT_COMPONENT_TYPES.Currency]: 'cost',\n [GT_COMPONENT_TYPES.GtInternalCurrency]: 'cost',\n [GT_COMPONENT_TYPES.Derive]: 'static',\n} as const;\nconst baseVariablePrefix = '_gt_';\n\n/**\n * Get the variable name\n */\nexport function getVariableName(\n variableType: keyof typeof defaultVariableNames,\n id: number,\n name?: string\n): string {\n if (name) return name;\n const baseVariableName = defaultVariableNames[variableType] || 'value';\n return `${baseVariablePrefix}${baseVariableName}_${id}`;\n}\n"],"mappings":";;;;;;;;;;;;;AAsBA,SAAgB,aAAa,MAAwC;AACnE,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK;;;;;;;AAQlB,SAAgB,0BACd,MACqC;AACrC,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK;;;;;;;AAQlB,SAAgB,cAAc,MAA0C;AACtE,QAAO,OAAO,OAAOA,qCAAAA,mBAAmB,CAAC,SAAS,KAA2B;;;;;AAM/E,SAAgB,uBACd,MAC8B;AAC9B,QAAO,CAAA,KAAA,yBAGN,CAAC,SAAS,KAA2B;;;;;AAMxC,SAAgB,oBAAoB,MAA0C;AAC5E,QACE;;;;;;;;;;EAUC,CACD,SAAS,KAAK;;;;;AAMlB,SAAgB,kBAAkB,MAA0C;AAC1E,QAAO,SAAA;;;;;AAMT,SAAgB,kBAAkB,MAA0C;AAC1E,QACE,CAAA,UAAA,SAAsD,CACtD,SAAS,KAAK;;;;;AAMlB,SAAgB,sBAAsB,MAAyC;AAC7E,QAAO,CAAC,SAAS,QAAQ,CAAC,SAAS,KAAK;;;;;AAM1C,SAAgB,8BACd,MAC+B;AAC/B,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK;;;;;AAMlB,SAAgB,iBAAiB,MAAyC;AACxE,QACE;;;;;;;EAOC,CACD,SAAS,KAAK;;AAGlB,SAAgB,sBACd,MAIqC;AACrC,QACE;;;;EAIC,CACD,SAAS,KAAK;;AAGlB,SAAgB,uBACd,2BACiE;AACjE,QAAO,4BAAA,qBAAA;;;;;AAQT,SAAgB,kBACd,MAC2C;AAC3C,QAAO,OAAO,OAAOC,iCAAAA,mBAAmB,CAAC,SACvC,KACD;;;;;AAMH,SAAgB,oBAAoB,eAA2C;AAC7E,QACEC,qCAAAA,0BACE,kBACG;;;;;AAOT,MAAa,uBAAuB;UACR;oBACU;UACV;oBACU;eACL;yBACU;mBACN;eACJ;yBACU;aACZ;CAC9B;AACD,MAAM,qBAAqB;;;;AAK3B,SAAgB,gBACd,cACA,IACA,MACQ;AACR,KAAI,KAAM,QAAO;AAEjB,QAAO,GAAG,qBADe,qBAAqB,iBAAiB,QACf,GAAG"}
@@ -12,6 +12,6 @@ export declare function isUserTranslationComponent(firstArgPath: NodePath<t.Expr
12
12
  export declare function isUserVariableComponent(firstArgPath: NodePath<t.Expression>): boolean;
13
13
  /** Check if first arg is Branch or Plural */
14
14
  export declare function isGTBranchComponent(firstArgPath: NodePath<t.Expression>): boolean;
15
- /** Check if first arg is Derive or Static */
15
+ /** Check if first arg is Derive */
16
16
  export declare function isGTDeriveComponent(firstArgPath: NodePath<t.Expression>): boolean;
17
17
  //# sourceMappingURL=isGTComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isGTComponent.d.ts","sourceRoot":"","sources":["../../../../src/utils/constants/resolveIdentifier/isGTComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAIlC;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,MAAM,GAAG,IAAI,CAkBf;AAED,oFAAoF;AACpF,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAET;AAED,uFAAuF;AACvF,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAST;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAKT;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAKT"}
1
+ {"version":3,"file":"isGTComponent.d.ts","sourceRoot":"","sources":["../../../../src/utils/constants/resolveIdentifier/isGTComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAIlC;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,MAAM,GAAG,IAAI,CAkBf;AAED,oFAAoF;AACpF,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAET;AAED,uFAAuF;AACvF,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAST;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAKT;AAED,mCAAmC;AACnC,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAGT"}
@@ -42,10 +42,9 @@ function isGTBranchComponent(firstArgPath) {
42
42
  const name = resolveFirstArgGTName(firstArgPath);
43
43
  return name === "Branch" || name === "Plural";
44
44
  }
45
- /** Check if first arg is Derive or Static */
45
+ /** Check if first arg is Derive */
46
46
  function isGTDeriveComponent(firstArgPath) {
47
- const name = resolveFirstArgGTName(firstArgPath);
48
- return name === "Derive" || name === "Static";
47
+ return resolveFirstArgGTName(firstArgPath) === "Derive";
49
48
  }
50
49
  //#endregion
51
50
  exports.isGTBranchComponent = isGTBranchComponent;
@@ -1 +1 @@
1
- {"version":3,"file":"isGTComponent.js","names":["t","isGTImportSource"],"sources":["../../../../src/utils/constants/resolveIdentifier/isGTComponent.ts"],"sourcesContent":["import { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { isGTImportSource } from '../gt/helpers';\nimport { GT_COMPONENT_TYPES } from '../gt/constants';\n\n/**\n * Given a NodePath to the first argument of a jsx() call (the component identifier),\n * resolve it to its original imported name from a GT source.\n * Returns null if the identifier is not imported from a GT library.\n */\nexport function resolveFirstArgGTName(\n firstArgPath: NodePath<t.Expression>\n): string | null {\n if (!firstArgPath.isIdentifier()) return null;\n\n const binding = firstArgPath.scope.getBinding(firstArgPath.node.name);\n if (!binding || !binding.path.isImportSpecifier()) return null;\n\n const imported = binding.path.node.imported;\n const originalName = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n\n const parentPath = binding.path.parentPath;\n if (!parentPath?.isImportDeclaration()) return null;\n\n const importSource = parentPath.node.source.value;\n if (!isGTImportSource(importSource)) return null;\n\n return originalName;\n}\n\n/** Check if first arg of jsx call is user-written T (not GtInternalTranslateJsx) */\nexport function isUserTranslationComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n return resolveFirstArgGTName(firstArgPath) === GT_COMPONENT_TYPES.T;\n}\n\n/** Check if first arg is user-written Var, Num, Currency, DateTime, or RelativeTime */\nexport function isUserVariableComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return [\n GT_COMPONENT_TYPES.Var,\n GT_COMPONENT_TYPES.Num,\n GT_COMPONENT_TYPES.Currency,\n GT_COMPONENT_TYPES.DateTime,\n GT_COMPONENT_TYPES.RelativeTime,\n ].includes((name ?? '') as GT_COMPONENT_TYPES);\n}\n\n/** Check if first arg is Branch or Plural */\nexport function isGTBranchComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return (\n name === GT_COMPONENT_TYPES.Branch || name === GT_COMPONENT_TYPES.Plural\n );\n}\n\n/** Check if first arg is Derive or Static */\nexport function isGTDeriveComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return (\n name === GT_COMPONENT_TYPES.Derive || name === GT_COMPONENT_TYPES.Static\n );\n}\n"],"mappings":";;;;;;;;;;;;AAUA,SAAgB,sBACd,cACe;AACf,KAAI,CAAC,aAAa,cAAc,CAAE,QAAO;CAEzC,MAAM,UAAU,aAAa,MAAM,WAAW,aAAa,KAAK,KAAK;AACrE,KAAI,CAAC,WAAW,CAAC,QAAQ,KAAK,mBAAmB,CAAE,QAAO;CAE1D,MAAM,WAAW,QAAQ,KAAK,KAAK;CACnC,MAAM,eAAeA,aAAE,aAAa,SAAS,GACzC,SAAS,OACT,SAAS;CAEb,MAAM,aAAa,QAAQ,KAAK;AAChC,KAAI,EAAA,eAAA,QAAA,eAAA,KAAA,IAAA,KAAA,IAAC,WAAY,qBAAqB,EAAE,QAAO;CAE/C,MAAM,eAAe,WAAW,KAAK,OAAO;AAC5C,KAAI,CAACC,mCAAAA,iBAAiB,aAAa,CAAE,QAAO;AAE5C,QAAO;;;AAIT,SAAgB,2BACd,cACS;AACT,QAAO,sBAAsB,aAAa,KAAA;;;AAI5C,SAAgB,wBACd,cACS;CACT,MAAM,OAAO,sBAAsB,aAAa;AAChD,QAAO;;;;;;EAMN,CAAC,SAAU,QAAQ,GAA0B;;;AAIhD,SAAgB,oBACd,cACS;CACT,MAAM,OAAO,sBAAsB,aAAa;AAChD,QACE,SAAA,YAAsC,SAAA;;;AAK1C,SAAgB,oBACd,cACS;CACT,MAAM,OAAO,sBAAsB,aAAa;AAChD,QACE,SAAA,YAAsC,SAAA"}
1
+ {"version":3,"file":"isGTComponent.js","names":["t","isGTImportSource"],"sources":["../../../../src/utils/constants/resolveIdentifier/isGTComponent.ts"],"sourcesContent":["import { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { isGTImportSource } from '../gt/helpers';\nimport { GT_COMPONENT_TYPES } from '../gt/constants';\n\n/**\n * Given a NodePath to the first argument of a jsx() call (the component identifier),\n * resolve it to its original imported name from a GT source.\n * Returns null if the identifier is not imported from a GT library.\n */\nexport function resolveFirstArgGTName(\n firstArgPath: NodePath<t.Expression>\n): string | null {\n if (!firstArgPath.isIdentifier()) return null;\n\n const binding = firstArgPath.scope.getBinding(firstArgPath.node.name);\n if (!binding || !binding.path.isImportSpecifier()) return null;\n\n const imported = binding.path.node.imported;\n const originalName = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n\n const parentPath = binding.path.parentPath;\n if (!parentPath?.isImportDeclaration()) return null;\n\n const importSource = parentPath.node.source.value;\n if (!isGTImportSource(importSource)) return null;\n\n return originalName;\n}\n\n/** Check if first arg of jsx call is user-written T (not GtInternalTranslateJsx) */\nexport function isUserTranslationComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n return resolveFirstArgGTName(firstArgPath) === GT_COMPONENT_TYPES.T;\n}\n\n/** Check if first arg is user-written Var, Num, Currency, DateTime, or RelativeTime */\nexport function isUserVariableComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return [\n GT_COMPONENT_TYPES.Var,\n GT_COMPONENT_TYPES.Num,\n GT_COMPONENT_TYPES.Currency,\n GT_COMPONENT_TYPES.DateTime,\n GT_COMPONENT_TYPES.RelativeTime,\n ].includes((name ?? '') as GT_COMPONENT_TYPES);\n}\n\n/** Check if first arg is Branch or Plural */\nexport function isGTBranchComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return (\n name === GT_COMPONENT_TYPES.Branch || name === GT_COMPONENT_TYPES.Plural\n );\n}\n\n/** Check if first arg is Derive */\nexport function isGTDeriveComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return name === GT_COMPONENT_TYPES.Derive;\n}\n"],"mappings":";;;;;;;;;;;;AAUA,SAAgB,sBACd,cACe;AACf,KAAI,CAAC,aAAa,cAAc,CAAE,QAAO;CAEzC,MAAM,UAAU,aAAa,MAAM,WAAW,aAAa,KAAK,KAAK;AACrE,KAAI,CAAC,WAAW,CAAC,QAAQ,KAAK,mBAAmB,CAAE,QAAO;CAE1D,MAAM,WAAW,QAAQ,KAAK,KAAK;CACnC,MAAM,eAAeA,aAAE,aAAa,SAAS,GACzC,SAAS,OACT,SAAS;CAEb,MAAM,aAAa,QAAQ,KAAK;AAChC,KAAI,EAAA,eAAA,QAAA,eAAA,KAAA,IAAA,KAAA,IAAC,WAAY,qBAAqB,EAAE,QAAO;CAE/C,MAAM,eAAe,WAAW,KAAK,OAAO;AAC5C,KAAI,CAACC,mCAAAA,iBAAiB,aAAa,CAAE,QAAO;AAE5C,QAAO;;;AAIT,SAAgB,2BACd,cACS;AACT,QAAO,sBAAsB,aAAa,KAAA;;;AAI5C,SAAgB,wBACd,cACS;CACT,MAAM,OAAO,sBAAsB,aAAa;AAChD,QAAO;;;;;;EAMN,CAAC,SAAU,QAAQ,GAA0B;;;AAIhD,SAAgB,oBACd,cACS;CACT,MAAM,OAAO,sBAAsB,aAAa;AAChD,QACE,SAAA,YAAsC,SAAA;;;AAK1C,SAAgB,oBACd,cACS;AAET,QADa,sBAAsB,aACxB,KAAA"}