Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-sugar-v-bind-sync

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-sugar-v-bind-sync - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

.github/workflows/ci.yml

2

lib/index.js

@@ -1,2 +0,2 @@

"use strict";var e=require("@babel/plugin-syntax-jsx"),t=require("camelcase");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),i=r(t);const s=["on"],o=/(.*)\_sync/;module.exports=e=>{const t=e.types;function r(e,r=[]){const n=e.get("name");let i,a;if(a=t.isJSXNamespacedName(n)?`${n.get("namespace.name").node}:${n.get("name.name").node}`:n.get("name").node,s.includes(a)&&t.isJSXExpressionContainer(e.get("value")))return t.JSXSpreadAttribute(t.objectExpression([t.objectProperty(t.stringLiteral(a),e.get("value").node.expression)]));i=s.find((e=>a.startsWith(e))),a=a.replace(new RegExp(`^${i}-?`),""),a=a[0].toLowerCase()+a.substr(1);const u=e.get("value");if(s.includes(i)&&!t.isJSXExpressionContainer(u))throw new Error(`getAttribute (attribute value): should be an JSXExpressionContainer but got ${u.type}`);const p=u.get("expression").node,c=a.match(o);if(null!=c){if(!t.isMemberExpression(p)){const t=e.get("parent").get("name.name").node;throw new Error(`getAttribute (attribute value): You should use MemberExpression with sync modifier, prop [${prop}] on node [${t}]`)}return{prop:c[1],value:p}}i&&(!function(e,r,n){if(e[r]){let i=!1;t.isObjectProperty(n)&&"on"===r&&(e[r].properties.forEach((e=>{t.isObjectProperty(e)&&e.key.value===n.key.value&&(t.isArrayExpression(e.value)?e.value.elements.push(n.value):e.value=t.arrayExpression([e.value,n.value]),i=!0)})),i||e[r].properties.push(n))}else e[r]=t.objectExpression([n])}(r,i,t.objectProperty(t.stringLiteral(a),p)),e.remove())}function a(e){const n={};return e.forEach((e=>{r(e,n)})),!!Object.entries(n).length&&function(e){return t.objectExpression(Object.entries(e).map((([e,r])=>t.objectProperty(t.stringLiteral(e),r))))}(n)}return{inherits:n.default,visitor:{JSXAttribute(e){const n=r(e);if(n&&!t.isJSXSpreadAttribute(n)){const{prop:r,value:a}=n;e.replaceWith(t.jSXAttribute(t.jSXIdentifier(r),t.jSXExpressionContainer(a))),e.parent.attributes.push(function(e,r){return t.jSXAttribute(t.jSXIdentifier(e),t.jSXExpressionContainer(r))}(`onUpdate:${i.default(r)}`,(s=[(o=a,t.ExpressionStatement(t.AssignmentExpression("=",o,t.Identifier("$$val"))))],t.ArrowFunctionExpression([t.Identifier("$$val")],t.BlockStatement(s)))))}var s,o},JSXOpeningElement:{exit(e){const r=a(e.get("attributes"));r&&e.node.attributes.push(t.JSXSpreadAttribute(r))}}}}};
"use strict";var e=require("@babel/plugin-syntax-jsx"),t=require("camelcase");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),i=r(t);const s=["on"],o=/(.*)\_sync/;module.exports=e=>{const t=e.types;function r(e,r=[]){const n=e.get("name");let i,a;if(a=t.isJSXNamespacedName(n)?`${n.get("namespace.name").node}:${n.get("name.name").node}`:n.get("name").node,s.includes(a)&&t.isJSXExpressionContainer(e.get("value")))return t.JSXSpreadAttribute(t.objectExpression([t.objectProperty(t.stringLiteral(a),e.get("value").node.expression)]));i=s.find((e=>a.startsWith(e))),a=a.replace(new RegExp(`^${i}-?`),""),a=a[0].toLowerCase()+a.substr(1);const u=e.get("value");if(s.includes(i)&&!t.isJSXExpressionContainer(u))throw new Error(`getAttribute (attribute value): should be an JSXExpressionContainer but got ${u.type}`);let p;if(u.node)if(t.isStringLiteral(u.node))p=u.node;else{if(!t.isJSXExpressionContainer(u))throw new Error(`getAttributes (attribute value): ${u.type} is not supported`);p=u.get("expression").node}else p=t.booleanLiteral(!0);const l=a.match(o);if(null!=l){if(!t.isMemberExpression(p)){const t=e.get("parent").get("name.name").node;throw new Error(`getAttribute (attribute value): You should use MemberExpression with sync modifier, prop [${prop}] on node [${t}]`)}return{prop:l[1],value:p}}i&&(!function(e,r,n){if(e[r]){let i=!1;t.isObjectProperty(n)&&"on"===r&&(e[r].properties.forEach((e=>{t.isObjectProperty(e)&&e.key.value===n.key.value&&(t.isArrayExpression(e.value)?e.value.elements.push(n.value):e.value=t.arrayExpression([e.value,n.value]),i=!0)})),i||e[r].properties.push(n))}else e[r]=t.objectExpression([n])}(r,i,t.objectProperty(t.stringLiteral(a),p)),e.remove())}function a(e){const n={};return e.forEach((e=>{r(e,n)})),!!Object.entries(n).length&&function(e){return t.objectExpression(Object.entries(e).map((([e,r])=>t.objectProperty(t.stringLiteral(e),r))))}(n)}return{inherits:n.default,visitor:{JSXAttribute(e){const n=r(e);if(n&&!t.isJSXSpreadAttribute(n)){const{prop:r,value:a}=n;e.replaceWith(t.jSXAttribute(t.jSXIdentifier(r),t.jSXExpressionContainer(a))),e.parent.attributes.push(function(e,r){return t.jSXAttribute(t.jSXIdentifier(e),t.jSXExpressionContainer(r))}(`onUpdate:${i.default(r)}`,(s=[(o=a,t.ExpressionStatement(t.AssignmentExpression("=",o,t.Identifier("$$val"))))],t.ArrowFunctionExpression([t.Identifier("$$val")],t.BlockStatement(s)))))}var s,o},JSXOpeningElement:{exit(e){const r=a(e.get("attributes"));r&&e.node.attributes.push(t.JSXSpreadAttribute(r))}}}}};
//# sourceMappingURL=index.js.map
{
"name": "babel-sugar-v-bind-sync",
"version": "0.2.2",
"version": "0.2.3",
"description": "Babel syntactic sugar for v-bind sync modifier support in Vue JSX",

@@ -15,3 +15,4 @@ "keywords": [

"build": "rollup -c rollup.config.js",
"prepublishOnly": "yarn build"
"test": "vitest",
"prepublishOnly": "pnpm run build"
},

@@ -23,12 +24,13 @@ "dependencies": {

"devDependencies": {
"@babel/core": "7.17.7",
"@babel/core": "7.17.9",
"@babel/preset-env": "7.16.11",
"@rollup/plugin-babel": "5.3.1",
"@vue/babel-plugin-transform-vue-jsx": "1.2.1",
"parcel": "2.3.2",
"parcel": "2.4.1",
"prismjs": "1.27.0",
"regenerator-runtime": "0.13.9",
"rollup": "2.70.1",
"rollup-plugin-terser": "7.0.2"
"rollup": "2.70.2",
"rollup-plugin-terser": "7.0.2",
"vitest": "0.9.3"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc