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

@vue/babel-sugar-composition-api-render-instance

Package Overview
Dependencies
Maintainers
17
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vue/babel-sugar-composition-api-render-instance - npm Package Compare versions

Comparing version 1.2.1 to 1.2.4

2

dist/plugin.js

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

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var syntaxJsx=_interopDefault(require("@babel/plugin-syntax-jsx"));const autoImportGetCurrentInstance=(e,t)=>{const n=t.get("body").filter(e=>e.isImportDeclaration()).map(e=>e.node);const i=n.filter(e=>"@vue/composition-api"===e.source.value);const o=i.some(t=>t.specifiers.some(t=>e.isImportSpecifier(t)&&"getCurrentInstance"===t.local.name));if(!o){const n=e.importSpecifier(e.identifier("getCurrentInstance"),e.identifier("getCurrentInstance"));i.length>0?i[0].specifiers.push(n):t.unshiftContainer("body",e.importDeclaration([n],e.stringLiteral("@vue/composition-api")))}};var index=({types:t})=>({inherits:syntaxJsx,visitor:{Program(e){e.traverse({"ObjectMethod|ObjectProperty"(n){"setup"===n.node.key.name&&n.traverse({JSXAttribute(n){const i=n.get("name");["v-on","on-input","on-change","model"].includes(i.node.name)&&n.traverse({MemberExpression(n){const i=n.get("object"),o=n.get("property");t.isThisExpression(i)&&t.isIdentifier(o)&&["$","_"].includes(o.node.name[0])&&(autoImportGetCurrentInstance(t,e),i.replaceWith(t.callExpression(t.identifier("getCurrentInstance"),[])))}})}})}})}}});module.exports=index;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var syntaxJsx=_interopDefault(require("@babel/plugin-syntax-jsx"));const autoImportGetCurrentInstance=(e,t)=>{const n=t.get("body").filter(e=>e.isImportDeclaration()).map(e=>e.node);const i=n.filter(e=>"@vue/composition-api"===e.source.value);const o=i.some(t=>t.specifiers.some(t=>e.isImportSpecifier(t)&&"getCurrentInstance"===t.local.name));if(!o){const n=e.importSpecifier(e.identifier("getCurrentInstance"),e.identifier("getCurrentInstance"));i.length>0?i[0].specifiers.push(n):t.unshiftContainer("body",e.importDeclaration([n],e.stringLiteral("@vue/composition-api")))}},injectInstanceId="__currentInstance";var index=({types:t})=>({inherits:syntaxJsx,visitor:{Program(e){e.traverse({"ObjectMethod|ObjectProperty"(n){if("setup"===n.node.key.name){let i=!1;n.traverse({JSXAttribute(o){const r=o.get("name");["v-on","on-input","on-change","model"].includes(r.node.name)&&o.traverse({MemberExpression(o){const r=o.get("object"),s=o.get("property");t.isThisExpression(r)&&t.isIdentifier(s)&&["$","_"].includes(s.node.name[0])&&(autoImportGetCurrentInstance(t,e),i||(n.node.value.body.body.unshift(t.variableDeclaration("const",[t.variableDeclarator(t.identifier(injectInstanceId),t.callExpression(t.identifier("getCurrentInstance"),[]))])),i=!0),r.replaceWith(t.identifier(injectInstanceId)))}})}})}}})}}});module.exports=index;
{
"name": "@vue/babel-sugar-composition-api-render-instance",
"version": "1.2.1",
"version": "1.2.4",
"description": "Babel syntactic sugar for replaceing `this` with `getCurrentInstance()` in Vue JSX with @vue/composition-api",

@@ -45,3 +45,3 @@ "main": "dist/plugin.js",

},
"gitHead": "ebe50c0f20b991fca6588cab93965629ffbcf64f"
"gitHead": "3a12ae2c13de6fdb47dce4394d26c74e048a25b6"
}

@@ -40,3 +40,5 @@ ## @vue/babel-sugar-composition-api-render-instance

defineComponent({
setup: () => <MyComponent vModel={a.b} />
setup() {
return () => <MyComponent vModel={a.b} />
}
})

@@ -49,8 +51,10 @@ ```

defineComponent({
setup: () => <MyComponent model={{
value: a.b,
callback: $$v => {
this.$set(a, "b", $$v);
}
}} />;
setup() {
return () => <MyComponent model={{
value: a.b,
callback: $$v => {
this.$set(a, "b", $$v);
}
}} />
}
})

@@ -65,9 +69,13 @@ ```

defineComponent({
setup: () => <MyComponent model={{
value: a.b,
callback: $$v => {
getCurrentInstance().$set(a, "b", $$v);
}
}} />;
setup() {
const __currentInstance = getCurrentInstance();
return () => <MyComponent model={{
value: a.b,
callback: $$v => {
__currentInstance.$set(a, "b", $$v);
}
}} />
}
})
```
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