@generaltranslation/compiler 1.3.25-odysseus.0 → 1.3.25-odysseus.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"basePass.d.ts","sourceRoot":"","sources":["../../src/passes/basePass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAoD/D"}
1
+ {"version":3,"file":"basePass.d.ts","sourceRoot":"","sources":["../../src/passes/basePass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAgBlD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAoD/D"}
@@ -1,19 +1,18 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_processing_processProgram = require("../processing/processProgram.js");
3
+ const require_processing_processScopeChange = require("../processing/processScopeChange.js");
4
+ const require_processing_processFunctionDeclaration = require("../processing/processFunctionDeclaration.js");
5
+ const require_processing_processFunctionExpression = require("../processing/processFunctionExpression.js");
2
6
  const require_processing_processArrowFunctionExpression = require("../processing/processArrowFunctionExpression.js");
3
- const require_processing_processAssignmentExpression = require("../processing/processAssignmentExpression.js");
4
- const require_processing_processCatchClause = require("../processing/processCatchClause.js");
5
- const require_processing_processClassDeclaration = require("../processing/processClassDeclaration.js");
7
+ const require_processing_processObjectMethod = require("../processing/processObjectMethod.js");
6
8
  const require_processing_processClassMethod = require("../processing/processClassMethod.js");
7
9
  const require_processing_processClassPrivateMethod = require("../processing/processClassPrivateMethod.js");
10
+ const require_processing_processImportDeclaration = require("../processing/processImportDeclaration.js");
11
+ const require_processing_processAssignmentExpression = require("../processing/processAssignmentExpression.js");
12
+ const require_processing_processClassDeclaration = require("../processing/processClassDeclaration.js");
8
13
  const require_processing_processForInStatement = require("../processing/processForInStatement.js");
9
14
  const require_processing_processForOfStatement = require("../processing/processForOfStatement.js");
10
- const require_processing_processFunctionDeclaration = require("../processing/processFunctionDeclaration.js");
11
- const require_processing_processFunctionExpression = require("../processing/processFunctionExpression.js");
12
- const require_processing_processImportDeclaration = require("../processing/processImportDeclaration.js");
13
- const require_processing_processObjectMethod = require("../processing/processObjectMethod.js");
14
- const require_processing_processProgram = require("../processing/processProgram.js");
15
- const require_processing_processScopeChange = require("../processing/processScopeChange.js");
16
- require("../processing/index.js");
15
+ const require_processing_processCatchClause = require("../processing/processCatchClause.js");
17
16
  //#region src/passes/basePass.ts
18
17
  function basePass(state) {
19
18
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"basePass.js","names":[],"sources":["../../src/passes/basePass.ts"],"sourcesContent":["import { TransformState } from '../state/types';\nimport { TraverseOptions } from '@babel/traverse';\nimport * as p from '../processing';\n\nexport function basePass(state: TransformState): TraverseOptions {\n return {\n // Initialize trackers for this program\n Program: p.processProgram(state),\n\n /* ----------------------------- */\n /* Scope management */\n /* ----------------------------- */\n\n // for(let T in obj) { ... }\n ForStatement: p.processScopeChange(state),\n // while(T) { ... }\n WhileStatement: p.processScopeChange(state),\n // switch(T) { ... }\n SwitchStatement: p.processScopeChange(state),\n // { ... }\n BlockStatement: p.processScopeChange(state),\n // static { ... }\n StaticBlock: p.processScopeChange(state),\n\n /* ----------------------------- */\n /* Shadowing tracking */\n /* ----------------------------- */\n\n // --- Function Processing --- //\n // function T() { ... }\n FunctionDeclaration: p.processFunctionDeclaration(state),\n // const a = function T() {...}\n FunctionExpression: p.processFunctionExpression(state),\n // () => {...}\n ArrowFunctionExpression: p.processArrowFunctionExpression(state),\n // { T() {} } in objects\n ObjectMethod: p.processObjectMethod(state),\n // Class GT { T() { ... } } in classes\n ClassMethod: p.processClassMethod(state),\n // Class GT { #T() {...} }\n ClassPrivateMethod: p.processClassPrivateMethod(state),\n\n // --- Other Processing --- //\n // import T from '...'\n ImportDeclaration: p.processImportDeclaration(state),\n // let t = useGT(); t = undefined;\n AssignmentExpression: p.processAssignmentExpression(state),\n // class T { ... }\n ClassDeclaration: p.processClassDeclaration(state),\n // for(let T in obj) { ... }\n ForInStatement: p.processForInStatement(state),\n // for(let T of items) { ... }\n ForOfStatement: p.processForOfStatement(state),\n // try { ... } catch(T) { ... }\n CatchClause: p.processCatchClause(state),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,SAAgB,SAAS,OAAwC;AAC/D,QAAO;EAEL,SAAA,kCAAA,eAA0B,MAAM;EAOhC,cAAA,sCAAA,mBAAmC,MAAM;EAEzC,gBAAA,sCAAA,mBAAqC,MAAM;EAE3C,iBAAA,sCAAA,mBAAsC,MAAM;EAE5C,gBAAA,sCAAA,mBAAqC,MAAM;EAE3C,aAAA,sCAAA,mBAAkC,MAAM;EAQxC,qBAAA,8CAAA,2BAAkD,MAAM;EAExD,oBAAA,6CAAA,0BAAgD,MAAM;EAEtD,yBAAA,kDAAA,+BAA0D,MAAM;EAEhE,cAAA,uCAAA,oBAAoC,MAAM;EAE1C,aAAA,sCAAA,mBAAkC,MAAM;EAExC,oBAAA,6CAAA,0BAAgD,MAAM;EAItD,mBAAA,4CAAA,yBAA8C,MAAM;EAEpD,sBAAA,+CAAA,4BAAoD,MAAM;EAE1D,kBAAA,2CAAA,wBAA4C,MAAM;EAElD,gBAAA,yCAAA,sBAAwC,MAAM;EAE9C,gBAAA,yCAAA,sBAAwC,MAAM;EAE9C,aAAA,sCAAA,mBAAkC,MAAM;EACzC"}
1
+ {"version":3,"file":"basePass.js","names":["processProgram","processScopeChange","processFunctionDeclaration","processFunctionExpression","processArrowFunctionExpression","processObjectMethod","processClassMethod","processClassPrivateMethod","processImportDeclaration","processAssignmentExpression","processClassDeclaration","processForInStatement","processForOfStatement","processCatchClause"],"sources":["../../src/passes/basePass.ts"],"sourcesContent":["import { TransformState } from '../state/types';\nimport { TraverseOptions } from '@babel/traverse';\nimport { processProgram } from '../processing/processProgram';\nimport { processScopeChange } from '../processing/processScopeChange';\nimport { processFunctionDeclaration } from '../processing/processFunctionDeclaration';\nimport { processFunctionExpression } from '../processing/processFunctionExpression';\nimport { processArrowFunctionExpression } from '../processing/processArrowFunctionExpression';\nimport { processObjectMethod } from '../processing/processObjectMethod';\nimport { processClassMethod } from '../processing/processClassMethod';\nimport { processClassPrivateMethod } from '../processing/processClassPrivateMethod';\nimport { processImportDeclaration } from '../processing/processImportDeclaration';\nimport { processAssignmentExpression } from '../processing/processAssignmentExpression';\nimport { processClassDeclaration } from '../processing/processClassDeclaration';\nimport { processForInStatement } from '../processing/processForInStatement';\nimport { processForOfStatement } from '../processing/processForOfStatement';\nimport { processCatchClause } from '../processing/processCatchClause';\n\nexport function basePass(state: TransformState): TraverseOptions {\n return {\n // Initialize trackers for this program\n Program: processProgram(state),\n\n /* ----------------------------- */\n /* Scope management */\n /* ----------------------------- */\n\n // for(let T in obj) { ... }\n ForStatement: processScopeChange(state),\n // while(T) { ... }\n WhileStatement: processScopeChange(state),\n // switch(T) { ... }\n SwitchStatement: processScopeChange(state),\n // { ... }\n BlockStatement: processScopeChange(state),\n // static { ... }\n StaticBlock: processScopeChange(state),\n\n /* ----------------------------- */\n /* Shadowing tracking */\n /* ----------------------------- */\n\n // --- Function Processing --- //\n // function T() { ... }\n FunctionDeclaration: processFunctionDeclaration(state),\n // const a = function T() {...}\n FunctionExpression: processFunctionExpression(state),\n // () => {...}\n ArrowFunctionExpression: processArrowFunctionExpression(state),\n // { T() {} } in objects\n ObjectMethod: processObjectMethod(state),\n // Class GT { T() { ... } } in classes\n ClassMethod: processClassMethod(state),\n // Class GT { #T() {...} }\n ClassPrivateMethod: processClassPrivateMethod(state),\n\n // --- Other Processing --- //\n // import T from '...'\n ImportDeclaration: processImportDeclaration(state),\n // let t = useGT(); t = undefined;\n AssignmentExpression: processAssignmentExpression(state),\n // class T { ... }\n ClassDeclaration: processClassDeclaration(state),\n // for(let T in obj) { ... }\n ForInStatement: processForInStatement(state),\n // for(let T of items) { ... }\n ForOfStatement: processForOfStatement(state),\n // try { ... } catch(T) { ... }\n CatchClause: processCatchClause(state),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,SAAS,OAAwC;AAC/D,QAAO;EAEL,SAASA,kCAAAA,eAAe,MAAM;EAO9B,cAAcC,sCAAAA,mBAAmB,MAAM;EAEvC,gBAAgBA,sCAAAA,mBAAmB,MAAM;EAEzC,iBAAiBA,sCAAAA,mBAAmB,MAAM;EAE1C,gBAAgBA,sCAAAA,mBAAmB,MAAM;EAEzC,aAAaA,sCAAAA,mBAAmB,MAAM;EAQtC,qBAAqBC,8CAAAA,2BAA2B,MAAM;EAEtD,oBAAoBC,6CAAAA,0BAA0B,MAAM;EAEpD,yBAAyBC,kDAAAA,+BAA+B,MAAM;EAE9D,cAAcC,uCAAAA,oBAAoB,MAAM;EAExC,aAAaC,sCAAAA,mBAAmB,MAAM;EAEtC,oBAAoBC,6CAAAA,0BAA0B,MAAM;EAIpD,mBAAmBC,4CAAAA,yBAAyB,MAAM;EAElD,sBAAsBC,+CAAAA,4BAA4B,MAAM;EAExD,kBAAkBC,2CAAAA,wBAAwB,MAAM;EAEhD,gBAAgBC,yCAAAA,sBAAsB,MAAM;EAE5C,gBAAgBC,yCAAAA,sBAAsB,MAAM;EAE5C,aAAaC,sCAAAA,mBAAmB,MAAM;EACvC"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_transform_tracking_trackFunctionParams = require("../transform/tracking/trackFunctionParams.js");
3
2
  const require_transform_tracking_trackFunctionName = require("../transform/tracking/trackFunctionName.js");
3
+ const require_transform_tracking_trackFunctionParams = require("../transform/tracking/trackFunctionParams.js");
4
4
  //#region src/processing/processFunctionDeclaration.ts
5
5
  /**
6
6
  * Process function declaration:
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_transform_tracking_trackFunctionParams = require("../transform/tracking/trackFunctionParams.js");
3
2
  const require_transform_tracking_trackFunctionName = require("../transform/tracking/trackFunctionName.js");
3
+ const require_transform_tracking_trackFunctionParams = require("../transform/tracking/trackFunctionParams.js");
4
4
  //#region src/processing/processFunctionExpression.ts
5
5
  /**
6
6
  * Process function expression:
@@ -12,11 +12,11 @@ export interface TranslationContent {
12
12
  message: string;
13
13
  /** Pre-calculated hash for this content */
14
14
  hash: string;
15
- /** Optional ID from options: t("text", {id: "greeting"}) → "greeting" */
15
+ /** Optional ID from options: t("text", {$id: "greeting"}) → "greeting" */
16
16
  id?: string;
17
- /** Optional context from options: t("text", {context: "nav"}) → "nav" */
17
+ /** Optional context from options: t("text", {$context: "nav"}) → "nav" */
18
18
  context?: string;
19
- /** Optional maxChars from options: t("text", {maxChars: 10}) → 10 */
19
+ /** Optional maxChars from options: t("text", {$maxChars: 10}) → 10 */
20
20
  maxChars?: number;
21
21
  /** Optional format from options: t("text", {$format: "STRING"}) → "STRING" */
22
22
  format?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"StringCollector.d.ts","sourceRoot":"","sources":["../../src/state/StringCollector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,+CAA+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AAK,GAAG,MAAM,CAAC;QACjC,KAAK,EAAE,kBAAkB,EAAE,GAAG,cAAc,GAAG,eAAe,CAAC;KAChE,GACD,SAAS;IAab;;OAEG;IACH,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,EAAE,GAAG,SAAS;IAI1E;;OAEG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAIhE;;OAEG;IACH,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIlE;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;OAEG;IACH,YAAY,IAAI,IAAI;IAIpB;;OAEG;IACH,UAAU,IAAI,OAAO;IAUrB;;OAEG;IACH,wBAAwB,IAAI,kBAAkB,EAAE;IAIhD;;OAEG;IACH,oBAAoB,IAAI,cAAc,EAAE;IAIxC;;OAEG;IACH,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAIzD;;OAEG;IACH,qBAAqB,IAAI,kBAAkB,EAAE;IAI7C;;OAEG;IACH,SAAS,IAAI,yBAAyB;IAUtC;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,yBAAyB,GAAG,IAAI;CAqBpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"StringCollector.js","names":[],"sources":["../../src/state/StringCollector.ts"],"sourcesContent":["/**\n * String Collector - Manages translation content across two-pass transformation\n *\n * Pass 1: Collects translation strings, JSX content, and hash data\n * Pass 2: Injects collected data back into useGT()/getGT() calls\n */\n\n/**\n * Content extracted from a t() function call\n */\nexport interface TranslationContent {\n /** The string message: t(\"Hello world\") → \"Hello world\" */\n message: string;\n /** Pre-calculated hash for this content */\n hash: string;\n /** Optional ID from options: t(\"text\", {id: \"greeting\"}) → \"greeting\" */\n id?: string;\n /** Optional context from options: t(\"text\", {context: \"nav\"}) → \"nav\" */\n context?: string;\n /** Optional maxChars from options: t(\"text\", {maxChars: 10}) → 10 */\n maxChars?: number;\n /** Optional format from options: t(\"text\", {$format: \"STRING\"}) → \"STRING\" */\n format?: string;\n}\n\n/**\n * Content extracted from JSX translation components like <T>\n */\nexport interface TranslationJsx {\n /** Pre-calculated hash for this JSX content */\n hash: string;\n /** JSX children structure (serializable) */\n children?: unknown;\n /** Optional ID from props */\n id?: string;\n /** Optional context from props */\n context?: string;\n}\n\n/**\n * Just a hash value for simple hash injection\n */\nexport interface TranslationHash {\n /** The hash value to inject */\n hash: string;\n}\n\ntype SerializedStringCollector = {\n contentAggregators: Record<string, TranslationContent[]>;\n jsxAggregators: Record<string, TranslationJsx>;\n hashAggregators: Record<string, TranslationHash>;\n globalCallCounter: number;\n};\n\n/**\n * String collector for two-pass transformation system\n */\nexport class StringCollector {\n /** Vector of translation calls indexed by counter ID */\n private contentAggregators: Map<number, TranslationContent[]> = new Map();\n private jsxAggregators: Map<number, TranslationJsx> = new Map();\n private hashAggregators: Map<number, TranslationHash> = new Map();\n /** Global counter incremented for each useGT/getGT call encountered */\n private globalCallCounter: number = 0;\n /** Runtime-only entries for standalone strings consumed by runtime translate */\n private runtimeOnlyEntries: TranslationContent[] = [];\n\n /**\n * Increment counter and return the current counter ID for a useGT/getGT call\n * These IDs are deterministic\n */\n incrementCounter(): number {\n this.globalCallCounter += 1;\n return this.globalCallCounter;\n }\n\n /**\n * Get current global counter value\n */\n getCounter(): number {\n return this.globalCallCounter;\n }\n\n /**\n * Pass 1: Add translation content from a gt() call to a specific useGT/getGT aggregator\n * Multiple content items can be added to the same call\n */\n pushTranslationContent(counterId: number, content: TranslationContent): void {\n if (counterId === -1) {\n throw new Error(\n 'Cannot have a counterId of -1. This likely means you are trying to register content from a namespace method invocation.'\n );\n }\n // Get the agreggator\n let aggregator = this.contentAggregators.get(counterId);\n if (!aggregator) {\n aggregator = [content];\n this.contentAggregators.set(counterId, aggregator);\n } else {\n aggregator.push(content);\n }\n }\n\n /**\n * Pass 1: Set JSX translation content for a specific useGT/getGT\n * Only one JSX item can be set per call (overwrites if called multiple times)\n */\n setTranslationJsx(counterId: number, jsx: TranslationJsx): void {\n this.jsxAggregators.set(counterId, jsx);\n }\n\n /**\n * Pass 1: Set hash-only content for a specific useGT/getGT\n * Only one hash can be set per call (overwrites if called multiple times)\n */\n setTranslationHash(counterId: number, hash: TranslationHash): void {\n this.hashAggregators.set(counterId, hash);\n }\n\n /**\n * Pass 2: Get translation call data for injection into a specific useGT/getGT call\n */\n getTranslationData(counterId: number):\n | {\n type: 'content' | 'jsx' | 'hash';\n value: TranslationContent[] | TranslationJsx | TranslationHash;\n }\n | undefined {\n if (this.contentAggregators.has(counterId)) {\n return {\n type: 'content',\n value: this.contentAggregators.get(counterId)!,\n };\n } else if (this.jsxAggregators.has(counterId)) {\n return { type: 'jsx', value: this.jsxAggregators.get(counterId)! };\n } else if (this.hashAggregators.has(counterId)) {\n return { type: 'hash', value: this.hashAggregators.get(counterId)! };\n }\n }\n\n /**\n * Get the translation content for a specific useGT/getGT call\n */\n getTranslationContent(counterId: number): TranslationContent[] | undefined {\n return this.contentAggregators.get(counterId);\n }\n\n /**\n * Get the translation JSX for a specific <T> component\n */\n getTranslationJsx(counterId: number): TranslationJsx | undefined {\n return this.jsxAggregators.get(counterId);\n }\n\n /**\n * Get the translation hash for a specific other call\n */\n getTranslationHash(counterId: number): TranslationHash | undefined {\n return this.hashAggregators.get(counterId);\n }\n\n /**\n * Reset all state (useful for testing)\n */\n clear(): void {\n this.contentAggregators.clear();\n this.jsxAggregators.clear();\n this.hashAggregators.clear();\n this.runtimeOnlyEntries = [];\n this.globalCallCounter = 0;\n }\n\n /**\n * Reset the counter to zero\n */\n resetCounter(): void {\n this.globalCallCounter = 0;\n }\n\n /**\n * Has content\n */\n hasContent(): boolean {\n return (\n this.contentAggregators.size +\n this.jsxAggregators.size +\n this.hashAggregators.size +\n this.runtimeOnlyEntries.length >\n 0\n );\n }\n\n /**\n * Get all translation content entries (flattened across all aggregators)\n */\n getAllTranslationContent(): TranslationContent[] {\n return Array.from(this.contentAggregators.values()).flat();\n }\n\n /**\n * Get all translation JSX entries\n */\n getAllTranslationJsx(): TranslationJsx[] {\n return Array.from(this.jsxAggregators.values());\n }\n\n /**\n * Add a runtime-only translation entry for the runtime translate pass.\n */\n pushRuntimeOnlyContent(content: TranslationContent): void {\n this.runtimeOnlyEntries.push(content);\n }\n\n /**\n * Get all runtime-only translation entries\n */\n getRuntimeOnlyContent(): TranslationContent[] {\n return this.runtimeOnlyEntries;\n }\n\n /**\n * Helper convert to string\n */\n serialize(): SerializedStringCollector {\n const output = {\n contentAggregators: Object.fromEntries(this.contentAggregators),\n jsxAggregators: Object.fromEntries(this.jsxAggregators),\n hashAggregators: Object.fromEntries(this.hashAggregators),\n globalCallCounter: this.globalCallCounter,\n };\n return output;\n }\n\n /**\n * Helper to repopulate\n */\n unserialize(input: SerializedStringCollector): void {\n this.contentAggregators = Object.entries(\n input.contentAggregators as Record<number, TranslationContent[]>\n ).reduce((acc, [key, value]) => {\n acc.set(Number(key), value);\n return acc;\n }, new Map<number, TranslationContent[]>());\n this.jsxAggregators = Object.entries(\n input.jsxAggregators as Record<number, TranslationJsx>\n ).reduce((acc, [key, value]) => {\n acc.set(Number(key), value);\n return acc;\n }, new Map<number, TranslationJsx>());\n this.hashAggregators = Object.entries(\n input.hashAggregators as Record<number, TranslationHash>\n ).reduce((acc, [key, value]) => {\n acc.set(Number(key), value);\n return acc;\n }, new Map<number, TranslationHash>());\n this.globalCallCounter = input.globalCallCounter;\n }\n}\n"],"mappings":";;;;;AAyDA,IAAa,kBAAb,MAA6B;;4CAEqC,IAAI,KAAK;wCACnB,IAAI,KAAK;yCACP,IAAI,KAAK;2BAE7B;4BAEe,EAAE;;;;;;CAMrD,mBAA2B;AACzB,OAAK,qBAAqB;AAC1B,SAAO,KAAK;;;;;CAMd,aAAqB;AACnB,SAAO,KAAK;;;;;;CAOd,uBAAuB,WAAmB,SAAmC;AAC3E,MAAI,cAAc,GAChB,OAAM,IAAI,MACR,0HACD;EAGH,IAAI,aAAa,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O,MAAM,KAAK,KAAK,eAAe,QAAQ,CAAC;;;;;CAMjD,uBAAuB,SAAmC;AACxD,OAAK,mBAAmB,KAAK,QAAQ;;;;;CAMvC,wBAA8C;AAC5C,SAAO,KAAK;;;;;CAMd,YAAuC;AAOrC,SAAO;GALL,oBAAoB,OAAO,YAAY,KAAK,mBAAmB;GAC/D,gBAAgB,OAAO,YAAY,KAAK,eAAe;GACvD,iBAAiB,OAAO,YAAY,KAAK,gBAAgB;GACzD,mBAAmB,KAAK;GAEb;;;;;CAMf,YAAY,OAAwC;AAClD,OAAK,qBAAqB,OAAO,QAC/B,MAAM,mBACP,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC9B,OAAI,IAAI,OAAO,IAAI,EAAE,MAAM;AAC3B,UAAO;qBACN,IAAI,KAAmC,CAAC;AAC3C,OAAK,iBAAiB,OAAO,QAC3B,MAAM,eACP,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC9B,OAAI,IAAI,OAAO,IAAI,EAAE,MAAM;AAC3B,UAAO;qBACN,IAAI,KAA6B,CAAC;AACrC,OAAK,kBAAkB,OAAO,QAC5B,MAAM,gBACP,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC9B,OAAI,IAAI,OAAO,IAAI,EAAE,MAAM;AAC3B,UAAO;qBACN,IAAI,KAA8B,CAAC;AACtC,OAAK,oBAAoB,MAAM"}
1
+ {"version":3,"file":"StringCollector.js","names":[],"sources":["../../src/state/StringCollector.ts"],"sourcesContent":["/**\n * String Collector - Manages translation content across two-pass transformation\n *\n * Pass 1: Collects translation strings, JSX content, and hash data\n * Pass 2: Injects collected data back into useGT()/getGT() calls\n */\n\n/**\n * Content extracted from a t() function call\n */\nexport interface TranslationContent {\n /** The string message: t(\"Hello world\") → \"Hello world\" */\n message: string;\n /** Pre-calculated hash for this content */\n hash: string;\n /** Optional ID from options: t(\"text\", {$id: \"greeting\"}) → \"greeting\" */\n id?: string;\n /** Optional context from options: t(\"text\", {$context: \"nav\"}) → \"nav\" */\n context?: string;\n /** Optional maxChars from options: t(\"text\", {$maxChars: 10}) → 10 */\n maxChars?: number;\n /** Optional format from options: t(\"text\", {$format: \"STRING\"}) → \"STRING\" */\n format?: string;\n}\n\n/**\n * Content extracted from JSX translation components like <T>\n */\nexport interface TranslationJsx {\n /** Pre-calculated hash for this JSX content */\n hash: string;\n /** JSX children structure (serializable) */\n children?: unknown;\n /** Optional ID from props */\n id?: string;\n /** Optional context from props */\n context?: string;\n}\n\n/**\n * Just a hash value for simple hash injection\n */\nexport interface TranslationHash {\n /** The hash value to inject */\n hash: string;\n}\n\ntype SerializedStringCollector = {\n contentAggregators: Record<string, TranslationContent[]>;\n jsxAggregators: Record<string, TranslationJsx>;\n hashAggregators: Record<string, TranslationHash>;\n globalCallCounter: number;\n};\n\n/**\n * String collector for two-pass transformation system\n */\nexport class StringCollector {\n /** Vector of translation calls indexed by counter ID */\n private contentAggregators: Map<number, TranslationContent[]> = new Map();\n private jsxAggregators: Map<number, TranslationJsx> = new Map();\n private hashAggregators: Map<number, TranslationHash> = new Map();\n /** Global counter incremented for each useGT/getGT call encountered */\n private globalCallCounter: number = 0;\n /** Runtime-only entries for standalone strings consumed by runtime translate */\n private runtimeOnlyEntries: TranslationContent[] = [];\n\n /**\n * Increment counter and return the current counter ID for a useGT/getGT call\n * These IDs are deterministic\n */\n incrementCounter(): number {\n this.globalCallCounter += 1;\n return this.globalCallCounter;\n }\n\n /**\n * Get current global counter value\n */\n getCounter(): number {\n return this.globalCallCounter;\n }\n\n /**\n * Pass 1: Add translation content from a gt() call to a specific useGT/getGT aggregator\n * Multiple content items can be added to the same call\n */\n pushTranslationContent(counterId: number, content: TranslationContent): void {\n if (counterId === -1) {\n throw new Error(\n 'Cannot have a counterId of -1. This likely means you are trying to register content from a namespace method invocation.'\n );\n }\n // Get the agreggator\n let aggregator = this.contentAggregators.get(counterId);\n if (!aggregator) {\n aggregator = [content];\n this.contentAggregators.set(counterId, aggregator);\n } else {\n aggregator.push(content);\n }\n }\n\n /**\n * Pass 1: Set JSX translation content for a specific useGT/getGT\n * Only one JSX item can be set per call (overwrites if called multiple times)\n */\n setTranslationJsx(counterId: number, jsx: TranslationJsx): void {\n this.jsxAggregators.set(counterId, jsx);\n }\n\n /**\n * Pass 1: Set hash-only content for a specific useGT/getGT\n * Only one hash can be set per call (overwrites if called multiple times)\n */\n setTranslationHash(counterId: number, hash: TranslationHash): void {\n this.hashAggregators.set(counterId, hash);\n }\n\n /**\n * Pass 2: Get translation call data for injection into a specific useGT/getGT call\n */\n getTranslationData(counterId: number):\n | {\n type: 'content' | 'jsx' | 'hash';\n value: TranslationContent[] | TranslationJsx | TranslationHash;\n }\n | undefined {\n if (this.contentAggregators.has(counterId)) {\n return {\n type: 'content',\n value: this.contentAggregators.get(counterId)!,\n };\n } else if (this.jsxAggregators.has(counterId)) {\n return { type: 'jsx', value: this.jsxAggregators.get(counterId)! };\n } else if (this.hashAggregators.has(counterId)) {\n return { type: 'hash', value: this.hashAggregators.get(counterId)! };\n }\n }\n\n /**\n * Get the translation content for a specific useGT/getGT call\n */\n getTranslationContent(counterId: number): TranslationContent[] | undefined {\n return this.contentAggregators.get(counterId);\n }\n\n /**\n * Get the translation JSX for a specific <T> component\n */\n getTranslationJsx(counterId: number): TranslationJsx | undefined {\n return this.jsxAggregators.get(counterId);\n }\n\n /**\n * Get the translation hash for a specific other call\n */\n getTranslationHash(counterId: number): TranslationHash | undefined {\n return this.hashAggregators.get(counterId);\n }\n\n /**\n * Reset all state (useful for testing)\n */\n clear(): void {\n this.contentAggregators.clear();\n this.jsxAggregators.clear();\n this.hashAggregators.clear();\n this.runtimeOnlyEntries = [];\n this.globalCallCounter = 0;\n }\n\n /**\n * Reset the counter to zero\n */\n resetCounter(): void {\n this.globalCallCounter = 0;\n }\n\n /**\n * Has content\n */\n hasContent(): boolean {\n return (\n this.contentAggregators.size +\n this.jsxAggregators.size +\n this.hashAggregators.size +\n this.runtimeOnlyEntries.length >\n 0\n );\n }\n\n /**\n * Get all translation content entries (flattened across all aggregators)\n */\n getAllTranslationContent(): TranslationContent[] {\n return Array.from(this.contentAggregators.values()).flat();\n }\n\n /**\n * Get all translation JSX entries\n */\n getAllTranslationJsx(): TranslationJsx[] {\n return Array.from(this.jsxAggregators.values());\n }\n\n /**\n * Add a runtime-only translation entry for the runtime translate pass.\n */\n pushRuntimeOnlyContent(content: TranslationContent): void {\n this.runtimeOnlyEntries.push(content);\n }\n\n /**\n * Get all runtime-only translation entries\n */\n getRuntimeOnlyContent(): TranslationContent[] {\n return this.runtimeOnlyEntries;\n }\n\n /**\n * Helper convert to string\n */\n serialize(): SerializedStringCollector {\n const output = {\n contentAggregators: Object.fromEntries(this.contentAggregators),\n jsxAggregators: Object.fromEntries(this.jsxAggregators),\n hashAggregators: Object.fromEntries(this.hashAggregators),\n globalCallCounter: this.globalCallCounter,\n };\n return output;\n }\n\n /**\n * Helper to repopulate\n */\n unserialize(input: SerializedStringCollector): void {\n this.contentAggregators = Object.entries(\n input.contentAggregators as Record<number, TranslationContent[]>\n ).reduce((acc, [key, value]) => {\n acc.set(Number(key), value);\n return acc;\n }, new Map<number, TranslationContent[]>());\n this.jsxAggregators = Object.entries(\n input.jsxAggregators as Record<number, TranslationJsx>\n ).reduce((acc, [key, value]) => {\n acc.set(Number(key), value);\n return acc;\n }, new Map<number, TranslationJsx>());\n this.hashAggregators = Object.entries(\n input.hashAggregators as Record<number, TranslationHash>\n ).reduce((acc, [key, value]) => {\n acc.set(Number(key), value);\n return acc;\n }, new Map<number, TranslationHash>());\n this.globalCallCounter = input.globalCallCounter;\n }\n}\n"],"mappings":";;;;;AAyDA,IAAa,kBAAb,MAA6B;;4CAEqC,IAAI,KAAK;wCACnB,IAAI,KAAK;yCACP,IAAI,KAAK;2BAE7B;4BAEe,EAAE;;;;;;CAMrD,mBAA2B;AACzB,OAAK,qBAAqB;AAC1B,SAAO,KAAK;;;;;CAMd,aAAqB;AACnB,SAAO,KAAK;;;;;;CAOd,u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SAAO,MAAM,KAAK,KAAK,mBAAmB,QAAQ,CAAC,CAAC,MAAM;;;;;CAM5D,uBAAyC;AACvC,SAAO,MAAM,KAAK,KAAK,eAAe,QAAQ,CAAC;;;;;CAMjD,uBAAuB,SAAmC;AACxD,OAAK,mBAAmB,KAAK,QAAQ;;;;;CAMvC,wBAA8C;AAC5C,SAAO,KAAK;;;;;CAMd,YAAuC;AAOrC,SAAO;GALL,oBAAoB,OAAO,YAAY,KAAK,mBAAmB;GAC/D,gBAAgB,OAAO,YAAY,KAAK,eAAe;GACvD,iBAAiB,OAAO,YAAY,KAAK,gBAAgB;GACzD,mBAAmB,KAAK;GAEb;;;;;CAMf,YAAY,OAAwC;AAClD,OAAK,qBAAqB,OAAO,QAC/B,MAAM,mBACP,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC9B,OAAI,IAAI,OAAO,IAAI,EAAE,MAAM;AAC3B,UAAO;qBACN,IAAI,KAAmC,CAAC;AAC3C,OAAK,iBAAiB,OAAO,QAC3B,MAAM,eACP,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC9B,OAAI,IAAI,OAAO,IAAI,EAAE,MAAM;AAC3B,UAAO;qBACN,IAAI,KAA6B,CAAC;AACrC,OAAK,kBAAkB,OAAO,QAC5B,MAAM,gBACP,CAAC,QAAQ,KAAK,CAAC,KAAK,WAAW;AAC9B,OAAI,IAAI,OAAO,IAAI,EAAE,MAAM;AAC3B,UAAO;qBACN,IAAI,KAA8B,CAAC;AACtC,OAAK,oBAAoB,MAAM"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_config = require("../../config.js");
3
- require("../../utils/constants/gt/constants.js");
4
3
  const require_state_ScopeTracker = require("../ScopeTracker.js");
4
+ require("../../utils/constants/gt/constants.js");
5
5
  const require_state_StringCollector = require("../StringCollector.js");
6
6
  const require_state_Logger = require("../Logger.js");
7
7
  const require_state_ErrorTracker = require("../ErrorTracker.js");
@@ -6,7 +6,6 @@ const require_utils_parsing_getObjectPropertyFromObjectExpression = require("../
6
6
  const require_utils_validation_validateExpressionIsStringLiteral = require("../../utils/validation/validateExpressionIsStringLiteral.js");
7
7
  const require_utils_validation_validateChildrenFromObjectExpression = require("../../utils/validation/validateChildrenFromObjectExpression.js");
8
8
  const require_transform_jsx_children_constructJsxChildren = require("../jsx-children/constructJsxChildren.js");
9
- require("../jsx-children/index.js");
10
9
  const require_utils_validation_validateExpressionIsNumericLiteral = require("../../utils/validation/validateExpressionIsNumericLiteral.js");
11
10
  let _babel_types = require("@babel/types");
12
11
  _babel_types = require_runtime.__toESM(_babel_types);
@@ -1 +1 @@
1
- {"version":3,"file":"validateTranslationComponentArgs.js","names":["t","validateChildrenPropertyFromObjectExpression","constructJsxChildren","getObjectPropertyFromObjectExpression","validateExpressionIsStringLiteral","validateExpressionIsNumericLiteral"],"sources":["../../../src/transform/validation/validateTranslationComponentArgs.ts"],"sourcesContent":["import { TransformState } from '../../state/types';\nimport { GT_COMPONENT_TYPES } from '../../utils/constants/gt/constants';\nimport * as t from '@babel/types';\nimport type { NodePath } from '@babel/traverse';\nimport { getObjectPropertyFromObjectExpression } from '../../utils/parsing/getObjectPropertyFromObjectExpression';\nimport { validateExpressionIsStringLiteral } from '../../utils/validation/validateExpressionIsStringLiteral';\nimport type { JsxChildren } from '@generaltranslation/format/types';\nimport { constructJsxChildren } from '../jsx-children';\nimport { validateChildrenPropertyFromObjectExpression } from '../../utils/validation/validateChildrenFromObjectExpression';\nimport { validateExpressionIsNumericLiteral } from '../../utils/validation/validateExpressionIsNumericLiteral';\nimport { validateDerive } from './validateTranslationFunction';\nimport { JsxValidationError } from '../jsx-children/errors';\n/**\n * Given a translation component, validate the arguments\n */\nexport function validateTranslationComponentArgs(\n callExprPath: NodePath<t.CallExpression>,\n canonicalName: string,\n state: TransformState\n): {\n errors: string[];\n _hash?: string;\n id?: string;\n context?: string;\n maxChars?: number;\n children?: JsxChildren;\n hasDeriveContext?: boolean;\n} {\n const callExpr = callExprPath.node;\n // Check that there are at least 2 arguments (identifier, args)\n if (callExpr.arguments.length < 2) {\n const errors = [\n 'Translation component must have at least 2 arguments (identifier, args)',\n ];\n return { errors };\n }\n\n // Get the component args\n const args = callExpr.arguments[1];\n if (!t.isObjectExpression(args)) {\n const errors = [\n 'Translation component must have an object expression as the second argument',\n ];\n return { errors };\n }\n const argsPath = callExprPath.get('arguments')[1];\n if (!argsPath?.isObjectExpression()) {\n const errors = [\n 'Translation component must have an object expression as the second argument',\n ];\n return { errors };\n }\n\n // Map to appropriate validation function\n switch (canonicalName) {\n case GT_COMPONENT_TYPES.T:\n case GT_COMPONENT_TYPES.GtInternalTranslateJsx:\n return validateTComponentArgs(\n argsPath as NodePath<t.ObjectExpression>,\n state\n );\n default:\n const errors = [\n `Invalid translation component: ${canonicalName}. You likely passed a non-translation component to validateTranslationComponentArgs`,\n ];\n return { errors };\n }\n}\n\n/* =============================== */\n/* Helper Functions */\n/* =============================== */\n\nfunction validateTComponentArgs(\n argsPath: NodePath<t.ObjectExpression>,\n state: TransformState\n): {\n errors: string[];\n _hash?: string;\n id?: string;\n context?: string;\n maxChars?: number;\n children?: JsxChildren;\n hasDeriveContext?: boolean;\n} {\n const errors: string[] = [];\n const args = argsPath.node;\n\n // Validate id\n const idValidation = validateStringProperty(args, 'id');\n errors.push(...idValidation.errors);\n const id = idValidation.value;\n\n // Validate context (with derive fallback)\n const contextValidation = validateStringProperty(args, 'context', state);\n errors.push(...contextValidation.errors);\n const context = contextValidation.value;\n // Validate maxChars\n const maxCharsValidation = validateNumberProperty(args, 'maxChars');\n errors.push(...maxCharsValidation.errors);\n const maxChars = maxCharsValidation.value;\n\n // Validate hash\n const hashValidation = validateStringProperty(args, '_hash');\n errors.push(...hashValidation.errors);\n const _hash = hashValidation.value;\n\n // Validate children\n const childrenValidation = validateChildrenProperty(argsPath, state);\n errors.push(...childrenValidation.errors);\n const children = childrenValidation.value;\n\n const hasDeriveContext =\n contextValidation.hasDeriveExpression || childrenValidation.hasAutoderive;\n\n return { errors, id, context, _hash, maxChars, children, hasDeriveContext };\n}\n\n/**\n * Validate that the children property is a string literal\n */\nexport function validateChildrenProperty(\n argsPath: NodePath<t.ObjectExpression>,\n state: TransformState\n): {\n errors: string[];\n value?: JsxChildren;\n hasAutoderive?: boolean;\n} {\n const errors: string[] = [];\n\n // Get the children property\n const childrenValidation =\n validateChildrenPropertyFromObjectExpression(argsPath);\n if (childrenValidation.errors.length > 0) {\n errors.push(...childrenValidation.errors);\n return { errors };\n }\n const children = childrenValidation.value;\n if (children === undefined) {\n errors.push(`The <${GT_COMPONENT_TYPES.T}> component must have children`);\n return { errors };\n }\n\n // constructJsxChildren now returns JsxValidationError[]\n const validation = constructJsxChildren(children, state);\n\n // Autoderive: filter out dynamic-content errors\n let hasAutoderive = false;\n let filteredErrors: JsxValidationError[] = validation.errors;\n if (state.settings.autoderive.jsx) {\n filteredErrors = validation.errors.filter(\n (e) => e.type !== 'dynamic-content'\n );\n hasAutoderive = filteredErrors.length < validation.errors.length;\n }\n\n // Convert structured errors back to strings\n errors.push(...filteredErrors.map((e) => e.message));\n const value = validation.value;\n\n return { errors, value, hasAutoderive };\n}\n\n// String Literal Functions\n\n/**\n * Will validate and retrieve property from object expression and also try prefixing with a $\n *\n */\nfunction validateStringProperty(\n args: t.ObjectExpression,\n name: string,\n state?: TransformState\n): {\n errors: string[];\n value?: string;\n hasDeriveExpression?: boolean;\n} {\n const errors: string[] = [];\n\n // Get the property\n const property =\n getObjectPropertyFromObjectExpression(args, name) ||\n getObjectPropertyFromObjectExpression(args, '$' + name);\n if (!property) {\n return { errors };\n }\n\n // Validate property\n const validation = validateObjectPropertyIsStringLiteral(property, name);\n if (validation.errors.length === 0) {\n return { errors, value: validation.value };\n }\n\n // String validation failed — check if it's a valid derive() expression\n if (state && t.isObjectProperty(property) && t.isExpression(property.value)) {\n const deriveErrors: string[] = [];\n validateDerive(property.value, state, deriveErrors);\n if (deriveErrors.length === 0) {\n return { errors, hasDeriveExpression: true };\n }\n }\n\n // Neither string nor derive — return original errors\n errors.push(...validation.errors);\n return { errors };\n}\n\n/**\n * Validate that an object property is a string literal\n */\nfunction validateObjectPropertyIsStringLiteral(\n arg: t.SpreadElement | t.ObjectMethod | t.ObjectProperty,\n name: string\n): {\n errors: string[];\n value?: string;\n} {\n const errors: string[] = [];\n\n // Validate the property is a string literal from an expression\n if (\n !t.isObjectProperty(arg) ||\n !t.isExpression(arg.value) ||\n !validateExpressionIsStringLiteral(arg.value)\n ) {\n errors.push(\n `The <${GT_COMPONENT_TYPES.T}> component must have a string literal in its ${name} field`\n );\n return { errors };\n }\n\n // Get the string literal\n const value = getStringLiteralFromExpression(arg.value);\n return { errors, value };\n}\n\n/**\n * Given an expression, return the string literal (throws an error if not a string literal)\n */\nfunction getStringLiteralFromExpression(\n expr: t.Expression\n): string | undefined {\n if (t.isStringLiteral(expr)) {\n return expr.value;\n }\n if (t.isTemplateLiteral(expr)) {\n if (expr.expressions.length === 0) {\n return expr.quasis[0]?.value.cooked || '';\n }\n }\n}\n\n// Number Literal Functions\n\n/**\n * Will validate and retrieve property from object expression and also try prefixing with a $\n */\nfunction validateNumberProperty(\n args: t.ObjectExpression,\n name: string\n): {\n errors: string[];\n value?: number;\n} {\n const errors: string[] = [];\n\n // Get the property\n const property =\n getObjectPropertyFromObjectExpression(args, name) ||\n getObjectPropertyFromObjectExpression(args, '$' + name);\n if (!property) {\n return { errors };\n }\n\n // Validate property\n const validation = validateObjectPropertyIsNumberLiteral(property, name);\n errors.push(...validation.errors);\n const value = validation.value;\n\n return { errors, value };\n}\n\n/**\n * Validate that an object property is a number literal\n */\nfunction validateObjectPropertyIsNumberLiteral(\n arg: t.SpreadElement | t.ObjectMethod | t.ObjectProperty,\n name: string\n): {\n errors: string[];\n value?: number;\n} {\n const errors: string[] = [];\n\n // Validate the property is a string literal from an expression\n if (\n !t.isObjectProperty(arg) ||\n !t.isExpression(arg.value) ||\n !validateExpressionIsNumericLiteral(arg.value)\n ) {\n errors.push(\n `The <${GT_COMPONENT_TYPES.T}> component must have a number literal in its ${name} field`\n );\n return { errors };\n }\n\n // Get the number literal\n const value = getNumberLiteralFromExpression(arg.value);\n\n // Validate it is an integer\n if (value !== undefined && !validateNumberLiteralIsInteger(value)) {\n errors.push(\n `The <${GT_COMPONENT_TYPES.T}> component must have an integer in its ${name} field`\n );\n return { errors };\n }\n\n return { errors, value };\n}\n\n/**\n * Given an expression, return the number literal (throws an error if not a number literal)\n */\nfunction getNumberLiteralFromExpression(\n expr: t.Expression\n): number | undefined {\n if (t.isNumericLiteral(expr)) {\n return expr.value;\n }\n // handle numbers with unary operators\n if (t.isUnaryExpression(expr) && t.isNumericLiteral(expr.argument)) {\n // On purpose, we are taking the absolute value of the number literal\n return expr.argument.value;\n }\n}\n\n/**\n * Validate that a number literal is an integer\n */\nfunction validateNumberLiteralIsInteger(value: number): boolean {\n return Number.isInteger(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAgB,iCACd,cACA,eACA,OASA;CACA,MAAM,WAAW,aAAa;AAE9B,KAAI,SAAS,UAAU,SAAS,EAI9B,QAAO,EAAE,QAAA,CAFP,0EAEa,EAAE;CAInB,MAAM,OAAO,SAAS,UAAU;AAChC,KAAI,CAACA,aAAE,mBAAmB,KAAK,CAI7B,QAAO,EAAE,QAAA,CAFP,8EAEa,EAAE;CAEnB,MAAM,WAAW,aAAa,IAAI,YAAY,CAAC;AAC/C,KAAI,EAAA,aAAA,QAAA,aAAA,KAAA,IAAA,KAAA,IAAC,SAAU,oBAAoB,EAIjC,QAAO,EAAE,QAAA,CAFP,8EAEa,EAAE;AAInB,SAAQ,eAAR;EACE,KAAA;EACA,KAAA,yBACE,QAAO,uBACL,UACA,MACD;EACH,QAIE,QAAO,EAAE,QAAA,CAFP,kCAAkC,cAAc,qFAEnC,EAAE;;;AAQvB,SAAS,uBACP,UACA,OASA;CACA,MAAM,SAAmB,EAAE;CAC3B,MAAM,OAAO,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mB,EAAE;CAG3B,MAAM,WACJG,4DAAAA,sCAAsC,MAAM,KAAK,IACjDA,4DAAAA,sCAAsC,MAAM,MAAM,KAAK;AACzD,KAAI,CAAC,SACH,QAAO,EAAE,QAAQ;CAInB,MAAM,aAAa,sCAAsC,UAAU,KAAK;AACxE,QAAO,KAAK,GAAG,WAAW,OAAO;AAGjC,QAAO;EAAE;EAAQ,OAFH,WAAW;EAED;;;;;AAM1B,SAAS,sCACP,KACA,MAIA;CACA,MAAM,SAAmB,EAAE;AAG3B,KACE,CAACH,aAAE,iBAAiB,IAAI,IACxB,CAACA,aAAE,aAAa,IAAI,MAAM,IAC1B,CAACK,4DAAAA,mCAAmC,IAAI,MAAM,EAC9C;AACA,SAAO,KACL,uDAA6E,KAAK,QACnF;AACD,SAAO,EAAE,QAAQ;;CAInB,MAAM,QAAQ,+BAA+B,IAAI,MAAM;AAGvD,KAAI,UAAU,KAAA,KAAa,CAAC,+BAA+B,MAAM,EAAE;AACjE,SAAO,KACL,iDAAuE,KAAK,QAC7E;AACD,SAAO,EAAE,QAAQ;;AAGnB,QAAO;EAAE;EAAQ;EAAO;;;;;AAM1B,SAAS,+BACP,MACoB;AACpB,KAAIL,aAAE,iBAAiB,KAAK,CAC1B,QAAO,KAAK;AAGd,KAAIA,aAAE,kBAAkB,KAAK,IAAIA,aAAE,iBAAiB,KAAK,SAAS,CAEhE,QAAO,KAAK,SAAS;;;;;AAOzB,SAAS,+BAA+B,OAAwB;AAC9D,QAAO,OAAO,UAAU,MAAM"}
1
+ {"version":3,"file":"validateTranslationComponentArgs.js","names":["t","validateChildrenPropertyFromObjectExpression","constructJsxChildren","getObjectPropertyFromObjectExpression","validateExpressionIsStringLiteral","validateExpressionIsNumericLiteral"],"sources":["../../../src/transform/validation/validateTranslationComponentArgs.ts"],"sourcesContent":["import { TransformState } from '../../state/types';\nimport { GT_COMPONENT_TYPES } from '../../utils/constants/gt/constants';\nimport * as t from '@babel/types';\nimport type { NodePath } from '@babel/traverse';\nimport { getObjectPropertyFromObjectExpression } from '../../utils/parsing/getObjectPropertyFromObjectExpression';\nimport { validateExpressionIsStringLiteral } from '../../utils/validation/validateExpressionIsStringLiteral';\nimport type { JsxChildren } from '@generaltranslation/format/types';\nimport { constructJsxChildren } from '../jsx-children/constructJsxChildren';\nimport { validateChildrenPropertyFromObjectExpression } from '../../utils/validation/validateChildrenFromObjectExpression';\nimport { validateExpressionIsNumericLiteral } from '../../utils/validation/validateExpressionIsNumericLiteral';\nimport { validateDerive } from './validateTranslationFunction';\nimport { JsxValidationError } from '../jsx-children/errors';\n/**\n * Given a translation component, validate the arguments\n */\nexport function validateTranslationComponentArgs(\n callExprPath: NodePath<t.CallExpression>,\n canonicalName: string,\n state: TransformState\n): {\n errors: string[];\n _hash?: string;\n id?: string;\n context?: string;\n maxChars?: number;\n children?: JsxChildren;\n hasDeriveContext?: boolean;\n} {\n const callExpr = callExprPath.node;\n // Check that there are at least 2 arguments (identifier, args)\n if (callExpr.arguments.length < 2) {\n const errors = [\n 'Translation component must have at least 2 arguments (identifier, args)',\n ];\n return { errors };\n }\n\n // Get the component args\n const args = callExpr.arguments[1];\n if (!t.isObjectExpression(args)) {\n const errors = [\n 'Translation component must have an object expression as the second argument',\n ];\n return { errors };\n }\n const argsPath = callExprPath.get('arguments')[1];\n if (!argsPath?.isObjectExpression()) {\n const errors = [\n 'Translation component must have an object expression as the second argument',\n ];\n return { errors };\n }\n\n // Map to appropriate validation function\n switch (canonicalName) {\n case GT_COMPONENT_TYPES.T:\n case GT_COMPONENT_TYPES.GtInternalTranslateJsx:\n return validateTComponentArgs(\n argsPath as NodePath<t.ObjectExpression>,\n state\n );\n default:\n const errors = [\n `Invalid translation component: ${canonicalName}. You likely passed a non-translation component to validateTranslationComponentArgs`,\n ];\n return { errors };\n }\n}\n\n/* =============================== */\n/* Helper Functions */\n/* =============================== */\n\nfunction validateTComponentArgs(\n argsPath: NodePath<t.ObjectExpression>,\n state: TransformState\n): {\n errors: string[];\n _hash?: string;\n id?: string;\n context?: string;\n maxChars?: number;\n children?: JsxChildren;\n hasDeriveContext?: boolean;\n} {\n const errors: string[] = [];\n const args = argsPath.node;\n\n // Validate id\n const idValidation = validateStringProperty(args, 'id');\n errors.push(...idValidation.errors);\n const id = idValidation.value;\n\n // Validate context (with derive fallback)\n const contextValidation = validateStringProperty(args, 'context', state);\n errors.push(...contextValidation.errors);\n const context = contextValidation.value;\n // Validate maxChars\n const maxCharsValidation = validateNumberProperty(args, 'maxChars');\n errors.push(...maxCharsValidation.errors);\n const maxChars = maxCharsValidation.value;\n\n // Validate hash\n const hashValidation = validateStringProperty(args, '_hash');\n errors.push(...hashValidation.errors);\n const _hash = hashValidation.value;\n\n // Validate children\n const childrenValidation = validateChildrenProperty(argsPath, state);\n errors.push(...childrenValidation.errors);\n const children = childrenValidation.value;\n\n const hasDeriveContext =\n contextValidation.hasDeriveExpression || childrenValidation.hasAutoderive;\n\n return { errors, id, context, _hash, maxChars, children, hasDeriveContext };\n}\n\n/**\n * Validate that the children property is a string literal\n */\nexport function validateChildrenProperty(\n argsPath: NodePath<t.ObjectExpression>,\n state: TransformState\n): {\n errors: string[];\n value?: JsxChildren;\n hasAutoderive?: boolean;\n} {\n const errors: string[] = [];\n\n // Get the children property\n const childrenValidation =\n validateChildrenPropertyFromObjectExpression(argsPath);\n if (childrenValidation.errors.length > 0) {\n errors.push(...childrenValidation.errors);\n return { errors };\n }\n const children = childrenValidation.value;\n if (children === undefined) {\n errors.push(`The <${GT_COMPONENT_TYPES.T}> component must have children`);\n return { errors };\n }\n\n // constructJsxChildren now returns JsxValidationError[]\n const validation = constructJsxChildren(children, state);\n\n // Autoderive: filter out dynamic-content errors\n let hasAutoderive = false;\n let filteredErrors: JsxValidationError[] = validation.errors;\n if (state.settings.autoderive.jsx) {\n filteredErrors = validation.errors.filter(\n (e) => e.type !== 'dynamic-content'\n );\n hasAutoderive = filteredErrors.length < validation.errors.length;\n }\n\n // Convert structured errors back to strings\n errors.push(...filteredErrors.map((e) => e.message));\n const value = validation.value;\n\n return { errors, value, hasAutoderive };\n}\n\n// String Literal Functions\n\n/**\n * Will validate and retrieve property from object expression and also try prefixing with a $\n *\n */\nfunction validateStringProperty(\n args: t.ObjectExpression,\n name: string,\n state?: TransformState\n): {\n errors: string[];\n value?: string;\n hasDeriveExpression?: boolean;\n} {\n const errors: string[] = [];\n\n // Get the property\n const property =\n getObjectPropertyFromObjectExpression(args, name) ||\n getObjectPropertyFromObjectExpression(args, '$' + name);\n if (!property) {\n return { errors };\n }\n\n // Validate property\n const validation = validateObjectPropertyIsStringLiteral(property, name);\n if (validation.errors.length === 0) {\n return { errors, value: validation.value };\n }\n\n // String validation failed — check if it's a valid derive() expression\n if (state && t.isObjectProperty(property) && t.isExpression(property.value)) {\n const deriveErrors: string[] = [];\n validateDerive(property.value, state, deriveErrors);\n if (deriveErrors.length === 0) {\n return { errors, hasDeriveExpression: true };\n }\n }\n\n // Neither string nor derive — return original errors\n errors.push(...validation.errors);\n return { errors };\n}\n\n/**\n * Validate that an object property is a string literal\n */\nfunction validateObjectPropertyIsStringLiteral(\n arg: t.SpreadElement | t.ObjectMethod | t.ObjectProperty,\n name: string\n): {\n errors: string[];\n value?: string;\n} {\n const errors: string[] = [];\n\n // Validate the property is a string literal from an expression\n if (\n !t.isObjectProperty(arg) ||\n !t.isExpression(arg.value) ||\n !validateExpressionIsStringLiteral(arg.value)\n ) {\n errors.push(\n `The <${GT_COMPONENT_TYPES.T}> component must have a string literal in its ${name} field`\n );\n return { errors };\n }\n\n // Get the string literal\n const value = getStringLiteralFromExpression(arg.value);\n return { errors, value };\n}\n\n/**\n * Given an expression, return the string literal (throws an error if not a string literal)\n */\nfunction getStringLiteralFromExpression(\n expr: t.Expression\n): string | undefined {\n if (t.isStringLiteral(expr)) {\n return expr.value;\n }\n if (t.isTemplateLiteral(expr)) {\n if (expr.expressions.length === 0) {\n return expr.quasis[0]?.value.cooked || '';\n }\n }\n}\n\n// Number Literal Functions\n\n/**\n * Will validate and retrieve property from object expression and also try prefixing with a $\n */\nfunction validateNumberProperty(\n args: t.ObjectExpression,\n name: string\n): {\n errors: string[];\n value?: number;\n} {\n const errors: string[] = [];\n\n // Get the property\n const property =\n getObjectPropertyFromObjectExpression(args, name) ||\n getObjectPropertyFromObjectExpression(args, '$' + name);\n if (!property) {\n return { errors };\n }\n\n // Validate property\n const validation = validateObjectPropertyIsNumberLiteral(property, name);\n errors.push(...validation.errors);\n const value = validation.value;\n\n return { errors, value };\n}\n\n/**\n * Validate that an object property is a number literal\n */\nfunction validateObjectPropertyIsNumberLiteral(\n arg: t.SpreadElement | t.ObjectMethod | t.ObjectProperty,\n name: string\n): {\n errors: string[];\n value?: number;\n} {\n const errors: string[] = [];\n\n // Validate the property is a string literal from an expression\n if (\n !t.isObjectProperty(arg) ||\n !t.isExpression(arg.value) ||\n !validateExpressionIsNumericLiteral(arg.value)\n ) {\n errors.push(\n `The <${GT_COMPONENT_TYPES.T}> component must have a number literal in its ${name} field`\n );\n return { errors };\n }\n\n // Get the number literal\n const value = getNumberLiteralFromExpression(arg.value);\n\n // Validate it is an integer\n if (value !== undefined && !validateNumberLiteralIsInteger(value)) {\n errors.push(\n `The <${GT_COMPONENT_TYPES.T}> component must have an integer in its ${name} field`\n );\n return { errors };\n }\n\n return { errors, value };\n}\n\n/**\n * Given an expression, return the number literal (throws an error if not a number literal)\n */\nfunction getNumberLiteralFromExpression(\n expr: t.Expression\n): number | undefined {\n if (t.isNumericLiteral(expr)) {\n return expr.value;\n }\n // handle numbers with unary operators\n if (t.isUnaryExpression(expr) && t.isNumericLiteral(expr.argument)) {\n // On purpose, we are taking the absolute value of the number literal\n return expr.argument.value;\n }\n}\n\n/**\n * Validate that a number literal is an integer\n */\nfunction validateNumberLiteralIsInteger(value: number): boolean {\n return Number.isInteger(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,iCACd,cACA,eACA,OASA;CACA,MAAM,WAAW,aAAa;AAE9B,KAAI,SAAS,UAAU,S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;;;AAM1B,SAAS,+BACP,MACoB;AACpB,KAAIL,aAAE,iBAAiB,KAAK,CAC1B,QAAO,KAAK;AAGd,KAAIA,aAAE,kBAAkB,KAAK,IAAIA,aAAE,iBAAiB,KAAK,SAAS,CAEhE,QAAO,KAAK,SAAS;;;;;AAOzB,SAAS,+BAA+B,OAAwB;AAC9D,QAAO,OAAO,UAAU,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@generaltranslation/compiler",
3
- "version": "1.3.25-odysseus.0",
3
+ "version": "1.3.25-odysseus.4",
4
4
  "description": "Universal plugin for compile-time optimization of GT translation components",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,8 +24,8 @@
24
24
  "@babel/traverse": "^7.23.0",
25
25
  "@babel/types": "^7.23.0",
26
26
  "unplugin": "^2.3.10",
27
- "@generaltranslation/format": "0.1.2-odysseus.0",
28
- "generaltranslation": "9.0.0-odysseus.0"
27
+ "@generaltranslation/format": "0.1.2-odysseus.1",
28
+ "generaltranslation": "9.0.0-odysseus.4"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/babel__core": "^7.20.0",
@@ -1,15 +0,0 @@
1
- export * from './processArrowFunctionExpression';
2
- export * from './processAssignmentExpression';
3
- export * from './processCatchClause';
4
- export * from './processClassDeclaration';
5
- export * from './processClassMethod';
6
- export * from './processClassPrivateMethod';
7
- export * from './processForInStatement';
8
- export * from './processForOfStatement';
9
- export * from './processFunctionDeclaration';
10
- export * from './processFunctionExpression';
11
- export * from './processImportDeclaration';
12
- export * from './processObjectMethod';
13
- export * from './processProgram';
14
- export * from './processScopeChange';
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/processing/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
@@ -1,29 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_processing_processArrowFunctionExpression = require("./processArrowFunctionExpression.js");
3
- const require_processing_processAssignmentExpression = require("./processAssignmentExpression.js");
4
- const require_processing_processCatchClause = require("./processCatchClause.js");
5
- const require_processing_processClassDeclaration = require("./processClassDeclaration.js");
6
- const require_processing_processClassMethod = require("./processClassMethod.js");
7
- const require_processing_processClassPrivateMethod = require("./processClassPrivateMethod.js");
8
- const require_processing_processForInStatement = require("./processForInStatement.js");
9
- const require_processing_processForOfStatement = require("./processForOfStatement.js");
10
- const require_processing_processFunctionDeclaration = require("./processFunctionDeclaration.js");
11
- const require_processing_processFunctionExpression = require("./processFunctionExpression.js");
12
- const require_processing_processImportDeclaration = require("./processImportDeclaration.js");
13
- const require_processing_processObjectMethod = require("./processObjectMethod.js");
14
- const require_processing_processProgram = require("./processProgram.js");
15
- const require_processing_processScopeChange = require("./processScopeChange.js");
16
- exports.processArrowFunctionExpression = require_processing_processArrowFunctionExpression.processArrowFunctionExpression;
17
- exports.processAssignmentExpression = require_processing_processAssignmentExpression.processAssignmentExpression;
18
- exports.processCatchClause = require_processing_processCatchClause.processCatchClause;
19
- exports.processClassDeclaration = require_processing_processClassDeclaration.processClassDeclaration;
20
- exports.processClassMethod = require_processing_processClassMethod.processClassMethod;
21
- exports.processClassPrivateMethod = require_processing_processClassPrivateMethod.processClassPrivateMethod;
22
- exports.processForInStatement = require_processing_processForInStatement.processForInStatement;
23
- exports.processForOfStatement = require_processing_processForOfStatement.processForOfStatement;
24
- exports.processFunctionDeclaration = require_processing_processFunctionDeclaration.processFunctionDeclaration;
25
- exports.processFunctionExpression = require_processing_processFunctionExpression.processFunctionExpression;
26
- exports.processImportDeclaration = require_processing_processImportDeclaration.processImportDeclaration;
27
- exports.processObjectMethod = require_processing_processObjectMethod.processObjectMethod;
28
- exports.processProgram = require_processing_processProgram.processProgram;
29
- exports.processScopeChange = require_processing_processScopeChange.processScopeChange;
@@ -1,2 +0,0 @@
1
- export { constructJsxChildren } from './constructJsxChildren';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/jsx-children/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,3 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_transform_jsx_children_constructJsxChildren = require("./constructJsxChildren.js");
3
- exports.constructJsxChildren = require_transform_jsx_children_constructJsxChildren.constructJsxChildren;