babel-plugin-mettle 0.7.0 → 0.7.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.
@@ -1 +1 @@
1
- module.exports=function({types:e}){function n(e){return/^[A-Z]/.test(e)}function t(n){if(!n)return!1;const{init:t}=n.path.node;return e.isCallExpression(t)&&e.isIdentifier(t.callee)&&("signal"===t.callee.name||"computed"===t.callee.name)}return{name:"babel-plugin-mettle",visitor:{FunctionDeclaration(t){if(t.node.id&&n(t.node.id.name)){const n=t.node.body.body.find(n=>e.isReturnStatement(n));if(n&&n.argument){const t=e.functionExpression(null,[],e.blockStatement([e.returnStatement(n.argument)]));n.argument=t}}},JSXExpressionContainer(i){const{expression:s}=i.node;if(e.isIdentifier(s)){const o=s.name,r=i.scope.getBinding(o);(r&&t(r)||o.endsWith("$"))&&(function(t){const i=t.parentPath;if(e.isJSXAttribute(i.node)){var s;const t=null==(s=i.parentPath)||null==(s=s.parentPath)?void 0:s.node.openingElement;if(e.isJSXOpeningElement(t)&&e.isJSXIdentifier(t.name))return n(t.name.name)}return!1}(i)||(i.node.expression=e.memberExpression(e.identifier(o),e.identifier("value"))))}if(e.isCallExpression(s)&&e.isMemberExpression(s.callee)&&e.isIdentifier(s.callee.object)){const n=s.callee.object.name,o=i.scope.getBinding(n);(o&&t(o)||n.endsWith("$"))&&(s.callee.object=e.memberExpression(s.callee.object,e.identifier("value")))}if(e.isConditionalExpression(s)&&e.isIdentifier(s.test)){const n=s.test.name,o=i.scope.getBinding(n);(o&&t(o)||n.endsWith("$"))&&(s.test=e.memberExpression(s.test,e.identifier("value")))}}}}};
1
+ module.exports=function({types:e}){function n(e){return/^[A-Z]/.test(e)}function i(n){if(!n)return!1;const{init:i}=n.path.node;return e.isCallExpression(i)&&e.isIdentifier(i.callee)&&("signal"===i.callee.name||"computed"===i.callee.name)}function t(n,s){if(e.isMemberExpression(n)){const r=t(n.object,s);if(r!==n.object)return e.memberExpression(r,n.property);if(e.isIdentifier(n.object)){const t=n.object.name,r=s.scope.getBinding(t);if(r&&i(r)||t.endsWith("$"))return e.memberExpression(e.memberExpression(n.object,e.identifier("value")),n.property)}}return n}return{name:"babel-plugin-mettle",visitor:{FunctionDeclaration(i){if(i.node.id&&n(i.node.id.name)){const n=i.node.body.body.find(n=>e.isReturnStatement(n));if(n&&n.argument){const i=e.functionExpression(null,[],e.blockStatement([e.returnStatement(n.argument)]));n.argument=i}}},JSXExpressionContainer(s){const{expression:r}=s.node;if(e.isIdentifier(r)){const t=r.name,o=s.scope.getBinding(t);(o&&i(o)||t.endsWith("$"))&&(function(i){const t=i.parentPath;if(e.isJSXAttribute(t.node)){var s;const i=null==(s=t.parentPath)||null==(s=s.parentPath)?void 0:s.node.openingElement;if(e.isJSXOpeningElement(i)&&e.isJSXIdentifier(i.name))return n(i.name.name)}return!1}(s)||(s.node.expression=e.memberExpression(e.identifier(t),e.identifier("value"))))}if(e.isMemberExpression(r)){const e=t(r,s);e!==r&&(s.node.expression=e)}if(e.isCallExpression(r)&&e.isMemberExpression(r.callee)&&e.isIdentifier(r.callee.object)){const n=r.callee.object.name,t=s.scope.getBinding(n);(t&&i(t)||n.endsWith("$"))&&(r.callee.object=e.memberExpression(r.callee.object,e.identifier("value")))}if(e.isConditionalExpression(r)&&e.isIdentifier(r.test)){const n=r.test.name,t=s.scope.getBinding(n);(t&&i(t)||n.endsWith("$"))&&(r.test=e.memberExpression(r.test,e.identifier("value")))}}}}};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "babel-plugin-mettle",
3
3
  "description": "A babel plugin for mettle.js",
4
- "version": "0.7.0",
4
+ "version": "0.7.1",
5
5
  "main": "dist/babel-plugin-mettle.js",
6
6
  "scripts": {
7
7
  "build": "microbundle src/index.js -f cjs --target node --compress --no-sourcemap"