gt 2.14.9 → 2.14.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.14.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1195](https://github.com/generaltranslation/gt/pull/1195) [`2090de3`](https://github.com/generaltranslation/gt/commit/2090de3613b9684fd43adc3b83f677bc33c1d9a6) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - refactor: standardize naming convention for "autoderive"
8
+
3
9
  ## 2.14.9
4
10
 
5
11
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  import { BaseParsingFlags, GTParsingFlags } from '../types/parsing.js';
2
2
  /**
3
3
  * Default parsing flags for GT files
4
- * @property {boolean} autoDerive - Whether to enable auto-derive for the t() function. (true -> 'AUTO', false -> 'DISABLED' {@link ParsingConfig['autoDeriveMethod']})
4
+ * @property {boolean} autoderive - Whether to enable autoderive for the t() function. (true -> 'AUTO', false -> 'DISABLED' {@link ParsingConfig['autoderiveMethod']})
5
5
  * @property {boolean} includeSourceCodeContext - Include surrounding source code lines as context for translations.
6
6
  */
7
7
  export declare const GT_PARSING_FLAGS_DEFAULT: GTParsingFlags;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Default parsing flags for GT files
3
- * @property {boolean} autoDerive - Whether to enable auto-derive for the t() function. (true -> 'AUTO', false -> 'DISABLED' {@link ParsingConfig['autoDeriveMethod']})
3
+ * @property {boolean} autoderive - Whether to enable autoderive for the t() function. (true -> 'AUTO', false -> 'DISABLED' {@link ParsingConfig['autoderiveMethod']})
4
4
  * @property {boolean} includeSourceCodeContext - Include surrounding source code lines as context for translations.
5
5
  */
6
6
  export const GT_PARSING_FLAGS_DEFAULT = {
7
- autoDerive: false,
7
+ autoderive: false,
8
8
  includeSourceCodeContext: false,
9
9
  enableAutoJsxInjection: false,
10
10
  };
@@ -25,7 +25,7 @@ export declare const warnRecursiveFunctionCallSync: (file: string, functionName:
25
25
  export declare const warnDeriveFunctionNotWrappedSync: (file: string, functionName: string, location?: string) => string;
26
26
  export declare const warnDeriveNonConstVariableSync: (file: string, varName: string, kind: string, location?: string) => string;
27
27
  export declare const warnDeriveFunctionNoResultsSync: (file: string, functionName: string, location?: string) => string;
28
- export declare const warnAutoDeriveNoResultsSync: (file: string, expression: string, location?: string) => string;
28
+ export declare const warnAutoderiveNoResultsSync: (file: string, expression: string, location?: string) => string;
29
29
  export declare const warnDeriveUnresolvableValueSync: (file: string, key: string, location?: string) => string;
30
30
  export declare const warnDeriveCircularSpreadSync: (file: string, varName: string, location?: string) => string;
31
31
  export declare const warnDeriveDestructuringSync: (file: string, varName: string, location?: string) => string;
@@ -36,7 +36,7 @@ export const warnRecursiveFunctionCallSync = (file, functionName, location) => w
36
36
  export const warnDeriveFunctionNotWrappedSync = (file, functionName, location) => withLocation(file, withDeriveFunctionError(`Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. This call is not wrapped in derive() (formerly declareStatic()). Ensure the function is properly wrapped with derive() and does not have circular import dependencies.`), location);
37
37
  export const warnDeriveNonConstVariableSync = (file, varName, kind, location) => withLocation(file, withDeriveFunctionError(`Variable ${colorizeFunctionName(varName)} is declared with '${kind}' but only 'const' declarations can be resolved statically. Change it to 'const'.`), location);
38
38
  export const warnDeriveFunctionNoResultsSync = (file, functionName, location) => withLocation(file, withDeriveFunctionError(`Could not resolve ${colorizeFunctionName(formatCodeClamp(functionName))}. derive() (formerly declareStatic()) can only receive function invocations and cannot use undefined values or looped calls to construct its result.`), location);
39
- export const warnAutoDeriveNoResultsSync = (file, expression, location) => withLocation(file, `Auto-derive could not resolve ${colorizeFunctionName(formatCodeClamp(expression))}. Only function calls with statically determinable return values can be used directly in t(). Consider wrapping with derive() for explicit derivation, or use an interpolation variable instead.`, location);
39
+ export const warnAutoderiveNoResultsSync = (file, expression, location) => withLocation(file, `Autoderive could not resolve ${colorizeFunctionName(formatCodeClamp(expression))}. Only function calls with statically determinable return values can be used directly in t(). Consider wrapping with derive() for explicit derivation, or use an interpolation variable instead.`, location);
40
40
  export const warnDeriveUnresolvableValueSync = (file, key, location) => withLocation(file, withDeriveFunctionError(`Object property ${colorizeFunctionName(formatCodeClamp(key))} could not be resolved to a static string value. Only string literals, template literals, conditionals, and function calls returning strings are supported.`), location);
41
41
  export const warnDeriveCircularSpreadSync = (file, varName, location) => withLocation(file, withDeriveFunctionError(`Circular spread detected involving ${colorizeFunctionName(varName)}. Spread references that form a cycle cannot be resolved statically.`), location);
42
42
  export const warnDeriveDestructuringSync = (file, varName, location) => withLocation(file, withDeriveFunctionError(`Variable ${colorizeFunctionName(varName)} uses destructuring syntax, which is not yet supported in derive(). Assign the value to a const variable directly instead.`), location);
@@ -99,13 +99,20 @@ export function resolveFiles(files, locale, locales, cwd, compositePatterns) {
99
99
  publishPaths,
100
100
  unpublishPaths,
101
101
  parsingFlags,
102
- gtJson: {
103
- publish: files.gt?.publish,
104
- parsingFlags: {
105
- ...GT_PARSING_FLAGS_DEFAULT,
106
- ...(files.gt?.parsingFlags || {}),
107
- },
108
- },
102
+ gtJson: (() => {
103
+ const rawGtFlags = (files.gt?.parsingFlags || {});
104
+ if ('autoDerive' in rawGtFlags && !('autoderive' in rawGtFlags)) {
105
+ rawGtFlags.autoderive = rawGtFlags.autoDerive;
106
+ delete rawGtFlags.autoDerive;
107
+ }
108
+ return {
109
+ publish: files.gt?.publish,
110
+ parsingFlags: {
111
+ ...GT_PARSING_FLAGS_DEFAULT,
112
+ ...rawGtFlags,
113
+ },
114
+ };
115
+ })(),
109
116
  };
110
117
  }
111
118
  // Helper function to expand glob patterns
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "2.14.9";
1
+ export declare const PACKAGE_VERSION = "2.14.10";
@@ -1,2 +1,2 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
- export const PACKAGE_VERSION = '2.14.9';
2
+ export const PACKAGE_VERSION = '2.14.10';
@@ -291,9 +291,9 @@ export function parseStrings(importName, originalName, path, config, output) {
291
291
  if (!config.ignoreGlobalTaggedTemplates) {
292
292
  processTaggedTemplateCall(path, {
293
293
  ...config,
294
- autoDeriveMethod: config.autoDeriveMethod === 'AUTO'
294
+ autoderiveMethod: config.autoderiveMethod === 'AUTO'
295
295
  ? 'DISABLED'
296
- : config.autoDeriveMethod,
296
+ : config.autoderiveMethod,
297
297
  }, output);
298
298
  }
299
299
  return;
@@ -315,15 +315,15 @@ export function parseStrings(importName, originalName, path, config, output) {
315
315
  ignoreTaggedTemplates: false,
316
316
  ignoreGlobalTaggedTemplates: false,
317
317
  // User configurable, otherwise default to AUTO
318
- autoDeriveMethod: config.autoDeriveMethod === 'AUTO'
318
+ autoderiveMethod: config.autoderiveMethod === 'AUTO'
319
319
  ? 'DISABLED'
320
- : config.autoDeriveMethod,
320
+ : config.autoderiveMethod,
321
321
  };
322
322
  // Check if this is a direct call to msg('string') or t('string')
323
323
  if (refPath.parent.type === 'CallExpression' &&
324
324
  refPath.parent.callee === refPath.node) {
325
325
  /**
326
- * CASE: Auto-derive t() and msg() function
326
+ * CASE: Autoderive t() and msg() function
327
327
  * The t() function, will treat variable content as if it was marked for derivation
328
328
  * without explicit calls to derive().
329
329
  *
@@ -336,10 +336,10 @@ export function parseStrings(importName, originalName, path, config, output) {
336
336
  * );
337
337
  * // "Hello, John! My name is {interpolatedValue}"
338
338
  */
339
- processTranslationCall(refPath, config.autoDeriveMethod === 'AUTO'
339
+ processTranslationCall(refPath, config.autoderiveMethod === 'AUTO'
340
340
  ? {
341
341
  ...stringRegistrationConfig,
342
- autoDeriveMethod: 'ENABLED',
342
+ autoderiveMethod: 'ENABLED',
343
343
  }
344
344
  : stringRegistrationConfig, output);
345
345
  }
@@ -386,11 +386,11 @@ export function parseStrings(importName, originalName, path, config, output) {
386
386
  ignoreTaggedTemplates: false,
387
387
  ignoreGlobalTaggedTemplates: false,
388
388
  // User configurable, otherwise default to DISABLED
389
- autoDeriveMethod: config.autoDeriveMethod === 'AUTO'
389
+ autoderiveMethod: config.autoderiveMethod === 'AUTO'
390
390
  ? isInlineGT
391
391
  ? 'ENABLED'
392
392
  : 'DISABLED'
393
- : config.autoDeriveMethod,
393
+ : config.autoderiveMethod,
394
394
  };
395
395
  const effectiveParent = parentPath?.node.type === 'AwaitExpression'
396
396
  ? parentPath.parentPath
@@ -4,7 +4,7 @@ import { buildImportMap } from '../../buildImportMap.js';
4
4
  import { resolveImportPath } from '../../resolveImportPath.js';
5
5
  import { parse } from '@babel/parser';
6
6
  import fs from 'node:fs';
7
- import { warnFunctionNotFoundSync, warnDeriveFunctionNoResultsSync, warnDeriveFunctionNotWrappedSync, warnAutoDeriveNoResultsSync, } from '../../../../../console/index.js';
7
+ import { warnFunctionNotFoundSync, warnDeriveFunctionNoResultsSync, warnDeriveFunctionNotWrappedSync, warnAutoderiveNoResultsSync, } from '../../../../../console/index.js';
8
8
  import traverseModule from '@babel/traverse';
9
9
  import generateModule from '@babel/generator';
10
10
  import { isDeriveCall } from './isDeriveCall.js';
@@ -220,9 +220,9 @@ export function handleDerivation({ expr, tPath, file, parsingOptions, errors, wa
220
220
  nodes: variants.map((v) => ({ type: 'text', text: v })),
221
221
  };
222
222
  }
223
- // Auto-derive had no resolvable results
223
+ // Autoderive had no resolvable results
224
224
  const code = generate(expr).code;
225
- errors.push(warnAutoDeriveNoResultsSync(file, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
225
+ errors.push(warnAutoderiveNoResultsSync(file, code, `${expr.loc?.start?.line}:${expr.loc?.start?.column}`));
226
226
  return null;
227
227
  }
228
228
  // Not a derivable expression
@@ -31,7 +31,7 @@ export function deriveExpression({ tPath, expr, metadata, config, output, index,
31
31
  runtimeInterpolationState: enableRuntimeInterpolation
32
32
  ? { index: 0 }
33
33
  : undefined,
34
- skipDeriveInvocation: config.autoDeriveMethod === 'ENABLED',
34
+ skipDeriveInvocation: config.autoderiveMethod === 'ENABLED',
35
35
  });
36
36
  // Nothing returned, push error
37
37
  if (!stringNode) {
@@ -37,11 +37,11 @@ export type ParsingConfig = {
37
37
  ignoreGlobalTaggedTemplates: boolean;
38
38
  /**
39
39
  * Skip requirement for a derive() invocation to trigger derivation
40
- * - ENABLED: Always auto-derive
41
- * - DISABLED: Never auto-derive
42
- * - AUTO: Only auto-derive for the t() function
40
+ * - ENABLED: Always autoderive
41
+ * - DISABLED: Never autoderive
42
+ * - AUTO: Only autoderive for the t() function
43
43
  */
44
- autoDeriveMethod: 'ENABLED' | 'DISABLED' | 'AUTO';
44
+ autoderiveMethod: 'ENABLED' | 'DISABLED' | 'AUTO';
45
45
  };
46
46
  /**
47
47
  * Mutable state for tracking parsing progress.
@@ -47,7 +47,7 @@ export async function createInlineUpdates(pkg, validate, filePatterns, parsingFl
47
47
  ignoreTaggedTemplates: false,
48
48
  ignoreGlobalTaggedTemplates: false,
49
49
  // User configurable, otherwise default to AUTO
50
- autoDeriveMethod: parsingFlags.autoDerive ? 'AUTO' : 'DISABLED',
50
+ autoderiveMethod: parsingFlags.autoderive ? 'AUTO' : 'DISABLED',
51
51
  }, { updates, errors, warnings });
52
52
  }
53
53
  // Parse <T> components — PASS 1: user-written T
@@ -30,12 +30,12 @@ export type BaseParsingFlags = Record<string, unknown>;
30
30
  * parsing features depending on the function being parsed. Parsing flags is for users to override
31
31
  * some of these defaults or enable/disable other features.
32
32
  *
33
- * @property {boolean} autoDerive - Whether to enable auto-derive for the t() function. (true -> 'AUTO', false -> 'DISABLED' {@link ParsingConfig['autoDeriveMethod']})
33
+ * @property {boolean} autoderive - Whether to enable autoderive for the t() function. (true -> 'AUTO', false -> 'DISABLED' {@link ParsingConfig['autoderiveMethod']})
34
34
  * @property {boolean} includeSourceCodeContext - Include surrounding source code lines as context for translations.
35
35
  * @property {boolean} enableAutoJsxInjection - Whether to enable auto-jsx injection for the internal <_T> and <_Var> components.
36
36
  */
37
37
  export type GTParsingFlags = BaseParsingFlags & {
38
- autoDerive: boolean;
38
+ autoderive: boolean;
39
39
  includeSourceCodeContext: boolean;
40
40
  enableAutoJsxInjection: boolean;
41
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt",
3
- "version": "2.14.9",
3
+ "version": "2.14.10",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [