@babel/plugin-proposal-decorators
Advanced tools
Comparing version 7.0.0-beta.31 to 7.0.0-beta.32
@@ -6,19 +6,17 @@ "use strict"; | ||
var _template = _interopRequireDefault(require("@babel/template")); | ||
var _pluginSyntaxDecorators = _interopRequireDefault(require("@babel/plugin-syntax-decorators")); | ||
var _core = require("@babel/core"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var buildClassDecorator = (0, _template.default)("\n DECORATOR(CLASS_REF = INNER) || CLASS_REF;\n"); | ||
var buildClassPrototype = (0, _template.default)("\n CLASS_REF.prototype;\n"); | ||
var buildGetDescriptor = (0, _template.default)("\n Object.getOwnPropertyDescriptor(TARGET, PROPERTY);\n"); | ||
var buildGetObjectInitializer = (0, _template.default)("\n (TEMP = Object.getOwnPropertyDescriptor(TARGET, PROPERTY), (TEMP = TEMP ? TEMP.value : undefined), {\n enumerable: true,\n configurable: true,\n writable: true,\n initializer: function(){\n return TEMP;\n }\n })\n"); | ||
var buildInitializerWarningHelper = (0, _template.default)("\n function NAME(descriptor, context){\n throw new Error(\n 'Decorating class property failed. Please ensure that ' +\n 'proposal-class-properties is enabled and set to use loose mode. ' +\n 'To use proposal-class-properties in spec mode with decorators, wait for ' +\n 'the next major version of decorators in stage 2.'\n );\n }\n"); | ||
var buildInitializerDefineProperty = (0, _template.default)("\n function NAME(target, property, descriptor, context){\n if (!descriptor) return;\n\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0,\n });\n }\n"); | ||
var buildApplyDecoratedDescriptor = (0, _template.default)("\n function NAME(target, property, decorators, descriptor, context){\n var desc = {};\n Object['ke' + 'ys'](descriptor).forEach(function(key){\n desc[key] = descriptor[key];\n });\n desc.enumerable = !!desc.enumerable;\n desc.configurable = !!desc.configurable;\n if ('value' in desc || desc.initializer){\n desc.writable = true;\n }\n\n desc = decorators.slice().reverse().reduce(function(desc, decorator){\n return decorator(target, property, desc) || desc;\n }, desc);\n\n if (context && desc.initializer !== void 0){\n desc.value = desc.initializer ? desc.initializer.call(context) : void 0;\n desc.initializer = undefined;\n }\n\n if (desc.initializer === void 0){\n // This is a hack to avoid this being processed by 'transform-runtime'.\n // See issue #9.\n Object['define' + 'Property'](target, property, desc);\n desc = null;\n }\n\n return desc;\n }\n"); | ||
var buildClassDecorator = (0, _core.template)("\n DECORATOR(CLASS_REF = INNER) || CLASS_REF;\n"); | ||
var buildClassPrototype = (0, _core.template)("\n CLASS_REF.prototype;\n"); | ||
var buildGetDescriptor = (0, _core.template)("\n Object.getOwnPropertyDescriptor(TARGET, PROPERTY);\n"); | ||
var buildGetObjectInitializer = (0, _core.template)("\n (TEMP = Object.getOwnPropertyDescriptor(TARGET, PROPERTY), (TEMP = TEMP ? TEMP.value : undefined), {\n enumerable: true,\n configurable: true,\n writable: true,\n initializer: function(){\n return TEMP;\n }\n })\n"); | ||
var buildInitializerWarningHelper = (0, _core.template)("\n function NAME(descriptor, context){\n throw new Error(\n 'Decorating class property failed. Please ensure that ' +\n 'proposal-class-properties is enabled and set to use loose mode. ' +\n 'To use proposal-class-properties in spec mode with decorators, wait for ' +\n 'the next major version of decorators in stage 2.'\n );\n }\n"); | ||
var buildInitializerDefineProperty = (0, _core.template)("\n function NAME(target, property, descriptor, context){\n if (!descriptor) return;\n\n Object.defineProperty(target, property, {\n enumerable: descriptor.enumerable,\n configurable: descriptor.configurable,\n writable: descriptor.writable,\n value: descriptor.initializer ? descriptor.initializer.call(context) : void 0,\n });\n }\n"); | ||
var buildApplyDecoratedDescriptor = (0, _core.template)("\n function NAME(target, property, decorators, descriptor, context){\n var desc = {};\n Object['ke' + 'ys'](descriptor).forEach(function(key){\n desc[key] = descriptor[key];\n });\n desc.enumerable = !!desc.enumerable;\n desc.configurable = !!desc.configurable;\n if ('value' in desc || desc.initializer){\n desc.writable = true;\n }\n\n desc = decorators.slice().reverse().reduce(function(desc, decorator){\n return decorator(target, property, desc) || desc;\n }, desc);\n\n if (context && desc.initializer !== void 0){\n desc.value = desc.initializer ? desc.initializer.call(context) : void 0;\n desc.initializer = undefined;\n }\n\n if (desc.initializer === void 0){\n // This is a hack to avoid this being processed by 'transform-runtime'.\n // See issue #9.\n Object['define' + 'Property'](target, property, desc);\n desc = null;\n }\n\n return desc;\n }\n"); | ||
function _default(_ref) { | ||
var t = _ref.types; | ||
function _default() { | ||
function ensureApplyDecoratedDescriptorHelper(path, state) { | ||
@@ -65,9 +63,9 @@ if (!state.applyDecoratedDescriptor) { | ||
var identDecorators = decorators.filter(function (decorator) { | ||
return !t.isIdentifier(decorator.expression); | ||
return !_core.types.isIdentifier(decorator.expression); | ||
}); | ||
if (identDecorators.length === 0) return; | ||
return t.sequenceExpression(identDecorators.map(function (decorator) { | ||
return _core.types.sequenceExpression(identDecorators.map(function (decorator) { | ||
var expression = decorator.expression; | ||
var id = decorator.expression = path.scope.generateDeclaredUidIdentifier("dec"); | ||
return t.assignmentExpression("=", id, expression); | ||
return _core.types.assignmentExpression("=", id, expression); | ||
}).concat([path.node])); | ||
@@ -119,3 +117,3 @@ } | ||
var property = t.isLiteral(node.key) ? node.key : t.stringLiteral(node.key.name); | ||
var property = _core.types.isLiteral(node.key) ? node.key : _core.types.stringLiteral(node.key.name); | ||
var target = path.isClass() && !node.static ? buildClassPrototype({ | ||
@@ -125,15 +123,15 @@ CLASS_REF: name | ||
if (t.isClassProperty(node, { | ||
if (_core.types.isClassProperty(node, { | ||
static: false | ||
})) { | ||
var descriptor = path.scope.generateDeclaredUidIdentifier("descriptor"); | ||
var initializer = node.value ? t.functionExpression(null, [], t.blockStatement([t.returnStatement(node.value)])) : t.nullLiteral(); | ||
node.value = t.callExpression(ensureInitializerWarning(path, state), [descriptor, t.thisExpression()]); | ||
acc = acc.concat([t.assignmentExpression("=", descriptor, t.callExpression(ensureApplyDecoratedDescriptorHelper(path, state), [target, property, t.arrayExpression(decorators.map(function (dec) { | ||
var initializer = node.value ? _core.types.functionExpression(null, [], _core.types.blockStatement([_core.types.returnStatement(node.value)])) : _core.types.nullLiteral(); | ||
node.value = _core.types.callExpression(ensureInitializerWarning(path, state), [descriptor, _core.types.thisExpression()]); | ||
acc = acc.concat([_core.types.assignmentExpression("=", descriptor, _core.types.callExpression(ensureApplyDecoratedDescriptorHelper(path, state), [target, property, _core.types.arrayExpression(decorators.map(function (dec) { | ||
return dec.expression; | ||
})), t.objectExpression([t.objectProperty(t.identifier("enumerable"), t.booleanLiteral(true)), t.objectProperty(t.identifier("initializer"), initializer)])]))]); | ||
})), _core.types.objectExpression([_core.types.objectProperty(_core.types.identifier("enumerable"), _core.types.booleanLiteral(true)), _core.types.objectProperty(_core.types.identifier("initializer"), initializer)])]))]); | ||
} else { | ||
acc = acc.concat(t.callExpression(ensureApplyDecoratedDescriptorHelper(path, state), [target, property, t.arrayExpression(decorators.map(function (dec) { | ||
acc = acc.concat(_core.types.callExpression(ensureApplyDecoratedDescriptorHelper(path, state), [target, property, _core.types.arrayExpression(decorators.map(function (dec) { | ||
return dec.expression; | ||
})), t.isObjectProperty(node) || t.isClassProperty(node, { | ||
})), _core.types.isObjectProperty(node) || _core.types.isClassProperty(node, { | ||
static: true | ||
@@ -152,3 +150,3 @@ }) ? buildGetObjectInitializer({ | ||
}, []); | ||
return t.sequenceExpression([t.assignmentExpression("=", name, path.node), t.sequenceExpression(exprs), name]); | ||
return _core.types.sequenceExpression([_core.types.assignmentExpression("=", name, path.node), _core.types.sequenceExpression(exprs), name]); | ||
} | ||
@@ -165,3 +163,3 @@ | ||
path.replaceWith(node.declaration); | ||
path.insertAfter(t.exportNamedDeclaration(null, [t.exportSpecifier(ref, t.identifier("default"))])); | ||
path.insertAfter(_core.types.exportNamedDeclaration(null, [_core.types.exportSpecifier(ref, _core.types.identifier("default"))])); | ||
}, | ||
@@ -171,3 +169,3 @@ ClassDeclaration: function ClassDeclaration(path) { | ||
var ref = node.id || path.scope.generateUidIdentifier("class"); | ||
path.replaceWith(t.variableDeclaration("let", [t.variableDeclarator(ref, t.toExpression(node))])); | ||
path.replaceWith(_core.types.variableDeclaration("let", [_core.types.variableDeclarator(ref, _core.types.toExpression(node))])); | ||
}, | ||
@@ -194,3 +192,3 @@ ClassExpression: function ClassExpression(path, state) { | ||
path.replaceWith(t.callExpression(ensureInitializerDefineProp(path, state), [path.get("left.object").node, t.stringLiteral(path.get("left.property").node.name), path.get("right.arguments")[0].node, path.get("right.arguments")[1].node])); | ||
path.replaceWith(_core.types.callExpression(ensureInitializerDefineProp(path, state), [path.get("left.object").node, _core.types.stringLiteral(path.get("left.property").node.name), path.get("right.arguments")[0].node, path.get("right.arguments")[1].node])); | ||
} | ||
@@ -197,0 +195,0 @@ } |
{ | ||
"name": "@babel/plugin-proposal-decorators", | ||
"version": "7.0.0-beta.31", | ||
"version": "7.0.0-beta.32", | ||
"author": "Logan Smyth <loganfsmyth@gmail.com>", | ||
@@ -15,12 +15,11 @@ "license": "MIT", | ||
"dependencies": { | ||
"@babel/plugin-syntax-decorators": "7.0.0-beta.31", | ||
"@babel/template": "7.0.0-beta.31" | ||
"@babel/plugin-syntax-decorators": "7.0.0-beta.32" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "7.0.0-beta.31" | ||
"@babel/core": "7.0.0-beta.32" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-beta.31", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.31" | ||
"@babel/core": "7.0.0-beta.32", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.32" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13281
2
170
+ Added@babel/code-frame@7.0.0-beta.32(transitive)
+ Added@babel/core@7.0.0-beta.32(transitive)
+ Added@babel/generator@7.0.0-beta.32(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.32(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.32(transitive)
+ Added@babel/helpers@7.0.0-beta.32(transitive)
+ Added@babel/plugin-syntax-decorators@7.0.0-beta.32(transitive)
+ Added@babel/template@7.0.0-beta.32(transitive)
+ Added@babel/traverse@7.0.0-beta.32(transitive)
+ Added@babel/types@7.0.0-beta.32(transitive)
+ Addedbabylon@7.0.0-beta.32(transitive)
- Removed@babel/template@7.0.0-beta.31
- Removed@babel/code-frame@7.0.0-beta.31(transitive)
- Removed@babel/core@7.0.0-beta.31(transitive)
- Removed@babel/generator@7.0.0-beta.31(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.31(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.31(transitive)
- Removed@babel/helpers@7.0.0-beta.31(transitive)
- Removed@babel/plugin-syntax-decorators@7.0.0-beta.31(transitive)
- Removed@babel/template@7.0.0-beta.31(transitive)
- Removed@babel/traverse@7.0.0-beta.31(transitive)
- Removed@babel/types@7.0.0-beta.31(transitive)
- Removedbabylon@7.0.0-beta.31(transitive)