New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-metadata

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-metadata - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

CHANGELOG.md

5

dist/factories/createCreateCreateGenericTypeMetadata.js

@@ -6,5 +6,2 @@ 'use strict';

function createCreateCreateGenericTypeMetadata(t, externalTypeNames, internalTypes, markGenerics) {
var propName = t.identifier('v');
var sigName = t.identifier('_r4');
return function createCreateGenericTypeMetadata(createObjectTypeMetadata) {

@@ -46,3 +43,3 @@ return function createGenericTypeMetadata(annotation, typeParameters) {

var interfaceId = markGenerics[id.name];
return interfaceId ? t.objectExpression([t.objectProperty(sigName, t.numericLiteral(interfaceId)), t.objectProperty(propName, t.arrayExpression(Array.isArray(result) ? result : [result]))]) : result;
return interfaceId ? t.arrayExpression([t.numericLiteral(interfaceId)].concat(Array.isArray(result) ? result : [result])) : result;
}

@@ -49,0 +46,0 @@ }

10

dist/index.js

@@ -51,6 +51,2 @@ 'use strict';

var _createInsertFactory = require('./modifiers/createInsertFactory');
var _createInsertFactory2 = _interopRequireDefault(_createInsertFactory);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -66,4 +62,3 @@

ambiantTypeCastImport: 'babel-plugin-transform-metadata/_',
ambiantDepsImport: 'babel-plugin-transform-metadata/Deps',
jsxPragma: 'createVNode'
ambiantDepsImport: 'babel-plugin-transform-metadata/Deps'
};

@@ -119,5 +114,2 @@

reflectionState.parentPaths.forEach(parentPathInsertAfter);
if (cnf.jsxPragma) {
state.functionsWithJsx.forEach((0, _createInsertFactory2.default)(t, cnf.jsxPragma));
}

@@ -124,0 +116,0 @@ if (state.ambiantTypeCast) {

@@ -6,6 +6,3 @@ 'use strict';

function createInjectParamTypes(t, injectPrefixRaw, typeForAnnotations, functionsWithJsx, filename, addDisplayName) {
var injectPrefix = injectPrefixRaw || '_r';
var argId = t.identifier(injectPrefix + '1');
var flagsId = t.identifier(injectPrefix + '2');
var fileId = t.identifier(injectPrefix + '3');
var injectPrefix = t.identifier(injectPrefixRaw || '_r');
var displayNameId = t.identifier('displayName');

@@ -17,36 +14,33 @@

var isJsx = functionsWithJsx.has(node);
var meta = [];
var typeArgs = [];
if (rawTypes.length) {
var types = void 0;
if (isJsx) {
types = rawTypes.length > 1 ? [rawTypes[1]] : [];
types = rawTypes.slice(1);
} else {
types = rawTypes;
}
var typeArgs = typeForAnnotations(types, node.typeParameters ? node.typeParameters.params : null);
if (typeArgs.length) {
body.push(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(target, argId), t.arrayExpression(typeArgs))));
}
for (var i = 0; i < types.length; i++) {
var argType = types[i];
var decorators = argType.decorators || [];
for (var j = 0; j < decorators.length; j++) {
body.push(t.expressionStatement(t.callExpression(decorators[j].expression, [target, t.identifier('null'), t.identifier(i.toString())])));
}
}
typeArgs = typeForAnnotations(types, node.typeParameters ? node.typeParameters.params : null);
}
if (type === 'FunctionDeclaration' || type === 'FunctionExpression' || type === 'ArrowFunctionExpression') {
body.push(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(target, flagsId), t.numericLiteral(isJsx ? 1 : 2))));
}
var isFunction = type === 'FunctionDeclaration' || type === 'FunctionExpression' || type === 'ArrowFunctionExpression';
if (filename) {
body.push(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(target, fileId), t.stringLiteral(filename))));
if (typeArgs.length) {
meta.push(t.numericLiteral(isJsx ? 1 : isFunction ? 2 : 0));
meta.push(t.arrayExpression(typeArgs));
} else if (isFunction) {
meta.push(t.numericLiteral(isJsx ? 1 : 2));
}
if (addDisplayName) {
body.push(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(target, displayNameId), t.stringLiteral(target.name))));
body.push(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(target, displayNameId), t.stringLiteral(filename ? filename + '#' + target.name : target.name))));
}
if (meta.length) {
body.push(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(target, injectPrefix), t.arrayExpression(meta))));
}
return body;

