@generaltranslation/compiler 1.3.30 → 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 +7 -27
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/passes/jsxInsertionPass.d.ts.map +1 -1
- package/dist/passes/jsxInsertionPass.js +1 -1
- package/dist/passes/jsxInsertionPass.js.map +1 -1
- package/dist/processing/collection/processCallExpression.d.ts.map +1 -1
- package/dist/processing/collection/processCallExpression.js +4 -8
- package/dist/processing/collection/processCallExpression.js.map +1 -1
- package/dist/processing/injection/processCallExpression.d.ts.map +1 -1
- package/dist/processing/injection/processCallExpression.js +2 -21
- package/dist/processing/injection/processCallExpression.js.map +1 -1
- package/dist/processing/jsx-insertion/processImportDeclaration.d.ts +1 -1
- package/dist/processing/jsx-insertion/processImportDeclaration.d.ts.map +1 -1
- package/dist/processing/jsx-insertion/processImportDeclaration.js +2 -2
- package/dist/processing/jsx-insertion/processImportDeclaration.js.map +1 -1
- package/dist/processing/jsx-insertion/processProgram.d.ts.map +1 -1
- package/dist/processing/jsx-insertion/processProgram.js +1 -1
- package/dist/processing/jsx-insertion/processProgram.js.map +1 -1
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.d.ts +1 -1
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.d.ts.map +1 -1
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.js +2 -2
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.js.map +1 -1
- package/package.json +2 -2
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.d.ts +0 -8
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.d.ts.map +0 -1
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.js +0 -10
- package/dist/transform/injection/callbacks/injectUseMessagesCallbackParameters.js.map +0 -1
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.d.ts +0 -8
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.d.ts.map +0 -1
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.js +0 -10
- package/dist/transform/injection/callbacks/injectUseTranslationsCallbackParameters.js.map +0 -1
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.d.ts +0 -10
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.d.ts.map +0 -1
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.js +0 -11
- package/dist/transform/registration/callbacks/registerUseMessagesCallback.js.map +0 -1
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.d.ts +0 -10
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.d.ts.map +0 -1
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.js +0 -11
- package/dist/transform/registration/callbacks/registerUseTranslationsCallback.js.map +0 -1
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
|
-
|
|
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;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAA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;IAC/B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,wBAAwB,EAAE,OAAO,CAAC;IAClC,sBAAsB,EAAE,OAAO,CAAC;IAChC,0BAA0B,EAAE,OAAO,CAAC;IACpC,mFAAmF;IACnF,sBAAsB,EAAE,OAAO,CAAC;IAChC,mEAAmE;IACnE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,6EAA6E;IAC7E,UAAU,EAAE;QAAE,GAAG,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAC/C,oEAAoE;IACpE,yBAAyB,EAAE,OAAO,CAAC;IACnC,+DAA+D;IAC/D,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mFAAmF;IACnF,YAAY,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,OAAO,CAAA;KAAE,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"}
|
package/dist/config.js.map
CHANGED
|
@@ -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
|
|
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,
|
|
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
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processCallExpression.d.ts","sourceRoot":"","sources":["../../../src/processing/collection/processCallExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"processCallExpression.d.ts","sourceRoot":"","sources":["../../../src/processing/collection/processCallExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA0BnD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,cAAc,GACpB,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,cAAc,CAAC,CAoDrC"}
|
|
@@ -8,8 +8,6 @@ const require_transform_getTrackedVariable = require("../../transform/getTracked
|
|
|
8
8
|
const require_transform_validation_validateTranslationFunction = require("../../transform/validation/validateTranslationFunction.js");
|
|
9
9
|
const require_utils_calculateHash = require("../../utils/calculateHash.js");
|
|
10
10
|
const require_transform_registration_callbacks_registerUseGTCallback = require("../../transform/registration/callbacks/registerUseGTCallback.js");
|
|
11
|
-
require("../../transform/registration/callbacks/registerUseTranslationsCallback.js");
|
|
12
|
-
require("../../transform/registration/callbacks/registerUseMessagesCallback.js");
|
|
13
11
|
const require_utils_errors = require("../../utils/errors.js");
|
|
14
12
|
const require_transform_jsx_children_utils_getCalleeNameFromJsxExpressionParam = require("../../transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.js");
|
|
15
13
|
const require_transform_validation_validateTranslationComponentArgs = require("../../transform/validation/validateTranslationComponentArgs.js");
|
|
@@ -50,11 +48,11 @@ function handleTranslationCallbackInvocation(callExprPath, state, canonicalName,
|
|
|
50
48
|
break;
|
|
51
49
|
case "useTranslations_callback":
|
|
52
50
|
case "getTranslations_callback":
|
|
53
|
-
handleUseTranslationsCallback(callExprPath, state
|
|
51
|
+
handleUseTranslationsCallback(callExprPath, state);
|
|
54
52
|
break;
|
|
55
53
|
case "useMessages_callback":
|
|
56
54
|
case "getMessages_callback":
|
|
57
|
-
handleUseMessagesCallback(callExprPath, state
|
|
55
|
+
handleUseMessagesCallback(callExprPath, state);
|
|
58
56
|
break;
|
|
59
57
|
default: return;
|
|
60
58
|
}
|
|
@@ -85,20 +83,18 @@ function handleUseGTCallback(callExprPath, state, identifier) {
|
|
|
85
83
|
/**
|
|
86
84
|
* Handle useTranslations_callback / getTranslations_callback
|
|
87
85
|
*/
|
|
88
|
-
function handleUseTranslationsCallback(callExprPath, state
|
|
86
|
+
function handleUseTranslationsCallback(callExprPath, state) {
|
|
89
87
|
const callExpr = callExprPath.node;
|
|
90
88
|
const useTranslationsCallbackParams = require_transform_validation_validateTranslationFunction.validateUseTranslationsCallback(callExpr);
|
|
91
89
|
state.errorTracker.addErrors(useTranslationsCallbackParams.errors);
|
|
92
|
-
if (useTranslationsCallbackParams.errors.length > 0) return;
|
|
93
90
|
}
|
|
94
91
|
/**
|
|
95
92
|
* Handle useMessages_callback / getMessages_callback
|
|
96
93
|
*/
|
|
97
|
-
function handleUseMessagesCallback(callExprPath, state
|
|
94
|
+
function handleUseMessagesCallback(callExprPath, state) {
|
|
98
95
|
const callExpr = callExprPath.node;
|
|
99
96
|
const useMessagesCallbackParams = require_transform_validation_validateTranslationFunction.validateUseMessagesCallback(callExpr);
|
|
100
97
|
state.errorTracker.addErrors(useMessagesCallbackParams.errors);
|
|
101
|
-
if (useMessagesCallbackParams.errors.length > 0) return;
|
|
102
98
|
}
|
|
103
99
|
/**
|
|
104
100
|
* Handle react function invocations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processCallExpression.js","names":["getCalleeNameFromExpression","getTrackedVariable","isTranslationFunctionCallback","isReactFunction","validateTranslationFunction","validateUseTranslationsCallback","validateUseMessagesCallback","createErrorLocation","t","getCalleeNameFromJsxExpressionParam","isTranslationComponent","validateTranslationComponentArgs","hashSource"],"sources":["../../../src/processing/collection/processCallExpression.ts"],"sourcesContent":["import { NodePath, VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { TransformState } from '../../state/types';\nimport {\n isTranslationComponent,\n isTranslationFunctionCallback,\n} from '../../utils/constants/gt/helpers';\nimport { getCalleeNameFromExpression } from '../../utils/parsing/getCalleeNameFromExpression';\nimport {\n GT_ALL_FUNCTIONS,\n GT_CALLBACK_FUNCTIONS,\n GT_OTHER_FUNCTIONS,\n} from '../../utils/constants/gt/constants';\nimport {\n validateTranslationFunction,\n validateUseMessagesCallback,\n validateUseTranslationsCallback,\n} from '../../transform/validation/validateTranslationFunction';\nimport { registerUseGTCallback } from '../../transform/registration/callbacks/registerUseGTCallback';\nimport { registerUseTranslationsCallback } from '../../transform/registration/callbacks/registerUseTranslationsCallback';\nimport { registerUseMessagesCallback } from '../../transform/registration/callbacks/registerUseMessagesCallback';\nimport { getTrackedVariable } from '../../transform/getTrackedVariable';\nimport { isReactFunction } from '../../utils/constants/react/helpers';\nimport { validateTranslationComponentArgs } from '../../transform/validation/validateTranslationComponentArgs';\nimport { registerTranslationComponent } from '../../transform/registration/registerTranslationComponent';\nimport { getCalleeNameFromJsxExpressionParam } from '../../transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam';\nimport { createErrorLocation } from '../../utils/errors';\nimport hashSource from '../../utils/calculateHash';\nimport { registerStandaloneTranslation } from '../../transform/registration/registerStandaloneTranslation';\n\n/**\n * Process call expressions\n * - register content from GT callback functions invocations (useGT_callback, etc.)\n * - register <T> + other component content (via jsxDev, jsx, jsxs invocations)\n * - register msg() function invocations?\n * - generally validate content\n */\nexport function processCallExpression(\n state: TransformState\n): VisitNode<t.Node, t.CallExpression> {\n return (callExprPath) => {\n // Get the call expression\n const callExpr = callExprPath.node;\n\n // Get function name from callee\n const { namespaceName, functionName } =\n getCalleeNameFromExpression(callExpr);\n if (!functionName) {\n return;\n }\n\n // Get the canonical function name\n const { canonicalName, identifier, type } = getTrackedVariable(\n state.scopeTracker,\n namespaceName,\n functionName\n );\n if (!canonicalName) {\n return;\n }\n\n // Handle each respective case\n if (\n type === 'generaltranslation' &&\n isTranslationFunctionCallback(canonicalName)\n ) {\n // Handle translation function callbacks (useGT_callback, etc.)\n handleTranslationCallbackInvocation(\n callExprPath,\n state,\n canonicalName,\n identifier!\n );\n } else if (type === 'react' && isReactFunction(canonicalName)) {\n // Handle react variables (jsxDEV, etc.)\n handleReactInvocation(callExprPath, state);\n } else if (\n type === 'generaltranslation' &&\n canonicalName === GT_OTHER_FUNCTIONS.msg\n ) {\n // msg() is runtime-only content; it must not advance the injection counter.\n handleStandaloneTranslation(callExprPath, state, { injectHash: false });\n } else if (\n type === 'generaltranslation' &&\n canonicalName === GT_OTHER_FUNCTIONS.t\n ) {\n // Standalone t() receives an injected $_hash, so collection reserves a\n // matching counter slot for the injection pass.\n handleStandaloneTranslation(callExprPath, state, { injectHash: true });\n }\n };\n}\n\n/* =============================== */\n/* Handlers */\n/* =============================== */\n\n/**\n * Handle general translation variables\n * useGTCallback(), useTranslationsCallback(), useMessagesCallback(), etc.\n */\nfunction handleTranslationCallbackInvocation(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState,\n canonicalName: GT_ALL_FUNCTIONS,\n identifier: number\n) {\n // Handle translation function callbacks ()\n switch (canonicalName) {\n case GT_CALLBACK_FUNCTIONS.useGT_callback:\n case GT_CALLBACK_FUNCTIONS.getGT_callback:\n handleUseGTCallback(callExprPath, state, identifier);\n break;\n case GT_CALLBACK_FUNCTIONS.useTranslations_callback:\n case GT_CALLBACK_FUNCTIONS.getTranslations_callback:\n handleUseTranslationsCallback(callExprPath, state, identifier);\n break;\n case GT_CALLBACK_FUNCTIONS.useMessages_callback:\n case GT_CALLBACK_FUNCTIONS.getMessages_callback:\n handleUseMessagesCallback(callExprPath, state, identifier);\n break;\n default:\n return;\n }\n}\n\n/**\n * Handle useGT_callback / getGT_callback\n */\nfunction handleUseGTCallback(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState,\n identifier: number\n) {\n // Check for violations\n const useGTCallbackParams = validateTranslationFunction(callExprPath, state);\n state.errorTracker.addErrors(useGTCallbackParams.errors);\n if (useGTCallbackParams.errors.length > 0) {\n return;\n }\n\n // Derive content (explicit derive() in the message, autoderive dynamic\n // content) and derive $context cannot be hashed at compile time — the CLI\n // resolves the variants and the runtime hashes the resolved values.\n // Reserve the counter slot without a hash so the injection pass stays\n // aligned and skips this call; register no prefetch entry.\n if (\n useGTCallbackParams.content === undefined ||\n useGTCallbackParams.hasDeriveContext\n ) {\n state.stringCollector.incrementCounter();\n return;\n }\n\n // Track the function call\n registerUseGTCallback({\n identifier,\n state,\n content: useGTCallbackParams.content,\n context: useGTCallbackParams.context,\n id: useGTCallbackParams.id,\n maxChars: useGTCallbackParams.maxChars,\n requiresReview: useGTCallbackParams.requiresReview,\n hash: useGTCallbackParams.hash,\n format: useGTCallbackParams.format,\n });\n}\n\n/**\n * Handle useTranslations_callback / getTranslations_callback\n */\nfunction handleUseTranslationsCallback(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState,\n identifier: number\n) {\n // Check for violations\n const callExpr = callExprPath.node;\n const useTranslationsCallbackParams =\n validateUseTranslationsCallback(callExpr);\n state.errorTracker.addErrors(useTranslationsCallbackParams.errors);\n if (useTranslationsCallbackParams.errors.length > 0) {\n return;\n }\n\n // Track the function call\n registerUseTranslationsCallback({\n identifier,\n state,\n });\n}\n\n/**\n * Handle useMessages_callback / getMessages_callback\n */\nfunction handleUseMessagesCallback(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState,\n identifier: number\n) {\n // Validate parameters\n const callExpr = callExprPath.node;\n const useMessagesCallbackParams = validateUseMessagesCallback(callExpr);\n\n // Check for violations\n state.errorTracker.addErrors(useMessagesCallbackParams.errors);\n if (useMessagesCallbackParams.errors.length > 0) {\n return;\n }\n\n // Track the function call\n registerUseMessagesCallback({\n identifier,\n state,\n });\n}\n\n/**\n * Handle react function invocations\n * jsxDEV, jsx, jsxs, ...\n *\n * We want to check these because they wrap <T> and other components\n */\nfunction handleReactInvocation(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState\n) {\n const callExpr = callExprPath.node;\n // Check if it contains a GT component (first argument)\n if (callExpr.arguments.length === 0) {\n state.errorTracker.addError(\n 'React invocation must have at least one argument' +\n createErrorLocation(callExpr)\n );\n return;\n }\n const firstArg = callExpr.arguments[0];\n if (!t.isExpression(firstArg)) {\n state.errorTracker.addError(\n 'React invocation first argument must be an expression' +\n createErrorLocation(callExpr)\n );\n return;\n }\n\n // Get function name from callee\n const { namespaceName, functionName } =\n getCalleeNameFromJsxExpressionParam(firstArg);\n if (!functionName) {\n state.errorTracker.addError(\n 'React invocation first argument must be a function' +\n createErrorLocation(callExpr)\n );\n return;\n }\n // Get the canonical function name\n const { canonicalName, type } = getTrackedVariable(\n state.scopeTracker,\n namespaceName,\n functionName\n );\n if (!canonicalName) {\n return;\n }\n\n // Filter out non-GT components\n if (type !== 'generaltranslation' || !isTranslationComponent(canonicalName)) {\n return;\n }\n\n // Validate the arguments\n const {\n errors,\n _hash,\n id,\n context,\n children,\n maxChars,\n requiresReview,\n hasDeriveContext,\n hasDeriveChildren,\n } = validateTranslationComponentArgs(callExprPath, canonicalName, state);\n\n if (errors.length > 0) {\n state.errorTracker.addErrors(errors);\n return;\n }\n\n // Calculate hash (skip when context contains derive or children contain a\n // <Derive> element — one hash per resolved variant, so the runtime computes\n // it; the CLI handles variant resolution)\n const hash =\n hasDeriveContext || hasDeriveChildren\n ? ''\n : _hash ||\n hashSource({\n source: children!,\n ...(context && { context }),\n ...(maxChars != null && { maxChars }),\n ...(requiresReview === true && { requiresReview: true }),\n dataFormat: 'JSX',\n });\n\n // Debug: record hash → children mapping\n // Note: children may be undefined when autoderive filters all dynamic-content\n // errors (the early return in constructJsxChildren means value is never set).\n // This is intentional — the compiler signals CLI resolution via hash=''.\n if (state.debugManifest) {\n state.debugManifest.set(hash, children ?? null);\n }\n\n // Track the component (increment counter, initialize aggregator, set hash)\n registerTranslationComponent(state, hash, {\n children,\n id,\n context,\n requiresReview,\n });\n}\n\n/**\n * Handle standalone translation functions: t() and msg()\n * Same argument structure as useGT_callback (message string + options object).\n */\nfunction handleStandaloneTranslation(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState,\n { injectHash }: { injectHash: boolean }\n) {\n // Reuse the same validation as useGT_callback (identical argument structure)\n const params = validateTranslationFunction(callExprPath, state);\n state.errorTracker.addErrors(params.errors);\n if (params.errors.length > 0 || params.content === undefined) {\n return;\n }\n\n // Skip derive content\n if (params.hasDeriveContext) {\n return;\n }\n\n registerStandaloneTranslation({\n state,\n content: params.content,\n hash: params.hash,\n id: params.id,\n context: params.context,\n maxChars: params.maxChars,\n requiresReview: params.requiresReview,\n format: params.format,\n injectHash,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,sBACd,OACqC;AACrC,SAAQ,iBAAiB;EAEvB,MAAM,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AE,UAAU;EACpC,GAAI,mBAAmB,QAAQ,EAAE,gBAAgB,MAAM;EACvD,YAAY;EACb,CAAC;AAMR,KAAI,MAAM,cACR,OAAM,cAAc,IAAI,MAAM,YAAY,KAAK;AAIjD,6DAAA,6BAA6B,OAAO,MAAM;EACxC;EACA;EACA;EACA;EACD,CAAC;;;;;;AAOJ,SAAS,4BACP,cACA,OACA,EAAE,cACF;CAEA,MAAM,SAASR,yDAAAA,4BAA4B,cAAc,MAAM;AAC/D,OAAM,aAAa,UAAU,OAAO,OAAO;AAC3C,KAAI,OAAO,OAAO,SAAS,KAAK,OAAO,YAAY,KAAA,EACjD;AAIF,KAAI,OAAO,iBACT;AAGF,8DAAA,8BAA8B;EAC5B;EACA,SAAS,OAAO;EAChB,MAAM,OAAO;EACb,IAAI,OAAO;EACX,SAAS,OAAO;EAChB,UAAU,OAAO;EACjB,gBAAgB,OAAO;EACvB,QAAQ,OAAO;EACf;EACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"processCallExpression.js","names":["getCalleeNameFromExpression","getTrackedVariable","isTranslationFunctionCallback","isReactFunction","validateTranslationFunction","validateUseTranslationsCallback","validateUseMessagesCallback","createErrorLocation","t","getCalleeNameFromJsxExpressionParam","isTranslationComponent","validateTranslationComponentArgs","hashSource"],"sources":["../../../src/processing/collection/processCallExpression.ts"],"sourcesContent":["import { NodePath, VisitNode } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { TransformState } from '../../state/types';\nimport {\n isTranslationComponent,\n isTranslationFunctionCallback,\n} from '../../utils/constants/gt/helpers';\nimport { getCalleeNameFromExpression } from '../../utils/parsing/getCalleeNameFromExpression';\nimport {\n GT_ALL_FUNCTIONS,\n GT_CALLBACK_FUNCTIONS,\n GT_OTHER_FUNCTIONS,\n} from '../../utils/constants/gt/constants';\nimport {\n validateTranslationFunction,\n validateUseMessagesCallback,\n validateUseTranslationsCallback,\n} from '../../transform/validation/validateTranslationFunction';\nimport { registerUseGTCallback } from '../../transform/registration/callbacks/registerUseGTCallback';\nimport { getTrackedVariable } from '../../transform/getTrackedVariable';\nimport { isReactFunction } from '../../utils/constants/react/helpers';\nimport { validateTranslationComponentArgs } from '../../transform/validation/validateTranslationComponentArgs';\nimport { registerTranslationComponent } from '../../transform/registration/registerTranslationComponent';\nimport { getCalleeNameFromJsxExpressionParam } from '../../transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam';\nimport { createErrorLocation } from '../../utils/errors';\nimport hashSource from '../../utils/calculateHash';\nimport { registerStandaloneTranslation } from '../../transform/registration/registerStandaloneTranslation';\n\n/**\n * Process call expressions\n * - register content from GT callback functions invocations (useGT_callback, etc.)\n * - register <T> + other component content (via jsxDev, jsx, jsxs invocations)\n * - register msg() function invocations?\n * - generally validate content\n */\nexport function processCallExpression(\n state: TransformState\n): VisitNode<t.Node, t.CallExpression> {\n return (callExprPath) => {\n // Get the call expression\n const callExpr = callExprPath.node;\n\n // Get function name from callee\n const { namespaceName, functionName } =\n getCalleeNameFromExpression(callExpr);\n if (!functionName) {\n return;\n }\n\n // Get the canonical function name\n const { canonicalName, identifier, type } = getTrackedVariable(\n state.scopeTracker,\n namespaceName,\n functionName\n );\n if (!canonicalName) {\n return;\n }\n\n // Handle each respective case\n if (\n type === 'generaltranslation' &&\n isTranslationFunctionCallback(canonicalName)\n ) {\n // Handle translation function callbacks (useGT_callback, etc.)\n handleTranslationCallbackInvocation(\n callExprPath,\n state,\n canonicalName,\n identifier!\n );\n } else if (type === 'react' && isReactFunction(canonicalName)) {\n // Handle react variables (jsxDEV, etc.)\n handleReactInvocation(callExprPath, state);\n } else if (\n type === 'generaltranslation' &&\n canonicalName === GT_OTHER_FUNCTIONS.msg\n ) {\n // msg() is runtime-only content; it must not advance the injection counter.\n handleStandaloneTranslation(callExprPath, state, { injectHash: false });\n } else if (\n type === 'generaltranslation' &&\n canonicalName === GT_OTHER_FUNCTIONS.t\n ) {\n // Standalone t() receives an injected $_hash, so collection reserves a\n // matching counter slot for the injection pass.\n handleStandaloneTranslation(callExprPath, state, { injectHash: true });\n }\n };\n}\n\n/* =============================== */\n/* Handlers */\n/* =============================== */\n\n/**\n * Handle general translation variables\n * useGTCallback(), useTranslationsCallback(), useMessagesCallback(), etc.\n */\nfunction handleTranslationCallbackInvocation(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState,\n canonicalName: GT_ALL_FUNCTIONS,\n identifier: number\n) {\n // Handle translation function callbacks ()\n switch (canonicalName) {\n case GT_CALLBACK_FUNCTIONS.useGT_callback:\n case GT_CALLBACK_FUNCTIONS.getGT_callback:\n handleUseGTCallback(callExprPath, state, identifier);\n break;\n case GT_CALLBACK_FUNCTIONS.useTranslations_callback:\n case GT_CALLBACK_FUNCTIONS.getTranslations_callback:\n handleUseTranslationsCallback(callExprPath, state);\n break;\n case GT_CALLBACK_FUNCTIONS.useMessages_callback:\n case GT_CALLBACK_FUNCTIONS.getMessages_callback:\n handleUseMessagesCallback(callExprPath, state);\n break;\n default:\n return;\n }\n}\n\n/**\n * Handle useGT_callback / getGT_callback\n */\nfunction handleUseGTCallback(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState,\n identifier: number\n) {\n // Check for violations\n const useGTCallbackParams = validateTranslationFunction(callExprPath, state);\n state.errorTracker.addErrors(useGTCallbackParams.errors);\n if (useGTCallbackParams.errors.length > 0) {\n return;\n }\n\n // Derive content (explicit derive() in the message, autoderive dynamic\n // content) and derive $context cannot be hashed at compile time — the CLI\n // resolves the variants and the runtime hashes the resolved values.\n // Reserve the counter slot without a hash so the injection pass stays\n // aligned and skips this call; register no prefetch entry.\n if (\n useGTCallbackParams.content === undefined ||\n useGTCallbackParams.hasDeriveContext\n ) {\n state.stringCollector.incrementCounter();\n return;\n }\n\n // Track the function call\n registerUseGTCallback({\n identifier,\n state,\n content: useGTCallbackParams.content,\n context: useGTCallbackParams.context,\n id: useGTCallbackParams.id,\n maxChars: useGTCallbackParams.maxChars,\n requiresReview: useGTCallbackParams.requiresReview,\n hash: useGTCallbackParams.hash,\n format: useGTCallbackParams.format,\n });\n}\n\n/**\n * Handle useTranslations_callback / getTranslations_callback\n */\nfunction handleUseTranslationsCallback(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState\n) {\n const callExpr = callExprPath.node;\n const useTranslationsCallbackParams =\n validateUseTranslationsCallback(callExpr);\n state.errorTracker.addErrors(useTranslationsCallbackParams.errors);\n}\n\n/**\n * Handle useMessages_callback / getMessages_callback\n */\nfunction handleUseMessagesCallback(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState\n) {\n const callExpr = callExprPath.node;\n const useMessagesCallbackParams = validateUseMessagesCallback(callExpr);\n state.errorTracker.addErrors(useMessagesCallbackParams.errors);\n}\n\n/**\n * Handle react function invocations\n * jsxDEV, jsx, jsxs, ...\n *\n * We want to check these because they wrap <T> and other components\n */\nfunction handleReactInvocation(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState\n) {\n const callExpr = callExprPath.node;\n // Check if it contains a GT component (first argument)\n if (callExpr.arguments.length === 0) {\n state.errorTracker.addError(\n 'React invocation must have at least one argument' +\n createErrorLocation(callExpr)\n );\n return;\n }\n const firstArg = callExpr.arguments[0];\n if (!t.isExpression(firstArg)) {\n state.errorTracker.addError(\n 'React invocation first argument must be an expression' +\n createErrorLocation(callExpr)\n );\n return;\n }\n\n // Get function name from callee\n const { namespaceName, functionName } =\n getCalleeNameFromJsxExpressionParam(firstArg);\n if (!functionName) {\n state.errorTracker.addError(\n 'React invocation first argument must be a function' +\n createErrorLocation(callExpr)\n );\n return;\n }\n // Get the canonical function name\n const { canonicalName, type } = getTrackedVariable(\n state.scopeTracker,\n namespaceName,\n functionName\n );\n if (!canonicalName) {\n return;\n }\n\n // Filter out non-GT components\n if (type !== 'generaltranslation' || !isTranslationComponent(canonicalName)) {\n return;\n }\n\n // Validate the arguments\n const {\n errors,\n _hash,\n id,\n context,\n children,\n maxChars,\n requiresReview,\n hasDeriveContext,\n hasDeriveChildren,\n } = validateTranslationComponentArgs(callExprPath, canonicalName, state);\n\n if (errors.length > 0) {\n state.errorTracker.addErrors(errors);\n return;\n }\n\n // Calculate hash (skip when context contains derive or children contain a\n // <Derive> element — one hash per resolved variant, so the runtime computes\n // it; the CLI handles variant resolution)\n const hash =\n hasDeriveContext || hasDeriveChildren\n ? ''\n : _hash ||\n hashSource({\n source: children!,\n ...(context && { context }),\n ...(maxChars != null && { maxChars }),\n ...(requiresReview === true && { requiresReview: true }),\n dataFormat: 'JSX',\n });\n\n // Debug: record hash → children mapping\n // Note: children may be undefined when autoderive filters all dynamic-content\n // errors (the early return in constructJsxChildren means value is never set).\n // This is intentional — the compiler signals CLI resolution via hash=''.\n if (state.debugManifest) {\n state.debugManifest.set(hash, children ?? null);\n }\n\n // Track the component (increment counter, initialize aggregator, set hash)\n registerTranslationComponent(state, hash, {\n children,\n id,\n context,\n requiresReview,\n });\n}\n\n/**\n * Handle standalone translation functions: t() and msg()\n * Same argument structure as useGT_callback (message string + options object).\n */\nfunction handleStandaloneTranslation(\n callExprPath: NodePath<t.CallExpression>,\n state: TransformState,\n { injectHash }: { injectHash: boolean }\n) {\n // Reuse the same validation as useGT_callback (identical argument structure)\n const params = validateTranslationFunction(callExprPath, state);\n state.errorTracker.addErrors(params.errors);\n if (params.errors.length > 0 || params.content === undefined) {\n return;\n }\n\n // Skip derive content\n if (params.hasDeriveContext) {\n return;\n }\n\n registerStandaloneTranslation({\n state,\n content: params.content,\n hash: params.hash,\n id: params.id,\n context: params.context,\n maxChars: params.maxChars,\n requiresReview: params.requiresReview,\n format: params.format,\n injectHash,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,sBACd,OACqC;AACrC,SAAQ,iBAAiB;EAEvB,MAAM,WAAW,aAAa;EAG9B,MAAM,EAAE,eAAe,iBACrBA,kDAAAA,4BAA4B,SAAS;AACvC,MAAI,CAAC,aACH;EAIF,MAAM,EAAE,eAAe,YAAY,SAASC,qCAAAA,mBAC1C,MAAM,cACN,eACA,aACD;AACD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,4BAA4B,cAAc,MAAM;AAC/D,OAAM,aAAa,UAAU,OAAO,OAAO;AAC3C,KAAI,OAAO,OAAO,SAAS,KAAK,OAAO,YAAY,KAAA,EACjD;AAIF,KAAI,OAAO,iBACT;AAGF,8DAAA,8BAA8B;EAC5B;EACA,SAAS,OAAO;EAChB,MAAM,OAAO;EACb,IAAI,OAAO;EACX,SAAS,OAAO;EAChB,UAAU,OAAO;EACjB,gBAAgB,OAAO;EACvB,QAAQ,OAAO;EACf;EACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processCallExpression.d.ts","sourceRoot":"","sources":["../../../src/processing/injection/processCallExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"processCallExpression.d.ts","sourceRoot":"","sources":["../../../src/processing/injection/processCallExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAelC;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,cAAc,GACpB,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,cAAc,CAAC,CAuCrC"}
|
|
@@ -9,8 +9,6 @@ const require_utils_errors = require("../../utils/errors.js");
|
|
|
9
9
|
const require_transform_jsx_children_utils_getCalleeNameFromJsxExpressionParam = require("../../transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam.js");
|
|
10
10
|
const require_transform_injection_injectTComponentParameters = require("../../transform/injection/injectTComponentParameters.js");
|
|
11
11
|
const require_transform_injection_callbacks_injectUseGTCallbackParameters = require("../../transform/injection/callbacks/injectUseGTCallbackParameters.js");
|
|
12
|
-
require("../../transform/injection/callbacks/injectUseTranslationsCallbackParameters.js");
|
|
13
|
-
require("../../transform/injection/callbacks/injectUseMessagesCallbackParameters.js");
|
|
14
12
|
const require_transform_injection_injectStandaloneTFunctionParameters = require("../../transform/injection/injectStandaloneTFunctionParameters.js");
|
|
15
13
|
let _babel_types = require("@babel/types");
|
|
16
14
|
_babel_types = require_runtime.__toESM(_babel_types);
|
|
@@ -25,29 +23,12 @@ function processCallExpression(state) {
|
|
|
25
23
|
if (!functionName) return;
|
|
26
24
|
const { canonicalName, type } = require_transform_getTrackedVariable.getTrackedVariable(state.scopeTracker, namespaceName, functionName);
|
|
27
25
|
if (!canonicalName) return;
|
|
28
|
-
if (type === "generaltranslation" &&
|
|
26
|
+
if (type === "generaltranslation" && (canonicalName === "useGT_callback" || canonicalName === "getGT_callback")) require_transform_injection_callbacks_injectUseGTCallbackParameters.injectUseGTCallbackParameters(callExprPath, state);
|
|
29
27
|
else if (type === "react" && require_utils_constants_react_helpers.isReactFunction(canonicalName)) handleReactInvocation(callExpr, state);
|
|
30
|
-
else if (type === "generaltranslation" && canonicalName === "
|
|
28
|
+
else if (type === "generaltranslation" && canonicalName === "t") require_transform_injection_injectStandaloneTFunctionParameters.injectStandaloneTFunctionParameters(callExprPath, state);
|
|
31
29
|
};
|
|
32
30
|
}
|
|
33
31
|
/**
|
|
34
|
-
* Handle general translation variables
|
|
35
|
-
* useGTCallback(), useTranslationsCallback(), useMessagesCallback(), etc.
|
|
36
|
-
*/
|
|
37
|
-
function handleTranslationCallbackInvocation(callExprPath, state, canonicalName) {
|
|
38
|
-
switch (canonicalName) {
|
|
39
|
-
case "useGT_callback":
|
|
40
|
-
case "getGT_callback":
|
|
41
|
-
require_transform_injection_callbacks_injectUseGTCallbackParameters.injectUseGTCallbackParameters(callExprPath, state);
|
|
42
|
-
break;
|
|
43
|
-
case "useTranslations_callback":
|
|
44
|
-
case "getTranslations_callback": break;
|
|
45
|
-
case "useMessages_callback":
|
|
46
|
-
case "getMessages_callback": break;
|
|
47
|
-
default: return;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
32
|
* Handle react function invocations
|
|
52
33
|
* jsxDEV, jsx, jsxs, ...
|
|
53
34
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processCallExpression.js","names":["getCalleeNameFromExpression","getTrackedVariable","
|
|
1
|
+
{"version":3,"file":"processCallExpression.js","names":["getCalleeNameFromExpression","getTrackedVariable","isReactFunction","createErrorLocation","t","getCalleeNameFromJsxExpressionParam","isTranslationComponent"],"sources":["../../../src/processing/injection/processCallExpression.ts"],"sourcesContent":["import { VisitNode } from '@babel/traverse';\nimport { TransformState } from '../../state/types';\nimport * as t from '@babel/types';\nimport {\n GT_CALLBACK_FUNCTIONS,\n GT_OTHER_FUNCTIONS,\n} from '../../utils/constants/gt/constants';\nimport { getCalleeNameFromExpression } from '../../utils/parsing/getCalleeNameFromExpression';\nimport { getTrackedVariable } from '../../transform/getTrackedVariable';\nimport { isTranslationComponent } from '../../utils/constants/gt/helpers';\nimport { isReactFunction } from '../../utils/constants/react/helpers';\nimport { getCalleeNameFromJsxExpressionParam } from '../../transform/jsx-children/utils/getCalleeNameFromJsxExpressionParam';\nimport { injectTComponentParameters } from '../../transform/injection/injectTComponentParameters';\nimport { createErrorLocation } from '../../utils/errors';\nimport { injectUseGTCallbackParameters } from '../../transform/injection/callbacks/injectUseGTCallbackParameters';\nimport { injectStandaloneTFunctionParameters } from '../../transform/injection/injectStandaloneTFunctionParameters';\n\n/**\n * Process call expression:\n */\nexport function processCallExpression(\n state: TransformState\n): VisitNode<t.Node, t.CallExpression> {\n return (callExprPath) => {\n // Get the call expression\n const callExpr = callExprPath.node;\n\n // Get function name from callee\n const { namespaceName, functionName } =\n getCalleeNameFromExpression(callExpr);\n if (!functionName) {\n return;\n }\n\n // Get the canonical function name\n const { canonicalName, type } = getTrackedVariable(\n state.scopeTracker,\n namespaceName,\n functionName\n );\n if (!canonicalName) {\n return;\n }\n\n // Handle each respective case\n if (\n type === 'generaltranslation' &&\n (canonicalName === GT_CALLBACK_FUNCTIONS.useGT_callback ||\n canonicalName === GT_CALLBACK_FUNCTIONS.getGT_callback)\n ) {\n injectUseGTCallbackParameters(callExprPath, state);\n } else if (type === 'react' && isReactFunction(canonicalName)) {\n // Handle react variables (jsxDEV, etc.)\n handleReactInvocation(callExpr, state);\n } else if (\n type === 'generaltranslation' &&\n canonicalName === GT_OTHER_FUNCTIONS.t\n ) {\n injectStandaloneTFunctionParameters(callExprPath, state);\n }\n };\n}\n\n/* =============================== */\n/* Handlers */\n/* =============================== */\n\n/**\n * Handle react function invocations\n * jsxDEV, jsx, jsxs, ...\n *\n * We want to check these because they wrap <T> and other components\n */\nfunction handleReactInvocation(\n callExpr: t.CallExpression,\n state: TransformState\n) {\n // Check if it contains a GT component (first argument)\n if (callExpr.arguments.length === 0) {\n state.logger.logError(\n 'React invocation must have at least one argument. Parameter injection failed.' +\n createErrorLocation(callExpr)\n );\n return;\n }\n const firstArg = callExpr.arguments[0];\n if (!t.isExpression(firstArg)) {\n state.logger.logError(\n 'React invocation first argument must be an expression. Parameter injection failed.' +\n createErrorLocation(callExpr)\n );\n return;\n }\n\n // Get function name from callee\n const { namespaceName, functionName } =\n getCalleeNameFromJsxExpressionParam(firstArg);\n if (!functionName) {\n state.logger.logError(\n 'React invocation first argument must be a function. Parameter injection failed.' +\n createErrorLocation(callExpr)\n );\n return;\n }\n // Get the canonical function name\n const { canonicalName, type } = getTrackedVariable(\n state.scopeTracker,\n namespaceName,\n functionName\n );\n if (!canonicalName) {\n return;\n }\n\n // Filter out non-GT components\n if (type !== 'generaltranslation' || !isTranslationComponent(canonicalName)) {\n return;\n }\n\n // Track the component (increment counter, initialize aggregator, set hash)\n injectTComponentParameters(callExpr, state);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,SAAgB,sBACd,OACqC;AACrC,SAAQ,iBAAiB;EAEvB,MAAM,WAAW,aAAa;EAG9B,MAAM,EAAE,eAAe,iBACrBA,kDAAAA,4BAA4B,SAAS;AACvC,MAAI,CAAC,aACH;EAIF,MAAM,EAAE,eAAe,SAASC,qCAAAA,mBAC9B,MAAM,cACN,eACA,aACD;AACD,MAAI,CAAC,cACH;AAIF,MACE,SAAS,yBACR,kBAAA,oBACC,kBAAA,kBAEF,qEAAA,8BAA8B,cAAc,MAAM;WACzC,SAAS,WAAWC,sCAAAA,gBAAgB,cAAc,CAE3D,uBAAsB,UAAU,MAAM;WAEtC,SAAS,wBACT,kBAAA,IAEA,iEAAA,oCAAoC,cAAc,MAAM;;;;;;;;;AAe9D,SAAS,sBACP,UACA,OACA;AAEA,KAAI,SAAS,UAAU,WAAW,GAAG;AACnC,QAAM,OAAO,SACX,kFACEC,qBAAAA,oBAAoB,SAAS,CAChC;AACD;;CAEF,MAAM,WAAW,SAAS,UAAU;AACpC,KAAI,CAACC,aAAE,aAAa,SAAS,EAAE;AAC7B,QAAM,OAAO,SACX,uFACED,qBAAAA,oBAAoB,SAAS,CAChC;AACD;;CAIF,MAAM,EAAE,eAAe,iBACrBE,yEAAAA,oCAAoC,SAAS;AAC/C,KAAI,CAAC,cAAc;AACjB,QAAM,OAAO,SACX,oFACEF,qBAAAA,oBAAoB,SAAS,CAChC;AACD;;CAGF,MAAM,EAAE,eAAe,SAASF,qCAAAA,mBAC9B,MAAM,cACN,eACA,aACD;AACD,KAAI,CAAC,cACH;AAIF,KAAI,SAAS,wBAAwB,CAACK,mCAAAA,uBAAuB,cAAc,CACzE;AAIF,wDAAA,2BAA2B,UAAU,MAAM"}
|
|
@@ -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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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.
|
|
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.
|
|
28
|
+
"generaltranslation": "9.0.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/babel__core": "^7.20.0",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TransformState } from '../../../state/types';
|
|
2
|
-
import * as t from '@babel/types';
|
|
3
|
-
import { NodePath } from '@babel/traverse';
|
|
4
|
-
/**
|
|
5
|
-
* Injects parameters into invocation of useMessages_callback(..., { $_hash })
|
|
6
|
-
*/
|
|
7
|
-
export declare function injectUseMessagesCallbackParameters(_callExprPath: NodePath<t.CallExpression>, _state: TransformState): void;
|
|
8
|
-
//# sourceMappingURL=injectUseMessagesCallbackParameters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injectUseMessagesCallbackParameters.d.ts","sourceRoot":"","sources":["../../../../src/transform/injection/callbacks/injectUseMessagesCallbackParameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;GAEG;AACH,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,EACzC,MAAM,EAAE,cAAc,QACpB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/transform/injection/callbacks/injectUseMessagesCallbackParameters.ts
|
|
3
|
-
/**
|
|
4
|
-
* Injects parameters into invocation of useMessages_callback(..., { $_hash })
|
|
5
|
-
*/
|
|
6
|
-
function injectUseMessagesCallbackParameters(_callExprPath, _state) {}
|
|
7
|
-
//#endregion
|
|
8
|
-
exports.injectUseMessagesCallbackParameters = injectUseMessagesCallbackParameters;
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=injectUseMessagesCallbackParameters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injectUseMessagesCallbackParameters.js","names":[],"sources":["../../../../src/transform/injection/callbacks/injectUseMessagesCallbackParameters.ts"],"sourcesContent":["import { TransformState } from '../../../state/types';\nimport * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\n\n/**\n * Injects parameters into invocation of useMessages_callback(..., { $_hash })\n */\nexport function injectUseMessagesCallbackParameters(\n _callExprPath: NodePath<t.CallExpression>,\n _state: TransformState\n) {}\n"],"mappings":";;;;;AAOA,SAAgB,oCACd,eACA,QACA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TransformState } from '../../../state/types';
|
|
2
|
-
import * as t from '@babel/types';
|
|
3
|
-
import { NodePath } from '@babel/traverse';
|
|
4
|
-
/**
|
|
5
|
-
* Injects parameters into invocation of useTranslations_callback(..., { $_hash })
|
|
6
|
-
*/
|
|
7
|
-
export declare function injectUseTranslationsCallbackParameters(_callExprPath: NodePath<t.CallExpression>, _state: TransformState): void;
|
|
8
|
-
//# sourceMappingURL=injectUseTranslationsCallbackParameters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injectUseTranslationsCallbackParameters.d.ts","sourceRoot":"","sources":["../../../../src/transform/injection/callbacks/injectUseTranslationsCallbackParameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;GAEG;AACH,wBAAgB,uCAAuC,CACrD,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,EACzC,MAAM,EAAE,cAAc,QACpB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/transform/injection/callbacks/injectUseTranslationsCallbackParameters.ts
|
|
3
|
-
/**
|
|
4
|
-
* Injects parameters into invocation of useTranslations_callback(..., { $_hash })
|
|
5
|
-
*/
|
|
6
|
-
function injectUseTranslationsCallbackParameters(_callExprPath, _state) {}
|
|
7
|
-
//#endregion
|
|
8
|
-
exports.injectUseTranslationsCallbackParameters = injectUseTranslationsCallbackParameters;
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=injectUseTranslationsCallbackParameters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"injectUseTranslationsCallbackParameters.js","names":[],"sources":["../../../../src/transform/injection/callbacks/injectUseTranslationsCallbackParameters.ts"],"sourcesContent":["import { TransformState } from '../../../state/types';\nimport * as t from '@babel/types';\nimport { NodePath } from '@babel/traverse';\n\n/**\n * Injects parameters into invocation of useTranslations_callback(..., { $_hash })\n */\nexport function injectUseTranslationsCallbackParameters(\n _callExprPath: NodePath<t.CallExpression>,\n _state: TransformState\n) {}\n"],"mappings":";;;;;AAOA,SAAgB,wCACd,eACA,QACA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TransformState } from '../../../state/types';
|
|
2
|
-
/**
|
|
3
|
-
* Track gt() function invocations
|
|
4
|
-
* - Adds the translation content to the string collector
|
|
5
|
-
*/
|
|
6
|
-
export declare function registerUseMessagesCallback(_params: {
|
|
7
|
-
identifier: number;
|
|
8
|
-
state: TransformState;
|
|
9
|
-
}): void;
|
|
10
|
-
//# sourceMappingURL=registerUseMessagesCallback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerUseMessagesCallback.d.ts","sourceRoot":"","sources":["../../../../src/transform/registration/callbacks/registerUseMessagesCallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,cAAc,CAAC;CACvB,GAAG,IAAI,CAEP"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/transform/registration/callbacks/registerUseMessagesCallback.ts
|
|
3
|
-
/**
|
|
4
|
-
* Track gt() function invocations
|
|
5
|
-
* - Adds the translation content to the string collector
|
|
6
|
-
*/
|
|
7
|
-
function registerUseMessagesCallback(_params) {}
|
|
8
|
-
//#endregion
|
|
9
|
-
exports.registerUseMessagesCallback = registerUseMessagesCallback;
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=registerUseMessagesCallback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerUseMessagesCallback.js","names":[],"sources":["../../../../src/transform/registration/callbacks/registerUseMessagesCallback.ts"],"sourcesContent":["import { TransformState } from '../../../state/types';\n\n/**\n * Track gt() function invocations\n * - Adds the translation content to the string collector\n */\nexport function registerUseMessagesCallback(_params: {\n identifier: number;\n state: TransformState;\n}): void {\n // For future useMessagesCallback implementation\n}\n"],"mappings":";;;;;;AAMA,SAAgB,4BAA4B,SAGnC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TransformState } from '../../../state/types';
|
|
2
|
-
/**
|
|
3
|
-
* Track t() function invocations
|
|
4
|
-
* - Adds the translation content to the string collector
|
|
5
|
-
*/
|
|
6
|
-
export declare function registerUseTranslationsCallback(_params: {
|
|
7
|
-
identifier: number;
|
|
8
|
-
state: TransformState;
|
|
9
|
-
}): void;
|
|
10
|
-
//# sourceMappingURL=registerUseTranslationsCallback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerUseTranslationsCallback.d.ts","sourceRoot":"","sources":["../../../../src/transform/registration/callbacks/registerUseTranslationsCallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,cAAc,CAAC;CACvB,GAAG,IAAI,CAEP"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region src/transform/registration/callbacks/registerUseTranslationsCallback.ts
|
|
3
|
-
/**
|
|
4
|
-
* Track t() function invocations
|
|
5
|
-
* - Adds the translation content to the string collector
|
|
6
|
-
*/
|
|
7
|
-
function registerUseTranslationsCallback(_params) {}
|
|
8
|
-
//#endregion
|
|
9
|
-
exports.registerUseTranslationsCallback = registerUseTranslationsCallback;
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=registerUseTranslationsCallback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerUseTranslationsCallback.js","names":[],"sources":["../../../../src/transform/registration/callbacks/registerUseTranslationsCallback.ts"],"sourcesContent":["import { TransformState } from '../../../state/types';\n\n/**\n * Track t() function invocations\n * - Adds the translation content to the string collector\n */\nexport function registerUseTranslationsCallback(_params: {\n identifier: number;\n state: TransformState;\n}): void {\n // For future useTranslationsCallback implementation\n}\n"],"mappings":";;;;;;AAMA,SAAgB,gCAAgC,SAGvC"}
|