@generaltranslation/compiler 1.3.31 → 1.3.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.d.ts CHANGED
@@ -1,34 +1,10 @@
1
1
  /**
2
2
  * Configuration types for the GT Babel plugin
3
3
  */
4
+ import type { GTConfig as SharedGTConfig } from 'generaltranslation/types';
4
5
  export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';
5
- /**
6
- * The only relevant parts of the GT config that we are concerned with
7
- */
8
- export type GTConfig = {
9
- defaultLocale?: string;
10
- locales?: string[];
11
- projectId?: string;
12
- _versionId?: string;
13
- files?: {
14
- gt?: {
15
- output?: string;
16
- parsingFlags?: {
17
- enableAutoJsxInjection?: boolean;
18
- autoderive?: boolean | {
19
- jsx?: boolean;
20
- strings?: boolean;
21
- };
22
- legacyGtReactImportSource?: boolean;
23
- /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */
24
- devHotReload?: boolean | {
25
- strings?: boolean;
26
- jsx?: boolean;
27
- };
28
- };
29
- };
30
- };
31
- };
6
+ /** A complete or partial gt.config.json accepted by compiler integrations. */
7
+ export type GTConfig = Partial<SharedGTConfig>;
32
8
  /**
33
9
  * Plugin configuration options (from babel config)
34
10
  */