@@ -53,0 +47,0 @@ };

{
"name": "babel-plugin-transform-metadata",
"version": "3.0.0",
"version": "4.0.0",
"description": "Reflection metadata support for classes and functions with flowtype type aliases support",

@@ -13,18 +13,9 @@ "publishConfig": {

"scripts": {
"postinstall": "test -d conf && conf/resources/postinstall.sh $npm_package_name || exit 0",
"prepush": "exit 0 && npm test",
"prepublish": "conf/resources/prepublish.sh",
"preversion": "conf/resources/checkgit.sh && npm test",
"postversion": "git push && git push --tags",
"precommit": "exit 0",
"update": "ncu -ua && npm install",
"clean": "rm -rf $npm_package_config_builddir/dist coverage",
"build": "npm run clean && babel src --source-maps --out-dir $npm_package_config_builddir/dist",
"build.dev": "babel src --source-maps --out-dir $npm_package_config_builddir/dist --watch",
"lint": "exit 0 && eslint src",
"check": "flow check",
"testonly": "mocha",
"test": "npm run lint && npm run check && npm run testonly",
"test.dev": "npm run testonly -- --growl --watch",
"test.cov": "babel-istanbul cover --report text --report html node_modules/mocha/bin/_mocha"
"major": "npm test && npm run build && standard-version --release-as major && npm run postversion",
"release": "npm test && npm run build && standard-version && npm run postversion",
"postversion": "git push --follow-tags origin master && npm publish",
"clean": "rm -rf $npm_package_config_builddir/dist",
"build": "npm run clean && babel src --ignore __tests__ --source-maps --out-dir $npm_package_config_builddir/dist",
"test": "flow check && mocha",
"test.dev": "mocha --growl --watch"
},

@@ -60,7 +51,7 @@ "author": "Stefan Zerkalica <zerkalica@gmail.com>",

"devDependencies": {
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-espower": "^2.3.2",
"babel-plugin-inferno": "^2.1.0",
"babel-plugin-module-resolver": "^2.5.0",
"babel-plugin-inferno": "^3.2.0",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-syntax-decorators": "^6.13.0",

@@ -70,10 +61,8 @@ "babel-plugin-syntax-flow": "^6.18.0",

"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-stage-0": "^6.22.0",
"eslint": "^3.18.0",
"eslint-config-airplus": "^2.0.13",
"glob": "^7.1.1",
"mocha": "^3.2.0",
"power-assert": "^1.4.2",
"sinon": "^2.1.0"
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"glob": "^7.1.2",
"mocha": "^3.5.1",
"standard-version": "^4.2.0"
},

@@ -80,0 +69,0 @@ "dependencies": {

@@ -7,6 +7,3 @@ # babel-plugin-transform-metadata

- Metadata provided for array and object-style arguments
- Generics and type arguments supported
- With transform-decorators-legacy supports argument decorators
- Adds createVNode as third argument to each function with jsx, used in [reactive-di](https://github.com/zerkalica/reactive-di) components: (props, state, h) => React$Element
- typeof, Class support
- Generics and type arguments support

@@ -54,4 +51,3 @@ ## Examples

MyClass.displayName = 'MyClass';
MyClass._r3 = 'babel-plugin-transform-metadata/src/__tests__/data/MagicTypeCast.js';
MyClass._r1 = ['C'];
MyClass._r = [0, ['C']];

@@ -62,3 +58,3 @@

## Mark function
### Mark function

@@ -86,5 +82,3 @@ In:

fn.displayName = "fn";
fn._r3 = "babel-plugin-transform-metadata/src/__tests__/data/FunctionMark.js";
fn._r2 = 2;
fn._r1 = [A];
fn._r = [1, [A]];
```

@@ -94,4 +88,2 @@

We use [inferno](https://infernojs.org/) style createVNode:
In:

@@ -119,4 +111,2 @@

ComponentD.displayName = 'ComponentD';
ComponentD._r3 = 'babel-plugin-transform-metadata/src/__tests__/data/AllFeatures.js';
ComponentD._r2 = 1;
ComponentD._r1 = [{

@@ -163,6 +153,5 @@ s: A

}];
var id = 'IT';
```
For more examples see ./src/__tests__/data
For more examples see ``` ./src/__tests__/data ```

@@ -172,2 +161,4 @@

To each function plugin adds following metadata:
```js

@@ -174,0 +165,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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