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

babel-plugin-react-originjs

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-react-originjs - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

36

lib/index.js

@@ -23,3 +23,7 @@ 'use strict';

}
if (types.isImportDefaultSpecifier(spec)) {
methodName = value + '/' + spec.local.name;
}
});
methodName = methodName || 'noname';
}

@@ -38,8 +42,30 @@ },

if (!types.isIdentifier(node.callee)) {
if (object && object.name.toLowerCase() === 'reactdom') {
var fn = 'function(render, name, argus){ render.apply(this, argus); }';
var argus = t.arrayExpression(node.arguments);
var icatReact = "window['ICAT']? window['ICAT'].react : ";
if (object && (object.name || '').toLowerCase() === 'reactdom') {
(function () {
var fn = 'function(){\n var argus = Array.prototype.slice.call(arguments),\n rcDom = argus[1], el = argus[4], vdom = argus[5]; \n rcDom.render(vdom, el);\n }';
var argus = t.arrayExpression(node.arguments);
var icatReact = "window['ICAT']? window['ICAT'].react : ";
var arr = [t.stringLiteral(methodName), node.callee.object];
node.arguments.map(function (arg) {
if (t.isJSXElement(arg)) {
arr.push(arg.openingElement.name);
if (arg.openingElement.attributes.length) {
(function () {
var attrs = [];
arg.openingElement.attributes.map(function (item) {
attrs.push(t.objectProperty(t.stringLiteral(item.name.name), item.value));
});
arr.push(t.objectExpression(attrs));
})();
} else {
arr.push(t.identifier('null'));
}
} else {
arr.push(arg);
}
});
path.replaceWith(t.callExpression(t.identifier("(" + icatReact + fn + ")"), [node.callee, t.stringLiteral(methodName), argus]));
arr.push(node.arguments[0]);
path.replaceWith(t.callExpression(t.identifier("(" + icatReact + fn + ")"), arr));
})();
}

@@ -46,0 +72,0 @@ }

2

package.json
{
"name": "babel-plugin-react-originjs",
"version": "0.0.1",
"version": "0.0.2",
"description": "Make react-components into original js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,3 +15,7 @@ export default function({ types }) {

}
});
if (types.isImportDefaultSpecifier(spec)) {
methodName = value + '/' + spec.local.name;
}
});
methodName = methodName || 'noname';
}

@@ -27,11 +31,31 @@ },

if (!types.isIdentifier(node.callee)) {
if(object && object.name.toLowerCase()==='reactdom'){
let fn = 'function(render, name, argus){ render.apply(this, argus); }';
if(object && (object.name||'').toLowerCase()==='reactdom'){
let fn = `function(){
var argus = Array.prototype.slice.call(arguments),
rcDom = argus[1], el = argus[4], vdom = argus[5];
rcDom.render(vdom, el);
}`;
let argus = t.arrayExpression(node.arguments);
let icatReact = "window['ICAT']? window['ICAT'].react : ";
let arr = [t.stringLiteral(methodName), node.callee.object];
node.arguments.map(arg => {
if(t.isJSXElement(arg)) {
arr.push(arg.openingElement.name);
if(arg.openingElement.attributes.length){
let attrs = [];
arg.openingElement.attributes.map(item=>{
attrs.push(t.objectProperty(t.stringLiteral(item.name.name), item.value));
});
arr.push(t.objectExpression(attrs));
} else {
arr.push(t.identifier('null'));
}
} else {
arr.push(arg);
}
});
arr.push(node.arguments[0]);
path.replaceWith(
t.callExpression(
t.identifier("(" + icatReact + fn + ")"),
[node.callee, t.stringLiteral(methodName), argus])
t.callExpression(t.identifier("(" + icatReact + fn + ")"), arr)
)

@@ -38,0 +62,0 @@ }

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