forked from daren.hsu/line_push
update
This commit is contained in:
+29
File diff suppressed because one or more lines are too long
+193
-312
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _template = _interopRequireDefault(require("@babel/template"));
|
||||
var _template = require("@babel/template");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
var _helpersGenerated = require("./helpers-generated");
|
||||
|
||||
const helpers = Object.create(null);
|
||||
const helpers = Object.assign({
|
||||
__proto__: null
|
||||
}, _helpersGenerated.default);
|
||||
var _default = helpers;
|
||||
exports.default = _default;
|
||||
|
||||
@@ -18,90 +20,6 @@ const helper = minVersion => tpl => ({
|
||||
ast: () => _template.default.program.ast(tpl)
|
||||
});
|
||||
|
||||
helpers.typeof = helper("7.0.0-beta.0")`
|
||||
export default function _typeof(obj) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||||
_typeof = function (obj) { return typeof obj; };
|
||||
} else {
|
||||
_typeof = function (obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype
|
||||
? "symbol"
|
||||
: typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
`;
|
||||
helpers.jsx = helper("7.0.0-beta.0")`
|
||||
var REACT_ELEMENT_TYPE;
|
||||
|
||||
export default function _createRawReactElement(type, props, key, children) {
|
||||
if (!REACT_ELEMENT_TYPE) {
|
||||
REACT_ELEMENT_TYPE = (
|
||||
typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element")
|
||||
) || 0xeac7;
|
||||
}
|
||||
|
||||
var defaultProps = type && type.defaultProps;
|
||||
var childrenLength = arguments.length - 3;
|
||||
|
||||
if (!props && childrenLength !== 0) {
|
||||
// If we're going to assign props.children, we create a new object now
|
||||
// to avoid mutating defaultProps.
|
||||
props = {
|
||||
children: void 0,
|
||||
};
|
||||
}
|
||||
|
||||
if (childrenLength === 1) {
|
||||
props.children = children;
|
||||
} else if (childrenLength > 1) {
|
||||
var childArray = new Array(childrenLength);
|
||||
for (var i = 0; i < childrenLength; i++) {
|
||||
childArray[i] = arguments[i + 3];
|
||||
}
|
||||
props.children = childArray;
|
||||
}
|
||||
|
||||
if (props && defaultProps) {
|
||||
for (var propName in defaultProps) {
|
||||
if (props[propName] === void 0) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
} else if (!props) {
|
||||
props = defaultProps || {};
|
||||
}
|
||||
|
||||
return {
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
type: type,
|
||||
key: key === undefined ? null : '' + key,
|
||||
ref: null,
|
||||
props: props,
|
||||
_owner: null,
|
||||
};
|
||||
}
|
||||
`;
|
||||
helpers.asyncIterator = helper("7.0.0-beta.0")`
|
||||
export default function _asyncIterator(iterable) {
|
||||
var method
|
||||
if (typeof Symbol !== "undefined") {
|
||||
if (Symbol.asyncIterator) {
|
||||
method = iterable[Symbol.asyncIterator]
|
||||
if (method != null) return method.call(iterable);
|
||||
}
|
||||
if (Symbol.iterator) {
|
||||
method = iterable[Symbol.iterator]
|
||||
if (method != null) return method.call(iterable);
|
||||
}
|
||||
}
|
||||
throw new TypeError("Object is not async iterable");
|
||||
}
|
||||
`;
|
||||
helpers.AwaitValue = helper("7.0.0-beta.0")`
|
||||
export default function _AwaitValue(value) {
|
||||
this.wrapped = value;
|
||||
@@ -182,9 +100,7 @@ helpers.AsyncGenerator = helper("7.0.0-beta.0")`
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof Symbol === "function" && Symbol.asyncIterator) {
|
||||
AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; };
|
||||
}
|
||||
AsyncGenerator.prototype[typeof Symbol === "function" && Symbol.asyncIterator || "@@asyncIterator"] = function () { return this; };
|
||||
|
||||
AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };
|
||||
AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); };
|
||||
@@ -216,9 +132,7 @@ helpers.asyncGeneratorDelegate = helper("7.0.0-beta.0")`
|
||||
return { done: false, value: awaitWrap(value) };
|
||||
};
|
||||
|
||||
if (typeof Symbol === "function" && Symbol.iterator) {
|
||||
iter[Symbol.iterator] = function () { return this; };
|
||||
}
|
||||
iter[typeof Symbol !== "undefined" && Symbol.iterator || "@@iterator"] = function () { return this; };
|
||||
|
||||
iter.next = function (value) {
|
||||
if (waiting) {
|
||||
@@ -306,6 +220,7 @@ helpers.createClass = helper("7.0.0-beta.0")`
|
||||
export default function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
Object.defineProperty(Constructor, "prototype", { writable: false });
|
||||
return Constructor;
|
||||
}
|
||||
`;
|
||||
@@ -369,7 +284,7 @@ helpers.defineProperty = helper("7.0.0-beta.0")`
|
||||
`;
|
||||
helpers.extends = helper("7.0.0-beta.0")`
|
||||
export default function _extends() {
|
||||
_extends = Object.assign || function (target) {
|
||||
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
@@ -392,7 +307,7 @@ helpers.objectSpread = helper("7.0.0-beta.0")`
|
||||
var source = (arguments[i] != null) ? Object(arguments[i]) : {};
|
||||
var ownKeys = Object.keys(source);
|
||||
if (typeof Object.getOwnPropertySymbols === 'function') {
|
||||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
ownKeys.push.apply(ownKeys, Object.getOwnPropertySymbols(source).filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
||||
}));
|
||||
}
|
||||
@@ -403,47 +318,6 @@ helpers.objectSpread = helper("7.0.0-beta.0")`
|
||||
return target;
|
||||
}
|
||||
`;
|
||||
helpers.objectSpread2 = helper("7.5.0")`
|
||||
import defineProperty from "defineProperty";
|
||||
|
||||
// This function is different to "Reflect.ownKeys". The enumerableOnly
|
||||
// filters on symbol properties only. Returned string properties are always
|
||||
// enumerable. It is good to use in objectSpread.
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
export default function _objectSpread2(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = (arguments[i] != null) ? arguments[i] : {};
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function (key) {
|
||||
defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function (key) {
|
||||
Object.defineProperty(
|
||||
target,
|
||||
key,
|
||||
Object.getOwnPropertyDescriptor(source, key)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
`;
|
||||
helpers.inherits = helper("7.0.0-beta.0")`
|
||||
import setPrototypeOf from "setPrototypeOf";
|
||||
|
||||
@@ -451,6 +325,9 @@ helpers.inherits = helper("7.0.0-beta.0")`
|
||||
if (typeof superClass !== "function" && superClass !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function");
|
||||
}
|
||||
// We can't use defineProperty to set the prototype in a single step because it
|
||||
// doesn't work in Chrome <= 36. https://github.com/babel/babel/issues/14056
|
||||
// V8 bug: https://bugs.chromium.org/p/v8/issues/detail?id=3334
|
||||
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||||
constructor: {
|
||||
value: subClass,
|
||||
@@ -458,20 +335,23 @@ helpers.inherits = helper("7.0.0-beta.0")`
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
Object.defineProperty(subClass, "prototype", { writable: false });
|
||||
if (superClass) setPrototypeOf(subClass, superClass);
|
||||
}
|
||||
`;
|
||||
helpers.inheritsLoose = helper("7.0.0-beta.0")`
|
||||
import setPrototypeOf from "setPrototypeOf";
|
||||
|
||||
export default function _inheritsLoose(subClass, superClass) {
|
||||
subClass.prototype = Object.create(superClass.prototype);
|
||||
subClass.prototype.constructor = subClass;
|
||||
subClass.__proto__ = superClass;
|
||||
setPrototypeOf(subClass, superClass);
|
||||
}
|
||||
`;
|
||||
helpers.getPrototypeOf = helper("7.0.0-beta.0")`
|
||||
export default function _getPrototypeOf(o) {
|
||||
_getPrototypeOf = Object.setPrototypeOf
|
||||
? Object.getPrototypeOf
|
||||
? Object.getPrototypeOf.bind()
|
||||
: function _getPrototypeOf(o) {
|
||||
return o.__proto__ || Object.getPrototypeOf(o);
|
||||
};
|
||||
@@ -480,10 +360,12 @@ helpers.getPrototypeOf = helper("7.0.0-beta.0")`
|
||||
`;
|
||||
helpers.setPrototypeOf = helper("7.0.0-beta.0")`
|
||||
export default function _setPrototypeOf(o, p) {
|
||||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
||||
o.__proto__ = p;
|
||||
return o;
|
||||
};
|
||||
_setPrototypeOf = Object.setPrototypeOf
|
||||
? Object.setPrototypeOf.bind()
|
||||
: function _setPrototypeOf(o, p) {
|
||||
o.__proto__ = p;
|
||||
return o;
|
||||
};
|
||||
return _setPrototypeOf(o, p);
|
||||
}
|
||||
`;
|
||||
@@ -505,8 +387,9 @@ helpers.isNativeReflectConstruct = helper("7.9.0")`
|
||||
// use our fallback implementation.
|
||||
try {
|
||||
// If the internal slots aren't set, this throws an error similar to
|
||||
// TypeError: this is not a Date object.
|
||||
Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
|
||||
// TypeError: this is not a Boolean object.
|
||||
|
||||
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
@@ -519,7 +402,7 @@ helpers.construct = helper("7.0.0-beta.0")`
|
||||
|
||||
export default function _construct(Parent, args, Class) {
|
||||
if (isNativeReflectConstruct()) {
|
||||
_construct = Reflect.construct;
|
||||
_construct = Reflect.construct.bind();
|
||||
} else {
|
||||
// NOTE: If Parent !== Class, the correct __proto__ is set *after*
|
||||
// calling the constructor.
|
||||
@@ -593,17 +476,19 @@ helpers.interopRequireDefault = helper("7.0.0-beta.0")`
|
||||
return obj && obj.__esModule ? obj : { default: obj };
|
||||
}
|
||||
`;
|
||||
helpers.interopRequireWildcard = helper("7.0.0-beta.0")`
|
||||
function _getRequireWildcardCache() {
|
||||
helpers.interopRequireWildcard = helper("7.14.0")`
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () { return cache; };
|
||||
return cache;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function (nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
|
||||
export default function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
export default function _interopRequireWildcard(obj, nodeInterop) {
|
||||
if (!nodeInterop && obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -611,7 +496,7 @@ helpers.interopRequireWildcard = helper("7.0.0-beta.0")`
|
||||
return { default: obj }
|
||||
}
|
||||
|
||||
var cache = _getRequireWildcardCache();
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
@@ -619,7 +504,7 @@ helpers.interopRequireWildcard = helper("7.0.0-beta.0")`
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
@@ -702,7 +587,10 @@ helpers.possibleConstructorReturn = helper("7.0.0-beta.0")`
|
||||
export default function _possibleConstructorReturn(self, call) {
|
||||
if (call && (typeof call === "object" || typeof call === "function")) {
|
||||
return call;
|
||||
} else if (call !== void 0) {
|
||||
throw new TypeError("Derived constructors may only return object or undefined");
|
||||
}
|
||||
|
||||
return assertThisInitialized(self);
|
||||
}
|
||||
`;
|
||||
@@ -742,9 +630,9 @@ helpers.superPropBase = helper("7.0.0-beta.0")`
|
||||
helpers.get = helper("7.0.0-beta.0")`
|
||||
import superPropBase from "superPropBase";
|
||||
|
||||
export default function _get(target, property, receiver) {
|
||||
export default function _get() {
|
||||
if (typeof Reflect !== "undefined" && Reflect.get) {
|
||||
_get = Reflect.get;
|
||||
_get = Reflect.get.bind();
|
||||
} else {
|
||||
_get = function _get(target, property, receiver) {
|
||||
var base = superPropBase(target, property);
|
||||
@@ -753,13 +641,14 @@ helpers.get = helper("7.0.0-beta.0")`
|
||||
|
||||
var desc = Object.getOwnPropertyDescriptor(base, property);
|
||||
if (desc.get) {
|
||||
return desc.get.call(receiver);
|
||||
// STEP 3. If receiver is not present, then set receiver to target.
|
||||
return desc.get.call(arguments.length < 3 ? target : receiver);
|
||||
}
|
||||
|
||||
return desc.value;
|
||||
};
|
||||
}
|
||||
return _get(target, property, receiver || target);
|
||||
return _get.apply(this, arguments);
|
||||
}
|
||||
`;
|
||||
helpers.set = helper("7.0.0-beta.0")`
|
||||
@@ -835,7 +724,12 @@ helpers.taggedTemplateLiteralLoose = helper("7.0.0-beta.0")`
|
||||
`;
|
||||
helpers.readOnlyError = helper("7.0.0-beta.0")`
|
||||
export default function _readOnlyError(name) {
|
||||
throw new Error("\\"" + name + "\\" is read-only");
|
||||
throw new TypeError("\\"" + name + "\\" is read-only");
|
||||
}
|
||||
`;
|
||||
helpers.writeOnlyError = helper("7.12.13")`
|
||||
export default function _writeOnlyError(name) {
|
||||
throw new TypeError("\\"" + name + "\\" is write-only");
|
||||
}
|
||||
`;
|
||||
helpers.classNameTDZError = helper("7.0.0-beta.0")`
|
||||
@@ -946,7 +840,7 @@ helpers.maybeArrayLike = helper("7.9.0")`
|
||||
`;
|
||||
helpers.iterableToArray = helper("7.0.0-beta.0")`
|
||||
export default function _iterableToArray(iter) {
|
||||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
||||
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
||||
}
|
||||
`;
|
||||
helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
|
||||
@@ -961,14 +855,15 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
|
||||
// _i = _iterator
|
||||
// _s = _step
|
||||
|
||||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
||||
var _i = arr == null ? null : (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
|
||||
if (_i == null) return;
|
||||
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
var _s, _e;
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
@@ -987,10 +882,11 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
|
||||
`;
|
||||
helpers.iterableToArrayLimitLoose = helper("7.0.0-beta.0")`
|
||||
export default function _iterableToArrayLimitLoose(arr, i) {
|
||||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
||||
var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
|
||||
if (_i == null) return;
|
||||
|
||||
var _arr = [];
|
||||
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
for (_i = _i.call(arr), _step; !(_step = _i.next()).done;) {
|
||||
_arr.push(_step.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
@@ -1040,8 +936,9 @@ helpers.createForOfIteratorHelper = helper("7.9.0")`
|
||||
// f: finish (always called at the end)
|
||||
|
||||
export default function _createForOfIteratorHelper(o, allowArrayLike) {
|
||||
var it;
|
||||
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
||||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
||||
|
||||
if (!it) {
|
||||
// Fallback for engines without symbol support
|
||||
if (
|
||||
Array.isArray(o) ||
|
||||
@@ -1069,7 +966,7 @@ helpers.createForOfIteratorHelper = helper("7.9.0")`
|
||||
|
||||
return {
|
||||
s: function() {
|
||||
it = o[Symbol.iterator]();
|
||||
it = it.call(o);
|
||||
},
|
||||
n: function() {
|
||||
var step = it.next();
|
||||
@@ -1094,28 +991,25 @@ helpers.createForOfIteratorHelperLoose = helper("7.9.0")`
|
||||
import unsupportedIterableToArray from "unsupportedIterableToArray";
|
||||
|
||||
export default function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
||||
var it;
|
||||
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
||||
|
||||
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
||||
// Fallback for engines without symbol support
|
||||
if (
|
||||
Array.isArray(o) ||
|
||||
(it = unsupportedIterableToArray(o)) ||
|
||||
(allowArrayLike && o && typeof o.length === "number")
|
||||
) {
|
||||
if (it) o = it;
|
||||
var i = 0;
|
||||
return function() {
|
||||
if (i >= o.length) return { done: true };
|
||||
return { done: false, value: o[i++] };
|
||||
}
|
||||
if (it) return (it = it.call(o)).next.bind(it);
|
||||
|
||||
// Fallback for engines without symbol support
|
||||
if (
|
||||
Array.isArray(o) ||
|
||||
(it = unsupportedIterableToArray(o)) ||
|
||||
(allowArrayLike && o && typeof o.length === "number")
|
||||
) {
|
||||
if (it) o = it;
|
||||
var i = 0;
|
||||
return function() {
|
||||
if (i >= o.length) return { done: true };
|
||||
return { done: false, value: o[i++] };
|
||||
}
|
||||
|
||||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
|
||||
it = o[Symbol.iterator]();
|
||||
return it.next.bind(it);
|
||||
throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||||
}
|
||||
`;
|
||||
helpers.skipFirstGeneratorNext = helper("7.0.0-beta.0")`
|
||||
@@ -1192,8 +1086,6 @@ helpers.applyDecoratedDescriptor = helper("7.0.0-beta.0")`
|
||||
}
|
||||
|
||||
if (desc.initializer === void 0){
|
||||
// This is a hack to avoid this being processed by 'transform-runtime'.
|
||||
// See issue #9.
|
||||
Object.defineProperty(target, property, desc);
|
||||
desc = null;
|
||||
}
|
||||
@@ -1216,23 +1108,81 @@ helpers.classPrivateFieldLooseBase = helper("7.0.0-beta.0")`
|
||||
}
|
||||
`;
|
||||
helpers.classPrivateFieldGet = helper("7.0.0-beta.0")`
|
||||
import classApplyDescriptorGet from "classApplyDescriptorGet";
|
||||
import classExtractFieldDescriptor from "classExtractFieldDescriptor";
|
||||
export default function _classPrivateFieldGet(receiver, privateMap) {
|
||||
var descriptor = privateMap.get(receiver);
|
||||
if (!descriptor) {
|
||||
throw new TypeError("attempted to get private field on non-instance");
|
||||
var descriptor = classExtractFieldDescriptor(receiver, privateMap, "get");
|
||||
return classApplyDescriptorGet(receiver, descriptor);
|
||||
}
|
||||
`;
|
||||
helpers.classPrivateFieldSet = helper("7.0.0-beta.0")`
|
||||
import classApplyDescriptorSet from "classApplyDescriptorSet";
|
||||
import classExtractFieldDescriptor from "classExtractFieldDescriptor";
|
||||
export default function _classPrivateFieldSet(receiver, privateMap, value) {
|
||||
var descriptor = classExtractFieldDescriptor(receiver, privateMap, "set");
|
||||
classApplyDescriptorSet(receiver, descriptor, value);
|
||||
return value;
|
||||
}
|
||||
`;
|
||||
helpers.classPrivateFieldDestructureSet = helper("7.4.4")`
|
||||
import classApplyDescriptorDestructureSet from "classApplyDescriptorDestructureSet";
|
||||
import classExtractFieldDescriptor from "classExtractFieldDescriptor";
|
||||
export default function _classPrivateFieldDestructureSet(receiver, privateMap) {
|
||||
var descriptor = classExtractFieldDescriptor(receiver, privateMap, "set");
|
||||
return classApplyDescriptorDestructureSet(receiver, descriptor);
|
||||
}
|
||||
`;
|
||||
helpers.classExtractFieldDescriptor = helper("7.13.10")`
|
||||
export default function _classExtractFieldDescriptor(receiver, privateMap, action) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to " + action + " private field on non-instance");
|
||||
}
|
||||
return privateMap.get(receiver);
|
||||
}
|
||||
`;
|
||||
helpers.classStaticPrivateFieldSpecGet = helper("7.0.2")`
|
||||
import classApplyDescriptorGet from "classApplyDescriptorGet";
|
||||
import classCheckPrivateStaticAccess from "classCheckPrivateStaticAccess";
|
||||
import classCheckPrivateStaticFieldDescriptor from "classCheckPrivateStaticFieldDescriptor";
|
||||
export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
|
||||
classCheckPrivateStaticAccess(receiver, classConstructor);
|
||||
classCheckPrivateStaticFieldDescriptor(descriptor, "get");
|
||||
return classApplyDescriptorGet(receiver, descriptor);
|
||||
}
|
||||
`;
|
||||
helpers.classStaticPrivateFieldSpecSet = helper("7.0.2")`
|
||||
import classApplyDescriptorSet from "classApplyDescriptorSet";
|
||||
import classCheckPrivateStaticAccess from "classCheckPrivateStaticAccess";
|
||||
import classCheckPrivateStaticFieldDescriptor from "classCheckPrivateStaticFieldDescriptor";
|
||||
export default function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
|
||||
classCheckPrivateStaticAccess(receiver, classConstructor);
|
||||
classCheckPrivateStaticFieldDescriptor(descriptor, "set");
|
||||
classApplyDescriptorSet(receiver, descriptor, value);
|
||||
return value;
|
||||
}
|
||||
`;
|
||||
helpers.classStaticPrivateMethodGet = helper("7.3.2")`
|
||||
import classCheckPrivateStaticAccess from "classCheckPrivateStaticAccess";
|
||||
export default function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
|
||||
classCheckPrivateStaticAccess(receiver, classConstructor);
|
||||
return method;
|
||||
}
|
||||
`;
|
||||
helpers.classStaticPrivateMethodSet = helper("7.3.2")`
|
||||
export default function _classStaticPrivateMethodSet() {
|
||||
throw new TypeError("attempted to set read only static private field");
|
||||
}
|
||||
`;
|
||||
helpers.classApplyDescriptorGet = helper("7.13.10")`
|
||||
export default function _classApplyDescriptorGet(receiver, descriptor) {
|
||||
if (descriptor.get) {
|
||||
return descriptor.get.call(receiver);
|
||||
}
|
||||
return descriptor.value;
|
||||
}
|
||||
`;
|
||||
helpers.classPrivateFieldSet = helper("7.0.0-beta.0")`
|
||||
export default function _classPrivateFieldSet(receiver, privateMap, value) {
|
||||
var descriptor = privateMap.get(receiver);
|
||||
if (!descriptor) {
|
||||
throw new TypeError("attempted to set private field on non-instance");
|
||||
}
|
||||
helpers.classApplyDescriptorSet = helper("7.13.10")`
|
||||
export default function _classApplyDescriptorSet(receiver, descriptor, value) {
|
||||
if (descriptor.set) {
|
||||
descriptor.set.call(receiver, value);
|
||||
} else {
|
||||
@@ -1242,19 +1192,12 @@ helpers.classPrivateFieldSet = helper("7.0.0-beta.0")`
|
||||
// class bodies.
|
||||
throw new TypeError("attempted to set read only private field");
|
||||
}
|
||||
|
||||
descriptor.value = value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
`;
|
||||
helpers.classPrivateFieldDestructureSet = helper("7.4.4")`
|
||||
export default function _classPrivateFieldDestructureSet(receiver, privateMap) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to set private field on non-instance");
|
||||
}
|
||||
var descriptor = privateMap.get(receiver);
|
||||
helpers.classApplyDescriptorDestructureSet = helper("7.13.10")`
|
||||
export default function _classApplyDescriptorDestructureSet(receiver, descriptor) {
|
||||
if (descriptor.set) {
|
||||
if (!("__destrObj" in descriptor)) {
|
||||
descriptor.__destrObj = {
|
||||
@@ -1276,48 +1219,28 @@ helpers.classPrivateFieldDestructureSet = helper("7.4.4")`
|
||||
}
|
||||
}
|
||||
`;
|
||||
helpers.classStaticPrivateFieldSpecGet = helper("7.0.2")`
|
||||
export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
|
||||
helpers.classStaticPrivateFieldDestructureSet = helper("7.13.10")`
|
||||
import classApplyDescriptorDestructureSet from "classApplyDescriptorDestructureSet";
|
||||
import classCheckPrivateStaticAccess from "classCheckPrivateStaticAccess";
|
||||
import classCheckPrivateStaticFieldDescriptor from "classCheckPrivateStaticFieldDescriptor";
|
||||
export default function _classStaticPrivateFieldDestructureSet(receiver, classConstructor, descriptor) {
|
||||
classCheckPrivateStaticAccess(receiver, classConstructor);
|
||||
classCheckPrivateStaticFieldDescriptor(descriptor, "set");
|
||||
return classApplyDescriptorDestructureSet(receiver, descriptor);
|
||||
}
|
||||
`;
|
||||
helpers.classCheckPrivateStaticAccess = helper("7.13.10")`
|
||||
export default function _classCheckPrivateStaticAccess(receiver, classConstructor) {
|
||||
if (receiver !== classConstructor) {
|
||||
throw new TypeError("Private static access of wrong provenance");
|
||||
}
|
||||
if (descriptor.get) {
|
||||
return descriptor.get.call(receiver);
|
||||
}
|
||||
return descriptor.value;
|
||||
}
|
||||
`;
|
||||
helpers.classStaticPrivateFieldSpecSet = helper("7.0.2")`
|
||||
export default function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
|
||||
if (receiver !== classConstructor) {
|
||||
throw new TypeError("Private static access of wrong provenance");
|
||||
helpers.classCheckPrivateStaticFieldDescriptor = helper("7.13.10")`
|
||||
export default function _classCheckPrivateStaticFieldDescriptor(descriptor, action) {
|
||||
if (descriptor === undefined) {
|
||||
throw new TypeError("attempted to " + action + " private static field before its declaration");
|
||||
}
|
||||
if (descriptor.set) {
|
||||
descriptor.set.call(receiver, value);
|
||||
} else {
|
||||
if (!descriptor.writable) {
|
||||
// This should only throw in strict mode, but class bodies are
|
||||
// always strict and private fields can only be used inside
|
||||
// class bodies.
|
||||
throw new TypeError("attempted to set read only private field");
|
||||
}
|
||||
descriptor.value = value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
`;
|
||||
helpers.classStaticPrivateMethodGet = helper("7.3.2")`
|
||||
export default function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
|
||||
if (receiver !== classConstructor) {
|
||||
throw new TypeError("Private static access of wrong provenance");
|
||||
}
|
||||
return method;
|
||||
}
|
||||
`;
|
||||
helpers.classStaticPrivateMethodSet = helper("7.3.2")`
|
||||
export default function _classStaticPrivateMethodSet() {
|
||||
throw new TypeError("attempted to set read only static private field");
|
||||
}
|
||||
`;
|
||||
helpers.decorate = helper("7.1.5")`
|
||||
@@ -2001,80 +1924,38 @@ helpers.classPrivateMethodGet = helper("7.1.6")`
|
||||
return fn;
|
||||
}
|
||||
`;
|
||||
helpers.classPrivateMethodSet = helper("7.1.6")`
|
||||
export default function _classPrivateMethodSet() {
|
||||
throw new TypeError("attempted to reassign private method");
|
||||
helpers.checkPrivateRedeclaration = helper("7.14.1")`
|
||||
export default function _checkPrivateRedeclaration(obj, privateCollection) {
|
||||
if (privateCollection.has(obj)) {
|
||||
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
||||
}
|
||||
}
|
||||
`;
|
||||
helpers.wrapRegExp = helper("7.2.6")`
|
||||
import wrapNativeSuper from "wrapNativeSuper";
|
||||
import getPrototypeOf from "getPrototypeOf";
|
||||
import possibleConstructorReturn from "possibleConstructorReturn";
|
||||
import inherits from "inherits";
|
||||
helpers.classPrivateFieldInitSpec = helper("7.14.1")`
|
||||
import checkPrivateRedeclaration from "checkPrivateRedeclaration";
|
||||
|
||||
export default function _wrapRegExp(re, groups) {
|
||||
_wrapRegExp = function(re, groups) {
|
||||
return new BabelRegExp(re, undefined, groups);
|
||||
};
|
||||
export default function _classPrivateFieldInitSpec(obj, privateMap, value) {
|
||||
checkPrivateRedeclaration(obj, privateMap);
|
||||
privateMap.set(obj, value);
|
||||
}
|
||||
`;
|
||||
helpers.classPrivateMethodInitSpec = helper("7.14.1")`
|
||||
import checkPrivateRedeclaration from "checkPrivateRedeclaration";
|
||||
|
||||
var _RegExp = wrapNativeSuper(RegExp);
|
||||
var _super = RegExp.prototype;
|
||||
var _groups = new WeakMap();
|
||||
|
||||
function BabelRegExp(re, flags, groups) {
|
||||
var _this = _RegExp.call(this, re, flags);
|
||||
// if the regex is recreated with 'g' flag
|
||||
_groups.set(_this, groups || _groups.get(re));
|
||||
return _this;
|
||||
export default function _classPrivateMethodInitSpec(obj, privateSet) {
|
||||
checkPrivateRedeclaration(obj, privateSet);
|
||||
privateSet.add(obj);
|
||||
}
|
||||
`;
|
||||
{
|
||||
helpers.classPrivateMethodSet = helper("7.1.6")`
|
||||
export default function _classPrivateMethodSet() {
|
||||
throw new TypeError("attempted to reassign private method");
|
||||
}
|
||||
inherits(BabelRegExp, _RegExp);
|
||||
|
||||
BabelRegExp.prototype.exec = function(str) {
|
||||
var result = _super.exec.call(this, str);
|
||||
if (result) result.groups = buildGroups(result, this);
|
||||
return result;
|
||||
};
|
||||
BabelRegExp.prototype[Symbol.replace] = function(str, substitution) {
|
||||
if (typeof substitution === "string") {
|
||||
var groups = _groups.get(this);
|
||||
return _super[Symbol.replace].call(
|
||||
this,
|
||||
str,
|
||||
substitution.replace(/\\$<([^>]+)>/g, function(_, name) {
|
||||
return "$" + groups[name];
|
||||
})
|
||||
);
|
||||
} else if (typeof substitution === "function") {
|
||||
var _this = this;
|
||||
return _super[Symbol.replace].call(
|
||||
this,
|
||||
str,
|
||||
function() {
|
||||
var args = [];
|
||||
args.push.apply(args, arguments);
|
||||
if (typeof args[args.length - 1] !== "object") {
|
||||
// Modern engines already pass result.groups as the last arg.
|
||||
args.push(buildGroups(args, _this));
|
||||
}
|
||||
return substitution.apply(this, args);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
return _super[Symbol.replace].call(this, str, substitution);
|
||||
}
|
||||
}
|
||||
|
||||
function buildGroups(result, re) {
|
||||
// NOTE: This function should return undefined if there are no groups,
|
||||
// but in that case Babel doesn't add the wrapper anyway.
|
||||
|
||||
var g = _groups.get(re);
|
||||
return Object.keys(g).reduce(function(groups, name) {
|
||||
groups[name] = result[g[name]];
|
||||
return groups;
|
||||
}, Object.create(null));
|
||||
}
|
||||
|
||||
return _wrapRegExp.apply(this, arguments);
|
||||
`;
|
||||
}
|
||||
helpers.identity = helper("7.17.0")`
|
||||
export default function _identity(x) {
|
||||
return x;
|
||||
}
|
||||
`;
|
||||
+530
@@ -0,0 +1,530 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = applyDecs;
|
||||
|
||||
function createMetadataMethodsForProperty(metadataMap, kind, property, decoratorFinishedRef) {
|
||||
return {
|
||||
getMetadata: function (key) {
|
||||
assertNotFinished(decoratorFinishedRef, "getMetadata");
|
||||
assertMetadataKey(key);
|
||||
var metadataForKey = metadataMap[key];
|
||||
if (metadataForKey === void 0) return void 0;
|
||||
|
||||
if (kind === 1) {
|
||||
var pub = metadataForKey.public;
|
||||
|
||||
if (pub !== void 0) {
|
||||
return pub[property];
|
||||
}
|
||||
} else if (kind === 2) {
|
||||
var priv = metadataForKey.private;
|
||||
|
||||
if (priv !== void 0) {
|
||||
return priv.get(property);
|
||||
}
|
||||
} else if (Object.hasOwnProperty.call(metadataForKey, "constructor")) {
|
||||
return metadataForKey.constructor;
|
||||
}
|
||||
},
|
||||
setMetadata: function (key, value) {
|
||||
assertNotFinished(decoratorFinishedRef, "setMetadata");
|
||||
assertMetadataKey(key);
|
||||
var metadataForKey = metadataMap[key];
|
||||
|
||||
if (metadataForKey === void 0) {
|
||||
metadataForKey = metadataMap[key] = {};
|
||||
}
|
||||
|
||||
if (kind === 1) {
|
||||
var pub = metadataForKey.public;
|
||||
|
||||
if (pub === void 0) {
|
||||
pub = metadataForKey.public = {};
|
||||
}
|
||||
|
||||
pub[property] = value;
|
||||
} else if (kind === 2) {
|
||||
var priv = metadataForKey.priv;
|
||||
|
||||
if (priv === void 0) {
|
||||
priv = metadataForKey.private = new Map();
|
||||
}
|
||||
|
||||
priv.set(property, value);
|
||||
} else {
|
||||
metadataForKey.constructor = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function convertMetadataMapToFinal(obj, metadataMap) {
|
||||
var parentMetadataMap = obj[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
||||
var metadataKeys = Object.getOwnPropertySymbols(metadataMap);
|
||||
if (metadataKeys.length === 0) return;
|
||||
|
||||
for (var i = 0; i < metadataKeys.length; i++) {
|
||||
var key = metadataKeys[i];
|
||||
var metaForKey = metadataMap[key];
|
||||
var parentMetaForKey = parentMetadataMap ? parentMetadataMap[key] : null;
|
||||
var pub = metaForKey.public;
|
||||
var parentPub = parentMetaForKey ? parentMetaForKey.public : null;
|
||||
|
||||
if (pub && parentPub) {
|
||||
Object.setPrototypeOf(pub, parentPub);
|
||||
}
|
||||
|
||||
var priv = metaForKey.private;
|
||||
|
||||
if (priv) {
|
||||
var privArr = Array.from(priv.values());
|
||||
var parentPriv = parentMetaForKey ? parentMetaForKey.private : null;
|
||||
|
||||
if (parentPriv) {
|
||||
privArr = privArr.concat(parentPriv);
|
||||
}
|
||||
|
||||
metaForKey.private = privArr;
|
||||
}
|
||||
|
||||
if (parentMetaForKey) {
|
||||
Object.setPrototypeOf(metaForKey, parentMetaForKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (parentMetadataMap) {
|
||||
Object.setPrototypeOf(metadataMap, parentMetadataMap);
|
||||
}
|
||||
|
||||
obj[Symbol.metadata || Symbol.for("Symbol.metadata")] = metadataMap;
|
||||
}
|
||||
|
||||
function createAddInitializerMethod(initializers, decoratorFinishedRef) {
|
||||
return function addInitializer(initializer) {
|
||||
assertNotFinished(decoratorFinishedRef, "addInitializer");
|
||||
assertCallable(initializer, "An initializer");
|
||||
initializers.push(initializer);
|
||||
};
|
||||
}
|
||||
|
||||
function memberDec(dec, name, desc, metadataMap, initializers, kind, isStatic, isPrivate, value) {
|
||||
var kindStr;
|
||||
|
||||
switch (kind) {
|
||||
case 1:
|
||||
kindStr = "accessor";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
kindStr = "method";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
kindStr = "getter";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
kindStr = "setter";
|
||||
break;
|
||||
|
||||
default:
|
||||
kindStr = "field";
|
||||
}
|
||||
|
||||
var ctx = {
|
||||
kind: kindStr,
|
||||
name: isPrivate ? "#" + name : name,
|
||||
isStatic: isStatic,
|
||||
isPrivate: isPrivate
|
||||
};
|
||||
var decoratorFinishedRef = {
|
||||
v: false
|
||||
};
|
||||
|
||||
if (kind !== 0) {
|
||||
ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
|
||||
}
|
||||
|
||||
var metadataKind, metadataName;
|
||||
|
||||
if (isPrivate) {
|
||||
metadataKind = 2;
|
||||
metadataName = Symbol(name);
|
||||
var access = {};
|
||||
|
||||
if (kind === 0) {
|
||||
access.get = desc.get;
|
||||
access.set = desc.set;
|
||||
} else if (kind === 2) {
|
||||
access.get = function () {
|
||||
return desc.value;
|
||||
};
|
||||
} else {
|
||||
if (kind === 1 || kind === 3) {
|
||||
access.get = function () {
|
||||
return desc.get.call(this);
|
||||
};
|
||||
}
|
||||
|
||||
if (kind === 1 || kind === 4) {
|
||||
access.set = function (v) {
|
||||
desc.set.call(this, v);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
ctx.access = access;
|
||||
} else {
|
||||
metadataKind = 1;
|
||||
metadataName = name;
|
||||
}
|
||||
|
||||
try {
|
||||
return dec(value, Object.assign(ctx, createMetadataMethodsForProperty(metadataMap, metadataKind, metadataName, decoratorFinishedRef)));
|
||||
} finally {
|
||||
decoratorFinishedRef.v = true;
|
||||
}
|
||||
}
|
||||
|
||||
function assertNotFinished(decoratorFinishedRef, fnName) {
|
||||
if (decoratorFinishedRef.v) {
|
||||
throw new Error("attempted to call " + fnName + " after decoration was finished");
|
||||
}
|
||||
}
|
||||
|
||||
function assertMetadataKey(key) {
|
||||
if (typeof key !== "symbol") {
|
||||
throw new TypeError("Metadata keys must be symbols, received: " + key);
|
||||
}
|
||||
}
|
||||
|
||||
function assertCallable(fn, hint) {
|
||||
if (typeof fn !== "function") {
|
||||
throw new TypeError(hint + " must be a function");
|
||||
}
|
||||
}
|
||||
|
||||
function assertValidReturnValue(kind, value) {
|
||||
var type = typeof value;
|
||||
|
||||
if (kind === 1) {
|
||||
if (type !== "object" || value === null) {
|
||||
throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
|
||||
}
|
||||
|
||||
if (value.get !== undefined) {
|
||||
assertCallable(value.get, "accessor.get");
|
||||
}
|
||||
|
||||
if (value.set !== undefined) {
|
||||
assertCallable(value.set, "accessor.set");
|
||||
}
|
||||
|
||||
if (value.init !== undefined) {
|
||||
assertCallable(value.init, "accessor.init");
|
||||
}
|
||||
|
||||
if (value.initializer !== undefined) {
|
||||
assertCallable(value.initializer, "accessor.initializer");
|
||||
}
|
||||
} else if (type !== "function") {
|
||||
var hint;
|
||||
|
||||
if (kind === 0) {
|
||||
hint = "field";
|
||||
} else if (kind === 10) {
|
||||
hint = "class";
|
||||
} else {
|
||||
hint = "method";
|
||||
}
|
||||
|
||||
throw new TypeError(hint + " decorators must return a function or void 0");
|
||||
}
|
||||
}
|
||||
|
||||
function getInit(desc) {
|
||||
var initializer;
|
||||
|
||||
if ((initializer = desc.init) == null && (initializer = desc.initializer) && typeof console !== "undefined") {
|
||||
console.warn(".initializer has been renamed to .init as of March 2022");
|
||||
}
|
||||
|
||||
return initializer;
|
||||
}
|
||||
|
||||
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers) {
|
||||
var decs = decInfo[0];
|
||||
var desc, initializer, value;
|
||||
|
||||
if (isPrivate) {
|
||||
if (kind === 0 || kind === 1) {
|
||||
desc = {
|
||||
get: decInfo[3],
|
||||
set: decInfo[4]
|
||||
};
|
||||
} else if (kind === 3) {
|
||||
desc = {
|
||||
get: decInfo[3]
|
||||
};
|
||||
} else if (kind === 4) {
|
||||
desc = {
|
||||
set: decInfo[3]
|
||||
};
|
||||
} else {
|
||||
desc = {
|
||||
value: decInfo[3]
|
||||
};
|
||||
}
|
||||
} else if (kind !== 0) {
|
||||
desc = Object.getOwnPropertyDescriptor(base, name);
|
||||
}
|
||||
|
||||
if (kind === 1) {
|
||||
value = {
|
||||
get: desc.get,
|
||||
set: desc.set
|
||||
};
|
||||
} else if (kind === 2) {
|
||||
value = desc.value;
|
||||
} else if (kind === 3) {
|
||||
value = desc.get;
|
||||
} else if (kind === 4) {
|
||||
value = desc.set;
|
||||
}
|
||||
|
||||
var newValue, get, set;
|
||||
|
||||
if (typeof decs === "function") {
|
||||
newValue = memberDec(decs, name, desc, metadataMap, initializers, kind, isStatic, isPrivate, value);
|
||||
|
||||
if (newValue !== void 0) {
|
||||
assertValidReturnValue(kind, newValue);
|
||||
|
||||
if (kind === 0) {
|
||||
initializer = newValue;
|
||||
} else if (kind === 1) {
|
||||
initializer = getInit(newValue);
|
||||
get = newValue.get || value.get;
|
||||
set = newValue.set || value.set;
|
||||
value = {
|
||||
get: get,
|
||||
set: set
|
||||
};
|
||||
} else {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var i = decs.length - 1; i >= 0; i--) {
|
||||
var dec = decs[i];
|
||||
newValue = memberDec(dec, name, desc, metadataMap, initializers, kind, isStatic, isPrivate, value);
|
||||
|
||||
if (newValue !== void 0) {
|
||||
assertValidReturnValue(kind, newValue);
|
||||
var newInit;
|
||||
|
||||
if (kind === 0) {
|
||||
newInit = newValue;
|
||||
} else if (kind === 1) {
|
||||
newInit = getInit(newValue);
|
||||
get = newValue.get || value.get;
|
||||
set = newValue.set || value.set;
|
||||
value = {
|
||||
get: get,
|
||||
set: set
|
||||
};
|
||||
} else {
|
||||
value = newValue;
|
||||
}
|
||||
|
||||
if (newInit !== void 0) {
|
||||
if (initializer === void 0) {
|
||||
initializer = newInit;
|
||||
} else if (typeof initializer === "function") {
|
||||
initializer = [initializer, newInit];
|
||||
} else {
|
||||
initializer.push(newInit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kind === 0 || kind === 1) {
|
||||
if (initializer === void 0) {
|
||||
initializer = function (instance, init) {
|
||||
return init;
|
||||
};
|
||||
} else if (typeof initializer !== "function") {
|
||||
var ownInitializers = initializer;
|
||||
|
||||
initializer = function (instance, init) {
|
||||
var value = init;
|
||||
|
||||
for (var i = 0; i < ownInitializers.length; i++) {
|
||||
value = ownInitializers[i].call(instance, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
} else {
|
||||
var originalInitializer = initializer;
|
||||
|
||||
initializer = function (instance, init) {
|
||||
return originalInitializer.call(instance, init);
|
||||
};
|
||||
}
|
||||
|
||||
ret.push(initializer);
|
||||
}
|
||||
|
||||
if (kind !== 0) {
|
||||
if (kind === 1) {
|
||||
desc.get = value.get;
|
||||
desc.set = value.set;
|
||||
} else if (kind === 2) {
|
||||
desc.value = value;
|
||||
} else if (kind === 3) {
|
||||
desc.get = value;
|
||||
} else if (kind === 4) {
|
||||
desc.set = value;
|
||||
}
|
||||
|
||||
if (isPrivate) {
|
||||
if (kind === 1) {
|
||||
ret.push(function (instance, args) {
|
||||
return value.get.call(instance, args);
|
||||
});
|
||||
ret.push(function (instance, args) {
|
||||
return value.set.call(instance, args);
|
||||
});
|
||||
} else if (kind === 2) {
|
||||
ret.push(value);
|
||||
} else {
|
||||
ret.push(function (instance, args) {
|
||||
return value.call(instance, args);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Object.defineProperty(base, name, desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function applyMemberDecs(ret, Class, protoMetadataMap, staticMetadataMap, decInfos) {
|
||||
var protoInitializers;
|
||||
var staticInitializers;
|
||||
var existingProtoNonFields = new Map();
|
||||
var existingStaticNonFields = new Map();
|
||||
|
||||
for (var i = 0; i < decInfos.length; i++) {
|
||||
var decInfo = decInfos[i];
|
||||
if (!Array.isArray(decInfo)) continue;
|
||||
var kind = decInfo[1];
|
||||
var name = decInfo[2];
|
||||
var isPrivate = decInfo.length > 3;
|
||||
var isStatic = kind >= 5;
|
||||
var base;
|
||||
var metadataMap;
|
||||
var initializers;
|
||||
|
||||
if (isStatic) {
|
||||
base = Class;
|
||||
metadataMap = staticMetadataMap;
|
||||
kind = kind - 5;
|
||||
|
||||
if (kind !== 0) {
|
||||
staticInitializers = staticInitializers || [];
|
||||
initializers = staticInitializers;
|
||||
}
|
||||
} else {
|
||||
base = Class.prototype;
|
||||
metadataMap = protoMetadataMap;
|
||||
|
||||
if (kind !== 0) {
|
||||
protoInitializers = protoInitializers || [];
|
||||
initializers = protoInitializers;
|
||||
}
|
||||
}
|
||||
|
||||
if (kind !== 0 && !isPrivate) {
|
||||
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
||||
var existingKind = existingNonFields.get(name) || 0;
|
||||
|
||||
if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
|
||||
throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
|
||||
} else if (!existingKind && kind > 2) {
|
||||
existingNonFields.set(name, kind);
|
||||
} else {
|
||||
existingNonFields.set(name, true);
|
||||
}
|
||||
}
|
||||
|
||||
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers);
|
||||
}
|
||||
|
||||
pushInitializers(ret, protoInitializers);
|
||||
pushInitializers(ret, staticInitializers);
|
||||
}
|
||||
|
||||
function pushInitializers(ret, initializers) {
|
||||
if (initializers) {
|
||||
ret.push(function (instance) {
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
initializers[i].call(instance);
|
||||
}
|
||||
|
||||
return instance;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function applyClassDecs(ret, targetClass, metadataMap, classDecs) {
|
||||
if (classDecs.length > 0) {
|
||||
var initializers = [];
|
||||
var newClass = targetClass;
|
||||
var name = targetClass.name;
|
||||
|
||||
for (var i = classDecs.length - 1; i >= 0; i--) {
|
||||
var decoratorFinishedRef = {
|
||||
v: false
|
||||
};
|
||||
|
||||
try {
|
||||
var ctx = Object.assign({
|
||||
kind: "class",
|
||||
name: name,
|
||||
addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef)
|
||||
}, createMetadataMethodsForProperty(metadataMap, 0, name, decoratorFinishedRef));
|
||||
var nextNewClass = classDecs[i](newClass, ctx);
|
||||
} finally {
|
||||
decoratorFinishedRef.v = true;
|
||||
}
|
||||
|
||||
if (nextNewClass !== undefined) {
|
||||
assertValidReturnValue(10, nextNewClass);
|
||||
newClass = nextNewClass;
|
||||
}
|
||||
}
|
||||
|
||||
ret.push(newClass, function () {
|
||||
for (var i = 0; i < initializers.length; i++) {
|
||||
initializers[i].call(newClass);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function applyDecs(targetClass, memberDecs, classDecs) {
|
||||
var ret = [];
|
||||
var staticMetadataMap = {};
|
||||
var protoMetadataMap = {};
|
||||
applyMemberDecs(ret, targetClass, protoMetadataMap, staticMetadataMap, memberDecs);
|
||||
convertMetadataMapToFinal(targetClass.prototype, protoMetadataMap);
|
||||
applyClassDecs(ret, targetClass, staticMetadataMap, classDecs);
|
||||
convertMetadataMapToFinal(targetClass, staticMetadataMap);
|
||||
return ret;
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _asyncIterator;
|
||||
|
||||
function _asyncIterator(iterable) {
|
||||
var method,
|
||||
async,
|
||||
sync,
|
||||
retry = 2;
|
||||
|
||||
if (typeof Symbol !== "undefined") {
|
||||
async = Symbol.asyncIterator;
|
||||
sync = Symbol.iterator;
|
||||
}
|
||||
|
||||
while (retry--) {
|
||||
if (async && (method = iterable[async]) != null) {
|
||||
return method.call(iterable);
|
||||
}
|
||||
|
||||
if (sync && (method = iterable[sync]) != null) {
|
||||
return new AsyncFromSyncIterator(method.call(iterable));
|
||||
}
|
||||
|
||||
async = "@@asyncIterator";
|
||||
sync = "@@iterator";
|
||||
}
|
||||
|
||||
throw new TypeError("Object is not async iterable");
|
||||
}
|
||||
|
||||
function AsyncFromSyncIterator(s) {
|
||||
AsyncFromSyncIterator = function (s) {
|
||||
this.s = s;
|
||||
this.n = s.next;
|
||||
};
|
||||
|
||||
AsyncFromSyncIterator.prototype = {
|
||||
s: null,
|
||||
n: null,
|
||||
next: function () {
|
||||
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
||||
},
|
||||
return: function (value) {
|
||||
var ret = this.s.return;
|
||||
|
||||
if (ret === undefined) {
|
||||
return Promise.resolve({
|
||||
value: value,
|
||||
done: true
|
||||
});
|
||||
}
|
||||
|
||||
return AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
|
||||
},
|
||||
throw: function (value) {
|
||||
var thr = this.s.return;
|
||||
if (thr === undefined) return Promise.reject(value);
|
||||
return AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
|
||||
}
|
||||
};
|
||||
|
||||
function AsyncFromSyncIteratorContinuation(r) {
|
||||
if (Object(r) !== r) {
|
||||
return Promise.reject(new TypeError(r + " is not an object."));
|
||||
}
|
||||
|
||||
var done = r.done;
|
||||
return Promise.resolve(r.value).then(function (value) {
|
||||
return {
|
||||
value: value,
|
||||
done: done
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return new AsyncFromSyncIterator(s);
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _createRawReactElement;
|
||||
var REACT_ELEMENT_TYPE;
|
||||
|
||||
function _createRawReactElement(type, props, key, children) {
|
||||
if (!REACT_ELEMENT_TYPE) {
|
||||
REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 0xeac7;
|
||||
}
|
||||
|
||||
var defaultProps = type && type.defaultProps;
|
||||
var childrenLength = arguments.length - 3;
|
||||
|
||||
if (!props && childrenLength !== 0) {
|
||||
props = {
|
||||
children: void 0
|
||||
};
|
||||
}
|
||||
|
||||
if (childrenLength === 1) {
|
||||
props.children = children;
|
||||
} else if (childrenLength > 1) {
|
||||
var childArray = new Array(childrenLength);
|
||||
|
||||
for (var i = 0; i < childrenLength; i++) {
|
||||
childArray[i] = arguments[i + 3];
|
||||
}
|
||||
|
||||
props.children = childArray;
|
||||
}
|
||||
|
||||
if (props && defaultProps) {
|
||||
for (var propName in defaultProps) {
|
||||
if (props[propName] === void 0) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
} else if (!props) {
|
||||
props = defaultProps || {};
|
||||
}
|
||||
|
||||
return {
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
type: type,
|
||||
key: key === undefined ? null : "" + key,
|
||||
ref: null,
|
||||
props: props,
|
||||
_owner: null
|
||||
};
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _objectSpread2;
|
||||
|
||||
var _defineProperty = require("defineProperty");
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
|
||||
if (enumerableOnly) {
|
||||
symbols = symbols.filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
}
|
||||
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread2(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function (key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function (key) {
|
||||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
+587
@@ -0,0 +1,587 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _regeneratorRuntime;
|
||||
|
||||
function _regeneratorRuntime() {
|
||||
"use strict";
|
||||
|
||||
exports.default = _regeneratorRuntime = function () {
|
||||
return exports;
|
||||
};
|
||||
|
||||
var exports = {};
|
||||
var Op = Object.prototype;
|
||||
var hasOwn = Op.hasOwnProperty;
|
||||
var undefined;
|
||||
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
||||
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
||||
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
||||
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
||||
|
||||
function define(obj, key, value) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
return obj[key];
|
||||
}
|
||||
|
||||
try {
|
||||
define({}, "");
|
||||
} catch (err) {
|
||||
define = function (obj, key, value) {
|
||||
return obj[key] = value;
|
||||
};
|
||||
}
|
||||
|
||||
function wrap(innerFn, outerFn, self, tryLocsList) {
|
||||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
||||
var generator = Object.create(protoGenerator.prototype);
|
||||
var context = new Context(tryLocsList || []);
|
||||
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
||||
return generator;
|
||||
}
|
||||
|
||||
exports.wrap = wrap;
|
||||
|
||||
function tryCatch(fn, obj, arg) {
|
||||
try {
|
||||
return {
|
||||
type: "normal",
|
||||
arg: fn.call(obj, arg)
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
type: "throw",
|
||||
arg: err
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var GenStateSuspendedStart = "suspendedStart";
|
||||
var GenStateSuspendedYield = "suspendedYield";
|
||||
var GenStateExecuting = "executing";
|
||||
var GenStateCompleted = "completed";
|
||||
var ContinueSentinel = {};
|
||||
|
||||
function Generator() {}
|
||||
|
||||
function GeneratorFunction() {}
|
||||
|
||||
function GeneratorFunctionPrototype() {}
|
||||
|
||||
var IteratorPrototype = {};
|
||||
define(IteratorPrototype, iteratorSymbol, function () {
|
||||
return this;
|
||||
});
|
||||
var getProto = Object.getPrototypeOf;
|
||||
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
||||
|
||||
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
||||
IteratorPrototype = NativeIteratorPrototype;
|
||||
}
|
||||
|
||||
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
||||
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
||||
define(Gp, "constructor", GeneratorFunctionPrototype);
|
||||
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
||||
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
||||
|
||||
function defineIteratorMethods(prototype) {
|
||||
["next", "throw", "return"].forEach(function (method) {
|
||||
define(prototype, method, function (arg) {
|
||||
return this._invoke(method, arg);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
exports.isGeneratorFunction = function (genFun) {
|
||||
var ctor = typeof genFun === "function" && genFun.constructor;
|
||||
return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
||||
};
|
||||
|
||||
exports.mark = function (genFun) {
|
||||
if (Object.setPrototypeOf) {
|
||||
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
||||
} else {
|
||||
genFun.__proto__ = GeneratorFunctionPrototype;
|
||||
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
||||
}
|
||||
|
||||
genFun.prototype = Object.create(Gp);
|
||||
return genFun;
|
||||
};
|
||||
|
||||
exports.awrap = function (arg) {
|
||||
return {
|
||||
__await: arg
|
||||
};
|
||||
};
|
||||
|
||||
function AsyncIterator(generator, PromiseImpl) {
|
||||
function invoke(method, arg, resolve, reject) {
|
||||
var record = tryCatch(generator[method], generator, arg);
|
||||
|
||||
if (record.type === "throw") {
|
||||
reject(record.arg);
|
||||
} else {
|
||||
var result = record.arg;
|
||||
var value = result.value;
|
||||
|
||||
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
||||
return PromiseImpl.resolve(value.__await).then(function (value) {
|
||||
invoke("next", value, resolve, reject);
|
||||
}, function (err) {
|
||||
invoke("throw", err, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
||||
result.value = unwrapped;
|
||||
resolve(result);
|
||||
}, function (error) {
|
||||
return invoke("throw", error, resolve, reject);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var previousPromise;
|
||||
|
||||
function enqueue(method, arg) {
|
||||
function callInvokeWithMethodAndArg() {
|
||||
return new PromiseImpl(function (resolve, reject) {
|
||||
invoke(method, arg, resolve, reject);
|
||||
});
|
||||
}
|
||||
|
||||
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
||||
}
|
||||
|
||||
this._invoke = enqueue;
|
||||
}
|
||||
|
||||
defineIteratorMethods(AsyncIterator.prototype);
|
||||
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
||||
return this;
|
||||
});
|
||||
exports.AsyncIterator = AsyncIterator;
|
||||
|
||||
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
||||
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
||||
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
||||
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
||||
return result.done ? result.value : iter.next();
|
||||
});
|
||||
};
|
||||
|
||||
function makeInvokeMethod(innerFn, self, context) {
|
||||
var state = GenStateSuspendedStart;
|
||||
return function invoke(method, arg) {
|
||||
if (state === GenStateExecuting) {
|
||||
throw new Error("Generator is already running");
|
||||
}
|
||||
|
||||
if (state === GenStateCompleted) {
|
||||
if (method === "throw") {
|
||||
throw arg;
|
||||
}
|
||||
|
||||
return doneResult();
|
||||
}
|
||||
|
||||
context.method = method;
|
||||
context.arg = arg;
|
||||
|
||||
while (true) {
|
||||
var delegate = context.delegate;
|
||||
|
||||
if (delegate) {
|
||||
var delegateResult = maybeInvokeDelegate(delegate, context);
|
||||
|
||||
if (delegateResult) {
|
||||
if (delegateResult === ContinueSentinel) continue;
|
||||
return delegateResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (context.method === "next") {
|
||||
context.sent = context._sent = context.arg;
|
||||
} else if (context.method === "throw") {
|
||||
if (state === GenStateSuspendedStart) {
|
||||
state = GenStateCompleted;
|
||||
throw context.arg;
|
||||
}
|
||||
|
||||
context.dispatchException(context.arg);
|
||||
} else if (context.method === "return") {
|
||||
context.abrupt("return", context.arg);
|
||||
}
|
||||
|
||||
state = GenStateExecuting;
|
||||
var record = tryCatch(innerFn, self, context);
|
||||
|
||||
if (record.type === "normal") {
|
||||
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
||||
|
||||
if (record.arg === ContinueSentinel) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return {
|
||||
value: record.arg,
|
||||
done: context.done
|
||||
};
|
||||
} else if (record.type === "throw") {
|
||||
state = GenStateCompleted;
|
||||
context.method = "throw";
|
||||
context.arg = record.arg;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function maybeInvokeDelegate(delegate, context) {
|
||||
var method = delegate.iterator[context.method];
|
||||
|
||||
if (method === undefined) {
|
||||
context.delegate = null;
|
||||
|
||||
if (context.method === "throw") {
|
||||
if (delegate.iterator["return"]) {
|
||||
context.method = "return";
|
||||
context.arg = undefined;
|
||||
maybeInvokeDelegate(delegate, context);
|
||||
|
||||
if (context.method === "throw") {
|
||||
return ContinueSentinel;
|
||||
}
|
||||
}
|
||||
|
||||
context.method = "throw";
|
||||
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
||||
}
|
||||
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
var record = tryCatch(method, delegate.iterator, context.arg);
|
||||
|
||||
if (record.type === "throw") {
|
||||
context.method = "throw";
|
||||
context.arg = record.arg;
|
||||
context.delegate = null;
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
var info = record.arg;
|
||||
|
||||
if (!info) {
|
||||
context.method = "throw";
|
||||
context.arg = new TypeError("iterator result is not an object");
|
||||
context.delegate = null;
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
if (info.done) {
|
||||
context[delegate.resultName] = info.value;
|
||||
context.next = delegate.nextLoc;
|
||||
|
||||
if (context.method !== "return") {
|
||||
context.method = "next";
|
||||
context.arg = undefined;
|
||||
}
|
||||
} else {
|
||||
return info;
|
||||
}
|
||||
|
||||
context.delegate = null;
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
defineIteratorMethods(Gp);
|
||||
define(Gp, toStringTagSymbol, "Generator");
|
||||
define(Gp, iteratorSymbol, function () {
|
||||
return this;
|
||||
});
|
||||
define(Gp, "toString", function () {
|
||||
return "[object Generator]";
|
||||
});
|
||||
|
||||
function pushTryEntry(locs) {
|
||||
var entry = {
|
||||
tryLoc: locs[0]
|
||||
};
|
||||
|
||||
if (1 in locs) {
|
||||
entry.catchLoc = locs[1];
|
||||
}
|
||||
|
||||
if (2 in locs) {
|
||||
entry.finallyLoc = locs[2];
|
||||
entry.afterLoc = locs[3];
|
||||
}
|
||||
|
||||
this.tryEntries.push(entry);
|
||||
}
|
||||
|
||||
function resetTryEntry(entry) {
|
||||
var record = entry.completion || {};
|
||||
record.type = "normal";
|
||||
delete record.arg;
|
||||
entry.completion = record;
|
||||
}
|
||||
|
||||
function Context(tryLocsList) {
|
||||
this.tryEntries = [{
|
||||
tryLoc: "root"
|
||||
}];
|
||||
tryLocsList.forEach(pushTryEntry, this);
|
||||
this.reset(true);
|
||||
}
|
||||
|
||||
exports.keys = function (object) {
|
||||
var keys = [];
|
||||
|
||||
for (var key in object) {
|
||||
keys.push(key);
|
||||
}
|
||||
|
||||
keys.reverse();
|
||||
return function next() {
|
||||
while (keys.length) {
|
||||
var key = keys.pop();
|
||||
|
||||
if (key in object) {
|
||||
next.value = key;
|
||||
next.done = false;
|
||||
return next;
|
||||
}
|
||||
}
|
||||
|
||||
next.done = true;
|
||||
return next;
|
||||
};
|
||||
};
|
||||
|
||||
function values(iterable) {
|
||||
if (iterable) {
|
||||
var iteratorMethod = iterable[iteratorSymbol];
|
||||
|
||||
if (iteratorMethod) {
|
||||
return iteratorMethod.call(iterable);
|
||||
}
|
||||
|
||||
if (typeof iterable.next === "function") {
|
||||
return iterable;
|
||||
}
|
||||
|
||||
if (!isNaN(iterable.length)) {
|
||||
var i = -1,
|
||||
next = function next() {
|
||||
while (++i < iterable.length) {
|
||||
if (hasOwn.call(iterable, i)) {
|
||||
next.value = iterable[i];
|
||||
next.done = false;
|
||||
return next;
|
||||
}
|
||||
}
|
||||
|
||||
next.value = undefined;
|
||||
next.done = true;
|
||||
return next;
|
||||
};
|
||||
|
||||
return next.next = next;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
next: doneResult
|
||||
};
|
||||
}
|
||||
|
||||
exports.values = values;
|
||||
|
||||
function doneResult() {
|
||||
return {
|
||||
value: undefined,
|
||||
done: true
|
||||
};
|
||||
}
|
||||
|
||||
Context.prototype = {
|
||||
constructor: Context,
|
||||
reset: function (skipTempReset) {
|
||||
this.prev = 0;
|
||||
this.next = 0;
|
||||
this.sent = this._sent = undefined;
|
||||
this.done = false;
|
||||
this.delegate = null;
|
||||
this.method = "next";
|
||||
this.arg = undefined;
|
||||
this.tryEntries.forEach(resetTryEntry);
|
||||
|
||||
if (!skipTempReset) {
|
||||
for (var name in this) {
|
||||
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
||||
this[name] = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
stop: function () {
|
||||
this.done = true;
|
||||
var rootEntry = this.tryEntries[0];
|
||||
var rootRecord = rootEntry.completion;
|
||||
|
||||
if (rootRecord.type === "throw") {
|
||||
throw rootRecord.arg;
|
||||
}
|
||||
|
||||
return this.rval;
|
||||
},
|
||||
dispatchException: function (exception) {
|
||||
if (this.done) {
|
||||
throw exception;
|
||||
}
|
||||
|
||||
var context = this;
|
||||
|
||||
function handle(loc, caught) {
|
||||
record.type = "throw";
|
||||
record.arg = exception;
|
||||
context.next = loc;
|
||||
|
||||
if (caught) {
|
||||
context.method = "next";
|
||||
context.arg = undefined;
|
||||
}
|
||||
|
||||
return !!caught;
|
||||
}
|
||||
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
var record = entry.completion;
|
||||
|
||||
if (entry.tryLoc === "root") {
|
||||
return handle("end");
|
||||
}
|
||||
|
||||
if (entry.tryLoc <= this.prev) {
|
||||
var hasCatch = hasOwn.call(entry, "catchLoc");
|
||||
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
||||
|
||||
if (hasCatch && hasFinally) {
|
||||
if (this.prev < entry.catchLoc) {
|
||||
return handle(entry.catchLoc, true);
|
||||
} else if (this.prev < entry.finallyLoc) {
|
||||
return handle(entry.finallyLoc);
|
||||
}
|
||||
} else if (hasCatch) {
|
||||
if (this.prev < entry.catchLoc) {
|
||||
return handle(entry.catchLoc, true);
|
||||
}
|
||||
} else if (hasFinally) {
|
||||
if (this.prev < entry.finallyLoc) {
|
||||
return handle(entry.finallyLoc);
|
||||
}
|
||||
} else {
|
||||
throw new Error("try statement without catch or finally");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
abrupt: function (type, arg) {
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
|
||||
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
||||
var finallyEntry = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
||||
finallyEntry = null;
|
||||
}
|
||||
|
||||
var record = finallyEntry ? finallyEntry.completion : {};
|
||||
record.type = type;
|
||||
record.arg = arg;
|
||||
|
||||
if (finallyEntry) {
|
||||
this.method = "next";
|
||||
this.next = finallyEntry.finallyLoc;
|
||||
return ContinueSentinel;
|
||||
}
|
||||
|
||||
return this.complete(record);
|
||||
},
|
||||
complete: function (record, afterLoc) {
|
||||
if (record.type === "throw") {
|
||||
throw record.arg;
|
||||
}
|
||||
|
||||
if (record.type === "break" || record.type === "continue") {
|
||||
this.next = record.arg;
|
||||
} else if (record.type === "return") {
|
||||
this.rval = this.arg = record.arg;
|
||||
this.method = "return";
|
||||
this.next = "end";
|
||||
} else if (record.type === "normal" && afterLoc) {
|
||||
this.next = afterLoc;
|
||||
}
|
||||
|
||||
return ContinueSentinel;
|
||||
},
|
||||
finish: function (finallyLoc) {
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
|
||||
if (entry.finallyLoc === finallyLoc) {
|
||||
this.complete(entry.completion, entry.afterLoc);
|
||||
resetTryEntry(entry);
|
||||
return ContinueSentinel;
|
||||
}
|
||||
}
|
||||
},
|
||||
catch: function (tryLoc) {
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
|
||||
if (entry.tryLoc === tryLoc) {
|
||||
var record = entry.completion;
|
||||
|
||||
if (record.type === "throw") {
|
||||
var thrown = record.arg;
|
||||
resetTryEntry(entry);
|
||||
}
|
||||
|
||||
return thrown;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("illegal catch attempt");
|
||||
},
|
||||
delegateYield: function (iterable, resultName, nextLoc) {
|
||||
this.delegate = {
|
||||
iterator: values(iterable),
|
||||
resultName: resultName,
|
||||
nextLoc: nextLoc
|
||||
};
|
||||
|
||||
if (this.method === "next") {
|
||||
this.arg = undefined;
|
||||
}
|
||||
|
||||
return ContinueSentinel;
|
||||
}
|
||||
};
|
||||
return exports;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _typeof;
|
||||
|
||||
function _typeof(obj) {
|
||||
"@babel/helpers - typeof";
|
||||
|
||||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
||||
exports.default = _typeof = function (obj) {
|
||||
return typeof obj;
|
||||
};
|
||||
} else {
|
||||
exports.default = _typeof = function (obj) {
|
||||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
||||
};
|
||||
}
|
||||
|
||||
return _typeof(obj);
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _wrapRegExp;
|
||||
|
||||
var _setPrototypeOf = require("setPrototypeOf");
|
||||
|
||||
var _inherits = require("inherits");
|
||||
|
||||
function _wrapRegExp() {
|
||||
exports.default = _wrapRegExp = function (re, groups) {
|
||||
return new BabelRegExp(re, undefined, groups);
|
||||
};
|
||||
|
||||
var _super = RegExp.prototype;
|
||||
|
||||
var _groups = new WeakMap();
|
||||
|
||||
function BabelRegExp(re, flags, groups) {
|
||||
var _this = new RegExp(re, flags);
|
||||
|
||||
_groups.set(_this, groups || _groups.get(re));
|
||||
|
||||
return _setPrototypeOf(_this, BabelRegExp.prototype);
|
||||
}
|
||||
|
||||
_inherits(BabelRegExp, RegExp);
|
||||
|
||||
BabelRegExp.prototype.exec = function (str) {
|
||||
var result = _super.exec.call(this, str);
|
||||
|
||||
if (result) result.groups = buildGroups(result, this);
|
||||
return result;
|
||||
};
|
||||
|
||||
BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
|
||||
if (typeof substitution === "string") {
|
||||
var groups = _groups.get(this);
|
||||
|
||||
return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
|
||||
return "$" + groups[name];
|
||||
}));
|
||||
} else if (typeof substitution === "function") {
|
||||
var _this = this;
|
||||
|
||||
return _super[Symbol.replace].call(this, str, function () {
|
||||
var args = arguments;
|
||||
|
||||
if (typeof args[args.length - 1] !== "object") {
|
||||
args = [].slice.call(args);
|
||||
args.push(buildGroups(args, _this));
|
||||
}
|
||||
|
||||
return substitution.apply(this, args);
|
||||
});
|
||||
} else {
|
||||
return _super[Symbol.replace].call(this, str, substitution);
|
||||
}
|
||||
};
|
||||
|
||||
function buildGroups(result, re) {
|
||||
var g = _groups.get(re);
|
||||
|
||||
return Object.keys(g).reduce(function (groups, name) {
|
||||
groups[name] = result[g[name]];
|
||||
return groups;
|
||||
}, Object.create(null));
|
||||
}
|
||||
|
||||
return _wrapRegExp.apply(this, arguments);
|
||||
}
|
||||
+79
-84
@@ -3,23 +3,26 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.get = get;
|
||||
exports.minVersion = minVersion;
|
||||
exports.getDependencies = getDependencies;
|
||||
exports.default = void 0;
|
||||
exports.ensure = ensure;
|
||||
exports.default = exports.list = void 0;
|
||||
exports.get = get;
|
||||
exports.getDependencies = getDependencies;
|
||||
exports.list = void 0;
|
||||
exports.minVersion = minVersion;
|
||||
|
||||
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
||||
var _traverse = require("@babel/traverse");
|
||||
|
||||
var t = _interopRequireWildcard(require("@babel/types"));
|
||||
var _t = require("@babel/types");
|
||||
|
||||
var _helpers = _interopRequireDefault(require("./helpers"));
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
const {
|
||||
assignmentExpression,
|
||||
cloneNode,
|
||||
expressionStatement,
|
||||
file,
|
||||
identifier
|
||||
} = _t;
|
||||
|
||||
function makePath(path) {
|
||||
const parts = [];
|
||||
@@ -32,7 +35,7 @@ function makePath(path) {
|
||||
return parts.reverse().join(".");
|
||||
}
|
||||
|
||||
let fileClass = undefined;
|
||||
let FileClass = undefined;
|
||||
|
||||
function getHelperMetadata(file) {
|
||||
const globals = new Set();
|
||||
@@ -63,14 +66,11 @@ function getHelperMetadata(file) {
|
||||
ExportDefaultDeclaration(child) {
|
||||
const decl = child.get("declaration");
|
||||
|
||||
if (decl.isFunctionDeclaration()) {
|
||||
if (!decl.node.id) {
|
||||
throw decl.buildCodeFrameError("Helpers should give names to their exported func declaration");
|
||||
}
|
||||
|
||||
exportName = decl.node.id.name;
|
||||
if (!decl.isFunctionDeclaration() || !decl.node.id) {
|
||||
throw decl.buildCodeFrameError("Helpers can only export named function declarations");
|
||||
}
|
||||
|
||||
exportName = decl.node.id.name;
|
||||
exportPath = makePath(child);
|
||||
},
|
||||
|
||||
@@ -100,7 +100,7 @@ function getHelperMetadata(file) {
|
||||
|
||||
ReferencedIdentifier(child) {
|
||||
const name = child.node.name;
|
||||
const binding = child.scope.getBinding(name, true);
|
||||
const binding = child.scope.getBinding(name);
|
||||
|
||||
if (!binding) {
|
||||
globals.add(name);
|
||||
@@ -119,7 +119,7 @@ function getHelperMetadata(file) {
|
||||
|
||||
const binding = child.scope.getBinding(exportName);
|
||||
|
||||
if (binding == null ? void 0 : binding.scope.path.isProgram()) {
|
||||
if (binding != null && binding.scope.path.isProgram()) {
|
||||
exportBindingAssignments.push(makePath(child));
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ function getHelperMetadata(file) {
|
||||
};
|
||||
(0, _traverse.default)(file.ast, dependencyVisitor, file.scope);
|
||||
(0, _traverse.default)(file.ast, referenceVisitor, file.scope);
|
||||
if (!exportPath) throw new Error("Helpers must default-export something.");
|
||||
if (!exportPath) throw new Error("Helpers must have a default export.");
|
||||
exportBindingAssignments.reverse();
|
||||
return {
|
||||
globals: Array.from(globals),
|
||||
@@ -174,50 +174,37 @@ function permuteHelperAST(file, metadata, id, localBindings, getDependency) {
|
||||
toRename[exportName] = id.name;
|
||||
}
|
||||
|
||||
const visitor = {
|
||||
Program(path) {
|
||||
const exp = path.get(exportPath);
|
||||
const imps = importPaths.map(p => path.get(p));
|
||||
const impsBindingRefs = importBindingsReferences.map(p => path.get(p));
|
||||
const decl = exp.get("declaration");
|
||||
const {
|
||||
path
|
||||
} = file;
|
||||
const exp = path.get(exportPath);
|
||||
const imps = importPaths.map(p => path.get(p));
|
||||
const impsBindingRefs = importBindingsReferences.map(p => path.get(p));
|
||||
const decl = exp.get("declaration");
|
||||
|
||||
if (id.type === "Identifier") {
|
||||
if (decl.isFunctionDeclaration()) {
|
||||
exp.replaceWith(decl);
|
||||
} else {
|
||||
exp.replaceWith(t.variableDeclaration("var", [t.variableDeclarator(id, decl.node)]));
|
||||
}
|
||||
} else if (id.type === "MemberExpression") {
|
||||
if (decl.isFunctionDeclaration()) {
|
||||
exportBindingAssignments.forEach(assignPath => {
|
||||
const assign = path.get(assignPath);
|
||||
assign.replaceWith(t.assignmentExpression("=", id, assign.node));
|
||||
});
|
||||
exp.replaceWith(decl);
|
||||
path.pushContainer("body", t.expressionStatement(t.assignmentExpression("=", id, t.identifier(exportName))));
|
||||
} else {
|
||||
exp.replaceWith(t.expressionStatement(t.assignmentExpression("=", id, decl.node)));
|
||||
}
|
||||
} else {
|
||||
throw new Error("Unexpected helper format.");
|
||||
}
|
||||
if (id.type === "Identifier") {
|
||||
exp.replaceWith(decl);
|
||||
} else if (id.type === "MemberExpression") {
|
||||
exportBindingAssignments.forEach(assignPath => {
|
||||
const assign = path.get(assignPath);
|
||||
assign.replaceWith(assignmentExpression("=", id, assign.node));
|
||||
});
|
||||
exp.replaceWith(decl);
|
||||
path.pushContainer("body", expressionStatement(assignmentExpression("=", id, identifier(exportName))));
|
||||
} else {
|
||||
throw new Error("Unexpected helper format.");
|
||||
}
|
||||
|
||||
Object.keys(toRename).forEach(name => {
|
||||
path.scope.rename(name, toRename[name]);
|
||||
});
|
||||
Object.keys(toRename).forEach(name => {
|
||||
path.scope.rename(name, toRename[name]);
|
||||
});
|
||||
|
||||
for (const path of imps) path.remove();
|
||||
for (const path of imps) path.remove();
|
||||
|
||||
for (const path of impsBindingRefs) {
|
||||
const node = t.cloneNode(dependenciesRefs[path.node.name]);
|
||||
path.replaceWith(node);
|
||||
}
|
||||
|
||||
path.stop();
|
||||
}
|
||||
|
||||
};
|
||||
(0, _traverse.default)(file.ast, visitor, file.scope);
|
||||
for (const path of impsBindingRefs) {
|
||||
const node = cloneNode(dependenciesRefs[path.node.name]);
|
||||
path.replaceWith(node);
|
||||
}
|
||||
}
|
||||
|
||||
const helperData = Object.create(null);
|
||||
@@ -234,23 +221,34 @@ function loadHelper(name) {
|
||||
}
|
||||
|
||||
const fn = () => {
|
||||
const file = {
|
||||
ast: t.file(helper.ast())
|
||||
};
|
||||
|
||||
if (fileClass) {
|
||||
return new fileClass({
|
||||
filename: `babel-helper://${name}`
|
||||
}, file);
|
||||
{
|
||||
if (!FileClass) {
|
||||
const fakeFile = {
|
||||
ast: file(helper.ast()),
|
||||
path: null
|
||||
};
|
||||
(0, _traverse.default)(fakeFile.ast, {
|
||||
Program: path => (fakeFile.path = path).stop()
|
||||
});
|
||||
return fakeFile;
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
return new FileClass({
|
||||
filename: `babel-helper://${name}`
|
||||
}, {
|
||||
ast: file(helper.ast()),
|
||||
code: "[internal Babel helper code]",
|
||||
inputMap: null
|
||||
});
|
||||
};
|
||||
|
||||
const metadata = getHelperMetadata(fn());
|
||||
let metadata = null;
|
||||
helperData[name] = {
|
||||
minVersion: helper.minVersion,
|
||||
|
||||
build(getDependency, id, localBindings) {
|
||||
const file = fn();
|
||||
metadata || (metadata = getHelperMetadata(file));
|
||||
permuteHelperAST(file, metadata, id, localBindings, getDependency);
|
||||
return {
|
||||
nodes: file.ast.program.body,
|
||||
@@ -258,11 +256,11 @@ function loadHelper(name) {
|
||||
};
|
||||
},
|
||||
|
||||
minVersion() {
|
||||
return helper.minVersion;
|
||||
},
|
||||
getDependencies() {
|
||||
metadata || (metadata = getHelperMetadata(fn()));
|
||||
return Array.from(metadata.dependencies.values());
|
||||
}
|
||||
|
||||
dependencies: metadata.dependencies
|
||||
};
|
||||
}
|
||||
|
||||
@@ -274,22 +272,19 @@ function get(name, getDependency, id, localBindings) {
|
||||
}
|
||||
|
||||
function minVersion(name) {
|
||||
return loadHelper(name).minVersion();
|
||||
return loadHelper(name).minVersion;
|
||||
}
|
||||
|
||||
function getDependencies(name) {
|
||||
return Array.from(loadHelper(name).dependencies.values());
|
||||
return loadHelper(name).getDependencies();
|
||||
}
|
||||
|
||||
function ensure(name, newFileClass) {
|
||||
if (!fileClass) {
|
||||
fileClass = newFileClass;
|
||||
}
|
||||
|
||||
FileClass || (FileClass = newFileClass);
|
||||
loadHelper(name);
|
||||
}
|
||||
|
||||
const list = Object.keys(_helpers.default).map(name => name.replace(/^_/, "")).filter(name => name !== "__esModule");
|
||||
const list = Object.keys(_helpers.default).map(name => name.replace(/^_/, ""));
|
||||
exports.list = list;
|
||||
var _default = get;
|
||||
exports.default = _default;
|
||||
Reference in New Issue
Block a user