babel-plugin-mettle 0.3.2 → 0.5.0

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/License CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Vam
3
+ Copyright (c) 2025 maomincoding
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1 +1 @@
1
- module.exports=function({types:t}){return{name:"babel-plugin-mettle",visitor:{FunctionDeclaration(n){if(n.node.id&&/^[A-Z]/.test(n.node.id.name)){const e=n.node.body.body.find(n=>t.isReturnStatement(n));if(e&&e.argument){const n=t.functionExpression(null,[],t.blockStatement([t.returnStatement(e.argument)]));e.argument=n}}}}}};
1
+ module.exports=function({types:e}){function n(e){return/^[A-Z]/.test(e)}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(t){const{expression:i}=t.node;if(e.isIdentifier(i)){const o=i.name,r=t.scope.getBinding(o);r&&function(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)}(r)&&(function(t){const i=t.parentPath;if(e.isJSXAttribute(i.node)){var o;const t=null==(o=i.parentPath)||null==(o=o.parentPath)?void 0:o.node.openingElement;if(e.isJSXOpeningElement(t)&&e.isJSXIdentifier(t.name))return n(t.name.name)}return!1}(t)||(t.node.expression=e.memberExpression(e.identifier(o),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.3.2",
4
+ "version": "0.5.0",
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"