first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

41
build/node_modules/prepack/lib/utils/builder.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = buildExpressionTemplate;
var _babelTemplate = require("babel-template");
var _babelTemplate2 = _interopRequireDefault(_babelTemplate);
var _invariant = require("../invariant.js");
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function buildExpressionTemplate(code) {
var template = void 0;
return function (preludeGenerator) {
return function (obj) {
if (template === undefined) template = (0, _babelTemplate2.default)(code);
if (preludeGenerator !== undefined && code.includes("global")) obj = Object.assign({
global: preludeGenerator.memoizeReference("global")
}, obj);
var result = template(obj).expression;
(0, _invariant2.default)(result !== undefined, "Code does not represent an expression: " + code);
return result;
};
};
}
//# sourceMappingURL=builder.js.map

1
build/node_modules/prepack/lib/utils/builder.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/builder.js"],"names":["buildExpressionTemplate","code","template","preludeGenerator","obj","undefined","includes","Object","assign","global","memoizeReference","result","expression"],"mappings":";;;;;kBAgBwBA,uB;;AALxB;;;;AAGA;;;;;;AAdA;;;;;;;;;AAgBe,SAASA,uBAAT,CAAiCC,IAAjC,EAAwG;AACrH,MAAIC,iBAAJ;AACA,SAAO,UAACC,gBAAD;AAAA,WAA+C,UAACC,GAAD,EAAmC;AACvF,UAAIF,aAAaG,SAAjB,EAA4BH,WAAW,6BAAcD,IAAd,CAAX;AAC5B,UAAIE,qBAAqBE,SAArB,IAAkCJ,KAAKK,QAAL,CAAc,QAAd,CAAtC,EACEF,MAAMG,OAAOC,MAAP,CACJ;AACEC,gBAAQN,iBAAiBO,gBAAjB,CAAkC,QAAlC;AADV,OADI,EAIJN,GAJI,CAAN;AAMF,UAAIO,SAAST,SAASE,GAAT,EAAcQ,UAA3B;AACA,+BAAUD,WAAWN,SAArB,EAAgC,4CAA4CJ,IAA5E;AACA,aAAOU,MAAP;AACD,KAZM;AAAA,GAAP;AAaD","file":"builder.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport buildTemplate from \"babel-template\";\nimport type { BabelNodeExpression } from \"babel-types\";\nimport type { PreludeGenerator } from \"./generator.js\";\nimport invariant from \"../invariant.js\";\n\nexport default function buildExpressionTemplate(code: string): (void | PreludeGenerator) => any => BabelNodeExpression {\n let template;\n return (preludeGenerator: void | PreludeGenerator) => (obj: any): BabelNodeExpression => {\n if (template === undefined) template = buildTemplate(code);\n if (preludeGenerator !== undefined && code.includes(\"global\"))\n obj = Object.assign(\n {\n global: preludeGenerator.memoizeReference(\"global\"),\n },\n obj\n );\n let result = template(obj).expression;\n invariant(result !== undefined, \"Code does not represent an expression: \" + code);\n return result;\n };\n}\n"]}

35
build/node_modules/prepack/lib/utils/errors.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ignoreErrorsIn = ignoreErrorsIn;
var _errors = require("../errors.js");
var _realm = require("../realm.js");
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function ignoreErrorsIn(realm, f) {
var savedHandler = realm.errorHandler;
realm.errorHandler = function (d) {
return "Recover";
};
try {
return f();
} catch (err) {
if (err instanceof _errors.FatalError) return undefined;
throw err;
} finally {
realm.errorHandler = savedHandler;
}
}
//# sourceMappingURL=errors.js.map

1
build/node_modules/prepack/lib/utils/errors.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/errors.js"],"names":["ignoreErrorsIn","realm","f","savedHandler","errorHandler","err","undefined"],"mappings":";;;;;QAcgBA,c,GAAAA,c;;AAHhB;;AACA;;AAZA;;;;;;;;;AAcO,SAASA,cAAT,CAA2BC,KAA3B,EAAyCC,CAAzC,EAA+D;AACpE,MAAIC,eAAeF,MAAMG,YAAzB;AACAH,QAAMG,YAAN,GAAqB;AAAA,WAAK,SAAL;AAAA,GAArB;AACA,MAAI;AACF,WAAOF,GAAP;AACD,GAFD,CAEE,OAAOG,GAAP,EAAY;AACZ,QAAIA,iCAAJ,EAA+B,OAAOC,SAAP;AAC/B,UAAMD,GAAN;AACD,GALD,SAKU;AACRJ,UAAMG,YAAN,GAAqBD,YAArB;AACD;AACF","file":"errors.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport { FatalError } from \"../errors.js\";\nimport { Realm } from \"../realm.js\";\n\nexport function ignoreErrorsIn<T>(realm: Realm, f: () => T): void | T {\n let savedHandler = realm.errorHandler;\n realm.errorHandler = d => \"Recover\";\n try {\n return f();\n } catch (err) {\n if (err instanceof FatalError) return undefined;\n throw err;\n } finally {\n realm.errorHandler = savedHandler;\n }\n}\n"]}

624
build/node_modules/prepack/lib/utils/generator.js generated vendored Normal file
View File

