Comparing version 0.2.17 to 0.2.18
{ | ||
"name": "aether", | ||
"version": "0.2.17", | ||
"version": "0.2.18", | ||
"homepage": "https://github.com/codecombat/aether", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -60,2 +60,4 @@ (function() { | ||
this.allGlobals = this.options.globals.concat(protectBuiltins.builtinNames, Object.keys(this.language.runtimeGlobals)); | ||
this.protectAPIClonesToValues = {}; | ||
this.protectAPIValuesToClones = {}; | ||
} | ||
@@ -62,0 +64,0 @@ |
(function() { | ||
var JavaScript, Language, acorn_loose, esprima, jshint, traversal, _, _ref, _ref1, _ref2, _ref3, | ||
var JavaScript, Language, acorn_loose, escodegen, esprima, jshint, traversal, _, _ref, _ref1, _ref2, _ref3, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -14,2 +14,4 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
escodegen = require('escodegen'); | ||
Language = require('./language'); | ||
@@ -16,0 +18,0 @@ |
(function() { | ||
var argsClass, arrayClass, boolClass, cloneableClasses, createAPIClone, ctorByClass, dateClass, errorClass, funcClass, numberClass, objectClass, reFlags, regexpClass, restoreAPIClone, stringClass, _, _ref, _ref1, _ref2, | ||
var argsClass, arrayClass, boolClass, cloneableClasses, createAPIClone, ctorByClass, dateClass, errorClass, funcClass, numberClass, objectClass, protectionIdCounter, reFlags, regexpClass, restoreAPIClone, stringClass, _, _ref, _ref1, _ref2, | ||
__hasProp = {}.hasOwnProperty; | ||
@@ -35,6 +35,8 @@ | ||
protectionIdCounter = 0; | ||
reFlags = /\w*$/; | ||
module.exports.createAPIClone = createAPIClone = function(value) { | ||
var className, clone, ctor, i, isArr, k, prop, result, v, _fn, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref3, _ref4, _ref5, _ref6, _ref7; | ||
module.exports.createAPIClone = createAPIClone = function(aether, value) { | ||
var className, ctor, i, id, isArr, k, prop, result, v, _fn, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref3, _ref4, _ref5, _ref6, _ref7; | ||
if (!_.isObject(value)) { | ||
@@ -60,8 +62,13 @@ return value; | ||
} | ||
if (clone = value.__aetherAPIClone) { | ||
return clone; | ||
if (value.__aetherID != null) { | ||
id = value.__aetherID; | ||
if ((result = aether.protectAPIValuesToClones[id]) != null) { | ||
return result; | ||
} | ||
} else { | ||
id = protectionIdCounter++; | ||
Object.defineProperty(value, '__aetherID', { | ||
value: id | ||
}); | ||
} | ||
if (value.__aetherAPIValue) { | ||
return value; | ||
} | ||
if (isArr = _.isArray(value)) { | ||
@@ -78,14 +85,11 @@ result = ctor(value.length); | ||
} | ||
Object.defineProperty(value, "__aetherAPIClone", { | ||
value: result, | ||
writable: true, | ||
configurable: true | ||
Object.defineProperty(result, '__aetherID', { | ||
value: id | ||
}); | ||
Object.defineProperty(result, "__aetherAPIValue", { | ||
value: value | ||
}); | ||
aether.protectAPIValuesToClones[id] = result; | ||
aether.protectAPIClonesToValues[id] = value; | ||
if (isArr) { | ||
for (i = _i = 0, _len = value.length; _i < _len; i = ++_i) { | ||
v = value[i]; | ||
result[i] = createAPIClone(v); | ||
result[i] = createAPIClone(aether, v); | ||
} | ||
@@ -118,3 +122,3 @@ } else if (value.apiProperties) { | ||
fn = function() { | ||
return createAPIClone(value[prop]); | ||
return createAPIClone(aether, value[prop]); | ||
}; | ||
@@ -132,3 +136,3 @@ return Object.defineProperty(result, prop, { | ||
if (result[prop] == null) { | ||
result[prop] = createAPIClone(value[prop]); | ||
result[prop] = createAPIClone(aether, value[prop]); | ||
} | ||
@@ -141,3 +145,3 @@ } | ||
Object.defineProperty(result, k, { | ||
value: createAPIClone(v), | ||
value: createAPIClone(aether, v), | ||
enumerable: true | ||
@@ -150,4 +154,4 @@ }); | ||
module.exports.restoreAPIClone = restoreAPIClone = function(value, depth) { | ||
var className, isArr, k, result, source, v, _ref3; | ||
module.exports.restoreAPIClone = restoreAPIClone = function(aether, value, depth) { | ||
var className, isArr, k, result, source, v; | ||
if (depth == null) { | ||
@@ -166,8 +170,5 @@ depth = 0; | ||
} | ||
if (source = value.__aetherAPIValue) { | ||
if ((source = aether.protectAPIClonesToValues[value.__aetherID]) != null) { | ||
return source; | ||
} | ||
if (source = (_ref3 = value.__aetherAPIClone) != null ? _ref3.__aetherAPIValue : void 0) { | ||
return source; | ||
} | ||
if (depth > 1) { | ||
@@ -182,3 +183,3 @@ return value; | ||
v = value[_i]; | ||
_results.push(restoreAPIClone(v, depth + 1)); | ||
_results.push(restoreAPIClone(aether, v, depth + 1)); | ||
} | ||
@@ -191,3 +192,3 @@ return _results; | ||
v = value[k]; | ||
result[k] = restoreAPIClone(v, depth + 1); | ||
result[k] = restoreAPIClone(aether, v, depth + 1); | ||
} | ||
@@ -194,0 +195,0 @@ } |
@@ -304,9 +304,9 @@ (function() { | ||
arg = _ref4[_i]; | ||
arg.update("_aether.restoreAPIClone(" + (arg.source()) + ")"); | ||
arg.update("_aether.restoreAPIClone(_aether, " + (arg.source()) + ")"); | ||
} | ||
} else if (node.type === S.ReturnStatement && (arg = node.argument)) { | ||
arg.update("_aether.restoreAPIClone(" + (arg.source()) + ")"); | ||
arg.update("_aether.restoreAPIClone(_aether, " + (arg.source()) + ")"); | ||
} | ||
if (node.parent.type === S.AssignmentExpression || node.type === S.ThisExpression) { | ||
return node.update("_aether.createAPIClone(" + (node.source()) + ")"); | ||
return node.update("_aether.createAPIClone(_aether, " + (node.source()) + ")"); | ||
} else if (node.type === S.VariableDeclaration) { | ||
@@ -328,7 +328,7 @@ parameters = (function() { | ||
parameter = parameters[_j]; | ||
_results.push("" + parameter + " = _aether.createAPIClone(" + parameter + ");"); | ||
_results.push("" + parameter + " = _aether.createAPIClone(_aether, " + parameter + ");"); | ||
} | ||
return _results; | ||
})(); | ||
argumentsProtector = "for(var __argIndexer = 0; __argIndexer < arguments.length; ++__argIndexer) arguments[__argIndexer] = _aether.createAPIClone(arguments[__argIndexer]);"; | ||
argumentsProtector = "for(var __argIndexer = 0; __argIndexer < arguments.length; ++__argIndexer) arguments[__argIndexer] = _aether.createAPIClone(_aether, arguments[__argIndexer]);"; | ||
return node.update("" + (node.source()) + " " + (protectors.join(' ')) + " " + argumentsProtector); | ||
@@ -335,0 +335,0 @@ } |
{ | ||
"name": "aether", | ||
"version": "0.2.17", | ||
"version": "0.2.18", | ||
"description": "Analyzes, instruments, and transpiles JS to help beginners.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
155329
2647