wuchale 0.16.0 → 0.16.2

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.
@@ -69,6 +69,7 @@ export declare class Transformer {
69
69
  visitBlockStatement: (node: Estree.BlockStatement) => Message[];
70
70
  visitReturnStatement: (node: Estree.ReturnStatement) => Message[];
71
71
  visitIfStatement: (node: Estree.IfStatement) => Message[];
72
+ visitClassDeclaration: (node: Estree.ClassDeclaration) => Message[];
72
73
  visitTemplateLiteral: (node: Estree.TemplateLiteral) => Message[];
73
74
  visitProgram: (node: Estree.Program) => Message[];
74
75
  visit: (node: Estree.AnyNode) => Message[];
@@ -345,6 +345,26 @@ export class Transformer {
345
345
  }
346
346
  return msgs;
347
347
  };
348
+ visitClassDeclaration = (node) => {
349
+ const msgs = [];
350
+ const prevDecl = this.declaring;
351
+ this.declaring = 'class';
352
+ for (const body of node.body.body) {
353
+ if (body.type === 'MethodDefinition') {
354
+ msgs.push(...this.visit(body.key));
355
+ const methodName = this.content.slice(body.key.start, body.key.end);
356
+ msgs.push(...this.visitFunctionBody(body.value, `${node.id.name}.${methodName}`));
357
+ }
358
+ else if (body.type === 'StaticBlock') {
359
+ const currentFuncDef = this.currentFuncDef;
360
+ this.currentFuncDef = `${node.id.name}.[static]`;
361
+ msgs.push(...body.body.map(this.visit).flat());
362
+ this.currentFuncDef = currentFuncDef; // restore
363
+ }
364
+ }
365
+ this.declaring = prevDecl; // restore
366
+ return msgs;
367
+ };
348
368
  visitTemplateLiteral = (node) => {
349
369
  let heurTxt = '';
350
370
  for (const quasi of node.quasis) {
@@ -5,7 +5,7 @@ export type HeuristicDetailsBase = {
5
5
  element?: string;
6
6
  attribute?: string;
7
7
  };
8
- export type ScriptDeclType = "variable" | "function" | "expression";
8
+ export type ScriptDeclType = "variable" | "function" | "class" | "expression";
9
9
  export type HeuristicDetails = HeuristicDetailsBase & {
10
10
  file: string;
11
11
  declaring?: ScriptDeclType;
package/dist/handler.d.ts CHANGED
@@ -54,6 +54,7 @@ export declare class AdapterHandler {
54
54
  granularStateByFile: Record<string, GranularState>;
55
55
  granularStateByID: Record<string, GranularState>;
56
56
  catalogPathsToLocales: Record<string, string>;
57
+ onBeforeWritePO: () => void;
57
58
  constructor(adapter: Adapter, key: string, config: ConfigPartial, mode: Mode, virtualPrefix: string, projectRoot: string, log: Logger);
58
59
  getLoaderPaths(): LoaderPath[];
59
60
  getLoaderPath(): Promise<{
package/dist/handler.js CHANGED
@@ -92,6 +92,7 @@ export class AdapterHandler {
92
92
  #mode;
93
93
  #geminiQueue = {};
94
94
  #log;
95
+ onBeforeWritePO;
95
96
  constructor(adapter, key, config, mode, virtualPrefix, projectRoot, log) {
96
97
  this.#adapter = adapter;
97
98
  this.key = key.toString();
@@ -451,6 +452,7 @@ export class AdapterHandler {
451
452
  fullHead[key] = val;
452
453
  }
453
454
  }
455
+ this.onBeforeWritePO?.();
454
456
  await saveCatalogToPO(poFile.catalog, this.#catalogsFname[loc], fullHead);
455
457
  if (this.#mode !== 'extract') { // save for the end
456
458
  await this.compile(loc);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuchale",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "description": "Protobuf-like i18n from plain code",
5
5
  "scripts": {
6
6
  "dev": "tsc --watch",
@@ -77,13 +77,13 @@
77
77
  "@sveltejs/acorn-typescript": "^1.0.5",
78
78
  "acorn": "^8.15.0",
79
79
  "chokidar": "^4.0.3",
80
- "magic-string": "^0.30.18",
80
+ "magic-string": "^0.30.19",
81
81
  "picomatch": "^4.0.3",
82
82
  "pofile": "^1.1.4",
83
83
  "tinyglobby": "^0.2.15"
84
84
  },
85
85
  "devDependencies": {
86
- "@types/node": "^24.3.1",
86
+ "@types/node": "^24.4.0",
87
87
  "@types/picomatch": "^4.0.1",
88
88
  "typescript": "^5.8.3"
89
89
  },