@@ -0,0 +1,624 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PreludeGenerator = exports.NameGenerator = exports.Generator = undefined;
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
var _index = require("../values/index.js");
var _index2 = require("../domains/index.js");
var _base = require("base62");
var base62 = _interopRequireWildcard(_base);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _invariant = require("../invariant.js");
var _invariant2 = _interopRequireDefault(_invariant);
var _internalizer = require("./internalizer.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function serializeBody(generator, context) {
var statements = context.serializeGenerator(generator);
return t.blockStatement(statements);
}
var Generator = exports.Generator = function () {
function Generator(realm, name) {
_classCallCheck(this, Generator);
(0, _invariant2.default)(realm.useAbstractInterpretation);
var realmPreludeGenerator = realm.preludeGenerator;
(0, _invariant2.default)(realmPreludeGenerator);
this.preludeGenerator = realmPreludeGenerator;
this.parent = realm.generator;
this.realm = realm;
this._entries = [];
this.id = realm.nextGeneratorId++;
this._name = name;
}
_createClass(Generator, [{
key: "getName",
value: function getName() {
return this._name || "#" + this.id;
}
}, {
key: "getAsPropertyNameExpression",
value: function getAsPropertyNameExpression(key) {
var canBeIdentifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
// If key is a non-negative numeric string literal, parse it and set it as a numeric index instead.
var index = Number.parseInt(key, 10);
if (index >= 0 && index.toString() === key) {
return t.numericLiteral(index);
}
if (canBeIdentifier) {
// TODO #1020: revert this when Unicode identifiers are supported by all targetted JavaScript engines
var keyIsAscii = /^[\u0000-\u007f]*$/.test(key);
if (t.isValidIdentifier(key) && keyIsAscii) return t.identifier(key);
}
return t.stringLiteral(key);
}
}, {
key: "getParent",
value: function getParent() {
return this.parent;
}
}, {
key: "empty",
value: function empty() {
return this._entries.length === 0;
}
// Will force the array of Values to be serialized but not emit anything for a buildNode
}, {
key: "appendRoots",
value: function appendRoots(values) {
this._addEntry({
args: values
});
}
}, {
key: "emitGlobalDeclaration",
value: function emitGlobalDeclaration(key, value) {
this.preludeGenerator.declaredGlobals.add(key);
if (!(value instanceof _index.UndefinedValue)) this.emitGlobalAssignment(key, value, true);
}
}, {
key: "emitGlobalAssignment",
value: function emitGlobalAssignment(key, value, strictMode) {
var _this = this;
this._addEntry({
args: [value],
buildNode: function buildNode(_ref) {
var _ref2 = _slicedToArray(_ref, 1),
valueNode = _ref2[0];
return t.expressionStatement(t.assignmentExpression("=", _this.preludeGenerator.globalReference(key, !strictMode), valueNode));
}
});
}
}, {
key: "emitGlobalDelete",
value: function emitGlobalDelete(key, strictMode) {
var _this2 = this;
this._addEntry({
args: [],
buildNode: function buildNode(_ref3) {
var _ref4 = _toArray(_ref3);
return t.expressionStatement(t.unaryExpression("delete", _this2.preludeGenerator.globalReference(key, !strictMode)));
}
});
}
}, {
key: "emitBindingAssignment",
value: function emitBindingAssignment(binding, value) {
this._addEntry({
args: [value],
buildNode: function buildNode(_ref5, context) {
var _ref6 = _slicedToArray(_ref5, 1),
valueNode = _ref6[0];
return t.expressionStatement(t.assignmentExpression("=", context.serializeBinding(binding), valueNode));
}
});
}
}, {
key: "emitPropertyAssignment",
value: function emitPropertyAssignment(object, key, value) {
if (object.refuseSerialization) return;
var propName = this.getAsPropertyNameExpression(key);
this._addEntry({
args: [object, value],
buildNode: function buildNode(_ref7) {
var _ref8 = _slicedToArray(_ref7, 2),
objectNode = _ref8[0],
valueNode = _ref8[1];
return t.expressionStatement(t.assignmentExpression("=", t.memberExpression(objectNode, propName, !t.isIdentifier(propName)), valueNode));
}
});
}
}, {
key: "emitDefineProperty",
value: function emitDefineProperty(object, key, desc) {
var isDescChanged = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
if (object.refuseSerialization) return;
if (desc.enumerable && desc.configurable && desc.writable && desc.value && !isDescChanged) {
var descValue = desc.value;
(0, _invariant2.default)(descValue instanceof _index.Value);
this.emitPropertyAssignment(object, key, descValue);
} else {
desc = Object.assign({}, desc);
var _descValue = desc.value || object.$Realm.intrinsics.undefined;
(0, _invariant2.default)(_descValue instanceof _index.Value);
this._addEntry({
args: [object, _descValue, desc.get || object.$Realm.intrinsics.undefined, desc.set || object.$Realm.intrinsics.undefined],
buildNode: function buildNode(_, context) {
return context.emitDefinePropertyBody(object, key, desc);
}
});
}
}
}, {
key: "emitPropertyDelete",
value: function emitPropertyDelete(object, key) {
if (object.refuseSerialization) return;
var propName = this.getAsPropertyNameExpression(key);
this._addEntry({
args: [object],
buildNode: function buildNode(_ref9) {
var _ref10 = _slicedToArray(_ref9, 1),
objectNode = _ref10[0];
return t.expressionStatement(t.unaryExpression("delete", t.memberExpression(objectNode, propName, !t.isIdentifier(propName))));
}
});
}
}, {
key: "emitCall",
value: function emitCall(createCallee, args) {
this._addEntry({
args: args,
buildNode: function buildNode(values) {
return t.expressionStatement(t.callExpression(createCallee(), [].concat(_toConsumableArray(values))));
}
});
}
}, {
key: "emitConsoleLog",
value: function emitConsoleLog(method, args) {
var _this3 = this;
this.emitCall(function () {
return t.memberExpression(t.identifier("console"), t.identifier(method));
}, args.map(function (v) {
return typeof v === "string" ? new _index.StringValue(_this3.realm, v) : v;
}));
}
// test must be a temporal value, which means that it must have a defined intrinsicName
}, {
key: "emitDoWhileStatement",
value: function emitDoWhileStatement(test, body) {
this._addEntry({
args: [],
buildNode: function buildNode(_ref11, context) {
var _ref12 = _toArray(_ref11);
var testId = test.intrinsicName;
(0, _invariant2.default)(testId !== undefined);
var statements = context.serializeGenerator(body);
var block = t.blockStatement(statements);
return t.doWhileStatement(t.identifier(testId), block);
},
dependencies: [body]
});
}
}, {
key: "emitInvariant",
value: function emitInvariant(args, violationConditionFn, appendLastToInvariantFn) {
if (this.realm.omitInvariants) return;
this._addEntry({
args: args,
buildNode: function buildNode(nodes) {
var throwString = t.stringLiteral("Prepack model invariant violation");
if (appendLastToInvariantFn) {
var last = nodes.pop();
throwString = t.binaryExpression("+", t.stringLiteral("Prepack model invariant violation: "), appendLastToInvariantFn(last));
}
var condition = violationConditionFn(nodes);
var throwblock = t.blockStatement([t.throwStatement(t.newExpression(t.identifier("Error"), [throwString]))]);
return t.ifStatement(condition, throwblock);
}
});
}
}, {
key: "emitCallAndCaptureResult",
value: function emitCallAndCaptureResult(types, values, createCallee, args, kind) {
return this.derive(types, values, args, function (nodes) {
return t.callExpression(createCallee(), nodes);
});
}
}, {
key: "emitStatement",
value: function emitStatement(args, buildNode_) {
this._addEntry({
args: args,
buildNode: buildNode_
});
}
}, {
key: "emitVoidExpression",
value: function emitVoidExpression(types, values, args, buildNode_) {
this._addEntry({
args: args,
buildNode: function buildNode(nodes) {
return t.expressionStatement(buildNode_ instanceof Function ? buildNode_(nodes) : buildNode_);
}
});
return this.realm.intrinsics.undefined;
}
}, {
key: "emitForInStatement",
value: function emitForInStatement(o, lh, sourceObject, targetObject, boundName) {
this._addEntry({
// duplicate args to ensure refcount > 1
args: [o, targetObject, sourceObject, targetObject, sourceObject],
buildNode: function buildNode(_ref13) {
var _ref14 = _slicedToArray(_ref13, 6),
obj = _ref14[0],
tgt = _ref14[1],
src = _ref14[2],
obj1 = _ref14[3],
tgt1 = _ref14[4],
src1 = _ref14[5];
return t.forInStatement(lh, obj, t.blockStatement([t.expressionStatement(t.assignmentExpression("=", t.memberExpression(tgt, boundName, true), t.memberExpression(src, boundName, true)))]));
}
});
}
}, {
key: "derive",
value: function derive(types, values, args, buildNode_, optionalArgs) {
(0, _invariant2.default)(buildNode_ instanceof Function || args.length === 0);
var id = t.identifier(this.preludeGenerator.nameGenerator.generate("derived"));
this.preludeGenerator.derivedIds.set(id.name, args);
var options = {};
if (optionalArgs && optionalArgs.kind) options.kind = optionalArgs.kind;
var Constructor = _index.Value.isTypeCompatibleWith(types.getType(), _index.ObjectValue) ? _index.AbstractObjectValue : _index.AbstractValue;
var res = new Constructor(this.realm, types, values, 0, [], id, options);
this._addEntry({
isPure: optionalArgs ? optionalArgs.isPure : undefined,
declared: res,
args: args,
buildNode: function buildNode(nodes, context) {
return t.variableDeclaration("var", [t.variableDeclarator(id, buildNode_ instanceof Function ? buildNode_(nodes, context) : buildNode_)]);
}
});
var type = types.getType();
res.intrinsicName = id.name;
if (optionalArgs && optionalArgs.skipInvariant) return res;
var typeofString = void 0;
if (type instanceof _index.FunctionValue) typeofString = "function";else if (type === _index.UndefinedValue) (0, _invariant2.default)(false);else if (type === _index.NullValue) (0, _invariant2.default)(false);else if (type === _index.StringValue) typeofString = "string";else if (type === _index.BooleanValue) typeofString = "boolean";else if (type === _index.NumberValue) typeofString = "number";else if (type === _index.SymbolValue) typeofString = "symbol";else if (type === _index.ObjectValue) typeofString = "object";
if (typeofString !== undefined) {
// Verify that the types are as expected, a failure of this invariant
// should mean the model is wrong.
this.emitInvariant([res, res], function (nodes) {
(0, _invariant2.default)(typeofString !== undefined);
var condition = t.binaryExpression("!==", t.unaryExpression("typeof", nodes[0]), t.stringLiteral(typeofString));
if (typeofString === "object") {
condition = t.logicalExpression("&&", condition, t.binaryExpression("!==", t.unaryExpression("typeof", nodes[0]), t.stringLiteral("function")));
condition = t.logicalExpression("||", condition, t.binaryExpression("===", nodes[0], _internalizer.nullExpression));
}
return condition;
}, function (node) {
return node;
});
}
return res;
}
}, {
key: "serialize",
value: function serialize(context) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this._entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var entry = _step.value;
if (!entry.isPure || !entry.declared || !context.canOmit(entry.declared)) {
var nodes = entry.args.map(function (boundArg, i) {
return context.serializeValue(boundArg);
});
if (entry.buildNode) context.emit(entry.buildNode(nodes, context));
if (entry.declared !== undefined) context.declare(entry.declared);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
}, {
key: "visitEntry",
value: function visitEntry(entry, callbacks) {
if (entry.isPure && entry.declared && callbacks.canSkip(entry.declared)) {
callbacks.recordDelayedEntry(entry);
} else {
if (entry.declared) callbacks.recordDeclaration(entry.declared);
callbacks.visitValues(entry.args);
if (entry.dependencies) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = entry.dependencies[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var dependency = _step2.value;
callbacks.visitGenerator(dependency);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
}
}
}, {
key: "visit",
value: function visit(callbacks) {
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = this._entries[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var entry = _step3.value;
this.visitEntry(entry, callbacks);
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
}
}, {
key: "_addEntry",
value: function _addEntry(entry) {
this._entries.push(entry);
}
}, {
key: "appendGenerator",
value: function appendGenerator(other, leadingComment) {
if (other.empty()) return;
this._addEntry({
args: [],
buildNode: function buildNode(args, context) {
var statements = context.serializeGenerator(other);
var block = t.blockStatement(statements);
if (leadingComment.length > 0) block.leadingComments = [{ type: "BlockComment", value: leadingComment }];
return block;
},
dependencies: [other]
});
}
}, {
key: "composeGenerators",
value: function composeGenerators(generator1, generator2) {
this._addEntry({
args: [],
buildNode: function buildNode(_ref15, context) {
var _ref16 = _toArray(_ref15);
var statements = [];
if (!generator1.empty()) statements.push(serializeBody(generator1, context));
if (!generator2.empty()) statements.push(serializeBody(generator2, context));
return t.blockStatement(statements);
},
dependencies: [generator1, generator2]
});
}
}, {
key: "joinGenerators",
value: function joinGenerators(joinCondition, generator1, generator2) {
this._addEntry({
args: [joinCondition],
buildNode: function buildNode(_ref17, context) {
var _ref18 = _slicedToArray(_ref17, 1),
cond = _ref18[0];
var block1 = generator1.empty() ? null : serializeBody(generator1, context);
var block2 = generator2.empty() ? null : serializeBody(generator2, context);
if (block1) return t.ifStatement(cond, block1, block2);
(0, _invariant2.default)(block2);
return t.ifStatement(t.unaryExpression("!", cond), block2);
},
dependencies: [generator1, generator2]
});
}
}]);
return Generator;
}();
// some characters are invalid within a JavaScript identifier,
// such as: . , : ( ) ' " ` [ ] -
// so we replace these character instacnes with an underscore
function replaceInvalidCharactersWithUnderscore(string) {
return string.replace(/[.,:\(\)\"\'\`\[\]\-]/g, "_");
}
var NameGenerator = exports.NameGenerator = function () {
function NameGenerator(forbiddenNames, debugNames, uniqueSuffix, prefix) {
_classCallCheck(this, NameGenerator);
this.prefix = prefix;
this.uidCounter = 0;
this.debugNames = debugNames;
this.forbiddenNames = forbiddenNames;
this.uniqueSuffix = uniqueSuffix;
}
_createClass(NameGenerator, [{
key: "generate",
value: function generate(debugSuffix) {
var id = void 0;
do {
id = this.prefix + base62.encode(this.uidCounter++);
if (this.uniqueSuffix.length > 0) id += this.uniqueSuffix;
if (this.debugNames) {
if (debugSuffix) id += "_" + replaceInvalidCharactersWithUnderscore(debugSuffix);else id += "_";
}
} while (this.forbiddenNames.has(id));
return id;
}
}]);
return NameGenerator;
}();
var PreludeGenerator = exports.PreludeGenerator = function () {
function PreludeGenerator(debugNames, uniqueSuffix) {
_classCallCheck(this, PreludeGenerator);
this.prelude = [];
this.derivedIds = new Map();
this.memoizedRefs = new Map();
this.nameGenerator = new NameGenerator(new Set(), !!debugNames, uniqueSuffix || "", "_$");
this.usesThis = false;
this.declaredGlobals = new Set();
}
_createClass(PreludeGenerator, [{
key: "createNameGenerator",
value: function createNameGenerator(prefix) {
return new NameGenerator(this.nameGenerator.forbiddenNames, this.nameGenerator.debugNames, this.nameGenerator.uniqueSuffix, prefix);
}
}, {
key: "convertStringToMember",
value: function convertStringToMember(str) {
var _this4 = this;
return str.split(".").map(function (name) {
return name === "global" ? _this4.memoizeReference(name) : t.identifier(name);
}).reduce(function (obj, prop) {
return t.memberExpression(obj, prop);
});
}
}, {
key: "globalReference",
value: function globalReference(key) {
var globalScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
if (globalScope && t.isValidIdentifier(key)) return t.identifier(key);
var keyNode = t.isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);
return t.memberExpression(this.memoizeReference("global"), keyNode, !t.isIdentifier(keyNode));
}
}, {
key: "memoizeReference",
value: function memoizeReference(key) {
var ref = this.memoizedRefs.get(key);
if (ref) return ref;
var init = void 0;
if (key.includes("(") || key.includes("[")) {
// Horrible but effective hack:
// Some internal object have intrinsic names such as
// ([][Symbol.iterator]().__proto__.__proto__)
// and
// RegExp.prototype[Symbol.match]
// which get turned into a babel node here.
// TODO: We should properly parse such a string, and memoize all references in it separately.
// Instead, we just turn it into a funky identifier, which Babel seems to accept.
init = t.identifier(key);
} else if (key === "global") {
this.usesThis = true;
init = t.thisExpression();
} else {
var i = key.lastIndexOf(".");
if (i === -1) {
init = t.memberExpression(this.memoizeReference("global"), t.identifier(key));
} else {
init = t.memberExpression(this.memoizeReference(key.substr(0, i)), t.identifier(key.substr(i + 1)));
}
}
ref = t.identifier(this.nameGenerator.generate(key));
this.prelude.push(t.variableDeclaration("var", [t.variableDeclarator(ref, init)]));
this.memoizedRefs.set(key, ref);
return ref;
}
}]);
return PreludeGenerator;
}();
//# sourceMappingURL=generator.js.map

File diff suppressed because one or more lines are too long

28
build/node_modules/prepack/lib/utils/internalizer.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.protoExpression = exports.constructorExpression = exports.emptyExpression = exports.nullExpression = exports.voidExpression = undefined;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
var voidExpression = exports.voidExpression = t.unaryExpression("void", t.numericLiteral(0), true);
var nullExpression = exports.nullExpression = t.nullLiteral();
var emptyExpression = exports.emptyExpression = t.identifier("__empty");
var constructorExpression = exports.constructorExpression = t.identifier("__constructor");
var protoExpression = exports.protoExpression = t.identifier("__proto__");
//# sourceMappingURL=internalizer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/internalizer.js"],"names":["t","voidExpression","unaryExpression","numericLiteral","nullExpression","nullLiteral","emptyExpression","identifier","constructorExpression","protoExpression"],"mappings":";;;;;;;AAYA;;IAAYA,C;;;;AAZZ;;;;;;;;;AAcO,IAAMC,0CAAsCD,EAAEE,eAAF,CAAkB,MAAlB,EAA0BF,EAAEG,cAAF,CAAiB,CAAjB,CAA1B,EAA+C,IAA/C,CAA5C;AACA,IAAMC,0CAAsCJ,EAAEK,WAAF,EAA5C;AACA,IAAMC,4CAAuCN,EAAEO,UAAF,CAAa,SAAb,CAA7C;AACA,IAAMC,wDAA6CR,EAAEO,UAAF,CAAa,eAAb,CAAnD;AACA,IAAME,4CAAuCT,EAAEO,UAAF,CAAa,WAAb,CAA7C","file":"internalizer.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { BabelNodeExpression } from \"babel-types\";\nimport * as t from \"babel-types\";\n\nexport const voidExpression: BabelNodeExpression = t.unaryExpression(\"void\", t.numericLiteral(0), true);\nexport const nullExpression: BabelNodeExpression = t.nullLiteral();\nexport const emptyExpression: BabelNodeIdentifier = t.identifier(\"__empty\");\nexport const constructorExpression: BabelNodeIdentifier = t.identifier(\"__constructor\");\nexport const protoExpression: BabelNodeIdentifier = t.identifier(\"__proto__\");\n"]}

60
build/node_modules/prepack/lib/utils/json.js generated vendored Normal file
View File

@@ -0,0 +1,60 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.mergeAdacentJSONTextNodes = mergeAdacentJSONTextNodes;
// this will mutate the original JSON object
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function mergeAdacentJSONTextNodes(node) {
// we merge adjacent text nodes
if (Array.isArray(node)) {
// we create a new array rather than mutating the original
var arr = [];
var length = node.length;
var concatString = null;
var i = -1;
while (i++ < length) {
var child = node[i];
if (typeof child === "string" || typeof child === "number") {
if (concatString !== null) {
concatString += child;
} else {
concatString = child;
}
} else if ((typeof child === "undefined" ? "undefined" : _typeof(child)) === "object" && child !== null) {
if (concatString !== null) {
arr.push(concatString);
concatString = null;
}
arr.push(mergeAdacentJSONTextNodes(child));
}
}
if (concatString !== null) {
arr.push(concatString);
}
return arr;
} else {
for (var _key in node) {
var value = node[_key];
if ((typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && value !== null) {
node[_key] = mergeAdacentJSONTextNodes(value);
}
}
}
return node;
}
//# sourceMappingURL=json.js.map

1
build/node_modules/prepack/lib/utils/json.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/json.js"],"names":["mergeAdacentJSONTextNodes","node","Array","isArray","arr","length","concatString","i","child","push","key","value"],"mappings":";;;;;;;;QAcgBA,yB,GAAAA,yB;;;AADhB;AAbA;;;;;;;;;AAcO,SAASA,yBAAT,CAAmCC,IAAnC,EAA+C;AACpD;AACA,MAAIC,MAAMC,OAAN,CAAcF,IAAd,CAAJ,EAAyB;AACvB;AACA,QAAIG,MAAM,EAAV;AACA,QAAIC,SAASJ,KAAKI,MAAlB;AACA,QAAIC,eAAe,IAAnB;AACA,QAAIC,IAAI,CAAC,CAAT;AACA,WAAOA,MAAMF,MAAb,EAAqB;AACnB,UAAIG,QAAQP,KAAKM,CAAL,CAAZ;AACA,UAAI,OAAOC,KAAP,KAAiB,QAAjB,IAA6B,OAAOA,KAAP,KAAiB,QAAlD,EAA4D;AAC1D,YAAIF,iBAAiB,IAArB,EAA2B;AACzBA,0BAAgBE,KAAhB;AACD,SAFD,MAEO;AACLF,yBAAeE,KAAf;AACD;AACF,OAND,MAMO,IAAI,QAAOA,KAAP,yCAAOA,KAAP,OAAiB,QAAjB,IAA6BA,UAAU,IAA3C,EAAiD;AACtD,YAAIF,iBAAiB,IAArB,EAA2B;AACzBF,cAAIK,IAAJ,CAASH,YAAT;AACAA,yBAAe,IAAf;AACD;AACDF,YAAIK,IAAJ,CAAST,0BAA0BQ,KAA1B,CAAT;AACD;AACF;AACD,QAAIF,iBAAiB,IAArB,EAA2B;AACzBF,UAAIK,IAAJ,CAASH,YAAT;AACD;AACD,WAAOF,GAAP;AACD,GA1BD,MA0BO;AACL,SAAK,IAAIM,IAAT,IAAgBT,IAAhB,EAAsB;AACpB,UAAIU,QAAQV,KAAKS,IAAL,CAAZ;AACA,UAAI,QAAOC,KAAP,yCAAOA,KAAP,OAAiB,QAAjB,IAA6BA,UAAU,IAA3C,EAAiD;AAC/CV,aAAKS,IAAL,IAAYV,0BAA4BW,KAA5B,CAAZ;AACD;AACF;AACF;AACD,SAAOV,IAAP;AACD","file":"json.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\ntype JSONValue = Array<JSONValue> | string | number | JSON;\ntype JSON = { [key: string]: JSONValue };\n\n// this will mutate the original JSON object\nexport function mergeAdacentJSONTextNodes(node: JSON) {\n // we merge adjacent text nodes\n if (Array.isArray(node)) {\n // we create a new array rather than mutating the original\n let arr = [];\n let length = node.length;\n let concatString = null;\n let i = -1;\n while (i++ < length) {\n let child = node[i];\n if (typeof child === \"string\" || typeof child === \"number\") {\n if (concatString !== null) {\n concatString += child;\n } else {\n concatString = child;\n }\n } else if (typeof child === \"object\" && child !== null) {\n if (concatString !== null) {\n arr.push(concatString);\n concatString = null;\n }\n arr.push(mergeAdacentJSONTextNodes(child));\n }\n }\n if (concatString !== null) {\n arr.push(concatString);\n }\n return arr;\n } else {\n for (let key in node) {\n let value = node[key];\n if (typeof value === \"object\" && value !== null) {\n node[key] = mergeAdacentJSONTextNodes(((value: any): JSON));\n }\n }\n }\n return node;\n}\n"]}

548
build/node_modules/prepack/lib/utils/leak.js generated vendored Normal file
View File

@@ -0,0 +1,548 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LeakImplementation = undefined;
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
var _errors = require("../errors.js");
var _environment = require("../environment.js");
var _index = require("../values/index.js");
var _index2 = require("../methods/index.js");
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _babelTraverse = require("babel-traverse");
var _babelTraverse2 = _interopRequireDefault(_babelTraverse);
var _invariant = require("../invariant.js");
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function visitName(path, state, name, read, write) {
// Is the name bound to some local identifier? If so, we don't need to do anything
if (path.scope.hasBinding(name, /*noGlobals*/true)) return;
// Otherwise, let's record that there's an unbound identifier
if (read) state.unboundReads.add(name);
if (write) state.unboundWrites.add(name);
}
function ignorePath(path) {
var parent = path.parent;
return t.isLabeledStatement(parent) || t.isBreakStatement(parent) || t.isContinueStatement(parent);
}
var LeakedClosureRefVisitor = {
ReferencedIdentifier: function ReferencedIdentifier(path, state) {
if (ignorePath(path)) return;
var innerName = path.node.name;
if (innerName === "arguments") {
return;
}
visitName(path, state, innerName, true, false);
},
"AssignmentExpression|UpdateExpression": function AssignmentExpressionUpdateExpression(path, state) {
var doesRead = path.node.operator !== "=";
for (var name in path.getBindingIdentifiers()) {
visitName(path, state, name, doesRead, true);
}
}
};
function getLeakedFunctionInfo(value) {
// TODO: This should really be cached on a per AST basis in case we have
// many uses of the same closure. It should ideally share this cache
// and data with ResidualHeapVisitor.
(0, _invariant2.default)(value instanceof _index.ECMAScriptSourceFunctionValue);
(0, _invariant2.default)(value.constructor === _index.ECMAScriptSourceFunctionValue);
var functionInfo = {
unboundReads: new Set(),
unboundWrites: new Set()
};
var formalParameters = value.$FormalParameters;
(0, _invariant2.default)(formalParameters != null);
var code = value.$ECMAScriptCode;
(0, _invariant2.default)(code != null);
(0, _babelTraverse2.default)(t.file(t.program([t.expressionStatement(t.functionExpression(null, formalParameters, code))])), LeakedClosureRefVisitor, null, functionInfo);
return functionInfo;
}
var ObjectValueLeakingVisitor = function () {
// ObjectValues to visit if they're reachable.
function ObjectValueLeakingVisitor(objectsTrackedForLeaks) {
_classCallCheck(this, ObjectValueLeakingVisitor);
this.objectsTrackedForLeaks = objectsTrackedForLeaks;
this.visitedValues = new Set();
}
// Values that has been visited.
_createClass(ObjectValueLeakingVisitor, [{
key: "mustVisit",
value: function mustVisit(val) {
if (val instanceof _index.ObjectValue) {
// For Objects we only need to visit it if it is tracked
// as a newly created object that might still be mutated.
// Abstract values gets their arguments visited.
if (!this.objectsTrackedForLeaks.has(val)) return false;
}
if (this.visitedValues.has(val)) return false;
this.visitedValues.add(val);
return true;
}
}, {
key: "visitObjectProperty",
value: function visitObjectProperty(binding) {
var desc = binding.descriptor;
if (desc === undefined) return; //deleted
this.visitDescriptor(desc);
}
}, {
key: "visitObjectProperties",
value: function visitObjectProperties(obj, kind) {
// visit symbol properties
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = obj.symbols[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _ref = _step.value;
var _ref2 = _slicedToArray(_ref, 2);
var propertyBindingValue = _ref2[1];
(0, _invariant2.default)(propertyBindingValue);
this.visitObjectProperty(propertyBindingValue);
}
// visit string properties
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = obj.properties[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _ref3 = _step2.value;
var _ref4 = _slicedToArray(_ref3, 2);
var _propertyBindingValue = _ref4[1];
(0, _invariant2.default)(_propertyBindingValue);
this.visitObjectProperty(_propertyBindingValue);
}
// inject properties with computed names
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
if (obj.unknownProperty !== undefined) {
var desc = obj.unknownProperty.descriptor;
if (desc !== undefined) {
var val = desc.value;
(0, _invariant2.default)(val instanceof _index.AbstractValue);
this.visitObjectPropertiesWithComputedNames(val);
}
}
// prototype
this.visitObjectPrototype(obj);
// if this object wasn't already leaked, we need mark it as leaked
// so that any mutation and property access get tracked after this.
if (!obj.isLeakedObject()) {
obj.leak();
}
}
}, {
key: "visitObjectPrototype",
value: function visitObjectPrototype(obj) {
var proto = obj.$Prototype;
this.visitValue(proto);
}
}, {
key: "visitObjectPropertiesWithComputedNames",
value: function visitObjectPropertiesWithComputedNames(absVal) {
(0, _invariant2.default)(absVal.args.length === 3);
var cond = absVal.args[0];
(0, _invariant2.default)(cond instanceof _index.AbstractValue);
if (cond.kind === "template for property name condition") {
var P = cond.args[0];
(0, _invariant2.default)(P instanceof _index.AbstractValue);
var V = absVal.args[1];
var earlier_props = absVal.args[2];
if (earlier_props instanceof _index.AbstractValue) this.visitObjectPropertiesWithComputedNames(earlier_props);
this.visitValue(P);
this.visitValue(V);
} else {
// conditional assignment
this.visitValue(cond);
var consequent = absVal.args[1];
(0, _invariant2.default)(consequent instanceof _index.AbstractValue);
var alternate = absVal.args[2];
(0, _invariant2.default)(alternate instanceof _index.AbstractValue);
this.visitObjectPropertiesWithComputedNames(consequent);
this.visitObjectPropertiesWithComputedNames(alternate);
}
}
}, {
key: "visitDescriptor",
value: function visitDescriptor(desc) {
(0, _invariant2.default)(desc.value === undefined || desc.value instanceof _index.Value);
if (desc.value !== undefined) this.visitValue(desc.value);
if (desc.get !== undefined) this.visitValue(desc.get);
if (desc.set !== undefined) this.visitValue(desc.set);
}
}, {
key: "visitDeclarativeEnvironmentRecordBinding",
value: function visitDeclarativeEnvironmentRecordBinding(record, remainingLeakedBindings) {
var bindings = record.bindings;
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = Object.keys(bindings)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var bindingName = _step3.value;
var binding = bindings[bindingName];
// Check if this binding is referenced, and if so delete it from the set.
var isRead = remainingLeakedBindings.unboundReads.delete(bindingName);
var isWritten = remainingLeakedBindings.unboundWrites.delete(bindingName);
if (isRead) {
// If this binding can be read from the closure, its value has now leaked.
var value = binding.value;
if (value) {
this.visitValue(value);
}
}
if (isWritten || isRead) {
// If this binding could have been mutated from the closure, then the
// binding itself has now leaked, but not necessarily the value in it.
// TODO: We could tag a leaked binding as read and/or write. That way
// we don't have to leak values written to this binding if only writes
// have leaked. We also don't have to leak reads from this binding
// if it is only read from.
(0, _environment.leakBinding)(binding);
}
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
}
}, {
key: "visitValueMap",
value: function visitValueMap(val) {
var kind = val.getKind();
var entries = void 0;
if (kind === "Map") {
entries = val.$MapData;
} else {
(0, _invariant2.default)(kind === "WeakMap");
entries = val.$WeakMapData;
}
(0, _invariant2.default)(entries !== undefined);
var len = entries.length;
for (var i = 0; i < len; i++) {
var entry = entries[i];
var key = entry.$Key;
var value = entry.$Value;
if (key === undefined || value === undefined) continue;
this.visitValue(key);
this.visitValue(value);
}
}
}, {
key: "visitValueSet",
value: function visitValueSet(val) {
var kind = val.getKind();
var entries = void 0;
if (kind === "Set") {
entries = val.$SetData;
} else {
(0, _invariant2.default)(kind === "WeakSet");
entries = val.$WeakSetData;
}
(0, _invariant2.default)(entries !== undefined);
var len = entries.length;
for (var i = 0; i < len; i++) {
var entry = entries[i];
if (entry === undefined) continue;
this.visitValue(entry);
}
}
}, {
key: "visitValueFunction",
value: function visitValueFunction(val) {
if (val.isLeakedObject()) {
return;
}
this.visitObjectProperties(val);
if (val instanceof _index.BoundFunctionValue) {
this.visitValue(val.$BoundTargetFunction);
this.visitValue(val.$BoundThis);
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = val.$BoundArguments[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var boundArg = _step4.value;
this.visitValue(boundArg);
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
return;
}
(0, _invariant2.default)(!(val instanceof _index.NativeFunctionValue), "all native function values should have already been created outside this pure function");
var remainingLeakedBindings = getLeakedFunctionInfo(val);
var environment = val.$Environment.parent;
while (environment) {
var record = environment.environmentRecord;
if (record instanceof _environment.ObjectEnvironmentRecord) {
this.visitValue(record.object);
continue;
}
(0, _invariant2.default)(!(record instanceof _environment.GlobalEnvironmentRecord), "we should never reach the global scope because it is never newly created in a pure function.");
(0, _invariant2.default)(record instanceof _environment.DeclarativeEnvironmentRecord);
this.visitDeclarativeEnvironmentRecordBinding(record, remainingLeakedBindings);
if (record instanceof _environment.FunctionEnvironmentRecord) {
// If this is a function environment, which is not tracked for leaks,
// we can bail out because its bindings should not be mutated in a
// pure function.
var fn = record.$FunctionObject;
if (!this.objectsTrackedForLeaks.has(fn)) {
break;
}
}
environment = environment.parent;
}
}
}, {
key: "visitValueObject",
value: function visitValueObject(val) {
if (val.isLeakedObject()) {
return;
}
var kind = val.getKind();
this.visitObjectProperties(val, kind);
switch (kind) {
case "RegExp":
case "Number":
case "String":
case "Boolean":
case "ReactElement":
case "ArrayBuffer":
return;
case "Date":
var dateValue = val.$DateValue;
(0, _invariant2.default)(dateValue !== undefined);
this.visitValue(dateValue);
return;
case "Float32Array":
case "Float64Array":
case "Int8Array":
case "Int16Array":
case "Int32Array":
case "Uint8Array":
case "Uint16Array":
case "Uint32Array":
case "Uint8ClampedArray":
case "DataView":
var buf = val.$ViewedArrayBuffer;
(0, _invariant2.default)(buf !== undefined);
this.visitValue(buf);
return;
case "Map":
case "WeakMap":
this.visitValueMap(val);
return;
case "Set":
case "WeakSet":
this.visitValueSet(val);
return;
default:
(0, _invariant2.default)(kind === "Object", "Object of kind " + kind + " is not supported in calls to abstract functions.");
(0, _invariant2.default)(this.$ParameterMap === undefined, "Arguments object is not supported in calls to abstract functions.");
return;
}
}
}, {
key: "visitValueProxy",
value: function visitValueProxy(val) {
this.visitValue(val.$ProxyTarget);
this.visitValue(val.$ProxyHandler);
}
}, {
key: "visitAbstractValue",
value: function visitAbstractValue(val) {
for (var i = 0, n = val.args.length; i < n; i++) {
this.visitValue(val.args[i]);
}
}
}, {
key: "visitValue",
value: function visitValue(val) {
if (val instanceof _index.AbstractValue) {
if (this.mustVisit(val)) this.visitAbstractValue(val);
} else if (val.isIntrinsic()) {
// All intrinsic values exist from the beginning of time...
// ...except for a few that come into existance as templates for abstract objects (TODO #882).
this.mustVisit(val);
} else if (val instanceof _index.EmptyValue) {
this.mustVisit(val);
} else if (val instanceof _index.PrimitiveValue) {
this.mustVisit(val);
} else if (val instanceof _index.ProxyValue) {
if (this.mustVisit(val)) this.visitValueProxy(val);
} else if (val instanceof _index.FunctionValue) {
(0, _invariant2.default)(val instanceof _index.FunctionValue);
if (this.mustVisit(val)) this.visitValueFunction(val);
} else {
(0, _invariant2.default)(val instanceof _index.ObjectValue);
if (val.originalConstructor !== undefined) {
(0, _invariant2.default)(val instanceof _index.ObjectValue);
if (this.mustVisit(val)) this.visitValueObject(val);
} else {
if (this.mustVisit(val)) this.visitValueObject(val);
}
}
}
}]);
return ObjectValueLeakingVisitor;
}();
function ensureFrozenValue(realm, value, loc) {
// TODO: This should really check if it is recursively immutability.
if (value instanceof _index.ObjectValue && !(0, _index2.TestIntegrityLevel)(realm, value, "frozen")) {
var diag = new _errors.CompilerDiagnostic("Unfrozen object leaked before end of global code", loc || realm.currentLocation, "PP0017", "RecoverableError");
if (realm.handleError(diag) !== "Recover") throw new _errors.FatalError();
}
}
// Ensure that a value is immutable. If it is not, set all its properties to abstract values
// and all reachable bindings to abstract values.
var LeakImplementation = exports.LeakImplementation = function () {
function LeakImplementation() {
_classCallCheck(this, LeakImplementation);
}
_createClass(LeakImplementation, [{
key: "leakValue",
value: function leakValue(realm, value, loc) {
var objectsTrackedForLeaks = realm.createdObjectsTrackedForLeaks;
if (objectsTrackedForLeaks === undefined) {
// We're not tracking a pure function. That means that we would track
// everything as leaked. We'll assume that any object argument
// is invalid unless it's frozen.
ensureFrozenValue(realm, value, loc);
} else {
// If we're tracking a pure function, we can assume that only newly
// created objects and bindings, within it, are mutable. Any other
// object can safely be assumed to be deeply immutable as far as this
// pure function is concerned. However, any mutable object needs to
// be tainted as possibly having changed to anything.
var visitor = new ObjectValueLeakingVisitor(objectsTrackedForLeaks);
visitor.visitValue(value);
}
}
}]);
return LeakImplementation;
}();
//# sourceMappingURL=leak.js.map

1
build/node_modules/prepack/lib/utils/leak.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
exports.default = convert;
var _errors = require("../errors.js");
var _index = require("../values/index.js");
var _singletons = require("../singletons.js");
function convert(realm, val) {
if (typeof val === "number") {
return new _index.NumberValue(realm, val);
} else if (typeof val === "string") {
return new _index.StringValue(realm, val);
} else if (val === null) {
return realm.intrinsics.null;
} else if (val === undefined) {
return realm.intrinsics.undefined;
} else if (val === true) {
return realm.intrinsics.true;
} else if (val === false) {
return realm.intrinsics.false;
} else if (Array.isArray(val)) {
return _singletons.Create.CreateArrayFromList(realm, val.map(function (item) {
return convert(realm, item);
}));
} else if ((typeof val === "undefined" ? "undefined" : _typeof(val)) === "object") {
var obj = new _index.ObjectValue(realm, realm.intrinsics.ObjectPrototype);
for (var key in val) {
obj.$DefineOwnProperty(key, {
enumerable: true,
writable: true,
configurable: true,
value: convert(realm, val[key])
});
}
return obj;
} else {
throw new _errors.FatalError("need to convert value of type " + (typeof val === "undefined" ? "undefined" : _typeof(val)));
}
}
//# sourceMappingURL=native-to-interp.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/native-to-interp.js"],"names":["convert","realm","val","intrinsics","null","undefined","true","false","Array","isArray","CreateArrayFromList","map","item","obj","ObjectPrototype","key","$DefineOwnProperty","enumerable","writable","configurable","value"],"mappings":";;;;;;8QAAA;;;;;;;;;kBAgBwBA,O;;AAJxB;;AACA;;AACA;;AAEe,SAASA,OAAT,CAAiBC,KAAjB,EAA+BC,GAA/B,EAAgD;AAC7D,MAAI,OAAOA,GAAP,KAAe,QAAnB,EAA6B;AAC3B,WAAO,uBAAgBD,KAAhB,EAAuBC,GAAvB,CAAP;AACD,GAFD,MAEO,IAAI,OAAOA,GAAP,KAAe,QAAnB,EAA6B;AAClC,WAAO,uBAAgBD,KAAhB,EAAuBC,GAAvB,CAAP;AACD,GAFM,MAEA,IAAIA,QAAQ,IAAZ,EAAkB;AACvB,WAAOD,MAAME,UAAN,CAAiBC,IAAxB;AACD,GAFM,MAEA,IAAIF,QAAQG,SAAZ,EAAuB;AAC5B,WAAOJ,MAAME,UAAN,CAAiBE,SAAxB;AACD,GAFM,MAEA,IAAIH,QAAQ,IAAZ,EAAkB;AACvB,WAAOD,MAAME,UAAN,CAAiBG,IAAxB;AACD,GAFM,MAEA,IAAIJ,QAAQ,KAAZ,EAAmB;AACxB,WAAOD,MAAME,UAAN,CAAiBI,KAAxB;AACD,GAFM,MAEA,IAAIC,MAAMC,OAAN,CAAcP,GAAd,CAAJ,EAAwB;AAC7B,WAAO,mBAAOQ,mBAAP,CAA2BT,KAA3B,EAAkCC,IAAIS,GAAJ,CAAQ;AAAA,aAAQX,QAAQC,KAAR,EAAeW,IAAf,CAAR;AAAA,KAAR,CAAlC,CAAP;AACD,GAFM,MAEA,IAAI,QAAOV,GAAP,yCAAOA,GAAP,OAAe,QAAnB,EAA6B;AAClC,QAAIW,MAAM,uBAAgBZ,KAAhB,EAAuBA,MAAME,UAAN,CAAiBW,eAAxC,CAAV;;AAEA,SAAK,IAAIC,GAAT,IAAgBb,GAAhB,EAAqB;AACnBW,UAAIG,kBAAJ,CAAuBD,GAAvB,EAA4B;AAC1BE,oBAAY,IADc;AAE1BC,kBAAU,IAFgB;AAG1BC,sBAAc,IAHY;AAI1BC,eAAOpB,QAAQC,KAAR,EAAeC,IAAIa,GAAJ,CAAf;AAJmB,OAA5B;AAMD;;AAED,WAAOF,GAAP;AACD,GAbM,MAaA;AACL,UAAM,uBAAe,2CAA0CX,GAA1C,yCAA0CA,GAA1C,EAAf,CAAN;AACD;AACF","file":"native-to-interp.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { Realm } from \"../realm.js\";\nimport { FatalError } from \"../errors.js\";\nimport { Value, StringValue, NumberValue, ObjectValue } from \"../values/index.js\";\nimport { Create } from \"../singletons.js\";\n\nexport default function convert(realm: Realm, val: any): Value {\n if (typeof val === \"number\") {\n return new NumberValue(realm, val);\n } else if (typeof val === \"string\") {\n return new StringValue(realm, val);\n } else if (val === null) {\n return realm.intrinsics.null;\n } else if (val === undefined) {\n return realm.intrinsics.undefined;\n } else if (val === true) {\n return realm.intrinsics.true;\n } else if (val === false) {\n return realm.intrinsics.false;\n } else if (Array.isArray(val)) {\n return Create.CreateArrayFromList(realm, val.map(item => convert(realm, item)));\n } else if (typeof val === \"object\") {\n let obj = new ObjectValue(realm, realm.intrinsics.ObjectPrototype);\n\n for (let key in val) {\n obj.$DefineOwnProperty(key, {\n enumerable: true,\n writable: true,\n configurable: true,\n value: convert(realm, val[key]),\n });\n }\n\n return obj;\n } else {\n throw new FatalError(\"need to convert value of type \" + typeof val);\n }\n}\n"]}

74
build/node_modules/prepack/lib/utils/parse.js generated vendored Normal file
View File

@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (realm, code, filename) {
var sourceType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "script";
var startLine = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
try {
var plugins = [];
if (realm.react.enabled) {
plugins.push("jsx");
if (realm.react.flowRequired) {
plugins.push("flow");
}
}
var ast = (0, _babylon.parse)(code, { filename: filename, sourceType: sourceType, startLine: startLine, plugins: plugins });
(0, _traverseFast2.default)(ast, function (node) {
(0, _invariant2.default)(node.loc);
node.loc.source = filename;
return false;
});
return ast;
} catch (e) {
if (e instanceof SyntaxError) {
// Babel reports all errors as syntax errors, even if a ReferenceError should be thrown.
// What we do here is a totally robust way to address that issue.
var referenceErrors = ["Invalid left-hand side in postfix operation", "Invalid left-hand side in prefix operation", "Invalid left-hand side in assignment expression"];
var error = void 0;
if (referenceErrors.some(function (msg) {
return e.message.indexOf(msg) >= 0;
})) {
error = (0, _construct.Construct)(realm, realm.intrinsics.ReferenceError, [new _index.StringValue(realm, e.message)]);
} else {
error = (0, _construct.Construct)(realm, realm.intrinsics.SyntaxError, [new _index.StringValue(realm, e.message)]);
}
// These constructors are currently guaranteed to produce an object with
// built-in error data. Append location information about the syntax error
// and the source code to it so that we can use it to print nicer errors.
(0, _invariant2.default)(error.$ErrorData);
error.$ErrorData.locationData = {
filename: filename,
sourceCode: code,
loc: e.loc,
stackDecorated: false
};
throw new _completions.ThrowCompletion(error, e.loc);
} else {
throw e;
}
}
};
var _invariant = require("../invariant.js");
var _invariant2 = _interopRequireDefault(_invariant);
var _completions = require("../completions.js");
var _index = require("../values/index.js");
var _construct = require("../methods/construct.js");
var _traverseFast = require("../utils/traverse-fast.js");
var _traverseFast2 = _interopRequireDefault(_traverseFast);
var _babylon = require("babylon");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=parse.js.map

1
build/node_modules/prepack/lib/utils/parse.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/parse.js"],"names":["realm","code","filename","sourceType","startLine","plugins","react","enabled","push","flowRequired","ast","node","loc","source","e","SyntaxError","referenceErrors","error","some","message","indexOf","msg","intrinsics","ReferenceError","$ErrorData","locationData","sourceCode","stackDecorated"],"mappings":";;;;;;kBAqBe,UACbA,KADa,EAEbC,IAFa,EAGbC,QAHa,EAME;AAAA,MAFfC,UAEe,uEAFU,QAEV;AAAA,MADfC,SACe,uEADK,CACL;;AACf,MAAI;AACF,QAAIC,UAAU,EAAd;AACA,QAAIL,MAAMM,KAAN,CAAYC,OAAhB,EAAyB;AACvBF,cAAQG,IAAR,CAAa,KAAb;AACA,UAAIR,MAAMM,KAAN,CAAYG,YAAhB,EAA8B;AAC5BJ,gBAAQG,IAAR,CAAa,MAAb;AACD;AACF;AACD,QAAIE,MAAM,oBAAMT,IAAN,EAAY,EAAEC,kBAAF,EAAYC,sBAAZ,EAAwBC,oBAAxB,EAAmCC,gBAAnC,EAAZ,CAAV;AACA,gCAAaK,GAAb,EAAkB,gBAAQ;AACxB,+BAAUC,KAAKC,GAAf;AACAD,WAAKC,GAAL,CAASC,MAAT,GAAkBX,QAAlB;AACA,aAAO,KAAP;AACD,KAJD;AAKA,WAAOQ,GAAP;AACD,GAfD,CAeE,OAAOI,CAAP,EAAU;AACV,QAAIA,aAAaC,WAAjB,EAA8B;AAC5B;AACA;AACA,UAAIC,kBAAkB,CACpB,6CADoB,EAEpB,4CAFoB,EAGpB,iDAHoB,CAAtB;;AAMA,UAAIC,cAAJ;AACA,UAAID,gBAAgBE,IAAhB,CAAqB;AAAA,eAAOJ,EAAEK,OAAF,CAAUC,OAAV,CAAkBC,GAAlB,KAA0B,CAAjC;AAAA,OAArB,CAAJ,EAA8D;AAC5DJ,gBAAQ,0BAAUjB,KAAV,EAAiBA,MAAMsB,UAAN,CAAiBC,cAAlC,EAAkD,CAAC,uBAAgBvB,KAAhB,EAAuBc,EAAEK,OAAzB,CAAD,CAAlD,CAAR;AACD,OAFD,MAEO;AACLF,gBAAQ,0BAAUjB,KAAV,EAAiBA,MAAMsB,UAAN,CAAiBP,WAAlC,EAA+C,CAAC,uBAAgBf,KAAhB,EAAuBc,EAAEK,OAAzB,CAAD,CAA/C,CAAR;AACD;AACD;AACA;AACA;AACA,+BAAUF,MAAMO,UAAhB;AACAP,YAAMO,UAAN,CAAiBC,YAAjB,GAAgC;AAC9BvB,kBAAUA,QADoB;AAE9BwB,oBAAYzB,IAFkB;AAG9BW,aAAKE,EAAEF,GAHuB;AAI9Be,wBAAgB;AAJc,OAAhC;AAMA,YAAM,iCAAoBV,KAApB,EAA2BH,EAAEF,GAA7B,CAAN;AACD,KA1BD,MA0BO;AACL,YAAME,CAAN;AACD;AACF;AACF,C;;AA/DD;;;;AAGA;;AACA;;AACA;;AACA;;;;AACA","file":"parse.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport invariant from \"../invariant.js\";\nimport type { SourceType } from \"../types.js\";\nimport type { Realm } from \"../realm.js\";\nimport { ThrowCompletion } from \"../completions.js\";\nimport { StringValue } from \"../values/index.js\";\nimport { Construct } from \"../methods/construct.js\";\nimport traverseFast from \"../utils/traverse-fast.js\";\nimport { parse } from \"babylon\";\nimport type { BabelNodeFile } from \"babel-types\";\n\nexport default function(\n realm: Realm,\n code: string,\n filename: string,\n sourceType: SourceType = \"script\",\n startLine: number = 1\n): BabelNodeFile {\n try {\n let plugins = [];\n if (realm.react.enabled) {\n plugins.push(\"jsx\");\n if (realm.react.flowRequired) {\n plugins.push(\"flow\");\n }\n }\n let ast = parse(code, { filename, sourceType, startLine, plugins });\n traverseFast(ast, node => {\n invariant(node.loc);\n node.loc.source = filename;\n return false;\n });\n return ast;\n } catch (e) {\n if (e instanceof SyntaxError) {\n // Babel reports all errors as syntax errors, even if a ReferenceError should be thrown.\n // What we do here is a totally robust way to address that issue.\n let referenceErrors = [\n \"Invalid left-hand side in postfix operation\",\n \"Invalid left-hand side in prefix operation\",\n \"Invalid left-hand side in assignment expression\",\n ];\n\n let error;\n if (referenceErrors.some(msg => e.message.indexOf(msg) >= 0)) {\n error = Construct(realm, realm.intrinsics.ReferenceError, [new StringValue(realm, e.message)]);\n } else {\n error = Construct(realm, realm.intrinsics.SyntaxError, [new StringValue(realm, e.message)]);\n }\n // These constructors are currently guaranteed to produce an object with\n // built-in error data. Append location information about the syntax error\n // and the source code to it so that we can use it to print nicer errors.\n invariant(error.$ErrorData);\n error.$ErrorData.locationData = {\n filename: filename,\n sourceCode: code,\n loc: e.loc,\n stackDecorated: false,\n };\n throw new ThrowCompletion(error, e.loc);\n } else {\n throw e;\n }\n }\n}\n"]}

212
build/node_modules/prepack/lib/utils/paths.js generated vendored Normal file
View File

@@ -0,0 +1,212 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PathImplementation = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
var _index = require("../values/index.js");
var _invariant = require("../invariant.js");
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var PathImplementation = exports.PathImplementation = function () {
function PathImplementation() {
_classCallCheck(this, PathImplementation);
}
_createClass(PathImplementation, [{
key: "implies",
value: function implies(condition) {
if (!condition.mightNotBeTrue()) return true; // any path implies true
var path = condition.$Realm.pathConditions;
for (var i = path.length - 1; i >= 0; i--) {
var pathCondition = path[i];
if (pathCondition.implies(condition)) return true;
}
return false;
}
}, {
key: "impliesNot",
value: function impliesNot(condition) {
if (!condition.mightNotBeFalse()) return true; // any path implies !false
var path = condition.$Realm.pathConditions;
for (var i = path.length - 1; i >= 0; i--) {
var pathCondition = path[i];
if (pathCondition.impliesNot(condition)) return true;
}
return false;
}
}, {
key: "withCondition",
value: function withCondition(condition, evaluate) {
var realm = condition.$Realm;
var savedPath = realm.pathConditions;
realm.pathConditions = [];
try {
pushPathCondition(condition);
pushRefinedConditions(savedPath);
return evaluate();
} finally {
realm.pathConditions = savedPath;
}
}
}, {
key: "withInverseCondition",
value: function withInverseCondition(condition, evaluate) {
var realm = condition.$Realm;
var savedPath = realm.pathConditions;
realm.pathConditions = [];
try {
pushInversePathCondition(condition);
pushRefinedConditions(savedPath);
return evaluate();
} finally {
realm.pathConditions = savedPath;
}
}
}, {
key: "pushAndRefine",
value: function pushAndRefine(condition) {
var realm = condition.$Realm;
var savedPath = realm.pathConditions;
realm.pathConditions = [];
pushPathCondition(condition);
pushRefinedConditions(savedPath);
}
}, {
key: "pushInverseAndRefine",
value: function pushInverseAndRefine(condition) {
var realm = condition.$Realm;
var savedPath = realm.pathConditions;
realm.pathConditions = [];
pushInversePathCondition(condition);
pushRefinedConditions(savedPath);
}
}]);
return PathImplementation;
}();
// A path condition is an abstract value that is known to be true in a particular code path
function pushPathCondition(condition) {
(0, _invariant2.default)(condition.mightNotBeFalse(), "pushing false"); // it is mistake to assert that false is true
if (condition instanceof _index.ConcreteValue) return;
if (!condition.mightNotBeTrue()) return;
(0, _invariant2.default)(condition instanceof _index.AbstractValue);
var realm = condition.$Realm;
if (condition.kind === "&&") {
var left = condition.args[0];
var right = condition.args[1];
(0, _invariant2.default)(left instanceof _index.AbstractValue); // it is a mistake to create an abstract value when concrete value will do
pushPathCondition(left);
pushPathCondition(right);
} else {
if (condition.kind === "!=" || condition.kind === "==") {
var _left = condition.args[0];
var _right = condition.args[1];
if (_left instanceof _index.ConcreteValue && _right instanceof _index.AbstractValue) {
;
var _ref = [_right, _left];
_left = _ref[0];
_right = _ref[1];
}if (_left instanceof _index.AbstractValue && (_right instanceof _index.UndefinedValue || _right instanceof _index.NullValue)) {
var op = condition.kind === "!=" ? "!==" : "===";
if (op === "!==") pushPathCondition(_left);else pushInversePathCondition(_left);
var leftNeNull = _index.AbstractValue.createFromBinaryOp(realm, op, _left, realm.intrinsics.null);
if (leftNeNull.mightNotBeFalse()) pushPathCondition(leftNeNull);
var leftNeUndefined = _index.AbstractValue.createFromBinaryOp(realm, op, _left, realm.intrinsics.undefined);
if (leftNeUndefined.mightNotBeFalse()) pushPathCondition(leftNeUndefined);
return;
}
}
realm.pathConditions.push(condition);
}
}
// An inverse path condition is an abstract value that is known to be false in a particular code path
function pushInversePathCondition(condition) {
// it is mistake to assert that true is false.
(0, _invariant2.default)(condition.mightNotBeTrue());
if (condition instanceof _index.ConcreteValue) return;
(0, _invariant2.default)(condition instanceof _index.AbstractValue);
if (condition.kind === "||") {
var left = condition.args[0];
var right = condition.args[1];
(0, _invariant2.default)(left instanceof _index.AbstractValue); // it is a mistake to create an abstract value when concrete value will do
pushInversePathCondition(left);
if (right.mightNotBeTrue()) pushInversePathCondition(right);
} else {
var realm = condition.$Realm;
if (condition.kind === "!=" || condition.kind === "==") {
var _left2 = condition.args[0];
var _right2 = condition.args[1];
if (_left2 instanceof _index.ConcreteValue && _right2 instanceof _index.AbstractValue) {
;
var _ref2 = [_right2, _left2];
_left2 = _ref2[0];
_right2 = _ref2[1];
}if (_left2 instanceof _index.AbstractValue && (_right2 instanceof _index.UndefinedValue || _right2 instanceof _index.NullValue)) {
var op = condition.kind === "!=" ? "===" : "!==";
if (op === "!==") pushInversePathCondition(_left2);else pushPathCondition(_left2);
var leftEqNull = _index.AbstractValue.createFromBinaryOp(realm, op, _left2, realm.intrinsics.null);
if (leftEqNull.mightNotBeFalse()) pushPathCondition(leftEqNull);
var leftEqUndefined = _index.AbstractValue.createFromBinaryOp(realm, op, _left2, realm.intrinsics.undefined);
if (leftEqUndefined.mightNotBeFalse()) pushPathCondition(leftEqUndefined);
return;
}
}
var inverseCondition = _index.AbstractValue.createFromUnaryOp(realm, "!", condition);
pushPathCondition(inverseCondition);
if (inverseCondition instanceof _index.AbstractValue) {
var simplifiedInverseCondition = realm.simplifyAndRefineAbstractCondition(inverseCondition);
if (!simplifiedInverseCondition.equals(inverseCondition)) pushPathCondition(simplifiedInverseCondition);
}
}
}
function pushRefinedConditions(unrefinedConditions) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = unrefinedConditions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var unrefinedCond = _step.value;
pushPathCondition(unrefinedCond.$Realm.simplifyAndRefineAbstractCondition(unrefinedCond));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
//# sourceMappingURL=paths.js.map

1
build/node_modules/prepack/lib/utils/paths.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

334
build/node_modules/prepack/lib/utils/simplifier.js generated vendored Normal file
View File

@@ -0,0 +1,334 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
exports.default = simplifyAndRefineAbstractValue;
var _errors = require("../errors.js");
var _index = require("../domains/index.js");
var _invariant = require("../invariant.js");
var _invariant2 = _interopRequireDefault(_invariant);
var _realm = require("../realm.js");
var _index2 = require("../values/index.js");
var _singletons = require("../singletons.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); }
function simplifyAndRefineAbstractValue(realm, isCondition, // The value is only used after converting it to a Boolean
value) {
var savedHandler = realm.errorHandler;
var savedIsReadOnly = realm.isReadOnly;
realm.isReadOnly = true;
try {
realm.errorHandler = function () {
throw new _errors.FatalError();
};
return simplify(realm, value, isCondition);
} catch (e) {
return value;
} finally {
realm.errorHandler = savedHandler;
realm.isReadOnly = savedIsReadOnly;
}
}
function simplify(realm, value) {
var isCondition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (value instanceof _index2.ConcreteValue) return value;
(0, _invariant2.default)(value instanceof _index2.AbstractValue);
if (isCondition || value.getType() === _index2.BooleanValue) {
if (_singletons.Path.implies(value)) return realm.intrinsics.true;
if (_singletons.Path.impliesNot(value)) return realm.intrinsics.false;
}
var loc = value.expressionLocation;
var op = value.kind;
switch (op) {
case "!":
{
var _value$args = _slicedToArray(value.args, 1),
x0 = _value$args[0];
var x = simplify(realm, x0, true);
return negate(realm, x, loc, x0.equals(x) ? value : undefined);
}
case "||":
case "&&":
{
var _value$args2 = _slicedToArray(value.args, 2),
_x2 = _value$args2[0],
y0 = _value$args2[1];
var _x3 = simplify(realm, _x2);
var y = simplify(realm, y0);
if (_x3 instanceof _index2.AbstractValue && _x3.equals(y)) return _x3;
// true && y <=> y
// true || y <=> true
if (!_x3.mightNotBeTrue()) return op === "&&" ? y : _x3;
// (x == false) && y <=> x
// false || y <=> y
if (!_x3.mightNotBeFalse()) return op === "||" ? y : _x3;
if (isCondition || _x3.getType() === _index2.BooleanValue && y.getType() === _index2.BooleanValue) {
// (x: boolean) && true <=> x
// x || true <=> true
if (!y.mightNotBeTrue()) return op === "&&" ? _x3 : realm.intrinsics.true;
// (x: boolean) && false <=> false
// (x: boolean) || false <=> x
if (!y.mightNotBeFalse()) return op === "||" ? _x3 : realm.intrinsics.false;
}
if (op === "||" && y instanceof _index2.AbstractValue && y.kind === "||" && _x3.equals(y.args[0]) && !y.args[1].mightNotBeTrue()) return y;
if (_x3.equals(_x2) && y.equals(y0)) return value;
return _index2.AbstractValue.createFromLogicalOp(realm, value.kind, _x3, y, loc);
}
case "==":
case "!=":
case "===":
case "!==":
return simplifyEquality(realm, value);
case "conditional":
{
var _value$args3 = _slicedToArray(value.args, 3),
c0 = _value$args3[0],
_x4 = _value$args3[1],
_y = _value$args3[2];
var c = simplify(realm, c0, true);
var cs = simplify(realm, c0);
var _x5 = simplify(realm, _x4);
var _y2 = simplify(realm, _y);
if (!c.mightNotBeTrue()) return _x5;
if (!c.mightNotBeFalse()) return _y2;
(0, _invariant2.default)(c instanceof _index2.AbstractValue);
if (_singletons.Path.implies(c)) return _x5;
var notc = _index2.AbstractValue.createFromUnaryOp(realm, "!", c);
if (!notc.mightNotBeTrue()) return _y2;
if (!notc.mightNotBeFalse()) return _x5;
(0, _invariant2.default)(notc instanceof _index2.AbstractValue);
if (_singletons.Path.implies(notc)) return _y2;
if (_singletons.Path.implies(_index2.AbstractValue.createFromBinaryOp(realm, "===", value, _x5))) return _x5;
if (_singletons.Path.implies(_index2.AbstractValue.createFromBinaryOp(realm, "!==", value, _x5))) return _y2;
if (_singletons.Path.implies(_index2.AbstractValue.createFromBinaryOp(realm, "!==", value, _y2))) return _x5;
if (_singletons.Path.implies(_index2.AbstractValue.createFromBinaryOp(realm, "===", value, _y2))) return _y2;
// c ? x : x <=> x
if (_x5.equals(_y2)) return _x5;
// x ? x : y <=> x || y
if (cs.equals(_x5)) return _index2.AbstractValue.createFromLogicalOp(realm, "||", _x5, _y2, loc);
// y ? x : y <=> y && x
if (cs.equals(_y2)) return _index2.AbstractValue.createFromLogicalOp(realm, "&&", _y2, _x5, loc);
// c ? (c ? xx : xy) : y <=> c ? xx : y
if (_x5 instanceof _index2.AbstractValue && _x5.kind === "conditional") {
var _x5$args = _slicedToArray(_x5.args, 2),
xc = _x5$args[0],
xx = _x5$args[1];
if (c.equals(xc)) return _index2.AbstractValue.createFromConditionalOp(realm, c, xx, _y2);
}
// c ? x : (c ? y : z) : z <=> c ? x : z
if (_y2 instanceof _index2.AbstractValue && _y2.kind === "conditional") {
var _y2$args = _slicedToArray(_y2.args, 3),
yc = _y2$args[0],
z = _y2$args[2];
if (c.equals(yc)) return _index2.AbstractValue.createFromConditionalOp(realm, c, _x5, z);
}
if (_x5.getType() === _index2.BooleanValue && _y2.getType() === _index2.BooleanValue) {
// c ? true : false <=> c
if (!_x5.mightNotBeTrue() && !_y2.mightNotBeFalse()) return c;
// c ? false : true <=> !c
if (!_x5.mightNotBeFalse() && !_y2.mightNotBeTrue()) return _index2.AbstractValue.createFromUnaryOp(realm, "!", c, true, loc);
}
if (c.equals(c0) && _x5.equals(_x4) && _y2.equals(_y)) return value;
return _index2.AbstractValue.createFromConditionalOp(realm, c, _x5, _y2, value.expressionLocation);
}
case "abstractConcreteUnion":
{
// The union of an abstract value with one or more concrete values.
if (realm.pathConditions.length === 0) return value;
var _value$args4 = _toArray(value.args),
abstractValue = _value$args4[0],
concreteValues = _value$args4.slice(1);
(0, _invariant2.default)(abstractValue instanceof _index2.AbstractValue);
var remainingConcreteValues = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = concreteValues[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var concreteValue = _step.value;
if (_singletons.Path.implies(_index2.AbstractValue.createFromBinaryOp(realm, "!==", value, concreteValue))) continue;
if (_singletons.Path.implies(_index2.AbstractValue.createFromBinaryOp(realm, "===", value, concreteValue))) return concreteValue;
remainingConcreteValues.push(concreteValue);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
if (remainingConcreteValues.length === 0) return abstractValue;
if (remainingConcreteValues.length === concreteValues.length) return value;
return _index2.AbstractValue.createAbstractConcreteUnion.apply(_index2.AbstractValue, [realm, abstractValue].concat(remainingConcreteValues));
}
default:
return value;
}
}
function simplifyEquality(realm, equality) {
var loc = equality.expressionLocation;
var op = equality.kind;
var _equality$args = _slicedToArray(equality.args, 2),
x = _equality$args[0],
y = _equality$args[1];
if (x instanceof _index2.ConcreteValue) {
;
var _ref = [y, x];
x = _ref[0];
y = _ref[1];
}if (x instanceof _index2.AbstractValue && x.kind === "conditional" && (!y.mightNotBeUndefined() || !y.mightNotBeNull())) {
// try to simplify "(cond ? xx : xy) op undefined/null" to just "cond" or "!cond"
var _x$args = _slicedToArray(x.args, 3),
cond = _x$args[0],
xx = _x$args[1],
xy = _x$args[2];
(0, _invariant2.default)(cond instanceof _index2.AbstractValue); // otherwise the the conditional should not have been created
if (op === "===" || op === "!==") {
// if xx === undefined && xy !== undefined then cond <=> x === undefined
if (!y.mightNotBeUndefined() && !xx.mightNotBeUndefined() && !xy.mightBeUndefined()) return op === "===" ? makeBoolean(realm, cond, loc) : negate(realm, cond, loc);
// if xx !== undefined && xy === undefined then !cond <=> x === undefined
if (!y.mightNotBeUndefined() && !xx.mightBeUndefined() && !xy.mightNotBeUndefined()) return op === "===" ? negate(realm, cond, loc) : makeBoolean(realm, cond, loc);
// if xx === null && xy !== null then cond <=> x === null
if (!y.mightNotBeNull() && !xx.mightNotBeNull() && !xy.mightBeNull()) return op === "===" ? makeBoolean(realm, cond, loc) : negate(realm, cond, loc);
// if xx !== null && xy === null then !cond <=> x === null
if (!y.mightNotBeNull() && !xx.mightBeNull() && !xy.mightNotBeNull()) return op === "===" ? negate(realm, cond, loc) : makeBoolean(realm, cond, loc);
} else {
(0, _invariant2.default)(op === "==" || op === "!=");
// if xx cannot be undefined/null and xy is undefined/null then !cond <=> x == undefined/null
if (!xx.mightBeUndefined() && !xx.mightBeNull() && (!xy.mightNotBeUndefined() || !xy.mightNotBeNull())) return op === "==" ? negate(realm, cond, loc) : makeBoolean(realm, cond, loc);
// if xx is undefined/null and xy cannot be undefined/null then cond <=> x == undefined/null
if ((!xx.mightNotBeUndefined() || !xx.mightNotBeNull()) && !xy.mightBeUndefined() && !xy.mightBeNull()) return op === "==" ? makeBoolean(realm, cond, loc) : negate(realm, cond, loc);
}
}
return equality;
}
function makeBoolean(realm, value) {
var loc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
if (value.getType() === _index2.BooleanValue) return value;
if (value instanceof _index2.ConcreteValue) return new _index2.BooleanValue(realm, _singletons.To.ToBoolean(realm, value));
(0, _invariant2.default)(value instanceof _index2.AbstractValue);
var v = _index2.AbstractValue.createFromUnaryOp(realm, "!", value, true, value.expressionLocation);
if (v instanceof _index2.ConcreteValue) return new _index2.BooleanValue(realm, !_singletons.To.ToBoolean(realm, v));
(0, _invariant2.default)(v instanceof _index2.AbstractValue);
return _index2.AbstractValue.createFromUnaryOp(realm, "!", v, true, loc || value.expressionLocation);
}
function negate(realm, value) {
var loc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
var unsimplifiedNegation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
if (value instanceof _index2.ConcreteValue) return _index.ValuesDomain.computeUnary(realm, "!", value);
(0, _invariant2.default)(value instanceof _index2.AbstractValue);
if (value.kind === "!") {
var _value$args5 = _slicedToArray(value.args, 1),
x = _value$args5[0];
if (x.getType() === _index2.BooleanValue) return simplify(realm, x, true);
if (unsimplifiedNegation !== undefined) return unsimplifiedNegation;
return makeBoolean(realm, x, loc);
}
if (!value.mightNotBeTrue()) return realm.intrinsics.false;
if (!value.mightNotBeFalse()) return realm.intrinsics.true;
// If NaN is not an issue, invert binary ops
if (value.args.length === 2 && !value.args[0].mightBeNumber() && !value.args[1].mightBeNumber()) {
var invertedComparison = void 0;
switch (value.kind) {
case "===":
invertedComparison = "!==";
break;
case "==":
invertedComparison = "!=";
break;
case "!==":
invertedComparison = "===";
break;
case "!=":
invertedComparison = "==";
break;
case "<":
invertedComparison = ">=";
break;
case "<=":
invertedComparison = ">";
break;
case ">":
invertedComparison = "<=";
break;
case ">=":
invertedComparison = "<";
break;
default:
break;
}
if (invertedComparison !== undefined) {
var left = simplify(realm, value.args[0]);
var right = simplify(realm, value.args[1]);
return _index2.AbstractValue.createFromBinaryOp(realm, invertedComparison, left, right, loc || value.expressionLocation);
}
var invertedLogicalOp = void 0;
switch (value.kind) {
case "&&":
invertedLogicalOp = "||";
break;
case "||":
invertedLogicalOp = "&&";
break;
default:
break;
}
if (invertedLogicalOp !== undefined) {
var _left = negate(realm, value.args[0]);
var _right = negate(realm, value.args[1]);
return _index2.AbstractValue.createFromLogicalOp(realm, invertedLogicalOp, _left, _right, loc || value.expressionLocation);
}
}
if (unsimplifiedNegation !== undefined) return unsimplifiedNegation;
return _index2.AbstractValue.createFromUnaryOp(realm, "!", value, true, loc || value.expressionLocation);
}
//# sourceMappingURL=simplifier.js.map

File diff suppressed because one or more lines are too long

29
build/node_modules/prepack/lib/utils/strict.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = IsStrict;
function IsStrict(node) {
if (node.strict) return true;
if (node.type !== "BlockStatement" && node.type !== "Program") return false;
var directives = node.directives;
if (!directives) return false;
return directives.some(function (directive) {
if (directive.type !== "Directive") {
return false;
}
if (directive.value.type !== "DirectiveLiteral") {
return false;
}
return directive.value.value === "use strict";
});
} /**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
//# sourceMappingURL=strict.js.map

1
build/node_modules/prepack/lib/utils/strict.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/strict.js"],"names":["IsStrict","node","strict","type","directives","some","directive","value"],"mappings":";;;;;kBAawBA,Q;AAAT,SAASA,QAAT,CAAkBC,IAAlB,EAA4C;AACzD,MAAIA,KAAKC,MAAT,EAAiB,OAAO,IAAP;AACjB,MAAID,KAAKE,IAAL,KAAc,gBAAd,IAAkCF,KAAKE,IAAL,KAAc,SAApD,EAA+D,OAAO,KAAP;AAC/D,MAAIC,aAAeH,IAAF,CAA0DG,UAA3E;AACA,MAAI,CAACA,UAAL,EAAiB,OAAO,KAAP;AACjB,SAAOA,WAAWC,IAAX,CAAgB,qBAAa;AAClC,QAAIC,UAAUH,IAAV,KAAmB,WAAvB,EAAoC;AAClC,aAAO,KAAP;AACD;AACD,QAAIG,UAAUC,KAAV,CAAgBJ,IAAhB,KAAyB,kBAA7B,EAAiD;AAC/C,aAAO,KAAP;AACD;AACD,WAAOG,UAAUC,KAAV,CAAgBA,KAAhB,KAA0B,YAAjC;AACD,GARM,CAAP;AASD,C,CA3BD","file":"strict.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport type { BabelNode, BabelNodeBlockStatement, BabelNodeProgram } from \"babel-types\";\n\nexport default function IsStrict(node: BabelNode): boolean {\n if (node.strict) return true;\n if (node.type !== \"BlockStatement\" && node.type !== \"Program\") return false;\n let directives = ((node: any): BabelNodeBlockStatement | BabelNodeProgram).directives;\n if (!directives) return false;\n return directives.some(directive => {\n if (directive.type !== \"Directive\") {\n return false;\n }\n if (directive.value.type !== \"DirectiveLiteral\") {\n return false;\n }\n return directive.value.value === \"use strict\";\n });\n}\n"]}

91
build/node_modules/prepack/lib/utils/traverse-fast.js generated vendored Normal file
View File

@@ -0,0 +1,91 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = traverse;
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
// This is a variation of traverseFast from
// https://github.com/babel/babel/blob/28ae47a174f67a8ae6f4527e0a66e88896814170/packages/babel-types/src/index.js
// This version...
// - takes a callback function that returns a boolean to indicate whether to short-circuit the traversal
// - doesn't pass around or allocate an optional parameter value to the callback.
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
function traverse(node, enter) {
if (!node) return;
var keys = t.VISITOR_KEYS[node.type];
if (!keys) return;
var stop = enter(node);
if (stop) return;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
var subNode = node[key];
if (Array.isArray(subNode)) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = subNode[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var elementNode = _step2.value;
traverse(elementNode, enter);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
} else {
traverse(subNode, enter);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
//# sourceMappingURL=traverse-fast.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/traverse-fast.js"],"names":["traverse","t","node","enter","keys","VISITOR_KEYS","type","stop","key","subNode","Array","isArray","elementNode"],"mappings":";;;;;kBAmBwBA,Q;;AARxB;;IACYC,C;;;;AAEZ;AACA;AACA;AACA;AACA;AAlBA;;;;;;;;;AAmBe,SAASD,QAAT,CAAkBE,IAAlB,EAAmCC,KAAnC,EAAgE;AAC7E,MAAI,CAACD,IAAL,EAAW;;AAEX,MAAIE,OAAOH,EAAEI,YAAF,CAAeH,KAAKI,IAApB,CAAX;AACA,MAAI,CAACF,IAAL,EAAW;;AAEX,MAAIG,OAAOJ,MAAMD,IAAN,CAAX;AACA,MAAIK,IAAJ,EAAU;;AAPmE;AAAA;AAAA;;AAAA;AAS7E,yBAAgBH,IAAhB,8HAAsB;AAAA,UAAbI,GAAa;;AACpB,UAAIC,UAAWP,IAAD,CAAYM,GAAZ,CAAd;;AAEA,UAAIE,MAAMC,OAAN,CAAcF,OAAd,CAAJ,EAA4B;AAAA;AAAA;AAAA;;AAAA;AAC1B,gCAAwBA,OAAxB,mIAAiC;AAAA,gBAAxBG,WAAwB;;AAC/BZ,qBAASY,WAAT,EAAsBT,KAAtB;AACD;AAHyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAI3B,OAJD,MAIO;AACLH,iBAASS,OAAT,EAAkBN,KAAlB;AACD;AACF;AAnB4E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoB9E","file":"traverse-fast.js","sourcesContent":["/**\n * Copyright (c) 2017-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n */\n\n/* @flow */\n\nimport { BabelNode } from \"babel-types\";\nimport * as t from \"babel-types\";\n\n// This is a variation of traverseFast from\n// https://github.com/babel/babel/blob/28ae47a174f67a8ae6f4527e0a66e88896814170/packages/babel-types/src/index.js\n// This version...\n// - takes a callback function that returns a boolean to indicate whether to short-circuit the traversal\n// - doesn't pass around or allocate an optional parameter value to the callback.\nexport default function traverse(node: BabelNode, enter: BabelNode => boolean) {\n if (!node) return;\n\n let keys = t.VISITOR_KEYS[node.type];\n if (!keys) return;\n\n let stop = enter(node);\n if (stop) return;\n\n for (let key of keys) {\n let subNode = (node: any)[key];\n\n if (Array.isArray(subNode)) {\n for (let elementNode of subNode) {\n traverse(elementNode, enter);\n }\n } else {\n traverse(subNode, enter);\n }\n }\n}\n"]}