@@ -47,6 +23,8 @@ export interface PluginConfig {
47
23
  stringTranslationMacro?: string;
48
24
  /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */
49
25
  enableAutoJsxInjection?: boolean;
26
+ /** Package source for components inserted by Auto JSX Injection */
27
+ autoJsxImportSource?: string;
50
28
  /** Automatically treat interpolated/concatenated values as derive() calls */
51
29
  autoderive?: boolean | {
52
30
  jsx?: boolean;
@@ -78,6 +56,8 @@ export interface PluginSettings {
78
56
  enableMacroImportInjection: boolean;
79
57
  /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */
80
58
  enableAutoJsxInjection: boolean;
59
+ /** Package source for components inserted by Auto JSX Injection */
60
+ autoJsxImportSource?: string;
81
61
  /** Automatically treat interpolated/concatenated values as derive() calls */
82
62
  autoderive: {
83
63
  jsx: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE;QACN,EAAE,CAAC,EAAE;YACH,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,YAAY,CAAC,EAAE;gBACb,sBAAsB,CAAC,EAAE,OAAO,CAAC;gBACjC,UAAU,CAAC,EAAE,OAAO,GAAG;oBAAE,GAAG,CAAC,EAAE,OAAO,CAAC;oBAAC,OAAO,CAAC,EAAE,OAAO,CAAA;iBAAE,CAAC;gBAC5D,yBAAyB,CAAC,EAAE,OAAO,CAAC;gBACpC,mFAAmF;gBACnF,YAAY,CAAC,EAAE,OAAO,GAAG;oBAAE,OAAO,CAAC,EAAE,OAAO,CAAC;oBAAC,GAAG,CAAC,EAAE,OAAO,CAAA;iBAAE,CAAC;aAC/D,CAAC;SACH,CAAC;KACH,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,0DAA0D;IAC1D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gDAAgD;IAChD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IA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AAE,CAAC;CAClD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,GAAG;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAChE;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAKpC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GAChE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,CAKpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Configuration types for the GT Babel plugin\n */\n\nexport type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';\n\n/**\n * The only relevant parts of the GT config that we are concerned with\n */\nexport type GTConfig = {\n defaultLocale?: string;\n locales?: string[];\n projectId?: string;\n _versionId?: string;\n files?: {\n gt?: {\n output?: string;\n parsingFlags?: {\n enableAutoJsxInjection?: boolean;\n autoderive?: boolean | { jsx?: boolean; strings?: boolean };\n legacyGtReactImportSource?: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload?: boolean | { strings?: boolean; jsx?: boolean };\n };\n };\n };\n};\n\n/**\n * Plugin configuration options (from babel config)\n */\nexport interface PluginConfig {\n /** Log level for the plugin */\n logLevel?: LogLevel;\n /** GT Configuration object — pass the parsed gt.config.json to sync settings */\n gtConfig?: GTConfig;\n /** Enable compile-time hash generation (default: true) */\n compileTimeHash?: boolean;\n /** Disable dynamic content validation checks */\n disableBuildChecks?: boolean;\n /** Enable macro transform (t`...`, t(`...`), t(\"a\" + b)) */\n enableMacroTransform?: boolean;\n /** Name of the string translation macro function */\n stringTranslationMacro?: string;\n /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */\n enableAutoJsxInjection?: boolean;\n /** Automatically treat interpolated/concatenated values as derive() calls */\n autoderive?: boolean | { jsx?: boolean; strings?: boolean };\n /** Emit compiler-injected gt-react imports from gt-react/browser */\n legacyGtReactImportSource?: boolean;\n /** Debug: write a hash → jsxChildren manifest file on build */\n _debugHashManifest?: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload?: boolean | { strings?: boolean; jsx?: boolean };\n}\n\n/**\n * Internal plugin settings (processed config)\n */\nexport interface PluginSettings {\n logLevel: LogLevel;\n compileTimeHash: boolean;\n disableBuildChecks: boolean;\n filename?: string;\n enableMacroTransform: boolean;\n stringTranslationMacro: string;\n enableTaggedTemplate: boolean;\n enableTemplateLiteralArg: boolean;\n enableConcatenationArg: boolean;\n enableMacroImportInjection: boolean;\n /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */\n enableAutoJsxInjection: boolean;\n /** Automatically treat interpolated/concatenated values as derive() calls */\n autoderive: { jsx: boolean; strings: boolean };\n /** Emit compiler-injected gt-react imports from gt-react/browser */\n legacyGtReactImportSource: boolean;\n /** Debug: write a hash → jsxChildren manifest file on build */\n _debugHashManifest: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload: { strings: boolean; jsx: boolean };\n}\n\n/**\n * Resolves the autoderive config value into separate jsx and strings flags.\n * - `true` enables both (backward compatible)\n * - `false` disables both (backward compatible)\n * - `{ jsx?: boolean; strings?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveAutoderive(\n value: boolean | { jsx?: boolean; strings?: boolean } | undefined\n): { jsx: boolean; strings: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { jsx: !!value, strings: !!value };\n }\n return { jsx: value.jsx ?? false, strings: value.strings ?? false };\n}\n\n/**\n * Resolves the devHotReload config value into separate strings and jsx flags.\n * - `true` enables strings only (JSX is handled at runtime via Suspense, no compiler injection needed)\n * - `false` disables both\n * - `{ strings?: boolean; jsx?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveDevHotReload(\n value: boolean | { strings?: boolean; jsx?: boolean } | undefined\n): { strings: boolean; jsx: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { strings: !!value, jsx: false };\n }\n return { strings: value.strings ?? false, jsx: value.jsx ?? false };\n}\n"],"mappings":";;;;;;;;AAwFA,SAAgB,kBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,KAAK,CAAC,CAAC;EAAO,SAAS,CAAC,CAAC;EAAO;AAE3C,QAAO;EAAE,KAAK,MAAM,OAAO;EAAO,SAAS,MAAM,WAAW;EAAO;;;;;;;;AASrE,SAAgB,oBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,SAAS,CAAC,CAAC;EAAO,KAAK;EAAO;AAEzC,QAAO;EAAE,SAAS,MAAM,WAAW;EAAO,KAAK,MAAM,OAAO;EAAO"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["/**\n * Configuration types for the GT Babel plugin\n */\n\nimport type { GTConfig as SharedGTConfig } from 'generaltranslation/types';\n\nexport type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug';\n\n/** A complete or partial gt.config.json accepted by compiler integrations. */\nexport type GTConfig = Partial<SharedGTConfig>;\n\n/**\n * Plugin configuration options (from babel config)\n */\nexport interface PluginConfig {\n /** Log level for the plugin */\n logLevel?: LogLevel;\n /** GT Configuration object — pass the parsed gt.config.json to sync settings */\n gtConfig?: GTConfig;\n /** Enable compile-time hash generation (default: true) */\n compileTimeHash?: boolean;\n /** Disable dynamic content validation checks */\n disableBuildChecks?: boolean;\n /** Enable macro transform (t`...`, t(`...`), t(\"a\" + b)) */\n enableMacroTransform?: boolean;\n /** Name of the string translation macro function */\n stringTranslationMacro?: string;\n /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */\n enableAutoJsxInjection?: boolean;\n /** Package source for components inserted by Auto JSX Injection */\n autoJsxImportSource?: string;\n /** Automatically treat interpolated/concatenated values as derive() calls */\n autoderive?: boolean | { jsx?: boolean; strings?: boolean };\n /** Emit compiler-injected gt-react imports from gt-react/browser */\n legacyGtReactImportSource?: boolean;\n /** Debug: write a hash → jsxChildren manifest file on build */\n _debugHashManifest?: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload?: boolean | { strings?: boolean; jsx?: boolean };\n}\n\n/**\n * Internal plugin settings (processed config)\n */\nexport interface PluginSettings {\n logLevel: LogLevel;\n compileTimeHash: boolean;\n disableBuildChecks: boolean;\n filename?: string;\n enableMacroTransform: boolean;\n stringTranslationMacro: string;\n enableTaggedTemplate: boolean;\n enableTemplateLiteralArg: boolean;\n enableConcatenationArg: boolean;\n enableMacroImportInjection: boolean;\n /** Enable Auto Jsx Injection (e.g. <div>Hello</div> -> <div><T>Hello</T></div>) */\n enableAutoJsxInjection: boolean;\n /** Package source for components inserted by Auto JSX Injection */\n autoJsxImportSource?: string;\n /** Automatically treat interpolated/concatenated values as derive() calls */\n autoderive: { jsx: boolean; strings: boolean };\n /** Emit compiler-injected gt-react imports from gt-react/browser */\n legacyGtReactImportSource: boolean;\n /** Debug: write a hash → jsxChildren manifest file on build */\n _debugHashManifest: boolean;\n /** Dev hot reload: inject runtime translate calls and enable Suspense-based <T> */\n devHotReload: { strings: boolean; jsx: boolean };\n}\n\n/**\n * Resolves the autoderive config value into separate jsx and strings flags.\n * - `true` enables both (backward compatible)\n * - `false` disables both (backward compatible)\n * - `{ jsx?: boolean; strings?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveAutoderive(\n value: boolean | { jsx?: boolean; strings?: boolean } | undefined\n): { jsx: boolean; strings: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { jsx: !!value, strings: !!value };\n }\n return { jsx: value.jsx ?? false, strings: value.strings ?? false };\n}\n\n/**\n * Resolves the devHotReload config value into separate strings and jsx flags.\n * - `true` enables strings only (JSX is handled at runtime via Suspense, no compiler injection needed)\n * - `false` disables both\n * - `{ strings?: boolean; jsx?: boolean }` enables selectively (missing keys default to false)\n */\nexport function resolveDevHotReload(\n value: boolean | { strings?: boolean; jsx?: boolean } | undefined\n): { strings: boolean; jsx: boolean } {\n if (value === undefined || typeof value === 'boolean') {\n return { strings: !!value, jsx: false };\n }\n return { strings: value.strings ?? false, jsx: value.jsx ?? false };\n}\n"],"mappings":";;;;;;;;AA2EA,SAAgB,kBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,KAAK,CAAC,CAAC;EAAO,SAAS,CAAC,CAAC;EAAO;AAE3C,QAAO;EAAE,KAAK,MAAM,OAAO;EAAO,SAAS,MAAM,WAAW;EAAO;;;;;;;;AASrE,SAAgB,oBACd,OACoC;AACpC,KAAI,UAAU,KAAA,KAAa,OAAO,UAAU,UAC1C,QAAO;EAAE,SAAS,CAAC,CAAC;EAAO,KAAK;EAAO;AAEzC,QAAO;EAAE,SAAS,MAAM,WAAW;EAAO,KAAK,MAAM,OAAO;EAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsxInsertionPass.d.ts","sourceRoot":"","sources":["../../src/passes/jsxInsertionPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQhD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAuBvE"}
1
+ {"version":3,"file":"jsxInsertionPass.d.ts","sourceRoot":"","sources":["../../src/passes/jsxInsertionPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAQhD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CA2BvE"}
@@ -21,7 +21,7 @@ function jsxInsertionPass(state) {
21
21
  alreadyImported = true;
22
22
  };
23
23
  return {
24
- ImportDeclaration: require_processing_jsx_insertion_processImportDeclaration.processImportDeclaration(onImportFound, calleeInfo),
24
+ ImportDeclaration: require_processing_jsx_insertion_processImportDeclaration.processImportDeclaration(onImportFound, calleeInfo, state.settings.autoJsxImportSource),
25
25
  CallExpression: require_processing_jsx_insertion_processCallExpression.processCallExpression(state, calleeInfo),
26
26
  Program: require_processing_jsx_insertion_processProgram.processProgram({
27
27
  state,
@@ -1 +1 @@
1
- {"version":3,"file":"jsxInsertionPass.js","names":["processImportDeclaration","processCallExpression","processProgram"],"sources":["../../src/passes/jsxInsertionPass.ts"],"sourcesContent":["import { TraverseOptions } from '@babel/traverse';\nimport { TransformState } from '../state/types';\nimport { processCallExpression } from '../processing/jsx-insertion/processCallExpression';\nimport {\n processImportDeclaration,\n JsxCalleeInfo,\n} from '../processing/jsx-insertion/processImportDeclaration';\nimport { processProgram } from '../processing/jsx-insertion/processProgram';\n\n/**\n * The purpose of this pass is to insert the translation component (GtInternalTranslateJsx)\n * and variable component (GtInternalVar) automatically into the Jsx tree.\n * This is specifically for browser builds only.\n *\n * <div>Hello</div> -> <div><GtInternalTranslateJsx>Hello</GtInternalTranslateJsx></div>\n */\nexport function jsxInsertionPass(state: TransformState): TraverseOptions {\n let alreadyImported = false;\n const countBefore = state.statistics.jsxInsertionsCount;\n\n const calleeInfo: JsxCalleeInfo = {\n singleCallee: null,\n multiCallee: null,\n };\n\n const onImportFound = () => {\n alreadyImported = true;\n };\n\n return {\n ImportDeclaration: processImportDeclaration(onImportFound, calleeInfo),\n CallExpression: processCallExpression(state, calleeInfo),\n Program: processProgram({\n state,\n countBefore,\n isAlreadyImported: () => alreadyImported,\n calleeInfo,\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,iBAAiB,OAAwC;CACvE,IAAI,kBAAkB;CACtB,MAAM,cAAc,MAAM,WAAW;CAErC,MAAM,aAA4B;EAChC,cAAc;EACd,aAAa;EACd;CAED,MAAM,sBAAsB;AAC1B,oBAAkB;;AAGpB,QAAO;EACL,mBAAmBA,0DAAAA,yBAAyB,eAAe,WAAW;EACtE,gBAAgBC,uDAAAA,sBAAsB,OAAO,WAAW;EACxD,SAASC,gDAAAA,eAAe;GACtB;GACA;GACA,yBAAyB;GACzB;GACD,CAAC;EACH"}
1
+ {"version":3,"file":"jsxInsertionPass.js","names":["processImportDeclaration","processCallExpression","processProgram"],"sources":["../../src/passes/jsxInsertionPass.ts"],"sourcesContent":["import { TraverseOptions } from '@babel/traverse';\nimport { TransformState } from '../state/types';\nimport { processCallExpression } from '../processing/jsx-insertion/processCallExpression';\nimport {\n processImportDeclaration,\n JsxCalleeInfo,\n} from '../processing/jsx-insertion/processImportDeclaration';\nimport { processProgram } from '../processing/jsx-insertion/processProgram';\n\n/**\n * The purpose of this pass is to insert the translation component (GtInternalTranslateJsx)\n * and variable component (GtInternalVar) automatically into the Jsx tree.\n * This is specifically for browser builds only.\n *\n * <div>Hello</div> -> <div><GtInternalTranslateJsx>Hello</GtInternalTranslateJsx></div>\n */\nexport function jsxInsertionPass(state: TransformState): TraverseOptions {\n let alreadyImported = false;\n const countBefore = state.statistics.jsxInsertionsCount;\n\n const calleeInfo: JsxCalleeInfo = {\n singleCallee: null,\n multiCallee: null,\n };\n\n const onImportFound = () => {\n alreadyImported = true;\n };\n\n return {\n ImportDeclaration: processImportDeclaration(\n onImportFound,\n calleeInfo,\n state.settings.autoJsxImportSource\n ),\n CallExpression: processCallExpression(state, calleeInfo),\n Program: processProgram({\n state,\n countBefore,\n isAlreadyImported: () => alreadyImported,\n calleeInfo,\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,iBAAiB,OAAwC;CACvE,IAAI,kBAAkB;CACtB,MAAM,cAAc,MAAM,WAAW;CAErC,MAAM,aAA4B;EAChC,cAAc;EACd,aAAa;EACd;CAED,MAAM,sBAAsB;AAC1B,oBAAkB;;AAGpB,QAAO;EACL,mBAAmBA,0DAAAA,yBACjB,eACA,YACA,MAAM,SAAS,oBAChB;EACD,gBAAgBC,uDAAAA,sBAAsB,OAAO,WAAW;EACxD,SAASC,gDAAAA,eAAe;GACtB;GACA;GACA,yBAAyB;GACzB;GACD,CAAC;EACH"}
@@ -16,5 +16,5 @@ export interface JsxCalleeInfo {
16
16
  * - Checks if GtInternalTranslateJsx is already imported from a GT source.
17
17
  * - Collects React jsx callee info (jsx vs jsxs vs jsxDEV, including aliases).
18
18
  */
19
- export declare function processImportDeclaration(onGtImportFound: () => void, calleeInfo: JsxCalleeInfo): VisitNode<t.Node, t.ImportDeclaration>;
19
+ export declare function processImportDeclaration(onGtImportFound: () => void, calleeInfo: JsxCalleeInfo, autoJsxImportSource?: string): VisitNode<t.Node, t.ImportDeclaration>;
20
20
  //# sourceMappingURL=processImportDeclaration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"processImportDeclaration.d.ts","sourceRoot":"","sources":["../../../src/processing/jsx-insertion/processImportDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAMlC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kEAAkE;IAClE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,IAAI,EAC3B,UAAU,EAAE,aAAa,GACxB,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,iBAAiB,CAAC,CA0CxC"}
1
+ {"version":3,"file":"processImportDeclaration.d.ts","sourceRoot":"","sources":["../../../src/processing/jsx-insertion/processImportDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAMlC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kEAAkE;IAClE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,MAAM,IAAI,EAC3B,UAAU,EAAE,aAAa,EACzB,mBAAmB,CAAC,EAAE,MAAM,GAC3B,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,iBAAiB,CAAC,CA0CxC"}
@@ -12,11 +12,11 @@ _babel_types = require_runtime.__toESM(_babel_types);
12
12
  * - Checks if GtInternalTranslateJsx is already imported from a GT source.
13
13
  * - Collects React jsx callee info (jsx vs jsxs vs jsxDEV, including aliases).
14
14
  */
15
- function processImportDeclaration(onGtImportFound, calleeInfo) {
15
+ function processImportDeclaration(onGtImportFound, calleeInfo, autoJsxImportSource) {
16
16
  const targetName = "GtInternalTranslateJsx";
17
17
  return (path) => {
18
18
  const source = path.node.source.value;
19
- if (require_utils_constants_gt_helpers.isGTImportSource(source)) {
19
+ if (require_utils_constants_gt_helpers.isGTImportSource(source) || source === autoJsxImportSource) {
20
20
  for (const specifier of path.node.specifiers) if (_babel_types.isImportSpecifier(specifier) && _babel_types.isIdentifier(specifier.imported) && specifier.imported.name === targetName) {
21
21
  onGtImportFound();
22
22
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"processImportDeclaration.js","names":["isGTImportSource","t","isReactImportSource"],"sources":["../../../src/processing/jsx-insertion/processImportDeclaration.ts"],"sourcesContent":["import { VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { isGTImportSource } from '../../utils/constants/gt/helpers';\nimport { isReactImportSource } from '../../utils/constants/react/helpers';\nimport { GT_COMPONENT_TYPES } from '../../utils/constants/gt/constants';\nimport { REACT_FUNTIONS } from '../../utils/constants/react/constants';\n\n/**\n * Info about the jsx callee names used in the file.\n * Populated during import analysis so processCallExpression\n * knows which callee to use for jsx (single child) vs jsxs (array children).\n */\nexport interface JsxCalleeInfo {\n /** Local name for single-child calls (jsx or _jsx or _jsxDEV) */\n singleCallee: string | null;\n /** Local name for multi-child calls (jsxs or _jsxs or _jsxDEV) */\n multiCallee: string | null;\n}\n\n/**\n * Process import declarations during jsx insertion.\n * - Checks if GtInternalTranslateJsx is already imported from a GT source.\n * - Collects React jsx callee info (jsx vs jsxs vs jsxDEV, including aliases).\n */\nexport function processImportDeclaration(\n onGtImportFound: () => void,\n calleeInfo: JsxCalleeInfo\n): VisitNode<t.Node, t.ImportDeclaration> {\n const targetName = GT_COMPONENT_TYPES.GtInternalTranslateJsx;\n\n return (path) => {\n const source = path.node.source.value;\n\n // Check for existing GT import\n if (isGTImportSource(source)) {\n for (const specifier of path.node.specifiers) {\n if (\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported) &&\n specifier.imported.name === targetName\n ) {\n onGtImportFound();\n return;\n }\n }\n }\n\n // Collect React jsx callee names\n if (isReactImportSource(source)) {\n for (const specifier of path.node.specifiers) {\n if (!t.isImportSpecifier(specifier)) continue;\n const imported = specifier.imported;\n const originalName = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n const localName = specifier.local.name;\n\n if (originalName === REACT_FUNTIONS.jsxDEV) {\n // Dev mode: jsxDEV handles both single and multi children\n calleeInfo.singleCallee = localName;\n calleeInfo.multiCallee = localName;\n } else if (originalName === REACT_FUNTIONS.jsx) {\n calleeInfo.singleCallee = localName;\n } else if (originalName === REACT_FUNTIONS.jsxs) {\n calleeInfo.multiCallee = localName;\n }\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,yBACd,iBACA,YACwC;CACxC,MAAM,aAAA;AAEN,SAAQ,SAAS;EACf,MAAM,SAAS,KAAK,KAAK,OAAO;AAGhC,MAAIA,mCAAAA,iBAAiB,OAAO;QACrB,MAAM,aAAa,KAAK,KAAK,WAChC,KACEC,aAAE,kBAAkB,UAAU,IAC9BA,aAAE,aAAa,UAAU,SAAS,IAClC,UAAU,SAAS,SAAS,YAC5B;AACA,qBAAiB;AACjB;;;AAMN,MAAIC,sCAAAA,oBAAoB,OAAO,CAC7B,MAAK,MAAM,aAAa,KAAK,KAAK,YAAY;AAC5C,OAAI,CAACD,aAAE,kBAAkB,UAAU,CAAE;GACrC,MAAM,WAAW,UAAU;GAC3B,MAAM,eAAeA,aAAE,aAAa,SAAS,GACzC,SAAS,OACT,SAAS;GACb,MAAM,YAAY,UAAU,MAAM;AAElC,OAAI,iBAAA,UAAwC;AAE1C,eAAW,eAAe;AAC1B,eAAW,cAAc;cAChB,iBAAA,MACT,YAAW,eAAe;YACjB,iBAAA,OACT,YAAW,cAAc"}
1
+ {"version":3,"file":"processImportDeclaration.js","names":["isGTImportSource","t","isReactImportSource"],"sources":["../../../src/processing/jsx-insertion/processImportDeclaration.ts"],"sourcesContent":["import { VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { isGTImportSource } from '../../utils/constants/gt/helpers';\nimport { isReactImportSource } from '../../utils/constants/react/helpers';\nimport { GT_COMPONENT_TYPES } from '../../utils/constants/gt/constants';\nimport { REACT_FUNTIONS } from '../../utils/constants/react/constants';\n\n/**\n * Info about the jsx callee names used in the file.\n * Populated during import analysis so processCallExpression\n * knows which callee to use for jsx (single child) vs jsxs (array children).\n */\nexport interface JsxCalleeInfo {\n /** Local name for single-child calls (jsx or _jsx or _jsxDEV) */\n singleCallee: string | null;\n /** Local name for multi-child calls (jsxs or _jsxs or _jsxDEV) */\n multiCallee: string | null;\n}\n\n/**\n * Process import declarations during jsx insertion.\n * - Checks if GtInternalTranslateJsx is already imported from a GT source.\n * - Collects React jsx callee info (jsx vs jsxs vs jsxDEV, including aliases).\n */\nexport function processImportDeclaration(\n onGtImportFound: () => void,\n calleeInfo: JsxCalleeInfo,\n autoJsxImportSource?: string\n): VisitNode<t.Node, t.ImportDeclaration> {\n const targetName = GT_COMPONENT_TYPES.GtInternalTranslateJsx;\n\n return (path) => {\n const source = path.node.source.value;\n\n // Check for existing GT import\n if (isGTImportSource(source) || source === autoJsxImportSource) {\n for (const specifier of path.node.specifiers) {\n if (\n t.isImportSpecifier(specifier) &&\n t.isIdentifier(specifier.imported) &&\n specifier.imported.name === targetName\n ) {\n onGtImportFound();\n return;\n }\n }\n }\n\n // Collect React jsx callee names\n if (isReactImportSource(source)) {\n for (const specifier of path.node.specifiers) {\n if (!t.isImportSpecifier(specifier)) continue;\n const imported = specifier.imported;\n const originalName = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n const localName = specifier.local.name;\n\n if (originalName === REACT_FUNTIONS.jsxDEV) {\n // Dev mode: jsxDEV handles both single and multi children\n calleeInfo.singleCallee = localName;\n calleeInfo.multiCallee = localName;\n } else if (originalName === REACT_FUNTIONS.jsx) {\n calleeInfo.singleCallee = localName;\n } else if (originalName === REACT_FUNTIONS.jsxs) {\n calleeInfo.multiCallee = localName;\n }\n }\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,SAAgB,yBACd,iBACA,YACA,qBACwC;CACxC,MAAM,aAAA;AAEN,SAAQ,SAAS;EACf,MAAM,SAAS,KAAK,KAAK,OAAO;AAGhC,MAAIA,mCAAAA,iBAAiB,OAAO,IAAI,WAAW;QACpC,MAAM,aAAa,KAAK,KAAK,WAChC,KACEC,aAAE,kBAAkB,UAAU,IAC9BA,aAAE,aAAa,UAAU,SAAS,IAClC,UAAU,SAAS,SAAS,YAC5B;AACA,qBAAiB;AACjB;;;AAMN,MAAIC,sCAAAA,oBAAoB,OAAO,CAC7B,MAAK,MAAM,aAAa,KAAK,KAAK,YAAY;AAC5C,OAAI,CAACD,aAAE,kBAAkB,UAAU,CAAE;GACrC,MAAM,WAAW,UAAU;GAC3B,MAAM,eAAeA,aAAE,aAAa,SAAS,GACzC,SAAS,OACT,SAAS;GACb,MAAM,YAAY,UAAU,MAAM;AAElC,OAAI,iBAAA,UAAwC;AAE1C,eAAW,eAAe;AAC1B,eAAW,cAAc;cAChB,iBAAA,MACT,YAAW,eAAe;YACjB,iBAAA,OACT,YAAW,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"processProgram.d.ts","sourceRoot":"","sources":["../../../src/processing/jsx-insertion/processProgram.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,iBAAiB,EACjB,UAAU,GACX,EAAE;IACD,KAAK,EAAE,cAAc,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,OAAO,CAAC;IACjC,UAAU,EAAE,aAAa,CAAC;CAC3B,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CA8B/B"}
1
+ {"version":3,"file":"processProgram.d.ts","sourceRoot":"","sources":["../../../src/processing/jsx-insertion/processProgram.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,iBAAiB,EACjB,UAAU,GACX,EAAE;IACD,KAAK,EAAE,cAAc,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,OAAO,CAAC;IACjC,UAAU,EAAE,aAAa,CAAC;CAC3B,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CA+B/B"}
@@ -15,7 +15,7 @@ _babel_types = require_runtime.__toESM(_babel_types);
15
15
  function processProgram({ state, countBefore, isAlreadyImported, calleeInfo }) {
16
16
  return { exit(path) {
17
17
  if (!(state.statistics.jsxInsertionsCount > countBefore)) return;
18
- if (!isAlreadyImported()) require_transform_jsx_insertion_injectJsxInsertionImport.injectJsxInsertionImport(path, state.settings.legacyGtReactImportSource);
18
+ if (!isAlreadyImported()) require_transform_jsx_insertion_injectJsxInsertionImport.injectJsxInsertionImport(path, state.settings.autoJsxImportSource, state.settings.legacyGtReactImportSource);
19
19
  if (!calleeInfo.singleCallee && calleeInfo.multiCallee) {
20
20
  const jsxImport = _babel_types.importDeclaration([_babel_types.importSpecifier(_babel_types.identifier("jsx"), _babel_types.identifier("jsx"))], _babel_types.stringLiteral("react/jsx-runtime"));
21
21
  path.unshiftContainer("body", jsxImport);
@@ -1 +1 @@
1
- {"version":3,"file":"processProgram.js","names":["t"],"sources":["../../../src/processing/jsx-insertion/processProgram.ts"],"sourcesContent":["import { TransformState } from '../../state/types';\nimport { VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { injectJsxInsertionImport } from '../../transform/jsx-insertion/injectJsxInsertionImport';\nimport { JsxCalleeInfo } from './processImportDeclaration';\nimport { REACT_FUNTIONS } from '../../utils/constants/react/constants';\nimport { REACT_IMPORT_SOURCES } from '../../utils/constants/react/constants';\n\n/**\n * Process program:\n * - on exit, injects GtInternalTranslateJsx/GtInternalVar import if needed\n * - also injects `jsx` from React runtime if only `jsxs` was imported\n * (Vite production builds only import what's needed — if a file has only\n * multi-child elements, `jsx` is never imported, but our _Var wrappers need it)\n */\nexport function processProgram({\n state,\n countBefore,\n isAlreadyImported,\n calleeInfo,\n}: {\n state: TransformState;\n countBefore: number;\n isAlreadyImported: () => boolean;\n calleeInfo: JsxCalleeInfo;\n}): VisitNode<t.Node, t.Program> {\n return {\n exit(path) {\n const didInsert = state.statistics.jsxInsertionsCount > countBefore;\n if (!didInsert) return;\n\n if (!isAlreadyImported()) {\n injectJsxInsertionImport(\n path,\n state.settings.legacyGtReactImportSource\n );\n }\n\n // If only jsxs was imported (no jsx), inject jsx import.\n // _Var wrappers always use singleCallee which defaults to 'jsx'.\n if (!calleeInfo.singleCallee && calleeInfo.multiCallee) {\n const jsxImport = t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier(REACT_FUNTIONS.jsx),\n t.identifier(REACT_FUNTIONS.jsx)\n ),\n ],\n t.stringLiteral(REACT_IMPORT_SOURCES.JSX_RUNTIME)\n );\n path.unshiftContainer('body', jsxImport);\n calleeInfo.singleCallee = REACT_FUNTIONS.jsx;\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,eAAe,EAC7B,OACA,aACA,mBACA,cAM+B;AAC/B,QAAO,EACL,KAAK,MAAM;AAET,MAAI,EADc,MAAM,WAAW,qBAAqB,aACxC;AAEhB,MAAI,CAAC,mBAAmB,CACtB,0DAAA,yBACE,MACA,MAAM,SAAS,0BAChB;AAKH,MAAI,CAAC,WAAW,gBAAgB,WAAW,aAAa;GACtD,MAAM,YAAYA,aAAE,kBAClB,CACEA,aAAE,gBACAA,aAAE,WAAA,MAA8B,EAChCA,aAAE,WAAA,MAA8B,CACjC,CACF,EACDA,aAAE,cAAA,oBAA+C,CAClD;AACD,QAAK,iBAAiB,QAAQ,UAAU;AACxC,cAAW,eAAA;;IAGhB"}
1
+ {"version":3,"file":"processProgram.js","names":["t"],"sources":["../../../src/processing/jsx-insertion/processProgram.ts"],"sourcesContent":["import { TransformState } from '../../state/types';\nimport { VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { injectJsxInsertionImport } from '../../transform/jsx-insertion/injectJsxInsertionImport';\nimport { JsxCalleeInfo } from './processImportDeclaration';\nimport { REACT_FUNTIONS } from '../../utils/constants/react/constants';\nimport { REACT_IMPORT_SOURCES } from '../../utils/constants/react/constants';\n\n/**\n * Process program:\n * - on exit, injects GtInternalTranslateJsx/GtInternalVar import if needed\n * - also injects `jsx` from React runtime if only `jsxs` was imported\n * (Vite production builds only import what's needed — if a file has only\n * multi-child elements, `jsx` is never imported, but our _Var wrappers need it)\n */\nexport function processProgram({\n state,\n countBefore,\n isAlreadyImported,\n calleeInfo,\n}: {\n state: TransformState;\n countBefore: number;\n isAlreadyImported: () => boolean;\n calleeInfo: JsxCalleeInfo;\n}): VisitNode<t.Node, t.Program> {\n return {\n exit(path) {\n const didInsert = state.statistics.jsxInsertionsCount > countBefore;\n if (!didInsert) return;\n\n if (!isAlreadyImported()) {\n injectJsxInsertionImport(\n path,\n state.settings.autoJsxImportSource,\n state.settings.legacyGtReactImportSource\n );\n }\n\n // If only jsxs was imported (no jsx), inject jsx import.\n // _Var wrappers always use singleCallee which defaults to 'jsx'.\n if (!calleeInfo.singleCallee && calleeInfo.multiCallee) {\n const jsxImport = t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier(REACT_FUNTIONS.jsx),\n t.identifier(REACT_FUNTIONS.jsx)\n ),\n ],\n t.stringLiteral(REACT_IMPORT_SOURCES.JSX_RUNTIME)\n );\n path.unshiftContainer('body', jsxImport);\n calleeInfo.singleCallee = REACT_FUNTIONS.jsx;\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,eAAe,EAC7B,OACA,aACA,mBACA,cAM+B;AAC/B,QAAO,EACL,KAAK,MAAM;AAET,MAAI,EADc,MAAM,WAAW,qBAAqB,aACxC;AAEhB,MAAI,CAAC,mBAAmB,CACtB,0DAAA,yBACE,MACA,MAAM,SAAS,qBACf,MAAM,SAAS,0BAChB;AAKH,MAAI,CAAC,WAAW,gBAAgB,WAAW,aAAa;GACtD,MAAM,YAAYA,aAAE,kBAClB,CACEA,aAAE,gBACAA,aAAE,WAAA,MAA8B,EAChCA,aAAE,WAAA,MAA8B,CACjC,CACF,EACDA,aAAE,cAAA,oBAA+C,CAClD;AACD,QAAK,iBAAiB,QAAQ,UAAU;AACxC,cAAW,eAAA;;IAGhB"}
@@ -4,5 +4,5 @@ import { NodePath } from '@babel/traverse';
4
4
  * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react'`
5
5
  * as the first statement in the program.
6
6
  */
7
- export declare function injectJsxInsertionImport(path: NodePath<t.Program>, legacyGtReactImportSource: boolean): void;
7
+ export declare function injectJsxInsertionImport(path: NodePath<t.Program>, autoJsxImportSource: string | undefined, legacyGtReactImportSource: boolean): void;
8
8
  //# sourceMappingURL=injectJsxInsertionImport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"injectJsxInsertionImport.d.ts","sourceRoot":"","sources":["../../../src/transform/jsx-insertion/injectJsxInsertionImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EACzB,yBAAyB,EAAE,OAAO,GACjC,IAAI,CAaN"}
1
+ {"version":3,"file":"injectJsxInsertionImport.d.ts","sourceRoot":"","sources":["../../../src/transform/jsx-insertion/injectJsxInsertionImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EACzB,mBAAmB,EAAE,MAAM,GAAG,SAAS,EACvC,yBAAyB,EAAE,OAAO,GACjC,IAAI,CAeN"}
@@ -9,10 +9,10 @@ _babel_types = require_runtime.__toESM(_babel_types);
9
9
  * Inject `import { GtInternalTranslateJsx, GtInternalVar } from 'gt-react'`
10
10
  * as the first statement in the program.
11
11
  */
12
- function injectJsxInsertionImport(path, legacyGtReactImportSource) {
12
+ function injectJsxInsertionImport(path, autoJsxImportSource, legacyGtReactImportSource) {
13
13
  const tName = "GtInternalTranslateJsx";
14
14
  const varName = "GtInternalVar";
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
+ 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(autoJsxImportSource ?? require_utils_constants_gt_helpers.getGtReactImportSource(legacyGtReactImportSource)));
16
16
  path.unshiftContainer("body", importDecl);
17
17
  }
18
18
  //#endregion
@@ -1 +1 @@
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
+ {"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 autoJsxImportSource: string | undefined,\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(\n autoJsxImportSource ?? getGtReactImportSource(legacyGtReactImportSource)\n )\n );\n\n path.unshiftContainer('body', importDecl);\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAgB,yBACd,MACA,qBACA,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,cACA,uBAAuBC,mCAAAA,uBAAuB,0BAA0B,CACzE,CACF;AAED,MAAK,iBAAiB,QAAQ,WAAW"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@generaltranslation/compiler",
3
- "version": "1.3.31",
3
+ "version": "1.3.32",
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",
@@ -25,7 +25,7 @@
25
25
  "@babel/types": "^7.23.0",
26
26
  "unplugin": "^2.3.10",
27
27
  "@generaltranslation/format": "0.1.2",
28
- "generaltranslation": "9.0.2"
28
+ "generaltranslation": "9.0.3"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/babel__core": "^7.20.0",