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

View File

@@ -0,0 +1,138 @@
"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.createObject = createObject;
exports.createArray = createArray;
exports.createAbstractObject = createAbstractObject;
exports.createAbstractObjectFromFlowTypes = createAbstractObjectFromFlowTypes;
exports.createAbstractByType = createAbstractByType;
var _realm = require("../realm.js");
var _builder = require("../utils/builder.js");
var _builder2 = _interopRequireDefault(_builder);
var _singletons = require("../singletons.js");
var _index = require("../domains/index.js");
var _index2 = require("../values/index.js");
var _invariant = require("../invariant.js");
var _invariant2 = _interopRequireDefault(_invariant);
require("./utils.js");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function createObject(realm, shape, name) {
var obj = _singletons.Create.ObjectCreate(realm, realm.intrinsics.ObjectPrototype);
if (shape != null) {
// to get around Flow complaining that shape could be null
var shapeThatIsNotNull = shape;
Object.keys(shape).forEach(function (id) {
var value = shapeThatIsNotNull[id];
(0, _invariant2.default)(value instanceof _index2.Value, "creation of object failed due to object containing non-value properties");
obj.$Set(id, value, obj);
if (name !== null) {
value.intrinsicName = name + "." + id;
}
});
}
if (name !== null) {
obj.intrinsicName = name;
}
return obj;
}
function createArray(realm, name) {
var obj = _singletons.Create.ArrayCreate(realm, 0, realm.intrinsics.ArrayPrototype);
if (name !== null) {
obj.intrinsicName = name;
}
return obj;
}
function _createAbstractArray(realm, name) {
var value = _index2.AbstractValue.createFromTemplate(realm, (0, _builder2.default)(name), _index2.ArrayValue, [], name);
value.intrinsicName = name;
var template = createArray(realm, name);
template.makePartial();
template.makeSimple();
value.values = new _index.ValuesDomain(new Set([template]));
realm.rebuildNestedProperties(value, name);
return value;
}
function createAbstractObject(realm, name, objectTypes, template) {
if (name === null) {
name = "unknown";
}
var value = _index2.AbstractValue.createFromTemplate(realm, (0, _builder2.default)(name), _index2.ObjectValue, [], name);
value.intrinsicName = name;
if (template === undefined) {
template = createObject(realm, objectTypes, name);
}
template.makePartial();
template.makeSimple();
value.values = new _index.ValuesDomain(new Set([template]));
realm.rebuildNestedProperties(value, name);
(0, _invariant2.default)(value instanceof _index2.AbstractObjectValue);
return value;
}
function createAbstractObjectFromFlowTypes(realm, name, objectTypes) {
if (typeof objectTypes === "string") {
(0, _invariant2.default)(objectTypes === "empty" || objectTypes === "object", "Expected an object or a string of \"empty\" or \"object\" for createAbstractObject() paramater \"objectTypes\"");
return createAbstractObject(realm, name, null);
}
if (objectTypes !== null) {
var propTypeObject = {};
var objTypes = objectTypes;
(0, _invariant2.default)(objTypes);
Object.keys(objTypes).forEach(function (key) {
var value = objTypes[key];
var propertyName = name !== null ? name + "." + key : key;
if (typeof value === "string") {
if (value === "array") {
propTypeObject[key] = _createAbstractArray(realm, propertyName);
} else if (value === "object") {
propTypeObject[key] = createAbstractObject(realm, propertyName, null);
} else {
propTypeObject[key] = createAbstractByType(realm, value, propertyName);
}
} else if ((typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && value !== null) {
propTypeObject[key] = createAbstractObject(realm, propertyName, value);
} else {
(0, _invariant2.default)(false, "Unknown propType value of \"" + value + "\" for \"" + key + "\"");
}
});
return createAbstractObject(realm, name, propTypeObject);
} else {
return createAbstractObject(realm, name, null);
}
}
function createAbstractByType(realm, typeNameString, name) {
var type = _index2.Value.getTypeFromName(typeNameString);
(0, _invariant2.default)(type !== undefined, "createAbstractByType() cannot be undefined");
var value = _index2.AbstractValue.createFromTemplate(realm, (0, _builder2.default)(name), type, [], name);
value.intrinsicName = name;
return value;
}
//# sourceMappingURL=abstractObjectFactories.js.map

File diff suppressed because one or more lines are too long

155
build/node_modules/prepack/lib/flow/utils.js generated vendored Normal file
View File

@@ -0,0 +1,155 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.flowAnnotationToObjectTypeTemplate = flowAnnotationToObjectTypeTemplate;
exports.stripFlowTypeAnnotations = stripFlowTypeAnnotations;
var _invariant = require("../invariant.js");
var _invariant2 = _interopRequireDefault(_invariant);
var _babelTraverse = require("babel-traverse");
var _babelTraverse2 = _interopRequireDefault(_babelTraverse);
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; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function flowAnnotationToObjectTypeTemplate(annotation) {
if (annotation.type === "TypeAnnotation") {
return flowAnnotationToObjectTypeTemplate(annotation.typeAnnotation);
} else if (annotation.type === "GenericTypeAnnotation") {
if (annotation.id.type === "Identifier") {
var identifier = annotation.id.name;
switch (identifier) {
case "Function":
return "function";
case "Object":
return "object";
case "Array":
return "array";
case "any":
case "empty":
return "empty";
default:
// get the Flow type
(0, _invariant2.default)(false, "Flow types are currently not supported");
}
} else {
(0, _invariant2.default)(false, "unknown generic Flow type annotation node");
}
} else if (annotation.type === "EmptyTypeAnnotation") {
return "empty";
} else if (annotation.type === "BooleanTypeAnnotation") {
return "boolean";
} else if (annotation.type === "StringTypeAnnotation") {
return "string";
} else if (annotation.type === "NumberTypeAnnotation") {
return "number";
} else if (annotation.type === "FunctionTypeAnnotation") {
return "function";
} else if (annotation.type === "ArrayTypeAnnotation") {
return "array";
} else if (annotation.type === "ObjectTypeAnnotation") {
var obj = {};
annotation.properties.forEach(function (property) {
if (property.type === "ObjectTypeProperty") {
if (property.key.type === "Identifier") {
obj[property.key.name] = flowAnnotationToObjectTypeTemplate(property.value);
} else {
(0, _invariant2.default)(false, "only Identifier nodes are supported in ObjectTypeProperty keys");
}
} else {
(0, _invariant2.default)(false, "only ObjectTypeProperty properties are supported in ObjectTypeAnnotation");
}
});
return obj;
} else if (annotation.type === "AnyTypeAnnotation") {
return "empty";
} else {
(0, _invariant2.default)(false, "unknown Flow type annotation node");
}
}
// Taken directly from Babel:
// https://github.com/babel/babel/blob/cde005422701a69ff21044c138c29a5ad23b6d0a/packages/babel-plugin-transform-flow-strip-types/src/index.js#L32-L107
// Copyright 2015-present Sebastian McKenzie / Babel project (https://github.com/babel)
// only the lines reflected in the above were used
/**
* 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 stripFlowTypeAnnotations(ast) {
(0, _babelTraverse2.default)(ast, {
ImportDeclaration: function ImportDeclaration(path) {
if (!path.node.specifiers.length) return;
var typeCount = 0;
path.node.specifiers.forEach(function (_ref) {
var importKind = _ref.importKind;
if (importKind === "type" || importKind === "typeof") {
typeCount++;
}
});
if (typeCount === path.node.specifiers.length) {
path.remove();
}
},
Flow: function Flow(path) {
path.remove();
},
ClassProperty: function ClassProperty(path) {
path.node.variance = null;
path.node.typeAnnotation = null;
if (!path.node.value) path.remove();
},
Class: function Class(path) {
path.node.implements = null;
path.get("body.body").forEach(function (child) {
if (child.isClassProperty()) {
child.node.typeAnnotation = null;
if (!child.node.value) child.remove();
}
});
},
AssignmentPattern: function AssignmentPattern(_ref2) {
var node = _ref2.node;
node.left.optional = false;
},
Function: function Function(_ref3) {
var node = _ref3.node;
for (var i = 0; i < node.params.length; i++) {
var param = node.params[i];
param.optional = false;
if (param.type === "AssignmentPattern") {
param.left.optional = false;
}
}
node.predicate = null;
},
TypeCastExpression: function TypeCastExpression(path) {
var node = path.node;
do {
node = node.expression;
} while (t.isTypeCastExpression(node));
path.replaceWith(node);
}
}, undefined, undefined, undefined);
}
//# sourceMappingURL=utils.js.map

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

File diff suppressed because one or more lines are too long