wuchale 0.14.4 → 0.14.6

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.
@@ -31,6 +31,8 @@ export declare class Transformer {
31
31
  }) => Message[];
32
32
  visitArrayExpression: (node: Estree.ArrayExpression) => Message[];
33
33
  visitObjectExpression: (node: Estree.ObjectExpression) => Message[];
34
+ visitObjectPattern: (node: Estree.ObjectPattern) => Message[];
35
+ visitRestElement: (node: Estree.RestElement) => Message[];
34
36
  visitProperty: (node: Estree.Property) => Message[];
35
37
  visitSpreadElement: (node: Estree.SpreadElement) => Message[];
36
38
  visitMemberExpression: (node: Estree.MemberExpression) => Message[];
@@ -43,6 +45,7 @@ export declare class Transformer {
43
45
  visitLogicalExpression: (node: Estree.LogicalExpression) => Message[];
44
46
  visitAwaitExpression: (node: Estree.AwaitExpression) => Message[];
45
47
  visitAssignmentExpression: (node: Estree.BinaryExpression) => Message[];
48
+ visitAssignmentPattern: (node: Estree.AssignmentPattern) => Message[];
46
49
  visitExpressionStatement: (node: Estree.ExpressionStatement) => Message[];
47
50
  visitForOfStatement: (node: Estree.ForOfStatement) => Message[];
48
51
  visitForInStatement: (node: Estree.ForInStatement) => Message[];
@@ -110,10 +110,19 @@ export class Transformer {
110
110
  };
111
111
  visitArrayExpression = (node) => node.elements.map(this.visit).flat();
112
112
  visitObjectExpression = (node) => node.properties.map(this.visit).flat();
113
- visitProperty = (node) => [
114
- ...this.visit(node.key),
115
- ...this.visit(node.value),
116
- ];
113
+ visitObjectPattern = (node) => node.properties.map(this.visit).flat();
114
+ visitRestElement = (node) => this.visit(node.argument);
115
+ visitProperty = (node) => {
116
+ const msgs = this.visit(node.key);
117
+ if (msgs.length && node.key.type === 'Literal' && typeof node.key.value === 'string' && !node.computed) {
118
+ // @ts-expect-error
119
+ this.mstr.appendRight(node.key.start, '[');
120
+ // @ts-expect-error
121
+ this.mstr.appendLeft(node.key.end, ']');
122
+ }
123
+ msgs.push(...this.visit(node.value));
124
+ return msgs;
125
+ };
117
126
  visitSpreadElement = (node) => this.visit(node.argument);
118
127
  visitMemberExpression = (node) => [
119
128
  ...this.visit(node.object),
@@ -170,6 +179,10 @@ export class Transformer {
170
179
  ];
171
180
  visitAwaitExpression = (node) => this.visit(node.argument);
172
181
  visitAssignmentExpression = this.visitBinaryExpression;
182
+ visitAssignmentPattern = (node) => [
183
+ ...this.visit(node.left),
184
+ ...this.visit(node.right),
185
+ ];
173
186
  visitExpressionStatement = (node) => this.visit(node.expression);
174
187
  visitForOfStatement = (node) => [
175
188
  ...this.visit(node.left),
@@ -226,6 +239,7 @@ export class Transformer {
226
239
  if (!dec.init) {
227
240
  continue;
228
241
  }
242
+ msgs.push(...this.visit(dec.id));
229
243
  // store the name of the function after =
230
244
  if (atTopLevelDefn) {
231
245
  if (dec.init.type === 'ArrowFunctionExpression') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuchale",
3
- "version": "0.14.4",
3
+ "version": "0.14.6",
4
4
  "description": "Protobuf-like i18n from plain code",
5
5
  "scripts": {
6
6
  "dev": "tsc --watch",
@@ -77,7 +77,7 @@
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.17",
80
+ "magic-string": "^0.30.18",
81
81
  "picomatch": "^4.0.3",
82
82
  "pofile": "^1.1.4",
83
83
  "tinyglobby": "^0.2.14"