1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- function _template() {
- const data = _interopRequireDefault(require("@babel/template"));
- _template = function () {
- return data;
- };
- return data;
- }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- const helpers = Object.create(null);
- var _default = helpers;
- exports.default = _default;
- const helper = minVersion => tpl => ({
- minVersion,
- ast: () => _template().default.program.ast(tpl)
- });
- helpers.typeof = helper("7.0.0-beta.0")`
- export default function _typeof(obj) {
- 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 (props && defaultProps) {
- for (var propName in defaultProps) {
- if (props[propName] === void 0) {
- props[propName] = defaultProps[propName];
- }
- }
- } else if (!props) {
- props = defaultProps || {};
- }
- 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;
- }
- 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;
- }
- `;
- helpers.AsyncGenerator = helper("7.0.0-beta.0")`
- import AwaitValue from "AwaitValue";
- export default function AsyncGenerator(gen) {
- var front, back;
- function send(key, arg) {
- return new Promise(function (resolve, reject) {
- var request = {
- key: key,
- arg: arg,
- resolve: resolve,
- reject: reject,
- next: null,
- };
- if (back) {
- back = back.next = request;
- } else {
- front = back = request;
- resume(key, arg);
- }
- });
- }
- function resume(key, arg) {
- try {
- var result = gen[key](arg)
- var value = result.value;
- var wrappedAwait = value instanceof AwaitValue;
- Promise.resolve(wrappedAwait ? value.wrapped : value).then(
- function (arg) {
- if (wrappedAwait) {
- resume("next", arg);
- return
- }
- settle(result.done ? "return" : "normal", arg);
- },
- function (err) { resume("throw", err); });
- } catch (err) {
- settle("throw", err);
- }
- }
- function settle(type, value) {
- switch (type) {
- case "return":
- front.resolve({ value: value, done: true });
- break;
- case "throw":
- front.reject(value);
- break;
- default:
- front.resolve({ value: value, done: false });
- break;
- }
- front = front.next;
- if (front) {
- resume(front.key, front.arg);
- } else {
- back = null;
- }
- }
- this._invoke = send;
- // Hide "return" method if generator return is not supported
- if (typeof gen.return !== "function") {
- this.return = undefined;
- }
- }
- if (typeof Symbol === "function" && Symbol.asyncIterator) {
- AsyncGenerator.prototype[Symbol.asyncIterator] = function () { return this; };
- }
- AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };
- AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); };
- AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); };
- `;
- helpers.wrapAsyncGenerator = helper("7.0.0-beta.0")`
- import AsyncGenerator from "AsyncGenerator";
- export default function _wrapAsyncGenerator(fn) {
- return function () {
- return new AsyncGenerator(fn.apply(this, arguments));
- };
- }
- `;
- helpers.awaitAsyncGenerator = helper("7.0.0-beta.0")`
- import AwaitValue from "AwaitValue";
- export default function _awaitAsyncGenerator(value) {
- return new AwaitValue(value);
- }
- `;
- helpers.asyncGeneratorDelegate = helper("7.0.0-beta.0")`
- export default function _asyncGeneratorDelegate(inner, awaitWrap) {
- var iter = {}, waiting = false;
- function pump(key, value) {
- waiting = true;
- value = new Promise(function (resolve) { resolve(inner[key](value)); });
- return { done: false, value: awaitWrap(value) };
- };
- if (typeof Symbol === "function" && Symbol.iterator) {
- iter[Symbol.iterator] = function () { return this; };
- }
- iter.next = function (value) {
- if (waiting) {
- waiting = false;
- return value;
- }
- return pump("next", value);
- };
- if (typeof inner.throw === "function") {
- iter.throw = function (value) {
- if (waiting) {
- waiting = false;
- throw value;
- }
- return pump("throw", value);
- };
- }
- if (typeof inner.return === "function") {
- iter.return = function (value) {
- return pump("return", value);
- };
- }
- return iter;
- }
- `;
- helpers.asyncToGenerator = helper("7.0.0-beta.0")`
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
- try {
- var info = gen[key](arg);
- var value = info.value;
- } catch (error) {
- reject(error);
- return;
- }
- if (info.done) {
- resolve(value);
- } else {
- Promise.resolve(value).then(_next, _throw);
- }
- }
- export default function _asyncToGenerator(fn) {
- return function () {
- var self = this, args = arguments;
- return new Promise(function (resolve, reject) {
- var gen = fn.apply(self, args);
- function _next(value) {
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
- }
- function _throw(err) {
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
- }
- _next(undefined);
- });
- };
- }
- `;
- helpers.classCallCheck = helper("7.0.0-beta.0")`
- export default function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- `;
- helpers.createClass = helper("7.0.0-beta.0")`
- 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);
- }
- }
- export default function _createClass(Constructor, protoProps, staticProps) {
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
- if (staticProps) _defineProperties(Constructor, staticProps);
- return Constructor;
- }
- `;
- helpers.defineEnumerableProperties = helper("7.0.0-beta.0")`
- export default function _defineEnumerableProperties(obj, descs) {
- for (var key in descs) {
- var desc = descs[key];
- desc.configurable = desc.enumerable = true;
- if ("value" in desc) desc.writable = true;
- Object.defineProperty(obj, key, desc);
- }
- // Symbols are not enumerated over by for-in loops. If native
- // Symbols are available, fetch all of the descs object's own
- // symbol properties and define them on our target object too.
- if (Object.getOwnPropertySymbols) {
- var objectSymbols = Object.getOwnPropertySymbols(descs);
- for (var i = 0; i < objectSymbols.length; i++) {
- var sym = objectSymbols[i];
- var desc = descs[sym];
- desc.configurable = desc.enumerable = true;
- if ("value" in desc) desc.writable = true;
- Object.defineProperty(obj, sym, desc);
- }
- }
- return obj;
- }
- `;
- helpers.defaults = helper("7.0.0-beta.0")`
- export default function _defaults(obj, defaults) {
- var keys = Object.getOwnPropertyNames(defaults);
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- var value = Object.getOwnPropertyDescriptor(defaults, key);
- if (value && value.configurable && obj[key] === undefined) {
- Object.defineProperty(obj, key, value);
- }
- }
- return obj;
- }
- `;
- helpers.defineProperty = helper("7.0.0-beta.0")`
- export default function _defineProperty(obj, key, value) {
- // Shortcircuit the slow defineProperty path when possible.
- // We are trying to avoid issues where setters defined on the
- // prototype cause side effects under the fast path of simple
- // assignment. By checking for existence of the property with
- // the in operator, we can optimize most of this overhead away.
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
- return obj;
- }
- `;
- helpers.extends = helper("7.0.0-beta.0")`
- export default function _extends() {
- _extends = Object.assign || function (target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
- for (var key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
- }
- return target;
- };
- return _extends.apply(this, arguments);
- }
- `;
- helpers.objectSpread = helper("7.0.0-beta.0")`
- import defineProperty from "defineProperty";
- export default function _objectSpread(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = (arguments[i] != null) ? arguments[i] : {};
- var ownKeys = Object.keys(source);
- if (typeof Object.getOwnPropertySymbols === 'function') {
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
- }));
- }
- ownKeys.forEach(function(key) {
- defineProperty(target, key, source[key]);
- });
- }
- return target;
- }
- `;
- helpers.objectSpread2 = helper("7.5.0")`
- import defineProperty from "defineProperty";
- function ownKeys(object, enumerableOnly) {
- var keys = Object.keys(object);
- if (Object.getOwnPropertySymbols) {
- keys.push.apply(keys, Object.getOwnPropertySymbols(object));
- }
- if (enumerableOnly) keys = keys.filter(function (sym) {
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
- });
- 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(source, true).forEach(function (key) {
- defineProperty(target, key, source[key]);
- });
- } else if (Object.getOwnPropertyDescriptors) {
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
- } else {
- ownKeys(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";
- export default function _inherits(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function");
- }
- subClass.prototype = Object.create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- writable: true,
- configurable: true
- }
- });
- if (superClass) setPrototypeOf(subClass, superClass);
- }
- `;
- helpers.inheritsLoose = helper("7.0.0-beta.0")`
- export default function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- `;
- helpers.getPrototypeOf = helper("7.0.0-beta.0")`
- export default function _getPrototypeOf(o) {
- _getPrototypeOf = Object.setPrototypeOf
- ? Object.getPrototypeOf
- : function _getPrototypeOf(o) {
- return o.__proto__ || Object.getPrototypeOf(o);
- };
- return _getPrototypeOf(o);
- }
- `;
- 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;
- };
- return _setPrototypeOf(o, p);
- }
- `;
- helpers.construct = helper("7.0.0-beta.0")`
- import setPrototypeOf from "setPrototypeOf";
- function isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
- // core-js@3
- if (Reflect.construct.sham) return false;
- // Proxy can't be polyfilled. Every browser implemented
- // proxies before or at the same time as Reflect.construct,
- // so if they support Proxy they also support Reflect.construct.
- if (typeof Proxy === "function") return true;
- // Since Reflect.construct can't be properly polyfilled, some
- // implementations (e.g. core-js@2) don't set the correct internal slots.
- // Those polyfills don't allow us to subclass built-ins, so we need to
- // 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() {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- export default function _construct(Parent, args, Class) {
- if (isNativeReflectConstruct()) {
- _construct = Reflect.construct;
- } else {
- // NOTE: If Parent !== Class, the correct __proto__ is set *after*
- // calling the constructor.
- _construct = function _construct(Parent, args, Class) {
- var a = [null];
- a.push.apply(a, args);
- var Constructor = Function.bind.apply(Parent, a);
- var instance = new Constructor();
- if (Class) setPrototypeOf(instance, Class.prototype);
- return instance;
- };
- }
- // Avoid issues with Class being present but undefined when it wasn't
- // present in the original call.
- return _construct.apply(null, arguments);
- }
- `;
- helpers.isNativeFunction = helper("7.0.0-beta.0")`
- export default function _isNativeFunction(fn) {
- // Note: This function returns "true" for core-js functions.
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
- }
- `;
- helpers.wrapNativeSuper = helper("7.0.0-beta.0")`
- import getPrototypeOf from "getPrototypeOf";
- import setPrototypeOf from "setPrototypeOf";
- import isNativeFunction from "isNativeFunction";
- import construct from "construct";
- export default function _wrapNativeSuper(Class) {
- var _cache = typeof Map === "function" ? new Map() : undefined;
- _wrapNativeSuper = function _wrapNativeSuper(Class) {
- if (Class === null || !isNativeFunction(Class)) return Class;
- if (typeof Class !== "function") {
- throw new TypeError("Super expression must either be null or a function");
- }
- if (typeof _cache !== "undefined") {
- if (_cache.has(Class)) return _cache.get(Class);
- _cache.set(Class, Wrapper);
- }
- function Wrapper() {
- return construct(Class, arguments, getPrototypeOf(this).constructor)
- }
- Wrapper.prototype = Object.create(Class.prototype, {
- constructor: {
- value: Wrapper,
- enumerable: false,
- writable: true,
- configurable: true,
- }
- });
- return setPrototypeOf(Wrapper, Class);
- }
- return _wrapNativeSuper(Class)
- }
- `;
- helpers.instanceof = helper("7.0.0-beta.0")`
- export default function _instanceof(left, right) {
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
- return right[Symbol.hasInstance](left);
- } else {
- return left instanceof right;
- }
- }
- `;
- helpers.interopRequireDefault = helper("7.0.0-beta.0")`
- export default function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : { default: obj };
- }
- `;
- helpers.interopRequireWildcard = helper("7.0.0-beta.0")`
- export default 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)) {
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor
- ? Object.getOwnPropertyDescriptor(obj, key)
- : {};
- if (desc.get || desc.set) {
- Object.defineProperty(newObj, key, desc);
- } else {
- newObj[key] = obj[key];
- }
- }
- }
- }
- newObj.default = obj;
- return newObj;
- }
- }
- `;
- helpers.newArrowCheck = helper("7.0.0-beta.0")`
- export default function _newArrowCheck(innerThis, boundThis) {
- if (innerThis !== boundThis) {
- throw new TypeError("Cannot instantiate an arrow function");
- }
- }
- `;
- helpers.objectDestructuringEmpty = helper("7.0.0-beta.0")`
- export default function _objectDestructuringEmpty(obj) {
- if (obj == null) throw new TypeError("Cannot destructure undefined");
- }
- `;
- helpers.objectWithoutPropertiesLoose = helper("7.0.0-beta.0")`
- export default function _objectWithoutPropertiesLoose(source, excluded) {
- if (source == null) return {};
- var target = {};
- var sourceKeys = Object.keys(source);
- var key, i;
- for (i = 0; i < sourceKeys.length; i++) {
- key = sourceKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- target[key] = source[key];
- }
- return target;
- }
- `;
- helpers.objectWithoutProperties = helper("7.0.0-beta.0")`
- import objectWithoutPropertiesLoose from "objectWithoutPropertiesLoose";
- export default function _objectWithoutProperties(source, excluded) {
- if (source == null) return {};
- var target = objectWithoutPropertiesLoose(source, excluded);
- var key, i;
- if (Object.getOwnPropertySymbols) {
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
- for (i = 0; i < sourceSymbolKeys.length; i++) {
- key = sourceSymbolKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
- target[key] = source[key];
- }
- }
- return target;
- }
- `;
- helpers.assertThisInitialized = helper("7.0.0-beta.0")`
- export default function _assertThisInitialized(self) {
- if (self === void 0) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }
- return self;
- }
- `;
- helpers.possibleConstructorReturn = helper("7.0.0-beta.0")`
- import assertThisInitialized from "assertThisInitialized";
- export default function _possibleConstructorReturn(self, call) {
- if (call && (typeof call === "object" || typeof call === "function")) {
- return call;
- }
- return assertThisInitialized(self);
- }
- `;
- helpers.superPropBase = helper("7.0.0-beta.0")`
- import getPrototypeOf from "getPrototypeOf";
- export default function _superPropBase(object, property) {
- // Yes, this throws if object is null to being with, that's on purpose.
- while (!Object.prototype.hasOwnProperty.call(object, property)) {
- object = getPrototypeOf(object);
- if (object === null) break;
- }
- return object;
- }
- `;
- helpers.get = helper("7.0.0-beta.0")`
- import getPrototypeOf from "getPrototypeOf";
- import superPropBase from "superPropBase";
- export default function _get(target, property, receiver) {
- if (typeof Reflect !== "undefined" && Reflect.get) {
- _get = Reflect.get;
- } else {
- _get = function _get(target, property, receiver) {
- var base = superPropBase(target, property);
- if (!base) return;
- var desc = Object.getOwnPropertyDescriptor(base, property);
- if (desc.get) {
- return desc.get.call(receiver);
- }
- return desc.value;
- };
- }
- return _get(target, property, receiver || target);
- }
- `;
- helpers.set = helper("7.0.0-beta.0")`
- import getPrototypeOf from "getPrototypeOf";
- import superPropBase from "superPropBase";
- import defineProperty from "defineProperty";
- function set(target, property, value, receiver) {
- if (typeof Reflect !== "undefined" && Reflect.set) {
- set = Reflect.set;
- } else {
- set = function set(target, property, value, receiver) {
- var base = superPropBase(target, property);
- var desc;
- if (base) {
- desc = Object.getOwnPropertyDescriptor(base, property);
- if (desc.set) {
- desc.set.call(receiver, value);
- return true;
- } else if (!desc.writable) {
- // Both getter and non-writable fall into this.
- return false;
- }
- }
- // Without a super that defines the property, spec boils down to
- // "define on receiver" for some reason.
- desc = Object.getOwnPropertyDescriptor(receiver, property);
- if (desc) {
- if (!desc.writable) {
- // Setter, getter, and non-writable fall into this.
- return false;
- }
- desc.value = value;
- Object.defineProperty(receiver, property, desc);
- } else {
- // Avoid setters that may be defined on Sub's prototype, but not on
- // the instance.
- defineProperty(receiver, property, value);
- }
- return true;
- };
- }
- return set(target, property, value, receiver);
- }
- export default function _set(target, property, value, receiver, isStrict) {
- var s = set(target, property, value, receiver || target);
- if (!s && isStrict) {
- throw new Error('failed to set property');
- }
- return value;
- }
- `;
- helpers.taggedTemplateLiteral = helper("7.0.0-beta.0")`
- export default function _taggedTemplateLiteral(strings, raw) {
- if (!raw) { raw = strings.slice(0); }
- return Object.freeze(Object.defineProperties(strings, {
- raw: { value: Object.freeze(raw) }
- }));
- }
- `;
- helpers.taggedTemplateLiteralLoose = helper("7.0.0-beta.0")`
- export default function _taggedTemplateLiteralLoose(strings, raw) {
- if (!raw) { raw = strings.slice(0); }
- strings.raw = raw;
- return strings;
- }
- `;
- helpers.temporalRef = helper("7.0.0-beta.0")`
- import undef from "temporalUndefined";
- export default function _temporalRef(val, name) {
- if (val === undef) {
- throw new ReferenceError(name + " is not defined - temporal dead zone");
- } else {
- return val;
- }
- }
- `;
- helpers.readOnlyError = helper("7.0.0-beta.0")`
- export default function _readOnlyError(name) {
- throw new Error("\\"" + name + "\\" is read-only");
- }
- `;
- helpers.classNameTDZError = helper("7.0.0-beta.0")`
- export default function _classNameTDZError(name) {
- throw new Error("Class \\"" + name + "\\" cannot be referenced in computed property keys.");
- }
- `;
- helpers.temporalUndefined = helper("7.0.0-beta.0")`
- export default {};
- `;
- helpers.slicedToArray = helper("7.0.0-beta.0")`
- import arrayWithHoles from "arrayWithHoles";
- import iterableToArrayLimit from "iterableToArrayLimit";
- import nonIterableRest from "nonIterableRest";
- export default function _slicedToArray(arr, i) {
- return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();
- }
- `;
- helpers.slicedToArrayLoose = helper("7.0.0-beta.0")`
- import arrayWithHoles from "arrayWithHoles";
- import iterableToArrayLimitLoose from "iterableToArrayLimitLoose";
- import nonIterableRest from "nonIterableRest";
- export default function _slicedToArrayLoose(arr, i) {
- return arrayWithHoles(arr) || iterableToArrayLimitLoose(arr, i) || nonIterableRest();
- }
- `;
- helpers.toArray = helper("7.0.0-beta.0")`
- import arrayWithHoles from "arrayWithHoles";
- import iterableToArray from "iterableToArray";
- import nonIterableRest from "nonIterableRest";
- export default function _toArray(arr) {
- return arrayWithHoles(arr) || iterableToArray(arr) || nonIterableRest();
- }
- `;
- helpers.toConsumableArray = helper("7.0.0-beta.0")`
- import arrayWithoutHoles from "arrayWithoutHoles";
- import iterableToArray from "iterableToArray";
- import nonIterableSpread from "nonIterableSpread";
- export default function _toConsumableArray(arr) {
- return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
- }
- `;
- helpers.arrayWithoutHoles = helper("7.0.0-beta.0")`
- export default function _arrayWithoutHoles(arr) {
- if (Array.isArray(arr)) {
- for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
- return arr2;
- }
- }
- `;
- helpers.arrayWithHoles = helper("7.0.0-beta.0")`
- export default function _arrayWithHoles(arr) {
- if (Array.isArray(arr)) return arr;
- }
- `;
- helpers.iterableToArray = helper("7.0.0-beta.0")`
- export default function _iterableToArray(iter) {
- if (
- Symbol.iterator in Object(iter) ||
- Object.prototype.toString.call(iter) === "[object Arguments]"
- ) return Array.from(iter);
- }
- `;
- helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
- export default function _iterableToArrayLimit(arr, i) {
- // this is an expanded form of \`for...of\` that properly supports abrupt completions of
- // iterators etc. variable names have been minimised to reduce the size of this massive
- // helper. sometimes spec compliancy is annoying :(
- //
- // _n = _iteratorNormalCompletion
- // _d = _didIteratorError
- // _e = _iteratorError
- // _i = _iterator
- // _s = _step
- 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"] != null) _i["return"]();
- } finally {
- if (_d) throw _e;
- }
- }
- return _arr;
- }
- `;
- helpers.iterableToArrayLimitLoose = helper("7.0.0-beta.0")`
- export default function _iterableToArrayLimitLoose(arr, i) {
- var _arr = [];
- for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
- _arr.push(_step.value);
- if (i && _arr.length === i) break;
- }
- return _arr;
- }
- `;
- helpers.nonIterableSpread = helper("7.0.0-beta.0")`
- export default function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance");
- }
- `;
- helpers.nonIterableRest = helper("7.0.0-beta.0")`
- export default function _nonIterableRest() {
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
- }
- `;
- helpers.skipFirstGeneratorNext = helper("7.0.0-beta.0")`
- export default function _skipFirstGeneratorNext(fn) {
- return function () {
- var it = fn.apply(this, arguments);
- it.next();
- return it;
- }
- }
- `;
- helpers.toPrimitive = helper("7.1.5")`
- export default function _toPrimitive(
- input,
- hint /*: "default" | "string" | "number" | void */
- ) {
- if (typeof input !== "object" || input === null) return input;
- var prim = input[Symbol.toPrimitive];
- if (prim !== undefined) {
- var res = prim.call(input, hint || "default");
- if (typeof res !== "object") return res;
- throw new TypeError("@@toPrimitive must return a primitive value.");
- }
- return (hint === "string" ? String : Number)(input);
- }
- `;
- helpers.toPropertyKey = helper("7.1.5")`
- import toPrimitive from "toPrimitive";
- export default function _toPropertyKey(arg) {
- var key = toPrimitive(arg, "string");
- return typeof key === "symbol" ? key : String(key);
- }
- `;
- helpers.initializerWarningHelper = helper("7.0.0-beta.0")`
- export default function _initializerWarningHelper(descriptor, context){
- throw new Error(
- 'Decorating class property failed. Please ensure that ' +
- 'proposal-class-properties is enabled and set to use loose mode. ' +
- 'To use proposal-class-properties in spec mode with decorators, wait for ' +
- 'the next major version of decorators in stage 2.'
- );
- }
- `;
- helpers.initializerDefineProperty = helper("7.0.0-beta.0")`
- export default function _initializerDefineProperty(target, property, descriptor, context){
- if (!descriptor) return;
- Object.defineProperty(target, property, {
- enumerable: descriptor.enumerable,
- configurable: descriptor.configurable,
- writable: descriptor.writable,
- value: descriptor.initializer ? descriptor.initializer.call(context) : void 0,
- });
- }
- `;
- helpers.applyDecoratedDescriptor = helper("7.0.0-beta.0")`
- export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context){
- var desc = {};
- Object.keys(descriptor).forEach(function(key){
- desc[key] = descriptor[key];
- });
- desc.enumerable = !!desc.enumerable;
- desc.configurable = !!desc.configurable;
- if ('value' in desc || desc.initializer){
- desc.writable = true;
- }
- desc = decorators.slice().reverse().reduce(function(desc, decorator){
- return decorator(target, property, desc) || desc;
- }, desc);
- if (context && desc.initializer !== void 0){
- desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
- desc.initializer = undefined;
- }
- 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;
- }
- return desc;
- }
- `;
- helpers.classPrivateFieldLooseKey = helper("7.0.0-beta.0")`
- var id = 0;
- export default function _classPrivateFieldKey(name) {
- return "__private_" + (id++) + "_" + name;
- }
- `;
- helpers.classPrivateFieldLooseBase = helper("7.0.0-beta.0")`
- export default function _classPrivateFieldBase(receiver, privateKey) {
- if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
- throw new TypeError("attempted to use private field on non-instance");
- }
- return receiver;
- }
- `;
- helpers.classPrivateFieldGet = helper("7.0.0-beta.0")`
- export default function _classPrivateFieldGet(receiver, privateMap) {
- var descriptor = privateMap.get(receiver);
- if (!descriptor) {
- throw new TypeError("attempted to get private field on non-instance");
- }
- 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");
- }
- 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.classStaticPrivateFieldSpecGet = helper("7.0.2")`
- export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
- if (receiver !== classConstructor) {
- throw new TypeError("Private static access of wrong provenance");
- }
- 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");
- }
- 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")`
- import toArray from "toArray";
- import toPropertyKey from "toPropertyKey";
- // These comments are stripped by @babel/template
- /*::
- type PropertyDescriptor =
- | {
- value: any,
- writable: boolean,
- configurable: boolean,
- enumerable: boolean,
- }
- | {
- get?: () => any,
- set?: (v: any) => void,
- configurable: boolean,
- enumerable: boolean,
- };
- type FieldDescriptor ={
- writable: boolean,
- configurable: boolean,
- enumerable: boolean,
- };
- type Placement = "static" | "prototype" | "own";
- type Key = string | symbol; // PrivateName is not supported yet.
- type ElementDescriptor =
- | {
- kind: "method",
- key: Key,
- placement: Placement,
- descriptor: PropertyDescriptor
- }
- | {
- kind: "field",
- key: Key,
- placement: Placement,
- descriptor: FieldDescriptor,
- initializer?: () => any,
- };
- // This is exposed to the user code
- type ElementObjectInput = ElementDescriptor & {
- [@@toStringTag]?: "Descriptor"
- };
- // This is exposed to the user code
- type ElementObjectOutput = ElementDescriptor & {
- [@@toStringTag]?: "Descriptor"
- extras?: ElementDescriptor[],
- finisher?: ClassFinisher,
- };
- // This is exposed to the user code
- type ClassObject = {
- [@@toStringTag]?: "Descriptor",
- kind: "class",
- elements: ElementDescriptor[],
- };
- type ElementDecorator = (descriptor: ElementObjectInput) => ?ElementObjectOutput;
- type ClassDecorator = (descriptor: ClassObject) => ?ClassObject;
- type ClassFinisher = <A, B>(cl: Class<A>) => Class<B>;
- // Only used by Babel in the transform output, not part of the spec.
- type ElementDefinition =
- | {
- kind: "method",
- value: any,
- key: Key,
- static?: boolean,
- decorators?: ElementDecorator[],
- }
- | {
- kind: "field",
- value: () => any,
- key: Key,
- static?: boolean,
- decorators?: ElementDecorator[],
- };
- declare function ClassFactory<C>(initialize: (instance: C) => void): {
- F: Class<C>,
- d: ElementDefinition[]
- }
- */
- /*::
- // Various combinations with/without extras and with one or many finishers
- type ElementFinisherExtras = {
- element: ElementDescriptor,
- finisher?: ClassFinisher,
- extras?: ElementDescriptor[],
- };
- type ElementFinishersExtras = {
- element: ElementDescriptor,
- finishers: ClassFinisher[],
- extras: ElementDescriptor[],
- };
- type ElementsFinisher = {
- elements: ElementDescriptor[],
- finisher?: ClassFinisher,
- };
- type ElementsFinishers = {
- elements: ElementDescriptor[],
- finishers: ClassFinisher[],
- };
- */
- /*::
- type Placements = {
- static: Key[],
- prototype: Key[],
- own: Key[],
- };
- */
- // ClassDefinitionEvaluation (Steps 26-*)
- export default function _decorate(
- decorators /*: ClassDecorator[] */,
- factory /*: ClassFactory */,
- superClass /*: ?Class<*> */,
- mixins /*: ?Array<Function> */,
- ) /*: Class<*> */ {
- var api = _getDecoratorsApi();
- if (mixins) {
- for (var i = 0; i < mixins.length; i++) {
- api = mixins[i](api);
- }
- }
- var r = factory(function initialize(O) {
- api.initializeInstanceElements(O, decorated.elements);
- }, superClass);
- var decorated = api.decorateClass(
- _coalesceClassElements(r.d.map(_createElementDescriptor)),
- decorators,
- );
- api.initializeClassElements(r.F, decorated.elements);
- return api.runClassFinishers(r.F, decorated.finishers);
- }
- function _getDecoratorsApi() {
- _getDecoratorsApi = function() {
- return api;
- };
- var api = {
- elementsDefinitionOrder: [["method"], ["field"]],
- // InitializeInstanceElements
- initializeInstanceElements: function(
- /*::<C>*/ O /*: C */,
- elements /*: ElementDescriptor[] */,
- ) {
- ["method", "field"].forEach(function(kind) {
- elements.forEach(function(element /*: ElementDescriptor */) {
- if (element.kind === kind && element.placement === "own") {
- this.defineClassElement(O, element);
- }
- }, this);
- }, this);
- },
- // InitializeClassElements
- initializeClassElements: function(
- /*::<C>*/ F /*: Class<C> */,
- elements /*: ElementDescriptor[] */,
- ) {
- var proto = F.prototype;
- ["method", "field"].forEach(function(kind) {
- elements.forEach(function(element /*: ElementDescriptor */) {
- var placement = element.placement;
- if (
- element.kind === kind &&
- (placement === "static" || placement === "prototype")
- ) {
- var receiver = placement === "static" ? F : proto;
- this.defineClassElement(receiver, element);
- }
- }, this);
- }, this);
- },
- // DefineClassElement
- defineClassElement: function(
- /*::<C>*/ receiver /*: C | Class<C> */,
- element /*: ElementDescriptor */,
- ) {
- var descriptor /*: PropertyDescriptor */ = element.descriptor;
- if (element.kind === "field") {
- var initializer = element.initializer;
- descriptor = {
- enumerable: descriptor.enumerable,
- writable: descriptor.writable,
- configurable: descriptor.configurable,
- value: initializer === void 0 ? void 0 : initializer.call(receiver),
- };
- }
- Object.defineProperty(receiver, element.key, descriptor);
- },
- // DecorateClass
- decorateClass: function(
- elements /*: ElementDescriptor[] */,
- decorators /*: ClassDecorator[] */,
- ) /*: ElementsFinishers */ {
- var newElements /*: ElementDescriptor[] */ = [];
- var finishers /*: ClassFinisher[] */ = [];
- var placements /*: Placements */ = {
- static: [],
- prototype: [],
- own: [],
- };
- elements.forEach(function(element /*: ElementDescriptor */) {
- this.addElementPlacement(element, placements);
- }, this);
- elements.forEach(function(element /*: ElementDescriptor */) {
- if (!_hasDecorators(element)) return newElements.push(element);
- var elementFinishersExtras /*: ElementFinishersExtras */ = this.decorateElement(
- element,
- placements,
- );
- newElements.push(elementFinishersExtras.element);
- newElements.push.apply(newElements, elementFinishersExtras.extras);
- finishers.push.apply(finishers, elementFinishersExtras.finishers);
- }, this);
- if (!decorators) {
- return { elements: newElements, finishers: finishers };
- }
- var result /*: ElementsFinishers */ = this.decorateConstructor(
- newElements,
- decorators,
- );
- finishers.push.apply(finishers, result.finishers);
- result.finishers = finishers;
- return result;
- },
- // AddElementPlacement
- addElementPlacement: function(
- element /*: ElementDescriptor */,
- placements /*: Placements */,
- silent /*: boolean */,
- ) {
- var keys = placements[element.placement];
- if (!silent && keys.indexOf(element.key) !== -1) {
- throw new TypeError("Duplicated element (" + element.key + ")");
- }
- keys.push(element.key);
- },
- // DecorateElement
- decorateElement: function(
- element /*: ElementDescriptor */,
- placements /*: Placements */,
- ) /*: ElementFinishersExtras */ {
- var extras /*: ElementDescriptor[] */ = [];
- var finishers /*: ClassFinisher[] */ = [];
- for (
- var decorators = element.decorators, i = decorators.length - 1;
- i >= 0;
- i--
- ) {
- // (inlined) RemoveElementPlacement
- var keys = placements[element.placement];
- keys.splice(keys.indexOf(element.key), 1);
- var elementObject /*: ElementObjectInput */ = this.fromElementDescriptor(
- element,
- );
- var elementFinisherExtras /*: ElementFinisherExtras */ = this.toElementFinisherExtras(
- (0, decorators[i])(elementObject) /*: ElementObjectOutput */ ||
- elementObject,
- );
- element = elementFinisherExtras.element;
- this.addElementPlacement(element, placements);
- if (elementFinisherExtras.finisher) {
- finishers.push(elementFinisherExtras.finisher);
- }
- var newExtras /*: ElementDescriptor[] | void */ =
- elementFinisherExtras.extras;
- if (newExtras) {
- for (var j = 0; j < newExtras.length; j++) {
- this.addElementPlacement(newExtras[j], placements);
- }
- extras.push.apply(extras, newExtras);
- }
- }
- return { element: element, finishers: finishers, extras: extras };
- },
- // DecorateConstructor
- decorateConstructor: function(
- elements /*: ElementDescriptor[] */,
- decorators /*: ClassDecorator[] */,
- ) /*: ElementsFinishers */ {
- var finishers /*: ClassFinisher[] */ = [];
- for (var i = decorators.length - 1; i >= 0; i--) {
- var obj /*: ClassObject */ = this.fromClassDescriptor(elements);
- var elementsAndFinisher /*: ElementsFinisher */ = this.toClassDescriptor(
- (0, decorators[i])(obj) /*: ClassObject */ || obj,
- );
- if (elementsAndFinisher.finisher !== undefined) {
- finishers.push(elementsAndFinisher.finisher);
- }
- if (elementsAndFinisher.elements !== undefined) {
- elements = elementsAndFinisher.elements;
- for (var j = 0; j < elements.length - 1; j++) {
- for (var k = j + 1; k < elements.length; k++) {
- if (
- elements[j].key === elements[k].key &&
- elements[j].placement === elements[k].placement
- ) {
- throw new TypeError(
- "Duplicated element (" + elements[j].key + ")",
- );
- }
- }
- }
- }
- }
- return { elements: elements, finishers: finishers };
- },
- // FromElementDescriptor
- fromElementDescriptor: function(
- element /*: ElementDescriptor */,
- ) /*: ElementObject */ {
- var obj /*: ElementObject */ = {
- kind: element.kind,
- key: element.key,
- placement: element.placement,
- descriptor: element.descriptor,
- };
- var desc = {
- value: "Descriptor",
- configurable: true,
- };
- Object.defineProperty(obj, Symbol.toStringTag, desc);
- if (element.kind === "field") obj.initializer = element.initializer;
- return obj;
- },
- // ToElementDescriptors
- toElementDescriptors: function(
- elementObjects /*: ElementObject[] */,
- ) /*: ElementDescriptor[] */ {
- if (elementObjects === undefined) return;
- return toArray(elementObjects).map(function(elementObject) {
- var element = this.toElementDescriptor(elementObject);
- this.disallowProperty(elementObject, "finisher", "An element descriptor");
- this.disallowProperty(elementObject, "extras", "An element descriptor");
- return element;
- }, this);
- },
- // ToElementDescriptor
- toElementDescriptor: function(
- elementObject /*: ElementObject */,
- ) /*: ElementDescriptor */ {
- var kind = String(elementObject.kind);
- if (kind !== "method" && kind !== "field") {
- throw new TypeError(
- 'An element descriptor\\'s .kind property must be either "method" or' +
- ' "field", but a decorator created an element descriptor with' +
- ' .kind "' +
- kind +
- '"',
- );
- }
- var key = toPropertyKey(elementObject.key);
- var placement = String(elementObject.placement);
- if (
- placement !== "static" &&
- placement !== "prototype" &&
- placement !== "own"
- ) {
- throw new TypeError(
- 'An element descriptor\\'s .placement property must be one of "static",' +
- ' "prototype" or "own", but a decorator created an element descriptor' +
- ' with .placement "' +
- placement +
- '"',
- );
- }
- var descriptor /*: PropertyDescriptor */ = elementObject.descriptor;
- this.disallowProperty(elementObject, "elements", "An element descriptor");
- var element /*: ElementDescriptor */ = {
- kind: kind,
- key: key,
- placement: placement,
- descriptor: Object.assign({}, descriptor),
- };
- if (kind !== "field") {
- this.disallowProperty(elementObject, "initializer", "A method descriptor");
- } else {
- this.disallowProperty(
- descriptor,
- "get",
- "The property descriptor of a field descriptor",
- );
- this.disallowProperty(
- descriptor,
- "set",
- "The property descriptor of a field descriptor",
- );
- this.disallowProperty(
- descriptor,
- "value",
- "The property descriptor of a field descriptor",
- );
- element.initializer = elementObject.initializer;
- }
- return element;
- },
- toElementFinisherExtras: function(
- elementObject /*: ElementObject */,
- ) /*: ElementFinisherExtras */ {
- var element /*: ElementDescriptor */ = this.toElementDescriptor(
- elementObject,
- );
- var finisher /*: ClassFinisher */ = _optionalCallableProperty(
- elementObject,
- "finisher",
- );
- var extras /*: ElementDescriptors[] */ = this.toElementDescriptors(
- elementObject.extras,
- );
- return { element: element, finisher: finisher, extras: extras };
- },
- // FromClassDescriptor
- fromClassDescriptor: function(
- elements /*: ElementDescriptor[] */,
- ) /*: ClassObject */ {
- var obj = {
- kind: "class",
- elements: elements.map(this.fromElementDescriptor, this),
- };
- var desc = { value: "Descriptor", configurable: true };
- Object.defineProperty(obj, Symbol.toStringTag, desc);
- return obj;
- },
- // ToClassDescriptor
- toClassDescriptor: function(
- obj /*: ClassObject */,
- ) /*: ElementsFinisher */ {
- var kind = String(obj.kind);
- if (kind !== "class") {
- throw new TypeError(
- 'A class descriptor\\'s .kind property must be "class", but a decorator' +
- ' created a class descriptor with .kind "' +
- kind +
- '"',
- );
- }
- this.disallowProperty(obj, "key", "A class descriptor");
- this.disallowProperty(obj, "placement", "A class descriptor");
- this.disallowProperty(obj, "descriptor", "A class descriptor");
- this.disallowProperty(obj, "initializer", "A class descriptor");
- this.disallowProperty(obj, "extras", "A class descriptor");
- var finisher = _optionalCallableProperty(obj, "finisher");
- var elements = this.toElementDescriptors(obj.elements);
- return { elements: elements, finisher: finisher };
- },
- // RunClassFinishers
- runClassFinishers: function(
- constructor /*: Class<*> */,
- finishers /*: ClassFinisher[] */,
- ) /*: Class<*> */ {
- for (var i = 0; i < finishers.length; i++) {
- var newConstructor /*: ?Class<*> */ = (0, finishers[i])(constructor);
- if (newConstructor !== undefined) {
- // NOTE: This should check if IsConstructor(newConstructor) is false.
- if (typeof newConstructor !== "function") {
- throw new TypeError("Finishers must return a constructor.");
- }
- constructor = newConstructor;
- }
- }
- return constructor;
- },
- disallowProperty: function(obj, name, objectType) {
- if (obj[name] !== undefined) {
- throw new TypeError(objectType + " can't have a ." + name + " property.");
- }
- }
- };
- return api;
- }
- // ClassElementEvaluation
- function _createElementDescriptor(
- def /*: ElementDefinition */,
- ) /*: ElementDescriptor */ {
- var key = toPropertyKey(def.key);
- var descriptor /*: PropertyDescriptor */;
- if (def.kind === "method") {
- descriptor = {
- value: def.value,
- writable: true,
- configurable: true,
- enumerable: false,
- };
- } else if (def.kind === "get") {
- descriptor = { get: def.value, configurable: true, enumerable: false };
- } else if (def.kind === "set") {
- descriptor = { set: def.value, configurable: true, enumerable: false };
- } else if (def.kind === "field") {
- descriptor = { configurable: true, writable: true, enumerable: true };
- }
- var element /*: ElementDescriptor */ = {
- kind: def.kind === "field" ? "field" : "method",
- key: key,
- placement: def.static
- ? "static"
- : def.kind === "field"
- ? "own"
- : "prototype",
- descriptor: descriptor,
- };
- if (def.decorators) element.decorators = def.decorators;
- if (def.kind === "field") element.initializer = def.value;
- return element;
- }
- // CoalesceGetterSetter
- function _coalesceGetterSetter(
- element /*: ElementDescriptor */,
- other /*: ElementDescriptor */,
- ) {
- if (element.descriptor.get !== undefined) {
- other.descriptor.get = element.descriptor.get;
- } else {
- other.descriptor.set = element.descriptor.set;
- }
- }
- // CoalesceClassElements
- function _coalesceClassElements(
- elements /*: ElementDescriptor[] */,
- ) /*: ElementDescriptor[] */ {
- var newElements /*: ElementDescriptor[] */ = [];
- var isSameElement = function(
- other /*: ElementDescriptor */,
- ) /*: boolean */ {
- return (
- other.kind === "method" &&
- other.key === element.key &&
- other.placement === element.placement
- );
- };
- for (var i = 0; i < elements.length; i++) {
- var element /*: ElementDescriptor */ = elements[i];
- var other /*: ElementDescriptor */;
- if (
- element.kind === "method" &&
- (other = newElements.find(isSameElement))
- ) {
- if (
- _isDataDescriptor(element.descriptor) ||
- _isDataDescriptor(other.descriptor)
- ) {
- if (_hasDecorators(element) || _hasDecorators(other)) {
- throw new ReferenceError(
- "Duplicated methods (" + element.key + ") can't be decorated.",
- );
- }
- other.descriptor = element.descriptor;
- } else {
- if (_hasDecorators(element)) {
- if (_hasDecorators(other)) {
- throw new ReferenceError(
- "Decorators can't be placed on different accessors with for " +
- "the same property (" +
- element.key +
- ").",
- );
- }
- other.decorators = element.decorators;
- }
- _coalesceGetterSetter(element, other);
- }
- } else {
- newElements.push(element);
- }
- }
- return newElements;
- }
- function _hasDecorators(element /*: ElementDescriptor */) /*: boolean */ {
- return element.decorators && element.decorators.length;
- }
- function _isDataDescriptor(desc /*: PropertyDescriptor */) /*: boolean */ {
- return (
- desc !== undefined &&
- !(desc.value === undefined && desc.writable === undefined)
- );
- }
- function _optionalCallableProperty /*::<T>*/(
- obj /*: T */,
- name /*: $Keys<T> */,
- ) /*: ?Function */ {
- var value = obj[name];
- if (value !== undefined && typeof value !== "function") {
- throw new TypeError("Expected '" + name + "' to be a function");
- }
- return value;
- }
- `;
- helpers.classPrivateMethodGet = helper("7.1.6")`
- export default function _classPrivateMethodGet(receiver, privateSet, fn) {
- if (!privateSet.has(receiver)) {
- throw new TypeError("attempted to get private field on non-instance");
- }
- return fn;
- }
- `;
- helpers.classPrivateMethodSet = helper("7.1.6")`
- export default function _classPrivateMethodSet() {
- throw new TypeError("attempted to reassign private method");
- }
- `;
- helpers.wrapRegExp = helper("7.2.6")`
- import wrapNativeSuper from "wrapNativeSuper";
- import getPrototypeOf from "getPrototypeOf";
- import possibleConstructorReturn from "possibleConstructorReturn";
- import inherits from "inherits";
- export default function _wrapRegExp(re, groups) {
- _wrapRegExp = function(re, groups) {
- return new BabelRegExp(re, groups);
- };
- var _RegExp = wrapNativeSuper(RegExp);
- var _super = RegExp.prototype;
- var _groups = new WeakMap();
- function BabelRegExp(re, groups) {
- var _this = _RegExp.call(this, re);
- _groups.set(_this, groups);
- return _this;
- }
- 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);
- }
- `;
|