babel-plugin-vasille 4.3.2 → 4.3.3

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/lib/expression.js CHANGED
@@ -42,6 +42,7 @@ exports.checkOrIgnoreAllExpressions = checkOrIgnoreAllExpressions;
42
42
  exports.checkAllExpressions = checkAllExpressions;
43
43
  exports.checkAllUnknown = checkAllUnknown;
44
44
  exports.checkOrIgnoreExpression = checkOrIgnoreExpression;
45
+ exports.assignToSetCall = assignToSetCall;
45
46
  exports.checkExpression = checkExpression;
46
47
  exports.checkStatements = checkStatements;
47
48
  exports.checkStatement = checkStatement;
@@ -215,6 +216,12 @@ function checkOrIgnoreExpression(path, search) {
215
216
  checkExpression(path, search);
216
217
  }
217
218
  }
219
+ function assignToSetCall(path, internal, left, right) {
220
+ const property = left.property;
221
+ path.replaceWith(internal.set(left.object, !left.computed && t.isIdentifier(property) ? t.stringLiteral(property.name) : property, path.node.operator === "="
222
+ ? right
223
+ : t.binaryExpression(path.node.operator.slice(0, path.node.operator.length - 1), internal.extract(left), right)));
224
+ }
218
225
  function checkExpression(nodePath, search) {
219
226
  const expr = nodePath.node;
220
227
  switch (expr && expr.type) {
@@ -278,7 +285,7 @@ function checkExpression(nodePath, search) {
278
285
  checkExpression(right, search);
279
286
  /* istanbul ignore else */
280
287
  if (!t.isPrivateName(property)) {
281
- path.replaceWith(search.external.set(left.node.object, !left.node.computed && t.isIdentifier(property) ? t.stringLiteral(property.name) : property, right.node));
288
+ assignToSetCall(path, search.external, left.node, right.node);
282
289
  }
283
290
  }
284
291
  else {
package/lib/mesh.js CHANGED
@@ -222,7 +222,7 @@ function meshExpression(nodePath, internal) {
222
222
  meshExpression(right, internal);
223
223
  /* istanbul ignore else */
224
224
  if (!t.isPrivateName(property)) {
225
- path.replaceWith(internal.set(left.node.object, !left.node.computed && t.isIdentifier(property) ? t.stringLiteral(property.name) : property, right.node));
225
+ (0, expression_js_1.assignToSetCall)(path, internal, left.node, right.node);
226
226
  }
227
227
  }
228
228
  }
@@ -146,6 +146,7 @@ function transformProgram(path, filename, opts) {
146
146
  set: "VasilleSet",
147
147
  Switch: "VasilleSwitch",
148
148
  safe: "VasilleSafe",
149
+ extract: "VasilleExtract",
149
150
  };
150
151
  function call(key, args) {
151
152
  used.add(key);
@@ -179,6 +180,7 @@ function transformProgram(path, filename, opts) {
179
180
  set: (obj, field, value) => call("set", [obj, field, value]),
180
181
  Switch: arg => call("Switch", [arg, internal_js_1.ctx]),
181
182
  safe: (arg) => call("safe", [arg]),
183
+ extract: (arg) => call("extract", [arg]),
182
184
  };
183
185
  function getCtx() {
184
186
  if (internal.isComposing)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-vasille",
3
- "version": "4.3.2",
3
+ "version": "4.3.3",
4
4
  "description": "Convert Vasille Meta Language code to pure JavaScript",
5
5
  "main": "lib/index.js",
6
6
  "type": "commonjs",