Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

helpers.js 61KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _template = require("@babel/template");
  7. var generated = require("./helpers-generated");
  8. const helpers = Object.assign({
  9. __proto__: null
  10. }, generated);
  11. var _default = helpers;
  12. exports.default = _default;
  13. const helper = minVersion => tpl => ({
  14. minVersion,
  15. ast: () => _template.default.program.ast(tpl)
  16. });
  17. helpers.asyncIterator = helper("7.0.0-beta.0")`
  18. export default function _asyncIterator(iterable) {
  19. var method;
  20. if (typeof Symbol !== "undefined") {
  21. if (Symbol.asyncIterator) method = iterable[Symbol.asyncIterator];
  22. if (method == null && Symbol.iterator) method = iterable[Symbol.iterator];
  23. }
  24. if (method == null) method = iterable["@@asyncIterator"];
  25. if (method == null) method = iterable["@@iterator"]
  26. if (method == null) throw new TypeError("Object is not async iterable");
  27. return method.call(iterable);
  28. }
  29. `;
  30. helpers.AwaitValue = helper("7.0.0-beta.0")`
  31. export default function _AwaitValue(value) {
  32. this.wrapped = value;
  33. }
  34. `;
  35. helpers.AsyncGenerator = helper("7.0.0-beta.0")`
  36. import AwaitValue from "AwaitValue";
  37. export default function AsyncGenerator(gen) {
  38. var front, back;
  39. function send(key, arg) {
  40. return new Promise(function (resolve, reject) {
  41. var request = {
  42. key: key,
  43. arg: arg,
  44. resolve: resolve,
  45. reject: reject,
  46. next: null,
  47. };
  48. if (back) {
  49. back = back.next = request;
  50. } else {
  51. front = back = request;
  52. resume(key, arg);
  53. }
  54. });
  55. }
  56. function resume(key, arg) {
  57. try {
  58. var result = gen[key](arg)
  59. var value = result.value;
  60. var wrappedAwait = value instanceof AwaitValue;
  61. Promise.resolve(wrappedAwait ? value.wrapped : value).then(
  62. function (arg) {
  63. if (wrappedAwait) {
  64. resume(key === "return" ? "return" : "next", arg);
  65. return
  66. }
  67. settle(result.done ? "return" : "normal", arg);
  68. },
  69. function (err) { resume("throw", err); });
  70. } catch (err) {
  71. settle("throw", err);
  72. }
  73. }
  74. function settle(type, value) {
  75. switch (type) {
  76. case "return":
  77. front.resolve({ value: value, done: true });
  78. break;
  79. case "throw":
  80. front.reject(value);
  81. break;
  82. default:
  83. front.resolve({ value: value, done: false });
  84. break;
  85. }
  86. front = front.next;
  87. if (front) {
  88. resume(front.key, front.arg);
  89. } else {
  90. back = null;
  91. }
  92. }
  93. this._invoke = send;
  94. // Hide "return" method if generator return is not supported
  95. if (typeof gen.return !== "function") {
  96. this.return = undefined;
  97. }
  98. }
  99. AsyncGenerator.prototype[typeof Symbol === "function" && Symbol.asyncIterator || "@@asyncIterator"] = function () { return this; };
  100. AsyncGenerator.prototype.next = function (arg) { return this._invoke("next", arg); };
  101. AsyncGenerator.prototype.throw = function (arg) { return this._invoke("throw", arg); };
  102. AsyncGenerator.prototype.return = function (arg) { return this._invoke("return", arg); };
  103. `;
  104. helpers.wrapAsyncGenerator = helper("7.0.0-beta.0")`
  105. import AsyncGenerator from "AsyncGenerator";
  106. export default function _wrapAsyncGenerator(fn) {
  107. return function () {
  108. return new AsyncGenerator(fn.apply(this, arguments));
  109. };
  110. }
  111. `;
  112. helpers.awaitAsyncGenerator = helper("7.0.0-beta.0")`
  113. import AwaitValue from "AwaitValue";
  114. export default function _awaitAsyncGenerator(value) {
  115. return new AwaitValue(value);
  116. }
  117. `;
  118. helpers.asyncGeneratorDelegate = helper("7.0.0-beta.0")`
  119. export default function _asyncGeneratorDelegate(inner, awaitWrap) {
  120. var iter = {}, waiting = false;
  121. function pump(key, value) {
  122. waiting = true;
  123. value = new Promise(function (resolve) { resolve(inner[key](value)); });
  124. return { done: false, value: awaitWrap(value) };
  125. };
  126. iter[typeof Symbol !== "undefined" && Symbol.iterator || "@@iterator"] = function () { return this; };
  127. iter.next = function (value) {
  128. if (waiting) {
  129. waiting = false;
  130. return value;
  131. }
  132. return pump("next", value);
  133. };
  134. if (typeof inner.throw === "function") {
  135. iter.throw = function (value) {
  136. if (waiting) {
  137. waiting = false;
  138. throw value;
  139. }
  140. return pump("throw", value);
  141. };
  142. }
  143. if (typeof inner.return === "function") {
  144. iter.return = function (value) {
  145. if (waiting) {
  146. waiting = false;
  147. return value;
  148. }
  149. return pump("return", value);
  150. };
  151. }
  152. return iter;
  153. }
  154. `;
  155. helpers.asyncToGenerator = helper("7.0.0-beta.0")`
  156. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  157. try {
  158. var info = gen[key](arg);
  159. var value = info.value;
  160. } catch (error) {
  161. reject(error);
  162. return;
  163. }
  164. if (info.done) {
  165. resolve(value);
  166. } else {
  167. Promise.resolve(value).then(_next, _throw);
  168. }
  169. }
  170. export default function _asyncToGenerator(fn) {
  171. return function () {
  172. var self = this, args = arguments;
  173. return new Promise(function (resolve, reject) {
  174. var gen = fn.apply(self, args);
  175. function _next(value) {
  176. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  177. }
  178. function _throw(err) {
  179. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  180. }
  181. _next(undefined);
  182. });
  183. };
  184. }
  185. `;
  186. helpers.classCallCheck = helper("7.0.0-beta.0")`
  187. export default function _classCallCheck(instance, Constructor) {
  188. if (!(instance instanceof Constructor)) {
  189. throw new TypeError("Cannot call a class as a function");
  190. }
  191. }
  192. `;
  193. helpers.createClass = helper("7.0.0-beta.0")`
  194. function _defineProperties(target, props) {
  195. for (var i = 0; i < props.length; i ++) {
  196. var descriptor = props[i];
  197. descriptor.enumerable = descriptor.enumerable || false;
  198. descriptor.configurable = true;
  199. if ("value" in descriptor) descriptor.writable = true;
  200. Object.defineProperty(target, descriptor.key, descriptor);
  201. }
  202. }
  203. export default function _createClass(Constructor, protoProps, staticProps) {
  204. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  205. if (staticProps) _defineProperties(Constructor, staticProps);
  206. return Constructor;
  207. }
  208. `;
  209. helpers.defineEnumerableProperties = helper("7.0.0-beta.0")`
  210. export default function _defineEnumerableProperties(obj, descs) {
  211. for (var key in descs) {
  212. var desc = descs[key];
  213. desc.configurable = desc.enumerable = true;
  214. if ("value" in desc) desc.writable = true;
  215. Object.defineProperty(obj, key, desc);
  216. }
  217. // Symbols are not enumerated over by for-in loops. If native
  218. // Symbols are available, fetch all of the descs object's own
  219. // symbol properties and define them on our target object too.
  220. if (Object.getOwnPropertySymbols) {
  221. var objectSymbols = Object.getOwnPropertySymbols(descs);
  222. for (var i = 0; i < objectSymbols.length; i++) {
  223. var sym = objectSymbols[i];
  224. var desc = descs[sym];
  225. desc.configurable = desc.enumerable = true;
  226. if ("value" in desc) desc.writable = true;
  227. Object.defineProperty(obj, sym, desc);
  228. }
  229. }
  230. return obj;
  231. }
  232. `;
  233. helpers.defaults = helper("7.0.0-beta.0")`
  234. export default function _defaults(obj, defaults) {
  235. var keys = Object.getOwnPropertyNames(defaults);
  236. for (var i = 0; i < keys.length; i++) {
  237. var key = keys[i];
  238. var value = Object.getOwnPropertyDescriptor(defaults, key);
  239. if (value && value.configurable && obj[key] === undefined) {
  240. Object.defineProperty(obj, key, value);
  241. }
  242. }
  243. return obj;
  244. }
  245. `;
  246. helpers.defineProperty = helper("7.0.0-beta.0")`
  247. export default function _defineProperty(obj, key, value) {
  248. // Shortcircuit the slow defineProperty path when possible.
  249. // We are trying to avoid issues where setters defined on the
  250. // prototype cause side effects under the fast path of simple
  251. // assignment. By checking for existence of the property with
  252. // the in operator, we can optimize most of this overhead away.
  253. if (key in obj) {
  254. Object.defineProperty(obj, key, {
  255. value: value,
  256. enumerable: true,
  257. configurable: true,
  258. writable: true
  259. });
  260. } else {
  261. obj[key] = value;
  262. }
  263. return obj;
  264. }
  265. `;
  266. helpers.extends = helper("7.0.0-beta.0")`
  267. export default function _extends() {
  268. _extends = Object.assign || function (target) {
  269. for (var i = 1; i < arguments.length; i++) {
  270. var source = arguments[i];
  271. for (var key in source) {
  272. if (Object.prototype.hasOwnProperty.call(source, key)) {
  273. target[key] = source[key];
  274. }
  275. }
  276. }
  277. return target;
  278. };
  279. return _extends.apply(this, arguments);
  280. }
  281. `;
  282. helpers.objectSpread = helper("7.0.0-beta.0")`
  283. import defineProperty from "defineProperty";
  284. export default function _objectSpread(target) {
  285. for (var i = 1; i < arguments.length; i++) {
  286. var source = (arguments[i] != null) ? Object(arguments[i]) : {};
  287. var ownKeys = Object.keys(source);
  288. if (typeof Object.getOwnPropertySymbols === 'function') {
  289. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
  290. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  291. }));
  292. }
  293. ownKeys.forEach(function(key) {
  294. defineProperty(target, key, source[key]);
  295. });
  296. }
  297. return target;
  298. }
  299. `;
  300. helpers.inherits = helper("7.0.0-beta.0")`
  301. import setPrototypeOf from "setPrototypeOf";
  302. export default function _inherits(subClass, superClass) {
  303. if (typeof superClass !== "function" && superClass !== null) {
  304. throw new TypeError("Super expression must either be null or a function");
  305. }
  306. subClass.prototype = Object.create(superClass && superClass.prototype, {
  307. constructor: {
  308. value: subClass,
  309. writable: true,
  310. configurable: true
  311. }
  312. });
  313. if (superClass) setPrototypeOf(subClass, superClass);
  314. }
  315. `;
  316. helpers.inheritsLoose = helper("7.0.0-beta.0")`
  317. import setPrototypeOf from "setPrototypeOf";
  318. export default function _inheritsLoose(subClass, superClass) {
  319. subClass.prototype = Object.create(superClass.prototype);
  320. subClass.prototype.constructor = subClass;
  321. setPrototypeOf(subClass, superClass);
  322. }
  323. `;
  324. helpers.getPrototypeOf = helper("7.0.0-beta.0")`
  325. export default function _getPrototypeOf(o) {
  326. _getPrototypeOf = Object.setPrototypeOf
  327. ? Object.getPrototypeOf
  328. : function _getPrototypeOf(o) {
  329. return o.__proto__ || Object.getPrototypeOf(o);
  330. };
  331. return _getPrototypeOf(o);
  332. }
  333. `;
  334. helpers.setPrototypeOf = helper("7.0.0-beta.0")`
  335. export default function _setPrototypeOf(o, p) {
  336. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  337. o.__proto__ = p;
  338. return o;
  339. };
  340. return _setPrototypeOf(o, p);
  341. }
  342. `;
  343. helpers.isNativeReflectConstruct = helper("7.9.0")`
  344. export default function _isNativeReflectConstruct() {
  345. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  346. // core-js@3
  347. if (Reflect.construct.sham) return false;
  348. // Proxy can't be polyfilled. Every browser implemented
  349. // proxies before or at the same time as Reflect.construct,
  350. // so if they support Proxy they also support Reflect.construct.
  351. if (typeof Proxy === "function") return true;
  352. // Since Reflect.construct can't be properly polyfilled, some
  353. // implementations (e.g. core-js@2) don't set the correct internal slots.
  354. // Those polyfills don't allow us to subclass built-ins, so we need to
  355. // use our fallback implementation.
  356. try {
  357. // If the internal slots aren't set, this throws an error similar to
  358. // TypeError: this is not a Boolean object.
  359. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  360. return true;
  361. } catch (e) {
  362. return false;
  363. }
  364. }
  365. `;
  366. helpers.construct = helper("7.0.0-beta.0")`
  367. import setPrototypeOf from "setPrototypeOf";
  368. import isNativeReflectConstruct from "isNativeReflectConstruct";
  369. export default function _construct(Parent, args, Class) {
  370. if (isNativeReflectConstruct()) {
  371. _construct = Reflect.construct;
  372. } else {
  373. // NOTE: If Parent !== Class, the correct __proto__ is set *after*
  374. // calling the constructor.
  375. _construct = function _construct(Parent, args, Class) {
  376. var a = [null];
  377. a.push.apply(a, args);
  378. var Constructor = Function.bind.apply(Parent, a);
  379. var instance = new Constructor();
  380. if (Class) setPrototypeOf(instance, Class.prototype);
  381. return instance;
  382. };
  383. }
  384. // Avoid issues with Class being present but undefined when it wasn't
  385. // present in the original call.
  386. return _construct.apply(null, arguments);
  387. }
  388. `;
  389. helpers.isNativeFunction = helper("7.0.0-beta.0")`
  390. export default function _isNativeFunction(fn) {
  391. // Note: This function returns "true" for core-js functions.
  392. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  393. }
  394. `;
  395. helpers.wrapNativeSuper = helper("7.0.0-beta.0")`
  396. import getPrototypeOf from "getPrototypeOf";
  397. import setPrototypeOf from "setPrototypeOf";
  398. import isNativeFunction from "isNativeFunction";
  399. import construct from "construct";
  400. export default function _wrapNativeSuper(Class) {
  401. var _cache = typeof Map === "function" ? new Map() : undefined;
  402. _wrapNativeSuper = function _wrapNativeSuper(Class) {
  403. if (Class === null || !isNativeFunction(Class)) return Class;
  404. if (typeof Class !== "function") {
  405. throw new TypeError("Super expression must either be null or a function");
  406. }
  407. if (typeof _cache !== "undefined") {
  408. if (_cache.has(Class)) return _cache.get(Class);
  409. _cache.set(Class, Wrapper);
  410. }
  411. function Wrapper() {
  412. return construct(Class, arguments, getPrototypeOf(this).constructor)
  413. }
  414. Wrapper.prototype = Object.create(Class.prototype, {
  415. constructor: {
  416. value: Wrapper,
  417. enumerable: false,
  418. writable: true,
  419. configurable: true,
  420. }
  421. });
  422. return setPrototypeOf(Wrapper, Class);
  423. }
  424. return _wrapNativeSuper(Class)
  425. }
  426. `;
  427. helpers.instanceof = helper("7.0.0-beta.0")`
  428. export default function _instanceof(left, right) {
  429. if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
  430. return !!right[Symbol.hasInstance](left);
  431. } else {
  432. return left instanceof right;
  433. }
  434. }
  435. `;
  436. helpers.interopRequireDefault = helper("7.0.0-beta.0")`
  437. export default function _interopRequireDefault(obj) {
  438. return obj && obj.__esModule ? obj : { default: obj };
  439. }
  440. `;
  441. helpers.interopRequireWildcard = helper("7.14.0")`
  442. function _getRequireWildcardCache(nodeInterop) {
  443. if (typeof WeakMap !== "function") return null;
  444. var cacheBabelInterop = new WeakMap();
  445. var cacheNodeInterop = new WeakMap();
  446. return (_getRequireWildcardCache = function (nodeInterop) {
  447. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  448. })(nodeInterop);
  449. }
  450. export default function _interopRequireWildcard(obj, nodeInterop) {
  451. if (!nodeInterop && obj && obj.__esModule) {
  452. return obj;
  453. }
  454. if (obj === null || (typeof obj !== "object" && typeof obj !== "function")) {
  455. return { default: obj }
  456. }
  457. var cache = _getRequireWildcardCache(nodeInterop);
  458. if (cache && cache.has(obj)) {
  459. return cache.get(obj);
  460. }
  461. var newObj = {};
  462. var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
  463. for (var key in obj) {
  464. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  465. var desc = hasPropertyDescriptor
  466. ? Object.getOwnPropertyDescriptor(obj, key)
  467. : null;
  468. if (desc && (desc.get || desc.set)) {
  469. Object.defineProperty(newObj, key, desc);
  470. } else {
  471. newObj[key] = obj[key];
  472. }
  473. }
  474. }
  475. newObj.default = obj;
  476. if (cache) {
  477. cache.set(obj, newObj);
  478. }
  479. return newObj;
  480. }
  481. `;
  482. helpers.newArrowCheck = helper("7.0.0-beta.0")`
  483. export default function _newArrowCheck(innerThis, boundThis) {
  484. if (innerThis !== boundThis) {
  485. throw new TypeError("Cannot instantiate an arrow function");
  486. }
  487. }
  488. `;
  489. helpers.objectDestructuringEmpty = helper("7.0.0-beta.0")`
  490. export default function _objectDestructuringEmpty(obj) {
  491. if (obj == null) throw new TypeError("Cannot destructure undefined");
  492. }
  493. `;
  494. helpers.objectWithoutPropertiesLoose = helper("7.0.0-beta.0")`
  495. export default function _objectWithoutPropertiesLoose(source, excluded) {
  496. if (source == null) return {};
  497. var target = {};
  498. var sourceKeys = Object.keys(source);
  499. var key, i;
  500. for (i = 0; i < sourceKeys.length; i++) {
  501. key = sourceKeys[i];
  502. if (excluded.indexOf(key) >= 0) continue;
  503. target[key] = source[key];
  504. }
  505. return target;
  506. }
  507. `;
  508. helpers.objectWithoutProperties = helper("7.0.0-beta.0")`
  509. import objectWithoutPropertiesLoose from "objectWithoutPropertiesLoose";
  510. export default function _objectWithoutProperties(source, excluded) {
  511. if (source == null) return {};
  512. var target = objectWithoutPropertiesLoose(source, excluded);
  513. var key, i;
  514. if (Object.getOwnPropertySymbols) {
  515. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  516. for (i = 0; i < sourceSymbolKeys.length; i++) {
  517. key = sourceSymbolKeys[i];
  518. if (excluded.indexOf(key) >= 0) continue;
  519. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  520. target[key] = source[key];
  521. }
  522. }
  523. return target;
  524. }
  525. `;
  526. helpers.assertThisInitialized = helper("7.0.0-beta.0")`
  527. export default function _assertThisInitialized(self) {
  528. if (self === void 0) {
  529. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  530. }
  531. return self;
  532. }
  533. `;
  534. helpers.possibleConstructorReturn = helper("7.0.0-beta.0")`
  535. import assertThisInitialized from "assertThisInitialized";
  536. export default function _possibleConstructorReturn(self, call) {
  537. if (call && (typeof call === "object" || typeof call === "function")) {
  538. return call;
  539. }
  540. return assertThisInitialized(self);
  541. }
  542. `;
  543. helpers.createSuper = helper("7.9.0")`
  544. import getPrototypeOf from "getPrototypeOf";
  545. import isNativeReflectConstruct from "isNativeReflectConstruct";
  546. import possibleConstructorReturn from "possibleConstructorReturn";
  547. export default function _createSuper(Derived) {
  548. var hasNativeReflectConstruct = isNativeReflectConstruct();
  549. return function _createSuperInternal() {
  550. var Super = getPrototypeOf(Derived), result;
  551. if (hasNativeReflectConstruct) {
  552. // NOTE: This doesn't work if this.__proto__.constructor has been modified.
  553. var NewTarget = getPrototypeOf(this).constructor;
  554. result = Reflect.construct(Super, arguments, NewTarget);
  555. } else {
  556. result = Super.apply(this, arguments);
  557. }
  558. return possibleConstructorReturn(this, result);
  559. }
  560. }
  561. `;
  562. helpers.superPropBase = helper("7.0.0-beta.0")`
  563. import getPrototypeOf from "getPrototypeOf";
  564. export default function _superPropBase(object, property) {
  565. // Yes, this throws if object is null to being with, that's on purpose.
  566. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  567. object = getPrototypeOf(object);
  568. if (object === null) break;
  569. }
  570. return object;
  571. }
  572. `;
  573. helpers.get = helper("7.0.0-beta.0")`
  574. import superPropBase from "superPropBase";
  575. export default function _get(target, property, receiver) {
  576. if (typeof Reflect !== "undefined" && Reflect.get) {
  577. _get = Reflect.get;
  578. } else {
  579. _get = function _get(target, property, receiver) {
  580. var base = superPropBase(target, property);
  581. if (!base) return;
  582. var desc = Object.getOwnPropertyDescriptor(base, property);
  583. if (desc.get) {
  584. return desc.get.call(receiver);
  585. }
  586. return desc.value;
  587. };
  588. }
  589. return _get(target, property, receiver || target);
  590. }
  591. `;
  592. helpers.set = helper("7.0.0-beta.0")`
  593. import superPropBase from "superPropBase";
  594. import defineProperty from "defineProperty";
  595. function set(target, property, value, receiver) {
  596. if (typeof Reflect !== "undefined" && Reflect.set) {
  597. set = Reflect.set;
  598. } else {
  599. set = function set(target, property, value, receiver) {
  600. var base = superPropBase(target, property);
  601. var desc;
  602. if (base) {
  603. desc = Object.getOwnPropertyDescriptor(base, property);
  604. if (desc.set) {
  605. desc.set.call(receiver, value);
  606. return true;
  607. } else if (!desc.writable) {
  608. // Both getter and non-writable fall into this.
  609. return false;
  610. }
  611. }
  612. // Without a super that defines the property, spec boils down to
  613. // "define on receiver" for some reason.
  614. desc = Object.getOwnPropertyDescriptor(receiver, property);
  615. if (desc) {
  616. if (!desc.writable) {
  617. // Setter, getter, and non-writable fall into this.
  618. return false;
  619. }
  620. desc.value = value;
  621. Object.defineProperty(receiver, property, desc);
  622. } else {
  623. // Avoid setters that may be defined on Sub's prototype, but not on
  624. // the instance.
  625. defineProperty(receiver, property, value);
  626. }
  627. return true;
  628. };
  629. }
  630. return set(target, property, value, receiver);
  631. }
  632. export default function _set(target, property, value, receiver, isStrict) {
  633. var s = set(target, property, value, receiver || target);
  634. if (!s && isStrict) {
  635. throw new Error('failed to set property');
  636. }
  637. return value;
  638. }
  639. `;
  640. helpers.taggedTemplateLiteral = helper("7.0.0-beta.0")`
  641. export default function _taggedTemplateLiteral(strings, raw) {
  642. if (!raw) { raw = strings.slice(0); }
  643. return Object.freeze(Object.defineProperties(strings, {
  644. raw: { value: Object.freeze(raw) }
  645. }));
  646. }
  647. `;
  648. helpers.taggedTemplateLiteralLoose = helper("7.0.0-beta.0")`
  649. export default function _taggedTemplateLiteralLoose(strings, raw) {
  650. if (!raw) { raw = strings.slice(0); }
  651. strings.raw = raw;
  652. return strings;
  653. }
  654. `;
  655. helpers.readOnlyError = helper("7.0.0-beta.0")`
  656. export default function _readOnlyError(name) {
  657. throw new TypeError("\\"" + name + "\\" is read-only");
  658. }
  659. `;
  660. helpers.writeOnlyError = helper("7.12.13")`
  661. export default function _writeOnlyError(name) {
  662. throw new TypeError("\\"" + name + "\\" is write-only");
  663. }
  664. `;
  665. helpers.classNameTDZError = helper("7.0.0-beta.0")`
  666. export default function _classNameTDZError(name) {
  667. throw new Error("Class \\"" + name + "\\" cannot be referenced in computed property keys.");
  668. }
  669. `;
  670. helpers.temporalUndefined = helper("7.0.0-beta.0")`
  671. // This function isn't mean to be called, but to be used as a reference.
  672. // We can't use a normal object because it isn't hoisted.
  673. export default function _temporalUndefined() {}
  674. `;
  675. helpers.tdz = helper("7.5.5")`
  676. export default function _tdzError(name) {
  677. throw new ReferenceError(name + " is not defined - temporal dead zone");
  678. }
  679. `;
  680. helpers.temporalRef = helper("7.0.0-beta.0")`
  681. import undef from "temporalUndefined";
  682. import err from "tdz";
  683. export default function _temporalRef(val, name) {
  684. return val === undef ? err(name) : val;
  685. }
  686. `;
  687. helpers.slicedToArray = helper("7.0.0-beta.0")`
  688. import arrayWithHoles from "arrayWithHoles";
  689. import iterableToArrayLimit from "iterableToArrayLimit";
  690. import unsupportedIterableToArray from "unsupportedIterableToArray";
  691. import nonIterableRest from "nonIterableRest";
  692. export default function _slicedToArray(arr, i) {
  693. return (
  694. arrayWithHoles(arr) ||
  695. iterableToArrayLimit(arr, i) ||
  696. unsupportedIterableToArray(arr, i) ||
  697. nonIterableRest()
  698. );
  699. }
  700. `;
  701. helpers.slicedToArrayLoose = helper("7.0.0-beta.0")`
  702. import arrayWithHoles from "arrayWithHoles";
  703. import iterableToArrayLimitLoose from "iterableToArrayLimitLoose";
  704. import unsupportedIterableToArray from "unsupportedIterableToArray";
  705. import nonIterableRest from "nonIterableRest";
  706. export default function _slicedToArrayLoose(arr, i) {
  707. return (
  708. arrayWithHoles(arr) ||
  709. iterableToArrayLimitLoose(arr, i) ||
  710. unsupportedIterableToArray(arr, i) ||
  711. nonIterableRest()
  712. );
  713. }
  714. `;
  715. helpers.toArray = helper("7.0.0-beta.0")`
  716. import arrayWithHoles from "arrayWithHoles";
  717. import iterableToArray from "iterableToArray";
  718. import unsupportedIterableToArray from "unsupportedIterableToArray";
  719. import nonIterableRest from "nonIterableRest";
  720. export default function _toArray(arr) {
  721. return (
  722. arrayWithHoles(arr) ||
  723. iterableToArray(arr) ||
  724. unsupportedIterableToArray(arr) ||
  725. nonIterableRest()
  726. );
  727. }
  728. `;
  729. helpers.toConsumableArray = helper("7.0.0-beta.0")`
  730. import arrayWithoutHoles from "arrayWithoutHoles";
  731. import iterableToArray from "iterableToArray";
  732. import unsupportedIterableToArray from "unsupportedIterableToArray";
  733. import nonIterableSpread from "nonIterableSpread";
  734. export default function _toConsumableArray(arr) {
  735. return (
  736. arrayWithoutHoles(arr) ||
  737. iterableToArray(arr) ||
  738. unsupportedIterableToArray(arr) ||
  739. nonIterableSpread()
  740. );
  741. }
  742. `;
  743. helpers.arrayWithoutHoles = helper("7.0.0-beta.0")`
  744. import arrayLikeToArray from "arrayLikeToArray";
  745. export default function _arrayWithoutHoles(arr) {
  746. if (Array.isArray(arr)) return arrayLikeToArray(arr);
  747. }
  748. `;
  749. helpers.arrayWithHoles = helper("7.0.0-beta.0")`
  750. export default function _arrayWithHoles(arr) {
  751. if (Array.isArray(arr)) return arr;
  752. }
  753. `;
  754. helpers.maybeArrayLike = helper("7.9.0")`
  755. import arrayLikeToArray from "arrayLikeToArray";
  756. export default function _maybeArrayLike(next, arr, i) {
  757. if (arr && !Array.isArray(arr) && typeof arr.length === "number") {
  758. var len = arr.length;
  759. return arrayLikeToArray(arr, i !== void 0 && i < len ? i : len);
  760. }
  761. return next(arr, i);
  762. }
  763. `;
  764. helpers.iterableToArray = helper("7.0.0-beta.0")`
  765. export default function _iterableToArray(iter) {
  766. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  767. }
  768. `;
  769. helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
  770. export default function _iterableToArrayLimit(arr, i) {
  771. // this is an expanded form of \`for...of\` that properly supports abrupt completions of
  772. // iterators etc. variable names have been minimised to reduce the size of this massive
  773. // helper. sometimes spec compliance is annoying :(
  774. //
  775. // _n = _iteratorNormalCompletion
  776. // _d = _didIteratorError
  777. // _e = _iteratorError
  778. // _i = _iterator
  779. // _s = _step
  780. var _i = arr == null ? null : (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
  781. if (_i == null) return;
  782. var _arr = [];
  783. var _n = true;
  784. var _d = false;
  785. var _s, _e;
  786. try {
  787. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  788. _arr.push(_s.value);
  789. if (i && _arr.length === i) break;
  790. }
  791. } catch (err) {
  792. _d = true;
  793. _e = err;
  794. } finally {
  795. try {
  796. if (!_n && _i["return"] != null) _i["return"]();
  797. } finally {
  798. if (_d) throw _e;
  799. }
  800. }
  801. return _arr;
  802. }
  803. `;
  804. helpers.iterableToArrayLimitLoose = helper("7.0.0-beta.0")`
  805. export default function _iterableToArrayLimitLoose(arr, i) {
  806. var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
  807. if (_i == null) return;
  808. var _arr = [];
  809. for (_i = _i.call(arr), _step; !(_step = _i.next()).done;) {
  810. _arr.push(_step.value);
  811. if (i && _arr.length === i) break;
  812. }
  813. return _arr;
  814. }
  815. `;
  816. helpers.unsupportedIterableToArray = helper("7.9.0")`
  817. import arrayLikeToArray from "arrayLikeToArray";
  818. export default function _unsupportedIterableToArray(o, minLen) {
  819. if (!o) return;
  820. if (typeof o === "string") return arrayLikeToArray(o, minLen);
  821. var n = Object.prototype.toString.call(o).slice(8, -1);
  822. if (n === "Object" && o.constructor) n = o.constructor.name;
  823. if (n === "Map" || n === "Set") return Array.from(o);
  824. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  825. return arrayLikeToArray(o, minLen);
  826. }
  827. `;
  828. helpers.arrayLikeToArray = helper("7.9.0")`
  829. export default function _arrayLikeToArray(arr, len) {
  830. if (len == null || len > arr.length) len = arr.length;
  831. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  832. return arr2;
  833. }
  834. `;
  835. helpers.nonIterableSpread = helper("7.0.0-beta.0")`
  836. export default function _nonIterableSpread() {
  837. throw new TypeError(
  838. "Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  839. );
  840. }
  841. `;
  842. helpers.nonIterableRest = helper("7.0.0-beta.0")`
  843. export default function _nonIterableRest() {
  844. throw new TypeError(
  845. "Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
  846. );
  847. }
  848. `;
  849. helpers.createForOfIteratorHelper = helper("7.9.0")`
  850. import unsupportedIterableToArray from "unsupportedIterableToArray";
  851. // s: start (create the iterator)
  852. // n: next
  853. // e: error (called whenever something throws)
  854. // f: finish (always called at the end)
  855. export default function _createForOfIteratorHelper(o, allowArrayLike) {
  856. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  857. if (!it) {
  858. // Fallback for engines without symbol support
  859. if (
  860. Array.isArray(o) ||
  861. (it = unsupportedIterableToArray(o)) ||
  862. (allowArrayLike && o && typeof o.length === "number")
  863. ) {
  864. if (it) o = it;
  865. var i = 0;
  866. var F = function(){};
  867. return {
  868. s: F,
  869. n: function() {
  870. if (i >= o.length) return { done: true };
  871. return { done: false, value: o[i++] };
  872. },
  873. e: function(e) { throw e; },
  874. f: F,
  875. };
  876. }
  877. throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  878. }
  879. var normalCompletion = true, didErr = false, err;
  880. return {
  881. s: function() {
  882. it = it.call(o);
  883. },
  884. n: function() {
  885. var step = it.next();
  886. normalCompletion = step.done;
  887. return step;
  888. },
  889. e: function(e) {
  890. didErr = true;
  891. err = e;
  892. },
  893. f: function() {
  894. try {
  895. if (!normalCompletion && it.return != null) it.return();
  896. } finally {
  897. if (didErr) throw err;
  898. }
  899. }
  900. };
  901. }
  902. `;
  903. helpers.createForOfIteratorHelperLoose = helper("7.9.0")`
  904. import unsupportedIterableToArray from "unsupportedIterableToArray";
  905. export default function _createForOfIteratorHelperLoose(o, allowArrayLike) {
  906. var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
  907. if (it) return (it = it.call(o)).next.bind(it);
  908. // Fallback for engines without symbol support
  909. if (
  910. Array.isArray(o) ||
  911. (it = unsupportedIterableToArray(o)) ||
  912. (allowArrayLike && o && typeof o.length === "number")
  913. ) {
  914. if (it) o = it;
  915. var i = 0;
  916. return function() {
  917. if (i >= o.length) return { done: true };
  918. return { done: false, value: o[i++] };
  919. }
  920. }
  921. throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  922. }
  923. `;
  924. helpers.skipFirstGeneratorNext = helper("7.0.0-beta.0")`
  925. export default function _skipFirstGeneratorNext(fn) {
  926. return function () {
  927. var it = fn.apply(this, arguments);
  928. it.next();
  929. return it;
  930. }
  931. }
  932. `;
  933. helpers.toPrimitive = helper("7.1.5")`
  934. export default function _toPrimitive(
  935. input,
  936. hint /*: "default" | "string" | "number" | void */
  937. ) {
  938. if (typeof input !== "object" || input === null) return input;
  939. var prim = input[Symbol.toPrimitive];
  940. if (prim !== undefined) {
  941. var res = prim.call(input, hint || "default");
  942. if (typeof res !== "object") return res;
  943. throw new TypeError("@@toPrimitive must return a primitive value.");
  944. }
  945. return (hint === "string" ? String : Number)(input);
  946. }
  947. `;
  948. helpers.toPropertyKey = helper("7.1.5")`
  949. import toPrimitive from "toPrimitive";
  950. export default function _toPropertyKey(arg) {
  951. var key = toPrimitive(arg, "string");
  952. return typeof key === "symbol" ? key : String(key);
  953. }
  954. `;
  955. helpers.initializerWarningHelper = helper("7.0.0-beta.0")`
  956. export default function _initializerWarningHelper(descriptor, context){
  957. throw new Error(
  958. 'Decorating class property failed. Please ensure that ' +
  959. 'proposal-class-properties is enabled and runs after the decorators transform.'
  960. );
  961. }
  962. `;
  963. helpers.initializerDefineProperty = helper("7.0.0-beta.0")`
  964. export default function _initializerDefineProperty(target, property, descriptor, context){
  965. if (!descriptor) return;
  966. Object.defineProperty(target, property, {
  967. enumerable: descriptor.enumerable,
  968. configurable: descriptor.configurable,
  969. writable: descriptor.writable,
  970. value: descriptor.initializer ? descriptor.initializer.call(context) : void 0,
  971. });
  972. }
  973. `;
  974. helpers.applyDecoratedDescriptor = helper("7.0.0-beta.0")`
  975. export default function _applyDecoratedDescriptor(target, property, decorators, descriptor, context){
  976. var desc = {};
  977. Object.keys(descriptor).forEach(function(key){
  978. desc[key] = descriptor[key];
  979. });
  980. desc.enumerable = !!desc.enumerable;
  981. desc.configurable = !!desc.configurable;
  982. if ('value' in desc || desc.initializer){
  983. desc.writable = true;
  984. }
  985. desc = decorators.slice().reverse().reduce(function(desc, decorator){
  986. return decorator(target, property, desc) || desc;
  987. }, desc);
  988. if (context && desc.initializer !== void 0){
  989. desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
  990. desc.initializer = undefined;
  991. }
  992. if (desc.initializer === void 0){
  993. Object.defineProperty(target, property, desc);
  994. desc = null;
  995. }
  996. return desc;
  997. }
  998. `;
  999. helpers.classPrivateFieldLooseKey = helper("7.0.0-beta.0")`
  1000. var id = 0;
  1001. export default function _classPrivateFieldKey(name) {
  1002. return "__private_" + (id++) + "_" + name;
  1003. }
  1004. `;
  1005. helpers.classPrivateFieldLooseBase = helper("7.0.0-beta.0")`
  1006. export default function _classPrivateFieldBase(receiver, privateKey) {
  1007. if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
  1008. throw new TypeError("attempted to use private field on non-instance");
  1009. }
  1010. return receiver;
  1011. }
  1012. `;
  1013. helpers.classPrivateFieldGet = helper("7.0.0-beta.0")`
  1014. import classApplyDescriptorGet from "classApplyDescriptorGet";
  1015. import classExtractFieldDescriptor from "classExtractFieldDescriptor";
  1016. export default function _classPrivateFieldGet(receiver, privateMap) {
  1017. var descriptor = classExtractFieldDescriptor(receiver, privateMap, "get");
  1018. return classApplyDescriptorGet(receiver, descriptor);
  1019. }
  1020. `;
  1021. helpers.classPrivateFieldSet = helper("7.0.0-beta.0")`
  1022. import classApplyDescriptorSet from "classApplyDescriptorSet";
  1023. import classExtractFieldDescriptor from "classExtractFieldDescriptor";
  1024. export default function _classPrivateFieldSet(receiver, privateMap, value) {
  1025. var descriptor = classExtractFieldDescriptor(receiver, privateMap, "set");
  1026. classApplyDescriptorSet(receiver, descriptor, value);
  1027. return value;
  1028. }
  1029. `;
  1030. helpers.classPrivateFieldDestructureSet = helper("7.4.4")`
  1031. import classApplyDescriptorDestructureSet from "classApplyDescriptorDestructureSet";
  1032. import classExtractFieldDescriptor from "classExtractFieldDescriptor";
  1033. export default function _classPrivateFieldDestructureSet(receiver, privateMap) {
  1034. var descriptor = classExtractFieldDescriptor(receiver, privateMap, "set");
  1035. return classApplyDescriptorDestructureSet(receiver, descriptor);
  1036. }
  1037. `;
  1038. helpers.classExtractFieldDescriptor = helper("7.13.10")`
  1039. export default function _classExtractFieldDescriptor(receiver, privateMap, action) {
  1040. if (!privateMap.has(receiver)) {
  1041. throw new TypeError("attempted to " + action + " private field on non-instance");
  1042. }
  1043. return privateMap.get(receiver);
  1044. }
  1045. `;
  1046. helpers.classStaticPrivateFieldSpecGet = helper("7.0.2")`
  1047. import classApplyDescriptorGet from "classApplyDescriptorGet";
  1048. import classCheckPrivateStaticAccess from "classCheckPrivateStaticAccess";
  1049. import classCheckPrivateStaticFieldDescriptor from "classCheckPrivateStaticFieldDescriptor";
  1050. export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
  1051. classCheckPrivateStaticAccess(receiver, classConstructor);
  1052. classCheckPrivateStaticFieldDescriptor(descriptor, "get");
  1053. return classApplyDescriptorGet(receiver, descriptor);
  1054. }
  1055. `;
  1056. helpers.classStaticPrivateFieldSpecSet = helper("7.0.2")`
  1057. import classApplyDescriptorSet from "classApplyDescriptorSet";
  1058. import classCheckPrivateStaticAccess from "classCheckPrivateStaticAccess";
  1059. import classCheckPrivateStaticFieldDescriptor from "classCheckPrivateStaticFieldDescriptor";
  1060. export default function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
  1061. classCheckPrivateStaticAccess(receiver, classConstructor);
  1062. classCheckPrivateStaticFieldDescriptor(descriptor, "set");
  1063. classApplyDescriptorSet(receiver, descriptor, value);
  1064. return value;
  1065. }
  1066. `;
  1067. helpers.classStaticPrivateMethodGet = helper("7.3.2")`
  1068. import classCheckPrivateStaticAccess from "classCheckPrivateStaticAccess";
  1069. export default function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
  1070. classCheckPrivateStaticAccess(receiver, classConstructor);
  1071. return method;
  1072. }
  1073. `;
  1074. helpers.classStaticPrivateMethodSet = helper("7.3.2")`
  1075. export default function _classStaticPrivateMethodSet() {
  1076. throw new TypeError("attempted to set read only static private field");
  1077. }
  1078. `;
  1079. helpers.classApplyDescriptorGet = helper("7.13.10")`
  1080. export default function _classApplyDescriptorGet(receiver, descriptor) {
  1081. if (descriptor.get) {
  1082. return descriptor.get.call(receiver);
  1083. }
  1084. return descriptor.value;
  1085. }
  1086. `;
  1087. helpers.classApplyDescriptorSet = helper("7.13.10")`
  1088. export default function _classApplyDescriptorSet(receiver, descriptor, value) {
  1089. if (descriptor.set) {
  1090. descriptor.set.call(receiver, value);
  1091. } else {
  1092. if (!descriptor.writable) {
  1093. // This should only throw in strict mode, but class bodies are
  1094. // always strict and private fields can only be used inside
  1095. // class bodies.
  1096. throw new TypeError("attempted to set read only private field");
  1097. }
  1098. descriptor.value = value;
  1099. }
  1100. }
  1101. `;
  1102. helpers.classApplyDescriptorDestructureSet = helper("7.13.10")`
  1103. export default function _classApplyDescriptorDestructureSet(receiver, descriptor) {
  1104. if (descriptor.set) {
  1105. if (!("__destrObj" in descriptor)) {
  1106. descriptor.__destrObj = {
  1107. set value(v) {
  1108. descriptor.set.call(receiver, v)
  1109. },
  1110. };
  1111. }
  1112. return descriptor.__destrObj;
  1113. } else {
  1114. if (!descriptor.writable) {
  1115. // This should only throw in strict mode, but class bodies are
  1116. // always strict and private fields can only be used inside
  1117. // class bodies.
  1118. throw new TypeError("attempted to set read only private field");
  1119. }
  1120. return descriptor;
  1121. }
  1122. }
  1123. `;
  1124. helpers.classStaticPrivateFieldDestructureSet = helper("7.13.10")`
  1125. import classApplyDescriptorDestructureSet from "classApplyDescriptorDestructureSet";
  1126. import classCheckPrivateStaticAccess from "classCheckPrivateStaticAccess";
  1127. import classCheckPrivateStaticFieldDescriptor from "classCheckPrivateStaticFieldDescriptor";
  1128. export default function _classStaticPrivateFieldDestructureSet(receiver, classConstructor, descriptor) {
  1129. classCheckPrivateStaticAccess(receiver, classConstructor);
  1130. classCheckPrivateStaticFieldDescriptor(descriptor, "set");
  1131. return classApplyDescriptorDestructureSet(receiver, descriptor);
  1132. }
  1133. `;
  1134. helpers.classCheckPrivateStaticAccess = helper("7.13.10")`
  1135. export default function _classCheckPrivateStaticAccess(receiver, classConstructor) {
  1136. if (receiver !== classConstructor) {
  1137. throw new TypeError("Private static access of wrong provenance");
  1138. }
  1139. }
  1140. `;
  1141. helpers.classCheckPrivateStaticFieldDescriptor = helper("7.13.10")`
  1142. export default function _classCheckPrivateStaticFieldDescriptor(descriptor, action) {
  1143. if (descriptor === undefined) {
  1144. throw new TypeError("attempted to " + action + " private static field before its declaration");
  1145. }
  1146. }
  1147. `;
  1148. helpers.decorate = helper("7.1.5")`
  1149. import toArray from "toArray";
  1150. import toPropertyKey from "toPropertyKey";
  1151. // These comments are stripped by @babel/template
  1152. /*::
  1153. type PropertyDescriptor =
  1154. | {
  1155. value: any,
  1156. writable: boolean,
  1157. configurable: boolean,
  1158. enumerable: boolean,
  1159. }
  1160. | {
  1161. get?: () => any,
  1162. set?: (v: any) => void,
  1163. configurable: boolean,
  1164. enumerable: boolean,
  1165. };
  1166. type FieldDescriptor ={
  1167. writable: boolean,
  1168. configurable: boolean,
  1169. enumerable: boolean,
  1170. };
  1171. type Placement = "static" | "prototype" | "own";
  1172. type Key = string | symbol; // PrivateName is not supported yet.
  1173. type ElementDescriptor =
  1174. | {
  1175. kind: "method",
  1176. key: Key,
  1177. placement: Placement,
  1178. descriptor: PropertyDescriptor
  1179. }
  1180. | {
  1181. kind: "field",
  1182. key: Key,
  1183. placement: Placement,
  1184. descriptor: FieldDescriptor,
  1185. initializer?: () => any,
  1186. };
  1187. // This is exposed to the user code
  1188. type ElementObjectInput = ElementDescriptor & {
  1189. [@@toStringTag]?: "Descriptor"
  1190. };
  1191. // This is exposed to the user code
  1192. type ElementObjectOutput = ElementDescriptor & {
  1193. [@@toStringTag]?: "Descriptor"
  1194. extras?: ElementDescriptor[],
  1195. finisher?: ClassFinisher,
  1196. };
  1197. // This is exposed to the user code
  1198. type ClassObject = {
  1199. [@@toStringTag]?: "Descriptor",
  1200. kind: "class",
  1201. elements: ElementDescriptor[],
  1202. };
  1203. type ElementDecorator = (descriptor: ElementObjectInput) => ?ElementObjectOutput;
  1204. type ClassDecorator = (descriptor: ClassObject) => ?ClassObject;
  1205. type ClassFinisher = <A, B>(cl: Class<A>) => Class<B>;
  1206. // Only used by Babel in the transform output, not part of the spec.
  1207. type ElementDefinition =
  1208. | {
  1209. kind: "method",
  1210. value: any,
  1211. key: Key,
  1212. static?: boolean,
  1213. decorators?: ElementDecorator[],
  1214. }
  1215. | {
  1216. kind: "field",
  1217. value: () => any,
  1218. key: Key,
  1219. static?: boolean,
  1220. decorators?: ElementDecorator[],
  1221. };
  1222. declare function ClassFactory<C>(initialize: (instance: C) => void): {
  1223. F: Class<C>,
  1224. d: ElementDefinition[]
  1225. }
  1226. */
  1227. /*::
  1228. // Various combinations with/without extras and with one or many finishers
  1229. type ElementFinisherExtras = {
  1230. element: ElementDescriptor,
  1231. finisher?: ClassFinisher,
  1232. extras?: ElementDescriptor[],
  1233. };
  1234. type ElementFinishersExtras = {
  1235. element: ElementDescriptor,
  1236. finishers: ClassFinisher[],
  1237. extras: ElementDescriptor[],
  1238. };
  1239. type ElementsFinisher = {
  1240. elements: ElementDescriptor[],
  1241. finisher?: ClassFinisher,
  1242. };
  1243. type ElementsFinishers = {
  1244. elements: ElementDescriptor[],
  1245. finishers: ClassFinisher[],
  1246. };
  1247. */
  1248. /*::
  1249. type Placements = {
  1250. static: Key[],
  1251. prototype: Key[],
  1252. own: Key[],
  1253. };
  1254. */
  1255. // ClassDefinitionEvaluation (Steps 26-*)
  1256. export default function _decorate(
  1257. decorators /*: ClassDecorator[] */,
  1258. factory /*: ClassFactory */,
  1259. superClass /*: ?Class<*> */,
  1260. mixins /*: ?Array<Function> */,
  1261. ) /*: Class<*> */ {
  1262. var api = _getDecoratorsApi();
  1263. if (mixins) {
  1264. for (var i = 0; i < mixins.length; i++) {
  1265. api = mixins[i](api);
  1266. }
  1267. }
  1268. var r = factory(function initialize(O) {
  1269. api.initializeInstanceElements(O, decorated.elements);
  1270. }, superClass);
  1271. var decorated = api.decorateClass(
  1272. _coalesceClassElements(r.d.map(_createElementDescriptor)),
  1273. decorators,
  1274. );
  1275. api.initializeClassElements(r.F, decorated.elements);
  1276. return api.runClassFinishers(r.F, decorated.finishers);
  1277. }
  1278. function _getDecoratorsApi() {
  1279. _getDecoratorsApi = function() {
  1280. return api;
  1281. };
  1282. var api = {
  1283. elementsDefinitionOrder: [["method"], ["field"]],
  1284. // InitializeInstanceElements
  1285. initializeInstanceElements: function(
  1286. /*::<C>*/ O /*: C */,
  1287. elements /*: ElementDescriptor[] */,
  1288. ) {
  1289. ["method", "field"].forEach(function(kind) {
  1290. elements.forEach(function(element /*: ElementDescriptor */) {
  1291. if (element.kind === kind && element.placement === "own") {
  1292. this.defineClassElement(O, element);
  1293. }
  1294. }, this);
  1295. }, this);
  1296. },
  1297. // InitializeClassElements
  1298. initializeClassElements: function(
  1299. /*::<C>*/ F /*: Class<C> */,
  1300. elements /*: ElementDescriptor[] */,
  1301. ) {
  1302. var proto = F.prototype;
  1303. ["method", "field"].forEach(function(kind) {
  1304. elements.forEach(function(element /*: ElementDescriptor */) {
  1305. var placement = element.placement;
  1306. if (
  1307. element.kind === kind &&
  1308. (placement === "static" || placement === "prototype")
  1309. ) {
  1310. var receiver = placement === "static" ? F : proto;
  1311. this.defineClassElement(receiver, element);
  1312. }
  1313. }, this);
  1314. }, this);
  1315. },
  1316. // DefineClassElement
  1317. defineClassElement: function(
  1318. /*::<C>*/ receiver /*: C | Class<C> */,
  1319. element /*: ElementDescriptor */,
  1320. ) {
  1321. var descriptor /*: PropertyDescriptor */ = element.descriptor;
  1322. if (element.kind === "field") {
  1323. var initializer = element.initializer;
  1324. descriptor = {
  1325. enumerable: descriptor.enumerable,
  1326. writable: descriptor.writable,
  1327. configurable: descriptor.configurable,
  1328. value: initializer === void 0 ? void 0 : initializer.call(receiver),
  1329. };
  1330. }
  1331. Object.defineProperty(receiver, element.key, descriptor);
  1332. },
  1333. // DecorateClass
  1334. decorateClass: function(
  1335. elements /*: ElementDescriptor[] */,
  1336. decorators /*: ClassDecorator[] */,
  1337. ) /*: ElementsFinishers */ {
  1338. var newElements /*: ElementDescriptor[] */ = [];
  1339. var finishers /*: ClassFinisher[] */ = [];
  1340. var placements /*: Placements */ = {
  1341. static: [],
  1342. prototype: [],
  1343. own: [],
  1344. };
  1345. elements.forEach(function(element /*: ElementDescriptor */) {
  1346. this.addElementPlacement(element, placements);
  1347. }, this);
  1348. elements.forEach(function(element /*: ElementDescriptor */) {
  1349. if (!_hasDecorators(element)) return newElements.push(element);
  1350. var elementFinishersExtras /*: ElementFinishersExtras */ = this.decorateElement(
  1351. element,
  1352. placements,
  1353. );
  1354. newElements.push(elementFinishersExtras.element);
  1355. newElements.push.apply(newElements, elementFinishersExtras.extras);
  1356. finishers.push.apply(finishers, elementFinishersExtras.finishers);
  1357. }, this);
  1358. if (!decorators) {
  1359. return { elements: newElements, finishers: finishers };
  1360. }
  1361. var result /*: ElementsFinishers */ = this.decorateConstructor(
  1362. newElements,
  1363. decorators,
  1364. );
  1365. finishers.push.apply(finishers, result.finishers);
  1366. result.finishers = finishers;
  1367. return result;
  1368. },
  1369. // AddElementPlacement
  1370. addElementPlacement: function(
  1371. element /*: ElementDescriptor */,
  1372. placements /*: Placements */,
  1373. silent /*: boolean */,
  1374. ) {
  1375. var keys = placements[element.placement];
  1376. if (!silent && keys.indexOf(element.key) !== -1) {
  1377. throw new TypeError("Duplicated element (" + element.key + ")");
  1378. }
  1379. keys.push(element.key);
  1380. },
  1381. // DecorateElement
  1382. decorateElement: function(
  1383. element /*: ElementDescriptor */,
  1384. placements /*: Placements */,
  1385. ) /*: ElementFinishersExtras */ {
  1386. var extras /*: ElementDescriptor[] */ = [];
  1387. var finishers /*: ClassFinisher[] */ = [];
  1388. for (
  1389. var decorators = element.decorators, i = decorators.length - 1;
  1390. i >= 0;
  1391. i--
  1392. ) {
  1393. // (inlined) RemoveElementPlacement
  1394. var keys = placements[element.placement];
  1395. keys.splice(keys.indexOf(element.key), 1);
  1396. var elementObject /*: ElementObjectInput */ = this.fromElementDescriptor(
  1397. element,
  1398. );
  1399. var elementFinisherExtras /*: ElementFinisherExtras */ = this.toElementFinisherExtras(
  1400. (0, decorators[i])(elementObject) /*: ElementObjectOutput */ ||
  1401. elementObject,
  1402. );
  1403. element = elementFinisherExtras.element;
  1404. this.addElementPlacement(element, placements);
  1405. if (elementFinisherExtras.finisher) {
  1406. finishers.push(elementFinisherExtras.finisher);
  1407. }
  1408. var newExtras /*: ElementDescriptor[] | void */ =
  1409. elementFinisherExtras.extras;
  1410. if (newExtras) {
  1411. for (var j = 0; j < newExtras.length; j++) {
  1412. this.addElementPlacement(newExtras[j], placements);
  1413. }
  1414. extras.push.apply(extras, newExtras);
  1415. }
  1416. }
  1417. return { element: element, finishers: finishers, extras: extras };
  1418. },
  1419. // DecorateConstructor
  1420. decorateConstructor: function(
  1421. elements /*: ElementDescriptor[] */,
  1422. decorators /*: ClassDecorator[] */,
  1423. ) /*: ElementsFinishers */ {
  1424. var finishers /*: ClassFinisher[] */ = [];
  1425. for (var i = decorators.length - 1; i >= 0; i--) {
  1426. var obj /*: ClassObject */ = this.fromClassDescriptor(elements);
  1427. var elementsAndFinisher /*: ElementsFinisher */ = this.toClassDescriptor(
  1428. (0, decorators[i])(obj) /*: ClassObject */ || obj,
  1429. );
  1430. if (elementsAndFinisher.finisher !== undefined) {
  1431. finishers.push(elementsAndFinisher.finisher);
  1432. }
  1433. if (elementsAndFinisher.elements !== undefined) {
  1434. elements = elementsAndFinisher.elements;
  1435. for (var j = 0; j < elements.length - 1; j++) {
  1436. for (var k = j + 1; k < elements.length; k++) {
  1437. if (
  1438. elements[j].key === elements[k].key &&
  1439. elements[j].placement === elements[k].placement
  1440. ) {
  1441. throw new TypeError(
  1442. "Duplicated element (" + elements[j].key + ")",
  1443. );
  1444. }
  1445. }
  1446. }
  1447. }
  1448. }
  1449. return { elements: elements, finishers: finishers };
  1450. },
  1451. // FromElementDescriptor
  1452. fromElementDescriptor: function(
  1453. element /*: ElementDescriptor */,
  1454. ) /*: ElementObject */ {
  1455. var obj /*: ElementObject */ = {
  1456. kind: element.kind,
  1457. key: element.key,
  1458. placement: element.placement,
  1459. descriptor: element.descriptor,
  1460. };
  1461. var desc = {
  1462. value: "Descriptor",
  1463. configurable: true,
  1464. };
  1465. Object.defineProperty(obj, Symbol.toStringTag, desc);
  1466. if (element.kind === "field") obj.initializer = element.initializer;
  1467. return obj;
  1468. },
  1469. // ToElementDescriptors
  1470. toElementDescriptors: function(
  1471. elementObjects /*: ElementObject[] */,
  1472. ) /*: ElementDescriptor[] */ {
  1473. if (elementObjects === undefined) return;
  1474. return toArray(elementObjects).map(function(elementObject) {
  1475. var element = this.toElementDescriptor(elementObject);
  1476. this.disallowProperty(elementObject, "finisher", "An element descriptor");
  1477. this.disallowProperty(elementObject, "extras", "An element descriptor");
  1478. return element;
  1479. }, this);
  1480. },
  1481. // ToElementDescriptor
  1482. toElementDescriptor: function(
  1483. elementObject /*: ElementObject */,
  1484. ) /*: ElementDescriptor */ {
  1485. var kind = String(elementObject.kind);
  1486. if (kind !== "method" && kind !== "field") {
  1487. throw new TypeError(
  1488. 'An element descriptor\\'s .kind property must be either "method" or' +
  1489. ' "field", but a decorator created an element descriptor with' +
  1490. ' .kind "' +
  1491. kind +
  1492. '"',
  1493. );
  1494. }
  1495. var key = toPropertyKey(elementObject.key);
  1496. var placement = String(elementObject.placement);
  1497. if (
  1498. placement !== "static" &&
  1499. placement !== "prototype" &&
  1500. placement !== "own"
  1501. ) {
  1502. throw new TypeError(
  1503. 'An element descriptor\\'s .placement property must be one of "static",' +
  1504. ' "prototype" or "own", but a decorator created an element descriptor' +
  1505. ' with .placement "' +
  1506. placement +
  1507. '"',
  1508. );
  1509. }
  1510. var descriptor /*: PropertyDescriptor */ = elementObject.descriptor;
  1511. this.disallowProperty(elementObject, "elements", "An element descriptor");
  1512. var element /*: ElementDescriptor */ = {
  1513. kind: kind,
  1514. key: key,
  1515. placement: placement,
  1516. descriptor: Object.assign({}, descriptor),
  1517. };
  1518. if (kind !== "field") {
  1519. this.disallowProperty(elementObject, "initializer", "A method descriptor");
  1520. } else {
  1521. this.disallowProperty(
  1522. descriptor,
  1523. "get",
  1524. "The property descriptor of a field descriptor",
  1525. );
  1526. this.disallowProperty(
  1527. descriptor,
  1528. "set",
  1529. "The property descriptor of a field descriptor",
  1530. );
  1531. this.disallowProperty(
  1532. descriptor,
  1533. "value",
  1534. "The property descriptor of a field descriptor",
  1535. );
  1536. element.initializer = elementObject.initializer;
  1537. }
  1538. return element;
  1539. },
  1540. toElementFinisherExtras: function(
  1541. elementObject /*: ElementObject */,
  1542. ) /*: ElementFinisherExtras */ {
  1543. var element /*: ElementDescriptor */ = this.toElementDescriptor(
  1544. elementObject,
  1545. );
  1546. var finisher /*: ClassFinisher */ = _optionalCallableProperty(
  1547. elementObject,
  1548. "finisher",
  1549. );
  1550. var extras /*: ElementDescriptors[] */ = this.toElementDescriptors(
  1551. elementObject.extras,
  1552. );
  1553. return { element: element, finisher: finisher, extras: extras };
  1554. },
  1555. // FromClassDescriptor
  1556. fromClassDescriptor: function(
  1557. elements /*: ElementDescriptor[] */,
  1558. ) /*: ClassObject */ {
  1559. var obj = {
  1560. kind: "class",
  1561. elements: elements.map(this.fromElementDescriptor, this),
  1562. };
  1563. var desc = { value: "Descriptor", configurable: true };
  1564. Object.defineProperty(obj, Symbol.toStringTag, desc);
  1565. return obj;
  1566. },
  1567. // ToClassDescriptor
  1568. toClassDescriptor: function(
  1569. obj /*: ClassObject */,
  1570. ) /*: ElementsFinisher */ {
  1571. var kind = String(obj.kind);
  1572. if (kind !== "class") {
  1573. throw new TypeError(
  1574. 'A class descriptor\\'s .kind property must be "class", but a decorator' +
  1575. ' created a class descriptor with .kind "' +
  1576. kind +
  1577. '"',
  1578. );
  1579. }
  1580. this.disallowProperty(obj, "key", "A class descriptor");
  1581. this.disallowProperty(obj, "placement", "A class descriptor");
  1582. this.disallowProperty(obj, "descriptor", "A class descriptor");
  1583. this.disallowProperty(obj, "initializer", "A class descriptor");
  1584. this.disallowProperty(obj, "extras", "A class descriptor");
  1585. var finisher = _optionalCallableProperty(obj, "finisher");
  1586. var elements = this.toElementDescriptors(obj.elements);
  1587. return { elements: elements, finisher: finisher };
  1588. },
  1589. // RunClassFinishers
  1590. runClassFinishers: function(
  1591. constructor /*: Class<*> */,
  1592. finishers /*: ClassFinisher[] */,
  1593. ) /*: Class<*> */ {
  1594. for (var i = 0; i < finishers.length; i++) {
  1595. var newConstructor /*: ?Class<*> */ = (0, finishers[i])(constructor);
  1596. if (newConstructor !== undefined) {
  1597. // NOTE: This should check if IsConstructor(newConstructor) is false.
  1598. if (typeof newConstructor !== "function") {
  1599. throw new TypeError("Finishers must return a constructor.");
  1600. }
  1601. constructor = newConstructor;
  1602. }
  1603. }
  1604. return constructor;
  1605. },
  1606. disallowProperty: function(obj, name, objectType) {
  1607. if (obj[name] !== undefined) {
  1608. throw new TypeError(objectType + " can't have a ." + name + " property.");
  1609. }
  1610. }
  1611. };
  1612. return api;
  1613. }
  1614. // ClassElementEvaluation
  1615. function _createElementDescriptor(
  1616. def /*: ElementDefinition */,
  1617. ) /*: ElementDescriptor */ {
  1618. var key = toPropertyKey(def.key);
  1619. var descriptor /*: PropertyDescriptor */;
  1620. if (def.kind === "method") {
  1621. descriptor = {
  1622. value: def.value,
  1623. writable: true,
  1624. configurable: true,
  1625. enumerable: false,
  1626. };
  1627. } else if (def.kind === "get") {
  1628. descriptor = { get: def.value, configurable: true, enumerable: false };
  1629. } else if (def.kind === "set") {
  1630. descriptor = { set: def.value, configurable: true, enumerable: false };
  1631. } else if (def.kind === "field") {
  1632. descriptor = { configurable: true, writable: true, enumerable: true };
  1633. }
  1634. var element /*: ElementDescriptor */ = {
  1635. kind: def.kind === "field" ? "field" : "method",
  1636. key: key,
  1637. placement: def.static
  1638. ? "static"
  1639. : def.kind === "field"
  1640. ? "own"
  1641. : "prototype",
  1642. descriptor: descriptor,
  1643. };
  1644. if (def.decorators) element.decorators = def.decorators;
  1645. if (def.kind === "field") element.initializer = def.value;
  1646. return element;
  1647. }
  1648. // CoalesceGetterSetter
  1649. function _coalesceGetterSetter(
  1650. element /*: ElementDescriptor */,
  1651. other /*: ElementDescriptor */,
  1652. ) {
  1653. if (element.descriptor.get !== undefined) {
  1654. other.descriptor.get = element.descriptor.get;
  1655. } else {
  1656. other.descriptor.set = element.descriptor.set;
  1657. }
  1658. }
  1659. // CoalesceClassElements
  1660. function _coalesceClassElements(
  1661. elements /*: ElementDescriptor[] */,
  1662. ) /*: ElementDescriptor[] */ {
  1663. var newElements /*: ElementDescriptor[] */ = [];
  1664. var isSameElement = function(
  1665. other /*: ElementDescriptor */,
  1666. ) /*: boolean */ {
  1667. return (
  1668. other.kind === "method" &&
  1669. other.key === element.key &&
  1670. other.placement === element.placement
  1671. );
  1672. };
  1673. for (var i = 0; i < elements.length; i++) {
  1674. var element /*: ElementDescriptor */ = elements[i];
  1675. var other /*: ElementDescriptor */;
  1676. if (
  1677. element.kind === "method" &&
  1678. (other = newElements.find(isSameElement))
  1679. ) {
  1680. if (
  1681. _isDataDescriptor(element.descriptor) ||
  1682. _isDataDescriptor(other.descriptor)
  1683. ) {
  1684. if (_hasDecorators(element) || _hasDecorators(other)) {
  1685. throw new ReferenceError(
  1686. "Duplicated methods (" + element.key + ") can't be decorated.",
  1687. );
  1688. }
  1689. other.descriptor = element.descriptor;
  1690. } else {
  1691. if (_hasDecorators(element)) {
  1692. if (_hasDecorators(other)) {
  1693. throw new ReferenceError(
  1694. "Decorators can't be placed on different accessors with for " +
  1695. "the same property (" +
  1696. element.key +
  1697. ").",
  1698. );
  1699. }
  1700. other.decorators = element.decorators;
  1701. }
  1702. _coalesceGetterSetter(element, other);
  1703. }
  1704. } else {
  1705. newElements.push(element);
  1706. }
  1707. }
  1708. return newElements;
  1709. }
  1710. function _hasDecorators(element /*: ElementDescriptor */) /*: boolean */ {
  1711. return element.decorators && element.decorators.length;
  1712. }
  1713. function _isDataDescriptor(desc /*: PropertyDescriptor */) /*: boolean */ {
  1714. return (
  1715. desc !== undefined &&
  1716. !(desc.value === undefined && desc.writable === undefined)
  1717. );
  1718. }
  1719. function _optionalCallableProperty /*::<T>*/(
  1720. obj /*: T */,
  1721. name /*: $Keys<T> */,
  1722. ) /*: ?Function */ {
  1723. var value = obj[name];
  1724. if (value !== undefined && typeof value !== "function") {
  1725. throw new TypeError("Expected '" + name + "' to be a function");
  1726. }
  1727. return value;
  1728. }
  1729. `;
  1730. helpers.classPrivateMethodGet = helper("7.1.6")`
  1731. export default function _classPrivateMethodGet(receiver, privateSet, fn) {
  1732. if (!privateSet.has(receiver)) {
  1733. throw new TypeError("attempted to get private field on non-instance");
  1734. }
  1735. return fn;
  1736. }
  1737. `;
  1738. {
  1739. helpers.classPrivateMethodSet = helper("7.1.6")`
  1740. export default function _classPrivateMethodSet() {
  1741. throw new TypeError("attempted to reassign private method");
  1742. }
  1743. `;
  1744. }