@generaltranslation/compiler 1.3.24 → 1.3.25-odysseus.1
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 +5 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/passes/basePass.d.ts.map +1 -1
- package/dist/passes/basePass.js +9 -10
- package/dist/passes/basePass.js.map +1 -1
- package/dist/processing/collection/processTaggedTemplateExpression.d.ts +1 -1
- package/dist/processing/collection/processTaggedTemplateExpression.js +1 -1
- package/dist/processing/collection/processTaggedTemplateExpression.js.map +1 -1
- package/dist/processing/jsx-insertion/processCallExpression.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/processing/macro-expansion/processProgram.js +1 -1
- package/dist/processing/macro-expansion/processProgram.js.map +1 -1
- package/dist/processing/macro-expansion/processTaggedTemplateExpression.d.ts +1 -1
- package/dist/processing/macro-expansion/processTaggedTemplateExpression.js +1 -1
- package/dist/processing/macro-expansion/processTaggedTemplateExpression.js.map +1 -1
- package/dist/processing/processFunctionDeclaration.js +1 -1
- package/dist/processing/processFunctionExpression.js +1 -1
- package/dist/processing/runtime-translate/processProgram.d.ts.map +1 -1
- package/dist/processing/runtime-translate/processProgram.js +2 -1
- package/dist/processing/runtime-translate/processProgram.js.map +1 -1
- package/dist/state/utils/initializeState.d.ts.map +1 -1
- package/dist/state/utils/initializeState.js +7 -4
- package/dist/state/utils/initializeState.js.map +1 -1
- package/dist/transform/jsx-children/constructJsxChildren.js.map +1 -1
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.d.ts +2 -2
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.d.ts.map +1 -1
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.js +4 -3
- package/dist/transform/jsx-insertion/injectJsxInsertionImport.js.map +1 -1
- package/dist/transform/macro-expansion/injectMacroImport.d.ts +2 -2
- package/dist/transform/macro-expansion/injectMacroImport.d.ts.map +1 -1
- package/dist/transform/macro-expansion/injectMacroImport.js +4 -3
- package/dist/transform/macro-expansion/injectMacroImport.js.map +1 -1
- package/dist/transform/runtime-translate/injectRuntimeTranslateImport.d.ts +3 -2
- package/dist/transform/runtime-translate/injectRuntimeTranslateImport.d.ts.map +1 -1
- package/dist/transform/runtime-translate/injectRuntimeTranslateImport.js +4 -3
- package/dist/transform/runtime-translate/injectRuntimeTranslateImport.js.map +1 -1
- package/dist/transform/validation/validateTranslationComponentArgs.js +0 -1
- package/dist/transform/validation/validateTranslationComponentArgs.js.map +1 -1
- package/dist/transform/validation/validateTranslationFunction.d.ts.map +1 -1
- package/dist/transform/validation/validateTranslationFunction.js +3 -3
- package/dist/transform/validation/validateTranslationFunction.js.map +1 -1
- package/dist/utils/constants/gt/constants.d.ts +1 -5
- package/dist/utils/constants/gt/constants.d.ts.map +1 -1
- package/dist/utils/constants/gt/constants.js +1 -5
- package/dist/utils/constants/gt/constants.js.map +1 -1
- package/dist/utils/constants/gt/helpers.d.ts +2 -1
- package/dist/utils/constants/gt/helpers.d.ts.map +1 -1
- package/dist/utils/constants/gt/helpers.js +15 -5
- package/dist/utils/constants/gt/helpers.js.map +1 -1
- package/dist/utils/constants/resolveIdentifier/isGTComponent.d.ts +1 -1
- package/dist/utils/constants/resolveIdentifier/isGTComponent.d.ts.map +1 -1
- package/dist/utils/constants/resolveIdentifier/isGTComponent.js +2 -3
- package/dist/utils/constants/resolveIdentifier/isGTComponent.js.map +1 -1
- package/dist/utils/parsing/isStringTranslationTaggedTemplate.d.ts +1 -1
- package/dist/utils/parsing/isStringTranslationTaggedTemplate.js +3 -3
- package/dist/utils/parsing/isStringTranslationTaggedTemplate.js.map +1 -1
- package/package.json +3 -3
- package/dist/processing/index.d.ts +0 -15
- package/dist/processing/index.d.ts.map +0 -1
- package/dist/processing/index.js +0 -29
- package/dist/transform/jsx-children/index.d.ts +0 -2
- package/dist/transform/jsx-children/index.d.ts.map +0 -1
- package/dist/transform/jsx-children/index.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../../../src/utils/constants/gt/constants.ts"],"sourcesContent":["/**\n * Different gt components\n */\nexport enum GT_COMPONENT_TYPES {\n T = 'T',\n Tx = 'Tx',\n Var = 'Var',\n Currency = 'Currency',\n DateTime = 'DateTime',\n RelativeTime = 'RelativeTime',\n Num = 'Num',\n
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../../src/utils/constants/gt/constants.ts"],"sourcesContent":["/**\n * Different gt components\n */\nexport enum GT_COMPONENT_TYPES {\n T = 'T',\n Tx = 'Tx',\n Var = 'Var',\n Currency = 'Currency',\n DateTime = 'DateTime',\n RelativeTime = 'RelativeTime',\n Num = 'Num',\n Derive = 'Derive',\n Branch = 'Branch',\n Plural = 'Plural',\n LocaleSelector = 'LocaleSelector',\n GtInternalTranslateJsx = 'GtInternalTranslateJsx',\n GtInternalVar = 'GtInternalVar',\n GtInternalNum = 'GtInternalNum',\n GtInternalCurrency = 'GtInternalCurrency',\n GtInternalDateTime = 'GtInternalDateTime',\n}\n\n/**\n * GT functions that produce callbacks\n */\nexport enum GT_FUNCTIONS_WITH_CALLBACKS {\n useGT = 'useGT',\n getGT = 'getGT',\n useTranslations = 'useTranslations',\n getTranslations = 'getTranslations',\n useMessages = 'useMessages',\n getMessages = 'getMessages',\n}\n\n/**\n * Other GT functions\n */\nexport enum GT_OTHER_FUNCTIONS {\n msg = 'msg',\n t = 't',\n derive = 'derive',\n GtInternalRuntimeTranslateString = 'GtInternalRuntimeTranslateString',\n GtInternalRuntimeTranslateJsx = 'GtInternalRuntimeTranslateJsx',\n}\n\n/**\n * Different gt functions\n */\nexport type GT_FUNCTIONS = GT_FUNCTIONS_WITH_CALLBACKS | GT_OTHER_FUNCTIONS;\n/**\n * gt callback functions\n */\nexport enum GT_CALLBACK_FUNCTIONS {\n useGT_callback = 'useGT_callback',\n getGT_callback = 'getGT_callback',\n useTranslations_callback = 'useTranslations_callback',\n getTranslations_callback = 'getTranslations_callback',\n useMessages_callback = 'useMessages_callback',\n getMessages_callback = 'getMessages_callback',\n}\n\n/**\n * Maps GT Functions to their callback functions\n */\nexport const GT_FUNCTIONS_TO_CALLBACKS: Record<\n GT_FUNCTIONS_WITH_CALLBACKS,\n GT_CALLBACK_FUNCTIONS\n> = {\n [GT_FUNCTIONS_WITH_CALLBACKS.useGT]: GT_CALLBACK_FUNCTIONS.useGT_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.getGT]: GT_CALLBACK_FUNCTIONS.getGT_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.useTranslations]:\n GT_CALLBACK_FUNCTIONS.useTranslations_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.getTranslations]:\n GT_CALLBACK_FUNCTIONS.getTranslations_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.useMessages]:\n GT_CALLBACK_FUNCTIONS.useMessages_callback,\n [GT_FUNCTIONS_WITH_CALLBACKS.getMessages]:\n GT_CALLBACK_FUNCTIONS.getMessages_callback,\n};\n\n/**\n * GT derive functions\n */\nexport const GT_DERIVE_STRING_FUNCTIONS = [GT_OTHER_FUNCTIONS.derive] as const;\n\n/**\n * All gt functions (both regular and callback functions)\n */\nexport type GT_ALL_FUNCTIONS =\n | GT_FUNCTIONS\n | GT_CALLBACK_FUNCTIONS\n | GT_COMPONENT_TYPES;\n\n/**\n * GT import sources\n */\nexport enum GT_IMPORT_SOURCES {\n GT_NEXT = 'gt-next',\n GT_NEXT_SERVER = 'gt-next/server',\n GT_REACT = 'gt-react',\n GT_REACT_CLIENT = 'gt-react/client',\n GT_REACT_BROWSER = 'gt-react/browser',\n GT_I18N = 'gt-i18n',\n}\n\n/**\n * Branch control props — not translatable content.\n * `branch` is the selector key; `data-*` props are HTML attributes ignored at runtime.\n * `data-*` is handled as a prefix check, not listed here.\n */\nexport const BRANCH_CONTROL_PROPS = new Set(['branch']);\n\n/**\n * Plural control props — not translatable content.\n * `n` is the count, `locales` is the locale hint.\n */\nexport const PLURAL_CONTROL_PROPS = new Set(['n', 'locales']);\n\n/**\n * Set of valid plural forms for Plural components\n */\nexport const PLURAL_FORMS = new Set([\n 'singular',\n 'plural',\n 'dual',\n 'zero',\n 'one',\n 'two',\n 'few',\n 'many',\n 'other',\n]);\n\n/**\n * Fields that must be string literals for useGT_callback / getGT_callback\n */\nexport enum USEGT_CALLBACK_OPTIONS {\n $id = '$id',\n $context = '$context',\n $maxChars = '$maxChars',\n $_hash = '$_hash',\n $format = '$format',\n}\n\n/**\n * Maps GT Component Types to their minified names\n */\nexport const MINIFY_CANONICAL_NAME_MAP = {\n [GT_COMPONENT_TYPES.Var]: 'v',\n [GT_COMPONENT_TYPES.GtInternalVar]: 'v',\n [GT_COMPONENT_TYPES.Num]: 'n',\n [GT_COMPONENT_TYPES.GtInternalNum]: 'n',\n [GT_COMPONENT_TYPES.Currency]: 'c',\n [GT_COMPONENT_TYPES.GtInternalCurrency]: 'c',\n [GT_COMPONENT_TYPES.DateTime]: 'd',\n [GT_COMPONENT_TYPES.GtInternalDateTime]: 'd',\n [GT_COMPONENT_TYPES.RelativeTime]: 'rt',\n [GT_COMPONENT_TYPES.Derive]: 's',\n [GT_COMPONENT_TYPES.Branch]: 'b',\n [GT_COMPONENT_TYPES.Plural]: 'p',\n} as const;\n"],"mappings":";;;;;AAGA,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,OAAA;AACA,oBAAA,QAAA;AACA,oBAAA,SAAA;AACA,oBAAA,cAAA;AACA,oBAAA,cAAA;AACA,oBAAA,kBAAA;AACA,oBAAA,SAAA;AACA,oBAAA,YAAA;AACA,oBAAA,YAAA;AACA,oBAAA,YAAA;AACA,oBAAA,oBAAA;AACA,oBAAA,4BAAA;AACA,oBAAA,mBAAA;AACA,oBAAA,mBAAA;AACA,oBAAA,wBAAA;AACA,oBAAA,wBAAA;;KACD;;;;AAKD,IAAY,8BAAL,yBAAA,6BAAA;AACL,6BAAA,WAAA;AACA,6BAAA,WAAA;AACA,6BAAA,qBAAA;AACA,6BAAA,qBAAA;AACA,6BAAA,iBAAA;AACA,6BAAA,iBAAA;;KACD;;;;AAKD,IAAY,qBAAL,yBAAA,oBAAA;AACL,oBAAA,SAAA;AACA,oBAAA,OAAA;AACA,oBAAA,YAAA;AACA,oBAAA,sCAAA;AACA,oBAAA,mCAAA;;KACD;;;;AASD,IAAY,wBAAL,yBAAA,uBAAA;AACL,uBAAA,oBAAA;AACA,uBAAA,oBAAA;AACA,uBAAA,8BAAA;AACA,uBAAA,8BAAA;AACA,uBAAA,0BAAA;AACA,uBAAA,0BAAA;;KACD;;;;AAKD,MAAa,4BAGT;;;;;;;CAWH;;;;AAKD,MAAa,6BAA6B,CAAA,SAA2B;;;;AAarE,IAAY,oBAAL,yBAAA,mBAAA;AACL,mBAAA,aAAA;AACA,mBAAA,oBAAA;AACA,mBAAA,cAAA;AACA,mBAAA,qBAAA;AACA,mBAAA,sBAAA;AACA,mBAAA,aAAA;;KACD;;;;;;AAOD,MAAa,uBAAuB,IAAI,IAAI,CAAC,SAAS,CAAC;;;;;AAMvD,MAAa,uBAAuB,IAAI,IAAI,CAAC,KAAK,UAAU,CAAC;;;;AAK7D,MAAa,eAAe,IAAI,IAAI;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;AAKF,IAAY,yBAAL,yBAAA,wBAAA;AACL,wBAAA,SAAA;AACA,wBAAA,cAAA;AACA,wBAAA,eAAA;AACA,wBAAA,YAAA;AACA,wBAAA,aAAA;;KACD;;;;AAKD,MAAa,4BAA4B;UACb;oBACU;UACV;oBACU;eACL;yBACU;eACV;yBACU;mBACN;aACN;aACA;aACA;CAC9B"}
|
|
@@ -49,6 +49,8 @@ export declare function isTranslationFunctionCallback(name: string): name is GT_
|
|
|
49
49
|
* Check if it's a GT import source
|
|
50
50
|
*/
|
|
51
51
|
export declare function isGTImportSource(name: string): name is GT_IMPORT_SOURCES;
|
|
52
|
+
export declare function isGTReactImportSource(name: string): name is GT_IMPORT_SOURCES.GT_REACT | GT_IMPORT_SOURCES.GT_REACT_CLIENT | GT_IMPORT_SOURCES.GT_REACT_BROWSER;
|
|
53
|
+
export declare function getGtReactImportSource(legacyGtReactImportSource: boolean): GT_IMPORT_SOURCES.GT_REACT | GT_IMPORT_SOURCES.GT_REACT_BROWSER;
|
|
52
54
|
/**
|
|
53
55
|
* Check if is a html content prop
|
|
54
56
|
*/
|
|
@@ -71,7 +73,6 @@ export declare const defaultVariableNames: {
|
|
|
71
73
|
readonly Currency: "cost";
|
|
72
74
|
readonly GtInternalCurrency: "cost";
|
|
73
75
|
readonly Derive: "static";
|
|
74
|
-
readonly Static: "static";
|
|
75
76
|
};
|
|
76
77
|
/**
|
|
77
78
|
* Get the variable name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/utils/constants/gt/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EAElB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,gBAAgB,CAiCnE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,2BAA2B,CASrC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAEtE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,kBAAkB,CAAC,CAAC,CAK9B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAc5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/utils/constants/gt/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EAElB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,2BAA2B,EAC5B,MAAM,kCAAkC,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,gBAAgB,CAiCnE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,2BAA2B,CASrC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAEtE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,kBAAkB,CAAC,CAAC,CAK9B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAc5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAE1E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,kBAAkB,CAI1E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,OAAO,GAAG,OAAO,CAE7E;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,qBAAqB,CAS/B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,iBAAiB,CAWxE;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,GACX,IAAI,IACH,iBAAiB,CAAC,QAAQ,GAC1B,iBAAiB,CAAC,eAAe,GACjC,iBAAiB,CAAC,gBAAgB,CAQrC;AAED,wBAAgB,sBAAsB,CACpC,yBAAyB,EAAE,OAAO,GACjC,iBAAiB,CAAC,QAAQ,GAAG,iBAAiB,CAAC,gBAAgB,CAIjE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,MAAM,2BAA2B,CAI3C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,GAAG,MAAM,CAM7E;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAWvB,CAAC;AAGX;;GAEG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,MAAM,OAAO,oBAAoB,EAC/C,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAIR"}
|
|
@@ -21,6 +21,7 @@ function isGTFunction(name) {
|
|
|
21
21
|
"getMessages",
|
|
22
22
|
"msg",
|
|
23
23
|
"t",
|
|
24
|
+
"derive",
|
|
24
25
|
"useGT_callback",
|
|
25
26
|
"getGT_callback",
|
|
26
27
|
"useTranslations_callback",
|
|
@@ -30,7 +31,6 @@ function isGTFunction(name) {
|
|
|
30
31
|
"T",
|
|
31
32
|
"Tx",
|
|
32
33
|
"Var",
|
|
33
|
-
"Static",
|
|
34
34
|
"Derive",
|
|
35
35
|
"Currency",
|
|
36
36
|
"DateTime",
|
|
@@ -94,7 +94,7 @@ function isVariableComponent(name) {
|
|
|
94
94
|
* Check if a name is a GT derive component
|
|
95
95
|
*/
|
|
96
96
|
function isDeriveComponent(name) {
|
|
97
|
-
return
|
|
97
|
+
return name === "Derive";
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Check if a name is a GT branch component
|
|
@@ -127,7 +127,6 @@ function isTranslationFunctionCallback(name) {
|
|
|
127
127
|
function isGTImportSource(name) {
|
|
128
128
|
return [
|
|
129
129
|
"gt-next",
|
|
130
|
-
"gt-next/client",
|
|
131
130
|
"gt-next/server",
|
|
132
131
|
"gt-react",
|
|
133
132
|
"gt-react/client",
|
|
@@ -135,6 +134,16 @@ function isGTImportSource(name) {
|
|
|
135
134
|
"gt-i18n"
|
|
136
135
|
].includes(name);
|
|
137
136
|
}
|
|
137
|
+
function isGTReactImportSource(name) {
|
|
138
|
+
return [
|
|
139
|
+
"gt-react",
|
|
140
|
+
"gt-react/client",
|
|
141
|
+
"gt-react/browser"
|
|
142
|
+
].includes(name);
|
|
143
|
+
}
|
|
144
|
+
function getGtReactImportSource(legacyGtReactImportSource) {
|
|
145
|
+
return legacyGtReactImportSource ? "gt-react/browser" : "gt-react";
|
|
146
|
+
}
|
|
138
147
|
/**
|
|
139
148
|
* Check if is a html content prop
|
|
140
149
|
*/
|
|
@@ -160,8 +169,7 @@ const defaultVariableNames = {
|
|
|
160
169
|
["RelativeTime"]: "time",
|
|
161
170
|
["Currency"]: "cost",
|
|
162
171
|
["GtInternalCurrency"]: "cost",
|
|
163
|
-
["Derive"]: "static"
|
|
164
|
-
["Static"]: "static"
|
|
172
|
+
["Derive"]: "static"
|
|
165
173
|
};
|
|
166
174
|
const baseVariablePrefix = "_gt_";
|
|
167
175
|
/**
|
|
@@ -173,6 +181,7 @@ function getVariableName(variableType, id, name) {
|
|
|
173
181
|
}
|
|
174
182
|
//#endregion
|
|
175
183
|
exports.defaultVariableNames = defaultVariableNames;
|
|
184
|
+
exports.getGtReactImportSource = getGtReactImportSource;
|
|
176
185
|
exports.getVariableName = getVariableName;
|
|
177
186
|
exports.isBranchComponent = isBranchComponent;
|
|
178
187
|
exports.isDeriveComponent = isDeriveComponent;
|
|
@@ -180,6 +189,7 @@ exports.isGTComponent = isGTComponent;
|
|
|
180
189
|
exports.isGTFunction = isGTFunction;
|
|
181
190
|
exports.isGTFunctionWithCallbacks = isGTFunctionWithCallbacks;
|
|
182
191
|
exports.isGTImportSource = isGTImportSource;
|
|
192
|
+
exports.isGTReactImportSource = isGTReactImportSource;
|
|
183
193
|
exports.isHtmlContentProp = isHtmlContentProp;
|
|
184
194
|
exports.isTranslationComponent = isTranslationComponent;
|
|
185
195
|
exports.isTranslationFunction = isTranslationFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["GT_COMPONENT_TYPES","HTML_CONTENT_PROPS","MINIFY_CANONICAL_NAME_MAP"],"sources":["../../../../src/utils/constants/gt/helpers.ts"],"sourcesContent":["/**\n * Analysis utilities for identifying GT components and functions\n */\n\nimport {\n GT_ALL_FUNCTIONS,\n GT_CALLBACK_FUNCTIONS,\n GT_COMPONENT_TYPES,\n GT_FUNCTIONS_WITH_CALLBACKS,\n GT_IMPORT_SOURCES,\n MINIFY_CANONICAL_NAME_MAP,\n} from './constants';\nimport {\n HTML_CONTENT_PROPS,\n HtmlContentPropValuesRecord,\n} from '@generaltranslation/format/types';\n\n/**\n * Check if a name is a GT function\n * @param name - The name to check\n * @returns True if the name is a GT function\n */\nexport function isGTFunction(name: string): name is GT_ALL_FUNCTIONS {\n return [\n 'useGT',\n 'getGT',\n 'useTranslations',\n 'getTranslations',\n 'useMessages',\n 'getMessages',\n 'msg',\n 't',\n 'useGT_callback',\n 'getGT_callback',\n 'useTranslations_callback',\n 'getTranslations_callback',\n 'useMessages_callback',\n 'getMessages_callback',\n 'T',\n 'Tx',\n 'Var',\n '
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["GT_COMPONENT_TYPES","HTML_CONTENT_PROPS","MINIFY_CANONICAL_NAME_MAP"],"sources":["../../../../src/utils/constants/gt/helpers.ts"],"sourcesContent":["/**\n * Analysis utilities for identifying GT components and functions\n */\n\nimport {\n GT_ALL_FUNCTIONS,\n GT_CALLBACK_FUNCTIONS,\n GT_COMPONENT_TYPES,\n GT_FUNCTIONS_WITH_CALLBACKS,\n GT_IMPORT_SOURCES,\n MINIFY_CANONICAL_NAME_MAP,\n} from './constants';\nimport {\n HTML_CONTENT_PROPS,\n HtmlContentPropValuesRecord,\n} from '@generaltranslation/format/types';\n\n/**\n * Check if a name is a GT function\n * @param name - The name to check\n * @returns True if the name is a GT function\n */\nexport function isGTFunction(name: string): name is GT_ALL_FUNCTIONS {\n return [\n 'useGT',\n 'getGT',\n 'useTranslations',\n 'getTranslations',\n 'useMessages',\n 'getMessages',\n 'msg',\n 't',\n 'derive',\n 'useGT_callback',\n 'getGT_callback',\n 'useTranslations_callback',\n 'getTranslations_callback',\n 'useMessages_callback',\n 'getMessages_callback',\n 'T',\n 'Tx',\n 'Var',\n 'Derive',\n 'Currency',\n 'DateTime',\n 'RelativeTime',\n 'Num',\n 'Branch',\n 'Plural',\n 'GtInternalTranslateJsx',\n 'GtInternalVar',\n 'GtInternalNum',\n 'GtInternalCurrency',\n 'GtInternalDateTime',\n ].includes(name);\n}\n\n/**\n * Check if a name is a GT function with callbacks\n * @param name - The name to check\n * @returns True if the name is a GT function with callbacks\n */\nexport function isGTFunctionWithCallbacks(\n name: string\n): name is GT_FUNCTIONS_WITH_CALLBACKS {\n return [\n 'useGT',\n 'getGT',\n 'useTranslations',\n 'getTranslations',\n 'useMessages',\n 'getMessages',\n ].includes(name);\n}\n\n/**\n * Check if a name is a GT component\n * @param name - The name to check\n * @returns True if the name is a GT component\n */\nexport function isGTComponent(name: string): name is GT_COMPONENT_TYPES {\n return Object.values(GT_COMPONENT_TYPES).includes(name as GT_COMPONENT_TYPES);\n}\n\n/**\n * Check if a component name matches known gt-next translation components\n */\nexport function isTranslationComponent(\n name: string\n): name is GT_COMPONENT_TYPES.T {\n return [\n GT_COMPONENT_TYPES.T,\n GT_COMPONENT_TYPES.GtInternalTranslateJsx,\n ].includes(name as GT_COMPONENT_TYPES);\n}\n\n/**\n * Check if a component name matches known gt-next variable components\n */\nexport function isVariableComponent(name: string): name is GT_COMPONENT_TYPES {\n return (\n [\n GT_COMPONENT_TYPES.Var,\n GT_COMPONENT_TYPES.Num,\n GT_COMPONENT_TYPES.Currency,\n GT_COMPONENT_TYPES.DateTime,\n GT_COMPONENT_TYPES.RelativeTime,\n GT_COMPONENT_TYPES.GtInternalVar,\n GT_COMPONENT_TYPES.GtInternalNum,\n GT_COMPONENT_TYPES.GtInternalCurrency,\n GT_COMPONENT_TYPES.GtInternalDateTime,\n ] as string[]\n ).includes(name);\n}\n\n/**\n * Check if a name is a GT derive component\n */\nexport function isDeriveComponent(name: string): name is GT_COMPONENT_TYPES {\n return name === GT_COMPONENT_TYPES.Derive;\n}\n\n/**\n * Check if a name is a GT branch component\n */\nexport function isBranchComponent(name: string): name is GT_COMPONENT_TYPES {\n return (\n [GT_COMPONENT_TYPES.Branch, GT_COMPONENT_TYPES.Plural] as string[]\n ).includes(name);\n}\n\n/**\n * Check if a name is a GT translation function\n */\nexport function isTranslationFunction(name: string): name is 'useGT' | 'getGT' {\n return ['useGT', 'getGT'].includes(name);\n}\n\n/**\n * Check if it's a translation function callback (const t = useGT())\n */\nexport function isTranslationFunctionCallback(\n name: string\n): name is GT_CALLBACK_FUNCTIONS {\n return [\n 'useGT_callback',\n 'getGT_callback',\n 'useTranslations_callback',\n 'getTranslations_callback',\n 'useMessages_callback',\n 'getMessages_callback',\n ].includes(name);\n}\n\n/**\n * Check if it's a GT import source\n */\nexport function isGTImportSource(name: string): name is GT_IMPORT_SOURCES {\n return (\n [\n GT_IMPORT_SOURCES.GT_NEXT,\n GT_IMPORT_SOURCES.GT_NEXT_SERVER,\n GT_IMPORT_SOURCES.GT_REACT,\n GT_IMPORT_SOURCES.GT_REACT_CLIENT,\n GT_IMPORT_SOURCES.GT_REACT_BROWSER,\n GT_IMPORT_SOURCES.GT_I18N,\n ] as string[]\n ).includes(name);\n}\n\nexport function isGTReactImportSource(\n name: string\n): name is\n | GT_IMPORT_SOURCES.GT_REACT\n | GT_IMPORT_SOURCES.GT_REACT_CLIENT\n | GT_IMPORT_SOURCES.GT_REACT_BROWSER {\n return (\n [\n GT_IMPORT_SOURCES.GT_REACT,\n GT_IMPORT_SOURCES.GT_REACT_CLIENT,\n GT_IMPORT_SOURCES.GT_REACT_BROWSER,\n ] as string[]\n ).includes(name);\n}\n\nexport function getGtReactImportSource(\n legacyGtReactImportSource: boolean\n): GT_IMPORT_SOURCES.GT_REACT | GT_IMPORT_SOURCES.GT_REACT_BROWSER {\n return legacyGtReactImportSource\n ? GT_IMPORT_SOURCES.GT_REACT_BROWSER\n : GT_IMPORT_SOURCES.GT_REACT;\n}\n\n/**\n * Check if is a html content prop\n */\nexport function isHtmlContentProp(\n name: string\n): name is keyof HtmlContentPropValuesRecord {\n return Object.values(HTML_CONTENT_PROPS).includes(\n name as keyof HtmlContentPropValuesRecord\n );\n}\n\n/**\n * Minify the canonical name\n */\nexport function minifyCanonicalName(canonicalName: GT_COMPONENT_TYPES): string {\n return (\n MINIFY_CANONICAL_NAME_MAP[\n canonicalName as keyof typeof MINIFY_CANONICAL_NAME_MAP\n ] || canonicalName\n );\n}\n\n/**\n * Default variable names\n */\nexport const defaultVariableNames = {\n [GT_COMPONENT_TYPES.Var]: 'value',\n [GT_COMPONENT_TYPES.GtInternalVar]: 'value',\n [GT_COMPONENT_TYPES.Num]: 'n',\n [GT_COMPONENT_TYPES.GtInternalNum]: 'n',\n [GT_COMPONENT_TYPES.DateTime]: 'date',\n [GT_COMPONENT_TYPES.GtInternalDateTime]: 'date',\n [GT_COMPONENT_TYPES.RelativeTime]: 'time',\n [GT_COMPONENT_TYPES.Currency]: 'cost',\n [GT_COMPONENT_TYPES.GtInternalCurrency]: 'cost',\n [GT_COMPONENT_TYPES.Derive]: 'static',\n} as const;\nconst baseVariablePrefix = '_gt_';\n\n/**\n * Get the variable name\n */\nexport function getVariableName(\n variableType: keyof typeof defaultVariableNames,\n id: number,\n name?: string\n): string {\n if (name) return name;\n const baseVariableName = defaultVariableNames[variableType] || 'value';\n return `${baseVariablePrefix}${baseVariableName}_${id}`;\n}\n"],"mappings":";;;;;;;;;;;;;AAsBA,SAAgB,aAAa,MAAwC;AACnE,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK;;;;;;;AAQlB,SAAgB,0BACd,MACqC;AACrC,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK;;;;;;;AAQlB,SAAgB,cAAc,MAA0C;AACtE,QAAO,OAAO,OAAOA,qCAAAA,mBAAmB,CAAC,SAAS,KAA2B;;;;;AAM/E,SAAgB,uBACd,MAC8B;AAC9B,QAAO,CAAA,KAAA,yBAGN,CAAC,SAAS,KAA2B;;;;;AAMxC,SAAgB,oBAAoB,MAA0C;AAC5E,QACE;;;;;;;;;;EAUC,CACD,SAAS,KAAK;;;;;AAMlB,SAAgB,kBAAkB,MAA0C;AAC1E,QAAO,SAAA;;;;;AAMT,SAAgB,kBAAkB,MAA0C;AAC1E,QACE,CAAA,UAAA,SAAsD,CACtD,SAAS,KAAK;;;;;AAMlB,SAAgB,sBAAsB,MAAyC;AAC7E,QAAO,CAAC,SAAS,QAAQ,CAAC,SAAS,KAAK;;;;;AAM1C,SAAgB,8BACd,MAC+B;AAC/B,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,SAAS,KAAK;;;;;AAMlB,SAAgB,iBAAiB,MAAyC;AACxE,QACE;;;;;;;EAOC,CACD,SAAS,KAAK;;AAGlB,SAAgB,sBACd,MAIqC;AACrC,QACE;;;;EAIC,CACD,SAAS,KAAK;;AAGlB,SAAgB,uBACd,2BACiE;AACjE,QAAO,4BAAA,qBAAA;;;;;AAQT,SAAgB,kBACd,MAC2C;AAC3C,QAAO,OAAO,OAAOC,iCAAAA,mBAAmB,CAAC,SACvC,KACD;;;;;AAMH,SAAgB,oBAAoB,eAA2C;AAC7E,QACEC,qCAAAA,0BACE,kBACG;;;;;AAOT,MAAa,uBAAuB;UACR;oBACU;UACV;oBACU;eACL;yBACU;mBACN;eACJ;yBACU;aACZ;CAC9B;AACD,MAAM,qBAAqB;;;;AAK3B,SAAgB,gBACd,cACA,IACA,MACQ;AACR,KAAI,KAAM,QAAO;AAEjB,QAAO,GAAG,qBADe,qBAAqB,iBAAiB,QACf,GAAG"}
|
|
@@ -12,6 +12,6 @@ export declare function isUserTranslationComponent(firstArgPath: NodePath<t.Expr
|
|
|
12
12
|
export declare function isUserVariableComponent(firstArgPath: NodePath<t.Expression>): boolean;
|
|
13
13
|
/** Check if first arg is Branch or Plural */
|
|
14
14
|
export declare function isGTBranchComponent(firstArgPath: NodePath<t.Expression>): boolean;
|
|
15
|
-
/** Check if first arg is Derive
|
|
15
|
+
/** Check if first arg is Derive */
|
|
16
16
|
export declare function isGTDeriveComponent(firstArgPath: NodePath<t.Expression>): boolean;
|
|
17
17
|
//# sourceMappingURL=isGTComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isGTComponent.d.ts","sourceRoot":"","sources":["../../../../src/utils/constants/resolveIdentifier/isGTComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAIlC;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,MAAM,GAAG,IAAI,CAkBf;AAED,oFAAoF;AACpF,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAET;AAED,uFAAuF;AACvF,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAST;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAKT;AAED,
|
|
1
|
+
{"version":3,"file":"isGTComponent.d.ts","sourceRoot":"","sources":["../../../../src/utils/constants/resolveIdentifier/isGTComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAIlC;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,MAAM,GAAG,IAAI,CAkBf;AAED,oFAAoF;AACpF,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAET;AAED,uFAAuF;AACvF,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAST;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAKT;AAED,mCAAmC;AACnC,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GACnC,OAAO,CAGT"}
|
|
@@ -42,10 +42,9 @@ function isGTBranchComponent(firstArgPath) {
|
|
|
42
42
|
const name = resolveFirstArgGTName(firstArgPath);
|
|
43
43
|
return name === "Branch" || name === "Plural";
|
|
44
44
|
}
|
|
45
|
-
/** Check if first arg is Derive
|
|
45
|
+
/** Check if first arg is Derive */
|
|
46
46
|
function isGTDeriveComponent(firstArgPath) {
|
|
47
|
-
|
|
48
|
-
return name === "Derive" || name === "Static";
|
|
47
|
+
return resolveFirstArgGTName(firstArgPath) === "Derive";
|
|
49
48
|
}
|
|
50
49
|
//#endregion
|
|
51
50
|
exports.isGTBranchComponent = isGTBranchComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isGTComponent.js","names":["t","isGTImportSource"],"sources":["../../../../src/utils/constants/resolveIdentifier/isGTComponent.ts"],"sourcesContent":["import { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { isGTImportSource } from '../gt/helpers';\nimport { GT_COMPONENT_TYPES } from '../gt/constants';\n\n/**\n * Given a NodePath to the first argument of a jsx() call (the component identifier),\n * resolve it to its original imported name from a GT source.\n * Returns null if the identifier is not imported from a GT library.\n */\nexport function resolveFirstArgGTName(\n firstArgPath: NodePath<t.Expression>\n): string | null {\n if (!firstArgPath.isIdentifier()) return null;\n\n const binding = firstArgPath.scope.getBinding(firstArgPath.node.name);\n if (!binding || !binding.path.isImportSpecifier()) return null;\n\n const imported = binding.path.node.imported;\n const originalName = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n\n const parentPath = binding.path.parentPath;\n if (!parentPath?.isImportDeclaration()) return null;\n\n const importSource = parentPath.node.source.value;\n if (!isGTImportSource(importSource)) return null;\n\n return originalName;\n}\n\n/** Check if first arg of jsx call is user-written T (not GtInternalTranslateJsx) */\nexport function isUserTranslationComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n return resolveFirstArgGTName(firstArgPath) === GT_COMPONENT_TYPES.T;\n}\n\n/** Check if first arg is user-written Var, Num, Currency, DateTime, or RelativeTime */\nexport function isUserVariableComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return [\n GT_COMPONENT_TYPES.Var,\n GT_COMPONENT_TYPES.Num,\n GT_COMPONENT_TYPES.Currency,\n GT_COMPONENT_TYPES.DateTime,\n GT_COMPONENT_TYPES.RelativeTime,\n ].includes((name ?? '') as GT_COMPONENT_TYPES);\n}\n\n/** Check if first arg is Branch or Plural */\nexport function isGTBranchComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return (\n name === GT_COMPONENT_TYPES.Branch || name === GT_COMPONENT_TYPES.Plural\n );\n}\n\n/** Check if first arg is Derive
|
|
1
|
+
{"version":3,"file":"isGTComponent.js","names":["t","isGTImportSource"],"sources":["../../../../src/utils/constants/resolveIdentifier/isGTComponent.ts"],"sourcesContent":["import { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { isGTImportSource } from '../gt/helpers';\nimport { GT_COMPONENT_TYPES } from '../gt/constants';\n\n/**\n * Given a NodePath to the first argument of a jsx() call (the component identifier),\n * resolve it to its original imported name from a GT source.\n * Returns null if the identifier is not imported from a GT library.\n */\nexport function resolveFirstArgGTName(\n firstArgPath: NodePath<t.Expression>\n): string | null {\n if (!firstArgPath.isIdentifier()) return null;\n\n const binding = firstArgPath.scope.getBinding(firstArgPath.node.name);\n if (!binding || !binding.path.isImportSpecifier()) return null;\n\n const imported = binding.path.node.imported;\n const originalName = t.isIdentifier(imported)\n ? imported.name\n : imported.value;\n\n const parentPath = binding.path.parentPath;\n if (!parentPath?.isImportDeclaration()) return null;\n\n const importSource = parentPath.node.source.value;\n if (!isGTImportSource(importSource)) return null;\n\n return originalName;\n}\n\n/** Check if first arg of jsx call is user-written T (not GtInternalTranslateJsx) */\nexport function isUserTranslationComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n return resolveFirstArgGTName(firstArgPath) === GT_COMPONENT_TYPES.T;\n}\n\n/** Check if first arg is user-written Var, Num, Currency, DateTime, or RelativeTime */\nexport function isUserVariableComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return [\n GT_COMPONENT_TYPES.Var,\n GT_COMPONENT_TYPES.Num,\n GT_COMPONENT_TYPES.Currency,\n GT_COMPONENT_TYPES.DateTime,\n GT_COMPONENT_TYPES.RelativeTime,\n ].includes((name ?? '') as GT_COMPONENT_TYPES);\n}\n\n/** Check if first arg is Branch or Plural */\nexport function isGTBranchComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return (\n name === GT_COMPONENT_TYPES.Branch || name === GT_COMPONENT_TYPES.Plural\n );\n}\n\n/** Check if first arg is Derive */\nexport function isGTDeriveComponent(\n firstArgPath: NodePath<t.Expression>\n): boolean {\n const name = resolveFirstArgGTName(firstArgPath);\n return name === GT_COMPONENT_TYPES.Derive;\n}\n"],"mappings":";;;;;;;;;;;;AAUA,SAAgB,sBACd,cACe;AACf,KAAI,CAAC,aAAa,cAAc,CAAE,QAAO;CAEzC,MAAM,UAAU,aAAa,MAAM,WAAW,aAAa,KAAK,KAAK;AACrE,KAAI,CAAC,WAAW,CAAC,QAAQ,KAAK,mBAAmB,CAAE,QAAO;CAE1D,MAAM,WAAW,QAAQ,KAAK,KAAK;CACnC,MAAM,eAAeA,aAAE,aAAa,SAAS,GACzC,SAAS,OACT,SAAS;CAEb,MAAM,aAAa,QAAQ,KAAK;AAChC,KAAI,EAAA,eAAA,QAAA,eAAA,KAAA,IAAA,KAAA,IAAC,WAAY,qBAAqB,EAAE,QAAO;CAE/C,MAAM,eAAe,WAAW,KAAK,OAAO;AAC5C,KAAI,CAACC,mCAAAA,iBAAiB,aAAa,CAAE,QAAO;AAE5C,QAAO;;;AAIT,SAAgB,2BACd,cACS;AACT,QAAO,sBAAsB,aAAa,KAAA;;;AAI5C,SAAgB,wBACd,cACS;CACT,MAAM,OAAO,sBAAsB,aAAa;AAChD,QAAO;;;;;;EAMN,CAAC,SAAU,QAAQ,GAA0B;;;AAIhD,SAAgB,oBACd,cACS;CACT,MAAM,OAAO,sBAAsB,aAAa;AAChD,QACE,SAAA,YAAsC,SAAA;;;AAK1C,SAAgB,oBACd,cACS;AAET,QADa,sBAAsB,aACxB,KAAA"}
|
|
@@ -5,7 +5,7 @@ import * as t from '@babel/types';
|
|
|
5
5
|
* string translation macro.
|
|
6
6
|
*
|
|
7
7
|
* The macro is valid when it is an unbound bare identifier, or when it is
|
|
8
|
-
* imported from gt-react
|
|
8
|
+
* imported from gt-react. This covers global `t`, but not explicit
|
|
9
9
|
* member access such as `globalThis.t` or `window.t`. Other bindings are left
|
|
10
10
|
* alone so local/i18next t tags do not get transformed or extracted.
|
|
11
11
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
3
|
-
require("../constants/gt/
|
|
3
|
+
const require_utils_constants_gt_helpers = require("../constants/gt/helpers.js");
|
|
4
4
|
let _babel_types = require("@babel/types");
|
|
5
5
|
_babel_types = require_runtime.__toESM(_babel_types);
|
|
6
6
|
//#region src/utils/parsing/isStringTranslationTaggedTemplate.ts
|
|
@@ -9,7 +9,7 @@ _babel_types = require_runtime.__toESM(_babel_types);
|
|
|
9
9
|
* string translation macro.
|
|
10
10
|
*
|
|
11
11
|
* The macro is valid when it is an unbound bare identifier, or when it is
|
|
12
|
-
* imported from gt-react
|
|
12
|
+
* imported from gt-react. This covers global `t`, but not explicit
|
|
13
13
|
* member access such as `globalThis.t` or `window.t`. Other bindings are left
|
|
14
14
|
* alone so local/i18next t tags do not get transformed or extracted.
|
|
15
15
|
*/
|
|
@@ -19,7 +19,7 @@ function isStringTranslationTaggedTemplate(path, symbol) {
|
|
|
19
19
|
if (!binding) return true;
|
|
20
20
|
if (!binding.path.isImportSpecifier()) return false;
|
|
21
21
|
const importDecl = binding.path.parentPath;
|
|
22
|
-
return (importDecl === null || importDecl === void 0 ? void 0 : importDecl.isImportDeclaration()) === true && importDecl.node.source.value
|
|
22
|
+
return (importDecl === null || importDecl === void 0 ? void 0 : importDecl.isImportDeclaration()) === true && require_utils_constants_gt_helpers.isGTReactImportSource(importDecl.node.source.value);
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
25
25
|
exports.isStringTranslationTaggedTemplate = isStringTranslationTaggedTemplate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isStringTranslationTaggedTemplate.js","names":["t"],"sources":["../../../src/utils/parsing/isStringTranslationTaggedTemplate.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport {
|
|
1
|
+
{"version":3,"file":"isStringTranslationTaggedTemplate.js","names":["t","isGTReactImportSource"],"sources":["../../../src/utils/parsing/isStringTranslationTaggedTemplate.ts"],"sourcesContent":["import type { NodePath } from '@babel/traverse';\nimport * as t from '@babel/types';\nimport { isGTReactImportSource } from '../constants/gt/helpers';\n\n/**\n * Checks whether a tagged template expression should be treated as the GT\n * string translation macro.\n *\n * The macro is valid when it is an unbound bare identifier, or when it is\n * imported from gt-react. This covers global `t`, but not explicit\n * member access such as `globalThis.t` or `window.t`. Other bindings are left\n * alone so local/i18next t tags do not get transformed or extracted.\n */\nexport function isStringTranslationTaggedTemplate(\n path: NodePath<t.TaggedTemplateExpression>,\n symbol: string\n): boolean {\n if (!t.isIdentifier(path.node.tag, { name: symbol })) {\n return false;\n }\n\n const binding = path.scope.getBinding(symbol);\n if (!binding) {\n return true;\n }\n\n if (!binding.path.isImportSpecifier()) {\n return false;\n }\n\n const importDecl = binding.path.parentPath;\n return (\n importDecl?.isImportDeclaration() === true &&\n isGTReactImportSource(importDecl.node.source.value)\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,SAAgB,kCACd,MACA,QACS;AACT,KAAI,CAACA,aAAE,aAAa,KAAK,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC,CAClD,QAAO;CAGT,MAAM,UAAU,KAAK,MAAM,WAAW,OAAO;AAC7C,KAAI,CAAC,QACH,QAAO;AAGT,KAAI,CAAC,QAAQ,KAAK,mBAAmB,CACnC,QAAO;CAGT,MAAM,aAAa,QAAQ,KAAK;AAChC,SAAA,eAAA,QAAA,eAAA,KAAA,IAAA,KAAA,IACE,WAAY,qBAAqB,MAAK,QACtCC,mCAAAA,sBAAsB,WAAW,KAAK,OAAO,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@generaltranslation/compiler",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.25-odysseus.1",
|
|
4
4
|
"description": "Universal plugin for compile-time optimization of GT translation components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"@babel/traverse": "^7.23.0",
|
|
25
25
|
"@babel/types": "^7.23.0",
|
|
26
26
|
"unplugin": "^2.3.10",
|
|
27
|
-
"@generaltranslation/format": "0.1.
|
|
28
|
-
"generaltranslation": "
|
|
27
|
+
"@generaltranslation/format": "0.1.2-odysseus.0",
|
|
28
|
+
"generaltranslation": "9.0.0-odysseus.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/babel__core": "^7.20.0",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from './processArrowFunctionExpression';
|
|
2
|
-
export * from './processAssignmentExpression';
|
|
3
|
-
export * from './processCatchClause';
|
|
4
|
-
export * from './processClassDeclaration';
|
|
5
|
-
export * from './processClassMethod';
|
|
6
|
-
export * from './processClassPrivateMethod';
|
|
7
|
-
export * from './processForInStatement';
|
|
8
|
-
export * from './processForOfStatement';
|
|
9
|
-
export * from './processFunctionDeclaration';
|
|
10
|
-
export * from './processFunctionExpression';
|
|
11
|
-
export * from './processImportDeclaration';
|
|
12
|
-
export * from './processObjectMethod';
|
|
13
|
-
export * from './processProgram';
|
|
14
|
-
export * from './processScopeChange';
|
|
15
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/processing/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
|
package/dist/processing/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_processing_processArrowFunctionExpression = require("./processArrowFunctionExpression.js");
|
|
3
|
-
const require_processing_processAssignmentExpression = require("./processAssignmentExpression.js");
|
|
4
|
-
const require_processing_processCatchClause = require("./processCatchClause.js");
|
|
5
|
-
const require_processing_processClassDeclaration = require("./processClassDeclaration.js");
|
|
6
|
-
const require_processing_processClassMethod = require("./processClassMethod.js");
|
|
7
|
-
const require_processing_processClassPrivateMethod = require("./processClassPrivateMethod.js");
|
|
8
|
-
const require_processing_processForInStatement = require("./processForInStatement.js");
|
|
9
|
-
const require_processing_processForOfStatement = require("./processForOfStatement.js");
|
|
10
|
-
const require_processing_processFunctionDeclaration = require("./processFunctionDeclaration.js");
|
|
11
|
-
const require_processing_processFunctionExpression = require("./processFunctionExpression.js");
|
|
12
|
-
const require_processing_processImportDeclaration = require("./processImportDeclaration.js");
|
|
13
|
-
const require_processing_processObjectMethod = require("./processObjectMethod.js");
|
|
14
|
-
const require_processing_processProgram = require("./processProgram.js");
|
|
15
|
-
const require_processing_processScopeChange = require("./processScopeChange.js");
|
|
16
|
-
exports.processArrowFunctionExpression = require_processing_processArrowFunctionExpression.processArrowFunctionExpression;
|
|
17
|
-
exports.processAssignmentExpression = require_processing_processAssignmentExpression.processAssignmentExpression;
|
|
18
|
-
exports.processCatchClause = require_processing_processCatchClause.processCatchClause;
|
|
19
|
-
exports.processClassDeclaration = require_processing_processClassDeclaration.processClassDeclaration;
|
|
20
|
-
exports.processClassMethod = require_processing_processClassMethod.processClassMethod;
|
|
21
|
-
exports.processClassPrivateMethod = require_processing_processClassPrivateMethod.processClassPrivateMethod;
|
|
22
|
-
exports.processForInStatement = require_processing_processForInStatement.processForInStatement;
|
|
23
|
-
exports.processForOfStatement = require_processing_processForOfStatement.processForOfStatement;
|
|
24
|
-
exports.processFunctionDeclaration = require_processing_processFunctionDeclaration.processFunctionDeclaration;
|
|
25
|
-
exports.processFunctionExpression = require_processing_processFunctionExpression.processFunctionExpression;
|
|
26
|
-
exports.processImportDeclaration = require_processing_processImportDeclaration.processImportDeclaration;
|
|
27
|
-
exports.processObjectMethod = require_processing_processObjectMethod.processObjectMethod;
|
|
28
|
-
exports.processProgram = require_processing_processProgram.processProgram;
|
|
29
|
-
exports.processScopeChange = require_processing_processScopeChange.processScopeChange;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/jsx-children/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_transform_jsx_children_constructJsxChildren = require("./constructJsxChildren.js");
|
|
3
|
-
exports.constructJsxChildren = require_transform_jsx_children_constructJsxChildren.constructJsxChildren;
|